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/webm | |
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/webm')
-rw-r--r-- | media/webm/webm_cluster_parser.cc | 9 | ||||
-rw-r--r-- | media/webm/webm_cluster_parser.h | 4 | ||||
-rw-r--r-- | media/webm/webm_stream_parser.cc | 9 | ||||
-rw-r--r-- | media/webm/webm_stream_parser.h | 4 |
4 files changed, 22 insertions, 4 deletions
diff --git a/media/webm/webm_cluster_parser.cc b/media/webm/webm_cluster_parser.cc index 14a360d..e9ef93e 100644 --- a/media/webm/webm_cluster_parser.cc +++ b/media/webm/webm_cluster_parser.cc @@ -43,6 +43,7 @@ WebMClusterParser::WebMClusterParser(int64 timecode_scale, block_duration_(-1), cluster_timecode_(-1), cluster_start_time_(kNoTimestamp()), + cluster_ended_(false), audio_(audio_track_num), video_(video_track_num) { CHECK_GE(video_encryption_key_id_size, 0); @@ -59,6 +60,7 @@ void WebMClusterParser::Reset() { last_block_timecode_ = -1; cluster_timecode_ = -1; cluster_start_time_ = kNoTimestamp(); + cluster_ended_ = false; parser_.Reset(); audio_.Reset(); video_.Reset(); @@ -70,10 +72,13 @@ int WebMClusterParser::Parse(const uint8* buf, int size) { int result = parser_.Parse(buf, size); - if (result <= 0) + if (result <= 0) { + cluster_ended_ = false; return result; + } - if (parser_.IsParsingComplete()) { + cluster_ended_ = parser_.IsParsingComplete(); + if (cluster_ended_) { // If there were no buffers in this cluster, set the cluster start time to // be the |cluster_timecode_|. if (cluster_start_time_ == kNoTimestamp()) { diff --git a/media/webm/webm_cluster_parser.h b/media/webm/webm_cluster_parser.h index 2bdb1e7..926e6a1 100644 --- a/media/webm/webm_cluster_parser.h +++ b/media/webm/webm_cluster_parser.h @@ -44,6 +44,9 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { const BufferQueue& audio_buffers() const { return audio_.buffers(); } const BufferQueue& video_buffers() const { return video_.buffers(); } + // Returns true if the last Parse() call stopped at the end of a cluster. + bool cluster_ended() const { return cluster_ended_; } + private: // Helper class that manages per-track state. class Track { @@ -88,6 +91,7 @@ class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { int64 cluster_timecode_; base::TimeDelta cluster_start_time_; + bool cluster_ended_; Track audio_; Track video_; diff --git a/media/webm/webm_stream_parser.cc b/media/webm/webm_stream_parser.cc index e9c8233..f27f7e7 100644 --- a/media/webm/webm_stream_parser.cc +++ b/media/webm/webm_stream_parser.cc @@ -192,7 +192,8 @@ void WebMStreamParser::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()); @@ -200,6 +201,7 @@ void WebMStreamParser::Init(const InitCB& init_cb, DCHECK(!audio_cb.is_null() || !video_cb.is_null()); DCHECK(!need_key_cb.is_null()); DCHECK(!new_segment_cb.is_null()); + DCHECK(!end_of_segment_cb.is_null()); ChangeState(kParsingHeaders); init_cb_ = init_cb; @@ -208,6 +210,7 @@ void WebMStreamParser::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 WebMStreamParser::Flush() { @@ -416,6 +419,7 @@ int WebMStreamParser::ParseCluster(const uint8* data, int size) { const BufferQueue& audio_buffers = cluster_parser_->audio_buffers(); const BufferQueue& video_buffers = cluster_parser_->video_buffers(); base::TimeDelta cluster_start_time = cluster_parser_->cluster_start_time(); + bool cluster_ended = cluster_parser_->cluster_ended(); if (waiting_for_buffers_ && cluster_start_time != kNoTimestamp()) { new_segment_cb_.Run(cluster_start_time); @@ -428,6 +432,9 @@ int WebMStreamParser::ParseCluster(const uint8* data, int size) { if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) return -1; + if (cluster_ended) + end_of_segment_cb_.Run(); + return bytes_parsed; } diff --git a/media/webm/webm_stream_parser.h b/media/webm/webm_stream_parser.h index f555278..c5d06d5 100644 --- a/media/webm/webm_stream_parser.h +++ b/media/webm/webm_stream_parser.h @@ -26,7 +26,8 @@ class WebMStreamParser : 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; @@ -66,6 +67,7 @@ class WebMStreamParser : public StreamParser { NewBuffersCB video_cb_; NeedKeyCB need_key_cb_; NewMediaSegmentCB new_segment_cb_; + base::Closure end_of_segment_cb_; // True if a new cluster id has been seen, but no audio or video buffers have // been parsed yet. |