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

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

Issue 178153004: Enable round-tripping and updating of WebSourceBufferImpl timestamp offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address PS3 comments Created 6 years, 10 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/chunk_demuxer_unittest.cc » ('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 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // error occurred. 111 // error occurred.
112 bool Append(const uint8* data, size_t length); 112 bool Append(const uint8* data, size_t length);
113 113
114 // Aborts the current append sequence and resets the parser. 114 // Aborts the current append sequence and resets the parser.
115 void Abort(); 115 void Abort();
116 116
117 // Calls Remove(|start|, |end|, |duration|) on all 117 // Calls Remove(|start|, |end|, |duration|) on all
118 // ChunkDemuxerStreams managed by this object. 118 // ChunkDemuxerStreams managed by this object.
119 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); 119 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration);
120 120
121 // Sets |timestamp_offset_| if possible. 121 // Sets user-specified |timestamp_offset_| if possible.
122 // Returns if the offset was set. Returns false if the offset could not be 122 // Returns true if the offset was set. Returns false if the offset could not
123 // updated at this time. 123 // be set at this time.
124 bool SetTimestampOffset(TimeDelta timestamp_offset); 124 bool SetTimestampOffset(TimeDelta timestamp_offset);
125 125
126 // Gets the updated timestamp offset or indication that it has not been
127 // updated.
128 // If |using_user_specified_timestamp_offset_| is true, meaning
acolwell GONE FROM CHROMIUM 2014/02/25 21:50:41 nit: I wonder if the name should be something like
wolenetz 2014/02/25 22:56:29 Done. That does make more sense :)
129 // |timestamp_offset_| was most recently set by SetTimestampOffset() or
130 // this SourceState's construction, returns kNoTimestamp().
131 // Otherwise, returns the updated |timestamp_offset_| resulting from
132 // operations like "sequence" mode Append() coded frame processing.
133 TimeDelta GetUpdatedTimestampOffset() const;
134
126 // Sets |sequence_mode_| to |sequence_mode| if possible. 135 // Sets |sequence_mode_| to |sequence_mode| if possible.
127 // Returns true if the mode update was allowed. Returns false if the mode 136 // Returns true if the mode update was allowed. Returns false if the mode
128 // could not be updated at this time. 137 // could not be updated at this time.
129 bool SetSequenceMode(bool sequence_mode); 138 bool SetSequenceMode(bool sequence_mode);
130 139
131 TimeDelta timestamp_offset() const { return timestamp_offset_; }
132
133 void set_append_window_start(TimeDelta start) { 140 void set_append_window_start(TimeDelta start) {
134 append_window_start_ = start; 141 append_window_start_ = start;
135 } 142 }
136 void set_append_window_end(TimeDelta end) { append_window_end_ = end; } 143 void set_append_window_end(TimeDelta end) { append_window_end_ = end; }
137 144
138 // Returns the range of buffered data in this source, capped at |duration|. 145 // Returns the range of buffered data in this source, capped at |duration|.
139 // |ended| - Set to true if end of stream has been signalled and the special 146 // |ended| - Set to true if end of stream has been signalled and the special
140 // end of stream range logic needs to be executed. 147 // end of stream range logic needs to be executed.
141 Ranges<TimeDelta> GetBufferedRanges(TimeDelta duration, bool ended) const; 148 Ranges<TimeDelta> GetBufferedRanges(TimeDelta duration, bool ended) const;
142 149
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool* needs_keyframe, 224 bool* needs_keyframe,
218 StreamParser::BufferQueue* filtered_buffers); 225 StreamParser::BufferQueue* filtered_buffers);
219 226
220 CreateDemuxerStreamCB create_demuxer_stream_cb_; 227 CreateDemuxerStreamCB create_demuxer_stream_cb_;
221 IncreaseDurationCB increase_duration_cb_; 228 IncreaseDurationCB increase_duration_cb_;
222 NewTextTrackCB new_text_track_cb_; 229 NewTextTrackCB new_text_track_cb_;
223 230
224 // The offset to apply to media segment timestamps. 231 // The offset to apply to media segment timestamps.
225 TimeDelta timestamp_offset_; 232 TimeDelta timestamp_offset_;
226 233
234 // Flag that is true only if |timestamp_offset_| was most recently set by
235 // SetTimestampOffset() or this SourceState's construction.
236 bool using_user_specified_timestamp_offset_;
237
227 // Tracks the mode by which appended media is processed. If true, then 238 // Tracks the mode by which appended media is processed. If true, then
228 // appended media is processed using "sequence" mode. Otherwise, appended 239 // appended media is processed using "sequence" mode. Otherwise, appended
229 // media is processed using "segments" mode. 240 // media is processed using "segments" mode.
230 // TODO(wolenetz): Enable "sequence" mode logic. See http://crbug.com/249422 241 // TODO(wolenetz): Enable "sequence" mode logic. See http://crbug.com/249422
231 // and http://crbug.com/333437. 242 // and http://crbug.com/333437.
232 bool sequence_mode_; 243 bool sequence_mode_;
233 244
234 TimeDelta append_window_start_; 245 TimeDelta append_window_start_;
235 TimeDelta append_window_end_; 246 TimeDelta append_window_end_;
236 247
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 369
359 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); 370 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream);
360 }; 371 };
361 372
362 SourceState::SourceState(scoped_ptr<StreamParser> stream_parser, 373 SourceState::SourceState(scoped_ptr<StreamParser> stream_parser,
363 const LogCB& log_cb, 374 const LogCB& log_cb,
364 const CreateDemuxerStreamCB& create_demuxer_stream_cb, 375 const CreateDemuxerStreamCB& create_demuxer_stream_cb,
365 const IncreaseDurationCB& increase_duration_cb) 376 const IncreaseDurationCB& increase_duration_cb)
366 : create_demuxer_stream_cb_(create_demuxer_stream_cb), 377 : create_demuxer_stream_cb_(create_demuxer_stream_cb),
367 increase_duration_cb_(increase_duration_cb), 378 increase_duration_cb_(increase_duration_cb),
379 using_user_specified_timestamp_offset_(true),
368 sequence_mode_(false), 380 sequence_mode_(false),
369 append_window_end_(kInfiniteDuration()), 381 append_window_end_(kInfiniteDuration()),
370 new_media_segment_(false), 382 new_media_segment_(false),
371 parsing_media_segment_(false), 383 parsing_media_segment_(false),
372 stream_parser_(stream_parser.release()), 384 stream_parser_(stream_parser.release()),
373 audio_(NULL), 385 audio_(NULL),
374 audio_needs_keyframe_(true), 386 audio_needs_keyframe_(true),
375 video_(NULL), 387 video_(NULL),
376 video_needs_keyframe_(true), 388 video_needs_keyframe_(true),
377 log_cb_(log_cb) { 389 log_cb_(log_cb) {
(...skipping 27 matching lines...) Expand all
405 base::Unretained(this)), 417 base::Unretained(this)),
406 base::Bind(&SourceState::OnEndOfMediaSegment, 418 base::Bind(&SourceState::OnEndOfMediaSegment,
407 base::Unretained(this)), 419 base::Unretained(this)),
408 log_cb_); 420 log_cb_);
409 } 421 }
410 422
411 bool SourceState::SetTimestampOffset(TimeDelta timestamp_offset) { 423 bool SourceState::SetTimestampOffset(TimeDelta timestamp_offset) {
412 if (parsing_media_segment_) 424 if (parsing_media_segment_)
413 return false; 425 return false;
414 426
427 using_user_specified_timestamp_offset_ = true;
415 timestamp_offset_ = timestamp_offset; 428 timestamp_offset_ = timestamp_offset;
429
416 return true; 430 return true;
417 } 431 }
418 432
433 TimeDelta SourceState::GetUpdatedTimestampOffset() const {
434 if (using_user_specified_timestamp_offset_)
435 return kNoTimestamp();
436
437 return timestamp_offset_;
438 }
439
419 bool SourceState::SetSequenceMode(bool sequence_mode) { 440 bool SourceState::SetSequenceMode(bool sequence_mode) {
420 if (parsing_media_segment_) 441 if (parsing_media_segment_)
421 return false; 442 return false;
422 443
423 sequence_mode_ = sequence_mode; 444 sequence_mode_ = sequence_mode;
424 return true; 445 return true;
425 } 446 }
426 447
427 448
428 bool SourceState::Append(const uint8* data, size_t length) { 449 bool SourceState::Append(const uint8* data, size_t length) {
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 } 1573 }
1553 1574
1554 bool ChunkDemuxer::SetTimestampOffset(const std::string& id, TimeDelta offset) { 1575 bool ChunkDemuxer::SetTimestampOffset(const std::string& id, TimeDelta offset) {
1555 base::AutoLock auto_lock(lock_); 1576 base::AutoLock auto_lock(lock_);
1556 DVLOG(1) << "SetTimestampOffset(" << id << ", " << offset.InSecondsF() << ")"; 1577 DVLOG(1) << "SetTimestampOffset(" << id << ", " << offset.InSecondsF() << ")";
1557 CHECK(IsValidId(id)); 1578 CHECK(IsValidId(id));
1558 1579
1559 return source_state_map_[id]->SetTimestampOffset(offset); 1580 return source_state_map_[id]->SetTimestampOffset(offset);
1560 } 1581 }
1561 1582
1583 TimeDelta ChunkDemuxer::GetUpdatedTimestampOffset(const std::string& id) {
1584 base::AutoLock auto_lock(lock_);
1585 DVLOG(1) << "GetUpdatedTimestampOffset(" << id << ")";
1586 CHECK(IsValidId(id));
1587
1588 return source_state_map_[id]->GetUpdatedTimestampOffset();
1589 }
1590
1562 bool ChunkDemuxer::SetSequenceMode(const std::string& id, 1591 bool ChunkDemuxer::SetSequenceMode(const std::string& id,
1563 bool sequence_mode) { 1592 bool sequence_mode) {
1564 base::AutoLock auto_lock(lock_); 1593 base::AutoLock auto_lock(lock_);
1565 DVLOG(1) << "SetSequenceMode(" << id << ", " << sequence_mode << ")"; 1594 DVLOG(1) << "SetSequenceMode(" << id << ", " << sequence_mode << ")";
1566 CHECK(IsValidId(id)); 1595 CHECK(IsValidId(id));
1567 DCHECK_NE(state_, ENDED); 1596 DCHECK_NE(state_, ENDED);
1568 1597
1569 return source_state_map_[id]->SetSequenceMode(sequence_mode); 1598 return source_state_map_[id]->SetSequenceMode(sequence_mode);
1570 } 1599 }
1571 1600
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 } 1894 }
1866 1895
1867 void ChunkDemuxer::ShutdownAllStreams() { 1896 void ChunkDemuxer::ShutdownAllStreams() {
1868 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1897 for (SourceStateMap::iterator itr = source_state_map_.begin();
1869 itr != source_state_map_.end(); ++itr) { 1898 itr != source_state_map_.end(); ++itr) {
1870 itr->second->Shutdown(); 1899 itr->second->Shutdown();
1871 } 1900 }
1872 } 1901 }
1873 1902
1874 } // namespace media 1903 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698