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

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: address review comments and fix a crash after hang up Created 7 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 (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/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "content/renderer/media/native_handle_impl.h"
12 #include "media/base/video_frame.h" 13 #include "media/base/video_frame.h"
13 #include "media/base/video_util.h" 14 #include "media/base/video_util.h"
14 #include "third_party/libjingle/source/talk/media/base/videoframe.h" 15 #include "third_party/libjingle/source/talk/media/base/videoframe.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
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 frame->GetTimeStamp() / talk_base::kNumNanosecsPerMillisec); 78 frame->GetTimeStamp() / talk_base::kNumNanosecsPerMillisec);
78 79
79 TRACE_EVENT_INSTANT2("rtc_video_renderer", 80 TRACE_EVENT_INSTANT2("rtc_video_renderer",
80 "RenderFrame", 81 "RenderFrame",
81 TRACE_EVENT_SCOPE_THREAD, 82 TRACE_EVENT_SCOPE_THREAD,
82 "elapsed time", 83 "elapsed time",
83 frame->GetElapsedTime(), 84 frame->GetElapsedTime(),
84 "timestamp_ms", 85 "timestamp_ms",
85 timestamp.InMilliseconds()); 86 timestamp.InMilliseconds());
86 87
87 gfx::Size size(frame->GetWidth(), frame->GetHeight()); 88 scoped_refptr<media::VideoFrame> video_frame;
88 scoped_refptr<media::VideoFrame> video_frame = 89 if (frame->GetNativeHandle() != NULL) {
89 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, 90 NativeHandleImpl* handle =
90 size, 91 static_cast<NativeHandleImpl*>(frame->GetNativeHandle());
91 gfx::Rect(size), 92 video_frame = static_cast<media::VideoFrame*>(handle->GetHandle());
92 size, 93 video_frame->SetTimestamp(timestamp);
93 timestamp); 94 } else {
95 gfx::Size size(frame->GetWidth(), frame->GetHeight());
96 video_frame = media::VideoFrame::CreateFrame(
97 media::VideoFrame::YV12, size, gfx::Rect(size), size, timestamp);
94 98
95 // Aspect ratio unsupported; DCHECK when there are non-square pixels. 99 // Aspect ratio unsupported; DCHECK when there are non-square pixels.
96 DCHECK_EQ(frame->GetPixelWidth(), 1u); 100 DCHECK_EQ(frame->GetPixelWidth(), 1u);
97 DCHECK_EQ(frame->GetPixelHeight(), 1u); 101 DCHECK_EQ(frame->GetPixelHeight(), 1u);
98 102
99 int y_rows = frame->GetHeight(); 103 int y_rows = frame->GetHeight();
100 int uv_rows = frame->GetHeight() / 2; // YV12 format. 104 int uv_rows = frame->GetHeight() / 2; // YV12 format.
101 CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame.get()); 105 CopyYPlane(
102 CopyUPlane( 106 frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame.get());
103 frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame.get()); 107 CopyUPlane(
104 CopyVPlane( 108 frame->GetUPlane(), frame->GetUPitch(), uv_rows, video_frame.get());
105 frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame.get()); 109 CopyVPlane(
110 frame->GetVPlane(), frame->GetVPitch(), uv_rows, video_frame.get());
111 }
106 112
107 message_loop_proxy_->PostTask( 113 message_loop_proxy_->PostTask(
108 FROM_HERE, base::Bind(&RTCVideoRenderer::DoRenderFrameOnMainThread, 114 FROM_HERE, base::Bind(&RTCVideoRenderer::DoRenderFrameOnMainThread,
109 this, video_frame)); 115 this, video_frame));
110 } 116 }
111 117
112 void RTCVideoRenderer::OnChanged() { 118 void RTCVideoRenderer::OnChanged() {
113 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 119 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
114 MaybeRenderSignalingFrame(); 120 MaybeRenderSignalingFrame();
115 } 121 }
(...skipping 17 matching lines...) Expand all
133 139
134 if (state_ != kStarted) { 140 if (state_ != kStarted) {
135 return; 141 return;
136 } 142 }
137 143
138 TRACE_EVENT0("video", "DoRenderFrameOnMainThread"); 144 TRACE_EVENT0("video", "DoRenderFrameOnMainThread");
139 repaint_cb_.Run(video_frame); 145 repaint_cb_.Run(video_frame);
140 } 146 }
141 147
142 } // namespace content 148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698