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

Side by Side Diff: media/renderers/video_renderer_impl.cc

Issue 1873513003: Add video-rendering to mojo media pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor cleanup Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderers/video_renderer_impl.h" 5 #include "media/renderers/video_renderer_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 start_timestamp_ = timestamp; 119 start_timestamp_ = timestamp;
120 AttemptRead_Locked(); 120 AttemptRead_Locked();
121 } 121 }
122 122
123 void VideoRendererImpl::Initialize( 123 void VideoRendererImpl::Initialize(
124 DemuxerStream* stream, 124 DemuxerStream* stream,
125 const PipelineStatusCB& init_cb, 125 const PipelineStatusCB& init_cb,
126 CdmContext* cdm_context, 126 CdmContext* cdm_context,
127 const StatisticsCB& statistics_cb, 127 const StatisticsCB& statistics_cb,
128 const BufferingStateCB& buffering_state_cb, 128 const BufferingStateCB& buffering_state_cb,
129 const NaturalSizeChangedCB& natural_size_changed_cb,
129 const base::Closure& ended_cb, 130 const base::Closure& ended_cb,
130 const PipelineStatusCB& error_cb, 131 const PipelineStatusCB& error_cb,
131 const TimeSource::WallClockTimeCB& wall_clock_time_cb, 132 const TimeSource::WallClockTimeCB& wall_clock_time_cb,
132 const base::Closure& waiting_for_decryption_key_cb) { 133 const base::Closure& waiting_for_decryption_key_cb) {
133 DCHECK(task_runner_->BelongsToCurrentThread()); 134 DCHECK(task_runner_->BelongsToCurrentThread());
134 base::AutoLock auto_lock(lock_); 135 base::AutoLock auto_lock(lock_);
135 DCHECK(stream); 136 DCHECK(stream);
136 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); 137 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO);
137 DCHECK(!init_cb.is_null()); 138 DCHECK(!init_cb.is_null());
138 DCHECK(!statistics_cb.is_null()); 139 DCHECK(!statistics_cb.is_null());
(...skipping 12 matching lines...) Expand all
151 MEDIA_LOG(DEBUG, media_log_) << "Video rendering in low delay mode."; 152 MEDIA_LOG(DEBUG, media_log_) << "Video rendering in low delay mode.";
152 153
153 // Always post |init_cb_| because |this| could be destroyed if initialization 154 // Always post |init_cb_| because |this| could be destroyed if initialization
154 // failed. 155 // failed.
155 init_cb_ = BindToCurrentLoop(init_cb); 156 init_cb_ = BindToCurrentLoop(init_cb);
156 157
157 // Always post |buffering_state_cb_| because it may otherwise invoke reentrant 158 // Always post |buffering_state_cb_| because it may otherwise invoke reentrant
158 // calls to OnTimeStateChanged() under lock, which can deadlock the compositor 159 // calls to OnTimeStateChanged() under lock, which can deadlock the compositor
159 // and media threads. 160 // and media threads.
160 buffering_state_cb_ = BindToCurrentLoop(buffering_state_cb); 161 buffering_state_cb_ = BindToCurrentLoop(buffering_state_cb);
161 162 natural_size_changed_cb_ = natural_size_changed_cb;
162 statistics_cb_ = statistics_cb; 163 statistics_cb_ = statistics_cb;
163 ended_cb_ = ended_cb; 164 ended_cb_ = ended_cb;
164 error_cb_ = error_cb; 165 error_cb_ = error_cb;
165 wall_clock_time_cb_ = wall_clock_time_cb; 166 wall_clock_time_cb_ = wall_clock_time_cb;
166 state_ = kInitializing; 167 state_ = kInitializing;
167 168
168 video_frame_stream_->Initialize( 169 video_frame_stream_->Initialize(
169 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, 170 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized,
170 weak_factory_.GetWeakPtr()), 171 weak_factory_.GetWeakPtr()),
171 cdm_context, statistics_cb, waiting_for_decryption_key_cb); 172 cdm_context, statistics_cb, waiting_for_decryption_key_cb);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 weak_factory_.GetWeakPtr()), 238 weak_factory_.GetWeakPtr()),
238 base::TimeDelta::FromMilliseconds(250)); 239 base::TimeDelta::FromMilliseconds(250));
239 } 240 }
240 241
241 // Always post this task, it will acquire new frames if necessary and since it 242 // Always post this task, it will acquire new frames if necessary and since it
242 // happens on another thread, even if we don't have room in the queue now, by 243 // happens on another thread, even if we don't have room in the queue now, by
243 // the time it runs (may be delayed up to 50ms for complex decodes!) we might. 244 // the time it runs (may be delayed up to 50ms for complex decodes!) we might.
244 task_runner_->PostTask(FROM_HERE, base::Bind(&VideoRendererImpl::AttemptRead, 245 task_runner_->PostTask(FROM_HERE, base::Bind(&VideoRendererImpl::AttemptRead,
245 weak_factory_.GetWeakPtr())); 246 weak_factory_.GetWeakPtr()));
246 247
248 // TODO(alokp): Fire NaturalSizeChangedCB if necessary.
xhwang 2016/04/12 19:40:38 This could be related to this comment: https://cod
alokp 2016/04/19 00:16:08 Done.
247 return result; 249 return result;
248 } 250 }
249 251
250 void VideoRendererImpl::OnFrameDropped() { 252 void VideoRendererImpl::OnFrameDropped() {
251 base::AutoLock auto_lock(lock_); 253 base::AutoLock auto_lock(lock_);
252 algorithm_->OnLastFrameDropped(); 254 algorithm_->OnLastFrameDropped();
253 } 255 }
254 256
255 void VideoRendererImpl::OnVideoFrameStreamInitialized(bool success) { 257 void VideoRendererImpl::OnVideoFrameStreamInitialized(bool success) {
256 DCHECK(task_runner_->BelongsToCurrentThread()); 258 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 std::vector<base::TimeTicks> current_time; 638 std::vector<base::TimeTicks> current_time;
637 wall_clock_time_cb_.Run(std::vector<base::TimeDelta>(), &current_time); 639 wall_clock_time_cb_.Run(std::vector<base::TimeDelta>(), &current_time);
638 return current_time[0]; 640 return current_time[0];
639 } 641 }
640 642
641 bool VideoRendererImpl::IsBeforeStartTime(base::TimeDelta timestamp) { 643 bool VideoRendererImpl::IsBeforeStartTime(base::TimeDelta timestamp) {
642 return timestamp + video_frame_stream_->AverageDuration() < start_timestamp_; 644 return timestamp + video_frame_stream_->AverageDuration() < start_timestamp_;
643 } 645 }
644 646
645 } // namespace media 647 } // namespace media
OLDNEW
« media/mojo/services/video_overlay_factory.cc ('K') | « media/renderers/video_renderer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698