xgplayer-mp4 1.2.4 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.js +1 -1
- package/browser/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/constants.js +14 -0
- package/src/fmp4/buffer.js +6 -0
- package/src/fmp4/mp4.js +181 -84
- package/src/gap_jump.js +151 -0
- package/src/index.js +550 -315
- package/src/media/mse.js +77 -22
- package/src/media/task.js +68 -17
- package/src/mp4.js +284 -268
- package/src/parse/box/MP4DecConfigDescrTag.js +3 -0
- package/src/parse/box/MP4DecSpecificDescrTag.js +4 -0
- package/src/parse/box/avcC.js +4 -1
- package/src/parse/box/elst.js +0 -13
- package/src/parse/box/esds.js +9 -4
- package/src/parse/box/frma.js +10 -0
- package/src/parse/box/golomb.js +88 -0
- package/src/parse/box/hvc1.js +30 -0
- package/src/parse/box/hvcC.js +55 -0
- package/src/parse/box/pasp.js +2 -3
- package/src/parse/box/schm.js +18 -0
- package/src/parse/box/sps.js +286 -0
- package/src/parse/box/stsz.js +6 -1
- package/src/parse/box/tfhd.js +43 -0
- package/src/parse/box.js +5 -1
- package/src/parse/stream.js +4 -0
- package/src/util/getHeaders.js +18 -0
- package/src/util/index.js +138 -20
- package/src/util/intervalTimer.js +36 -0
- package/src/util/isSupport.js +20 -0
- package/src/util/proxyPromise.js +27 -0
- package/src/util/timer.js +46 -0
- package/src/util/xhr.js +46 -0
- package/version.json +1 -1
- package/webpack.config.js +45 -39
- package/src/util/download.js +0 -13
- package/src/write/box/MP4DecConfigDescrTag.js +0 -21
- package/src/write/box/MP4DecSpecificDescrTag.js +0 -19
- package/src/write/box/MP4ESDescrTag.js +0 -19
- package/src/write/box/SLConfigDescriptor.js +0 -16
- package/src/write/box/avc1.js +0 -33
- package/src/write/box/avcC.js +0 -32
- package/src/write/box/btrt.js +0 -14
- package/src/write/box/co64.js +0 -17
- package/src/write/box/ctts.js +0 -19
- package/src/write/box/dref.js +0 -25
- package/src/write/box/elst.js +0 -27
- package/src/write/box/esds.js +0 -11
- package/src/write/box/ftyp.js +0 -17
- package/src/write/box/hdlr.js +0 -15
- package/src/write/box/iods.js +0 -14
- package/src/write/box/mdat.js +0 -5
- package/src/write/box/mdhd.js +0 -27
- package/src/write/box/mehd.js +0 -12
- package/src/write/box/mfhd.js +0 -12
- package/src/write/box/mfro.js +0 -14
- package/src/write/box/mp4a.js +0 -26
- package/src/write/box/mvhd.js +0 -34
- package/src/write/box/pasp.js +0 -10
- package/src/write/box/smhd.js +0 -17
- package/src/write/box/stco.js +0 -17
- package/src/write/box/stsc.js +0 -19
- package/src/write/box/stsd.js +0 -23
- package/src/write/box/stss.js +0 -17
- package/src/write/box/stsz.js +0 -18
- package/src/write/box/stts.js +0 -18
- package/src/write/box/tfdt.js +0 -16
- package/src/write/box/tfhd.js +0 -18
- package/src/write/box/tfra.js +0 -29
- package/src/write/box/tkhd.js +0 -44
- package/src/write/box/trex.js +0 -16
- package/src/write/box/trun.js +0 -40
- package/src/write/box/udta.js +0 -5
- package/src/write/box/url.js +0 -16
- package/src/write/box/vmhd.js +0 -19
- package/src/write/box/wide.js +0 -12
- package/src/write/box.js +0 -37
- package/src/write/buffer.js +0 -12
- package/src/write/index.js +0 -33
- package/src/write/stream.js +0 -99
- package/webpack.config.test.js +0 -8
package/src/write/box/co64.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.co64 = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.count)
|
|
7
|
-
data.entries.forEach(item => {
|
|
8
|
-
stream.writeUint64(item)
|
|
9
|
-
})
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw new Error(`${data.type} box incomplete`)
|
|
13
|
-
} else {
|
|
14
|
-
this.outputSize = stream.position
|
|
15
|
-
}
|
|
16
|
-
delete this.data
|
|
17
|
-
}
|
package/src/write/box/ctts.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
|
|
3
|
-
Box.ctts = function (data, output) {
|
|
4
|
-
let stream = this.stream
|
|
5
|
-
stream.writeUint8(data.version)
|
|
6
|
-
stream.writeUint24(data.flag)
|
|
7
|
-
stream.writeUint32(data.entryCount)
|
|
8
|
-
data.entry.forEach(item => {
|
|
9
|
-
stream.writeUint32(item.count)
|
|
10
|
-
stream.writeUint32(item.offset)
|
|
11
|
-
})
|
|
12
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
13
|
-
if (stream.position !== data.size - 8) {
|
|
14
|
-
throw new Error(`${data.type} box incomplete`)
|
|
15
|
-
} else {
|
|
16
|
-
this.outputSize = stream.position
|
|
17
|
-
}
|
|
18
|
-
delete this.data
|
|
19
|
-
}
|
package/src/write/box/dref.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
|
|
3
|
-
Box.dref = function (data, output) {
|
|
4
|
-
let stream = this.stream
|
|
5
|
-
stream.writeUint8(data.version)
|
|
6
|
-
stream.writeUint24(data.flag)
|
|
7
|
-
stream.writeUint32(data.entryCount)
|
|
8
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
9
|
-
let self = this
|
|
10
|
-
data.subBox.forEach(item => {
|
|
11
|
-
let box = new Box(item, self.output)
|
|
12
|
-
self.subBox.push(box)
|
|
13
|
-
box.writeBody()
|
|
14
|
-
})
|
|
15
|
-
let writeSize = stream.position
|
|
16
|
-
self.subBox.forEach(item => {
|
|
17
|
-
writeSize += item.stream.position + 8
|
|
18
|
-
})
|
|
19
|
-
if (writeSize !== data.size - 8) {
|
|
20
|
-
throw new Error(`${data.type} box incomplete`)
|
|
21
|
-
} else {
|
|
22
|
-
this.outputSize = stream.position
|
|
23
|
-
}
|
|
24
|
-
delete this.data
|
|
25
|
-
}
|
package/src/write/box/elst.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
|
|
3
|
-
Box.elst = function (data, output) {
|
|
4
|
-
let stream = this.stream
|
|
5
|
-
stream.writeUint8(data.version)
|
|
6
|
-
stream.writeUint24(data.flag)
|
|
7
|
-
stream.writeUint32(data.entries.length)
|
|
8
|
-
let version = data.version
|
|
9
|
-
data.entries.forEach(item => {
|
|
10
|
-
if (version === 1) {
|
|
11
|
-
stream.writeUint64(item.segment_duration)
|
|
12
|
-
stream.writeUint64(item.media_time)
|
|
13
|
-
} else {
|
|
14
|
-
stream.writeUint32(item.segment_duration)
|
|
15
|
-
stream.writeInt32(item.media_time)
|
|
16
|
-
}
|
|
17
|
-
stream.writeInt16(item.media_rate_integer)
|
|
18
|
-
stream.writeInt16(item.media_rate_fraction)
|
|
19
|
-
})
|
|
20
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
21
|
-
if (stream.position !== data.size - 8) {
|
|
22
|
-
throw new Error(`${data.type} box incomplete`)
|
|
23
|
-
} else {
|
|
24
|
-
this.outputSize = stream.position
|
|
25
|
-
}
|
|
26
|
-
delete this.data
|
|
27
|
-
}
|
package/src/write/box/esds.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
|
|
3
|
-
Box.esds = function (data, output) {
|
|
4
|
-
let stream = this.stream
|
|
5
|
-
stream.writeUint8(data.version)
|
|
6
|
-
stream.writeUint24(data.flag)
|
|
7
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
8
|
-
Box.MP4ESDescrTag(data.subBox[0], output)
|
|
9
|
-
this.outputSize = data.size - 8
|
|
10
|
-
delete this.data
|
|
11
|
-
}
|
package/src/write/box/ftyp.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
|
|
3
|
-
Box.ftyp = function (data, output) {
|
|
4
|
-
let stream = this.stream
|
|
5
|
-
stream.writeStr(data.major_brand)
|
|
6
|
-
stream.writeUint32(data.minor_version)
|
|
7
|
-
data.compatible_brands.forEach(item => {
|
|
8
|
-
stream.writeStr(item)
|
|
9
|
-
})
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw `${data.type} box incomplete`
|
|
13
|
-
} else {
|
|
14
|
-
this.outputSize = stream.position
|
|
15
|
-
}
|
|
16
|
-
delete this.data
|
|
17
|
-
}
|
package/src/write/box/hdlr.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.hdlr = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.fill(4)
|
|
7
|
-
stream.writeStr(data.handleType)
|
|
8
|
-
stream.fill(12)
|
|
9
|
-
stream.writeStr(data.name)
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw new Error(`${data.type} box incomplete`)
|
|
13
|
-
}
|
|
14
|
-
delete this.data
|
|
15
|
-
}
|
package/src/write/box/iods.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.iods = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
data.content.forEach(item => {
|
|
7
|
-
stream.writeUint8(item)
|
|
8
|
-
})
|
|
9
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
10
|
-
if (stream.position !== data.size - 8) {
|
|
11
|
-
throw new Error(`${data.type} box incomplete`)
|
|
12
|
-
}
|
|
13
|
-
delete this.data
|
|
14
|
-
}
|
package/src/write/box/mdat.js
DELETED
package/src/write/box/mdhd.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mdhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
let version = data.version
|
|
7
|
-
if (version === 1) {
|
|
8
|
-
stream.writeUint64(data.create)
|
|
9
|
-
stream.writeUint64(data.modify)
|
|
10
|
-
stream.writeUint32(data.timescale)
|
|
11
|
-
stream.writeUint64(data.duration)
|
|
12
|
-
} else {
|
|
13
|
-
stream.writeUint32(data.create)
|
|
14
|
-
stream.writeUint32(data.modify)
|
|
15
|
-
stream.writeUint32(data.timescale)
|
|
16
|
-
stream.writeUint32(data.duration)
|
|
17
|
-
}
|
|
18
|
-
stream.writeUint16(data.language)
|
|
19
|
-
stream.writeUint16()
|
|
20
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
21
|
-
if (stream.position !== data.size - 8) {
|
|
22
|
-
throw new Error(`${data.type} box incomplete`)
|
|
23
|
-
} else {
|
|
24
|
-
this.outputSize = stream.position
|
|
25
|
-
}
|
|
26
|
-
delete this.data
|
|
27
|
-
}
|
package/src/write/box/mehd.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mehd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.duration)
|
|
7
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
8
|
-
if (stream.position !== data.size - 8) {
|
|
9
|
-
throw new Error(`${data.type} box incomplete`)
|
|
10
|
-
}
|
|
11
|
-
delete this.data
|
|
12
|
-
}
|
package/src/write/box/mfhd.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mfhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.sequence)
|
|
7
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
8
|
-
if (stream.position !== data.size - 8) {
|
|
9
|
-
throw new Error(`${data.type} box incomplete`)
|
|
10
|
-
}
|
|
11
|
-
delete this.data
|
|
12
|
-
}
|
package/src/write/box/mfro.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mfro = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.dsize)
|
|
7
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
8
|
-
if (stream.position !== data.size - 8) {
|
|
9
|
-
throw new Error(`${data.type} box incomplete`)
|
|
10
|
-
} else {
|
|
11
|
-
this.outputSize = stream.position
|
|
12
|
-
}
|
|
13
|
-
delete this.data
|
|
14
|
-
}
|
package/src/write/box/mp4a.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mp4a = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
let self = this
|
|
5
|
-
stream.fill(6)
|
|
6
|
-
stream.writeUint16(data.dataReferenceIndex)
|
|
7
|
-
stream.fill(8)
|
|
8
|
-
stream.writeUint16(data.channelCount)
|
|
9
|
-
stream.writeUint16(data.sampleSize)
|
|
10
|
-
stream.fill(4)
|
|
11
|
-
stream.writeUint32(data.sampleRate)
|
|
12
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
13
|
-
let outputSize = stream.position
|
|
14
|
-
data.subBox.forEach(item => {
|
|
15
|
-
let box = new Box(item, self.output)
|
|
16
|
-
self.subBox.push(box)
|
|
17
|
-
box.writeBody()
|
|
18
|
-
outputSize += box.outputSize + 8
|
|
19
|
-
})
|
|
20
|
-
if (outputSize !== data.size - 8) {
|
|
21
|
-
throw new Error(`${data.type} box incomplete,outputSize=${outputSize},size=${data.size}`)
|
|
22
|
-
} else {
|
|
23
|
-
this.outputSize = outputSize
|
|
24
|
-
}
|
|
25
|
-
delete this.data
|
|
26
|
-
}
|
package/src/write/box/mvhd.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.mvhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
|
|
5
|
-
stream.writeUint8(data.version)
|
|
6
|
-
stream.writeUint24(data.flag)
|
|
7
|
-
stream.writeUint32(data.create)
|
|
8
|
-
stream.writeUint32(data.modify)
|
|
9
|
-
stream.writeUint32(data.timeScale)
|
|
10
|
-
stream.writeUint32(data.duration)
|
|
11
|
-
|
|
12
|
-
let rate = data.rate.split('.')
|
|
13
|
-
let volume = data.volume.split('.')
|
|
14
|
-
stream.writeUint16(rate[0])
|
|
15
|
-
stream.writeUint16(rate[1])
|
|
16
|
-
stream.writeUint8(volume[0])
|
|
17
|
-
stream.writeUint8(volume[1])
|
|
18
|
-
stream.fill(10)
|
|
19
|
-
data.matrix.forEach(item => {
|
|
20
|
-
let matrix
|
|
21
|
-
matrix = item.split('.')
|
|
22
|
-
stream.writeUint16(matrix[0])
|
|
23
|
-
stream.writeUint16(matrix[1])
|
|
24
|
-
})
|
|
25
|
-
stream.fill(24)
|
|
26
|
-
stream.writeUint32(data.nextTrackID)
|
|
27
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
28
|
-
if (stream.position !== data.size - 8) {
|
|
29
|
-
throw new Error(`${data.type} box incomplete`)
|
|
30
|
-
} else {
|
|
31
|
-
this.outputSize = stream.position
|
|
32
|
-
}
|
|
33
|
-
delete this.data
|
|
34
|
-
}
|
package/src/write/box/pasp.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.pasp = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.position = data.content.byteLength
|
|
5
|
-
output.write(new Uint8Array(data.content))
|
|
6
|
-
if (data.content.byteLength !== data.size - 8) {
|
|
7
|
-
throw new Error(`${data.type} box incomplete`)
|
|
8
|
-
}
|
|
9
|
-
delete this.data
|
|
10
|
-
}
|
package/src/write/box/smhd.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.smhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
let balance = data.balance.split('.')
|
|
7
|
-
stream.writeUint8(balance[0])
|
|
8
|
-
stream.writeUint8(balance[1])
|
|
9
|
-
stream.fill(2)
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw new Error(`${data.type} box incomplete`)
|
|
13
|
-
} else {
|
|
14
|
-
this.outputSize = stream.position
|
|
15
|
-
}
|
|
16
|
-
delete this.data
|
|
17
|
-
}
|
package/src/write/box/stco.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stco = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.count)
|
|
7
|
-
data.entries.forEach(item => {
|
|
8
|
-
stream.writeUint32(item)
|
|
9
|
-
})
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw new Error(`${data.type} box incomplete`)
|
|
13
|
-
} else {
|
|
14
|
-
this.outputSize = stream.position
|
|
15
|
-
}
|
|
16
|
-
delete this.data
|
|
17
|
-
}
|
package/src/write/box/stsc.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stsc = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.count)
|
|
7
|
-
data.entries.forEach(item => {
|
|
8
|
-
stream.writeUint32(item.first_chunk)
|
|
9
|
-
stream.writeUint32(item.samples_per_chunk)
|
|
10
|
-
stream.writeUint32(item.sample_desc_index)
|
|
11
|
-
})
|
|
12
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
13
|
-
if (stream.position !== data.size - 8) {
|
|
14
|
-
throw new Error(`${data.type} box incomplete`)
|
|
15
|
-
} else {
|
|
16
|
-
this.outputSize = stream.position
|
|
17
|
-
}
|
|
18
|
-
delete this.data
|
|
19
|
-
}
|
package/src/write/box/stsd.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stsd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
let self = this
|
|
5
|
-
let outputSize = 0
|
|
6
|
-
stream.writeUint8(data.version)
|
|
7
|
-
stream.writeUint24(data.flag)
|
|
8
|
-
stream.writeUint32(data.entryCount)
|
|
9
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
10
|
-
outputSize = stream.position
|
|
11
|
-
data.subBox.forEach(item => {
|
|
12
|
-
let box = new Box(item, self.output)
|
|
13
|
-
self.subBox.push(box)
|
|
14
|
-
box.writeBody()
|
|
15
|
-
outputSize += box.outputSize + 8
|
|
16
|
-
})
|
|
17
|
-
if (outputSize !== data.size - 8) {
|
|
18
|
-
throw new Error(`${data.type} box incomplete`)
|
|
19
|
-
} else {
|
|
20
|
-
this.outputSize = outputSize
|
|
21
|
-
}
|
|
22
|
-
delete this.data
|
|
23
|
-
}
|
package/src/write/box/stss.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stss = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.count)
|
|
7
|
-
data.entries.forEach(item => {
|
|
8
|
-
stream.writeUint32(item)
|
|
9
|
-
})
|
|
10
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
11
|
-
if (stream.position !== data.size - 8) {
|
|
12
|
-
throw new Error(`${data.type} box incomplete`)
|
|
13
|
-
} else {
|
|
14
|
-
this.outputSize = stream.position
|
|
15
|
-
}
|
|
16
|
-
delete this.data
|
|
17
|
-
}
|
package/src/write/box/stsz.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stsz = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.sampleSize)
|
|
7
|
-
stream.writeUint32(data.count)
|
|
8
|
-
data.entries.forEach(item => {
|
|
9
|
-
stream.writeUint32(item)
|
|
10
|
-
})
|
|
11
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
12
|
-
if (stream.position !== data.size - 8) {
|
|
13
|
-
throw new Error(`${data.type} box incomplete`)
|
|
14
|
-
} else {
|
|
15
|
-
this.outputSize = stream.position
|
|
16
|
-
}
|
|
17
|
-
delete this.data
|
|
18
|
-
}
|
package/src/write/box/stts.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.stts = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.count)
|
|
7
|
-
data.entry.forEach(item => {
|
|
8
|
-
stream.writeUint32(item.sampleCount)
|
|
9
|
-
stream.writeUint32(item.sampleDuration)
|
|
10
|
-
})
|
|
11
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
12
|
-
if (stream.position !== data.size - 8) {
|
|
13
|
-
throw new Error(`${data.type} box incomplete`)
|
|
14
|
-
} else {
|
|
15
|
-
this.outputSize = stream.position
|
|
16
|
-
}
|
|
17
|
-
delete this.data
|
|
18
|
-
}
|
package/src/write/box/tfdt.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.tfdt = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
if (data.version === 0) {
|
|
7
|
-
stream.writeUint32(data.decodeTime)
|
|
8
|
-
} else {
|
|
9
|
-
stream.writeUint64(data.decodeTime)
|
|
10
|
-
}
|
|
11
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
12
|
-
if (stream.position !== data.size - 8) {
|
|
13
|
-
throw new Error(`${data.type} box incomplete`)
|
|
14
|
-
}
|
|
15
|
-
delete this.data
|
|
16
|
-
}
|
package/src/write/box/tfhd.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.tfhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.trackID)
|
|
7
|
-
if (data.sampleDuration) {
|
|
8
|
-
stream.writeUint32(data.sampleDuration)
|
|
9
|
-
}
|
|
10
|
-
if (data.sampleFlag) {
|
|
11
|
-
stream.writeUint32(data.sampleFlag)
|
|
12
|
-
}
|
|
13
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
14
|
-
if (stream.position !== data.size - 8) {
|
|
15
|
-
throw new Error(`${data.type} box incomplete`)
|
|
16
|
-
}
|
|
17
|
-
delete this.data
|
|
18
|
-
}
|
package/src/write/box/tfra.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.tfra = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.trackID)
|
|
7
|
-
stream.writeUint32(data.trafTurnSampleNumber)
|
|
8
|
-
stream.writeUint32(data.entries.length)
|
|
9
|
-
let version = data.version
|
|
10
|
-
data.entries.forEach(item => {
|
|
11
|
-
if (version === 1) {
|
|
12
|
-
stream.writeUint64(item.time)
|
|
13
|
-
stream.writeUint64(item.moofOffset)
|
|
14
|
-
} else {
|
|
15
|
-
stream.writeUint32(item.time)
|
|
16
|
-
stream.writeUint32(item.moofOffset)
|
|
17
|
-
}
|
|
18
|
-
stream.writeUint8(1)
|
|
19
|
-
stream.writeUint8(1)
|
|
20
|
-
stream.writeUint8(1)
|
|
21
|
-
})
|
|
22
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
23
|
-
if (stream.position !== data.size - 8) {
|
|
24
|
-
throw new Error(`${data.type} box incomplete`)
|
|
25
|
-
} else {
|
|
26
|
-
this.outputSize = stream.position
|
|
27
|
-
}
|
|
28
|
-
delete this.data
|
|
29
|
-
}
|
package/src/write/box/tkhd.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.tkhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
if (data.version === 1) {
|
|
7
|
-
stream.writeUint64(data.create)
|
|
8
|
-
stream.writeUint64(data.modify)
|
|
9
|
-
stream.writeUint32(data.trackID)
|
|
10
|
-
stream.writeUint32(data.reserverd)
|
|
11
|
-
stream.writeUint64(data.duration)
|
|
12
|
-
} else {
|
|
13
|
-
stream.writeUint32(data.create)
|
|
14
|
-
stream.writeUint32(data.modify)
|
|
15
|
-
stream.writeUint32(data.trackID)
|
|
16
|
-
stream.writeUint32(data.reserverd)
|
|
17
|
-
stream.writeUint32(data.duration)
|
|
18
|
-
}
|
|
19
|
-
stream.fill(8)
|
|
20
|
-
stream.writeInt16(data.layer)
|
|
21
|
-
stream.writeInt16(data.alternate_group)
|
|
22
|
-
stream.writeInt16(data.volume << 8)
|
|
23
|
-
stream.fill(2)
|
|
24
|
-
|
|
25
|
-
data.matrix.forEach(item => {
|
|
26
|
-
let matrix = item.split('.')
|
|
27
|
-
stream.writeUint16(matrix[0])
|
|
28
|
-
stream.writeUint16(matrix[1])
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
let width = data.width.split('.')
|
|
32
|
-
let height = data.height.split('.')
|
|
33
|
-
stream.writeUint16(width[0])
|
|
34
|
-
stream.writeUint16(width[1])
|
|
35
|
-
stream.writeUint16(height[0])
|
|
36
|
-
stream.writeUint16(height[1])
|
|
37
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
38
|
-
if (stream.position !== data.size - 8) {
|
|
39
|
-
throw new Error(`${data.type} box incomplete`)
|
|
40
|
-
} else {
|
|
41
|
-
this.outputSize = stream.position
|
|
42
|
-
}
|
|
43
|
-
delete this.data
|
|
44
|
-
}
|
package/src/write/box/trex.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.trex = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.trackID)
|
|
7
|
-
stream.writeUint32(data.index)
|
|
8
|
-
stream.writeUint32(data.duration)
|
|
9
|
-
stream.writeUint32(data.dsize)
|
|
10
|
-
stream.writeUint32(data.flags)
|
|
11
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
12
|
-
if (stream.position !== data.size - 8) {
|
|
13
|
-
throw new Error(`${data.type} box incomplete`)
|
|
14
|
-
}
|
|
15
|
-
delete this.data
|
|
16
|
-
}
|
package/src/write/box/trun.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.trun = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
stream.writeUint24(data.flag)
|
|
6
|
-
stream.writeUint32(data.sampleCount)
|
|
7
|
-
stream.writeInt32(data.dataOffset)
|
|
8
|
-
if (data.firstSampleFlags) {
|
|
9
|
-
stream.writeUint32(data.firstSampleFlags)
|
|
10
|
-
if (data.sampleDuration) {
|
|
11
|
-
data.samples.forEach(item => {
|
|
12
|
-
stream.writeUint32(item.size)
|
|
13
|
-
stream.writeUint32(item.offsetTime)
|
|
14
|
-
})
|
|
15
|
-
} else {
|
|
16
|
-
data.samples.forEach(item => {
|
|
17
|
-
stream.writeUint32(item.duration)
|
|
18
|
-
stream.writeUint32(item.size)
|
|
19
|
-
stream.writeUint32(item.offsetTime)
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
if (data.sampleDuration) {
|
|
24
|
-
data.samples.forEach(item => {
|
|
25
|
-
stream.writeUint32(item.size)
|
|
26
|
-
})
|
|
27
|
-
} else {
|
|
28
|
-
data.samples.forEach(item => {
|
|
29
|
-
stream.writeUint32(item.duration)
|
|
30
|
-
stream.writeUint32(item.size)
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
36
|
-
if (stream.position !== data.size - 8) {
|
|
37
|
-
throw new Error(`${data.type} box incomplete`)
|
|
38
|
-
}
|
|
39
|
-
delete this.data
|
|
40
|
-
}
|
package/src/write/box/udta.js
DELETED
package/src/write/box/url.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box['url '] = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
data.flag.forEach(item => {
|
|
6
|
-
stream.writeUint8(item)
|
|
7
|
-
})
|
|
8
|
-
data.location.forEach(item => {
|
|
9
|
-
stream.writeUint8(item)
|
|
10
|
-
})
|
|
11
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
12
|
-
if (stream.position !== data.size - 8) {
|
|
13
|
-
throw new Error(`${data.type} box incomplete`)
|
|
14
|
-
}
|
|
15
|
-
delete this.data
|
|
16
|
-
}
|
package/src/write/box/vmhd.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.vmhd = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.writeUint8(data.version)
|
|
5
|
-
data.flag.forEach(item => {
|
|
6
|
-
stream.writeUint8(item)
|
|
7
|
-
})
|
|
8
|
-
stream.writeUint16(data.graphicsmode)
|
|
9
|
-
data.opcolor.forEach(item => {
|
|
10
|
-
stream.writeUint16(item)
|
|
11
|
-
})
|
|
12
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
13
|
-
if (stream.position !== data.size - 8) {
|
|
14
|
-
throw new Error(`${data.type} box incomplete`)
|
|
15
|
-
} else {
|
|
16
|
-
this.outputSize = stream.position
|
|
17
|
-
}
|
|
18
|
-
delete this.data
|
|
19
|
-
}
|
package/src/write/box/wide.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Box from '../box'
|
|
2
|
-
Box.wide = function (data, output) {
|
|
3
|
-
let stream = this.stream
|
|
4
|
-
stream.fill(data.size - 8)
|
|
5
|
-
output.write(new Uint8Array(stream.buffer.slice(0, stream.position)))
|
|
6
|
-
if (stream.position !== data.size - 8) {
|
|
7
|
-
throw new Error(`${data.type} box incomplete`)
|
|
8
|
-
} else {
|
|
9
|
-
this.outputSize = stream.position
|
|
10
|
-
}
|
|
11
|
-
delete this.data
|
|
12
|
-
}
|