From 122369424921a966bbcc170ca3c52d7e52149b00 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Tue, 27 Mar 2018 09:27:17 -0700 Subject: [PATCH] Do not force earliest_presentation_time to 0 for VOD Instead, the actual earliest presentation time is used except for the first segment if there is an offset between presentation time (pts) and decoding time (dts). Chrome (as of v66) reports dts instead of pts in buffered ranges in MSE API. To avoid breaking Chrome, the earliest_presentation_time of the first segment is set to its dts as Chrome does not like negative values for adjusted dts = dts + Period@start (0 for the first period) - presentationTimeOffset (earliest_presentation_time). Fixes #303. Change-Id: I5ca80e05d5570961400499436f2bcc01f06e69e0 --- .../testdata/bear-320x180-a-wvm-golden.mp4 | Bin 44949 -> 44949 bytes .../testdata/bear-320x180-avc3-wvm-golden.mp4 | Bin 121153 -> 121153 bytes .../testdata/bear-320x180-v-wvm-golden.mp4 | Bin 121043 -> 121043 bytes .../bear-320x240-opus-vp9-cenc-golden.mpd | 4 +- .../testdata/bear-320x240-vp9-cenc-golden.mp4 | Bin 71890 -> 71890 bytes .../test/testdata/bear-320x240-vp9-golden.mp4 | Bin 70698 -> 70698 bytes .../bear-320x240-vp9-opus-webm-golden.mpd | 4 +- .../bear-640x360-a-clear-v-cenc-golden.mpd | 2 +- .../testdata/bear-640x360-a-wvm-golden.mp4 | Bin 46061 -> 46061 bytes .../bear-640x360-ac3-from-ts-golden.mp4 | Bin 68606 -> 68606 bytes .../testdata/bear-640x360-av-cbc1-golden.mpd | 2 +- .../testdata/bear-640x360-av-cbcs-golden.mpd | 2 +- .../bear-640x360-av-cenc-ad_cues-golden.mpd | 4 +- .../testdata/bear-640x360-av-cenc-golden.mpd | 2 +- ...r-640x360-av-cenc-no-clear-lead-golden.mpd | 2 +- .../bear-640x360-av-cenc-no-pssh-golden.mpd | 2 +- .../bear-640x360-av-cenc-non-iop-golden.mpd | 2 +- .../testdata/bear-640x360-av-cens-golden.mpd | 2 +- .../test/testdata/bear-640x360-av-golden.mpd | 2 +- .../bear-640x360-av-live-cenc-golden.mpd | 5 ++- ...ar-640x360-av-live-cenc-non-iop-golden.mpd | 5 ++- ...r-640x360-av-live-cenc-rotation-golden.mpd | 5 ++- ...0-av-live-cenc-rotation-no-pssh-golden.mpd | 5 ++- ...0-av-live-cenc-rotation-non-iop-golden.mpd | 5 ++- .../testdata/bear-640x360-av-live-golden.mpd | 5 ++- ...-640x360-av-live-static-ad_cues-golden.mpd | 9 ++-- .../bear-640x360-av-live-static-golden.mpd | 7 +-- .../bear-640x360-av-por-BR-golden.mpd | 2 +- .../testdata/bear-640x360-av-por-golden.mpd | 2 +- .../bear-640x360-av-trick-1-cenc-golden.mpd | 2 +- .../bear-640x360-av-trick-1-golden.mpd | 2 +- ...640x360-av-trick-1-trick-2-cenc-golden.mpd | 2 +- ...bear-640x360-av-trick-1-trick-2-golden.mpd | 2 +- .../testdata/bear-640x360-avc3-wvm-golden.mp4 | Bin 300149 -> 300149 bytes .../test/testdata/bear-640x360-avt-golden.mpd | 2 +- .../bear-640x360-ec3-v-cenc-golden.mp4 | Bin 297371 -> 297371 bytes .../bear-640x360-ec3-v-mp4-cenc-golden.m3u8 | 2 +- .../bear-640x360-hevc-cenc-golden.mp4 | Bin 92801 -> 92801 bytes .../bear-640x360-hevc-cenc-golden.mpd | 2 +- .../testdata/bear-640x360-hevc-golden.mp4 | Bin 90519 -> 90519 bytes .../testdata/bear-640x360-v-cbc1-golden.mp4 | Bin 302879 -> 302879 bytes .../testdata/bear-640x360-v-cbcs-golden.mp4 | Bin 302472 -> 302472 bytes .../bear-640x360-v-cenc-ad_cues-golden.mp4 | Bin 302879 -> 302879 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-from-ts-golden.mp4 | Bin 301673 -> 301673 bytes .../test/testdata/bear-640x360-v-golden.mp4 | Bin 301673 -> 301673 bytes .../test/testdata/bear-640x360-v-golden.mpd | 2 +- .../bear-640x360-v-live-ad_cues-golden-1.m4s | Bin 99393 -> 99393 bytes .../bear-640x360-v-live-cenc-golden-1.m4s | Bin 99393 -> 99393 bytes ...-640x360-v-live-cenc-rotation-golden-1.m4s | Bin 99445 -> 99445 bytes ...-v-live-cenc-rotation-no-pssh-golden-1.m4s | Bin 99393 -> 99393 bytes .../testdata/bear-640x360-v-live-golden-1.m4s | Bin 99393 -> 99393 bytes ...ear-640x360-v-mp4-cenc-ad_cues-golden.m3u8 | 2 +- .../bear-640x360-v-mp4-cenc-golden.m3u8 | 2 +- .../testdata/bear-640x360-v-mp4-golden.m3u8 | 2 +- .../bear-640x360-v-trick-1-cenc-golden.mp4 | Bin 53814 -> 53814 bytes .../bear-640x360-v-trick-1-golden.mp4 | Bin 53408 -> 53408 bytes .../bear-640x360-v-trick-2-cenc-golden.mp4 | Bin 35860 -> 35860 bytes .../bear-640x360-v-trick-2-golden.mp4 | Bin 35523 -> 35523 bytes .../bear-640x360-v-ts-to-mp4-golden.m3u8 | 2 +- .../testdata/bear-640x360-v-wvm-golden.mp4 | Bin 300036 -> 300036 bytes .../testdata/bear-640x360-vp8-cenc-golden.mp4 | Bin 116628 -> 116628 bytes .../testdata/bear-640x360-vp8-cenc-golden.mpd | 2 +- .../bear-640x360-vp8-cenc-webm-golden.mpd | 2 +- .../test/testdata/bear-640x360-vp8-golden.mp4 | Bin 115868 -> 115868 bytes .../testdata/bear-640x360-vp8-webm-golden.mpd | 2 +- .../test/testdata/bear-avc3-wvm-golden.mpd | 10 ++--- .../app/test/testdata/bear-wvm-golden.mpd | 10 ++--- packager/media/formats/mp4/fragmenter.cc | 23 +++++++++- packager/media/formats/mp4/fragmenter.h | 5 ++- .../formats/mp4/single_segment_segmenter.cc | 20 +-------- packager/mpd/base/mpd_builder.cc | 16 ------- packager/mpd/base/mpd_builder_unittest.cc | 41 ++++++++++++++---- 76 files changed, 127 insertions(+), 108 deletions(-) diff --git a/packager/app/test/testdata/bear-320x180-a-wvm-golden.mp4 b/packager/app/test/testdata/bear-320x180-a-wvm-golden.mp4 index 1de4b6a9e864db08470944811bf4df0276fb7b90..372bb7827ee9b069f7324140b7494608069d2b0e 100644 GIT binary patch delta 17 ZcmbPwpK0oSrVZT8OtHr{^D=j=0RTW{2FCyZ delta 17 ZcmbPwpK0oSrVZT8ObiU0d6_%b0022Q1*8A~ diff --git a/packager/app/test/testdata/bear-320x180-avc3-wvm-golden.mp4 b/packager/app/test/testdata/bear-320x180-avc3-wvm-golden.mp4 index 5dfff29f96300bfc0fea0f93ce0ff2db3420054b..7c24e9e5091db7e643224262835ce91c895d64dc 100644 GIT binary patch delta 41 tcmX@OiT&Uv_6;7)Vr~Hp5Wvj9FncotV|l^^2Jy1yIOgqf%#4q(0s!mb3zq-@ delta 41 qcmX@OiT&Uv_6;7)Vhk|A%)l^vGXrD%s|i4n<~Zib{gLqkU67%*XX2!y+0Pao;EdT%j delta 41 pcmcb-k^S;U_6 output_audio.mp4 - + @@ -22,7 +22,7 @@ output_video.mp4 - + 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 1e611f0a642cc6c124d2aaec090716c365952aea..199276410d5c369c63bf974f4c2c33b5a88c9ed2 100644 GIT binary patch delta 21 dcmcb#k>%1xmJPNnOcOeq?OC?lvoKB;0RUkq2Z8_q delta 21 dcmcb#k>%1xmJPNnObiUo_AJ}&Sr{ja0032|25JBR diff --git a/packager/app/test/testdata/bear-320x240-vp9-golden.mp4 b/packager/app/test/testdata/bear-320x240-vp9-golden.mp4 index eb37055756482856be84d925082b703ca5f21e29..a7190fb2018ad2bb77d447705da91b49af3a16d0 100644 GIT binary patch delta 21 dcmZ3rf@ReTmJRmIOcOeq9htW~GBdsu003Hu2Xz1d delta 21 dcmZ3rf@ReTmJRmIObiUoj?CK~nHgUS002)223-IE diff --git a/packager/app/test/testdata/bear-320x240-vp9-opus-webm-golden.mpd b/packager/app/test/testdata/bear-320x240-vp9-opus-webm-golden.mpd index e076235af7..6dc1619cad 100644 --- a/packager/app/test/testdata/bear-320x240-vp9-opus-webm-golden.mpd +++ b/packager/app/test/testdata/bear-320x240-vp9-opus-webm-golden.mpd @@ -6,7 +6,7 @@ output_audio.webm - + @@ -14,7 +14,7 @@ output_video.webm - + diff --git a/packager/app/test/testdata/bear-640x360-a-clear-v-cenc-golden.mpd b/packager/app/test/testdata/bear-640x360-a-clear-v-cenc-golden.mpd index 343e19815b..f68d3d8392 100644 --- a/packager/app/test/testdata/bear-640x360-a-clear-v-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-a-clear-v-cenc-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-a-wvm-golden.mp4 b/packager/app/test/testdata/bear-640x360-a-wvm-golden.mp4 index d7a846f1b8bc276968105b4c81a81e0c7ee0ba99..c5ec848107f61607830cc2bf43d89555f7e48288 100644 GIT binary patch delta 17 ZcmaF+oayazrVZT8OtHr{^D;l!002y>2jc($ delta 17 ZcmaF+oayazrVZT8ObiU0d6^$<002dL2EYIS diff --git a/packager/app/test/testdata/bear-640x360-ac3-from-ts-golden.mp4 b/packager/app/test/testdata/bear-640x360-ac3-from-ts-golden.mp4 index 3c4ec7a4b0c58d1a39578fff553bcffcbe168081..84a7c72c985f3042fdbdaff0af11f78176ad3e9b 100644 GIT binary patch delta 21 dcmex2o#o$jmJM&1n0TF<-!W}}$HXYW2>@*H2vz_9 delta 21 dcmex2o#o$jmJM&1m>3wE-!W}}$HXYW2>@x$2nPTF diff --git a/packager/app/test/testdata/bear-640x360-av-cbc1-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cbc1-golden.mpd index 95f82e1034..42d7148ecd 100644 --- a/packager/app/test/testdata/bear-640x360-av-cbc1-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cbc1-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd index be8c59ecc9..4de893cb06 100644 --- a/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cenc-ad_cues-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cenc-ad_cues-golden.mpd index 4a943da447..088ce48969 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-ad_cues-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-ad_cues-golden.mpd @@ -1,7 +1,7 @@ - - + + diff --git a/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd index d53ce856cc..9b31d76eed 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cenc-no-clear-lead-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cenc-no-clear-lead-golden.mpd index 3fc1016025..1532a60109 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-no-clear-lead-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-no-clear-lead-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cenc-no-pssh-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cenc-no-pssh-golden.mpd index 3fd3a0c4a8..c5f0dae86d 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-no-pssh-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-no-pssh-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cenc-non-iop-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cenc-non-iop-golden.mpd index 5a14de9678..c374be4333 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-non-iop-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-non-iop-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-cens-golden.mpd b/packager/app/test/testdata/bear-640x360-av-cens-golden.mpd index 8280a41d19..868c42aada 100644 --- a/packager/app/test/testdata/bear-640x360-av-cens-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cens-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-golden.mpd b/packager/app/test/testdata/bear-640x360-av-golden.mpd index 7ca5c607af..6e8cd992f3 100644 --- a/packager/app/test/testdata/bear-640x360-av-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-golden.mpd index b904b4dde3..9849d82ef7 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-golden.mpd @@ -7,10 +7,11 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-non-iop-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-non-iop-golden.mpd index 7358bb9452..41e66c930f 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-non-iop-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-non-iop-golden.mpd @@ -3,14 +3,15 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd index e9c4348da4..e9af6691d3 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-golden.mpd @@ -5,10 +5,11 @@ - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd index 9265f2e191..59ef0f3a3d 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd @@ -5,10 +5,11 @@ - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd index 81eb4d90d5..1244a592b8 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd @@ -3,12 +3,13 @@ - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-golden.mpd index 4faf8e66e8..5a0e4cdfca 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-golden.mpd @@ -3,10 +3,11 @@ - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-static-ad_cues-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-static-ad_cues-golden.mpd index 4cd8f2669c..55f6ce4224 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-static-ad_cues-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-static-ad_cues-golden.mpd @@ -1,12 +1,13 @@ - - + + - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-live-static-golden.mpd b/packager/app/test/testdata/bear-640x360-av-live-static-golden.mpd index 377d854878..a4c435e0b0 100644 --- a/packager/app/test/testdata/bear-640x360-av-live-static-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-live-static-golden.mpd @@ -1,12 +1,13 @@ - + - + - + + diff --git a/packager/app/test/testdata/bear-640x360-av-por-BR-golden.mpd b/packager/app/test/testdata/bear-640x360-av-por-BR-golden.mpd index 641a9c4b2f..1a9fb6efcf 100644 --- a/packager/app/test/testdata/bear-640x360-av-por-BR-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-por-BR-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-por-golden.mpd b/packager/app/test/testdata/bear-640x360-av-por-golden.mpd index 641a9c4b2f..1a9fb6efcf 100644 --- a/packager/app/test/testdata/bear-640x360-av-por-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-por-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-trick-1-cenc-golden.mpd b/packager/app/test/testdata/bear-640x360-av-trick-1-cenc-golden.mpd index 3b1204aa54..8f9472fd1e 100644 --- a/packager/app/test/testdata/bear-640x360-av-trick-1-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-trick-1-cenc-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-trick-1-golden.mpd b/packager/app/test/testdata/bear-640x360-av-trick-1-golden.mpd index 9bd9928649..1a4c7f37c2 100644 --- a/packager/app/test/testdata/bear-640x360-av-trick-1-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-trick-1-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-cenc-golden.mpd b/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-cenc-golden.mpd index d1d8946925..5d16b77220 100644 --- a/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-cenc-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-golden.mpd b/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-golden.mpd index a42099b0ca..aa49b8ae1b 100644 --- a/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-trick-1-trick-2-golden.mpd @@ -1,6 +1,6 @@ - + diff --git a/packager/app/test/testdata/bear-640x360-avc3-wvm-golden.mp4 b/packager/app/test/testdata/bear-640x360-avc3-wvm-golden.mp4 index 1c0e5237cf0445d5a2c630f8845280120334182b..9553f9bd8d369081ab47cc0192bf17a489eef46e 100644 GIT binary patch delta 53 zcmeymLg?!Xp$(qQVr~Hp5Wvj9*doEeSe`I}LA - + diff --git a/packager/app/test/testdata/bear-640x360-ec3-v-cenc-golden.mp4 b/packager/app/test/testdata/bear-640x360-ec3-v-cenc-golden.mp4 index e883a5eac5139f5537fd745d70edd7e3b22991c3..ea10e135b39184582597d8648f7754d9998bc74a 100644 GIT binary patch delta 37 qcmbO|S!niTp$(ZVY_$p#7}zg0=d-luvoHcN6A&|R&u3xLX$1i8TMKgl delta 37 qcmbO|S!niTp$(ZVY^8n^7#J9u^I6*SSr~zs35c1u=d-Zrv;qL%f(pO@ diff --git a/packager/app/test/testdata/bear-640x360-ec3-v-mp4-cenc-golden.m3u8 b/packager/app/test/testdata/bear-640x360-ec3-v-mp4-cenc-golden.m3u8 index cdf5fa0ee4..2eddc6f85a 100644 --- a/packager/app/test/testdata/bear-640x360-ec3-v-mp4-cenc-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-ec3-v-mp4-cenc-golden.m3u8 @@ -5,7 +5,7 @@ #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-MAP:URI="output_video.mp4",BYTERANGE="1091@0" #EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,MTIzNDU2Nzg5MDEyMzQ1Ng==",KEYFORMAT="identity" -#EXTINF:1.001, +#EXTINF:1.068, #EXT-X-BYTERANGE:93805@1159 output_video.mp4 #EXTINF:1.001, 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 ba921f62147bcdc06b45a7961f35263cac6b103a..b98897e81a24c551b50799e7fc144a2d52d08b0a 100644 GIT binary patch delta 25 hcmZp?%G!99bwe)?Tdl$b2KGzMlX - + diff --git a/packager/app/test/testdata/bear-640x360-hevc-golden.mp4 b/packager/app/test/testdata/bear-640x360-hevc-golden.mp4 index 69170b8652e379cb6a759d7520c8c162d8dc8d56..b18ed17f70806b4a7c0d1621813aaaab09078c24 100644 GIT binary patch delta 25 hcmbP!n05ML)(yGrY_$p#7}zg07qf3KW@l810swsz2%G=_ delta 25 hcmbP!n05ML)(yGrY^8n^7#J9ui`lmqvooqh0RVQM2k8I+ 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 1edc8ecddc6472cfd7b70b14c7df6dabb2f48d80..8cbfc316caee1303e62c55a5009ddb231b9a3a31 100644 GIT binary patch delta 37 qcmbQgPiX!=p$(ZVY_$p#7}zg0=d-luvoHcN6A&|R&u3xTFbe?uD-3D? delta 37 qcmbQgPiX!=p$(ZVY^8n^7#J9u^I6*SSr~zs35c1u=d-YEm<0gsQVX{L 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 246a814ab05da035adeba2c36287863ac471df15..59c5ade7943b4dd3d94bfb0958d8936c5f25814f 100644 GIT binary patch delta 37 qcmeC!E!44FXhRVTTdl$b2KGzM6)f!)EQ~ - + diff --git a/packager/app/test/testdata/bear-640x360-v-live-ad_cues-golden-1.m4s b/packager/app/test/testdata/bear-640x360-v-live-ad_cues-golden-1.m4s index e8a21a613c3bb3799226baaf66bb6338bd12d28b..82605ec2c30428a0cff9d9f6c124502f65de509c 100644 GIT binary patch delta 38 ncmX@u!FI5NZGx2;0}L=SFgAZ=V5n7?z`%Z~F<@%|+d delta 38 ocmX@u!FI5NZGx2;`y~blU}Ruy{>Z>k>Nf$%Zw%NP!1%El0LCl|YybcN diff --git a/packager/app/test/testdata/bear-640x360-v-live-cenc-golden-1.m4s b/packager/app/test/testdata/bear-640x360-v-live-cenc-golden-1.m4s index c8e0ec8cfa6add9df9dea33d5aac40f12d250b09..eddc48d4b101b2693f7c60aa388cc3f4774dcf68 100644 GIT binary patch delta 38 ncmX@u!FI5NZGx2;0}L=SFgAZ=V5n7?z`%Z~F<@%|+d delta 38 ocmX@u!FI5NZGx2;`y~blU}Ruy{>Z>k>Nf$%Zw%NP!1%El0LCl|YybcN diff --git a/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-golden-1.m4s b/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-golden-1.m4s index 5ff1a7ced3a820ba9d483e563c6c7389e7ca507e..6fcbc85250059fe8368afb2371bf1ddef993fa14 100644 GIT binary patch delta 38 ncmey`!S=O-ZGx2;0}L=SFt(^NFw`ncU|_%07_c>fQMCmCv<3+n delta 38 ocmey`!S=O-ZGx2;`y~blU}RuyQDtB#^_u|XHwJ7CU{q}Z0LHorJ^%m! diff --git a/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-no-pssh-golden-1.m4s b/packager/app/test/testdata/bear-640x360-v-live-cenc-rotation-no-pssh-golden-1.m4s index c8e0ec8cfa6add9df9dea33d5aac40f12d250b09..eddc48d4b101b2693f7c60aa388cc3f4774dcf68 100644 GIT binary patch delta 38 ncmX@u!FI5NZGx2;0}L=SFgAZ=V5n7?z`%Z~F<@%|+d delta 38 ocmX@u!FI5NZGx2;`y~blU}Ruy{>Z>k>Nf$%Zw%NP!1%El0LCl|YybcN diff --git a/packager/app/test/testdata/bear-640x360-v-live-golden-1.m4s b/packager/app/test/testdata/bear-640x360-v-live-golden-1.m4s index e8a21a613c3bb3799226baaf66bb6338bd12d28b..82605ec2c30428a0cff9d9f6c124502f65de509c 100644 GIT binary patch delta 38 ncmX@u!FI5NZGx2;0}L=SFgAZ=V5n7?z`%Z~F<@%|+d delta 38 ocmX@u!FI5NZGx2;`y~blU}Ruy{>Z>k>Nf$%Zw%NP!1%El0LCl|YybcN diff --git a/packager/app/test/testdata/bear-640x360-v-mp4-cenc-ad_cues-golden.m3u8 b/packager/app/test/testdata/bear-640x360-v-mp4-cenc-ad_cues-golden.m3u8 index 99442c7fdd..74b9eaed2f 100644 --- a/packager/app/test/testdata/bear-640x360-v-mp4-cenc-ad_cues-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-v-mp4-cenc-ad_cues-golden.m3u8 @@ -5,7 +5,7 @@ #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-MAP:URI="output_video.mp4",BYTERANGE="1091@0" #EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,MTIzNDU2Nzg5MDEyMzQ1Ng==",KEYFORMAT="identity" -#EXTINF:1.001, +#EXTINF:1.068, #EXT-X-BYTERANGE:99313@1159 output_video.mp4 #EXTINF:1.001, diff --git a/packager/app/test/testdata/bear-640x360-v-mp4-cenc-golden.m3u8 b/packager/app/test/testdata/bear-640x360-v-mp4-cenc-golden.m3u8 index 2cfe6ed71d..e9bf00a372 100644 --- a/packager/app/test/testdata/bear-640x360-v-mp4-cenc-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-v-mp4-cenc-golden.m3u8 @@ -5,7 +5,7 @@ #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-MAP:URI="output_video.mp4",BYTERANGE="1091@0" #EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,MTIzNDU2Nzg5MDEyMzQ1Ng==",KEYFORMAT="identity" -#EXTINF:1.001, +#EXTINF:1.068, #EXT-X-BYTERANGE:99313@1159 output_video.mp4 #EXTINF:1.001, diff --git a/packager/app/test/testdata/bear-640x360-v-mp4-golden.m3u8 b/packager/app/test/testdata/bear-640x360-v-mp4-golden.m3u8 index 0f3fbe7f5a..2c0c3d4ea0 100644 --- a/packager/app/test/testdata/bear-640x360-v-mp4-golden.m3u8 +++ b/packager/app/test/testdata/bear-640x360-v-mp4-golden.m3u8 @@ -4,7 +4,7 @@ #EXT-X-TARGETDURATION:2 #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-MAP:URI="video-init.mp4" -#EXTINF:1.001, +#EXTINF:1.068, video-1.m4s #EXTINF:1.001, video-2.m4s diff --git a/packager/app/test/testdata/bear-640x360-v-trick-1-cenc-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-trick-1-cenc-golden.mp4 index c6251150ff91bdfd68bffda524eefee9de777fe9..ce0e437d68e55e896b0a3279ca9ae4fc59716cd3 100644 GIT binary patch delta 21 dcmdnCgn8Q%<_(!FY_$p#7}zgu&SyD(764r22%Z1{ delta 21 dcmdnCgn8Q%<_(!FY^8n^7#J8f=d&C?3jkR=2kQU; diff --git a/packager/app/test/testdata/bear-640x360-v-trick-1-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-trick-1-golden.mp4 index 60407efb5f9a4656a5cec43a7b1dcf5b63415c03..0473a61a765db7cbd07fe9703cfa719d1db97a9e 100644 GIT binary patch delta 21 dcmZ3mka@vE<_)pTY_$p#7}zguPG+_}3jkLi2gm>b delta 21 dcmZ3mka@vE<_)pTY^8n^7#J8fCo|ig1prfa2NeJS 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 e4d1f9556e9e6390d73c33c42e4ae8de02e2f129..09bc5d466810b4370487cd3949b50f21240d69cc 100644 GIT binary patch delta 21 dcmbO-gK5ePrVW`aY@hNbFtA_RoX@hf9ROWm2%7)^ delta 21 dcmbO-gK5ePrVW`aY_H}_U|?X_oX@hf9ROLk2j~C* diff --git a/packager/app/test/testdata/bear-640x360-v-trick-2-golden.mp4 b/packager/app/test/testdata/bear-640x360-v-trick-2-golden.mp4 index 078bad9cc8fd6923ac5f6a4981db93d8cd72d208..5279433a2bef6699ad2df0233efe7384282d706b 100644 GIT binary patch delta 37 tcmX>+mFe(QrVX*oLZ9*`FtA@@VDP@oz!1hZfq{Wx@&`Nd&27xK?Ew9H41xdv delta 37 ocmX>+mFe(QrVX*oLa*jbU;qK{%M1)*Y#{dJ4|d|4+n87nVDtb1OR9J B4W0l1 delta 53 ycmZo!A=I)$XoD}a7y}G2GcY!PWMGVcH32BnoXp&w%*+VHOhC-MJ(-zh;RFCqVGQj6 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 8c3c919a137edfff5c011c0fd2bede00b4741cf5..dbfd1689cc46e9df99a436fbd19797bcb65b38b4 100644 GIT binary patch delta 21 ccmbQz&pxG}eS<6uQ|g3fd6w<+ER3ax0ZzUK)&Kwi delta 21 ccmbQz&pxG}eS<6u69YrDJj-@@7RJ)U07S output_video.mp4 - + diff --git a/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd b/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd index 2aea967717..0b3ec13441 100644 --- a/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-vp8-cenc-webm-golden.mpd @@ -8,7 +8,7 @@ output_video.webm - + diff --git a/packager/app/test/testdata/bear-640x360-vp8-golden.mp4 b/packager/app/test/testdata/bear-640x360-vp8-golden.mp4 index 8c51125bac835e62cda0c903fbd3d87096d25a68..e5033f940a62e01c637fef591d8e5dd76e35c1f0 100644 GIT binary patch delta 21 ccmbQ!$v&r(eS output_video.webm - + diff --git a/packager/app/test/testdata/bear-avc3-wvm-golden.mpd b/packager/app/test/testdata/bear-avc3-wvm-golden.mpd index a44577f4b0..66b6b9bf71 100644 --- a/packager/app/test/testdata/bear-avc3-wvm-golden.mpd +++ b/packager/app/test/testdata/bear-avc3-wvm-golden.mpd @@ -1,17 +1,17 @@ - + output_0.mp4 - + output_2.mp4 - + @@ -20,14 +20,14 @@ output_1.mp4 - + output_3.mp4 - + diff --git a/packager/app/test/testdata/bear-wvm-golden.mpd b/packager/app/test/testdata/bear-wvm-golden.mpd index bb0cd8b4d2..7abea46a19 100644 --- a/packager/app/test/testdata/bear-wvm-golden.mpd +++ b/packager/app/test/testdata/bear-wvm-golden.mpd @@ -1,17 +1,17 @@ - + output_0.mp4 - + output_2.mp4 - + @@ -20,14 +20,14 @@ output_1.mp4 - + output_3.mp4 - + diff --git a/packager/media/formats/mp4/fragmenter.cc b/packager/media/formats/mp4/fragmenter.cc index 166abb4c79..d637e467ce 100644 --- a/packager/media/formats/mp4/fragmenter.cc +++ b/packager/media/formats/mp4/fragmenter.cc @@ -6,6 +6,7 @@ #include "packager/media/formats/mp4/fragmenter.h" +#include #include #include "packager/media/base/audio_stream_info.h" @@ -150,6 +151,24 @@ Status Fragmenter::FinalizeFragment() { return status; } + if (first_fragment_) { + // Chrome (as of v66 https://crbug.com/398141) does not like negative values + // for adjusted dts = dts + Period@start (0 for first Period) + // - presentationTimeOffset + // Since |earliest_presentation_time| of the first fragment will be used to + // set presentationTimeOffset, the adjusted dts can become negative for the + // frames in the first segment in the first Period. To avoid seeing that, + // |earliest_presentation_time| is adjusted so it is not larger than the + // dts. + const int64_t dts = traf_->decode_time.decode_time; + if (earliest_presentation_time_ > dts) { + const uint64_t delta = earliest_presentation_time_ - dts; + earliest_presentation_time_ = dts; + fragment_duration_ += delta; + } + first_fragment_ = false; + } + // Optimize trun box. traf_->runs[0].sample_count = static_cast(traf_->runs[0].sample_sizes.size()); @@ -208,7 +227,7 @@ Status Fragmenter::FinalizeFragment() { return Status::OK; } -void Fragmenter::GenerateSegmentReference(SegmentReference* reference) { +void Fragmenter::GenerateSegmentReference(SegmentReference* reference) const { // NOTE: Daisy chain is not supported currently. reference->reference_type = false; reference->subsegment_duration = fragment_duration_; @@ -275,7 +294,7 @@ Status Fragmenter::FinalizeFragmentForEncryption() { return Status::OK; } -bool Fragmenter::StartsWithSAP() { +bool Fragmenter::StartsWithSAP() const { DCHECK(!traf_->runs.empty()); uint32_t start_sample_flag; if (traf_->runs[0].flags & TrackFragmentRun::kSampleFlagsPresentMask) { diff --git a/packager/media/formats/mp4/fragmenter.h b/packager/media/formats/mp4/fragmenter.h index 8870077754..4edf5c116b 100644 --- a/packager/media/formats/mp4/fragmenter.h +++ b/packager/media/formats/mp4/fragmenter.h @@ -51,7 +51,7 @@ class Fragmenter { Status FinalizeFragment(); /// Fill @a reference with current fragment information. - void GenerateSegmentReference(SegmentReference* reference); + void GenerateSegmentReference(SegmentReference* reference) const; void ClearFragmentFinalized() { fragment_finalized_ = false; } @@ -88,7 +88,7 @@ class Fragmenter { private: Status FinalizeFragmentForEncryption(); // Check if the current fragment starts with SAP. - bool StartsWithSAP(); + bool StartsWithSAP() const; std::shared_ptr stream_info_; bool use_decoding_timestamp_in_timeline_; @@ -98,6 +98,7 @@ class Fragmenter { bool fragment_finalized_; uint64_t fragment_duration_; int64_t earliest_presentation_time_; + bool first_fragment_ = true; int64_t first_sap_time_; std::unique_ptr data_; // Saves key frames information, for Video. diff --git a/packager/media/formats/mp4/single_segment_segmenter.cc b/packager/media/formats/mp4/single_segment_segmenter.cc index 409cdac680..7c54d9235a 100644 --- a/packager/media/formats/mp4/single_segment_segmenter.cc +++ b/packager/media/formats/mp4/single_segment_segmenter.cc @@ -196,25 +196,7 @@ Status SingleSegmentSegmenter::DoFinalizeSegment() { vod_sidx_.reset(new SegmentIndex()); vod_sidx_->reference_id = sidx()->reference_id; vod_sidx_->timescale = sidx()->timescale; - - if (vod_ref.earliest_presentation_time > 0) { - const double starting_time_in_seconds = - static_cast(vod_ref.earliest_presentation_time) / - GetReferenceTimeScale(); - // Give a warning if it is significant. - if (starting_time_in_seconds > 0.5) { - // Note that DASH IF player requires presentationTimeOffset to be set in - // Segment{Base,List,Template} if there is non-zero starting time. Since - // current Chromium's MSE implementation uses DTS, the player expects - // DTS to be used. - LOG(WARNING) << "Warning! Non-zero starting time (in seconds): " - << starting_time_in_seconds - << ". Manual adjustment of presentationTimeOffset in " - "mpd might be necessary."; - } - } - // Force earliest_presentation_time to start from 0 for VOD. - vod_sidx_->earliest_presentation_time = 0; + vod_sidx_->earliest_presentation_time = vod_ref.earliest_presentation_time; } vod_sidx_->references.push_back(vod_ref); diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index b1fc1656d7..c3853478f3 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -338,7 +338,6 @@ bool MpdBuilder::GetEarliestTimestamp(double* timestamp_seconds) { void MpdBuilder::UpdatePeriodDurationAndPresentationTimestamp() { DCHECK_EQ(MpdType::kStatic, mpd_options_.mpd_type); - bool first_period = true; for (const auto& period : periods_) { std::list video_representations; std::list non_video_representations; @@ -378,21 +377,6 @@ void MpdBuilder::UpdatePeriodDurationAndPresentationTimestamp() { period->set_duration_seconds(*latest_end_time - *earliest_start_time); double presentation_time_offset = *earliest_start_time; - if (first_period) { - first_period = false; - // Chrome does not like negative dts (https://crbug.com/398141). - // Always set presentationTimeOffset (pto) to 0 for the first period as it - // may result in an error on Chrome v63.0.3239.132 if it sets to a non - // zero value. - // It is fine with subsequent periods as the actual offset applied takes - // Period@start into consideration: - // offset = Period@start - presentationTimeOffset - // The result timestamp with offset applied is close to Period@start, so - // it is unlikely to result in a negative dts value. - // TODO(kqyang): Set the pto to |dts| instead of always setting it to 0 to - // workaround Chrome negative DTS bug. - presentation_time_offset = 0; - } for (const auto& adaptation_set : period->GetAdaptationSets()) { for (const auto& representation : adaptation_set->GetRepresentations()) { representation->SetPresentationTimeOffset(presentation_time_offset); diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 288354025c..49fb4fc72d 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -174,6 +174,29 @@ TEST_F(OnDemandMpdBuilderTest, MediaInfoMissingBandwidth) { ASSERT_FALSE(mpd_.ToString(&mpd_doc)); } +TEST_F(OnDemandMpdBuilderTest, CheckXmlTest) { + // Disable pto adjustment. + FLAGS_pto_adjustment = 0; + + const double kPeriod1StartTimeSeconds = 0.0; + + // Actual period duration is determined by the segments not by the period + // start time above, which only provides an anchor point. + const double kPeriod1SegmentStartSeconds = 0.2; + const double kPeriod1SegmentDurationSeconds = 3.0; + + Period* period = mpd_.GetOrCreatePeriod(kPeriod1StartTimeSeconds); + AddSegmentToPeriod(kPeriod1SegmentStartSeconds, + kPeriod1SegmentDurationSeconds, period); + + std::string mpd_doc; + ASSERT_TRUE(mpd_.ToString(&mpd_doc)); + EXPECT_THAT(mpd_doc, HasSubstr("\n")); + EXPECT_THAT(mpd_doc, + HasSubstr("")); +} + TEST_F(OnDemandMpdBuilderTest, MultiplePeriodTest) { const double kPeriodStartTimeSeconds = 1.0; Period* period = mpd_.GetOrCreatePeriod(kPeriodStartTimeSeconds); @@ -226,17 +249,19 @@ TEST_F(OnDemandMpdBuilderTest, MultiplePeriodCheckXmlTest) { std::string mpd_doc; ASSERT_TRUE(mpd_.ToString(&mpd_doc)); EXPECT_THAT(mpd_doc, HasSubstr("\n")); + EXPECT_THAT(mpd_doc, + HasSubstr("")); + EXPECT_THAT(mpd_doc, HasSubstr("\n")); EXPECT_THAT( mpd_doc, - HasSubstr("")); - EXPECT_THAT(mpd_doc, HasSubstr("\n")); - EXPECT_THAT(mpd_doc, - HasSubstr("")); + HasSubstr("")); EXPECT_THAT(mpd_doc, HasSubstr("\n")); - EXPECT_THAT(mpd_doc, - HasSubstr("")); + EXPECT_THAT( + mpd_doc, + HasSubstr("")); } TEST_F(LiveMpdBuilderTest, MultiplePeriodCheckXmlTest) {