Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: media/filters/chunk_demuxer.cc

Issue 10879056: Support setting an explicit duration on MediaSource objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: response to CR Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/source_buffer_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void StartWaitingForSeek(); 174 void StartWaitingForSeek();
175 void Seek(TimeDelta time); 175 void Seek(TimeDelta time);
176 void CancelPendingSeek(); 176 void CancelPendingSeek();
177 bool IsSeekPending() const; 177 bool IsSeekPending() const;
178 178
179 // Add buffers to this stream. Buffers are stored in SourceBufferStreams, 179 // Add buffers to this stream. Buffers are stored in SourceBufferStreams,
180 // which handle ordering and overlap resolution. 180 // which handle ordering and overlap resolution.
181 // Returns true if buffers were successfully added. 181 // Returns true if buffers were successfully added.
182 bool Append(const StreamParser::BufferQueue& buffers); 182 bool Append(const StreamParser::BufferQueue& buffers);
183 183
184 // Signal to the stream that duration has changed to |duration|.
185 void OnSetDuration(base::TimeDelta duration);
186
184 // Returns the range of buffered data in this stream, capped at |duration|. 187 // Returns the range of buffered data in this stream, capped at |duration|.
185 Ranges<TimeDelta> GetBufferedRanges(base::TimeDelta duration) const; 188 Ranges<TimeDelta> GetBufferedRanges(base::TimeDelta duration) const;
186 189
187 // Signal to the stream that buffers handed in through subsequent calls to 190 // Signal to the stream that buffers handed in through subsequent calls to
188 // Append() belong to a media segment that starts at |start_timestamp|. 191 // Append() belong to a media segment that starts at |start_timestamp|.
189 void OnNewMediaSegment(TimeDelta start_timestamp); 192 void OnNewMediaSegment(TimeDelta start_timestamp);
190 193
191 // Called when mid-stream config updates occur. 194 // Called when mid-stream config updates occur.
192 // Returns true if the new config is accepted. 195 // Returns true if the new config is accepted.
193 // Returns false if the new config should trigger an error. 196 // Returns false if the new config should trigger an error.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 331 }
329 CreateReadDoneClosures_Locked(&closures); 332 CreateReadDoneClosures_Locked(&closures);
330 } 333 }
331 334
332 for (ClosureQueue::iterator it = closures.begin(); it != closures.end(); ++it) 335 for (ClosureQueue::iterator it = closures.begin(); it != closures.end(); ++it)
333 it->Run(); 336 it->Run();
334 337
335 return true; 338 return true;
336 } 339 }
337 340
341 void ChunkDemuxerStream::OnSetDuration(base::TimeDelta duration) {
342 base::AutoLock auto_lock(lock_);
343 stream_->OnSetDuration(duration);
344 }
345
338 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( 346 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges(
339 base::TimeDelta duration) const { 347 base::TimeDelta duration) const {
340 base::AutoLock auto_lock(lock_); 348 base::AutoLock auto_lock(lock_);
341 Ranges<TimeDelta> range = stream_->GetBufferedTime(); 349 Ranges<TimeDelta> range = stream_->GetBufferedTime();
342 350
343 if (range.size() == 0u) 351 if (range.size() == 0u)
344 return range; 352 return range;
345 353
346 // Clamp the end of the stream's buffered ranges to fit within the duration. 354 // Clamp the end of the stream's buffered ranges to fit within the duration.
347 // This can be done by intersecting the stream's range with the valid time 355 // This can be done by intersecting the stream's range with the valid time
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 825 }
818 826
819 void ChunkDemuxer::Abort(const std::string& id) { 827 void ChunkDemuxer::Abort(const std::string& id) {
820 DVLOG(1) << "Abort(" << id << ")"; 828 DVLOG(1) << "Abort(" << id << ")";
821 DCHECK(!id.empty()); 829 DCHECK(!id.empty());
822 CHECK(IsValidId(id)); 830 CHECK(IsValidId(id));
823 831
824 stream_parser_map_[id]->Flush(); 832 stream_parser_map_[id]->Flush();
825 } 833 }
826 834
835 void ChunkDemuxer::SetDuration(base::TimeDelta duration) {
836 DVLOG(1) << "SetDuration(" << duration.InSecondsF() << ")";
837
838 if (duration == duration_)
839 return;
840
841 UpdateDuration(duration);
842
843 if (audio_)
844 audio_->OnSetDuration(duration);
845
846 if (video_)
847 video_->OnSetDuration(duration);
848 }
849
827 bool ChunkDemuxer::SetTimestampOffset(const std::string& id, TimeDelta offset) { 850 bool ChunkDemuxer::SetTimestampOffset(const std::string& id, TimeDelta offset) {
828 DVLOG(1) << "SetTimestampOffset(" << id << ", " << offset.InSecondsF() << ")"; 851 DVLOG(1) << "SetTimestampOffset(" << id << ", " << offset.InSecondsF() << ")";
829 CHECK(IsValidId(id)); 852 CHECK(IsValidId(id));
830 853
831 if (!source_info_map_[id].can_update_offset) 854 if (!source_info_map_[id].can_update_offset)
832 return false; 855 return false;
833 856
834 source_info_map_[id].timestamp_offset = offset; 857 source_info_map_[id].timestamp_offset = offset;
835 return true; 858 return true;
836 } 859 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1179
1157 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { 1180 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const {
1158 if (audio_ && !video_) 1181 if (audio_ && !video_)
1159 return audio_->GetBufferedRanges(duration_); 1182 return audio_->GetBufferedRanges(duration_);
1160 else if (!audio_ && video_) 1183 else if (!audio_ && video_)
1161 return video_->GetBufferedRanges(duration_); 1184 return video_->GetBufferedRanges(duration_);
1162 return ComputeIntersection(); 1185 return ComputeIntersection();
1163 } 1186 }
1164 1187
1165 } // namespace media 1188 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/source_buffer_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698