From b2932d5a335778e9542c809f06c3650087795856 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Mon, 23 Apr 2018 17:20:00 -0700 Subject: [PATCH] Fix bitrate for DASH on-demand profile too Removed the logic in MuxerListener to estimate bandwidth from file size and duration, since it is not compliant to the spec. MpdBuilder will estimate bandwidth from segment size and duration if bandwidth is not specified in MediaInfo. Here is the statement from DASH spec (23009-1:2014): Consider a hypothetical constant bitrate channel of bandwidth with the value of this attribute in bits per second (bps). Then, if the Representation is continuously delivered at this bitrate, starting at any SAP that is indicated either by @startwithsap or by any Segment Index box, a client can be assured of having enough data for continuous playout providing playout begins after @minbuffertime * @bandwidth bits have been received (i.e. at time @minbuffertime after the first bit is received). For dependent Representations this value specifies the bandwidth according to the above definition for the aggregation of this Representation and all complementary Representations. Fixes #376. Change-Id: I0fddce39e709d0cded0a4c9ae59adbbcc97ec5ea --- packager/app/test/testdata/acc-he/output.mpd | 2 +- .../output.mpd | 4 +- .../output.mpd | 4 +- .../audio-video-with-trick-play/output.mpd | 6 +- .../output.mpd | 8 +-- .../app/test/testdata/audio-video/output.mpd | 4 +- .../testdata/bear-640x360-av-cbcs-golden.mpd | 4 +- .../testdata/bear-640x360-av-cenc-golden.mpd | 4 +- .../bear-640x360-av-cenc-non-iop-golden.mpd | 4 +- .../encryption-and-ad-cues/output.mpd | 8 +-- .../encryption-and-no-clear-lead/output.mpd | 4 +- .../output.mpd | 4 +- .../bear-640x360-audio.mp4.media_info | 2 +- .../bear-640x360-video.mp4.media_info | 2 +- .../encryption-and-trick-play/output.mpd | 6 +- .../encryption-and-two-trick-plays/output.mpd | 8 +-- .../test/testdata/encryption-cbc-1/output.mpd | 4 +- .../test/testdata/encryption-cens/output.mpd | 4 +- .../output.mpd | 4 +- .../testdata/encryption-multi-keys/output.mpd | 4 +- .../output.mpd | 4 +- .../encryption-using-fixed-key/output.mpd | 4 +- .../app/test/testdata/encryption/output.mpd | 4 +- .../app/test/testdata/first-stream/output.mpd | 2 +- .../testdata/hevc-with-encryption/output.mpd | 2 +- .../opus-vp9-mp4-with-encryption/output.mpd | 4 +- .../test/testdata/video-audio-text/output.mpd | 4 +- .../app/test/testdata/vorbis-webm/output.mpd | 2 +- .../vp8-mp4-with-encryption/output.mpd | 2 +- .../app/test/testdata/vp8-webm/output.mpd | 2 +- .../vp9-webm-with-blockgroup/output.mpd | 2 +- .../app/test/testdata/vp9-webm/output.mpd | 4 +- .../webm-subsample-encryption/output.mpd | 2 +- .../output.mpd | 2 +- .../testdata/webm-with-encryption/output.mpd | 2 +- .../output.mpd | 8 +-- .../app/test/testdata/wvm-input/output.mpd | 8 +-- .../mpd_notify_muxer_listener_unittest.cc | 1 - .../media/event/muxer_listener_internal.cc | 26 --------- .../media/event/muxer_listener_test_helper.h | 8 ++- .../vod_media_info_dump_muxer_listener.cc | 16 +++++- .../vod_media_info_dump_muxer_listener.h | 3 +- ...media_info_dump_muxer_listener_unittest.cc | 56 +++++++++++++++++-- packager/mpd/base/mpd_builder_unittest.cc | 11 ---- packager/mpd/base/representation.cc | 10 ---- 45 files changed, 149 insertions(+), 130 deletions(-) diff --git a/packager/app/test/testdata/acc-he/output.mpd b/packager/app/test/testdata/acc-he/output.mpd index 276c1d9ae2..930f5157a9 100644 --- a/packager/app/test/testdata/acc-he/output.mpd +++ b/packager/app/test/testdata/acc-he/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-aac_he-silent_right-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd index a7c74fc568..b3c34985fc 100644 --- a/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd +++ b/packager/app/test/testdata/audio-video-with-language-override-with-subtag/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.mp4 @@ -11,7 +11,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-language-override/output.mpd b/packager/app/test/testdata/audio-video-with-language-override/output.mpd index 969b06e962..6e10d55a2f 100644 --- a/packager/app/test/testdata/audio-video-with-language-override/output.mpd +++ b/packager/app/test/testdata/audio-video-with-language-override/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.mp4 @@ -12,7 +12,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-trick-play/output.mpd index 406031e9bc..6bc1290825 100644 --- a/packager/app/test/testdata/audio-video-with-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-trick-play/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.mp4 @@ -12,7 +12,7 @@ - + bear-640x360-video-trick_play_factor_1.mp4 @@ -20,7 +20,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd index 3376c8d0db..f58f1cc09e 100644 --- a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.mp4 @@ -12,13 +12,13 @@ - + bear-640x360-video-trick_play_factor_2.mp4 - + bear-640x360-video-trick_play_factor_1.mp4 @@ -26,7 +26,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/audio-video/output.mpd b/packager/app/test/testdata/audio-video/output.mpd index cc41438310..7b011f19a2 100644 --- a/packager/app/test/testdata/audio-video/output.mpd +++ b/packager/app/test/testdata/audio-video/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.mp4 @@ -11,7 +11,7 @@ - + bear-640x360-audio.mp4 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 abbc149629..aab95f3265 100644 --- a/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cbcs-golden.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 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 955443b1c6..90522e074a 100644 --- a/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd +++ b/packager/app/test/testdata/bear-640x360-av-cenc-golden.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 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 f15e43cd03..c78bebd1f9 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 @@ -3,7 +3,7 @@ - + AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== @@ -15,7 +15,7 @@ - + diff --git a/packager/app/test/testdata/encryption-and-ad-cues/output.mpd b/packager/app/test/testdata/encryption-and-ad-cues/output.mpd index 501f4288dd..a8711aab5a 100644 --- a/packager/app/test/testdata/encryption-and-ad-cues/output.mpd +++ b/packager/app/test/testdata/encryption-and-ad-cues/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 @@ -20,7 +20,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -34,7 +34,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 @@ -47,7 +47,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 diff --git a/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd b/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd index 6c9d0c3d29..a406c368eb 100644 --- a/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd +++ b/packager/app/test/testdata/encryption-and-no-clear-lead/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd b/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd index 0f841e15f3..db8a9ddfec 100644 --- a/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd +++ b/packager/app/test/testdata/encryption-and-no-pssh-in-stream/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-audio.mp4.media_info b/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-audio.mp4.media_info index 81c9899a52..af1dd07a5c 100644 --- a/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-audio.mp4.media_info +++ b/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-audio.mp4.media_info @@ -1,4 +1,4 @@ -bandwidth: 129162 +bandwidth: 133406 audio_info { codec: "mp4a.40.2" sampling_frequency: 44100 diff --git a/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-video.mp4.media_info b/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-video.mp4.media_info index 43b401de22..61ab89e2f9 100644 --- a/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-video.mp4.media_info +++ b/packager/app/test/testdata/encryption-and-output-media-info/bear-640x360-video.mp4.media_info @@ -1,4 +1,4 @@ -bandwidth: 885590 +bandwidth: 977743 video_info { codec: "avc1.64001e" width: 640 diff --git a/packager/app/test/testdata/encryption-and-trick-play/output.mpd b/packager/app/test/testdata/encryption-and-trick-play/output.mpd index c890540aa5..40251c3e18 100644 --- a/packager/app/test/testdata/encryption-and-trick-play/output.mpd +++ b/packager/app/test/testdata/encryption-and-trick-play/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -20,7 +20,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video-trick_play_factor_1.mp4 @@ -32,7 +32,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd index 629287de1f..41b09094f3 100644 --- a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd +++ b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -20,13 +20,13 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video-trick_play_factor_2.mp4 - + bear-640x360-video-trick_play_factor_1.mp4 @@ -38,7 +38,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-cbc-1/output.mpd b/packager/app/test/testdata/encryption-cbc-1/output.mpd index be386623e4..98b44c9d6f 100644 --- a/packager/app/test/testdata/encryption-cbc-1/output.mpd +++ b/packager/app/test/testdata/encryption-cbc-1/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-cens/output.mpd b/packager/app/test/testdata/encryption-cens/output.mpd index 1bad06fde1..7b1e637eea 100644 --- a/packager/app/test/testdata/encryption-cens/output.mpd +++ b/packager/app/test/testdata/encryption-cens/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd b/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd index b93325dba9..6598851047 100644 --- a/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd +++ b/packager/app/test/testdata/encryption-multi-keys-with-stream-label/output.mpd @@ -7,7 +7,7 @@ AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-multi-keys/output.mpd b/packager/app/test/testdata/encryption-multi-keys/output.mpd index 135bca7a7e..5d4d105dfd 100644 --- a/packager/app/test/testdata/encryption-multi-keys/output.mpd +++ b/packager/app/test/testdata/encryption-multi-keys/output.mpd @@ -7,7 +7,7 @@ AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAARHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAIQERITFBUWFxgZICEiIyQlICEiIyQlJicoKTAxMjM0NQAAAAA= - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd b/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd index aac311031d..09783656aa 100644 --- a/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd +++ b/packager/app/test/testdata/encryption-of-only-video-stream/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -15,7 +15,7 @@ - + bear-640x360-audio-skip_encryption.mp4 diff --git a/packager/app/test/testdata/encryption-using-fixed-key/output.mpd b/packager/app/test/testdata/encryption-using-fixed-key/output.mpd index 955443b1c6..90522e074a 100644 --- a/packager/app/test/testdata/encryption-using-fixed-key/output.mpd +++ b/packager/app/test/testdata/encryption-using-fixed-key/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/encryption/output.mpd b/packager/app/test/testdata/encryption/output.mpd index 955443b1c6..90522e074a 100644 --- a/packager/app/test/testdata/encryption/output.mpd +++ b/packager/app/test/testdata/encryption/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 @@ -19,7 +19,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/first-stream/output.mpd b/packager/app/test/testdata/first-stream/output.mpd index 9400a05120..7f60529716 100644 --- a/packager/app/test/testdata/first-stream/output.mpd +++ b/packager/app/test/testdata/first-stream/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-0.mp4 diff --git a/packager/app/test/testdata/hevc-with-encryption/output.mpd b/packager/app/test/testdata/hevc-with-encryption/output.mpd index f70db69d40..568659f8b9 100644 --- a/packager/app/test/testdata/hevc-with-encryption/output.mpd +++ b/packager/app/test/testdata/hevc-with-encryption/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-hevc-video.mp4 diff --git a/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd b/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd index 9ba2d9b72d..159d99300f 100644 --- a/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd +++ b/packager/app/test/testdata/opus-vp9-mp4-with-encryption/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x240-vp9-opus-audio.mp4 @@ -20,7 +20,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x240-vp9-opus-video.mp4 diff --git a/packager/app/test/testdata/video-audio-text/output.mpd b/packager/app/test/testdata/video-audio-text/output.mpd index ad7e4a7d4b..7aea0acb6f 100644 --- a/packager/app/test/testdata/video-audio-text/output.mpd +++ b/packager/app/test/testdata/video-audio-text/output.mpd @@ -8,7 +8,7 @@ - + bear-640x360-video.mp4 @@ -16,7 +16,7 @@ - + bear-640x360-audio.mp4 diff --git a/packager/app/test/testdata/vorbis-webm/output.mpd b/packager/app/test/testdata/vorbis-webm/output.mpd index 4b8ced7f6f..73e8ac87cc 100644 --- a/packager/app/test/testdata/vorbis-webm/output.mpd +++ b/packager/app/test/testdata/vorbis-webm/output.mpd @@ -3,7 +3,7 @@ - + bear-320x240-audio-only-audio.webm diff --git a/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd b/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd index afbd586a37..188e15c6ba 100644 --- a/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd +++ b/packager/app/test/testdata/vp8-mp4-with-encryption/output.mpd @@ -7,7 +7,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.mp4 diff --git a/packager/app/test/testdata/vp8-webm/output.mpd b/packager/app/test/testdata/vp8-webm/output.mpd index 3b0f4feedf..2357e3f266 100644 --- a/packager/app/test/testdata/vp8-webm/output.mpd +++ b/packager/app/test/testdata/vp8-webm/output.mpd @@ -3,7 +3,7 @@ - + bear-640x360-video.webm diff --git a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd index 57ca8e3ece..fb3aeef4be 100644 --- a/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd +++ b/packager/app/test/testdata/vp9-webm-with-blockgroup/output.mpd @@ -3,7 +3,7 @@ - + bear-vp9-blockgroup-video.webm diff --git a/packager/app/test/testdata/vp9-webm/output.mpd b/packager/app/test/testdata/vp9-webm/output.mpd index 382c854f6e..de85cd81a3 100644 --- a/packager/app/test/testdata/vp9-webm/output.mpd +++ b/packager/app/test/testdata/vp9-webm/output.mpd @@ -3,7 +3,7 @@ - + bear-320x240-vp9-opus-audio.webm @@ -12,7 +12,7 @@ - + bear-320x240-vp9-opus-video.webm diff --git a/packager/app/test/testdata/webm-subsample-encryption/output.mpd b/packager/app/test/testdata/webm-subsample-encryption/output.mpd index 50d2817883..d50519d9ed 100644 --- a/packager/app/test/testdata/webm-subsample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-subsample-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x180-vp9-altref-video.webm diff --git a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd index 50d2817883..d50519d9ed 100644 --- a/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd +++ b/packager/app/test/testdata/webm-vp9-full-sample-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-320x180-vp9-altref-video.webm diff --git a/packager/app/test/testdata/webm-with-encryption/output.mpd b/packager/app/test/testdata/webm-with-encryption/output.mpd index 7428611196..73e41c7ff0 100644 --- a/packager/app/test/testdata/webm-with-encryption/output.mpd +++ b/packager/app/test/testdata/webm-with-encryption/output.mpd @@ -6,7 +6,7 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - + bear-640x360-video.webm diff --git a/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd b/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd index dd290501c0..e3ebb1f1df 100644 --- a/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd +++ b/packager/app/test/testdata/wvm-input-without-stripping-parameters-set-nalus/output.mpd @@ -3,13 +3,13 @@ - + bear-multi-configs-0.mp4 - + bear-multi-configs-2.mp4 @@ -17,14 +17,14 @@ - + bear-multi-configs-1.mp4 - + bear-multi-configs-3.mp4 diff --git a/packager/app/test/testdata/wvm-input/output.mpd b/packager/app/test/testdata/wvm-input/output.mpd index 2966176422..f9c0852c52 100644 --- a/packager/app/test/testdata/wvm-input/output.mpd +++ b/packager/app/test/testdata/wvm-input/output.mpd @@ -3,13 +3,13 @@ - + bear-multi-configs-0.mp4 - + bear-multi-configs-2.mp4 @@ -17,14 +17,14 @@ - + bear-multi-configs-1.mp4 - + bear-multi-configs-3.mp4 diff --git a/packager/media/event/mpd_notify_muxer_listener_unittest.cc b/packager/media/event/mpd_notify_muxer_listener_unittest.cc index ce8790f71e..05813873b0 100644 --- a/packager/media/event/mpd_notify_muxer_listener_unittest.cc +++ b/packager/media/event/mpd_notify_muxer_listener_unittest.cc @@ -192,7 +192,6 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReady) { CreateVideoStreamInfo(video_params); const uint32_t kSampleDuration = 1234u; const char kExpectedMediaInfo[] = - "bandwidth: 7620\n" "video_info {\n" " frame_duration: 1234\n" // Should match the constant above. " codec: 'avc1.010101'\n" diff --git a/packager/media/event/muxer_listener_internal.cc b/packager/media/event/muxer_listener_internal.cc index 85dd06d5f2..c5de0ddc27 100644 --- a/packager/media/event/muxer_listener_internal.cc +++ b/packager/media/event/muxer_listener_internal.cc @@ -25,17 +25,6 @@ namespace internal { namespace { -// This will return a positive value, given that |file_size| and -// |duration_seconds| are positive. -uint32_t EstimateRequiredBandwidth(uint64_t file_size, float duration_seconds) { - const uint64_t file_size_bits = file_size * 8; - const float bits_per_second = file_size_bits / duration_seconds; - - // Note that casting |bits_per_second| to an integer might make it 0. Take the - // ceiling and make sure that it returns a positive value. - return static_cast(ceil(bits_per_second)); -} - // TODO(rkuroiwa): There is shaka::Range in MediaInfo proto and // shaka::media::Range in media/base. Find better names. void SetRange(uint64_t begin, uint64_t end, shaka::Range* range) { @@ -207,21 +196,6 @@ bool SetVodInformation(const MuxerListener::MediaRanges& media_ranges, media_info->set_media_duration_seconds(duration_seconds); - if (!media_info->has_bandwidth()) { - // Calculate file size from media_ranges. - uint64_t file_size = 0; - if (media_ranges.init_range) - file_size = std::max(file_size, media_ranges.init_range->end + 1); - if (media_ranges.index_range) - file_size = std::max(file_size, media_ranges.index_range->end + 1); - if (!media_ranges.subsegment_ranges.empty()) { - file_size = - std::max(file_size, media_ranges.subsegment_ranges.back().end + 1); - } - - media_info->set_bandwidth( - EstimateRequiredBandwidth(file_size, duration_seconds)); - } return true; } diff --git a/packager/media/event/muxer_listener_test_helper.h b/packager/media/event/muxer_listener_test_helper.h index 3b96d00e5f..fa4c2d25db 100644 --- a/packager/media/event/muxer_listener_test_helper.h +++ b/packager/media/event/muxer_listener_test_helper.h @@ -28,7 +28,6 @@ const char kExpectedDefaultPsshBox[] = "\\000\\000\\000$pssh\\000\\000\\000\\000\\000\\001\\002\\003\\004\\005" "\\006\\007\\010\\t\\n\\013\\014\\r\\016\\017\\000\\000\\000\\004pssh"; const char kExpectedDefaultMediaInfo[] = - "bandwidth: 7620\n" "video_info {\n" " codec: 'avc1.010101'\n" " width: 720\n" @@ -72,6 +71,13 @@ struct VideoStreamInfoParameters { bool is_encrypted; }; +struct OnNewSegmentParameters { + std::string file_name; + uint64_t start_time; + uint64_t duration; + uint64_t segment_file_size; +}; + // Note that this does not have vector of StreamInfo pointer. struct OnMediaEndParameters { MuxerListener::MediaRanges media_ranges; diff --git a/packager/media/event/vod_media_info_dump_muxer_listener.cc b/packager/media/event/vod_media_info_dump_muxer_listener.cc index 489d5101b1..4a09ac3b60 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener.cc +++ b/packager/media/event/vod_media_info_dump_muxer_listener.cc @@ -8,6 +8,8 @@ #include +#include + #include "packager/base/logging.h" #include "packager/file/file.h" #include "packager/media/base/muxer_options.h" @@ -21,7 +23,7 @@ namespace media { VodMediaInfoDumpMuxerListener::VodMediaInfoDumpMuxerListener( const std::string& output_file_path) - : output_file_name_(output_file_path), is_encrypted_(false) {} + : output_file_name_(output_file_path) {} VodMediaInfoDumpMuxerListener::~VodMediaInfoDumpMuxerListener() {} @@ -80,13 +82,23 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd(const MediaRanges& media_ranges, LOG(ERROR) << "Failed to generate VOD information from input."; return; } + if (!media_info_->has_bandwidth()) + media_info_->set_bandwidth(max_bitrate_); WriteMediaInfoToFile(*media_info_, output_file_name_); } void VodMediaInfoDumpMuxerListener::OnNewSegment(const std::string& file_name, uint64_t start_time, uint64_t duration, - uint64_t segment_file_size) {} + uint64_t segment_file_size) { + const double segment_duration_seconds = + static_cast(duration) / media_info_->reference_time_scale(); + + const int kBitsInByte = 8; + const uint64_t bitrate = + ceil(kBitsInByte * segment_file_size / segment_duration_seconds); + max_bitrate_ = std::max(max_bitrate_, bitrate); +} void VodMediaInfoDumpMuxerListener::OnKeyFrame(uint64_t timestamp, uint64_t start_byte_offset, diff --git a/packager/media/event/vod_media_info_dump_muxer_listener.h b/packager/media/event/vod_media_info_dump_muxer_listener.h index 235bcd0066..6990fd667b 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener.h +++ b/packager/media/event/vod_media_info_dump_muxer_listener.h @@ -68,8 +68,9 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { private: std::string output_file_name_; std::unique_ptr media_info_; + uint64_t max_bitrate_ = 0; - bool is_encrypted_; + bool is_encrypted_ = false; // Storage for values passed to OnEncryptionInfoReady(). FourCC protection_scheme_; std::vector default_key_id_; diff --git a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc index b5689c1419..2c570c6557 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc +++ b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc @@ -93,6 +93,11 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test { MuxerListener::kContainerMp4); } + void FireOnNewSegmentWithParams(const OnNewSegmentParameters& params) { + listener_->OnNewSegment(params.file_name, params.start_time, + params.duration, params.segment_file_size); + } + void FireOnMediaEndWithParams(const OnMediaEndParameters& params) { // On success, this writes the result to |temp_file_path_|. listener_->OnMediaEnd(params.media_ranges, params.duration_seconds); @@ -125,7 +130,7 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, UnencryptedStream_Normal) { FireOnMediaEndWithParams(media_end_param); const char kExpectedProtobufOutput[] = - "bandwidth: 7620\n" + "bandwidth: 0\n" "video_info {\n" " codec: 'avc1.010101'\n" " width: 720\n" @@ -157,7 +162,7 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, EncryptedStream_Normal) { FireOnMediaEndWithParams(media_end_param); const std::string kExpectedProtobufOutput = - "bandwidth: 7620\n" + "bandwidth: 0\n" "video_info {\n" " codec: 'avc1.010101'\n" " width: 720\n" @@ -181,7 +186,9 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, EncryptedStream_Normal) { "protected_content {\n" " content_protection_entry {\n" " uuid: '00010203-0405-0607-0809-0a0b0c0d0e0f'\n" - " pssh: '" + std::string(kExpectedDefaultPsshBox) + "'\n" + " pssh: '" + + std::string(kExpectedDefaultPsshBox) + + "'\n" " }\n" " default_key_id: '_default_key_id_'\n" " protection_scheme: 'cenc'\n" @@ -203,7 +210,7 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, CheckPixelWidthAndHeightSet) { FireOnMediaEndWithParams(media_end_param); const char kExpectedProtobufOutput[] = - "bandwidth: 7620\n" + "bandwidth: 0\n" "video_info {\n" " codec: 'avc1.010101'\n" " width: 720\n" @@ -227,5 +234,46 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, CheckPixelWidthAndHeightSet) { ASSERT_NO_FATAL_FAILURE(ExpectTempFileToEqual(kExpectedProtobufOutput)); } +TEST_F(VodMediaInfoDumpMuxerListenerTest, CheckBandwidth) { + VideoStreamInfoParameters params = GetDefaultVideoStreamInfoParams(); + + std::shared_ptr stream_info = CreateVideoStreamInfo(params); + FireOnMediaStartWithDefaultMuxerOptions(*stream_info, !kEnableEncryption); + + OnNewSegmentParameters new_segment_param; + new_segment_param.segment_file_size = 100; + new_segment_param.duration = 1000; + FireOnNewSegmentWithParams(new_segment_param); + new_segment_param.segment_file_size = 200; + FireOnNewSegmentWithParams(new_segment_param); + + OnMediaEndParameters media_end_param = GetDefaultOnMediaEndParams(); + FireOnMediaEndWithParams(media_end_param); + + const char kExpectedProtobufOutput[] = + "bandwidth: 1600\n" + "video_info {\n" + " codec: 'avc1.010101'\n" + " width: 720\n" + " height: 480\n" + " time_scale: 10\n" + " pixel_width: 1\n" + " pixel_height: 1\n" + "}\n" + "init_range {\n" + " begin: 0\n" + " end: 120\n" + "}\n" + "index_range {\n" + " begin: 121\n" + " end: 221\n" + "}\n" + "reference_time_scale: 1000\n" + "container_type: 1\n" + "media_file_name: 'test_output_file_name.mp4'\n" + "media_duration_seconds: 10.5\n"; + ASSERT_NO_FATAL_FAILURE(ExpectTempFileToEqual(kExpectedProtobufOutput)); +} + } // namespace media } // namespace shaka diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 3f0410be29..c33c89b79d 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -160,17 +160,6 @@ TEST_F(OnDemandMpdBuilderTest, VideoAndAudio) { EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputAudio1AndVideo1)); } -// Static profile requires bandwidth to be set because it has no other way to -// get the bandwidth for the Representation. -TEST_F(OnDemandMpdBuilderTest, MediaInfoMissingBandwidth) { - MediaInfo video_media_info = GetTestMediaInfo(kFileNameVideoMediaInfo1); - video_media_info.clear_bandwidth(); - AddRepresentation(video_media_info); - - std::string mpd_doc; - ASSERT_FALSE(mpd_.ToString(&mpd_doc)); -} - TEST_F(OnDemandMpdBuilderTest, CheckXmlTest) { const double kPeriod1StartTimeSeconds = 0.0; diff --git a/packager/mpd/base/representation.cc b/packager/mpd/base/representation.cc index 4680d063f9..716f1667bb 100644 --- a/packager/mpd/base/representation.cc +++ b/packager/mpd/base/representation.cc @@ -341,16 +341,6 @@ bool Representation::HasRequiredMediaInfoFields() const { return false; } - if (HasVODOnlyFields(media_info_) && !media_info_.has_bandwidth()) { - LOG(ERROR) << "Missing 'bandwidth' field. MediaInfo requires bandwidth for " - "static profile for generating a valid MPD."; - return false; - } - - VLOG_IF(3, HasLiveOnlyFields(media_info_) && !media_info_.has_bandwidth()) - << "MediaInfo missing field 'bandwidth'. Using estimated from " - "segment size."; - return true; }