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

Side by Side Diff: content/browser/renderer_host/media/video_capture_device_client.cc

Issue 2045813003: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 6 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 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_device_client.h" 5 #include "content/browser/renderer_host/media/video_capture_device_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DCHECK_GE(static_cast<size_t>(length), frame_format.ImageAllocationSize()); 218 DCHECK_GE(static_cast<size_t>(length), frame_format.ImageAllocationSize());
219 219
220 if (external_jpeg_decoder_) { 220 if (external_jpeg_decoder_) {
221 const VideoCaptureGpuJpegDecoder::STATUS status = 221 const VideoCaptureGpuJpegDecoder::STATUS status =
222 external_jpeg_decoder_->GetStatus(); 222 external_jpeg_decoder_->GetStatus();
223 if (status == VideoCaptureGpuJpegDecoder::FAILED) { 223 if (status == VideoCaptureGpuJpegDecoder::FAILED) {
224 external_jpeg_decoder_.reset(); 224 external_jpeg_decoder_.reset();
225 } else if (status == VideoCaptureGpuJpegDecoder::INIT_PASSED && 225 } else if (status == VideoCaptureGpuJpegDecoder::INIT_PASSED &&
226 frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG && 226 frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG &&
227 rotation == 0 && !flip) { 227 rotation == 0 && !flip) {
228 // TODO(qiangchen): Pass timestamp into DecodeCapturedData. 228 external_jpeg_decoder_->DecodeCapturedData(data, length, frame_format,
229 external_jpeg_decoder_->DecodeCapturedData( 229 reference_time, timestamp,
230 data, length, frame_format, reference_time, std::move(buffer)); 230 std::move(buffer));
231 return; 231 return;
232 } 232 }
233 } 233 }
234 234
235 if (libyuv::ConvertToI420(data, 235 if (libyuv::ConvertToI420(data,
236 length, 236 length,
237 y_plane_data, 237 y_plane_data,
238 yplane_stride, 238 yplane_stride,
239 u_plane_data, 239 u_plane_data,
240 uv_plane_stride, 240 uv_plane_stride,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 reinterpret_cast<uint8_t*>(buffer->data()), 316 reinterpret_cast<uint8_t*>(buffer->data()),
317 VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420, 317 VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420,
318 frame_format.frame_size), 318 frame_format.frame_size),
319 base::SharedMemory::NULLHandle(), 0u, timestamp); 319 base::SharedMemory::NULLHandle(), 0u, timestamp);
320 break; 320 break;
321 } 321 }
322 if (!frame) 322 if (!frame)
323 return; 323 return;
324 frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, 324 frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE,
325 frame_format.frame_rate); 325 frame_format.frame_rate);
326 OnIncomingCapturedVideoFrame(std::move(buffer), frame, reference_time); 326 frame->metadata()->SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME,
327 reference_time);
328 OnIncomingCapturedVideoFrame(std::move(buffer), frame);
327 } 329 }
328 330
329 void VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame( 331 void VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame(
330 std::unique_ptr<Buffer> buffer, 332 std::unique_ptr<Buffer> buffer,
331 const scoped_refptr<VideoFrame>& frame, 333 const scoped_refptr<VideoFrame>& frame) {
332 base::TimeTicks reference_time) {
333 // TODO(qiangchen): Dive into DoIncomingCapturedVideoFrameOnIOThread to
334 // process timestamp.
335 BrowserThread::PostTask( 334 BrowserThread::PostTask(
336 BrowserThread::IO, FROM_HERE, 335 BrowserThread::IO, FROM_HERE,
337 base::Bind( 336 base::Bind(
338 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, 337 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread,
339 controller_, base::Passed(&buffer), frame, reference_time)); 338 controller_, base::Passed(&buffer), frame));
340 } 339 }
341 340
342 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> 341 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>
343 VideoCaptureDeviceClient::ResurrectLastOutputBuffer( 342 VideoCaptureDeviceClient::ResurrectLastOutputBuffer(
344 const gfx::Size& dimensions, 343 const gfx::Size& dimensions,
345 media::VideoPixelFormat format, 344 media::VideoPixelFormat format,
346 media::VideoPixelStorage storage) { 345 media::VideoPixelStorage storage) {
347 const int buffer_id = 346 const int buffer_id =
348 buffer_pool_->ResurrectLastForProducer(dimensions, format, storage); 347 buffer_pool_->ResurrectLastForProducer(dimensions, format, storage);
349 if (buffer_id == VideoCaptureBufferPool::kInvalidId) 348 if (buffer_id == VideoCaptureBufferPool::kInvalidId)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kUPlane)); 417 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kUPlane));
419 *v_plane_data = 418 *v_plane_data =
420 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kVPlane)); 419 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kVPlane));
421 return buffer; 420 return buffer;
422 } 421 }
423 NOTREACHED(); 422 NOTREACHED();
424 return std::unique_ptr<Buffer>(); 423 return std::unique_ptr<Buffer>();
425 } 424 }
426 425
427 } // namespace content 426 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698