From f17b97250ed6af8ee5bc573f4b164c9cbe7a9034 Mon Sep 17 00:00:00 2001 From: cconcolato Date: Mon, 4 Mar 2019 14:58:01 -0800 Subject: [PATCH 1/2] add 'codecs' generation for encrypted files --- src/box-codecs.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/box-codecs.js b/src/box-codecs.js index b9a19aed..9bb06e38 100644 --- a/src/box-codecs.js +++ b/src/box-codecs.js @@ -165,7 +165,7 @@ BoxParser.stxtSampleEntry.prototype.getCodec = function() { if(this.mime_format) { return baseCodec + "." + this.mime_format; } else { - return baseCodec + return baseCodec; } } @@ -181,4 +181,25 @@ BoxParser.av01SampleEntry.prototype.getCodec = function() { return baseCodec+"."+this.av1C.seq_profile+"."+this.av1C.seq_level_idx_0+(this.av1C.seq_tier_0?"H":"M")+"."+bitdepth+"."+this.av1C.monochrome+"."+this.av1C.chroma_subsampling_x+""+this.av1C.chroma_subsampling_y+""+this.av1C.chroma_sample_position; } +BoxParser.encvSampleEntry.prototype.getCodec = function() { + var baseCodec = BoxParser.SampleEntry.prototype.getCodec.call(this); + if (this.sinfs[0] && + this.sinfs[0].frma && this.sinfs[0].frma.data_format && + this.sinfs[0].schm && this.sinfs[0].schm.scheme_type && + BoxParser[this.sinfs[0].frma.data_format + "SampleEntry"]) { + var backupType = this.type; + this.type = this.sinfs[0].frma.data_format; + var scheme = this.sinfs[0].schm.scheme_type; + var fullCodec = baseCodec+"."+scheme+"."+BoxParser[this.type + "SampleEntry"].prototype.getCodec.call(this); + this.type = backupType; + return fullCodec; + } else { + return baseCodec; + } +} +BoxParser.encaSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; +BoxParser.encuSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; +BoxParser.encsSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; +BoxParser.enctSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; +BoxParser.encmSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; From f0e6256cd23f79dc64da58865c098b5829f2df19 Mon Sep 17 00:00:00 2001 From: cconcolato Date: Mon, 4 Mar 2019 17:20:08 -0800 Subject: [PATCH 2/2] adding resv support --- src/box-codecs.js | 15 +++++++++------ src/box.js | 3 +++ src/parsing/sampleentries/sampleentry.js | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/box-codecs.js b/src/box-codecs.js index 9bb06e38..057b978b 100644 --- a/src/box-codecs.js +++ b/src/box-codecs.js @@ -183,13 +183,14 @@ BoxParser.av01SampleEntry.prototype.getCodec = function() { BoxParser.encvSampleEntry.prototype.getCodec = function() { var baseCodec = BoxParser.SampleEntry.prototype.getCodec.call(this); - if (this.sinfs[0] && - this.sinfs[0].frma && this.sinfs[0].frma.data_format && - this.sinfs[0].schm && this.sinfs[0].schm.scheme_type && - BoxParser[this.sinfs[0].frma.data_format + "SampleEntry"]) { + var transBox = (this.sinfs || this.rinfs)[0]; + if (transBox && + transBox.frma && transBox.frma.data_format && + transBox.schm && transBox.schm.scheme_type && + BoxParser[transBox.frma.data_format + "SampleEntry"]) { var backupType = this.type; - this.type = this.sinfs[0].frma.data_format; - var scheme = this.sinfs[0].schm.scheme_type; + this.type = transBox.frma.data_format; + var scheme = transBox.schm.scheme_type; var fullCodec = baseCodec+"."+scheme+"."+BoxParser[this.type + "SampleEntry"].prototype.getCodec.call(this); this.type = backupType; return fullCodec; @@ -203,3 +204,5 @@ BoxParser.encuSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototy BoxParser.encsSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; BoxParser.enctSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; BoxParser.encmSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; + +BoxParser.resvSampleEntry.prototype.getCodec = BoxParser.encvSampleEntry.prototype.getCodec; diff --git a/src/box.js b/src/box.js index e64fef44..9e3c343a 100644 --- a/src/box.js +++ b/src/box.js @@ -149,6 +149,9 @@ var BoxParser = { createEncryptedSampleEntryCtor: function(mediaType, type, parseMethod) { BoxParser.createSampleEntryCtor.call(this, mediaType, type, parseMethod, ["sinf"]); }, + createRestrictedSampleEntryCtor: function(mediaType, type, parseMethod) { + BoxParser.createSampleEntryCtor.call(this, mediaType, type, parseMethod, ["rinf"]); + }, createSampleGroupCtor: function(type, parseMethod) { //BoxParser.sampleGroupEntryCodes.push(type); BoxParser[type+"SampleGroupEntry"] = function(size) { diff --git a/src/parsing/sampleentries/sampleentry.js b/src/parsing/sampleentries/sampleentry.js index 2671c746..bf674342 100644 --- a/src/parsing/sampleentries/sampleentry.js +++ b/src/parsing/sampleentries/sampleentry.js @@ -85,4 +85,6 @@ BoxParser.createEncryptedSampleEntryCtor(BoxParser.SAMPLE_ENTRY_TYPE_SYSTEM, "e BoxParser.createEncryptedSampleEntryCtor(BoxParser.SAMPLE_ENTRY_TYPE_TEXT, "enct"); BoxParser.createEncryptedSampleEntryCtor(BoxParser.SAMPLE_ENTRY_TYPE_METADATA, "encm"); +// Restricted sample entries +BoxParser.createRestrictedSampleEntryCtor(BoxParser.SAMPLE_ENTRY_TYPE_VISUAL, "resv");