From b93f2020c8fc08cf7acb25c10e9c63944a13d53e Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Wed, 12 Feb 2014 16:35:05 -0800 Subject: [PATCH] Fix no ContentProtection element problem. The original code used stream_info.is_encrypted() to check whether output stream is encrypted; However, stream_info contains input stream information and does not contain output stream infomation, which results in incorrect status was passed to mpd generator. Fix the problem with correct information from muxer. Change on behalf of rkuroiwa after a discussion with him. Bug: 12994813 Change-Id: I6e74b378a0fd7deedaaac166e913a66d312b8318 --- app/mpd_generator.cc | 2 +- media/event/muxer_listener.h | 3 ++- media/event/vod_media_info_dump_muxer_listener.cc | 5 +++-- media/event/vod_media_info_dump_muxer_listener.h | 4 +++- media/event/vod_media_info_dump_muxer_listener_unittest.cc | 4 +++- media/event/vod_mpd_notify_muxer_listener.cc | 3 ++- media/event/vod_mpd_notify_muxer_listener.h | 3 ++- media/mp4/mp4_muxer.cc | 3 ++- 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/mpd_generator.cc b/app/mpd_generator.cc index 4a6b16c38e..5260968c8a 100644 --- a/app/mpd_generator.cc +++ b/app/mpd_generator.cc @@ -21,7 +21,7 @@ const char kUsage[] = " There will be at most 3 AdaptationSets in the MPD, i.e. 1 video, 1 " "audio, and 1 text.\n" "Sample Usage:\n" - "%s --input=\"video1.txt,video2.txt,audio1.txt\" " + "%s --input=\"video1.media_info,video2.media_info,audio1.media_info\" " "--output=\"video_audio.mpd\""; enum ExitStatus { diff --git a/media/event/muxer_listener.h b/media/event/muxer_listener.h index f8e646bfe8..dcff50d19a 100644 --- a/media/event/muxer_listener.h +++ b/media/event/muxer_listener.h @@ -61,7 +61,8 @@ class MuxerListener { uint64 index_range_start, uint64 index_range_end, float duration_seconds, - uint64 file_size) = 0; + uint64 file_size, + bool is_encrypted) = 0; // Called when a segment has been muxed and the file has been written. // Note: For video on demand (VOD), this would be for subsegments. diff --git a/media/event/vod_media_info_dump_muxer_listener.cc b/media/event/vod_media_info_dump_muxer_listener.cc index 024b3e6853..f08d0b8020 100644 --- a/media/event/vod_media_info_dump_muxer_listener.cc +++ b/media/event/vod_media_info_dump_muxer_listener.cc @@ -62,7 +62,8 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd( uint64 index_range_start, uint64 index_range_end, float duration_seconds, - uint64 file_size) { + uint64 file_size, + bool is_encrypted) { MediaInfo media_info; if (!internal::GenerateMediaInfo(muxer_options_, stream_infos, @@ -81,7 +82,7 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd( return; } - if (IsAnyStreamEncrypted(stream_infos)) { + if (is_encrypted) { if (scheme_id_uri_.empty()) { LOG(ERROR) << "The stream is encrypted but no schemeIdUri specified for " "ContentProtection."; diff --git a/media/event/vod_media_info_dump_muxer_listener.h b/media/event/vod_media_info_dump_muxer_listener.h index 35c0883f39..f8e8321f22 100644 --- a/media/event/vod_media_info_dump_muxer_listener.h +++ b/media/event/vod_media_info_dump_muxer_listener.h @@ -46,6 +46,7 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { uint32 time_scale, ContainerType container_type) OVERRIDE; + // TODO(rkuroiwa): Make an Event structure for passing parameters. virtual void OnMediaEnd(const std::vector& stream_infos, bool has_init_range, uint64 init_range_start, @@ -54,7 +55,8 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { uint64 index_range_start, uint64 index_range_end, float duration_seconds, - uint64 file_size) OVERRIDE; + uint64 file_size, + bool is_encrypted) OVERRIDE; virtual void OnNewSegment(uint64 start_time, uint64 duration, diff --git a/media/event/vod_media_info_dump_muxer_listener_unittest.cc b/media/event/vod_media_info_dump_muxer_listener_unittest.cc index 30796cc97a..7dd140342e 100644 --- a/media/event/vod_media_info_dump_muxer_listener_unittest.cc +++ b/media/event/vod_media_info_dump_muxer_listener_unittest.cc @@ -46,6 +46,7 @@ struct OnMediaEndParameters { uint64 index_range_end; float duration_seconds; uint64 file_size; + bool is_encrypted; }; scoped_refptr CreateVideoStreamInfo( @@ -185,7 +186,8 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test { params.index_range_start, params.index_range_end, params.duration_seconds, - params.file_size); + params.file_size, + params.is_encrypted); } void ExpectTempFileToEqual(const std::string& expected_protobuf) { diff --git a/media/event/vod_mpd_notify_muxer_listener.cc b/media/event/vod_mpd_notify_muxer_listener.cc index cf18e12938..39f52d1fc9 100644 --- a/media/event/vod_mpd_notify_muxer_listener.cc +++ b/media/event/vod_mpd_notify_muxer_listener.cc @@ -47,7 +47,8 @@ void VodMpdNotifyMuxerListener::OnMediaEnd( uint64 index_range_start, uint64 index_range_end, float duration_seconds, - uint64 file_size) { + uint64 file_size, + bool is_encrypted) { dash_packager::MediaInfo media_info; if (!internal::GenerateMediaInfo(muxer_options_, stream_infos, diff --git a/media/event/vod_mpd_notify_muxer_listener.h b/media/event/vod_mpd_notify_muxer_listener.h index 3928839253..0257c75b9c 100644 --- a/media/event/vod_mpd_notify_muxer_listener.h +++ b/media/event/vod_mpd_notify_muxer_listener.h @@ -43,7 +43,8 @@ class VodMpdNotifyMuxerListener : public MuxerListener { uint64 index_range_start, uint64 index_range_end, float duration_seconds, - uint64 file_size) OVERRIDE; + uint64 file_size, + bool is_encrypted) OVERRIDE; virtual void OnNewSegment(uint64 start_time, uint64 duration, diff --git a/media/mp4/mp4_muxer.cc b/media/mp4/mp4_muxer.cc index 179102a3d4..b1fe031344 100644 --- a/media/mp4/mp4_muxer.cc +++ b/media/mp4/mp4_muxer.cc @@ -325,7 +325,8 @@ void MP4Muxer::FireOnMediaEndEvent() { index_range_start, index_range_end, duration_seconds, - file_size); + file_size, + IsEncryptionRequired()); } } // namespace mp4