├── .babelrc
├── .eslintrc
├── .gitignore
├── .travis.yml
├── README.md
├── how-it-works.png
├── jasmine.json
├── karma.conf.js
├── logo.png
├── package.json
├── src
├── IsoBmff
│ ├── Box
│ │ ├── AVCConfigurationBox.js
│ │ ├── AVCSampleEntry.js
│ │ ├── AudioSampleEntry.js
│ │ ├── Box.js
│ │ ├── ChunkOffsetBox.js
│ │ ├── CompactSampleSizeBox.js
│ │ ├── DataEntryUrlBox.js
│ │ ├── DataEntryUrnBox.js
│ │ ├── DataInformationBox.js
│ │ ├── DataReferenceBox.js
│ │ ├── ESDBox.js
│ │ ├── EditBox.js
│ │ ├── EditListBox.js
│ │ ├── File.js
│ │ ├── FileTypeBox.js
│ │ ├── FullBox.js
│ │ ├── HandlerReferenceBox.js
│ │ ├── HintMediaHeaderBox.js
│ │ ├── MP4AudioSampleEntry.js
│ │ ├── MPEG4BitRateBox.js
│ │ ├── MediaBox.js
│ │ ├── MediaDataBox.js
│ │ ├── MediaHeaderBox.js
│ │ ├── MediaInformationBox.js
│ │ ├── MovieBox.js
│ │ ├── MovieExtendsBox.js
│ │ ├── MovieExtendsHeaderBox.js
│ │ ├── MovieFragmentBox.js
│ │ ├── MovieFragmentHeaderBox.js
│ │ ├── MovieHeaderBox.js
│ │ ├── NullMediaHeaderBox.js
│ │ ├── SampleDescriptionBox.js
│ │ ├── SampleEntry.js
│ │ ├── SampleSizeBox.js
│ │ ├── SampleTableBox.js
│ │ ├── SampleToChunkBox.js
│ │ ├── SoundMediaHeaderBox.js
│ │ ├── SyncSampleBox.js
│ │ ├── TimeToSampleBox.js
│ │ ├── TrackBox.js
│ │ ├── TrackExtendsBox.js
│ │ ├── TrackFragmentBaseMediaDecodeTimeBox.js
│ │ ├── TrackFragmentBox.js
│ │ ├── TrackFragmentHeaderBox.js
│ │ ├── TrackHeaderBox.js
│ │ ├── TrackRunBox.js
│ │ ├── UnknownBox.js
│ │ ├── VideoMediaHeaderBox.js
│ │ └── VisualSampleEntry.js
│ └── index.js
├── Matroska
│ ├── EBMLElement
│ │ ├── AESSettingsCipherMode.js
│ │ ├── AlphaMode.js
│ │ ├── AspectRatioType.js
│ │ ├── Audio.js
│ │ ├── BitDepth.js
│ │ ├── Block.js
│ │ ├── BlockAddID.js
│ │ ├── BlockAdditional.js
│ │ ├── BlockAdditions.js
│ │ ├── BlockDuration.js
│ │ ├── BlockGroup.js
│ │ ├── BlockMore.js
│ │ ├── Channels.js
│ │ ├── ChapCountry.js
│ │ ├── ChapLanguage.js
│ │ ├── ChapString.js
│ │ ├── ChapterAtom.js
│ │ ├── ChapterDisplay.js
│ │ ├── ChapterStringUID.js
│ │ ├── ChapterTimeEnd.js
│ │ ├── ChapterTimeStart.js
│ │ ├── ChapterUID.js
│ │ ├── Chapters.js
│ │ ├── Cluster.js
│ │ ├── CodecDelay.js
│ │ ├── CodecID.js
│ │ ├── CodecName.js
│ │ ├── CodecPrivate.js
│ │ ├── ContentEncAESSettings.js
│ │ ├── ContentEncAlgo.js
│ │ ├── ContentEncKeyID.js
│ │ ├── ContentEncoding.js
│ │ ├── ContentEncodingOrder.js
│ │ ├── ContentEncodingScope.js
│ │ ├── ContentEncodingType.js
│ │ ├── ContentEncodings.js
│ │ ├── ContentEncryption.js
│ │ ├── CueBlockNumber.js
│ │ ├── CueClusterPosition.js
│ │ ├── CueDuration.js
│ │ ├── CuePoint.js
│ │ ├── CueRelativePosition.js
│ │ ├── CueTime.js
│ │ ├── CueTrack.js
│ │ ├── CueTrackPositions.js
│ │ ├── Cues.js
│ │ ├── DateUTC.js
│ │ ├── DefaultDuration.js
│ │ ├── DiscardPadding.js
│ │ ├── DisplayHeight.js
│ │ ├── DisplayUnit.js
│ │ ├── DisplayWidth.js
│ │ ├── DocType.js
│ │ ├── DocTypeReadVersion.js
│ │ ├── DocTypeVersion.js
│ │ ├── Duration.js
│ │ ├── EBML.js
│ │ ├── EBMLMaxIDLength.js
│ │ ├── EBMLMaxSizeLength.js
│ │ ├── EBMLReadVersion.js
│ │ ├── EBMLVersion.js
│ │ ├── EditionEntry.js
│ │ ├── Element.js
│ │ ├── File.js
│ │ ├── FlagDefault.js
│ │ ├── FlagEnabled.js
│ │ ├── FlagForced.js
│ │ ├── FlagInterlaced.js
│ │ ├── FlagLacing.js
│ │ ├── Info.js
│ │ ├── Language.js
│ │ ├── MuxingApp.js
│ │ ├── Name.js
│ │ ├── OutputSamplingFrequency.js
│ │ ├── PixelCropBottom.js
│ │ ├── PixelCropLeft.js
│ │ ├── PixelCropRight.js
│ │ ├── PixelCropTop.js
│ │ ├── PixelHeight.js
│ │ ├── PixelWidth.js
│ │ ├── PrevSize.js
│ │ ├── ReferenceBlock.js
│ │ ├── SamplingFrequency.js
│ │ ├── Seek.js
│ │ ├── SeekHead.js
│ │ ├── SeekID.js
│ │ ├── SeekPosition.js
│ │ ├── SeekPreRoll.js
│ │ ├── Segment.js
│ │ ├── SegmentUID.js
│ │ ├── SimpleBlock.js
│ │ ├── SimpleTag.js
│ │ ├── StereoMode.js
│ │ ├── Tag.js
│ │ ├── TagBinary.js
│ │ ├── TagDefault.js
│ │ ├── TagLanguage.js
│ │ ├── TagName.js
│ │ ├── TagString.js
│ │ ├── TagTrackUID.js
│ │ ├── Tags.js
│ │ ├── TargetType.js
│ │ ├── TargetTypeValue.js
│ │ ├── Targets.js
│ │ ├── Timecode.js
│ │ ├── TimecodeScale.js
│ │ ├── Title.js
│ │ ├── TrackEntry.js
│ │ ├── TrackNumber.js
│ │ ├── TrackType.js
│ │ ├── TrackUID.js
│ │ ├── Tracks.js
│ │ ├── TypeBlock.js
│ │ ├── TypeBool.js
│ │ ├── TypeBytes.js
│ │ ├── TypeDate.js
│ │ ├── TypeElementId.js
│ │ ├── TypeFloat.js
│ │ ├── TypeInt.js
│ │ ├── TypeString.js
│ │ ├── TypeUInt.js
│ │ ├── Unknown.js
│ │ ├── Video.js
│ │ ├── Void.js
│ │ └── WritingApp.js
│ ├── ElementLookup.js
│ └── index.js
├── cli.js
├── core
│ ├── Buffer.js
│ ├── Component.js
│ ├── Error.js
│ ├── MediaFormat.js
│ ├── PropTypes.js
│ ├── Reader.js
│ ├── Stream.js
│ ├── Util.js
│ ├── Visitor.js
│ └── Writer.js
└── index.js
└── test
├── contents
└── Matroska
│ ├── README.txt
│ ├── test1.mkv
│ ├── test2.mkv
│ ├── test3.mkv
│ ├── test4.mkv
│ ├── test5.mkv
│ ├── test6.mkv
│ ├── test7.mkv
│ └── test8.mkv
├── helper
├── IsoBmff.js
├── Matroska.js
├── data.js
└── matcher.js
└── spec
├── IsoBmff
├── Box
│ ├── avcC.spec.js
│ ├── elst.spec.js
│ ├── file.spec.js
│ ├── ftyp.spec.js
│ ├── mdat.spec.js
│ ├── mehd.spec.js
│ ├── mfhd.spec.js
│ ├── mp4a.spec.js
│ ├── stco.spec.js
│ ├── stsc.spec.js
│ ├── stss.spec.js
│ ├── stsz.spec.js
│ ├── stz2.spec.js
│ ├── tfdt.spec.js
│ ├── tfhd.spec.js
│ ├── trex.spec.js
│ ├── trun.spec.js
│ └── unknown.spec.js
└── index.spec.js
├── Matroska
└── Element
│ ├── AESSettingsCipherMode.spec.js
│ ├── AlphaMode.spec.js
│ ├── AspectRatioType.spec.js
│ ├── Audio.spec.js
│ ├── BitDepth.spec.js
│ ├── Block.spec.js
│ ├── BlockAddID.spec.js
│ ├── BlockAdditional.spec.js
│ ├── BlockAdditions.spec.js
│ ├── BlockDuration.spec.js
│ ├── BlockGroup.spec.js
│ ├── BlockMore.spec.js
│ ├── Channels.spec.js
│ ├── ChapCountry.spec.js
│ ├── ChapLanguage.spec.js
│ ├── ChapString.spec.js
│ ├── ChapterAtom.spec.js
│ ├── ChapterDisplay.spec.js
│ ├── ChapterStringUID.spec.js
│ ├── ChapterTimeEnd.spec.js
│ ├── ChapterTimeStart.spec.js
│ ├── ChapterUID.spec.js
│ ├── Chapters.spec.js
│ ├── Cluster.spec.js
│ ├── CodecDelay.spec.js
│ ├── CodecID.spec.js
│ ├── CodecName.spec.js
│ ├── CodecPrivate.spec.js
│ ├── ContentEncAESSettings.spec.js
│ ├── ContentEncAlgo.spec.js
│ ├── ContentEncKeyID.spec.js
│ ├── ContentEncoding.spec.js
│ ├── ContentEncodingOrder.spec.js
│ ├── ContentEncodingScope.spec.js
│ ├── ContentEncodingType.spec.js
│ ├── ContentEncodings.spec.js
│ ├── ContentEncryption.spec.js
│ ├── CueBlockNumber.spec.js
│ ├── CueClusterPosition.spec.js
│ ├── CueDuration.spec.js
│ ├── CuePoint.spec.js
│ ├── CueRelativePosition.spec.js
│ ├── CueTime.spec.js
│ ├── CueTrack.spec.js
│ ├── CueTrackPositions.spec.js
│ ├── Cues.spec.js
│ ├── DateUTC.spec.js
│ ├── DefaultDuration.spec.js
│ ├── DiscardPadding.spec.js
│ ├── DisplayHeight.spec.js
│ ├── DisplayUnit.spec.js
│ ├── DisplayWidth.spec.js
│ ├── DocType.spec.js
│ ├── DocTypeReadVersion.spec.js
│ ├── DocTypeVersion.spec.js
│ ├── Duration.spec.js
│ ├── EBML.spec.js
│ ├── EBMLMaxIDLength.spec.js
│ ├── EBMLMaxSizeLength.spec.js
│ ├── EBMLReadVersion.spec.js
│ ├── EBMLVersion.spec.js
│ ├── EditionEntry.spec.js
│ ├── FlagDefault.spec.js
│ ├── FlagEnabled.spec.js
│ ├── FlagForced.spec.js
│ ├── FlagInterlaced.spec.js
│ ├── FlagLacing.spec.js
│ ├── Info.spec.js
│ ├── Language.spec.js
│ ├── MuxingApp.spec.js
│ ├── Name.spec.js
│ ├── OutputSamplingFrequency.spec.js
│ ├── PixelCropBottom.spec.js
│ ├── PixelCropLeft.spec.js
│ ├── PixelCropRight.spec.js
│ ├── PixelCropTop.spec.js
│ ├── PixelHeight.spec.js
│ ├── PixelWidth.spec.js
│ ├── PrevSize.spec.js
│ ├── ReferenceBlock.spec.js
│ ├── SamplingFrequency.spec.js
│ ├── Seek.spec.js
│ ├── SeekHead.spec.js
│ ├── SeekID.spec.js
│ ├── SeekPosition.spec.js
│ ├── SeekPreRoll.spec.js
│ ├── Segment.spec.js
│ ├── SegmentUID.spec.js
│ ├── SimpleBlock.spec.js
│ ├── SimpleTag.spec.js
│ ├── StereoMode.spec.js
│ ├── Tag.spec.js
│ ├── TagBinary.spec.js
│ ├── TagDefault.spec.js
│ ├── TagLanguage.spec.js
│ ├── TagName.spec.js
│ ├── TagString.spec.js
│ ├── TagTrackUID.spec.js
│ ├── Tags.spec.js
│ ├── TargetType.spec.js
│ ├── TargetTypeValue.spec.js
│ ├── Targets.spec.js
│ ├── Timecode.spec.js
│ ├── TimecodeScale.spec.js
│ ├── Title.spec.js
│ ├── TrackEntry.spec.js
│ ├── TrackNumber.spec.js
│ ├── TrackType.spec.js
│ ├── TrackUID.spec.js
│ ├── Tracks.spec.js
│ ├── Unknown.spec.js
│ ├── Video.spec.js
│ ├── Void.spec.js
│ └── WritingApp.spec.js
├── core
├── Reader.spec.js
├── Stream.spec.js
└── Writer.spec.js
└── index.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015"],
3 | "plugins": ["transform-kontainer-js"]
4 | }
5 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "node": true,
5 | "es6": true
6 | },
7 | "ecmaFeatures": {
8 | "sourceType": "module"
9 | },
10 | "parserOptions": {
11 | "sourceType": "module",
12 | "ecmaFeatures": {
13 | "jsx": true,
14 | "experimentalObjectRestSpread": true
15 | }
16 | },
17 | "rules": {
18 | "strict": 0,
19 | "quotes": [2, "single"],
20 | "new-cap": 0
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 | lib
29 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "4"
4 | - "node"
5 | sudo: required
6 | dist: trusty
7 | addons:
8 | apt:
9 | sources:
10 | - google-chrome
11 | packages:
12 | - google-chrome-stable
13 | before_install:
14 | - export CHROME_BIN=chromium-browser
15 | - export DISPLAY=:99.0
16 | - sh -e /etc/init.d/xvfb start
17 | - npm install -g npm
18 |
--------------------------------------------------------------------------------
/how-it-works.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/how-it-works.png
--------------------------------------------------------------------------------
/jasmine.json:
--------------------------------------------------------------------------------
1 | {
2 | "spec_dir": "./test/spec",
3 | "spec_files": [
4 | "**/*[sS]pec.js"
5 | ],
6 | "helpers": [
7 | "../../node_modules/jasmine-es6/lib/install.js",
8 | "../helper/**/*.js"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/logo.png
--------------------------------------------------------------------------------
/src/IsoBmff/Box/AVCSampleEntry.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import VisualSampleEntry from './VisualSampleEntry';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class AVCSampleEntry extends VisualSampleEntry {
6 | constructor(props) {
7 | super(AVCSampleEntry.COMPACT_NAME, props);
8 | }
9 |
10 | serialize(buffer, offset=0) {
11 | //console.log('--- AVCSampleEntry.serialize enter.');
12 | let base = offset;
13 |
14 | base += super.serialize(buffer, base);
15 | super.setSize(base - offset, buffer, offset);
16 |
17 | //console.log(`--- AVCSampleEntry.serialize exit. size=${this.size}`);
18 | return this.size;
19 | }
20 |
21 | static parse(buffer, offset=0) {
22 | let base = offset,
23 | readBytesNum, props;
24 |
25 | [readBytesNum, props] = VisualSampleEntry.parse(buffer, base);
26 | base += readBytesNum;
27 |
28 | return [base - offset, props];
29 | }
30 | }
31 |
32 | AVCSampleEntry.COMPACT_NAME = 'avc1';
33 |
34 | AVCSampleEntry.propTypes = {
35 | dataReferenceIndex: PropTypes.number.isRequired,
36 | width: PropTypes.number.isRequired,
37 | height: PropTypes.number.isRequired,
38 | horizResolution: PropTypes.number,
39 | vertResolution: PropTypes.number,
40 | frameCount: PropTypes.number,
41 | compressorName: PropTypes.string,
42 | depth: PropTypes.number
43 | };
44 |
45 | AVCSampleEntry.defaultProps = {
46 | horizResolution: 72.0,
47 | vertResolution: 72.0,
48 | frameCount: 1,
49 | compressorName: '',
50 | depth: 0x18
51 | };
52 |
53 | AVCSampleEntry.spec = {
54 | container: 'stsd',
55 | quantity: Box.QUANTITY_ANY_NUMBER,
56 | mandatoryList: []
57 | };
58 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/DataInformationBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class DataInformationBox extends Box {
4 | constructor(props) {
5 | super(DataInformationBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | DataInformationBox.COMPACT_NAME = 'dinf';
10 |
11 | DataInformationBox.spec = {
12 | container: 'minf',
13 | quantity: Box.QUANTITY_EXACTLY_ONE,
14 | mandatoryList: ['dref']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/EditBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class EditBox extends Box {
4 | constructor(props) {
5 | super(EditBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | EditBox.COMPACT_NAME = 'edts';
10 |
11 | EditBox.spec = {
12 | container: 'trak',
13 | quantity: Box.QUANTITY_ZERO_OR_ONE,
14 | mandatoryList: []
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/File.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class File extends Box {
4 | constructor(props) {
5 | super(File.COMPACT_NAME, props);
6 | }
7 |
8 | serialize() {
9 | return 0;
10 | }
11 |
12 | setSize(size) {
13 | this.size = size;
14 | }
15 |
16 | toString() {
17 | return null;
18 | }
19 |
20 | static parse() {
21 | return [0, null];
22 | }
23 | }
24 |
25 | File.COMPACT_NAME = 'file';
26 |
27 | File.spec = {
28 | mandatoryList: []
29 | };
30 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MP4AudioSampleEntry.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import AudioSampleEntry from './AudioSampleEntry';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class MP4AudioSampleEntry extends AudioSampleEntry {
6 | constructor(props) {
7 | super(MP4AudioSampleEntry.COMPACT_NAME, props);
8 | }
9 |
10 | serialize(buffer, offset=0) {
11 | //console.log('--- MP4AudioSampleEntry.serialize enter.');
12 | let base = offset;
13 |
14 | base += super.serialize(buffer, base);
15 | super.setSize(base - offset, buffer, offset);
16 |
17 | //console.log(`--- MP4AudioSampleEntry.serialize exit. size=${this.size}`);
18 | return this.size;
19 | }
20 |
21 | static parse(buffer, offset=0) {
22 | let base = offset,
23 | readBytesNum, props;
24 |
25 | [readBytesNum, props] = AudioSampleEntry.parse(buffer, base);
26 | base += readBytesNum;
27 |
28 | return [base - offset, props];
29 | }
30 | }
31 |
32 | MP4AudioSampleEntry.COMPACT_NAME = 'mp4a';
33 |
34 | MP4AudioSampleEntry.propTypes = {
35 | dataReferenceIndex: PropTypes.number.isRequired,
36 | channelCount: PropTypes.oneOf([1, 2]),
37 | sampleSize: PropTypes.number,
38 | sampleRate: PropTypes.number
39 | };
40 |
41 | MP4AudioSampleEntry.defaultProps = {
42 | channelCount: 1, // mono
43 | sampleSize: 16,
44 | sampleRate: 44100
45 | };
46 |
47 | MP4AudioSampleEntry.spec = {
48 | container: 'stsd',
49 | quantity: Box.QUANTITY_ANY_NUMBER,
50 | mandatoryList: []
51 | };
52 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MediaBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class MediaBox extends Box {
4 | constructor(props) {
5 | super(MediaBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | MediaBox.COMPACT_NAME = 'mdia';
10 |
11 | MediaBox.spec = {
12 | container: 'trak',
13 | quantity: Box.QUANTITY_EXACTLY_ONE,
14 | mandatoryList: ['mdhd', 'hdlr', 'minf']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MediaInformationBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class MediaInformationBox extends Box {
4 | constructor(props) {
5 | super(MediaInformationBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | MediaInformationBox.COMPACT_NAME = 'minf';
10 |
11 | MediaInformationBox.spec = {
12 | container: 'mdia',
13 | quantity: Box.QUANTITY_EXACTLY_ONE,
14 | mandatoryList: [['vmhd', 'smhd', 'hmhd', 'nmhd'], 'dinf', 'stbl']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MovieBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class MovieBox extends Box {
4 | constructor(props) {
5 | super(MovieBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | MovieBox.COMPACT_NAME = 'moov';
10 |
11 | MovieBox.spec = {
12 | container: 'file',
13 | quantity: Box.QUANTITY_EXACTLY_ONE,
14 | mandatoryList: ['mvhd', 'trak']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MovieExtendsBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class MovieExtendsBox extends Box {
4 | constructor(props) {
5 | super(MovieExtendsBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | MovieExtendsBox.COMPACT_NAME = 'mvex';
10 |
11 | MovieExtendsBox.spec = {
12 | container: 'moov',
13 | quantity: Box.QUANTITY_EXACTLY_ONE, // Actually zero or one.
14 | mandatoryList: ['trex']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/MovieFragmentBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class MovieFragmentBox extends Box {
4 | constructor(props) {
5 | super(MovieFragmentBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | MovieFragmentBox.COMPACT_NAME = 'moof';
10 |
11 | MovieFragmentBox.spec = {
12 | container: 'file',
13 | quantity: Box.QUANTITY_ANY_NUMBER,
14 | mandatoryList: ['mfhd']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/NullMediaHeaderBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import FullBox from './FullBox';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class NullMediaHeaderBox extends FullBox {
6 | constructor(props) {
7 | super(NullMediaHeaderBox.COMPACT_NAME, props, props.version, 0);
8 | }
9 |
10 | serialize(buffer, offset=0) {
11 | let base = offset;
12 |
13 | base += super.serialize(buffer, base);
14 | super.setSize(base - offset, buffer, offset);
15 | return this.size;
16 | }
17 |
18 | static parse(buffer, offset=0) {
19 | let readBytesNum, props;
20 | [readBytesNum, props] = FullBox.parse(buffer, offset);
21 | return [readBytesNum, props];
22 | }
23 | }
24 |
25 | NullMediaHeaderBox.COMPACT_NAME = 'nmhd';
26 |
27 | NullMediaHeaderBox.propTypes = {
28 | version: PropTypes.oneOf([0, 1])
29 | };
30 |
31 | NullMediaHeaderBox.defaultProps = {
32 | version: 0
33 | };
34 |
35 | NullMediaHeaderBox.spec = {
36 | container: 'minf',
37 | quantity: Box.QUANTITY_EXACTLY_ONE,
38 | mandatoryList: []
39 | };
40 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/SampleDescriptionBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import FullBox from './FullBox';
3 | import PropTypes from '../../core/PropTypes';
4 | import Writer from '../../core/Writer';
5 | import Reader from '../../core/Reader';
6 |
7 | export default class SampleDescriptionBox extends FullBox {
8 | constructor(props) {
9 | super(SampleDescriptionBox.COMPACT_NAME, props, 0, 0);
10 | }
11 |
12 | serialize(buffer, offset=0) {
13 | //console.log('--- SampleDescriptionBox.serialize enter.');
14 | const props = this.props;
15 | const entryCount = props.entryCount;
16 |
17 | let base = offset;
18 |
19 | base += super.serialize(buffer, base);
20 | base += Writer.writeNumber(entryCount, buffer, base, 4);
21 |
22 | super.setSize(base - offset, buffer, offset);
23 |
24 | //console.log(`--- SampleDescriptionBox.serialize exit. size=${this.size}`);
25 | return this.size;
26 | }
27 |
28 | static parse(buffer, offset=0) {
29 | let base = offset,
30 | readBytesNum, props,
31 | entryCount;
32 |
33 | [readBytesNum, props] = FullBox.parse(buffer, base);
34 | base += readBytesNum;
35 |
36 | [readBytesNum, entryCount] = Reader.readNumber(buffer, base, 4);
37 | base += readBytesNum;
38 |
39 | props.entryCount = entryCount;
40 |
41 | return [base - offset, props];
42 | }
43 | }
44 |
45 | SampleDescriptionBox.COMPACT_NAME = 'stsd';
46 |
47 | SampleDescriptionBox.propTypes = {
48 | entryCount: PropTypes.number.isRequired
49 | };
50 |
51 | SampleDescriptionBox.spec = {
52 | container: 'stbl',
53 | quantity: Box.QUANTITY_EXACTLY_ONE,
54 | mandatoryList: []
55 | };
56 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/SampleEntry.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import Writer from '../../core/Writer';
3 | import Reader from '../../core/Reader';
4 |
5 | export default class SampleEntry extends Box {
6 | constructor(type, props, dataReferenceIndex) {
7 | super(type, props);
8 | this.dataReferenceIndex = dataReferenceIndex;
9 | }
10 |
11 | serialize(buffer, offset=0) {
12 | //console.log('--- SampleEntry.serialize enter.');
13 | const dataReferenceIndex = this.dataReferenceIndex;
14 |
15 | let base = offset;
16 |
17 | base += super.serialize(buffer, base);
18 |
19 | base += Writer.writeNumber(0, buffer, base, 6); // reserved (8)[6]
20 |
21 | base += Writer.writeNumber(dataReferenceIndex, buffer, base, 2);
22 |
23 | super.setSize(base - offset, buffer, offset);
24 |
25 | //console.log('--- SampleEntry.serialize exit.');
26 | return this.size;
27 | }
28 |
29 | static parse(buffer, offset=0) {
30 | let base = offset,
31 | readBytesNum, props,
32 | dataReferenceIndex;
33 |
34 | [readBytesNum, props] = Box.parse(buffer, base);
35 | base += readBytesNum;
36 |
37 | base += 6; // skip reserved
38 |
39 | [readBytesNum, dataReferenceIndex] = Reader.readNumber(buffer, base, 2);
40 | base += readBytesNum;
41 |
42 | props.dataReferenceIndex = dataReferenceIndex;
43 |
44 | return [base - offset, props];
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/SampleTableBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class SampleTableBox extends Box {
4 | constructor(props) {
5 | super(SampleTableBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | SampleTableBox.COMPACT_NAME = 'stbl';
10 |
11 | SampleTableBox.spec = {
12 | container: 'minf',
13 | quantity: Box.QUANTITY_EXACTLY_ONE,
14 | mandatoryList: ['stsd', 'stts', 'stsc', ['stsz', 'stz2'], ['stco', 'co64']]
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/TrackBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class TrackBox extends Box {
4 | constructor(props) {
5 | super(TrackBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | TrackBox.COMPACT_NAME = 'trak';
10 |
11 | TrackBox.spec = {
12 | container: 'moov',
13 | quantity: Box.QUANTITY_ANY_NUMBER, // Actually one or more.
14 | mandatoryList: ['tkhd', 'mdia']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/TrackFragmentBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 |
3 | export default class TrackFragmentBox extends Box {
4 | constructor(props) {
5 | super(TrackFragmentBox.COMPACT_NAME, props);
6 | }
7 | }
8 |
9 | TrackFragmentBox.COMPACT_NAME = 'traf';
10 |
11 | TrackFragmentBox.spec = {
12 | container: 'moof',
13 | quantity: Box.QUANTITY_ANY_NUMBER,
14 | mandatoryList: ['tfhd']
15 | };
16 |
--------------------------------------------------------------------------------
/src/IsoBmff/Box/UnknownBox.js:
--------------------------------------------------------------------------------
1 | import Box from './Box';
2 | import PropTypes from '../../core/PropTypes';
3 | import Buffer from '../../core/Buffer';
4 | import Reader from '../../core/Reader';
5 |
6 | export default function createUnknownBox(name) {
7 | class UnknownBox extends Box {
8 | constructor(props) {
9 | super(UnknownBox.COMPACT_NAME, props);
10 | }
11 |
12 | serialize(buffer, offset=0) {
13 | //console.log('--- UnknownBox.serialize enter.');
14 | const data = this.props.data;
15 |
16 | let base = offset;
17 |
18 | base += super.serialize(buffer, base);
19 |
20 | if (buffer) {
21 | Buffer.wrap(buffer).copyFrom(data, 0, data.length, base);
22 | }
23 | base += data.length;
24 |
25 | super.setSize(base - offset, buffer, offset);
26 |
27 | //console.log(`--- UnknownBox.serialize exit. size=${this.size}`);
28 | return this.size;
29 | }
30 |
31 | static parse(buffer, offset=-1) {
32 | let base = offset, readBytesNum, props;
33 |
34 | [readBytesNum, props] = Box.parse(buffer, base);
35 | base += readBytesNum;
36 |
37 | const toBeRead = props.size - readBytesNum;
38 | Reader.ASSERT(buffer, base, toBeRead);
39 | const buf = Buffer.wrap(buffer).copy(base, toBeRead);
40 | base += toBeRead;
41 |
42 | props.data = buf.getView();
43 |
44 | return [base - offset, props];
45 | }
46 | }
47 |
48 | UnknownBox.COMPACT_NAME = name;
49 |
50 | UnknownBox.propTypes = {
51 | data: PropTypes.any.isRequired
52 | };
53 | return UnknownBox;
54 | }
55 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/AlphaMode.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class AlphaMode extends TypeBool {
6 | constructor(props) {
7 | super(AlphaMode.ELEMENT_ID, AlphaMode.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | AlphaMode.COMPACT_NAME = 'AlphaMode';
12 |
13 | AlphaMode.ELEMENT_ID = [0x53, 0xC0];
14 |
15 | AlphaMode.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | AlphaMode.defaultProps = {
20 | value: false
21 | };
22 |
23 | AlphaMode.spec = {
24 | container: 'Video',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Audio.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Audio extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(Audio.ELEMENT_ID, Audio.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Audio.COMPACT_NAME = 'Audio';
11 |
12 | Audio.ELEMENT_ID = [0xe1];
13 |
14 | Audio.spec = {
15 | container: 'TrackEntry',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: ['SamplingFrequency', 'Channels']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BitDepth.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class BitDepth extends TypeUInt {
6 | constructor(props) {
7 | super(BitDepth.ELEMENT_ID, BitDepth.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | BitDepth.COMPACT_NAME = 'BitDepth';
12 |
13 | BitDepth.ELEMENT_ID = [0x62, 0x64];
14 |
15 | BitDepth.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | BitDepth.spec = {
20 | container: 'Audio',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Block.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBlock from './TypeBlock';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Block extends TypeBlock {
6 | constructor(props) {
7 | super(Block.ELEMENT_ID, Block.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Block.COMPACT_NAME = 'Block';
12 |
13 | Block.ELEMENT_ID = [0xa1];
14 |
15 | Block.propTypes = {
16 | trackNumber: PropTypes.number.isRequired,
17 | timecode: PropTypes.number.isRequired,
18 | flags: PropTypes.shape({
19 | invisible: PropTypes.bool,
20 | }),
21 | frames: PropTypes.any.isRequired
22 | };
23 |
24 | Block.defaultProps = {
25 | flags: {
26 | invisible: false,
27 | }
28 | };
29 |
30 | Block.spec = {
31 | container: 'BlockGroup',
32 | quantity: Component.QUANTITY_ANY_NUMBER, // QUANTITY_EXACTLY_ONE?
33 | mandatoryList: []
34 | };
35 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockAddID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class BlockAddID extends TypeUInt {
6 | constructor(props) {
7 | super(BlockAddID.ELEMENT_ID, BlockAddID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | BlockAddID.COMPACT_NAME = 'BlockAddID';
12 |
13 | BlockAddID.ELEMENT_ID = [0xee];
14 |
15 | BlockAddID.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | BlockAddID.defaultProps = {
20 | value: 1
21 | };
22 |
23 | BlockAddID.spec = {
24 | container: 'BlockMore',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockAdditional.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class BlockAdditional extends TypeBytes {
6 | constructor(props) {
7 | super(BlockAdditional.ELEMENT_ID, BlockAdditional.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | BlockAdditional.COMPACT_NAME = 'BlockAdditional';
12 |
13 | BlockAdditional.ELEMENT_ID = [0xa5];
14 |
15 | BlockAdditional.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | BlockAdditional.spec = {
20 | container: 'BlockMore',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockAdditions.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class BlockAdditions extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(BlockAdditions.ELEMENT_ID, BlockAdditions.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | BlockAdditions.COMPACT_NAME = 'BlockAdditions';
11 |
12 | BlockAdditions.ELEMENT_ID = [0x75, 0xa1];
13 |
14 | BlockAdditions.spec = {
15 | container: 'BlockGroup',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['BlockMore']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockDuration.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class BlockDuration extends TypeUInt {
6 | constructor(props) {
7 | super(BlockDuration.ELEMENT_ID, BlockDuration.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | BlockDuration.COMPACT_NAME = 'BlockDuration';
12 |
13 | BlockDuration.ELEMENT_ID = [0x9b];
14 |
15 | BlockDuration.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | BlockDuration.spec = {
20 | container: 'BlockGroup',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockGroup.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class BlockGroup extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(BlockGroup.ELEMENT_ID, BlockGroup.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | BlockGroup.COMPACT_NAME = 'BlockGroup';
11 |
12 | BlockGroup.ELEMENT_ID = [0xa0];
13 |
14 | BlockGroup.spec = {
15 | container: 'Cluster',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['Block']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/BlockMore.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class BlockMore extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(BlockMore.ELEMENT_ID, BlockMore.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | BlockMore.COMPACT_NAME = 'BlockMore';
11 |
12 | BlockMore.ELEMENT_ID = [0xa6];
13 |
14 | BlockMore.spec = {
15 | container: 'BlockAdditions',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['BlockAddID', 'BlockAdditional']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Channels.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Channels extends TypeUInt {
6 | constructor(props) {
7 | super(Channels.ELEMENT_ID, Channels.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Channels.COMPACT_NAME = 'Channels';
12 |
13 | Channels.ELEMENT_ID = [0x9F];
14 |
15 | Channels.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | Channels.defaultProps = {
20 | value: 1
21 | };
22 |
23 | Channels.spec = {
24 | container: 'Audio',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapCountry.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapCountry extends TypeString {
6 | constructor(props) {
7 | super(ChapCountry.ELEMENT_ID, ChapCountry.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapCountry.COMPACT_NAME = 'ChapCountry';
12 |
13 | ChapCountry.ELEMENT_ID = [0x43, 0x7E];
14 |
15 | ChapCountry.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | ChapCountry.spec = {
20 | container: 'ChapterDisplay',
21 | quantity: Component.QUANTITY_ANY_NUMBER,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapLanguage.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapLanguage extends TypeString {
6 | constructor(props) {
7 | super(ChapLanguage.ELEMENT_ID, ChapLanguage.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapLanguage.COMPACT_NAME = 'ChapLanguage';
12 |
13 | ChapLanguage.ELEMENT_ID = [0x43, 0x7C];
14 |
15 | ChapLanguage.propTypes = {
16 | value: PropTypes.string
17 | };
18 |
19 | ChapLanguage.defaultProps = {
20 | value: 'eng'
21 | };
22 |
23 | ChapLanguage.spec = {
24 | container: 'ChapterDisplay',
25 | quantity: Component.QUANTITY_ANY_NUMBER,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapString.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapString extends TypeString {
6 | constructor(props) {
7 | super(ChapString.ELEMENT_ID, ChapString.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapString.COMPACT_NAME = 'ChapString';
12 |
13 | ChapString.ELEMENT_ID = [0x85];
14 |
15 | ChapString.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | ChapString.spec = {
20 | container: 'ChapterDisplay',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterAtom.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class ChapterAtom extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(ChapterAtom.ELEMENT_ID, ChapterAtom.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | ChapterAtom.COMPACT_NAME = 'ChapterAtom';
11 |
12 | ChapterAtom.ELEMENT_ID = [0xB6];
13 |
14 | ChapterAtom.spec = {
15 | container: 'EditionEntry',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['ChapterUID', 'ChapterTimeStart']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterDisplay.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class ChapterDisplay extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(ChapterDisplay.ELEMENT_ID, ChapterDisplay.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | ChapterDisplay.COMPACT_NAME = 'ChapterDisplay';
11 |
12 | ChapterDisplay.ELEMENT_ID = [0x80];
13 |
14 | ChapterDisplay.spec = {
15 | container: 'ChapterAtom',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['ChapString', 'ChapLanguage']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterStringUID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapterStringUID extends TypeString {
6 | constructor(props) {
7 | super(ChapterStringUID.ELEMENT_ID, ChapterStringUID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapterStringUID.COMPACT_NAME = 'ChapterStringUID';
12 |
13 | ChapterStringUID.ELEMENT_ID = [0x56, 0x54];
14 |
15 | ChapterStringUID.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | ChapterStringUID.spec = {
20 | container: 'ChapterAtom',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterTimeEnd.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapterTimeEnd extends TypeUInt {
6 | constructor(props) {
7 | super(ChapterTimeEnd.ELEMENT_ID, ChapterTimeEnd.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapterTimeEnd.COMPACT_NAME = 'ChapterTimeEnd';
12 |
13 | ChapterTimeEnd.ELEMENT_ID = [0x92];
14 |
15 | ChapterTimeEnd.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | ChapterTimeEnd.spec = {
20 | container: 'ChapterAtom',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterTimeStart.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapterTimeStart extends TypeUInt {
6 | constructor(props) {
7 | super(ChapterTimeStart.ELEMENT_ID, ChapterTimeStart.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapterTimeStart.COMPACT_NAME = 'ChapterTimeStart';
12 |
13 | ChapterTimeStart.ELEMENT_ID = [0x91];
14 |
15 | ChapterTimeStart.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | ChapterTimeStart.spec = {
20 | container: 'ChapterAtom',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ChapterUID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ChapterUID extends TypeUInt {
6 | constructor(props) {
7 | super(ChapterUID.ELEMENT_ID, ChapterUID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ChapterUID.COMPACT_NAME = 'ChapterUID';
12 |
13 | ChapterUID.ELEMENT_ID = [0x73, 0xC4];
14 |
15 | ChapterUID.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | ChapterUID.spec = {
20 | container: 'ChapterAtom',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Chapters.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Chapters extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 4;
6 | super(Chapters.ELEMENT_ID, Chapters.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Chapters.COMPACT_NAME = 'Chapters';
11 |
12 | Chapters.ELEMENT_ID = [0x10, 0x43, 0xa7, 0x70];
13 |
14 | Chapters.spec = {
15 | container: '*',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: ['EditionEntry']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Cluster.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Cluster extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 4;
6 | super(Cluster.ELEMENT_ID, Cluster.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Cluster.COMPACT_NAME = 'Cluster';
11 |
12 | Cluster.ELEMENT_ID = [0x1f, 0x43, 0xb6, 0x75];
13 |
14 | Cluster.spec = {
15 | container: ['Segment', 'Cluster'],
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['Timecode']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CodecDelay.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CodecDelay extends TypeUInt {
6 | constructor(props) {
7 | super(CodecDelay.ELEMENT_ID, CodecDelay.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CodecDelay.COMPACT_NAME = 'CodecDelay';
12 |
13 | CodecDelay.ELEMENT_ID = [0x56, 0xAA];
14 |
15 | CodecDelay.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | CodecDelay.defaultProps = {
20 | value: 0
21 | };
22 |
23 | CodecDelay.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CodecID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CodecID extends TypeString {
6 | constructor(props) {
7 | super(CodecID.ELEMENT_ID, CodecID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CodecID.COMPACT_NAME = 'CodecID';
12 |
13 | CodecID.ELEMENT_ID = [0x86];
14 |
15 | CodecID.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | CodecID.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CodecName.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CodecName extends TypeString {
6 | constructor(props) {
7 | super(CodecName.ELEMENT_ID, CodecName.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CodecName.COMPACT_NAME = 'CodecName';
12 |
13 | CodecName.ELEMENT_ID = [0x25, 0x86, 0x88];
14 |
15 | CodecName.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | CodecName.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CodecPrivate.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CodecPrivate extends TypeBytes {
6 | constructor(props) {
7 | super(CodecPrivate.ELEMENT_ID, CodecPrivate.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CodecPrivate.COMPACT_NAME = 'CodecPrivate';
12 |
13 | CodecPrivate.ELEMENT_ID = [0x63, 0xA2];
14 |
15 | CodecPrivate.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | CodecPrivate.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncAESSettings.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class ContentEncAESSettings extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 1;
7 | super(ContentEncAESSettings.ELEMENT_ID, ContentEncAESSettings.COMPACT_NAME, props);
8 | }
9 |
10 | static validate(context, props) {
11 | const contentEncAlgo = context.contentEncAlgo;
12 | if (contentEncAlgo && contentEncAlgo !== 'AES') {
13 | throwException(`ContentEncAlgo is not "AES" but "${contentEncAlgo}"`);
14 | }
15 | }
16 | }
17 |
18 | ContentEncAESSettings.COMPACT_NAME = 'ContentEncAESSettings';
19 |
20 | ContentEncAESSettings.ELEMENT_ID = [0x47, 0xE7];
21 |
22 | ContentEncAESSettings.spec = {
23 | container: 'ContentEncryption',
24 | quantity: Element.QUANTITY_EXACTLY_ONE,
25 | mandatoryList: []
26 | };
27 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncKeyID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ContentEncKeyID extends TypeBytes {
6 | constructor(props) {
7 | super(ContentEncKeyID.ELEMENT_ID, ContentEncKeyID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ContentEncKeyID.COMPACT_NAME = 'ContentEncKeyID';
12 |
13 | ContentEncKeyID.ELEMENT_ID = [0x47, 0xE2];
14 |
15 | ContentEncKeyID.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | ContentEncKeyID.spec = {
20 | container: 'ContentEncryption',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncoding.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class ContentEncoding extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 1;
7 | super(ContentEncoding.ELEMENT_ID, ContentEncoding.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ContentEncoding.COMPACT_NAME = 'ContentEncoding';
12 |
13 | ContentEncoding.ELEMENT_ID = [0x62, 0x40];
14 |
15 | ContentEncoding.spec = {
16 | container: 'ContentEncodings',
17 | quantity: Element.QUANTITY_ANY_NUMBER,
18 | mandatoryList: ['ContentEncodingOrder', 'ContentEncodingScope', 'ContentEncodingType']
19 | };
20 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncodingOrder.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ContentEncodingOrder extends TypeUInt {
6 | constructor(props) {
7 | super(ContentEncodingOrder.ELEMENT_ID, ContentEncodingOrder.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ContentEncodingOrder.COMPACT_NAME = 'ContentEncodingOrder';
12 |
13 | ContentEncodingOrder.ELEMENT_ID = [0x50, 0x31];
14 |
15 | ContentEncodingOrder.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | ContentEncodingOrder.defaultProps = {
20 | value: 0
21 | };
22 |
23 | ContentEncodingOrder.spec = {
24 | container: 'ContentEncoding',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncodings.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class ContentEncodings extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 1;
7 | super(ContentEncodings.ELEMENT_ID, ContentEncodings.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ContentEncodings.COMPACT_NAME = 'ContentEncodings';
12 |
13 | ContentEncodings.ELEMENT_ID = [0x6D, 0x80];
14 |
15 | ContentEncodings.spec = {
16 | container: 'TrackEntry',
17 | quantity: Element.QUANTITY_EXACTLY_ONE,
18 | mandatoryList: ['ContentEncoding']
19 | };
20 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ContentEncryption.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class ContentEncryption extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 1;
7 | super(ContentEncryption.ELEMENT_ID, ContentEncryption.COMPACT_NAME, props);
8 | }
9 |
10 | static validate(context, props) {
11 | const contentEncodingType = context.contentEncodingType;
12 | if (contentEncodingType && contentEncodingType !== 'encryption') {
13 | throwException(`ContentEncodingType is not "encryption" but "${contentEncodingType}"`);
14 | }
15 | }
16 | }
17 |
18 | ContentEncryption.COMPACT_NAME = 'ContentEncryption';
19 |
20 | ContentEncryption.ELEMENT_ID = [0x50, 0x35];
21 |
22 | ContentEncryption.spec = {
23 | container: 'ContentEncoding',
24 | quantity: Element.QUANTITY_EXACTLY_ONE,
25 | mandatoryList: []
26 | };
27 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueBlockNumber.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueBlockNumber extends TypeUInt {
6 | constructor(props) {
7 | super(CueBlockNumber.ELEMENT_ID, CueBlockNumber.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueBlockNumber.COMPACT_NAME = 'CueBlockNumber';
12 |
13 | CueBlockNumber.ELEMENT_ID = [0x53, 0x78];
14 |
15 | CueBlockNumber.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | CueBlockNumber.defaultProps = {
20 | value: 1
21 | };
22 |
23 | CueBlockNumber.spec = {
24 | container: 'CueTrackPositions',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueClusterPosition.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueClusterPosition extends TypeUInt {
6 | constructor(props) {
7 | super(CueClusterPosition.ELEMENT_ID, CueClusterPosition.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueClusterPosition.COMPACT_NAME = 'CueClusterPosition';
12 |
13 | CueClusterPosition.ELEMENT_ID = [0xF1];
14 |
15 | CueClusterPosition.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | CueClusterPosition.spec = {
20 | container: 'CueTrackPositions',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueDuration.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueDuration extends TypeUInt {
6 | constructor(props) {
7 | super(CueDuration.ELEMENT_ID, CueDuration.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueDuration.COMPACT_NAME = 'CueDuration';
12 |
13 | CueDuration.ELEMENT_ID = [0xB2];
14 |
15 | CueDuration.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | CueDuration.spec = {
20 | container: 'CueTrackPositions',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CuePoint.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class CuePoint extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(CuePoint.ELEMENT_ID, CuePoint.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | CuePoint.COMPACT_NAME = 'CuePoint';
11 |
12 | CuePoint.ELEMENT_ID = [0xBB];
13 |
14 | CuePoint.spec = {
15 | container: 'Cues',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['CueTime', 'CueTrackPositions']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueRelativePosition.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueRelativePosition extends TypeUInt {
6 | constructor(props) {
7 | super(CueRelativePosition.ELEMENT_ID, CueRelativePosition.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueRelativePosition.COMPACT_NAME = 'CueRelativePosition';
12 |
13 | CueRelativePosition.ELEMENT_ID = [0xF0];
14 |
15 | CueRelativePosition.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | CueRelativePosition.spec = {
20 | container: 'CueTrackPositions',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueTime.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueTime extends TypeUInt {
6 | constructor(props) {
7 | super(CueTime.ELEMENT_ID, CueTime.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueTime.COMPACT_NAME = 'CueTime';
12 |
13 | CueTime.ELEMENT_ID = [0xB3];
14 |
15 | CueTime.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | CueTime.spec = {
20 | container: 'CuePoint',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueTrack.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class CueTrack extends TypeUInt {
6 | constructor(props) {
7 | super(CueTrack.ELEMENT_ID, CueTrack.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueTrack.COMPACT_NAME = 'CueTrack';
12 |
13 | CueTrack.ELEMENT_ID = [0xF7];
14 |
15 | CueTrack.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | CueTrack.spec = {
20 | container: 'CueTrackPositions',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/CueTrackPositions.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class CueTrackPositions extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 1;
7 | super(CueTrackPositions.ELEMENT_ID, CueTrackPositions.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | CueTrackPositions.COMPACT_NAME = 'CueTrackPositions';
12 |
13 | CueTrackPositions.ELEMENT_ID = [0xB7];
14 |
15 | CueTrackPositions.spec = {
16 | container: 'CuePoint',
17 | quantity: Element.QUANTITY_ANY_NUMBER,
18 | mandatoryList: ['CueTrack', 'CueClusterPosition']
19 | };
20 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Cues.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Cues extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(Cues.ELEMENT_ID, Cues.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Cues.COMPACT_NAME = 'Cues';
11 |
12 | Cues.ELEMENT_ID = [0x1c, 0x53, 0xbb, 0x6b];
13 |
14 | Cues.spec = {
15 | container: '*',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: ['CuePoint']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DateUTC.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeDate from './TypeDate';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DateUTC extends TypeDate {
6 | constructor(props) {
7 | super(DateUTC.ELEMENT_ID, DateUTC.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DateUTC.COMPACT_NAME = 'DateUTC';
12 |
13 | DateUTC.ELEMENT_ID = [0x44, 0x61];
14 |
15 | DateUTC.propTypes = {
16 | value: PropTypes.instanceOf(Date).isRequired
17 | };
18 |
19 | DateUTC.spec = {
20 | container: 'Info',
21 | quantity: Component.QUANTITY_ZERO_OR_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DefaultDuration.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DefaultDuration extends TypeUInt {
6 | constructor(props) {
7 | super(DefaultDuration.ELEMENT_ID, DefaultDuration.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DefaultDuration.COMPACT_NAME = 'DefaultDuration';
12 |
13 | DefaultDuration.ELEMENT_ID = [0x23, 0xe3, 0x83];
14 |
15 | DefaultDuration.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | DefaultDuration.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DiscardPadding.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeInt from './TypeInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DiscardPadding extends TypeInt {
6 | constructor(props) {
7 | super(DiscardPadding.ELEMENT_ID, DiscardPadding.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DiscardPadding.COMPACT_NAME = 'DiscardPadding';
12 |
13 | DiscardPadding.ELEMENT_ID = [0x75, 0xa2];
14 |
15 | DiscardPadding.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | DiscardPadding.spec = {
20 | container: 'BlockGroup',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DisplayHeight.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DisplayHeight extends TypeUInt {
6 | constructor(props) {
7 | super(DisplayHeight.ELEMENT_ID, DisplayHeight.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DisplayHeight.COMPACT_NAME = 'DisplayHeight';
12 |
13 | DisplayHeight.ELEMENT_ID = [0x54, 0xBA];
14 |
15 | DisplayHeight.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | DisplayHeight.spec = {
20 | container: 'Video',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DisplayWidth.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DisplayWidth extends TypeUInt {
6 | constructor(props) {
7 | super(DisplayWidth.ELEMENT_ID, DisplayWidth.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DisplayWidth.COMPACT_NAME = 'DisplayWidth';
12 |
13 | DisplayWidth.ELEMENT_ID = [0x54, 0xB0];
14 |
15 | DisplayWidth.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | DisplayWidth.spec = {
20 | container: 'Video',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DocType.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DocType extends TypeString {
6 | constructor(props) {
7 | super(DocType.ELEMENT_ID, DocType.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DocType.COMPACT_NAME = 'DocType';
12 |
13 | DocType.ELEMENT_ID = [0x42, 0x82];
14 |
15 | DocType.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | DocType.propTypes = {
20 | value: PropTypes.string
21 | };
22 |
23 | DocType.defaultProps = {
24 | value: 'webm'
25 | };
26 |
27 | DocType.spec = {
28 | container: 'EBML',
29 | quantity: Component.QUANTITY_EXACTLY_ONE,
30 | mandatoryList: []
31 | };
32 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DocTypeReadVersion.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DocTypeReadVersion extends TypeUInt {
6 | constructor(props) {
7 | super(DocTypeReadVersion.ELEMENT_ID, DocTypeReadVersion.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DocTypeReadVersion.COMPACT_NAME = 'DocTypeReadVersion';
12 |
13 | DocTypeReadVersion.ELEMENT_ID = [0x42, 0x85];
14 |
15 | DocTypeReadVersion.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | DocTypeReadVersion.defaultProps = {
20 | value: 1
21 | };
22 |
23 | DocTypeReadVersion.spec = {
24 | container: 'EBML',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/DocTypeVersion.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class DocTypeVersion extends TypeUInt {
6 | constructor(props) {
7 | super(DocTypeVersion.ELEMENT_ID, DocTypeVersion.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | DocTypeVersion.COMPACT_NAME = 'DocTypeVersion';
12 |
13 | DocTypeVersion.ELEMENT_ID = [0x42, 0x87];
14 |
15 | DocTypeVersion.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | DocTypeVersion.defaultProps = {
20 | value: 1
21 | };
22 |
23 | DocTypeVersion.spec = {
24 | container: 'EBML',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Duration.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeFloat from './TypeFloat';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Duration extends TypeFloat {
6 | constructor(props) {
7 | super(Duration.ELEMENT_ID, Duration.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Duration.COMPACT_NAME = 'Duration';
12 |
13 | Duration.ELEMENT_ID = [0x44, 0x89];
14 |
15 | Duration.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | Duration.spec = {
20 | container: 'Info',
21 | quantity: Component.QUANTITY_ZERO_OR_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EBML.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class EBML extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 4;
6 | super(EBML.ELEMENT_ID, EBML.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | EBML.COMPACT_NAME = 'EBML';
11 |
12 | EBML.ELEMENT_ID = [0x1a, 0x45, 0xdf, 0xa3];
13 |
14 | EBML.spec = {
15 | container: 'File',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['EBMLVersion', 'EBMLReadVersion', 'EBMLMaxIDLength', 'EBMLMaxSizeLength', 'DocType', 'DocTypeVersion', 'DocTypeReadVersion']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EBMLMaxIDLength.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class EBMLMaxIDLength extends TypeUInt {
6 | constructor(props) {
7 | super(EBMLMaxIDLength.ELEMENT_ID, EBMLMaxIDLength.COMPACT_NAME, props);
8 | }
9 |
10 | static validate(context, props) {
11 | context.maxIdLength = props.value;
12 | }
13 | }
14 |
15 | EBMLMaxIDLength.COMPACT_NAME = 'EBMLMaxIDLength';
16 |
17 | EBMLMaxIDLength.ELEMENT_ID = [0x42, 0xf2];
18 |
19 | EBMLMaxIDLength.propTypes = {
20 | value: PropTypes.number
21 | };
22 |
23 | EBMLMaxIDLength.defaultProps = {
24 | value: 4
25 | };
26 |
27 | EBMLMaxIDLength.spec = {
28 | container: 'EBML',
29 | quantity: Component.QUANTITY_EXACTLY_ONE,
30 | mandatoryList: []
31 | };
32 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EBMLMaxSizeLength.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class EBMLMaxSizeLength extends TypeUInt {
6 | constructor(props) {
7 | super(EBMLMaxSizeLength.ELEMENT_ID, EBMLMaxSizeLength.COMPACT_NAME, props);
8 | }
9 |
10 | static validate(context, props) {
11 | context.maxSizeLength = props.value;
12 | }
13 | }
14 |
15 | EBMLMaxSizeLength.COMPACT_NAME = 'EBMLMaxSizeLength';
16 |
17 | EBMLMaxSizeLength.ELEMENT_ID = [0x42, 0xf3];
18 |
19 | EBMLMaxSizeLength.propTypes = {
20 | value: PropTypes.number
21 | };
22 |
23 | EBMLMaxSizeLength.defaultProps = {
24 | value: 8
25 | };
26 |
27 | EBMLMaxSizeLength.spec = {
28 | container: 'EBML',
29 | quantity: Component.QUANTITY_EXACTLY_ONE,
30 | mandatoryList: []
31 | };
32 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EBMLReadVersion.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class EBMLReadVersion extends TypeUInt {
6 | constructor(props) {
7 | super(EBMLReadVersion.ELEMENT_ID, EBMLReadVersion.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | EBMLReadVersion.COMPACT_NAME = 'EBMLReadVersion';
12 |
13 | EBMLReadVersion.ELEMENT_ID = [0x42, 0xf7];
14 |
15 | EBMLReadVersion.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | EBMLReadVersion.defaultProps = {
20 | value: 1
21 | };
22 |
23 | EBMLReadVersion.spec = {
24 | container: 'EBML',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EBMLVersion.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class EBMLVersion extends TypeUInt {
6 | constructor(props) {
7 | super(EBMLVersion.ELEMENT_ID, EBMLVersion.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | EBMLVersion.COMPACT_NAME = 'EBMLVersion';
12 |
13 | EBMLVersion.ELEMENT_ID = [0x42, 0x86];
14 |
15 | EBMLVersion.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | EBMLVersion.defaultProps = {
20 | value: 1
21 | };
22 |
23 | EBMLVersion.spec = {
24 | container: 'EBML',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/EditionEntry.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class EditionEntry extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(EditionEntry.ELEMENT_ID, EditionEntry.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | EditionEntry.COMPACT_NAME = 'EditionEntry';
11 |
12 | EditionEntry.ELEMENT_ID = [0x45, 0xB9];
13 |
14 | EditionEntry.spec = {
15 | container: 'Chapters',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['ChapterAtom']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/File.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class File extends Element {
4 | constructor(props) {
5 | super(File.ELEMENT_ID, File.COMPACT_NAME, props);
6 | }
7 |
8 | serialize() {
9 | return 0;
10 | }
11 |
12 | setSize(size) {
13 | this.size = size;
14 | }
15 |
16 | toString() {
17 | return null;
18 | }
19 |
20 | static parse() {
21 | return [0, null];
22 | }
23 | }
24 |
25 | File.COMPACT_NAME = 'File';
26 |
27 | File.spec = {
28 | mandatoryList: []
29 | };
30 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/FlagDefault.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class FlagDefault extends TypeBool {
6 | constructor(props) {
7 | super(FlagDefault.ELEMENT_ID, FlagDefault.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | FlagDefault.COMPACT_NAME = 'FlagDefault';
12 |
13 | FlagDefault.ELEMENT_ID = [0x88];
14 |
15 | FlagDefault.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | FlagDefault.defaultProps = {
20 | value: true
21 | };
22 |
23 | FlagDefault.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/FlagEnabled.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class FlagEnabled extends TypeBool {
6 | constructor(props) {
7 | super(FlagEnabled.ELEMENT_ID, FlagEnabled.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | FlagEnabled.COMPACT_NAME = 'FlagEnabled';
12 |
13 | FlagEnabled.ELEMENT_ID = [0xb9];
14 |
15 | FlagEnabled.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | FlagEnabled.defaultProps = {
20 | value: true
21 | };
22 |
23 | FlagEnabled.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/FlagForced.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class FlagForced extends TypeBool {
6 | constructor(props) {
7 | super(FlagForced.ELEMENT_ID, FlagForced.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | FlagForced.COMPACT_NAME = 'FlagForced';
12 |
13 | FlagForced.ELEMENT_ID = [0x55, 0xaa];
14 |
15 | FlagForced.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | FlagForced.defaultProps = {
20 | value: false
21 | };
22 |
23 | FlagForced.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/FlagLacing.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class FlagLacing extends TypeBool {
6 | constructor(props) {
7 | super(FlagLacing.ELEMENT_ID, FlagLacing.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | FlagLacing.COMPACT_NAME = 'FlagLacing';
12 |
13 | FlagLacing.ELEMENT_ID = [0x9c];
14 |
15 | FlagLacing.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | FlagLacing.defaultProps = {
20 | value: true
21 | };
22 |
23 | FlagLacing.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Info.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Info extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(Info.ELEMENT_ID, Info.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Info.COMPACT_NAME = 'Info';
11 |
12 | Info.ELEMENT_ID = [0x15, 0x49, 0xa9, 0x66];
13 |
14 | Info.spec = {
15 | container: 'Segment',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['TimecodeScale', 'MuxingApp', 'WritingApp']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Language.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Language extends TypeString {
6 | constructor(props) {
7 | super(Language.ELEMENT_ID, Language.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Language.COMPACT_NAME = 'Language';
12 |
13 | Language.ELEMENT_ID = [0x22, 0xB5, 0x9C];
14 |
15 | Language.propTypes = {
16 | value: PropTypes.string
17 | };
18 |
19 | Language.defaultProps = {
20 | value: 'eng'
21 | };
22 |
23 | Language.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/MuxingApp.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class MuxingApp extends TypeString {
6 | constructor(props) {
7 | super(MuxingApp.ELEMENT_ID, MuxingApp.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | MuxingApp.COMPACT_NAME = 'MuxingApp';
12 |
13 | MuxingApp.ELEMENT_ID = [0x4d, 0x80];
14 |
15 | MuxingApp.propTypes = {
16 | value: PropTypes.string
17 | };
18 |
19 | MuxingApp.defaultProps = {
20 | value: 'kontainer-js'
21 | };
22 |
23 | MuxingApp.spec = {
24 | container: 'Info',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Name.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Name extends TypeString {
6 | constructor(props) {
7 | super(Name.ELEMENT_ID, Name.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Name.COMPACT_NAME = 'Name';
12 |
13 | Name.ELEMENT_ID = [0x53, 0x6e];
14 |
15 | Name.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | Name.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/OutputSamplingFrequency.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeFloat from './TypeFloat';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class OutputSamplingFrequency extends TypeFloat {
6 | constructor(props) {
7 | super(OutputSamplingFrequency.ELEMENT_ID, OutputSamplingFrequency.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | OutputSamplingFrequency.COMPACT_NAME = 'OutputSamplingFrequency';
12 |
13 | OutputSamplingFrequency.ELEMENT_ID = [0x78, 0xB5];
14 |
15 | OutputSamplingFrequency.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | OutputSamplingFrequency.spec = {
20 | container: 'Audio',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelCropBottom.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelCropBottom extends TypeUInt {
6 | constructor(props) {
7 | super(PixelCropBottom.ELEMENT_ID, PixelCropBottom.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelCropBottom.COMPACT_NAME = 'PixelCropBottom';
12 |
13 | PixelCropBottom.ELEMENT_ID = [0x54, 0xAA];
14 |
15 | PixelCropBottom.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | PixelCropBottom.defaultProps = {
20 | value: 0
21 | };
22 |
23 | PixelCropBottom.spec = {
24 | container: 'Video',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelCropLeft.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelCropLeft extends TypeUInt {
6 | constructor(props) {
7 | super(PixelCropLeft.ELEMENT_ID, PixelCropLeft.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelCropLeft.COMPACT_NAME = 'PixelCropLeft';
12 |
13 | PixelCropLeft.ELEMENT_ID = [0x54, 0xCC];
14 |
15 | PixelCropLeft.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | PixelCropLeft.defaultProps = {
20 | value: 0
21 | };
22 |
23 | PixelCropLeft.spec = {
24 | container: 'Video',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelCropRight.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelCropRight extends TypeUInt {
6 | constructor(props) {
7 | super(PixelCropRight.ELEMENT_ID, PixelCropRight.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelCropRight.COMPACT_NAME = 'PixelCropRight';
12 |
13 | PixelCropRight.ELEMENT_ID = [0x54, 0xDD];
14 |
15 | PixelCropRight.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | PixelCropRight.defaultProps = {
20 | value: 0
21 | };
22 |
23 | PixelCropRight.spec = {
24 | container: 'Video',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelCropTop.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelCropTop extends TypeUInt {
6 | constructor(props) {
7 | super(PixelCropTop.ELEMENT_ID, PixelCropTop.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelCropTop.COMPACT_NAME = 'PixelCropTop';
12 |
13 | PixelCropTop.ELEMENT_ID = [0x54, 0xBB];
14 |
15 | PixelCropTop.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | PixelCropTop.defaultProps = {
20 | value: 0
21 | };
22 |
23 | PixelCropTop.spec = {
24 | container: 'Video',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelHeight.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelHeight extends TypeUInt {
6 | constructor(props) {
7 | super(PixelHeight.ELEMENT_ID, PixelHeight.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelHeight.COMPACT_NAME = 'PixelHeight';
12 |
13 | PixelHeight.ELEMENT_ID = [0xBA];
14 |
15 | PixelHeight.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | PixelHeight.spec = {
20 | container: 'Video',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PixelWidth.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PixelWidth extends TypeUInt {
6 | constructor(props) {
7 | super(PixelWidth.ELEMENT_ID, PixelWidth.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PixelWidth.COMPACT_NAME = 'PixelWidth';
12 |
13 | PixelWidth.ELEMENT_ID = [0xB0];
14 |
15 | PixelWidth.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | PixelWidth.spec = {
20 | container: 'Video',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/PrevSize.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class PrevSize extends TypeUInt {
6 | constructor(props) {
7 | super(PrevSize.ELEMENT_ID, PrevSize.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | PrevSize.COMPACT_NAME = 'PrevSize';
12 |
13 | PrevSize.ELEMENT_ID = [0xab];
14 |
15 | PrevSize.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | PrevSize.spec = {
20 | container: 'Cluster',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/ReferenceBlock.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeInt from './TypeInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class ReferenceBlock extends TypeInt {
6 | constructor(props) {
7 | super(ReferenceBlock.ELEMENT_ID, ReferenceBlock.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | ReferenceBlock.COMPACT_NAME = 'ReferenceBlock';
12 |
13 | ReferenceBlock.ELEMENT_ID = [0xfb];
14 |
15 | ReferenceBlock.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | ReferenceBlock.spec = {
20 | container: 'BlockGroup',
21 | quantity: Component.QUANTITY_ANY_NUMBER,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SamplingFrequency.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeFloat from './TypeFloat';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SamplingFrequency extends TypeFloat {
6 | constructor(props) {
7 | super(SamplingFrequency.ELEMENT_ID, SamplingFrequency.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SamplingFrequency.COMPACT_NAME = 'SamplingFrequency';
12 |
13 | SamplingFrequency.ELEMENT_ID = [0xB5];
14 |
15 | SamplingFrequency.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | SamplingFrequency.defaultProps = {
20 | value: 8000.0
21 | };
22 |
23 | SamplingFrequency.spec = {
24 | container: 'Audio',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Seek.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Seek extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(Seek.ELEMENT_ID, Seek.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Seek.COMPACT_NAME = 'Seek';
11 |
12 | Seek.ELEMENT_ID = [0x4d, 0xbb];
13 |
14 | Seek.spec = {
15 | container: 'SeekHead',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['SeekID', 'SeekPosition']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SeekHead.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class SeekHead extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(SeekHead.ELEMENT_ID, SeekHead.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | SeekHead.COMPACT_NAME = 'SeekHead';
11 |
12 | SeekHead.ELEMENT_ID = [0x11, 0x4d, 0x9b, 0x74];
13 |
14 | SeekHead.spec = {
15 | container: 'Segment',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: []
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SeekID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeElementId from './TypeElementId';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SeekID extends TypeElementId {
6 | constructor(props) {
7 | super(SeekID.ELEMENT_ID, SeekID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SeekID.COMPACT_NAME = 'SeekID';
12 |
13 | SeekID.ELEMENT_ID = [0x53, 0xab];
14 |
15 | SeekID.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | SeekID.spec = {
20 | container: 'Seek',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SeekPosition.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SeekPosition extends TypeUInt {
6 | constructor(props) {
7 | super(SeekPosition.ELEMENT_ID, SeekPosition.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SeekPosition.COMPACT_NAME = 'SeekPosition';
12 |
13 | SeekPosition.ELEMENT_ID = [0x53, 0xac];
14 |
15 | SeekPosition.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | SeekPosition.spec = {
20 | container: 'Seek',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SeekPreRoll.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SeekPreRoll extends TypeUInt {
6 | constructor(props) {
7 | super(SeekPreRoll.ELEMENT_ID, SeekPreRoll.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SeekPreRoll.COMPACT_NAME = 'SeekPreRoll';
12 |
13 | SeekPreRoll.ELEMENT_ID = [0x56, 0xBB];
14 |
15 | SeekPreRoll.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | SeekPreRoll.defaultProps = {
20 | value: 0
21 | };
22 |
23 | SeekPreRoll.spec = {
24 | container: 'TrackEntry',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Segment.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Segment extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 8;
6 | super(Segment.ELEMENT_ID, Segment.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Segment.COMPACT_NAME = 'Segment';
11 |
12 | Segment.ELEMENT_ID = [0x18, 0x53, 0x80, 0x67];
13 |
14 | Segment.spec = {
15 | container: 'File',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: ['Info']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SegmentUID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SegmentUID extends TypeBytes {
6 | constructor(props) {
7 | super(SegmentUID.ELEMENT_ID, SegmentUID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SegmentUID.COMPACT_NAME = 'SegmentUID';
12 |
13 | SegmentUID.ELEMENT_ID = [0x73, 0xA4];
14 |
15 | SegmentUID.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | SegmentUID.spec = {
20 | container: 'Info',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SimpleBlock.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBlock from './TypeBlock';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class SimpleBlock extends TypeBlock {
6 | constructor(props) {
7 | super(SimpleBlock.ELEMENT_ID, SimpleBlock.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | SimpleBlock.COMPACT_NAME = 'SimpleBlock';
12 |
13 | SimpleBlock.ELEMENT_ID = [0xa3];
14 |
15 | SimpleBlock.propTypes = {
16 | trackNumber: PropTypes.number.isRequired,
17 | timecode: PropTypes.number.isRequired,
18 | flags: PropTypes.shape({
19 | keyframe: PropTypes.bool,
20 | invisible: PropTypes.bool,
21 | discardable: PropTypes.bool
22 | }),
23 | frames: PropTypes.any.isRequired
24 | };
25 |
26 | SimpleBlock.defaultProps = {
27 | flags: {
28 | keyframe: false,
29 | invisible: false,
30 | discardable: false
31 | }
32 | };
33 |
34 | SimpleBlock.spec = {
35 | container: 'Cluster',
36 | quantity: Component.QUANTITY_ANY_NUMBER,
37 | mandatoryList: []
38 | };
39 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/SimpleTag.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class SimpleTag extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(SimpleTag.ELEMENT_ID, SimpleTag.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | SimpleTag.COMPACT_NAME = 'SimpleTag';
11 |
12 | SimpleTag.ELEMENT_ID = [0x67, 0xC8];
13 |
14 | SimpleTag.spec = {
15 | container: 'Tag',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['TagName', 'TagLanguage', 'TagDefault']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Tag.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Tag extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 2;
6 | super(Tag.ELEMENT_ID, Tag.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Tag.COMPACT_NAME = 'Tag';
11 |
12 | Tag.ELEMENT_ID = [0x73, 0x73];
13 |
14 | Tag.spec = {
15 | container: 'Tags',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['Targets', 'SimpleTag']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagBinary.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagBinary extends TypeBytes {
6 | constructor(props) {
7 | super(TagBinary.ELEMENT_ID, TagBinary.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagBinary.COMPACT_NAME = 'TagBinary';
12 |
13 | TagBinary.ELEMENT_ID = [0x44, 0x85];
14 |
15 | TagBinary.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | TagBinary.spec = {
20 | container: 'SimpleTag',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagDefault.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBool from './TypeBool';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagDefault extends TypeBool {
6 | constructor(props) {
7 | super(TagDefault.ELEMENT_ID, TagDefault.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagDefault.COMPACT_NAME = 'TagDefault';
12 |
13 | TagDefault.ELEMENT_ID = [0x44, 0x84];
14 |
15 | TagDefault.propTypes = {
16 | value: PropTypes.bool
17 | };
18 |
19 | TagDefault.defaultProps = {
20 | value: true
21 | };
22 |
23 | TagDefault.spec = {
24 | container: 'SimpleTag',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagLanguage.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagLanguage extends TypeString {
6 | constructor(props) {
7 | super(TagLanguage.ELEMENT_ID, TagLanguage.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagLanguage.COMPACT_NAME = 'TagLanguage';
12 |
13 | TagLanguage.ELEMENT_ID = [0x44, 0x7A];
14 |
15 | TagLanguage.propTypes = {
16 | value: PropTypes.string
17 | };
18 |
19 | TagLanguage.defaultProps = {
20 | value: 'und'
21 | };
22 |
23 | TagLanguage.spec = {
24 | container: 'SimpleTag',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagName.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagName extends TypeString {
6 | constructor(props) {
7 | super(TagName.ELEMENT_ID, TagName.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagName.COMPACT_NAME = 'TagName';
12 |
13 | TagName.ELEMENT_ID = [0x45, 0xA3];
14 |
15 | TagName.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | TagName.spec = {
20 | container: 'SimpleTag',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagString.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagString extends TypeString {
6 | constructor(props) {
7 | super(TagString.ELEMENT_ID, TagString.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagString.COMPACT_NAME = 'TagString';
12 |
13 | TagString.ELEMENT_ID = [0x44, 0x87];
14 |
15 | TagString.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | TagString.spec = {
20 | container: 'SimpleTag',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TagTrackUID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TagTrackUID extends TypeUInt {
6 | constructor(props) {
7 | super(TagTrackUID.ELEMENT_ID, TagTrackUID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TagTrackUID.COMPACT_NAME = 'TagTrackUID';
12 |
13 | TagTrackUID.ELEMENT_ID = [0x63, 0xC5];
14 |
15 | TagTrackUID.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | TagTrackUID.defaultProps = {
20 | value: 0
21 | };
22 |
23 | TagTrackUID.spec = {
24 | container: 'Targets',
25 | quantity: Component.QUANTITY_ANY_NUMBER,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Tags.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Tags extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 4;
6 | super(Tags.ELEMENT_ID, Tags.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Tags.COMPACT_NAME = 'Tags';
11 |
12 | Tags.ELEMENT_ID = [0x12, 0x54, 0xC3, 0x67];
13 |
14 | Tags.spec = {
15 | container: '*',
16 | quantity: Element.QUANTITY_ANY_NUMBER,
17 | mandatoryList: ['Tag']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TargetType.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TargetType extends TypeString {
6 | constructor(props) {
7 | super(TargetType.ELEMENT_ID, TargetType.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TargetType.COMPACT_NAME = 'TargetType';
12 |
13 | TargetType.ELEMENT_ID = [0x63, 0xCA];
14 |
15 | TargetType.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | TargetType.spec = {
20 | container: 'Targets',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TargetTypeValue.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TargetTypeValue extends TypeUInt {
6 | constructor(props) {
7 | super(TargetTypeValue.ELEMENT_ID, TargetTypeValue.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TargetTypeValue.COMPACT_NAME = 'TargetTypeValue';
12 |
13 | TargetTypeValue.ELEMENT_ID = [0x68, 0xCA];
14 |
15 | TargetTypeValue.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | TargetTypeValue.defaultProps = {
20 | value: 0x50
21 | };
22 |
23 | TargetTypeValue.spec = {
24 | container: 'Targets',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Targets.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Targets extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(Targets.ELEMENT_ID, Targets.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Targets.COMPACT_NAME = 'Targets';
11 |
12 | Targets.ELEMENT_ID = [0x63, 0xC0];
13 |
14 | Targets.spec = {
15 | container: 'Tag',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: []
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Timecode.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Timecode extends TypeUInt {
6 | constructor(props) {
7 | super(Timecode.ELEMENT_ID, Timecode.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Timecode.COMPACT_NAME = 'Timecode';
12 |
13 | Timecode.ELEMENT_ID = [0xe7];
14 |
15 | Timecode.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | Timecode.spec = {
20 | container: 'Cluster',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TimecodeScale.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TimecodeScale extends TypeUInt {
6 | constructor(props) {
7 | super(TimecodeScale.ELEMENT_ID, TimecodeScale.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TimecodeScale.COMPACT_NAME = 'TimecodeScale';
12 |
13 | TimecodeScale.ELEMENT_ID = [0x2a, 0xd7, 0xb1];
14 |
15 | TimecodeScale.propTypes = {
16 | value: PropTypes.number
17 | };
18 |
19 | TimecodeScale.defaultProps = {
20 | value: 1000000
21 | };
22 |
23 | TimecodeScale.spec = {
24 | container: 'Info',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Title.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Title extends TypeString {
6 | constructor(props) {
7 | super(Title.ELEMENT_ID, Title.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Title.COMPACT_NAME = 'Title';
12 |
13 | Title.ELEMENT_ID = [0x7b, 0xa9];
14 |
15 | Title.propTypes = {
16 | value: PropTypes.string.isRequired
17 | };
18 |
19 | Title.spec = {
20 | container: 'Info',
21 | quantity: Component.QUANTITY_ZERO_OR_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TrackEntry.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class TrackEntry extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 2;
7 | super(TrackEntry.ELEMENT_ID, TrackEntry.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TrackEntry.COMPACT_NAME = 'TrackEntry';
12 |
13 | TrackEntry.ELEMENT_ID = [0xAE];
14 |
15 | TrackEntry.spec = {
16 | container: 'Tracks',
17 | quantity: Element.QUANTITY_ANY_NUMBER,
18 | mandatoryList: ['TrackNumber', 'TrackUID', 'TrackType', 'FlagEnabled', 'FlagDefault', 'FlagForced', 'FlagLacing', 'CodecID', 'SeekPreRoll']
19 | };
20 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TrackNumber.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TrackNumber extends TypeUInt {
6 | constructor(props) {
7 | super(TrackNumber.ELEMENT_ID, TrackNumber.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TrackNumber.COMPACT_NAME = 'TrackNumber';
12 |
13 | TrackNumber.ELEMENT_ID = [0xd7];
14 |
15 | TrackNumber.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | TrackNumber.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TrackUID.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeUInt from './TypeUInt';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class TrackUID extends TypeUInt {
6 | constructor(props) {
7 | super(TrackUID.ELEMENT_ID, TrackUID.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | TrackUID.COMPACT_NAME = 'TrackUID';
12 |
13 | TrackUID.ELEMENT_ID = [0x73, 0xc5];
14 |
15 | TrackUID.propTypes = {
16 | value: PropTypes.number.isRequired
17 | };
18 |
19 | TrackUID.spec = {
20 | container: 'TrackEntry',
21 | quantity: Component.QUANTITY_EXACTLY_ONE,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Tracks.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import {throwException} from '../../core/Util';
3 |
4 | export default class Tracks extends Element {
5 | constructor(props) {
6 | props.initialSizeLen = 4;
7 | super(Tracks.ELEMENT_ID, Tracks.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Tracks.COMPACT_NAME = 'Tracks';
12 |
13 | Tracks.ELEMENT_ID = [0x16, 0x54, 0xae, 0x6b];
14 |
15 | Tracks.spec = {
16 | container: 'Segment',
17 | quantity: Element.QUANTITY_ANY_NUMBER,
18 | mandatoryList: ['TrackEntry']
19 | };
20 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TypeBool.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Writer from '../../core/Writer';
3 | import Reader from '../../core/Reader';
4 |
5 | export default class TypeBool extends Element {
6 | constructor(...params) {
7 | super(...params);
8 | }
9 |
10 | serialize(buffer, offset=0) {
11 | const value = this.props.value ? 1 : 0;
12 |
13 | let base = offset;
14 |
15 | super.setElementSize(1);
16 |
17 | base += super.serialize(buffer, base);
18 | base += Writer.writeNumber(value, buffer, base, 1);
19 |
20 | return base - offset;
21 | }
22 |
23 | static parse(buffer, offset=0) {
24 | let base = offset,
25 | readBytesNum, props, value;
26 |
27 | [readBytesNum, props] = Element.parse(buffer, base);
28 | base += readBytesNum;
29 |
30 | [readBytesNum, value] = Reader.readNumber(buffer, base, props.size);
31 | base += readBytesNum;
32 |
33 | props.value = !!value;
34 |
35 | return [base - offset, props];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TypeBytes.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Buffer from '../../core/Buffer';
3 | import Reader from '../../core/Reader';
4 | import {throwException} from '../../core/Util';
5 |
6 | export default class TypeBytes extends Element {
7 | constructor(...params) {
8 | super(...params);
9 | }
10 |
11 | serialize(buffer, offset=0) {
12 | const bytes = this.props.value;
13 |
14 | let base = offset;
15 |
16 | super.setElementSize(bytes.length);
17 |
18 | base += super.serialize(buffer, base);
19 |
20 | if (buffer) {
21 | Buffer.wrap(buffer).copyFrom(bytes, 0, bytes.length, base);
22 | }
23 | base += bytes.length;
24 |
25 | return this.size;
26 | }
27 |
28 | static parse(buffer, offset=0) {
29 | let base = offset,
30 | readBytesNum, props, bytes;
31 |
32 | [readBytesNum, props] = Element.parse(buffer, base);
33 | base += readBytesNum;
34 |
35 | Reader.ASSERT(buffer, base, props.size);
36 | const buf = Buffer.wrap(buffer).copy(base, props.size);
37 | base += props.size;
38 | props.value = buf.getView();
39 |
40 | return [base - offset, props];
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TypeDate.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Writer from '../../core/Writer';
3 | import Reader from '../../core/Reader';
4 |
5 | const DIFF_UNIXTIME_AND_MILLENNIUM = 978307200000; // msec
6 |
7 | export default class TypeDate extends Element {
8 | constructor(...params) {
9 | super(...params);
10 | }
11 |
12 | serialize(buffer, offset=0) {
13 | const date = this.props.value;
14 | const sinceMillenium = date.getTime() - DIFF_UNIXTIME_AND_MILLENNIUM; // msec
15 | const value = sinceMillenium * 1000000; // nanosec
16 | const size = 8;
17 |
18 | let base = offset;
19 |
20 | super.setElementSize(size);
21 |
22 | base += super.serialize(buffer, base);
23 | base += Writer.writeNumber(value, buffer, base, size);
24 |
25 | return base - offset;
26 | }
27 |
28 | static parse(buffer, offset=0) {
29 | let base = offset,
30 | readBytesNum, props, value;
31 |
32 | [readBytesNum, props] = Element.parse(buffer, base);
33 | base += readBytesNum;
34 |
35 | [readBytesNum, value] = Reader.readNumber(buffer, base, props.size, true, false);
36 | base += readBytesNum;
37 |
38 | const sinceMillenium = Math.floor(value / 1000000); // msec
39 | const date = new Date(sinceMillenium + DIFF_UNIXTIME_AND_MILLENNIUM);
40 |
41 | props.value = date;
42 |
43 | return [base - offset, props];
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TypeFloat.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Writer from '../../core/Writer';
3 | import Reader from '../../core/Reader';
4 |
5 | export default class TypeFloat extends Element {
6 | constructor(...params) {
7 | super(...params);
8 | }
9 |
10 | serialize(buffer, offset=0) {
11 | const value = this.props.value;
12 | const size = 8;
13 |
14 | let base = offset;
15 |
16 | super.setElementSize(size);
17 |
18 | base += super.serialize(buffer, base);
19 | base += Writer.writeFixedNumber(value, buffer, base, size);
20 |
21 | return base - offset;
22 | }
23 |
24 | static parse(buffer, offset=0) {
25 | let base = offset,
26 | readBytesNum, props, value;
27 |
28 | [readBytesNum, props] = Element.parse(buffer, base);
29 | base += readBytesNum;
30 |
31 | [readBytesNum, value] = Reader.readFixedNumber(buffer, base, props.size);
32 | base += readBytesNum;
33 |
34 | props.value = value;
35 |
36 | return [base - offset, props];
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/TypeString.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Writer from '../../core/Writer';
3 | import Reader from '../../core/Reader';
4 | import {throwException, getUTF8Length} from '../../core/Util';
5 |
6 | export default class TypeString extends Element {
7 | constructor(...params) {
8 | super(...params);
9 | }
10 |
11 | static validate(context, props) {
12 | const maxSizeLength = context.maxSizeLength;
13 | const size = getUTF8Length(props.value);
14 |
15 | if (maxSizeLength) {
16 | const sizeLen = Element.getNecessaryBytesNumForSize(size);
17 | if (sizeLen > maxSizeLength) {
18 | throwException(`Size field cannot exceed the EBMLMaxSizeLength(${maxSizeLength})`);
19 | }
20 | }
21 | }
22 |
23 | serialize(buffer, offset=0) {
24 | const value = this.props.value;
25 | const size = getUTF8Length(value);
26 |
27 | let base = offset;
28 |
29 | super.setElementSize(size);
30 |
31 | base += super.serialize(buffer, base);
32 | base += Writer.writeString(value, buffer, base, size);
33 |
34 | return base - offset;
35 | }
36 |
37 | static parse(buffer, offset=0) {
38 | let base = offset,
39 | readBytesNum, props, value;
40 |
41 | [readBytesNum, props] = Element.parse(buffer, base);
42 | base += readBytesNum;
43 |
44 | [readBytesNum, value] = Reader.readString(buffer, base, props.size);
45 | base += readBytesNum;
46 |
47 | props.value = value;
48 |
49 | return [base - offset, props];
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Unknown.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 | import Buffer from '../../core/Buffer';
3 | import Reader from '../../core/Reader';
4 | import {throwException} from '../../core/Util';
5 |
6 | export default function createUnknownElement(id) {
7 | class Unknown extends Element {
8 | constructor(props) {
9 | props.initialSizeLen = 1;
10 | super(Unknown.ELEMENT_ID, Unknown.COMPACT_NAME, props);
11 | }
12 |
13 | serialize(buffer, offset=0) {
14 | const bytes = this.props.value;
15 |
16 | let base = offset;
17 |
18 | super.setElementSize(bytes.length);
19 |
20 | base += super.serialize(buffer, base);
21 |
22 | if (buffer) {
23 | Buffer.wrap(buffer).copyFrom(bytes, 0, bytes.length, base);
24 | }
25 | base += bytes.length;
26 |
27 | return this.size;
28 | }
29 |
30 | static parse(buffer, offset=0) {
31 | let base = offset,
32 | readBytesNum, props;
33 |
34 | [readBytesNum, props] = Element.parse(buffer, base);
35 | base += readBytesNum;
36 |
37 | Reader.ASSERT(buffer, base, props.size);
38 | const buf = Buffer.wrap(buffer).copy(base, props.size);
39 | base += props.size;
40 | props.value = buf.getView();
41 |
42 | return [base - offset, props];
43 | }
44 | }
45 |
46 | Unknown.ELEMENT_ID = id;
47 | Unknown.COMPACT_NAME = `[${id.map(item => Number(item).toString(16)).join(', ')}]`;
48 |
49 | return Unknown;
50 | }
51 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Video.js:
--------------------------------------------------------------------------------
1 | import Element from './Element';
2 |
3 | export default class Video extends Element {
4 | constructor(props) {
5 | props.initialSizeLen = 1;
6 | super(Video.ELEMENT_ID, Video.COMPACT_NAME, props);
7 | }
8 | }
9 |
10 | Video.COMPACT_NAME = 'Video';
11 |
12 | Video.ELEMENT_ID = [0xe0];
13 |
14 | Video.spec = {
15 | container: 'TrackEntry',
16 | quantity: Element.QUANTITY_EXACTLY_ONE,
17 | mandatoryList: ['FlagInterlaced', 'PixelWidth', 'PixelHeight']
18 | };
19 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/Void.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeBytes from './TypeBytes';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class Void extends TypeBytes {
6 | constructor(props) {
7 | super(Void.ELEMENT_ID, Void.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | Void.COMPACT_NAME = 'Void';
12 |
13 | Void.ELEMENT_ID = [0xEC];
14 |
15 | Void.propTypes = {
16 | value: PropTypes.any.isRequired
17 | };
18 |
19 | Void.spec = {
20 | container: '*',
21 | quantity: Component.QUANTITY_ANY_NUMBER,
22 | mandatoryList: []
23 | };
24 |
--------------------------------------------------------------------------------
/src/Matroska/EBMLElement/WritingApp.js:
--------------------------------------------------------------------------------
1 | import Component from '../../core/Component';
2 | import TypeString from './TypeString';
3 | import PropTypes from '../../core/PropTypes';
4 |
5 | export default class WritingApp extends TypeString {
6 | constructor(props) {
7 | super(WritingApp.ELEMENT_ID, WritingApp.COMPACT_NAME, props);
8 | }
9 | }
10 |
11 | WritingApp.COMPACT_NAME = 'WritingApp';
12 |
13 | WritingApp.ELEMENT_ID = [0x57, 0x41];
14 |
15 | WritingApp.propTypes = {
16 | value: PropTypes.string
17 | };
18 |
19 | WritingApp.defaultProps = {
20 | value: 'kontainer-js'
21 | };
22 |
23 | WritingApp.spec = {
24 | container: 'Info',
25 | quantity: Component.QUANTITY_EXACTLY_ONE,
26 | mandatoryList: []
27 | };
28 |
--------------------------------------------------------------------------------
/src/cli.js:
--------------------------------------------------------------------------------
1 | import fs from 'fs';
2 | import yargs from 'yargs';
3 | import Kontainer from '.';
4 |
5 | const argv = yargs.argv;
6 | const HELP = `
7 | Usage:
8 | kontainer filePath [options]
9 |
10 | Example:
11 | kontainer /path/to/file
12 |
13 | Options:
14 | -h, --help Print help
15 | -v, --version Print version
16 | `;
17 |
18 | let pkg;
19 |
20 | try {
21 | pkg = require('./package.json');
22 | } catch (e) {
23 | // Being executed locally
24 | pkg = require('../package.json');
25 | }
26 |
27 | const VERSION = `v${pkg.version}`;
28 | const filePath = argv._[0];
29 |
30 | if (argv.h || argv.help) {
31 | console.info(HELP);
32 | } else if (argv.v || argv.version) {
33 | console.info(VERSION);
34 | } else {
35 |
36 | let input;
37 |
38 | if (filePath) {
39 | input = fs.createReadStream(filePath);
40 | } else {
41 | input = process.stdin;
42 | }
43 |
44 | const visitor = new Kontainer.DumpVisitor();
45 | const logger = Kontainer.transform(visitor);
46 |
47 | input.pipe(logger).pipe(process.stdout);
48 |
49 | input.on('error', () => {
50 | console.error('[kontainer] Unable to read - ' + filePath);
51 | });
52 | }
53 |
--------------------------------------------------------------------------------
/src/core/Buffer.js:
--------------------------------------------------------------------------------
1 | export default class Buffer {
2 | constructor(...params) {
3 | if (global && global.Buffer) {
4 | this.buffer = new global.Buffer(...params);
5 | } else {
6 | if (params.length === 1 && params[0] && typeof params[0][Symbol.iterator] === 'function') {
7 | this.buffer = Uint8Array.from(params[0]);
8 | } else {
9 | this.buffer = new Uint8Array(...params);
10 | }
11 | }
12 | }
13 |
14 | static wrap(buffer) {
15 | const buf = new Buffer(0);
16 | buf.buffer = buffer;
17 | return buf;
18 | }
19 |
20 | getView() {
21 | return this.buffer;
22 | }
23 |
24 | getData() {
25 | const buf = this.buffer;
26 | if (global && global.Buffer && buf instanceof global.Buffer) {
27 | return buf;
28 | } else {
29 | return buf.buffer;
30 | }
31 | }
32 |
33 | getLength() {
34 | if (global && global.Buffer) {
35 | return this.buffer.length;
36 | } else {
37 | return this.buffer.byteLength;
38 | }
39 | }
40 |
41 | copy(start, length) {
42 | if (global && global.Buffer) {
43 | let buf = new global.Buffer(length);
44 | this.buffer.copy(buf, 0, start, start + length);
45 | return Buffer.wrap(buf);
46 | } else {
47 | return Buffer.wrap(this.buffer.slice(start, start + length));
48 | }
49 | }
50 |
51 | copyFrom(src, srcOffset, length, thisOffset=0) {
52 | if (global && global.Buffer) {
53 | src.copy(this.buffer, thisOffset, srcOffset, srcOffset + length);
54 | } else {
55 | this.buffer.subarray(thisOffset, thisOffset + length).set(src, srcOffset);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/core/Component.js:
--------------------------------------------------------------------------------
1 | export default class Component {
2 | constructor(type, props) {
3 | this.type = type;
4 | this.props = props;
5 | }
6 |
7 | // To be overridden
8 | static validate(context, props) {
9 | void props;
10 | }
11 |
12 | // To be overridden
13 | serialize(buffer, offset) {
14 | void offset;
15 | }
16 |
17 | // To be overridden
18 | getSize() {
19 | }
20 |
21 | // To be overridden
22 | setSize(size, buffer, offset) {
23 | void offset;
24 | }
25 |
26 | // To be overridden
27 | toString(context) {
28 | void context;
29 | }
30 |
31 | // To be overridden
32 | static parse(buffer, offset) {
33 | void offset;
34 | }
35 |
36 | // To be overridden
37 | static getMimeType(element) {
38 | return '';
39 | }
40 | }
41 |
42 | Component.QUANTITY_ANY_NUMBER = 0;
43 | Component.QUANTITY_EXACTLY_ONE = 1;
44 | Component.QUANTITY_ZERO_OR_ONE = 2;
45 |
--------------------------------------------------------------------------------
/src/core/Error.js:
--------------------------------------------------------------------------------
1 | export class BufferReadError extends Error {
2 | constructor(pendingData=null) {
3 | super(BufferReadError.ERROR_MESSAGE);
4 | this.pendingData = pendingData;
5 | }
6 | }
7 | BufferReadError.ERROR_MESSAGE = 'Interrupted by insufficient buffer.';
8 |
--------------------------------------------------------------------------------
/src/core/Stream.js:
--------------------------------------------------------------------------------
1 | import Buffer from './Buffer';
2 |
3 | export let TransformStream;
4 |
5 | if (global && global.Buffer) {
6 | const Transform = require('stream').Transform;
7 |
8 | class NodeTransform extends Transform {
9 | constructor(parser, options={}) {
10 | super(options);
11 | this.buffer = null;
12 | this.offset = 0;
13 | this.parser = parser;
14 | this.options = options;
15 | }
16 |
17 | _transform(chunk, encoding, done) {
18 | if (chunk instanceof global.Buffer) {
19 | if (this.buffer) {
20 | this.offset = this.buffer.length;
21 | this.buffer = global.Buffer.concat([this.buffer, chunk]);
22 | } else {
23 | this.buffer = chunk;
24 | }
25 | this.parser(new Buffer(this.buffer), this.offset, (event, param) => {
26 | if (event === 'done') {
27 | let b;
28 | if (param && param instanceof Buffer) {
29 | b = param.getData();
30 | } else {
31 | b = param;
32 | }
33 | done(null, b);
34 | } else {
35 | this.emit(event, param);
36 | }
37 | });
38 | }
39 | }
40 |
41 | _flush(done) {
42 | done();
43 | }
44 |
45 | setOptions(options) {
46 | Object.assign(this.options, options);
47 | }
48 | }
49 |
50 | TransformStream = NodeTransform;
51 | } else {
52 | // TODO (WhatWG's streams)
53 | }
54 |
--------------------------------------------------------------------------------
/src/core/Util.js:
--------------------------------------------------------------------------------
1 | export function isNegative(value, bitLength) {
2 | return !!(value & (1 << (bitLength - 1)));
3 | }
4 |
5 | export function convertToNegative(value, bitLength) {
6 | const mask = (1 << bitLength) - 1;
7 | return -((~value & mask) + 1);
8 | }
9 |
10 | export function throwException(message) {
11 | throw new Error(message);
12 | }
13 |
14 | export function getUTF8Length(string) {
15 | return string.split('').map(ch => {
16 | const charCode = ch.charCodeAt(0);
17 | if (charCode < 0x80) {
18 | return 1;
19 | } else if (charCode >= 0x80 && charCode < 0x800) {
20 | return 2;
21 | } else if (charCode >= 0x800 && charCode < 0x10000) {
22 | return 3;
23 | } else if (charCode >= 0x10000 && charCode < 0x200000) {
24 | return 4;
25 | } else if (charCode >= 0x200000 && charCode < 0x4000000) {
26 | return 5;
27 | } else if (charCode >= 0x4000000 && charCode < 0x80000000) {
28 | return 6;
29 | } else {
30 | return 0
31 | }
32 | }).reduce((a, b) => a + b);
33 | }
34 |
--------------------------------------------------------------------------------
/test/contents/Matroska/test1.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test1.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test2.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test2.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test3.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test3.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test4.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test4.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test5.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test5.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test6.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test6.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test7.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test7.mkv
--------------------------------------------------------------------------------
/test/contents/Matroska/test8.mkv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kuu/Kontainer/d08a51841bc2aca39e7e387d7dc616ba9b1d9c9e/test/contents/Matroska/test8.mkv
--------------------------------------------------------------------------------
/test/spec/IsoBmff/Box/file.spec.js:
--------------------------------------------------------------------------------
1 | import Kontainer from 'kontainer-js';
2 | import customMatchers from '../../../helper/matcher';
3 | import sample from '../../../helper/IsoBmff';
4 | import Buffer from '../../../../src/core/Buffer';
5 |
6 | describe('File', () => {
7 | beforeEach(() => {
8 | jasmine.addMatchers(customMatchers);
9 | Kontainer.use('mp4');
10 | });
11 |
12 | const topLevelElement = sample.element,
13 | value = sample.buffer;
14 |
15 | it('generates a binary data from KontainerElements', () => {
16 | let buffer, elem, array;
17 |
18 | buffer = Kontainer.render(
19 |