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

Unified Diff: content/renderer/media/rtc_video_renderer.cc

Issue 13890012: Integrate VDA with WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address some review comments Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/rtc_video_renderer.cc
diff --git a/content/renderer/media/rtc_video_renderer.cc b/content/renderer/media/rtc_video_renderer.cc
index 8edef652ca56f4f9917e178e7139fbd9cc71f7f9..b6c05f27739a6b066cae6a0d6ef95eff9264e52e 100644
--- a/content/renderer/media/rtc_video_renderer.cc
+++ b/content/renderer/media/rtc_video_renderer.cc
@@ -9,6 +9,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop_proxy.h"
+#include "content/renderer/media/native_handle_impl.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "third_party/libjingle/source/talk/media/base/videoframe.h"
@@ -84,23 +85,31 @@ void RTCVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) {
"timestamp_ms",
timestamp.InMilliseconds());
- gfx::Size size(frame->GetWidth(), frame->GetHeight());
- scoped_refptr<media::VideoFrame> video_frame =
- media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
- size,
- gfx::Rect(size),
- size,
- timestamp);
-
- // Aspect ratio unsupported; DCHECK when there are non-square pixels.
- DCHECK_EQ(frame->GetPixelWidth(), 1u);
- DCHECK_EQ(frame->GetPixelHeight(), 1u);
-
- int y_rows = frame->GetHeight();
- int uv_rows = frame->GetHeight() / 2; // YV12 format.
- CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame);
- CopyUPlane(frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame);
- CopyVPlane(frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame);
+ scoped_refptr<media::VideoFrame> video_frame;
+ if (frame->GetNativeHandle() != NULL) {
+ NativeHandleImpl* handle =
+ static_cast<NativeHandleImpl*>(frame->GetNativeHandle());
+ video_frame = static_cast<media::VideoFrame*>(handle->GetHandle());
+ video_frame->SetTimestamp(timestamp);
+ } else {
+ gfx::Size size(frame->GetWidth(), frame->GetHeight());
+ video_frame =
+ media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
+ size,
+ gfx::Rect(size),
+ size,
+ timestamp);
+
+ // Aspect ratio unsupported; DCHECK when there are non-square pixels.
+ DCHECK_EQ(frame->GetPixelWidth(), 1u);
+ DCHECK_EQ(frame->GetPixelHeight(), 1u);
+
+ int y_rows = frame->GetHeight();
+ int uv_rows = frame->GetHeight() / 2; // YV12 format.
+ CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame);
+ CopyUPlane(frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame);
+ CopyVPlane(frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame);
+ }
message_loop_proxy_->PostTask(
FROM_HERE, base::Bind(&RTCVideoRenderer::DoRenderFrameOnMainThread,

Powered by Google App Engine
This is Rietveld 408576698