From 11210b400a8bc6e5e38db322e17f53f8071733c0 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Thu, 6 Jul 2017 11:53:44 -0700 Subject: [PATCH] Workaround Edge problem with non-zero clear lead Somehow Edge requires sinf box to be put after avcC box: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12658991/ b/37913785 Change-Id: I201c96768328b3910001dba49a9ddda7f06f3c20 --- .../bear-320x240-opus-cenc-golden.mp4 | Bin 28355 -> 28355 bytes .../testdata/bear-320x240-vp9-cenc-golden.mp4 | Bin 71890 -> 71890 bytes .../testdata/bear-640x360-a-cbc1-golden.mp4 | Bin 44612 -> 44612 bytes .../testdata/bear-640x360-a-cbcs-golden.mp4 | Bin 43947 -> 43947 bytes .../testdata/bear-640x360-a-cenc-golden.mp4 | Bin 44612 -> 44612 bytes ...ar-640x360-a-cenc-no-clear-lead-golden.mp4 | Bin 44939 -> 44939 bytes .../bear-640x360-a-cenc-no-pssh-golden.mp4 | Bin 44560 -> 44560 bytes .../testdata/bear-640x360-a-cens-golden.mp4 | Bin 44612 -> 44612 bytes .../bear-640x360-a-live-cenc-golden-init.mp4 | Bin 951 -> 951 bytes ...0x360-a-live-cenc-rotation-golden-init.mp4 | Bin 899 -> 899 bytes ...live-cenc-rotation-no-pssh-golden-init.mp4 | Bin 899 -> 899 bytes .../bear-640x360-hevc-cenc-golden.mp4 | Bin 92801 -> 92801 bytes .../testdata/bear-640x360-v-cbc1-golden.mp4 | Bin 302879 -> 302879 bytes .../testdata/bear-640x360-v-cbcs-golden.mp4 | Bin 302472 -> 302472 bytes .../testdata/bear-640x360-v-cenc-golden.mp4 | Bin 302879 -> 302879 bytes ...ar-640x360-v-cenc-no-clear-lead-golden.mp4 | Bin 303276 -> 303276 bytes .../bear-640x360-v-cenc-no-pssh-golden.mp4 | Bin 302827 -> 302827 bytes .../testdata/bear-640x360-v-cens-golden.mp4 | Bin 302879 -> 302879 bytes .../bear-640x360-v-live-cenc-golden-init.mp4 | Bin 1075 -> 1075 bytes ...0x360-v-live-cenc-rotation-golden-init.mp4 | Bin 1023 -> 1023 bytes ...live-cenc-rotation-no-pssh-golden-init.mp4 | Bin 1023 -> 1023 bytes .../bear-640x360-v-trick-1-cenc-golden.mp4 | Bin 53814 -> 53814 bytes .../bear-640x360-v-trick-2-cenc-golden.mp4 | Bin 35860 -> 35860 bytes .../testdata/bear-640x360-vp8-cenc-golden.mp4 | Bin 116628 -> 116628 bytes packager/media/formats/mp4/box_definitions.cc | 43 +++++++++++------- 25 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packager/app/test/testdata/bear-320x240-opus-cenc-golden.mp4 b/packager/app/test/testdata/bear-320x240-opus-cenc-golden.mp4 index 3522370065edd8641d33481caec4dcedd8ace247..646ae1c3299b2ab0c1a87df514c1d10a33c78587 100644 GIT binary patch delta 22 ecmX?nm+|mj#tlwPlTR`UPj+Go*u0cUE(ZW{ya=-Z delta 22 ecmX?nm+|mj#tlwPlS7#TCOa_+Z(hnImjeK8KnOno diff --git a/packager/app/test/testdata/bear-320x240-vp9-cenc-golden.mp4 b/packager/app/test/testdata/bear-320x240-vp9-cenc-golden.mp4 index 3b3ccc2494418bb5b33ffc4714568ccbfddd54b7..1e611f0a642cc6c124d2aaec090716c365952aea 100644 GIT binary patch delta 26 icmcb#k>%1xmJJn5lbx7VCRZ>8G{0fm{)UP1nJ564dkUlg delta 26 icmcb#k>%1xmJJn5ljkr6Om<>cX@0}B{S6c2Gf@DWKMKeI diff --git a/packager/app/test/testdata/bear-640x360-a-cbc1-golden.mp4 b/packager/app/test/testdata/bear-640x360-a-cbc1-golden.mp4 index 44254002317b287556bd1d2e6f8b9c5e7beed906..afd156b3f325b2b45a52bf297fa2c4f6d01198e7 100644 GIT binary patch delta 22 ecmX?dhv~>2rVUO^lOHf?O?F}m*u00SV>JMEObMd^ delta 22 ecmX?dhv~>2rVUO^lXI8?COa`{ZQjGwu^IqybO|p2 diff --git a/packager/app/test/testdata/bear-640x360-a-cbcs-golden.mp4 b/packager/app/test/testdata/bear-640x360-a-cbcs-golden.mp4 index 54071c85a3f5db06b762041f7940759bd70f54f8..e185a9f9f865187924cb0f9207313a41e1bcc436 100644 GIT binary patch delta 22 ecmZ2|ooV%TrVUO^lV37vO?G06+2rVUO^lOHf?O?F}m*u00SV>JMEObMd^ delta 22 ecmX?dhv~>2rVUO^lXI8?COa`{ZQjGwu^IqybO|p2 diff --git a/packager/app/test/testdata/bear-640x360-a-cenc-no-clear-lead-golden.mp4 b/packager/app/test/testdata/bear-640x360-a-cenc-no-clear-lead-golden.mp4 index 870e1cb3b3df07e48f2756d7bdacf9608567c766..fd6baf5aa9d459a8ceb994e651c4807745467018 100644 GIT binary patch delta 22 ecmeCa&(wXNX@e8fC> delta 22 ecmbPmhiSqcrVUO^lXI8?COa`{ZQjEavKjzqxCoN~ diff --git a/packager/app/test/testdata/bear-640x360-a-cens-golden.mp4 b/packager/app/test/testdata/bear-640x360-a-cens-golden.mp4 index b51c81193c36eed86a4a8ea3f97e29ece81cd1b2..87236142e2fa1e7c5f5b407851f9b886da1bda47 100644 GIT binary patch delta 22 ecmX?dhv~>2rVUO^lOHf?O?F}m*u00SV>JMEObMd^ delta 22 ecmX?dhv~>2rVUO^lXI8?COa`{ZQjGwu^IqybO|p2 diff --git a/packager/app/test/testdata/bear-640x360-a-live-cenc-golden-init.mp4 b/packager/app/test/testdata/bear-640x360-a-live-cenc-golden-init.mp4 index 5b8b64992eba270408c677e3ac3f1234549ec4f9..8baf873921a6c10688b92cffc7912d25751f94a1 100644 GIT binary patch delta 19 bcmdnazMXx86Vv1eOj?tjm;xs6VfqaKNLB}f delta 19 bcmdnazMXx86Vv1zrhv&#Oj?uoF#QGqL-Gd? diff --git a/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-golden-init.mp4 b/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-golden-init.mp4 index 1b003c389d26b32c4185ab9f1e7b3f011c0e6472..e0d23b00aea91625b31503fd5c0f7125d5beb63e 100644 GIT binary patch delta 19 bcmZo>Z)V@%#5DNrhv(Nn2rMgK+*>1 delta 19 acmZo>Z)V@%#56gFDPXb_lh))tOveE{ZU%Dz diff --git a/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-no-pssh-golden-init.mp4 b/packager/app/test/testdata/bear-640x360-a-live-cenc-rotation-no-pssh-golden-init.mp4 index 1b003c389d26b32c4185ab9f1e7b3f011c0e6472..e0d23b00aea91625b31503fd5c0f7125d5beb63e 100644 GIT binary patch delta 19 bcmZo>Z)V@%#5DNrhv(Nn2rMgK+*>1 delta 19 acmZo>Z)V@%#56gFDPXb_lh))tOveE{ZU%Dz diff --git a/packager/app/test/testdata/bear-640x360-hevc-cenc-golden.mp4 b/packager/app/test/testdata/bear-640x360-hevc-cenc-golden.mp4 index ca1335d15eb60468f4ee8d448a31d7f60203b1a6..ba921f62147bcdc06b45a7961f35263cac6b103a 100644 GIT binary patch delta 41 xcmZp?%G!99bwe@J=6H5@mdPbd0jzT}Qp*e{2QZ3Hwqmkuj%VK<&(5fn3;;C^4Ltw= delta 43 zcmZp?%G!99bwe@Jod;2nO#@lfKT}}^A diff --git a/packager/app/test/testdata/bear-640x360-v-cbc1-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-cbc1-golden.mp4 index 52993506afede6864eeeeebe936c160fbe3cb1aa..1edc8ecddc6472cfd7b70b14c7df6dabb2f48d80 100644 GIT binary patch delta 38 qcmbQgPiX!=p$!#GlLMHICRZ>8H2-31|HZ@z#2}h^`!6OI)j0q#q7MWB delta 38 qcmbQgPiX!=p$!#GlUFeXOb%c+YW~I4{)>qbh(R>-_Fqgas&fE0E)O;U diff --git a/packager/app/test/testdata/bear-640x360-v-cbcs-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-cbcs-golden.mp4 index 8bc2ea5aecdccad326fa9f03f36ff39cc06abe1b..246a814ab05da035adeba2c36287863ac471df15 100644 GIT binary patch delta 38 rcmeC!E!44FXhQ|l2H%ml>D+nJeJT4w8H2-31|HZ@z#2}h^`!6OI)j0q#q7MWB delta 38 qcmbQgPiX!=p$!#GlUFeXOb%c+YW~I4{)>qbh(R>-_Fqgas&fE0E)O;U diff --git a/packager/app/test/testdata/bear-640x360-v-cenc-no-clear-lead-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-cenc-no-clear-lead-golden.mp4 index 01bcc6be516c9aae3566fcb25209cdcda8d26469..95418131de4ed41b4dda68f08f3a006c2f2a3237 100644 GIT binary patch delta 38 rcmZ2;P-x9Tp$!#GlTR=iO|D=HX#U02{)>qbh(R>-_Fqgao8|%lLrf4U delta 38 rcmZ2;P-x9Tp$!#GlUFeXOs-%uYW~I4{)>qbh(R>-_Fqgao8|%lKztAj diff --git a/packager/app/test/testdata/bear-640x360-v-cenc-no-pssh-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-cenc-no-pssh-golden.mp4 index 69b13ea7c56aa5fa38978100ba92bfcd54867f9b..17b831df782bc7387169cbf430384f1a870ae3d1 100644 GIT binary patch delta 38 qcmaF8SLpR#p$!#GlLMHICRZ>8H2-31|HZ@z#2}h^`!6PzkFxqbh(R>-_FqgaA7=vqPAU+W diff --git a/packager/app/test/testdata/bear-640x360-v-cens-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-cens-golden.mp4 index 2f4f828aa02e0c874c83cdf58f7180ae19c90521..adee9cfc8ca6ef0aab84c068066878c3001e32c5 100644 GIT binary patch delta 38 qcmbQgPiX!=p$!#GlLMHICRZ>8H2-31|HZ@z#2}h^`!6OI)j0q#q7MWB delta 38 qcmbQgPiX!=p$!#GlUFeXOb%c+YW~I4{)>qbh(R>-_Fqgas&fE0E)O;U diff --git a/packager/app/test/testdata/bear-640x360-v-live-cenc-golden-init.mp4 b/packager/app/test/testdata/bear-640x360-v-live-cenc-golden-init.mp4 index 08e6c418add9f2263ee4caaa8927202795713153..69d5615bdb50257047c3d8489cfcb60b36531da7 100644 GIT binary patch delta 20 ccmdnYv6*8-1=HjJW~0d!OaYsJF8Z2rY$a~=R`qzM!N delta 22 ecmdnCgn8Q%<_#50lUFeXOb%c++Wd>j<~#sx5D7*A diff --git a/packager/app/test/testdata/bear-640x360-v-trick-2-cenc-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-trick-2-cenc-golden.mp4 index e8daf0b08e9fa158fc003a25bd712a8bc2f00ea6..e4d1f9556e9e6390d73c33c42e4ae8de02e2f129 100644 GIT binary patch delta 22 ecmbO-gK5ePrVSNLlLMHICRZ>8Z2rY0)d>J$uLw>6 delta 22 ecmbO-gK5ePrVSNLlUFeXOb%c++Wd=2suKWZ8wh{^ diff --git a/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.mp4 b/packager/app/test/testdata/bear-640x360-vp8-cenc-golden.mp4 index 6608e03f6472596f864eeb5830ee84476dccb2ca..8c3c919a137edfff5c011c0fd2bede00b4741cf5 100644 GIT binary patch delta 26 icmbQz&pxG}eM1G)WFuyg$rVfi&3Bl#-(h0haRdN^i3%$K delta 26 icmbQz&pxG}eM1G)PrepareChildren()); - if (format == FOURCC_encv) { - if (buffer->Reading()) { - // Continue scanning until a supported protection scheme is found, or - // until we run out of protection schemes. - while (!IsProtectionSchemeSupported(sinf.type.type)) - RCHECK(buffer->ReadWriteChild(&sinf)); - } else { - DCHECK(IsProtectionSchemeSupported(sinf.type.type)); + // This has to happen before reading codec configuration box as the actual + // format is read from sinf.format.format, which is needed to parse the codec + // configuration box. + if (format == FOURCC_encv && buffer->Reading()) { + // Continue scanning until a supported protection scheme is found, or + // until we run out of protection schemes. + while (!IsProtectionSchemeSupported(sinf.type.type)) RCHECK(buffer->ReadWriteChild(&sinf)); - } } const FourCC actual_format = GetActualFormat(); @@ -1575,10 +1573,19 @@ bool VideoSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { DCHECK_EQ(codec_configuration.box_type, GetCodecConfigurationBoxType(actual_format)); } - DCHECK_NE(codec_configuration.box_type, FOURCC_NULL); + if (codec_configuration.box_type == FOURCC_NULL) + return false; RCHECK(buffer->ReadWriteChild(&codec_configuration)); RCHECK(buffer->TryReadWriteChild(&pixel_aspect)); + + // Somehow Edge does not support having sinf box before codec_configuration, + // box, so just do it in the end of VideoSampleEntry. See + // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12658991/ + if (format == FOURCC_encv && !buffer->Reading()) { + DCHECK(IsProtectionSchemeSupported(sinf.type.type)); + RCHECK(buffer->ReadWriteChild(&sinf)); + } return true; } @@ -1805,6 +1812,16 @@ bool AudioSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { samplerate >>= 16; RCHECK(buffer->PrepareChildren()); + + RCHECK(buffer->TryReadWriteChild(&esds)); + RCHECK(buffer->TryReadWriteChild(&ddts)); + RCHECK(buffer->TryReadWriteChild(&dac3)); + RCHECK(buffer->TryReadWriteChild(&dec3)); + RCHECK(buffer->TryReadWriteChild(&dops)); + + // Somehow Edge does not support having sinf box before codec_configuration, + // box, so just do it in the end of AudioSampleEntry. See + // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12658991/ if (format == FOURCC_enca) { if (buffer->Reading()) { // Continue scanning until a supported protection scheme is found, or @@ -1816,12 +1833,6 @@ bool AudioSampleEntry::ReadWriteInternal(BoxBuffer* buffer) { RCHECK(buffer->ReadWriteChild(&sinf)); } } - - RCHECK(buffer->TryReadWriteChild(&esds)); - RCHECK(buffer->TryReadWriteChild(&ddts)); - RCHECK(buffer->TryReadWriteChild(&dac3)); - RCHECK(buffer->TryReadWriteChild(&dec3)); - RCHECK(buffer->TryReadWriteChild(&dops)); return true; }