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

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

Issue 1154153003: Relanding 1143663007: VideoFrame: Separate Pixel Format from Storage Type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NV12 support in CrOS Created 5 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/browser/compositor/image_transport_factory.h" 10 #include "content/browser/compositor/image_transport_factory.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 libyuv::RotationMode rotation_mode = libyuv::kRotate0; 240 libyuv::RotationMode rotation_mode = libyuv::kRotate0;
241 if (rotation == 90) 241 if (rotation == 90)
242 rotation_mode = libyuv::kRotate90; 242 rotation_mode = libyuv::kRotate90;
243 else if (rotation == 180) 243 else if (rotation == 180)
244 rotation_mode = libyuv::kRotate180; 244 rotation_mode = libyuv::kRotate180;
245 else if (rotation == 270) 245 else if (rotation == 270)
246 rotation_mode = libyuv::kRotate270; 246 rotation_mode = libyuv::kRotate270;
247 247
248 const gfx::Size dimensions(destination_width, destination_height); 248 const gfx::Size dimensions(destination_width, destination_height);
249 if (!VideoFrame::IsValidConfig(VideoFrame::I420, 249 if (!VideoFrame::IsValidConfig(VideoFrame::I420,
250 VideoFrame::STORAGE_UNKNOWN,
250 dimensions, 251 dimensions,
251 gfx::Rect(dimensions), 252 gfx::Rect(dimensions),
252 dimensions)) { 253 dimensions)) {
253 return; 254 return;
254 } 255 }
255 256
256 scoped_ptr<Buffer> buffer( 257 scoped_ptr<Buffer> buffer(
257 ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dimensions)); 258 ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dimensions));
258 if (!buffer.get()) 259 if (!buffer.get())
259 return; 260 return;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 capture_task_runner_->PostTask( 454 capture_task_runner_->PostTask(
454 FROM_HERE, 455 FROM_HERE,
455 base::Bind(&TextureWrapHelper::OnIncomingCapturedGpuMemoryBuffer, 456 base::Bind(&TextureWrapHelper::OnIncomingCapturedGpuMemoryBuffer,
456 texture_wrap_helper_, 457 texture_wrap_helper_,
457 base::Passed(&buffer), 458 base::Passed(&buffer),
458 frame_format, 459 frame_format,
459 timestamp)); 460 timestamp));
460 } else { 461 } else {
461 DCHECK_EQ(frame_format.pixel_format, media::PIXEL_FORMAT_I420); 462 DCHECK_EQ(frame_format.pixel_format, media::PIXEL_FORMAT_I420);
462 scoped_refptr<VideoFrame> video_frame = 463 scoped_refptr<VideoFrame> video_frame =
463 VideoFrame::WrapExternalPackedMemory( 464 VideoFrame::WrapExternalData(
464 VideoFrame::I420, 465 VideoFrame::I420,
465 frame_format.frame_size, 466 frame_format.frame_size,
466 gfx::Rect(frame_format.frame_size), 467 gfx::Rect(frame_format.frame_size),
467 frame_format.frame_size, 468 frame_format.frame_size,
468 reinterpret_cast<uint8*>(buffer->data()), 469 reinterpret_cast<uint8*>(buffer->data()),
469 VideoFrame::AllocationSize(VideoFrame::I420, 470 VideoFrame::AllocationSize(VideoFrame::I420,
470 frame_format.frame_size), 471 frame_format.frame_size),
471 base::SharedMemory::NULLHandle(),
472 0 /* shared_memory_offset */,
473 base::TimeDelta()); 472 base::TimeDelta());
474 DCHECK(video_frame.get()); 473 DCHECK(video_frame.get());
475 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, 474 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE,
476 frame_format.frame_rate); 475 frame_format.frame_rate);
477 OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, timestamp); 476 OnIncomingCapturedVideoFrame(buffer.Pass(), video_frame, timestamp);
478 } 477 }
479 } 478 }
480 479
481 void VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame( 480 void VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame(
482 scoped_ptr<Buffer> buffer, 481 scoped_ptr<Buffer> buffer,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( 662 void VideoCaptureDeviceClient::TextureWrapHelper::OnError(
664 const std::string& message) { 663 const std::string& message) {
665 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 664 DCHECK(capture_task_runner_->BelongsToCurrentThread());
666 DLOG(ERROR) << message; 665 DLOG(ERROR) << message;
667 BrowserThread::PostTask( 666 BrowserThread::PostTask(
668 BrowserThread::IO, FROM_HERE, 667 BrowserThread::IO, FROM_HERE,
669 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); 668 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_));
670 } 669 }
671 670
672 } // namespace content 671 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698