diff --git a/packager/media/base/demuxer.cc b/packager/media/base/demuxer.cc index 327eaa5ce3..104bab3799 100644 --- a/packager/media/base/demuxer.cc +++ b/packager/media/base/demuxer.cc @@ -9,7 +9,6 @@ #include "packager/base/bind.h" #include "packager/base/logging.h" #include "packager/base/stl_util.h" -#include "packager/media/base/container_names.h" #include "packager/media/base/decryptor_source.h" #include "packager/media/base/key_source.h" #include "packager/media/base/media_sample.h" @@ -33,6 +32,7 @@ Demuxer::Demuxer(const std::string& file_name) : file_name_(file_name), media_file_(NULL), init_event_received_(false), + container_name_(CONTAINER_UNKNOWN), buffer_(new uint8_t[kBufSize]), cancelled_(false) { } @@ -70,10 +70,10 @@ Status Demuxer::Initialize() { break; bytes_read += read_result; } - MediaContainerName container = DetermineContainer(buffer_.get(), bytes_read); + container_name_ = DetermineContainer(buffer_.get(), bytes_read); // Initialize media parser. - switch (container) { + switch (container_name_) { case CONTAINER_MOV: parser_.reset(new mp4::MP4MediaParser()); break; @@ -93,7 +93,7 @@ Status Demuxer::Initialize() { key_source_.get()); // Handle trailing 'moov'. - if (container == CONTAINER_MOV) + if (container_name_ == CONTAINER_MOV) static_cast(parser_.get())->LoadMoov(file_name_); if (!parser_->Parse(buffer_.get(), bytes_read)) { diff --git a/packager/media/base/demuxer.h b/packager/media/base/demuxer.h index 0a51e7e831..4012f98724 100644 --- a/packager/media/base/demuxer.h +++ b/packager/media/base/demuxer.h @@ -65,6 +65,10 @@ class Demuxer { /// through MediaStream APIs. const std::vector& streams() { return streams_; } + /// @return Container name (type). Value is CONTAINER_UNKNOWN if the demuxer + /// is not initialized. + MediaContainerName container_name() { return container_name_; } + private: // Parser event handlers. void ParserInitEvent(const std::vector >& streams); @@ -77,6 +81,7 @@ class Demuxer { Status init_parsing_status_; scoped_ptr parser_; std::vector streams_; + MediaContainerName container_name_; scoped_ptr buffer_; scoped_ptr key_source_; bool cancelled_; diff --git a/packager/media/base/video_stream_info.cc b/packager/media/base/video_stream_info.cc index 0a179f666f..1ae5c1c587 100644 --- a/packager/media/base/video_stream_info.cc +++ b/packager/media/base/video_stream_info.cc @@ -46,6 +46,7 @@ VideoStreamInfo::VideoStreamInfo(int track_id, const std::string& language, uint16_t width, uint16_t height, + int16_t trick_play_rate, uint8_t nalu_length_size, const uint8_t* extra_data, size_t extra_data_size, @@ -62,6 +63,7 @@ VideoStreamInfo::VideoStreamInfo(int track_id, codec_(codec), width_(width), height_(height), + trick_play_rate_(trick_play_rate), nalu_length_size_(nalu_length_size) { } @@ -76,11 +78,13 @@ bool VideoStreamInfo::IsValidConfig() const { std::string VideoStreamInfo::ToString() const { return base::StringPrintf( - "%s codec: %s\n width: %d\n height: %d\n nalu_length_size: %d\n", + "%s codec: %s\n width: %d\n height: %d\n trick_play_rate: %d\n" + " nalu_length_size: %d\n", StreamInfo::ToString().c_str(), VideoCodecToString(codec_).c_str(), width_, height_, + trick_play_rate_, nalu_length_size_); } diff --git a/packager/media/base/video_stream_info.h b/packager/media/base/video_stream_info.h index 4fd78f8ff7..5f63339247 100644 --- a/packager/media/base/video_stream_info.h +++ b/packager/media/base/video_stream_info.h @@ -36,6 +36,7 @@ class VideoStreamInfo : public StreamInfo { const std::string& language, uint16_t width, uint16_t height, + int16_t trick_play_rate, uint8_t nalu_length_size, const uint8_t* extra_data, size_t extra_data_size, @@ -65,6 +66,7 @@ class VideoStreamInfo : public StreamInfo { VideoCodec codec_; uint16_t width_; uint16_t height_; + int16_t trick_play_rate_; // Non-zero for trick-play streams. // Specifies the normalized size of the NAL unit length field. Can be 1, 2 or // 4 bytes, or 0 if the size if unknown or the stream is not a AVC stream 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 7f11b2c5ab..7deece19f2 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 @@ -63,6 +63,7 @@ scoped_refptr CreateVideoStreamInfo( param.language, param.width, param.height, + 0, // trick_play_rate param.nalu_length_size, vector_as_array(¶m.extra_data), param.extra_data.size(), diff --git a/packager/media/formats/mp2t/es_parser_h264.cc b/packager/media/formats/mp2t/es_parser_h264.cc index 3351e6dc04..8b0485233e 100644 --- a/packager/media/formats/mp2t/es_parser_h264.cc +++ b/packager/media/formats/mp2t/es_parser_h264.cc @@ -363,6 +363,7 @@ bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) { std::string(), width, height, + 0, H264ByteToUnitStreamConverter::kUnitStreamNaluLengthSize, decoder_config_record.data(), decoder_config_record.size(), diff --git a/packager/media/formats/mp4/mp4_media_parser.cc b/packager/media/formats/mp4/mp4_media_parser.cc index 04800b8357..2f061b2c7b 100644 --- a/packager/media/formats/mp4/mp4_media_parser.cc +++ b/packager/media/formats/mp4/mp4_media_parser.cc @@ -378,6 +378,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) { track->media.header.language, entry.width, entry.height, + 0, // trick_play_rate entry.avcc.length_size, &entry.avcc.data[0], entry.avcc.data.size(), diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index f1d4bdf423..181c9ea061 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -564,6 +564,7 @@ bool WvmMediaParser::ParseIndexEntry() { } uint64_t track_duration = 0; + int16_t trick_play_rate = 0; uint32_t sampling_frequency = kDefaultSamplingFrequency; uint32_t time_scale = kMpeg2ClockRate; uint16_t video_width = 0; @@ -668,6 +669,9 @@ bool WvmMediaParser::ParseIndexEntry() { case TrackDuration: track_duration = value; break; + case TrackTrickPlayRate: + trick_play_rate = value; + break; case VideoStreamId: video_pes_stream_id = value; break; @@ -706,7 +710,7 @@ bool WvmMediaParser::ParseIndexEntry() { stream_infos_.push_back(new VideoStreamInfo( stream_id_count_, time_scale, track_duration, video_codec, video_codec_string, std::string(), video_width, video_height, - nalu_length_size, NULL, 0, true)); + trick_play_rate, nalu_length_size, NULL, 0, true)); program_demux_stream_map_[base::UintToString(index_program_id_) + ":" + base::UintToString(video_pes_stream_id)] = stream_id_count_++;