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

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

Issue 236023003: Add WebMediaPlayer::timelineOffset() support to WebMediaPlayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 6 years, 8 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/ffmpeg_demuxer.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 <limits> 8 #include <limits>
9 #include <list> 9 #include <list>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 DemuxerStream::Type)> CreateDemuxerStreamCB; 91 DemuxerStream::Type)> CreateDemuxerStreamCB;
92 92
93 typedef base::Callback<void( 93 typedef base::Callback<void(
94 ChunkDemuxerStream*, const TextTrackConfig&)> NewTextTrackCB; 94 ChunkDemuxerStream*, const TextTrackConfig&)> NewTextTrackCB;
95 95
96 // First parameter - Indicates initialization success. Set to true if 96 // First parameter - Indicates initialization success. Set to true if
97 // initialization was successful. False if an error 97 // initialization was successful. False if an error
98 // occurred. 98 // occurred.
99 // Second parameter - Indicates the stream duration. Only contains a valid 99 // Second parameter - Indicates the stream duration. Only contains a valid
100 // value if the first parameter is true. 100 // value if the first parameter is true.
101 typedef base::Callback<void(bool, TimeDelta)> InitCB; 101 // Third parameter - Indicates the source Time associated with
102 // presentation timestamp 0. A null Time is returned if
103 // no mapping to Time exists. Only contains a
104 // valid value if the first parameter is true.
105 typedef base::Callback<void(bool, TimeDelta, base::Time)> InitCB;
102 106
103 SourceState( 107 SourceState(
104 scoped_ptr<StreamParser> stream_parser, 108 scoped_ptr<StreamParser> stream_parser,
105 scoped_ptr<FrameProcessorBase> frame_processor, const LogCB& log_cb, 109 scoped_ptr<FrameProcessorBase> frame_processor, const LogCB& log_cb,
106 const CreateDemuxerStreamCB& create_demuxer_stream_cb); 110 const CreateDemuxerStreamCB& create_demuxer_stream_cb);
107 111
108 ~SourceState(); 112 ~SourceState();
109 113
110 void Init(const InitCB& init_cb, 114 void Init(const InitCB& init_cb,
111 bool allow_audio, 115 bool allow_audio,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // appending the processed frames to associated demuxer streams for each 187 // appending the processed frames to associated demuxer streams for each
184 // frame's track. 188 // frame's track.
185 // Returns true on a successful call. Returns false if an error occurred while 189 // Returns true on a successful call. Returns false if an error occurred while
186 // processing the buffers. 190 // processing the buffers.
187 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, 191 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers,
188 const StreamParser::BufferQueue& video_buffers, 192 const StreamParser::BufferQueue& video_buffers,
189 const StreamParser::TextBufferQueueMap& text_map); 193 const StreamParser::TextBufferQueueMap& text_map);
190 194
191 void OnSourceInitDone(bool success, 195 void OnSourceInitDone(bool success,
192 TimeDelta duration, 196 TimeDelta duration,
197 base::Time timeline_offset,
193 bool auto_update_timestamp_offset); 198 bool auto_update_timestamp_offset);
194 199
195 CreateDemuxerStreamCB create_demuxer_stream_cb_; 200 CreateDemuxerStreamCB create_demuxer_stream_cb_;
196 NewTextTrackCB new_text_track_cb_; 201 NewTextTrackCB new_text_track_cb_;
197 202
198 // During Append(), if OnNewBuffers() coded frame processing updates the 203 // During Append(), if OnNewBuffers() coded frame processing updates the
199 // timestamp offset then |*timestamp_offset_during_append_| is also updated 204 // timestamp offset then |*timestamp_offset_during_append_| is also updated
200 // so Append()'s caller can know the new offset. This pointer is only non-NULL 205 // so Append()'s caller can know the new offset. This pointer is only non-NULL
201 // during the lifetime of an Append() call. 206 // during the lifetime of an Append() call.
202 TimeDelta* timestamp_offset_during_append_; 207 TimeDelta* timestamp_offset_during_append_;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if (auto_update_timestamp_offset_ && 695 if (auto_update_timestamp_offset_ &&
691 timestamp_offset_before_processing == *timestamp_offset_during_append_) { 696 timestamp_offset_before_processing == *timestamp_offset_during_append_) {
692 *timestamp_offset_during_append_ = new_timestamp_offset; 697 *timestamp_offset_during_append_ = new_timestamp_offset;
693 } 698 }
694 699
695 return true; 700 return true;
696 } 701 }
697 702
698 void SourceState::OnSourceInitDone(bool success, 703 void SourceState::OnSourceInitDone(bool success,
699 TimeDelta duration, 704 TimeDelta duration,
705 base::Time timeline_offset,
700 bool auto_update_timestamp_offset) { 706 bool auto_update_timestamp_offset) {
701 auto_update_timestamp_offset_ = auto_update_timestamp_offset; 707 auto_update_timestamp_offset_ = auto_update_timestamp_offset;
702 base::ResetAndReturn(&init_cb_).Run(success, duration); 708 base::ResetAndReturn(&init_cb_).Run(
709 success, duration, timeline_offset);
703 } 710 }
704 711
705 ChunkDemuxerStream::ChunkDemuxerStream(Type type, bool splice_frames_enabled) 712 ChunkDemuxerStream::ChunkDemuxerStream(Type type, bool splice_frames_enabled)
706 : type_(type), 713 : type_(type),
707 state_(UNINITIALIZED), 714 state_(UNINITIALIZED),
708 splice_frames_enabled_(splice_frames_enabled) {} 715 splice_frames_enabled_(splice_frames_enabled) {}
709 716
710 void ChunkDemuxerStream::StartReturningData() { 717 void ChunkDemuxerStream::StartReturningData() {
711 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()"; 718 DVLOG(1) << "ChunkDemuxerStream::StartReturningData()";
712 base::AutoLock auto_lock(lock_); 719 base::AutoLock auto_lock(lock_);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 if (type == DemuxerStream::AUDIO) 1069 if (type == DemuxerStream::AUDIO)
1063 return audio_.get(); 1070 return audio_.get();
1064 1071
1065 return NULL; 1072 return NULL;
1066 } 1073 }
1067 1074
1068 TimeDelta ChunkDemuxer::GetStartTime() const { 1075 TimeDelta ChunkDemuxer::GetStartTime() const {
1069 return TimeDelta(); 1076 return TimeDelta();
1070 } 1077 }
1071 1078
1079 base::Time ChunkDemuxer::GetTimelineOffset() const {
1080 return timeline_offset_;
1081 }
1082
1072 void ChunkDemuxer::StartWaitingForSeek(TimeDelta seek_time) { 1083 void ChunkDemuxer::StartWaitingForSeek(TimeDelta seek_time) {
1073 DVLOG(1) << "StartWaitingForSeek()"; 1084 DVLOG(1) << "StartWaitingForSeek()";
1074 base::AutoLock auto_lock(lock_); 1085 base::AutoLock auto_lock(lock_);
1075 DCHECK(state_ == INITIALIZED || state_ == ENDED || state_ == SHUTDOWN || 1086 DCHECK(state_ == INITIALIZED || state_ == ENDED || state_ == SHUTDOWN ||
1076 state_ == PARSE_ERROR) << state_; 1087 state_ == PARSE_ERROR) << state_;
1077 DCHECK(seek_cb_.is_null()); 1088 DCHECK(seek_cb_.is_null());
1078 1089
1079 if (state_ == SHUTDOWN || state_ == PARSE_ERROR) 1090 if (state_ == SHUTDOWN || state_ == PARSE_ERROR)
1080 return; 1091 return;
1081 1092
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 lock_.AssertAcquired(); 1490 lock_.AssertAcquired();
1480 for (SourceStateMap::const_iterator itr = source_state_map_.begin(); 1491 for (SourceStateMap::const_iterator itr = source_state_map_.begin();
1481 itr != source_state_map_.end(); ++itr) { 1492 itr != source_state_map_.end(); ++itr) {
1482 if (itr->second->IsSeekWaitingForData()) 1493 if (itr->second->IsSeekWaitingForData())
1483 return true; 1494 return true;
1484 } 1495 }
1485 1496
1486 return false; 1497 return false;
1487 } 1498 }
1488 1499
1489 void ChunkDemuxer::OnSourceInitDone(bool success, TimeDelta duration) { 1500 void ChunkDemuxer::OnSourceInitDone(bool success, TimeDelta duration,
1501 base::Time timeline_offset) {
1490 DVLOG(1) << "OnSourceInitDone(" << success << ", " 1502 DVLOG(1) << "OnSourceInitDone(" << success << ", "
1491 << duration.InSecondsF() << ")"; 1503 << duration.InSecondsF() << ")";
1492 lock_.AssertAcquired(); 1504 lock_.AssertAcquired();
1493 DCHECK_EQ(state_, INITIALIZING); 1505 DCHECK_EQ(state_, INITIALIZING);
1494 if (!success || (!audio_ && !video_)) { 1506 if (!success || (!audio_ && !video_)) {
1495 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); 1507 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN);
1496 return; 1508 return;
1497 } 1509 }
1498 1510
1499 if (duration != TimeDelta() && duration_ == kNoTimestamp()) 1511 if (duration != TimeDelta() && duration_ == kNoTimestamp())
1500 UpdateDuration(duration); 1512 UpdateDuration(duration);
1501 1513
1514 if (!timeline_offset.is_null()) {
1515 if (!timeline_offset_.is_null() &&
1516 timeline_offset != timeline_offset_) {
1517 MEDIA_LOG(log_cb_)
1518 << "Timeline offset is not the same across all SourceBuffers.";
1519 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN);
1520 return;
1521 }
1522
1523 timeline_offset_ = timeline_offset;
1524 }
1525
1502 // Wait until all streams have initialized. 1526 // Wait until all streams have initialized.
1503 if ((!source_id_audio_.empty() && !audio_) || 1527 if ((!source_id_audio_.empty() && !audio_) ||
1504 (!source_id_video_.empty() && !video_)) 1528 (!source_id_video_.empty() && !video_))
1505 return; 1529 return;
1506 1530
1507 SeekAllSources(GetStartTime()); 1531 SeekAllSources(GetStartTime());
1508 StartReturningData(); 1532 StartReturningData();
1509 1533
1510 if (duration_ == kNoTimestamp()) 1534 if (duration_ == kNoTimestamp())
1511 duration_ = kInfiniteDuration(); 1535 duration_ = kInfiniteDuration();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 } 1668 }
1645 1669
1646 void ChunkDemuxer::ShutdownAllStreams() { 1670 void ChunkDemuxer::ShutdownAllStreams() {
1647 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1671 for (SourceStateMap::iterator itr = source_state_map_.begin();
1648 itr != source_state_map_.end(); ++itr) { 1672 itr != source_state_map_.end(); ++itr) {
1649 itr->second->Shutdown(); 1673 itr->second->Shutdown();
1650 } 1674 }
1651 } 1675 }
1652 1676
1653 } // namespace media 1677 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698