OLD | NEW |
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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 void VideoRendererImpl::Initialize( | 103 void VideoRendererImpl::Initialize( |
104 DemuxerStream* stream, | 104 DemuxerStream* stream, |
105 const PipelineStatusCB& init_cb, | 105 const PipelineStatusCB& init_cb, |
106 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 106 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
107 const StatisticsCB& statistics_cb, | 107 const StatisticsCB& statistics_cb, |
108 const BufferingStateCB& buffering_state_cb, | 108 const BufferingStateCB& buffering_state_cb, |
109 const PaintCB& paint_cb, | 109 const PaintCB& paint_cb, |
110 const base::Closure& ended_cb, | 110 const base::Closure& ended_cb, |
111 const PipelineStatusCB& error_cb, | 111 const PipelineStatusCB& error_cb, |
112 const TimeDeltaCB& get_time_cb) { | 112 const TimeDeltaCB& get_time_cb, |
| 113 const base::Closure& waiting_for_decryption_key_cb) { |
113 DCHECK(task_runner_->BelongsToCurrentThread()); | 114 DCHECK(task_runner_->BelongsToCurrentThread()); |
114 base::AutoLock auto_lock(lock_); | 115 base::AutoLock auto_lock(lock_); |
115 DCHECK(stream); | 116 DCHECK(stream); |
116 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); | 117 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); |
117 DCHECK(!init_cb.is_null()); | 118 DCHECK(!init_cb.is_null()); |
118 DCHECK(!statistics_cb.is_null()); | 119 DCHECK(!statistics_cb.is_null()); |
119 DCHECK(!buffering_state_cb.is_null()); | 120 DCHECK(!buffering_state_cb.is_null()); |
120 DCHECK(!paint_cb.is_null()); | 121 DCHECK(!paint_cb.is_null()); |
121 DCHECK(!ended_cb.is_null()); | 122 DCHECK(!ended_cb.is_null()); |
122 DCHECK(!get_time_cb.is_null()); | 123 DCHECK(!get_time_cb.is_null()); |
123 DCHECK_EQ(kUninitialized, state_); | 124 DCHECK_EQ(kUninitialized, state_); |
124 | 125 |
125 low_delay_ = (stream->liveness() == DemuxerStream::LIVENESS_LIVE); | 126 low_delay_ = (stream->liveness() == DemuxerStream::LIVENESS_LIVE); |
126 | 127 |
127 // Always post |init_cb_| because |this| could be destroyed if initialization | 128 // Always post |init_cb_| because |this| could be destroyed if initialization |
128 // failed. | 129 // failed. |
129 init_cb_ = BindToCurrentLoop(init_cb); | 130 init_cb_ = BindToCurrentLoop(init_cb); |
130 | 131 |
131 statistics_cb_ = statistics_cb; | 132 statistics_cb_ = statistics_cb; |
132 buffering_state_cb_ = buffering_state_cb; | 133 buffering_state_cb_ = buffering_state_cb; |
133 paint_cb_ = paint_cb, | 134 paint_cb_ = paint_cb, |
134 ended_cb_ = ended_cb; | 135 ended_cb_ = ended_cb; |
135 error_cb_ = error_cb; | 136 error_cb_ = error_cb; |
136 get_time_cb_ = get_time_cb; | 137 get_time_cb_ = get_time_cb; |
137 state_ = kInitializing; | 138 state_ = kInitializing; |
138 | 139 |
139 video_frame_stream_->Initialize( | 140 video_frame_stream_->Initialize( |
140 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, | 141 stream, base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, |
141 weak_factory_.GetWeakPtr()), | 142 weak_factory_.GetWeakPtr()), |
142 set_decryptor_ready_cb, statistics_cb); | 143 set_decryptor_ready_cb, statistics_cb, waiting_for_decryption_key_cb); |
143 } | 144 } |
144 | 145 |
145 void VideoRendererImpl::CreateVideoThread() { | 146 void VideoRendererImpl::CreateVideoThread() { |
146 // This may fail and cause a crash if there are too many threads created in | 147 // This may fail and cause a crash if there are too many threads created in |
147 // the current process. See http://crbug.com/443291 | 148 // the current process. See http://crbug.com/443291 |
148 CHECK(base::PlatformThread::Create(0, this, &thread_)); | 149 CHECK(base::PlatformThread::Create(0, this, &thread_)); |
149 | 150 |
150 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
151 // Bump up our priority so our sleeping is more accurate. | 152 // Bump up our priority so our sleeping is more accurate. |
152 // TODO(scherkus): find out if this is necessary, but it seems to help. | 153 // TODO(scherkus): find out if this is necessary, but it seems to help. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); | 444 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); |
444 | 445 |
445 frames_decoded_ = 0; | 446 frames_decoded_ = 0; |
446 frames_dropped_ = 0; | 447 frames_dropped_ = 0; |
447 } | 448 } |
448 | 449 |
449 frame_available_.TimedWait(wait_duration); | 450 frame_available_.TimedWait(wait_duration); |
450 } | 451 } |
451 | 452 |
452 } // namespace media | 453 } // namespace media |
OLD | NEW |