diff options
author | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:39:00 +0000 |
---|---|---|
committer | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:39:00 +0000 |
commit | 2096a3454d28bb1b67233713a6434657a9781cb2 (patch) | |
tree | f8cdd51a3e8ad259968eb317020629eb569f94aa /media/formats | |
parent | 22a74fef5947336f7f7845d95601bc40954d99d8 (diff) | |
download | chromium_src-2096a3454d28bb1b67233713a6434657a9781cb2.zip chromium_src-2096a3454d28bb1b67233713a6434657a9781cb2.tar.gz chromium_src-2096a3454d28bb1b67233713a6434657a9781cb2.tar.bz2 |
Allow StreamParsers to request automatic timestampOffset updates.
Extends StreamParser::InitCB with a new parameter which indicates
that SourceState::OnNewBuffers() should update the timestampOffset
based on the earliest end time of returned buffers (accounting for
any current appendWindow).
To prevent doubling of the timestamps in conjuction with the update
to timestampOffset, the MPEGStreamParserBase now resets the timestamp
helper after each SendBuffers() call.
Also adds missing pipeline integration tests for ADTS.
BUG=353307
TEST=existing tests pass. Post mp3 append, timestampOffset is updated.
Review URL: https://codereview.chromium.org/195973006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/formats')
-rw-r--r-- | media/formats/common/stream_parser_test_base.cc | 8 | ||||
-rw-r--r-- | media/formats/common/stream_parser_test_base.h | 4 | ||||
-rw-r--r-- | media/formats/mp2t/mp2t_stream_parser.cc | 2 | ||||
-rw-r--r-- | media/formats/mp2t/mp2t_stream_parser_unittest.cc | 7 | ||||
-rw-r--r-- | media/formats/mp4/mp4_stream_parser.cc | 2 | ||||
-rw-r--r-- | media/formats/mp4/mp4_stream_parser_unittest.cc | 8 | ||||
-rw-r--r-- | media/formats/mpeg/adts_stream_parser_unittest.cc | 32 | ||||
-rw-r--r-- | media/formats/mpeg/mp3_stream_parser_unittest.cc | 32 | ||||
-rw-r--r-- | media/formats/mpeg/mpeg_audio_stream_parser_base.cc | 3 | ||||
-rw-r--r-- | media/formats/webm/webm_stream_parser.cc | 7 |
10 files changed, 58 insertions, 47 deletions
diff --git a/media/formats/common/stream_parser_test_base.cc b/media/formats/common/stream_parser_test_base.cc index 40d39d6..abe7cf9 100644 --- a/media/formats/common/stream_parser_test_base.cc +++ b/media/formats/common/stream_parser_test_base.cc @@ -70,9 +70,13 @@ bool StreamParserTestBase::AppendDataInPieces(const uint8* data, return true; } -void StreamParserTestBase::OnInitDone(bool success, base::TimeDelta duration) { +void StreamParserTestBase::OnInitDone(bool success, + base::TimeDelta duration, + bool auto_update_timestamp_offset) { + EXPECT_TRUE(auto_update_timestamp_offset); DVLOG(1) << __FUNCTION__ << "(" << success << ", " - << duration.InMilliseconds() << ")"; + << duration.InMilliseconds() << ", " << auto_update_timestamp_offset + << ")"; } bool StreamParserTestBase::OnNewConfig( diff --git a/media/formats/common/stream_parser_test_base.h b/media/formats/common/stream_parser_test_base.h index a3385ff..780f665 100644 --- a/media/formats/common/stream_parser_test_base.h +++ b/media/formats/common/stream_parser_test_base.h @@ -43,7 +43,9 @@ class StreamParserTestBase { void InitializeParser(); bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size); - void OnInitDone(bool success, base::TimeDelta duration); + void OnInitDone(bool success, + base::TimeDelta duration, + bool auto_update_timestamp_offset); bool OnNewConfig(const AudioDecoderConfig& audio_config, const VideoDecoderConfig& video_config, const StreamParser::TextTrackConfigMap& text_config); diff --git a/media/formats/mp2t/mp2t_stream_parser.cc b/media/formats/mp2t/mp2t_stream_parser.cc index 66bdf4f..a22af1a 100644 --- a/media/formats/mp2t/mp2t_stream_parser.cc +++ b/media/formats/mp2t/mp2t_stream_parser.cc @@ -484,7 +484,7 @@ bool Mp2tStreamParser::FinishInitializationIfNeeded() { // For Mpeg2 TS, the duration is not known. DVLOG(1) << "Mpeg2TS stream parser initialization done"; - init_cb_.Run(true, kInfiniteDuration()); + init_cb_.Run(true, kInfiniteDuration(), false); is_initialized_ = true; return true; diff --git a/media/formats/mp2t/mp2t_stream_parser_unittest.cc b/media/formats/mp2t/mp2t_stream_parser_unittest.cc index 02370f2..ea79674 100644 --- a/media/formats/mp2t/mp2t_stream_parser_unittest.cc +++ b/media/formats/mp2t/mp2t_stream_parser_unittest.cc @@ -57,9 +57,12 @@ class Mp2tStreamParserTest : public testing::Test { return true; } - void OnInit(bool init_ok, base::TimeDelta duration) { + void OnInit(bool init_ok, + base::TimeDelta duration, + bool auto_update_timestamp_offset) { DVLOG(1) << "OnInit: ok=" << init_ok - << ", dur=" << duration.InMilliseconds(); + << ", dur=" << duration.InMilliseconds() + << ", autoTimestampOffset=" << auto_update_timestamp_offset; } bool OnNewConfig(const AudioDecoderConfig& ac, diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc index 809bd82..2fac274 100644 --- a/media/formats/mp4/mp4_stream_parser.cc +++ b/media/formats/mp4/mp4_stream_parser.cc @@ -301,7 +301,7 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { } if (!init_cb_.is_null()) - base::ResetAndReturn(&init_cb_).Run(true, duration); + base::ResetAndReturn(&init_cb_).Run(true, duration, false); EmitNeedKeyIfNecessary(moov_->pssh); return true; diff --git a/media/formats/mp4/mp4_stream_parser_unittest.cc b/media/formats/mp4/mp4_stream_parser_unittest.cc index f86a5b0..226943e 100644 --- a/media/formats/mp4/mp4_stream_parser_unittest.cc +++ b/media/formats/mp4/mp4_stream_parser_unittest.cc @@ -58,9 +58,11 @@ class MP4StreamParserTest : public testing::Test { return true; } - void InitF(bool init_ok, base::TimeDelta duration) { - DVLOG(1) << "InitF: ok=" << init_ok - << ", dur=" << duration.InMilliseconds(); + void InitF(bool init_ok, + base::TimeDelta duration, + bool auto_update_timestamp_offset) { + DVLOG(1) << "InitF: ok=" << init_ok << ", dur=" << duration.InMilliseconds() + << ", autoTimestampOffset=" << auto_update_timestamp_offset; } bool NewConfigF(const AudioDecoderConfig& ac, diff --git a/media/formats/mpeg/adts_stream_parser_unittest.cc b/media/formats/mpeg/adts_stream_parser_unittest.cc index d0bedbe..b9eb0d9 100644 --- a/media/formats/mpeg/adts_stream_parser_unittest.cc +++ b/media/formats/mpeg/adts_stream_parser_unittest.cc @@ -22,21 +22,21 @@ TEST_F(ADTSStreamParserTest, UnalignedAppend) { const std::string expected = "NewSegment" "{ 0K }" - "{ 23K }" - "{ 46K }" - "{ 69K }" - "{ 92K }" - "{ 116K }" - "{ 139K }" - "{ 162K }" - "{ 185K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" "EndOfSegment" "NewSegment" - "{ 208K }" - "{ 232K }" - "{ 255K }" - "{ 278K }" - "{ 301K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" "EndOfSegment"; EXPECT_EQ(expected, ParseFile("sfx.adts", 17)); } @@ -47,11 +47,11 @@ TEST_F(ADTSStreamParserTest, UnalignedAppend512) { const std::string expected = "NewSegment" "{ 0K 23K 46K }" - "{ 69K 92K 116K 139K 162K }" - "{ 185K 208K 232K 255K 278K }" + "{ 0K 23K 46K 69K 92K }" + "{ 0K 23K 46K 69K 92K }" "EndOfSegment" "NewSegment" - "{ 301K }" + "{ 0K }" "EndOfSegment"; EXPECT_EQ(expected, ParseFile("sfx.adts", 512)); } diff --git a/media/formats/mpeg/mp3_stream_parser_unittest.cc b/media/formats/mpeg/mp3_stream_parser_unittest.cc index eefadc5..85cc129 100644 --- a/media/formats/mpeg/mp3_stream_parser_unittest.cc +++ b/media/formats/mpeg/mp3_stream_parser_unittest.cc @@ -22,22 +22,22 @@ TEST_F(MP3StreamParserTest, UnalignedAppend) { const std::string expected = "NewSegment" "{ 0K }" - "{ 26K }" - "{ 52K }" - "{ 78K }" - "{ 104K }" - "{ 130K }" - "{ 156K }" - "{ 182K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" "EndOfSegment" "NewSegment" - "{ 208K }" - "{ 235K }" - "{ 261K }" + "{ 0K }" + "{ 0K }" + "{ 0K }" "EndOfSegment" "NewSegment" - "{ 287K }" - "{ 313K }" + "{ 0K }" + "{ 0K }" "EndOfSegment"; EXPECT_EQ(expected, ParseFile("sfx.mp3", 17)); } @@ -48,12 +48,12 @@ TEST_F(MP3StreamParserTest, UnalignedAppend512) { const std::string expected = "NewSegment" "{ 0K }" - "{ 26K 52K 78K 104K }" + "{ 0K 26K 52K 78K }" "EndOfSegment" "NewSegment" - "{ 130K 156K 182K }" - "{ 208K 235K 261K 287K }" - "{ 313K }" + "{ 0K 26K 52K }" + "{ 0K 26K 52K 78K }" + "{ 0K }" "EndOfSegment"; EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); } diff --git a/media/formats/mpeg/mpeg_audio_stream_parser_base.cc b/media/formats/mpeg/mpeg_audio_stream_parser_base.cc index ba3cbd9..aaf6a50 100644 --- a/media/formats/mpeg/mpeg_audio_stream_parser_base.cc +++ b/media/formats/mpeg/mpeg_audio_stream_parser_base.cc @@ -208,7 +208,7 @@ int MPEGAudioStreamParserBase::ParseFrame(const uint8* data, bool success = config_cb_.Run(config_, video_config, TextTrackConfigMap()); if (!init_cb_.is_null()) - base::ResetAndReturn(&init_cb_).Run(success, kInfiniteDuration()); + base::ResetAndReturn(&init_cb_).Run(success, kInfiniteDuration(), true); if (!success) return -1; @@ -393,6 +393,7 @@ bool MPEGAudioStreamParserBase::SendBuffers(BufferQueue* buffers, end_of_segment_cb_.Run(); } + timestamp_helper_->SetBaseTimestamp(base::TimeDelta()); return true; } diff --git a/media/formats/webm/webm_stream_parser.cc b/media/formats/webm/webm_stream_parser.cc index fcb55de..eae0371 100644 --- a/media/formats/webm/webm_stream_parser.cc +++ b/media/formats/webm/webm_stream_parser.cc @@ -7,6 +7,7 @@ #include <string> #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/logging.h" #include "media/formats/webm/webm_cluster_parser.h" #include "media/formats/webm/webm_constants.h" @@ -214,10 +215,8 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) { ChangeState(kParsingClusters); - if (!init_cb_.is_null()) { - init_cb_.Run(true, duration); - init_cb_.Reset(); - } + if (!init_cb_.is_null()) + base::ResetAndReturn(&init_cb_).Run(true, duration, false); return bytes_parsed; } |