diff options
author | strobe@google.com <strobe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 00:09:31 +0000 |
---|---|---|
committer | strobe@google.com <strobe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 00:09:31 +0000 |
commit | d4ede5f837d13d0676c13084b068fb1f1cfdbd01 (patch) | |
tree | fed57805c0f7dcbcc6ddb5849fe7b86cc3560098 /media | |
parent | d072832fc455c1c614147731aafde6c5786c72b8 (diff) | |
download | chromium_src-d4ede5f837d13d0676c13084b068fb1f1cfdbd01.zip chromium_src-d4ede5f837d13d0676c13084b068fb1f1cfdbd01.tar.gz chromium_src-d4ede5f837d13d0676c13084b068fb1f1cfdbd01.tar.bz2 |
Temporary fix to allow ISO BMFF quality switching in Media Source.
BUG=122913
TEST=MP4StreamParserTest
Review URL: https://chromiumcodereview.appspot.com/10656022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/mp4/mp4_stream_parser.cc | 16 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser.h | 1 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser_unittest.cc | 25 |
3 files changed, 34 insertions, 8 deletions
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc index 2e20c5c..4996905 100644 --- a/media/mp4/mp4_stream_parser.cc +++ b/media/mp4/mp4_stream_parser.cc @@ -5,6 +5,7 @@ #include "media/mp4/mp4_stream_parser.h" #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/logging.h" #include "base/time.h" #include "media/base/audio_decoder_config.h" @@ -25,7 +26,6 @@ MP4StreamParser::MP4StreamParser() has_video_(false), audio_track_id_(0), video_track_id_(0), - parameter_sets_inserted_(false), size_of_nalu_length_(0) { } @@ -141,7 +141,6 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { has_audio_ = false; has_video_ = false; - parameter_sets_inserted_ = false; AudioDecoderConfig audio_config; VideoDecoderConfig video_config; @@ -197,7 +196,12 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { } } - RCHECK(config_cb_.Run(audio_config, video_config)); + // TODO(strobe): For now, we avoid sending new configs on a new + // reinitialization segment, and instead simply embed the updated parameter + // sets into the video stream. The conditional should be removed when + // http://crbug.com/122913 is fixed. + if (!init_cb_.is_null()) + RCHECK(config_cb_.Run(audio_config, video_config)); base::TimeDelta duration; if (moov_->extends.header.fragment_duration > 0) { @@ -210,7 +214,8 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { duration = kInfiniteDuration(); } - init_cb_.Run(true, duration); + if (!init_cb_.is_null()) + base::ResetAndReturn(&init_cb_).Run(true, duration); return true; } @@ -272,7 +277,7 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, std::vector<uint8> frame_buf(buf, buf + runs_.size()); if (video) { RCHECK(AVC::ConvertToAnnexB(size_of_nalu_length_, &frame_buf)); - if (!parameter_sets_inserted_) { + if (runs_.is_keyframe()) { const AVCDecoderConfigurationRecord* avc_config = NULL; for (size_t t = 0; t < moov_->tracks.size(); t++) { if (moov_->tracks[t].header.track_id == runs_.track_id()) { @@ -283,7 +288,6 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, } RCHECK(avc_config != NULL); RCHECK(AVC::InsertParameterSets(*avc_config, &frame_buf)); - parameter_sets_inserted_ = true; } } diff --git a/media/mp4/mp4_stream_parser.h b/media/mp4/mp4_stream_parser.h index df767b3..7d9be27 100644 --- a/media/mp4/mp4_stream_parser.h +++ b/media/mp4/mp4_stream_parser.h @@ -84,7 +84,6 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { bool has_video_; uint32 audio_track_id_; uint32 video_track_id_; - bool parameter_sets_inserted_; // We keep this around to avoid having to go digging through the moov with // every frame. diff --git a/media/mp4/mp4_stream_parser_unittest.cc b/media/mp4/mp4_stream_parser_unittest.cc index 9b6a923..f5be02af 100644 --- a/media/mp4/mp4_stream_parser_unittest.cc +++ b/media/mp4/mp4_stream_parser_unittest.cc @@ -26,11 +26,15 @@ namespace mp4 { class MP4StreamParserTest : public testing::Test { public: - MP4StreamParserTest() : parser_(new MP4StreamParser) {} + MP4StreamParserTest() + : parser_(new MP4StreamParser), + got_configs_(false) { + } protected: scoped_ptr<MP4StreamParser> parser_; base::TimeDelta segment_start_; + bool got_configs_; bool AppendData(const uint8* data, size_t length) { parser_->Parse(data, length); @@ -63,6 +67,12 @@ class MP4StreamParserTest : public testing::Test { const VideoDecoderConfig& vc) { DVLOG(1) << "NewConfigF: audio=" << ac.IsValidConfig() << ", video=" << vc.IsValidConfig(); + + // TODO(strobe): Until http://crbug.com/122913 is fixed, we want to make + // sure that this callback isn't called more than once per stream. Remove + // when that bug is fixed. + EXPECT_FALSE(got_configs_); + got_configs_ = true; return true; } @@ -117,5 +127,18 @@ TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) { ParseMP4File("bear.1280x720_dash.mp4", 768432); } +TEST_F(MP4StreamParserTest, TestReinitialization) { + InitializeParser(); + + scoped_refptr<DecoderBuffer> buffer = + ReadTestDataFile("bear.1280x720_dash.mp4"); + EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), + buffer->GetDataSize(), + 512)); + EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), + buffer->GetDataSize(), + 512)); +} + } // namespace mp4 } // namespace media |