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

Side by Side 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: Created 7 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/media/rtc_video_renderer.h" 5 #include "content/renderer/media/rtc_video_renderer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
13 #include "media/base/video_util.h" 13 #include "media/base/video_util.h"
14 #include "third_party/libjingle/source/talk/media/base/videoframe.h" 14 #include "third_party/libjingle/source/talk/media/base/videoframe.h"
15 #include "third_party/webrtc/common_video/interface/native_handle.h"
15 16
16 using media::CopyYPlane; 17 using media::CopyYPlane;
17 using media::CopyUPlane; 18 using media::CopyUPlane;
18 using media::CopyVPlane; 19 using media::CopyVPlane;
19 20
20 namespace content { 21 namespace content {
21 22
22 RTCVideoRenderer::RTCVideoRenderer( 23 RTCVideoRenderer::RTCVideoRenderer(
23 webrtc::VideoTrackInterface* video_track, 24 webrtc::VideoTrackInterface* video_track,
24 const base::Closure& error_cb, 25 const base::Closure& error_cb,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 void RTCVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) { 76 void RTCVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) {
76 TRACE_EVENT_INSTANT2("rtc_video_renderer", 77 TRACE_EVENT_INSTANT2("rtc_video_renderer",
77 "RenderFrame", 78 "RenderFrame",
78 TRACE_EVENT_SCOPE_THREAD, 79 TRACE_EVENT_SCOPE_THREAD,
79 "elapsed time", 80 "elapsed time",
80 frame->GetElapsedTime(), 81 frame->GetElapsedTime(),
81 "timestamp", 82 "timestamp",
82 frame->GetTimeStamp()); 83 frame->GetTimeStamp());
83 84
84 gfx::Size size(frame->GetWidth(), frame->GetHeight()); 85 scoped_refptr<media::VideoFrame> video_frame;
85 scoped_refptr<media::VideoFrame> video_frame = 86 if (frame->GetNativeHandle() != NULL) {
86 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, 87 webrtc::NativeHandle *handle =
87 size, 88 (webrtc::NativeHandle *)frame->GetNativeHandle();
Ami GONE FROM CHROMIUM 2013/04/26 00:42:05 if you cast this to the Impl version then you can
wuchengli 2013/05/08 15:58:56 I don't understand. The Impl version signature als
88 gfx::Rect(size), 89 video_frame = (media::VideoFrame *)handle->GetHandle();
89 size, 90 base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(
Ami GONE FROM CHROMIUM 2013/04/26 00:42:05 this is common to both if/else clauses so could be
wuchengli 2013/05/08 15:58:56 Done. Someone else extracted this. On 2013/04/26 0
90 base::TimeDelta::FromMilliseconds( 91 frame->GetTimeStamp());
91 frame->GetTimeStamp())); 92 video_frame->SetTimestamp(timestamp);
93 } else {
94 gfx::Size size(frame->GetWidth(), frame->GetHeight());
95 video_frame = media::VideoFrame::CreateFrame(
96 media::VideoFrame::YV12, size, gfx::Rect(size), size,
97 base::TimeDelta::FromMilliseconds(frame->GetTimeStamp()));
92 98
93 // Aspect ratio unsupported; DCHECK when there are non-square pixels. 99 // Aspect ratio unsupported; DCHECK when there are non-square pixels.
94 DCHECK_EQ(frame->GetPixelWidth(), 1u); 100 DCHECK_EQ(frame->GetPixelWidth(), 1u);
95 DCHECK_EQ(frame->GetPixelHeight(), 1u); 101 DCHECK_EQ(frame->GetPixelHeight(), 1u);
96 102
97 int y_rows = frame->GetHeight(); 103 int y_rows = frame->GetHeight();
98 int uv_rows = frame->GetHeight() / 2; // YV12 format. 104 int uv_rows = frame->GetHeight() / 2; // YV12 format.
99 CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame); 105 CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame);
100 CopyUPlane(frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame); 106 CopyUPlane(frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame);
101 CopyVPlane(frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame); 107 CopyVPlane(frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame);
108 }
102 109
103 message_loop_proxy_->PostTask( 110 message_loop_proxy_->PostTask(
104 FROM_HERE, base::Bind(&RTCVideoRenderer::DoRenderFrameOnMainThread, 111 FROM_HERE, base::Bind(&RTCVideoRenderer::DoRenderFrameOnMainThread,
105 this, video_frame)); 112 this, video_frame));
106 } 113 }
107 114
108 void RTCVideoRenderer::OnChanged() { 115 void RTCVideoRenderer::OnChanged() {
109 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 116 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
110 MaybeRenderSignalingFrame(); 117 MaybeRenderSignalingFrame();
111 } 118 }
(...skipping 17 matching lines...) Expand all
129 136
130 if (state_ != kStarted) { 137 if (state_ != kStarted) {
131 return; 138 return;
132 } 139 }
133 140
134 TRACE_EVENT0("video", "DoRenderFrameOnMainThread"); 141 TRACE_EVENT0("video", "DoRenderFrameOnMainThread");
135 repaint_cb_.Run(video_frame); 142 repaint_cb_.Run(video_frame);
136 } 143 }
137 144
138 } // namespace content 145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698