OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" | 5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 decode_done_closure_ = base::Bind( | 147 decode_done_closure_ = base::Bind( |
148 decode_done_cb_, base::Passed(&out_buffer), out_frame, timestamp); | 148 decode_done_cb_, base::Passed(&out_buffer), out_frame, timestamp); |
149 } | 149 } |
150 decoder_->Decode(in_buffer, out_frame); | 150 decoder_->Decode(in_buffer, out_frame); |
151 #else | 151 #else |
152 NOTREACHED(); | 152 NOTREACHED(); |
153 #endif | 153 #endif |
154 } | 154 } |
155 | 155 |
156 void VideoCaptureGpuJpegDecoder::VideoFrameReady(int32_t bitstream_buffer_id) { | 156 void VideoCaptureGpuJpegDecoder::VideoFrameReady(int32_t bitstream_buffer_id) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
158 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::VideoFrameReady"); | 158 TRACE_EVENT0("jpeg", "VideoCaptureGpuJpegDecoder::VideoFrameReady"); |
159 base::AutoLock lock(lock_); | 159 base::AutoLock lock(lock_); |
160 | 160 |
161 if (!IsDecoding_Locked()) { | 161 if (!IsDecoding_Locked()) { |
162 LOG(ERROR) << "Got decode response while not decoding"; | 162 LOG(ERROR) << "Got decode response while not decoding"; |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 if (bitstream_buffer_id != in_buffer_id_) { | 166 if (bitstream_buffer_id != in_buffer_id_) { |
167 LOG(ERROR) << "Unexpected bitstream_buffer_id " << bitstream_buffer_id | 167 LOG(ERROR) << "Unexpected bitstream_buffer_id " << bitstream_buffer_id |
168 << ", expected " << in_buffer_id_; | 168 << ", expected " << in_buffer_id_; |
169 return; | 169 return; |
170 } | 170 } |
171 in_buffer_id_ = media::JpegDecodeAccelerator::kInvalidBitstreamBufferId; | 171 in_buffer_id_ = media::JpegDecodeAccelerator::kInvalidBitstreamBufferId; |
172 | 172 |
173 decode_done_closure_.Run(); | 173 decode_done_closure_.Run(); |
174 decode_done_closure_.Reset(); | 174 decode_done_closure_.Reset(); |
175 | 175 |
176 TRACE_EVENT_ASYNC_END0("jpeg", "VideoCaptureGpuJpegDecoder decoding", | 176 TRACE_EVENT_ASYNC_END0("jpeg", "VideoCaptureGpuJpegDecoder decoding", |
177 bitstream_buffer_id); | 177 bitstream_buffer_id); |
178 } | 178 } |
179 | 179 |
180 void VideoCaptureGpuJpegDecoder::NotifyError( | 180 void VideoCaptureGpuJpegDecoder::NotifyError( |
181 int32_t bitstream_buffer_id, | 181 int32_t bitstream_buffer_id, |
182 media::JpegDecodeAccelerator::Error error) { | 182 media::JpegDecodeAccelerator::Error error) { |
183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 183 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
184 LOG(ERROR) << "Decode error, bitstream_buffer_id=" << bitstream_buffer_id | 184 LOG(ERROR) << "Decode error, bitstream_buffer_id=" << bitstream_buffer_id |
185 << ", error=" << error; | 185 << ", error=" << error; |
186 | 186 |
187 base::AutoLock lock(lock_); | 187 base::AutoLock lock(lock_); |
188 decode_done_closure_.Reset(); | 188 decode_done_closure_.Reset(); |
189 decoder_status_ = FAILED; | 189 decoder_status_ = FAILED; |
190 } | 190 } |
191 | 191 |
192 // static | 192 // static |
193 void VideoCaptureGpuJpegDecoder::EstablishGpuChannelOnUIThread( | 193 void VideoCaptureGpuJpegDecoder::EstablishGpuChannelOnUIThread( |
194 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 194 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
195 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { | 195 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { |
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
197 DCHECK(BrowserGpuChannelHostFactory::instance()); | 197 DCHECK(BrowserGpuChannelHostFactory::instance()); |
198 | 198 |
199 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( | 199 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
200 CAUSE_FOR_GPU_LAUNCH_JPEGDECODEACCELERATOR_INITIALIZE, | 200 CAUSE_FOR_GPU_LAUNCH_JPEGDECODEACCELERATOR_INITIALIZE, |
201 base::Bind(&VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread, | 201 base::Bind(&VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread, |
202 task_runner, weak_this)); | 202 task_runner, weak_this)); |
203 } | 203 } |
204 | 204 |
205 // static | 205 // static |
206 void VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread( | 206 void VideoCaptureGpuJpegDecoder::GpuChannelEstablishedOnUIThread( |
207 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 207 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
208 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { | 208 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this) { |
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 209 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
210 | 210 |
211 scoped_refptr<GpuChannelHost> gpu_channel_host( | 211 scoped_refptr<GpuChannelHost> gpu_channel_host( |
212 BrowserGpuChannelHostFactory::instance()->GetGpuChannel()); | 212 BrowserGpuChannelHostFactory::instance()->GetGpuChannel()); |
213 task_runner->PostTask( | 213 task_runner->PostTask( |
214 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization, | 214 FROM_HERE, base::Bind(&VideoCaptureGpuJpegDecoder::FinishInitialization, |
215 weak_this, base::Passed(&gpu_channel_host))); | 215 weak_this, base::Passed(&gpu_channel_host))); |
216 } | 216 } |
217 | 217 |
218 void VideoCaptureGpuJpegDecoder::FinishInitialization( | 218 void VideoCaptureGpuJpegDecoder::FinishInitialization( |
219 scoped_refptr<GpuChannelHost> gpu_channel_host) { | 219 scoped_refptr<GpuChannelHost> gpu_channel_host) { |
(...skipping 13 matching lines...) Expand all Loading... |
233 lock_.AssertAcquired(); | 233 lock_.AssertAcquired(); |
234 return !decode_done_closure_.is_null(); | 234 return !decode_done_closure_.is_null(); |
235 } | 235 } |
236 | 236 |
237 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { | 237 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { |
238 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", | 238 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", |
239 decoder_status_ == INIT_PASSED); | 239 decoder_status_ == INIT_PASSED); |
240 } | 240 } |
241 | 241 |
242 } // namespace content | 242 } // namespace content |
OLD | NEW |