diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:16:58 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:16:58 +0000 |
commit | 950c3b3d1d0cb93b6ddcea6aaf9646b8842a5506 (patch) | |
tree | b7be9df58fb83a5fa54bab684de8379999ab3491 /media/mp4 | |
parent | 3b693bdd1be9f78da6806fe58ea2aca4ee6f8fb8 (diff) | |
download | chromium_src-950c3b3d1d0cb93b6ddcea6aaf9646b8842a5506.zip chromium_src-950c3b3d1d0cb93b6ddcea6aaf9646b8842a5506.tar.gz chromium_src-950c3b3d1d0cb93b6ddcea6aaf9646b8842a5506.tar.bz2 |
Chrome-side implementation of media source timestamp offset
Adds functionality to signal an offset to be applied to the
buffers in ChunkDemuxer. Is not triggerable from Chrome yet.
BUG=139044
TEST=media_unittests
Review URL: https://chromiumcodereview.appspot.com/10803019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/mp4')
-rw-r--r-- | media/mp4/mp4_stream_parser.cc | 13 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser.h | 4 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser_unittest.cc | 8 |
3 files changed, 20 insertions, 5 deletions
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc index 757ea503..9d51959 100644 --- a/media/mp4/mp4_stream_parser.cc +++ b/media/mp4/mp4_stream_parser.cc @@ -37,13 +37,15 @@ void MP4StreamParser::Init(const InitCB& init_cb, const NewBuffersCB& audio_cb, const NewBuffersCB& video_cb, const NeedKeyCB& need_key_cb, - const NewMediaSegmentCB& new_segment_cb) { + const NewMediaSegmentCB& new_segment_cb, + const base::Closure& end_of_segment_cb) { DCHECK_EQ(state_, kWaitingForInit); DCHECK(init_cb_.is_null()); DCHECK(!init_cb.is_null()); DCHECK(!config_cb.is_null()); DCHECK(!audio_cb.is_null() || !video_cb.is_null()); DCHECK(!need_key_cb.is_null()); + DCHECK(!end_of_segment_cb.is_null()); ChangeState(kParsingBoxes); init_cb_ = init_cb; @@ -52,6 +54,7 @@ void MP4StreamParser::Init(const InitCB& init_cb, video_cb_ = video_cb; need_key_cb_ = need_key_cb; new_segment_cb_ = new_segment_cb; + end_of_segment_cb_ = end_of_segment_cb; } void MP4StreamParser::Flush() { @@ -316,8 +319,11 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, // Flush any buffers we've gotten in this chunk so that buffers don't // cross NewSegment() calls *err = !SendAndFlushSamples(audio_buffers, video_buffers); - if (*err) return false; + if (*err) + return false; + ChangeState(kParsingBoxes); + end_of_segment_cb_.Run(); return true; } @@ -337,7 +343,8 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, bool video = has_video_ && video_track_id_ == runs_->track_id(); // Skip this entire track if it's not one we're interested in - if (!audio && !video) runs_->AdvanceRun(); + if (!audio && !video) + runs_->AdvanceRun(); // Attempt to cache the auxiliary information first. Aux info is usually // placed in a contiguous block before the sample data, rather than being diff --git a/media/mp4/mp4_stream_parser.h b/media/mp4/mp4_stream_parser.h index 53100a95..b950af2 100644 --- a/media/mp4/mp4_stream_parser.h +++ b/media/mp4/mp4_stream_parser.h @@ -31,7 +31,8 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { const NewBuffersCB& audio_cb, const NewBuffersCB& video_cb, const NeedKeyCB& need_key_cb, - const NewMediaSegmentCB& new_segment_cb) OVERRIDE; + const NewMediaSegmentCB& new_segment_cb, + const base::Closure& end_of_segment_cb) OVERRIDE; virtual void Flush() OVERRIDE; virtual bool Parse(const uint8* buf, int size) OVERRIDE; @@ -70,6 +71,7 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { NewBuffersCB video_cb_; NeedKeyCB need_key_cb_; NewMediaSegmentCB new_segment_cb_; + base::Closure end_of_segment_cb_; OffsetByteQueue queue_; diff --git a/media/mp4/mp4_stream_parser_unittest.cc b/media/mp4/mp4_stream_parser_unittest.cc index 63e1382..56f40df 100644 --- a/media/mp4/mp4_stream_parser_unittest.cc +++ b/media/mp4/mp4_stream_parser_unittest.cc @@ -93,6 +93,10 @@ class MP4StreamParserTest : public testing::Test { segment_start_ = start_dts; } + void EndOfSegmentF() { + DVLOG(1) << "EndOfSegmentF()"; + } + void InitializeParser() { parser_->Init( base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), @@ -100,7 +104,9 @@ class MP4StreamParserTest : public testing::Test { base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), - base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this))); + base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), + base::Bind(&MP4StreamParserTest::EndOfSegmentF, + base::Unretained(this))); } bool ParseMP4File(const std::string& filename, int append_bytes) { |