├── .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 | 20 | 21 | 22 | 23 | 24 | ); 25 | expect(buffer).toBe(null); 26 | 27 | const len = Kontainer.render(topLevelElement, {dryRun: true}); 28 | buffer = Kontainer.render(topLevelElement); 29 | expect(buffer).not.toBe(null); 30 | expect(new Buffer(buffer).getLength()).toBe(len); 31 | expect(buffer).toBeTheSameBuffer(value); 32 | elem = Kontainer.createElementFromBuffer(buffer); 33 | expect(elem).toHaveTheSameProps(topLevelElement); 34 | }); 35 | 36 | it('parses a binary data into KontainerElements', () => { 37 | let b, elem, buf, array; 38 | 39 | if (global.Buffer) { 40 | b = new global.Buffer(value); 41 | } else { 42 | buf = new Uint8Array(value); 43 | b = buf.buffer; 44 | } 45 | elem = Kontainer.createElementFromBuffer(b); 46 | expect(elem).not.toBe(null); 47 | buf = Kontainer.render(elem); 48 | expect(buf).not.toBe(null); 49 | expect(buf).toBeTheSameBuffer(value); 50 | }); 51 | }); 52 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/ftyp.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FileTypeBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const defaultValue = [ 11 | 0, 0, 0, 16, // size=16 12 | 102, 116, 121, 112, // type='ftyp' 13 | 105, 115, 111, 109, // major_brand='isom' 14 | 0, 0, 0, 0 // minor_version=0 15 | ], 16 | avc1Value = [ 17 | 0, 0, 0, 24, // size=24 18 | 102, 116, 121, 112, // type='ftyp' 19 | 97, 118, 99, 49, // major_brand='avc1' 20 | 0, 0, 0, 2, // minor_version=2 21 | 105, 115, 111, 109, // compatible_brands[0]='isom' 22 | 105, 115, 111, 50 // compatible_brands[1]='iso2' 23 | ]; 24 | 25 | it('requires major_brand', () => { 26 | const buffer = Kontainer.render(); 27 | expect(buffer).toBe(null); 28 | }); 29 | 30 | it('can be initialized with the default values', () => { 31 | const buffer = Kontainer.render(); 32 | expect(buffer).toBeTheSameBuffer(defaultValue); 33 | }); 34 | 35 | it('can be initialized with the specified values', () => { 36 | const buffer = Kontainer.render(); 37 | expect(buffer).toBeTheSameBuffer(avc1Value); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/mdat.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('MediaDataBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const mdatValue = [ 11 | 0, 0, 0, 16, // size=16 12 | 109, 100, 97, 116, // type='mdat' 13 | 1, 2, 4, 8, 14 | 16, 32, 64, 128 15 | ]; 16 | 17 | it('can wrrap raw bytes', () => { 18 | const data = new Buffer(8); 19 | for (let i = 0; i < 8; i++) { 20 | data[i] = (1 << i); 21 | } 22 | const buffer = Kontainer.render(); 23 | expect(buffer).not.toBe(null); 24 | expect(buffer).toBeTheSameBuffer(mdatValue); 25 | const element = Kontainer.createElementFromBuffer(buffer); 26 | expect(element).not.toBe(null); 27 | expect(element.props.data).toBeTheSameBuffer(mdatValue.slice(8)); 28 | expect(element.props.byteOffset).toBe(8); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/mehd.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('MovieExtendsHeaderBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const value1 = [ 11 | 0, 0, 0, 16, // size=16 12 | 109, 101, 104, 100, // type='mehd' 13 | 0, 0, 0, 0, // version=0, flags=0 14 | 1, 0, 0, 0 // fragment_duration=16777216 15 | ], 16 | value2 = [ 17 | 0, 0, 0, 20, // size=20 18 | 109, 101, 104, 100, // type='mehd' 19 | 1, 0, 0, 0, // version=1, flags=0 20 | 0, 0, 0, 1, // fragment_duration=4294967296 21 | 0, 0, 0, 0 22 | ]; 23 | 24 | it('supports 32 bit duration', () => { 25 | const mehdElement = ; 26 | const buffer = Kontainer.render(mehdElement); 27 | expect(buffer).not.toBe(null); 28 | expect(buffer).toBeTheSameBuffer(value1); 29 | const element = Kontainer.createElementFromBuffer(buffer); 30 | expect(element).not.toBe(null); 31 | expect(mehdElement).toHaveTheSameProps(element); 32 | }); 33 | 34 | it('supports 64 bit duration', () => { 35 | const mehdElement = ; 36 | const buffer = Kontainer.render(mehdElement); 37 | expect(buffer).not.toBe(null); 38 | expect(buffer).toBeTheSameBuffer(value2); 39 | const element = Kontainer.createElementFromBuffer(buffer); 40 | expect(element).not.toBe(null); 41 | expect(mehdElement).toHaveTheSameProps(element); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/mfhd.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('MovieFragmentHeaderBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const value1 = [ 11 | 0, 0, 0, 16, // size=16 12 | 109, 102, 104, 100, // type='mfhd' 13 | 0, 0, 0, 0, // version=0, flags=0 14 | 0, 0, 0, 0 // sequence_number=0 15 | ], 16 | value2 = [ 17 | 0, 0, 0, 16, // size=16 18 | 109, 102, 104, 100, // type='mfhd' 19 | 0, 0, 0, 0, // version=0, flags=0 20 | 255, 255, 255, 255 // sequence_number=0xFFFFFFFF 21 | ]; 22 | 23 | it('supports the smallest sequence number.', () => { 24 | const mfhdElement = ; 25 | const buffer = Kontainer.render(mfhdElement); 26 | expect(buffer).not.toBe(null); 27 | expect(buffer).toBeTheSameBuffer(value1); 28 | const element = Kontainer.createElementFromBuffer(buffer); 29 | expect(element).not.toBe(null); 30 | expect(mfhdElement).toHaveTheSameProps(element); 31 | }); 32 | 33 | it('supports the largest sequence number.', () => { 34 | const mfhdElement = ; 35 | const buffer = Kontainer.render(mfhdElement); 36 | expect(buffer).not.toBe(null); 37 | expect(buffer).toBeTheSameBuffer(value2); 38 | const element = Kontainer.createElementFromBuffer(buffer); 39 | expect(element).not.toBe(null); 40 | expect(mfhdElement).toHaveTheSameProps(element); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/stco.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChunkOffsetBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const value1 = [ 11 | 0, 0, 0, 16, // size=16 12 | 115, 116, 99, 111, // type='stco' 13 | 0, 0, 0, 0, // version=0, flags=0 14 | 0, 0, 0, 0 // entry_count=0 15 | ], 16 | value2 = [ 17 | 0, 0, 0, 28, // size=28 18 | 115, 116, 99, 111, // type='stco' 19 | 0, 0, 0, 0, // version=0, flags=0 20 | 0, 0, 0, 3, // entry_count=3 21 | 0, 0, 0, 1, // chunk_offset=1 22 | 0, 0, 0, 2, // chunk_offset=2 23 | 0, 0, 0, 3 // chunk_offset=3 24 | ]; 25 | 26 | it('supports zero entry', () => { 27 | const stcoElement = ; 28 | const buffer = Kontainer.render(stcoElement); 29 | expect(buffer).not.toBe(null); 30 | expect(buffer).toBeTheSameBuffer(value1); 31 | const element = Kontainer.createElementFromBuffer(buffer); 32 | expect(element).not.toBe(null); 33 | expect(stcoElement).toHaveTheSameProps(element); 34 | }); 35 | 36 | it('supports multiple entries', () => { 37 | const stcoElement = ; 38 | const buffer = Kontainer.render(stcoElement); 39 | expect(buffer).not.toBe(null); 40 | expect(buffer).toBeTheSameBuffer(value2); 41 | const element = Kontainer.createElementFromBuffer(buffer); 42 | expect(element).not.toBe(null); 43 | expect(stcoElement).toHaveTheSameProps(element); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/tfdt.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TrackFragmentBaseMediaDecodeTimeBox', () => { 5 | beforeEach(() => { 6 | jasmine.addMatchers(customMatchers); 7 | Kontainer.use('mp4'); 8 | }); 9 | 10 | const tfdtValue = [ 11 | 0, 0, 0, 16, // size=16 12 | 116, 102, 100, 116, // type='tfdt' 13 | 0, 0, 0, 0, // version=0, flags=0 14 | 0, 1, 0, 0 // baseMediaDecodeTime=65536 15 | ]; 16 | 17 | it('provides the decode time of the first sample in the track fragment', () => { 18 | let element = ; 19 | let buffer = Kontainer.render(element); 20 | expect(buffer).not.toBe(null); 21 | expect(buffer).toBeTheSameBuffer(tfdtValue); 22 | const element2 = Kontainer.createElementFromBuffer(buffer); 23 | expect(element).toHaveTheSameProps(element2); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/IsoBmff/Box/unknown.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('UnknownBox', () => { 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('mp4'); 9 | }); 10 | 11 | const UNKNOWN_BOX_NAME = 'a '; 12 | const unknownValue = [ 13 | 0, 0, 0, 16, // size=16 14 | 97, 32, 32, 32, // type='a ' (unknown) 15 | 1, 2, 4, 8, 16 | 16, 32, 64, 128 17 | ]; 18 | 19 | it('can keep unknown box untouched', () => { 20 | 21 | const element = Kontainer.createElementFromBuffer((new Buffer(unknownValue)).getData()); 22 | expect(element).not.toBe(null); 23 | expect(element.type.COMPACT_NAME).toEqual(UNKNOWN_BOX_NAME); 24 | const buffer = Kontainer.render(element); 25 | expect(buffer).toBeTheSameBuffer(unknownValue); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/AESSettingsCipherMode.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('AESSettingsCipherMode', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 71, 232, 129, 1, // EBML-id [47][E8], size=1 [81], cipher mode=CTR 13 | ]; 14 | 15 | it('should parse/serialize the AESSettingsCipherMode element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/AlphaMode.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('AlphaMode', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 192, 129, 1, // EBML-id [53][C0], size=1 [81], hasAlpha 13 | ]; 14 | 15 | it('should parse/serialize the AlphaMode element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/AspectRatioType.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('AspectRatioType', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 179, 129, 1, // EBML-id [54][B3], size=1 [81], kind=keep 13 | ]; 14 | 15 | it('should parse/serialize the AspectRatioType element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Audio.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Audio', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 225, 156, // EBML-id [E1], size=28 [9C] 13 | 181, 136, 0, 0, 172, 68, 0, 0, 0, 0, // EBML-id [B5], size=8 [88], samplingRate=44.1kHz 14 | 120, 181, 136, 0, 0, 125, 0, 0, 0, 0, 0, // EBML-id [78][B5], size=8 [88], samplingRate=32kHz 15 | 159, 129, 2, // EBML-id [9F], size=1 [81], channels=stereo 16 | 98, 100, 129, 8, // EBML-id [62][64], size=1 [81], depth=8 17 | ]; 18 | 19 | it('should parse/serialize the Audio element', () => { 20 | const element1 = ; 26 | const buffer = Kontainer.render(element1); 27 | expect(buffer).not.toBe(null); 28 | expect(buffer).toBeTheSameBuffer(value); 29 | const element2 = Kontainer.createElementFromBuffer(buffer); 30 | expect(element2).not.toBe(null); 31 | expect(element2).toHaveTheSameProps(element1); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/BitDepth.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('BitDepth', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 98, 100, 129, 8, // EBML-id [62][64], size=1 [81], depth=8 13 | ]; 14 | 15 | it('should parse/serialize the BitDepth element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Block.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('Block', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | let value = [ 13 | 161, 197, // EBML-id [A1], size=6+63=69 [C5] 14 | 254, // Track Number=126 15 | 0, 33, // Timecode=33 (ms) 16 | 14, // Invisible=true, Lacing=EBML 17 | 0, // Number of frames in the lace-1 18 | 191, // Lacing sizes=63 [BF] 19 | ]; 20 | 21 | const frame1 = (new Array(63)).fill(1); 22 | 23 | value = value.concat(frame1); 24 | 25 | it('should parse/serialize the Block element', () => { 26 | const element1 = ; 32 | const buffer = Kontainer.render(element1); 33 | expect(buffer).not.toBe(null); 34 | /* 35 | console.log('++++++++++'); 36 | for (let i = 0; i < buffer.length; i++) { 37 | console.log(`\tbuffer[${i}]=${buffer[i]}`); 38 | } 39 | */ 40 | expect(buffer).toBeTheSameBuffer(value); 41 | const element2 = Kontainer.createElementFromBuffer(buffer); 42 | expect(element2).not.toBe(null); 43 | expect(element2).toHaveTheSameProps(element1); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/BlockAddID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('BlockAddID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 238, 130, 1, 244, // EBML-id [EE], size=2 [82], id=500 [41][f4] 13 | ]; 14 | 15 | it('should parse/serialize the BlockAddID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/BlockAdditional.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('BlockAdditional', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 165, 133, 1, 2, 3, 4, 5, // EBML-id [A5], size=5 [85], data=[1,2,3,4,5] 14 | ]; 15 | 16 | it('should parse/serialize the BlockAdditional element', () => { 17 | const buf = new Buffer([1, 2, 3, 4, 5]).getView(); 18 | const element1 = ; 19 | const buffer = Kontainer.render(element1); 20 | expect(buffer).not.toBe(null); 21 | expect(buffer).toBeTheSameBuffer(value); 22 | const element2 = Kontainer.createElementFromBuffer(buffer); 23 | expect(element2).not.toBe(null); 24 | expect(element2).toHaveTheSameProps(element1); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/BlockDuration.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('BlockDuration', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 155, 130, 2, 148, // EBML-id [9B], size=2 [82], duration=660 [02][94] 13 | ]; 14 | 15 | it('should parse/serialize the BlockDuration element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/BlockMore.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('BlockMore', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 166, 64, 11, // EBML-id [A6], size=11 [40][0b] 14 | 238, 130, 1, 244, // EBML-id [EE], size=2 [82], id=500 [41][f4] 15 | 165, 133, 1, 2, 3, 4, 5, // EBML-id [A5], size=5 [85], data=[1,2,3,4,5] 16 | ]; 17 | 18 | it('should parse/serialize the BlockMore element', () => { 19 | const buf = new Buffer([1, 2, 3, 4, 5]).getView(); 20 | const element1 = 21 | 22 | 23 | ; 24 | const buffer = Kontainer.render(element1); 25 | expect(buffer).not.toBe(null); 26 | expect(buffer).toBeTheSameBuffer(value); 27 | const element2 = Kontainer.createElementFromBuffer(buffer); 28 | expect(element2).not.toBe(null); 29 | expect(element2).toHaveTheSameProps(element1); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Channels.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Channels', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 159, 129, 2, // EBML-id [9F], size=1 [81], channels=stereo 13 | ]; 14 | 15 | it('should parse/serialize the Channels element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapCountry.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapCountry', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 67, 126, 130, 106, 112, // EBML-id [43][7E], size=2 [82], country="jp" 13 | ]; 14 | 15 | it('should parse/serialize the ChapCountry element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapLanguage.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapLanguage', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 67, 124, 131, 106, 112, 110, // EBML-id [43][7C], size=3 [83], country="jpn" 13 | ]; 14 | 15 | it('should parse/serialize the ChapLanguage element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapString.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapString', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 133, 149, 227, 130, 143, 227, 129, 159, 227, 129, 151, 227, 129, 175, 227, 129, 139, 227, 130, 130, 227, 130, 129, // EBML-id [85], size=21 [95], id=”I'm a seagull" in Japanese 13 | ]; 14 | 15 | it('should parse/serialize the ChapString element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapterDisplay.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapterDisplay', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 128, 162, // EBML-id [80], size=34 [A2] 13 | 133, 149, 227, 130, 143, 227, 129, 159, 227, 129, 151, 227, 129, 175, 227, 129, 139, 227, 130, 130, 227, 130, 129, // EBML-id [85], size=21 [95], id=”I'm a seagull" in Japanese 14 | 67, 124, 131, 106, 112, 110, // EBML-id [43][7C], size=3 [83], country="jpn" 15 | 67, 126, 130, 106, 112, // EBML-id [43][7E], size=2 [82], country="jp" 16 | ]; 17 | 18 | it('should parse/serialize the ChapterDisplay element', () => { 19 | const element1 = 20 | 21 | 22 | 23 | ; 24 | const buffer = Kontainer.render(element1); 25 | expect(buffer).not.toBe(null); 26 | expect(buffer).toBeTheSameBuffer(value); 27 | const element2 = Kontainer.createElementFromBuffer(buffer); 28 | expect(element2).not.toBe(null); 29 | expect(element2).toHaveTheSameProps(element1); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapterStringUID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapterStringUID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 86, 84, 149, 227, 130, 143, 227, 129, 159, 227, 129, 151, 227, 129, 175, 227, 129, 139, 227, 130, 130, 227, 130, 129, // EBML-id [56][54], size=21 [95], id=”I'm a seagull" in Japanese 13 | ]; 14 | 15 | it('should parse/serialize the ChapterStringUID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapterTimeEnd.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapterTimeEnd', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 146, 134, 6, 140, 97, 113, 64, 0, // EBML-id [92], size=6 [86], duration=2 hours (in nanosec) 13 | ]; 14 | 15 | it('should parse/serialize the ChapterTimeEnd element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapterTimeStart.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapterTimeStart', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 145, 134, 6, 140, 97, 113, 64, 0, // EBML-id [91], size=6 [86], duration=2 hours (in nanosec) 13 | ]; 14 | 15 | it('should parse/serialize the ChapterTimeStart element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ChapterUID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ChapterUID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 115, 196, 129, 127, // EBML-id [73][C4], size=1 [81], id=127 13 | ]; 14 | 15 | it('should parse/serialize the ChapterUID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CodecDelay.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CodecDelay', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 86, 170, 131, 76, 75, 64, // EBML-id [56][AA], size=3 [83], delay=5ms 13 | ]; 14 | 15 | it('should parse/serialize the CodecDelay element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CodecID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CodecID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 134, 136, 65, 95, 86, 79, 82, 66, 73, 83, // EBML-id [86], size=8 [88], codec id="A_VORBIS" 13 | ]; 14 | 15 | it('should parse/serialize the CodecID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CodecName.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CodecName', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 37, 134, 136, 146, 227, 129, 136, 227, 129, 131, 227, 129, 161, 228, 186, 140, 229, 133, 173, 229, 155, 155, // EBML-id [25][86][88], size=18 [92], name="H.264" in Japanese 13 | ]; 14 | 15 | it('should parse/serialize the CodecName element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CodecPrivate.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('CodecPrivate', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 99, 162, 133, 1, 2, 3, 4, 5, // EBML-id [63][A2], size=5 [85], version=1 14 | ]; 15 | 16 | it('should parse/serialize the CodecPrivate element', () => { 17 | const element1 = ; 18 | const buffer = Kontainer.render(element1); 19 | expect(buffer).not.toBe(null); 20 | expect(buffer).toBeTheSameBuffer(value); 21 | const element2 = Kontainer.createElementFromBuffer(buffer); 22 | expect(element2).not.toBe(null); 23 | expect(element2).toHaveTheSameProps(element1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncAESSettings.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ContentEncAESSettings', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 71, 231, 132, // EBML-id [47][E7], size=4 [84] 13 | 71, 232, 129, 1, // EBML-id [47][E8], size=1 [81], cipher mode=CTR 14 | ]; 15 | 16 | it('should parse/serialize the ContentEncAESSettings element', () => { 17 | const element1 = 18 | 19 | ; 20 | const buffer = Kontainer.render(element1); 21 | expect(buffer).not.toBe(null); 22 | expect(buffer).toBeTheSameBuffer(value); 23 | const element2 = Kontainer.createElementFromBuffer(buffer); 24 | expect(element2).not.toBe(null); 25 | expect(element2).toHaveTheSameProps(element1); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncAlgo.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ContentEncAlgo', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 71, 225, 129, 5, // EBML-id [47][E1], size=1 [81], algorithm=AES [5] 13 | ]; 14 | 15 | it('should parse/serialize the ContentEncAlgo element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncKeyID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('ContentEncKeyID', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 71, 226, 133, 1, 2, 3, 4, 5, // EBML-id [47][E2], size=5 [85], keyId 14 | ]; 15 | 16 | it('should parse/serialize the ContentEncKeyID element', () => { 17 | const element1 = ; 18 | const buffer = Kontainer.render(element1); 19 | expect(buffer).not.toBe(null); 20 | expect(buffer).toBeTheSameBuffer(value); 21 | const element2 = Kontainer.createElementFromBuffer(buffer); 22 | expect(element2).not.toBe(null); 23 | expect(element2).toHaveTheSameProps(element1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncodingOrder.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ContentEncodingOrder', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 80, 49, 129, 0, // EBML-id [50][31], size=1 [81], order=0 13 | ]; 14 | 15 | it('should parse/serialize the ContentEncodingOrder element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncodingScope.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ContentEncodingScope', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 80, 50, 129, 3, // EBML-id [50][32], size=1 [81], encrypted=(frame|private) 13 | ]; 14 | 15 | it('should parse/serialize the ContentEncodingScope element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncodingType.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ContentEncodingType', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 80, 51, 129, 1, // EBML-id [50][33], size=1 [81], type=encryption [1] 13 | ]; 14 | 15 | it('should parse/serialize the ContentEncodingType element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ContentEncryption.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('ContentEncryption', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 80, 53, 147, // EBML-id [50][35], size=19 [93] 14 | 71, 225, 129, 5, // EBML-id [47][E1], size=1 [81], algorithm=AES [5] 15 | 71, 226, 133, 1, 2, 3, 4, 5, // EBML-id [47][E2], size=5 [85], keyId 16 | 71, 231, 132, // EBML-id [47][E7], size=4 [84] 17 | 71, 232, 129, 1, // EBML-id [47][E8], size=1 [81], cipher mode=CTR 18 | ]; 19 | 20 | it('should parse/serialize the ContentEncryption element', () => { 21 | const element1 = 22 | 23 | 24 | 25 | 26 | 27 | ; 28 | const buffer = Kontainer.render(element1); 29 | expect(buffer).not.toBe(null); 30 | /* 31 | console.log('++++++++++'); 32 | for (let i = 0; i < buffer.length; i++) { 33 | console.log(`\tbuffer[${i}]=${buffer[i]}`); 34 | } 35 | */ 36 | expect(buffer).toBeTheSameBuffer(value); 37 | const element2 = Kontainer.createElementFromBuffer(buffer); 38 | expect(element2).not.toBe(null); 39 | expect(element2).toHaveTheSameProps(element1); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueBlockNumber.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueBlockNumber', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 120, 129, 3, // EBML-id [53][78], size=1 [83], num=3 13 | ]; 14 | 15 | it('should parse/serialize the CueBlockNumber element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueClusterPosition.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueClusterPosition', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 241, 131, 1, 0, 0, // EBML-id [F1], size=3 [83], position=65536 13 | ]; 14 | 15 | it('should parse/serialize the CueClusterPosition element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueDuration.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueDuration', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 178, 132, 1, 247, 138, 64, // EBML-id [B2], size=4 [84], duration=33ms [01][F7][8A][40] 13 | ]; 14 | 15 | it('should parse/serialize the CueDuration element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueRelativePosition.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueRelativePosition', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 240, 130, 5, 0, // EBML-id [F0], size=2 [82], offset=1280 [05][00] 13 | ]; 14 | 15 | it('should parse/serialize the CueRelativePosition element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueTime.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueTime', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 179, 134, 6, 140, 97, 113, 64, 0, // EBML-id [B3], size=6 [86], timestamp=2 hours (in nanosec) 13 | ]; 14 | 15 | it('should parse/serialize the CueTime element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueTrack.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueTrack', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 247, 129, 127, // EBML-id [F7], size=1 [81], trackUID=127 13 | ]; 14 | 15 | it('should parse/serialize the CueTrack element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/CueTrackPositions.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('CueTrackPositions', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 183, 150, // EBML-id [B7], size=22 [96] 13 | 247, 129, 127, // EBML-id [F7], size=1 [81], trackUID=127 14 | 241, 131, 1, 0, 0, // EBML-id [F1], size=3 [83], position=65536 15 | 240, 130, 5, 0, // EBML-id [F0], size=2 [82], offset=1280 [05][00] 16 | 178, 132, 1, 247, 138, 64, // EBML-id [B2], size=4 [84], duration=33ms [01][F7][8A][40] 17 | 83, 120, 129, 3, // EBML-id [53][78], size=1 [83], num=3 18 | ]; 19 | 20 | it('should parse/serialize the CueTrackPositions element', () => { 21 | const element1 = 22 | 23 | 24 | 25 | 26 | 27 | ; 28 | const buffer = Kontainer.render(element1); 29 | expect(buffer).not.toBe(null); 30 | expect(buffer).toBeTheSameBuffer(value); 31 | const element2 = Kontainer.createElementFromBuffer(buffer); 32 | expect(element2).not.toBe(null); 33 | expect(element2).toHaveTheSameProps(element1); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DateUTC.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DateUTC', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 68, 97, 136, 6, 145, 97, 165, 169, 252, 96, 0, // EBML-id [44][61], size=8 [88], date=2016/01/01(JST) 13 | ]; 14 | 15 | it('should parse/serialize the DateUTC element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DefaultDuration.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DefaultDuration', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 35, 227, 131, 134, 6, 140, 97, 113, 64, 0, // EBML-id [23][E3][83], size=6 [86], duration=2 hours (in nanosec) 13 | ]; 14 | 15 | it('should parse/serialize the DefaultDuration element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DiscardPadding.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DiscardPadding', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 117, 162, 131, 255, 0, 0, // EBML-id [75][A2], size=1 [83], padding=-65536 [FF][00][00] 13 | ]; 14 | 15 | it('should parse/serialize the DiscardPadding element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DisplayHeight.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DisplayHeight', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 186, 130, 3, 192, // EBML-id [54][BA], size=2 [82], height=960 13 | ]; 14 | 15 | it('should parse/serialize the DisplayHeight element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DisplayUnit.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DisplayUnit', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 178, 129, 3, // EBML-id [54][B2], size=1 [81], kind=aspectRatio 13 | ]; 14 | 15 | it('should parse/serialize the DisplayUnit element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DisplayWidth.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DisplayWidth', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 176, 130, 6, 224, // EBML-id [54][B0], size=2 [82], width=1760 13 | ]; 14 | 15 | it('should parse/serialize the DisplayWidth element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DocType.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DocType', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 130, 132, 119, 101, 98, 109, // EBML-id [42][82], size=4 [84], doc type="webm" 13 | ]; 14 | 15 | it('should parse/serialize the DocType element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DocTypeReadVersion.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DocTypeReadVersion', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 133, 129, 1, // EBML-id [42][85], size=1 [81], version=1 13 | ]; 14 | 15 | it('should parse/serialize the DocTypeReadVersion element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/DocTypeVersion.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('DocTypeVersion', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 135, 129, 1, // EBML-id [42][87], size=1 [81], version=1 13 | ]; 14 | 15 | it('should parse/serialize the DocTypeVersion element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Duration.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Duration', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 68, 137, 136, 0, 1, 0, 0, 0, 0, 0, 0, // EBML-id [44][89], size=8 [88], duration=65536.0 [00][01][00][00][00][00][00][00] 13 | ]; 14 | 15 | it('should parse/serialize the Duration element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/EBMLMaxIDLength.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('EBMLMaxIDLength', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 242, 129, 4, // EBML-id [42][F2], size=1 [81], max id length=4 13 | ]; 14 | 15 | it('should parse/serialize the EBMLMaxIDLength element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/EBMLMaxSizeLength.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('EBMLMaxSizeLength', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 243, 129, 8, // EBML-id [42][F3], size=1 [81], max size length=8 13 | ]; 14 | 15 | it('should parse/serialize the EBMLMaxSizeLength element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/EBMLReadVersion.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('EBMLReadVersion', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 247, 129, 1, // EBML-id [42][F7], size=1 [81], version=1 13 | ]; 14 | 15 | it('should parse/serialize the EBMLReadVersion element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/EBMLVersion.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('EBMLVersion', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 66, 134, 129, 1, // EBML-id [42][86], size=1 [81], version=1 13 | ]; 14 | 15 | it('should parse/serialize the EBMLVersion element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/FlagDefault.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FlagDefault', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 136, 129, 0, // EBML-id [88], size=1 [81], isNotDefault 13 | ]; 14 | 15 | it('should parse/serialize the FlagDefault element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/FlagEnabled.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FlagEnabled', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 185, 129, 1, // EBML-id [B9], size=1 [81], enabled 13 | ]; 14 | 15 | it('should parse/serialize the FlagEnabled element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/FlagForced.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FlagForced', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 85, 170, 129, 1, // EBML-id [55][AA], size=1 [81], isForced 13 | ]; 14 | 15 | it('should parse/serialize the FlagForced element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/FlagInterlaced.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FlagInterlaced', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 154, 129, 2, // EBML-id [9A], size=1 [81], type=progressive [2] 13 | ]; 14 | 15 | it('should parse/serialize the FlagInterlaced element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/FlagLacing.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('FlagLacing', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 156, 129, 0, // EBML-id [9C], size=1 [81], notUsingLacing 13 | ]; 14 | 15 | it('should parse/serialize the FlagLacing element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Language.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Language', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 34, 181, 156, 131, 106, 112, 110, // EBML-id [22][B5][9C], size=3 [83], country="jpn" 13 | ]; 14 | 15 | it('should parse/serialize the Language element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/MuxingApp.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('MuxingApp', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 77, 128, 140, 107, 111, 110, 116, 97, 105, 110, 101, 114, 45, 106, 115, // EBML-id [4D][80], size=12 [8C], title="kontainer-js" 13 | ]; 14 | 15 | it('should parse/serialize the MuxingApp element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Name.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Name', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 110, 149, 227, 130, 143, 227, 129, 159, 227, 129, 151, 227, 129, 175, 227, 129, 139, 227, 130, 130, 227, 130, 129, // EBML-id [53][6E], size=21 [95], name=”I'm a seagull" in Japanese 13 | ]; 14 | 15 | it('should parse/serialize the Name element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/OutputSamplingFrequency.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('OutputSamplingFrequency', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 120, 181, 136, 0, 0, 125, 0, 0, 0, 0, 0, // EBML-id [78][B5], size=8 [88], samplingRate=32kHz 13 | ]; 14 | 15 | it('should parse/serialize the OutputSamplingFrequency element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelCropBottom.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelCropBottom', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 170, 129, 80, // EBML-id [54][AA], size=1 [81], bottom=80px 13 | ]; 14 | 15 | it('should parse/serialize the PixelCropBottom element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelCropLeft.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelCropLeft', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 204, 129, 60, // EBML-id [54][CC], size=1 [81], left=60px 13 | ]; 14 | 15 | it('should parse/serialize the PixelCropLeft element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelCropRight.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelCropRight', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 221, 129, 60, // EBML-id [54][DD], size=1 [81], right=60 13 | ]; 14 | 15 | it('should parse/serialize the PixelCropRight element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelCropTop.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelCropTop', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 84, 187, 129, 80, // EBML-id [54][BB], size=1 [81], top=80px 13 | ]; 14 | 15 | it('should parse/serialize the PixelCropTop element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelHeight.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelHeight', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 186, 130, 4, 56, // EBML-id [BA], size=2 [82], height=1080 13 | ]; 14 | 15 | it('should parse/serialize the PixelHeight element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PixelWidth.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PixelWidth', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 176, 130, 7, 128, // EBML-id [B0], size=2 [82], width=1920 13 | ]; 14 | 15 | it('should parse/serialize the PixelWidth element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/PrevSize.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('PrevSize', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 171, 131, 1, 0, 0, // EBML-id [ab], size=3 [83], version=65536 13 | ]; 14 | 15 | it('should parse/serialize the PrevSize element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/ReferenceBlock.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('ReferenceBlock', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 251, 129, 33, // EBML-id [FB], size=1 [81], relative timestamp=33 [21] 13 | ]; 14 | 15 | it('should parse/serialize the ReferenceBlock element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/SamplingFrequency.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('SamplingFrequency', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 181, 136, 0, 0, 172, 68, 0, 0, 0, 0, // EBML-id [B5], size=8 [88], samplingRate=44.1kHz 13 | ]; 14 | 15 | it('should parse/serialize the SamplingFrequency element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Seek.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Seek', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 77, 187, 141, // EBML-id [4D][BB], size=13 [8d], 13 | 83, 171, 132, 26, 69, 223, 163, // EBML-id [53][AB], size=4 [84], id=[1A][45][DF][A3] :EBML 14 | 83, 172, 131, 1, 0, 0 // EBML-id [53][AC], size=3 [81], position=65536 15 | ]; 16 | 17 | it('should parse/serialize the Seek element', () => { 18 | const element1 = 19 | 20 | 21 | ; 22 | const buffer = Kontainer.render(element1); 23 | expect(buffer).not.toBe(null); 24 | expect(buffer).toBeTheSameBuffer(value); 25 | const element2 = Kontainer.createElementFromBuffer(buffer); 26 | expect(element2).not.toBe(null); 27 | expect(element2).toHaveTheSameProps(element1); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/SeekID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('SeekID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 171, 132, 26, 69, 223, 163, // EBML-id [53][AB], size=4 [84], id=[1A][45][DF][A3] :EBML 13 | ]; 14 | 15 | it('should parse/serialize the SeekID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/SeekPosition.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('SeekPosition', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 172, 131, 1, 0, 0 // EBML-id [53][AC], size=3 [81], position=65536 13 | ]; 14 | 15 | it('should parse/serialize the SeekPosition element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/SeekPreRoll.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('SeekPreRoll', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 86, 187, 132, 59, 154, 202, 0, // EBML-id [56][BB], size=4 [84], time=1sec 13 | ]; 14 | 15 | it('should parse/serialize the SeekPreRoll element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/SegmentUID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('SegmentUID', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 115, 164, 144, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // EBML-id [73][A4], size=16 [90], id(128bit) 14 | ]; 15 | 16 | it('should parse/serialize the SegmentUID element', () => { 17 | const element1 = ; 18 | const buffer = Kontainer.render(element1); 19 | expect(buffer).not.toBe(null); 20 | expect(buffer).toBeTheSameBuffer(value); 21 | const element2 = Kontainer.createElementFromBuffer(buffer); 22 | expect(element2).not.toBe(null); 23 | expect(element2).toHaveTheSameProps(element1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/StereoMode.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('StereoMode', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 83, 184, 129, 13, // EBML-id [53][B8], size=1 [81], mode=both eyes laced in one Block [0D] 13 | ]; 14 | 15 | it('should parse/serialize the StereoMode element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagBinary.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('TagBinary', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 68, 133, 133, 1, 2, 3, 4, 5, // EBML-id [44][85], size=5 [85], version=1 14 | ]; 15 | 16 | it('should parse/serialize the TagBinary element', () => { 17 | const element1 = ; 18 | const buffer = Kontainer.render(element1); 19 | expect(buffer).not.toBe(null); 20 | expect(buffer).toBeTheSameBuffer(value); 21 | const element2 = Kontainer.createElementFromBuffer(buffer); 22 | expect(element2).not.toBe(null); 23 | expect(element2).toHaveTheSameProps(element1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagDefault.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TagDefault', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 68, 132, 129, 0, // EBML-id [44][84], size=1 [81], isNotDefault 13 | ]; 14 | 15 | it('should parse/serialize the TagDefault element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagLanguage.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TagLanguage', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 68, 122, 131, 106, 112, 110, // EBML-id [44][7A], size=3 [83], country="jpn" 13 | ]; 14 | 15 | it('should parse/serialize the TagLanguage element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagName.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TagName', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 69, 163, 134, 80, 114, 105, 110, 99, 101, // EBML-id [45][A3], size=6 [86], tag="Prince" 13 | ]; 14 | 15 | it('should parse/serialize the TagName element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagString.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TagString', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 68, 135, 149, 80, 114, 105, 110, 99, 101, 32, 97, 110, 100, 32, 82, 101, 118, 111, 108, 117, 116, 105, 111, 110, // EBML-id [44][87], size=21 [95], tag="Prince and Revolution" 13 | ]; 14 | 15 | it('should parse/serialize the TagString element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TagTrackUID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TagTrackUID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 99, 197, 129, 127, // EBML-id [63][C5], size=1 [81], id=127 13 | ]; 14 | 15 | it('should parse/serialize the TagTrackUID element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TargetType.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TargetType', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 99, 202, 133, 65, 76, 66, 85, 77, // EBML-id [63][CA], size=5 [85], country="ALBUM" 13 | ]; 14 | 15 | it('should parse/serialize the TargetType element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TargetTypeValue.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TargetTypeValue', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 104, 202, 129, 48, // EBML-id [68][CA], size=1 [81], value=0x30 13 | ]; 14 | 15 | it('should parse/serialize the TargetTypeValue element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Targets.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Targets', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 99, 192, 144, // EBML-id [63][C0], size=16 [90] 13 | 104, 202, 129, 48, // EBML-id [68][CA], size=1 [81], value=0x30 14 | 99, 202, 133, 65, 76, 66, 85, 77, // EBML-id [63][CA], size=5 [85], country="ALBUM" 15 | 99, 197, 129, 127, // EBML-id [63][C5], size=1 [81], id=127 16 | ]; 17 | 18 | it('should parse/serialize the Targets element', () => { 19 | const element1 = 20 | 21 | 22 | 23 | ; 24 | const buffer = Kontainer.render(element1); 25 | expect(buffer).not.toBe(null); 26 | expect(buffer).toBeTheSameBuffer(value); 27 | const element2 = Kontainer.createElementFromBuffer(buffer); 28 | expect(element2).not.toBe(null); 29 | expect(element2).toHaveTheSameProps(element1); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Timecode.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Timecode', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 231, 132, 255, 255, 255, 255, // EBML-id [E7], size=4 [84], timestamp=4294967295 13 | ]; 14 | 15 | it('should parse/serialize the Timecode element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TimecodeScale.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TimecodeScale', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 42, 215, 177, 131, 30, 132, 128, // EBML-id [2A][D7][B1], size=3 [83], timestamp scale=2000000(ns) [1E][84][80] 13 | ]; 14 | 15 | it('should parse/serialize the TimecodeScale element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Title.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('Title', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 123, 169, 137, 227, 131, 134, 227, 130, 185, 227, 131, 136, // EBML-id [7B][A9], size=9 [89], title="TEST(in Japanese)" [E3, 83, 86, E3, 82, B9, E3, 83, 88] 13 | ]; 14 | 15 | it('should parse/serialize the Title element', () => { 16 | const element1 = ; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TrackNumber.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TrackNumber', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 215, 129, 127, // EBML-id [D7], size=1 [81], track number=127 13 | ]; 14 | 15 | it('should parse/serialize the TrackNumber element', () => { 16 | const element1 = <TrackNumber value={127} />; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TrackType.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TrackType', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 131, 129, 1, // EBML-id [83], size=1 [81], type=video [1] 13 | ]; 14 | 15 | it('should parse/serialize the TrackType element', () => { 16 | const element1 = <TrackType kind="video" />; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/TrackUID.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('TrackUID', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 115, 197, 132, 255, 255, 255, 255, // EBML-id [73][C5], size=1 [84], id=[FF][FF][FF][FF] 13 | ]; 14 | 15 | it('should parse/serialize the TrackUID element', () => { 16 | const element1 = <TrackUID value={0xffffffff} />; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Unknown.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('Unknown', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const UNKNOWN_ELEMENT_ID = [0x1B, 0x53, 0x86, 0x67]; 13 | const unknownValue = [ 14 | 27, 83, 134, 103, 129, 1, // EBML-id [1B][53][86][67], size=1 [81], value=1 15 | ]; 16 | 17 | it('can keep unknown element untouched', () => { 18 | 19 | const element = Kontainer.createElementFromBuffer((new Buffer(unknownValue)).getData()); 20 | expect(element).not.toBe(null); 21 | expect(element.type.ELEMENT_ID).toBeTheSameBuffer(UNKNOWN_ELEMENT_ID); 22 | const buffer = Kontainer.render(element); 23 | expect(buffer).not.toBe(null); 24 | expect(buffer).toBeTheSameBuffer(unknownValue); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/Void.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | import Buffer from '../../../../src/core/Buffer'; 4 | 5 | describe('Void', () => { 6 | 7 | beforeEach(() => { 8 | jasmine.addMatchers(customMatchers); 9 | Kontainer.use('webm'); 10 | }); 11 | 12 | const value = [ 13 | 236, 133, 1, 2, 3, 4, 5, // EBML-id [EC], size=5 [85], version=1 14 | ]; 15 | 16 | it('should parse/serialize the Void element', () => { 17 | const element1 = <Void value={new Buffer([1, 2, 3, 4, 5]).getView()} />; 18 | const buffer = Kontainer.render(element1); 19 | expect(buffer).not.toBe(null); 20 | expect(buffer).toBeTheSameBuffer(value); 21 | const element2 = Kontainer.createElementFromBuffer(buffer); 22 | expect(element2).not.toBe(null); 23 | expect(element2).toHaveTheSameProps(element1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /test/spec/Matroska/Element/WritingApp.spec.js: -------------------------------------------------------------------------------- 1 | import Kontainer from 'kontainer-js'; 2 | import customMatchers from '../../../helper/matcher'; 3 | 4 | describe('WritingApp', () => { 5 | 6 | beforeEach(() => { 7 | jasmine.addMatchers(customMatchers); 8 | Kontainer.use('webm'); 9 | }); 10 | 11 | const value = [ 12 | 87, 65, 140, 107, 111, 110, 116, 97, 105, 110, 101, 114, 45, 106, 115, // EBML-id [57][41], size=12 [8C], title="kontainer-js" 13 | ]; 14 | 15 | it('should parse/serialize the WritingApp element', () => { 16 | const element1 = <WritingApp value="kontainer-js" />; 17 | const buffer = Kontainer.render(element1); 18 | expect(buffer).not.toBe(null); 19 | expect(buffer).toBeTheSameBuffer(value); 20 | const element2 = Kontainer.createElementFromBuffer(buffer); 21 | expect(element2).not.toBe(null); 22 | expect(element2).toHaveTheSameProps(element1); 23 | }); 24 | }); 25 | --------------------------------------------------------------------------------