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

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

Issue 1053113002: Prime the landing pad for the new video rendering pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast. Created 5 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
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_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 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/time/default_tick_clock.h" 13 #include "base/time/default_tick_clock.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "media/base/bind_to_current_loop.h" 15 #include "media/base/bind_to_current_loop.h"
16 #include "media/base/buffers.h" 16 #include "media/base/buffers.h"
17 #include "media/base/limits.h" 17 #include "media/base/limits.h"
18 #include "media/base/pipeline.h" 18 #include "media/base/pipeline.h"
19 #include "media/base/video_frame.h" 19 #include "media/base/video_frame.h"
20 20
21 namespace media { 21 namespace media {
22 22
23 VideoRendererImpl::VideoRendererImpl( 23 VideoRendererImpl::VideoRendererImpl(
24 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 24 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
25 VideoRendererSink* sink,
25 ScopedVector<VideoDecoder> decoders, 26 ScopedVector<VideoDecoder> decoders,
26 bool drop_frames, 27 bool drop_frames,
27 const scoped_refptr<MediaLog>& media_log) 28 const scoped_refptr<MediaLog>& media_log)
28 : task_runner_(task_runner), 29 : task_runner_(task_runner),
30 sink_(sink),
29 video_frame_stream_( 31 video_frame_stream_(
30 new VideoFrameStream(task_runner, decoders.Pass(), media_log)), 32 new VideoFrameStream(task_runner, decoders.Pass(), media_log)),
31 low_delay_(false), 33 low_delay_(false),
32 received_end_of_stream_(false), 34 received_end_of_stream_(false),
33 rendered_end_of_stream_(false), 35 rendered_end_of_stream_(false),
34 frame_available_(&lock_), 36 frame_available_(&lock_),
35 state_(kUninitialized), 37 state_(kUninitialized),
36 thread_(), 38 thread_(),
37 pending_read_(false), 39 pending_read_(false),
38 drop_frames_(drop_frames), 40 drop_frames_(drop_frames),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 start_timestamp_ = timestamp; 101 start_timestamp_ = timestamp;
100 AttemptRead_Locked(); 102 AttemptRead_Locked();
101 } 103 }
102 104
103 void VideoRendererImpl::Initialize( 105 void VideoRendererImpl::Initialize(
104 DemuxerStream* stream, 106 DemuxerStream* stream,
105 const PipelineStatusCB& init_cb, 107 const PipelineStatusCB& init_cb,
106 const SetDecryptorReadyCB& set_decryptor_ready_cb, 108 const SetDecryptorReadyCB& set_decryptor_ready_cb,
107 const StatisticsCB& statistics_cb, 109 const StatisticsCB& statistics_cb,
108 const BufferingStateCB& buffering_state_cb, 110 const BufferingStateCB& buffering_state_cb,
109 const PaintCB& paint_cb,
110 const base::Closure& ended_cb, 111 const base::Closure& ended_cb,
111 const PipelineStatusCB& error_cb, 112 const PipelineStatusCB& error_cb,
112 const WallClockTimeCB& wall_clock_time_cb, 113 const WallClockTimeCB& wall_clock_time_cb,
113 const base::Closure& waiting_for_decryption_key_cb) { 114 const base::Closure& waiting_for_decryption_key_cb) {
114 DCHECK(task_runner_->BelongsToCurrentThread()); 115 DCHECK(task_runner_->BelongsToCurrentThread());
115 base::AutoLock auto_lock(lock_); 116 base::AutoLock auto_lock(lock_);
116 DCHECK(stream); 117 DCHECK(stream);
117 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); 118 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO);
118 DCHECK(!init_cb.is_null()); 119 DCHECK(!init_cb.is_null());
119 DCHECK(!statistics_cb.is_null()); 120 DCHECK(!statistics_cb.is_null());
120 DCHECK(!buffering_state_cb.is_null()); 121 DCHECK(!buffering_state_cb.is_null());
121 DCHECK(!paint_cb.is_null());
122 DCHECK(!ended_cb.is_null()); 122 DCHECK(!ended_cb.is_null());
123 DCHECK(!wall_clock_time_cb.is_null()); 123 DCHECK(!wall_clock_time_cb.is_null());
124 DCHECK_EQ(kUninitialized, state_); 124 DCHECK_EQ(kUninitialized, state_);
125 125
126 low_delay_ = (stream->liveness() == DemuxerStream::LIVENESS_LIVE); 126 low_delay_ = (stream->liveness() == DemuxerStream::LIVENESS_LIVE);
127 127
128 // Always post |init_cb_| because |this| could be destroyed if initialization 128 // Always post |init_cb_| because |this| could be destroyed if initialization
129 // failed. 129 // failed.
130 init_cb_ = BindToCurrentLoop(init_cb); 130 init_cb_ = BindToCurrentLoop(init_cb);
131 131
132 statistics_cb_ = statistics_cb; 132 statistics_cb_ = statistics_cb;
133 buffering_state_cb_ = buffering_state_cb; 133 buffering_state_cb_ = buffering_state_cb;
134 paint_cb_ = paint_cb, 134 paint_cb_ = base::Bind(&VideoRendererSink::PaintFrameUsingOldRenderingPath,
135 base::Unretained(sink_));
135 ended_cb_ = ended_cb; 136 ended_cb_ = ended_cb;
136 error_cb_ = error_cb; 137 error_cb_ = error_cb;
137 wall_clock_time_cb_ = wall_clock_time_cb; 138 wall_clock_time_cb_ = wall_clock_time_cb;
138 state_ = kInitializing; 139 state_ = kInitializing;
139 140
140 video_frame_stream_->Initialize( 141 video_frame_stream_->Initialize(
141 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, 142 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized,
142 weak_factory_.GetWeakPtr()), 143 weak_factory_.GetWeakPtr()),
143 set_decryptor_ready_cb, statistics_cb, waiting_for_decryption_key_cb); 144 set_decryptor_ready_cb, statistics_cb, waiting_for_decryption_key_cb);
144 } 145 }
145 146
147 scoped_refptr<VideoFrame> VideoRendererImpl::Render(
148 base::TimeTicks deadline_min,
149 base::TimeTicks deadline_max) {
150 // TODO(dalecurtis): Hook this up to the new VideoRendererAlgorithm.
151 NOTIMPLEMENTED();
152 return nullptr;
153 }
154
155 void VideoRendererImpl::OnFrameDropped() {
156 // TODO(dalecurtis): Hook this up to the new VideoRendererAlgorithm.
157 NOTIMPLEMENTED();
158 }
159
146 void VideoRendererImpl::CreateVideoThread() { 160 void VideoRendererImpl::CreateVideoThread() {
147 // This may fail and cause a crash if there are too many threads created in 161 // This may fail and cause a crash if there are too many threads created in
148 // the current process. See http://crbug.com/443291 162 // the current process. See http://crbug.com/443291
149 CHECK(base::PlatformThread::Create(0, this, &thread_)); 163 CHECK(base::PlatformThread::Create(0, this, &thread_));
150 164
151 #if defined(OS_WIN) 165 #if defined(OS_WIN)
152 // Bump up our priority so our sleeping is more accurate. 166 // Bump up our priority so our sleeping is more accurate.
153 // TODO(scherkus): find out if this is necessary, but it seems to help. 167 // TODO(scherkus): find out if this is necessary, but it seems to help.
154 ::SetThreadPriority(thread_.platform_handle(), THREAD_PRIORITY_ABOVE_NORMAL); 168 ::SetThreadPriority(thread_.platform_handle(), THREAD_PRIORITY_ABOVE_NORMAL);
155 #endif // defined(OS_WIN) 169 #endif // defined(OS_WIN)
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); 474 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics));
461 475
462 frames_decoded_ = 0; 476 frames_decoded_ = 0;
463 frames_dropped_ = 0; 477 frames_dropped_ = 0;
464 } 478 }
465 479
466 frame_available_.TimedWait(wait_duration); 480 frame_available_.TimedWait(wait_duration);
467 } 481 }
468 482
469 } // namespace media 483 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/video_renderer_impl.h ('k') | media/renderers/video_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698