OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // Implementation of CarbonVideoRenderer | 11 // Implementation of CarbonVideoRenderer |
12 | 12 |
13 #include "webrtc/media/devices/carbonvideorenderer.h" | 13 #include "webrtc/media/devices/carbonvideorenderer.h" |
14 | 14 |
| 15 #include "libyuv/convert_from.h" |
15 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
16 #include "webrtc/media/base/videocommon.h" | 17 #include "webrtc/media/base/videocommon.h" |
17 #include "webrtc/media/base/videoframe.h" | 18 #include "webrtc/media/base/videoframe.h" |
18 | 19 |
19 namespace cricket { | 20 namespace cricket { |
20 | 21 |
21 CarbonVideoRenderer::CarbonVideoRenderer(int x, int y) | 22 CarbonVideoRenderer::CarbonVideoRenderer(int x, int y) |
22 : image_width_(0), | 23 : image_width_(0), |
23 image_height_(0), | 24 image_height_(0), |
24 x_(x), | 25 x_(x), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(), | 111 webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(), |
111 video_frame.rotation()), | 112 video_frame.rotation()), |
112 webrtc::kVideoRotation_0, video_frame.timestamp_us()); | 113 webrtc::kVideoRotation_0, video_frame.timestamp_us()); |
113 | 114 |
114 if (!SetSize(frame.width(), frame.height())) { | 115 if (!SetSize(frame.width(), frame.height())) { |
115 return false; | 116 return false; |
116 } | 117 } |
117 | 118 |
118 // Grab the image lock so we are not trashing up the image being drawn. | 119 // Grab the image lock so we are not trashing up the image being drawn. |
119 rtc::CritScope cs(&image_crit_); | 120 rtc::CritScope cs(&image_crit_); |
120 frame.ConvertToRgbBuffer(cricket::FOURCC_ABGR, | 121 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
121 image_.get(), | 122 frame.video_frame_buffer()); |
122 static_cast<size_t>(frame.width()) * | 123 libyuv::I420ToABGR(buffer->DataY(), buffer->StrideY(), |
123 frame.height() * 4, | 124 buffer->DataU(), buffer->StrideU(), |
124 frame.width() * 4); | 125 buffer->DataV(), buffer->StrideV(), |
| 126 image_.get(), frame.width() * 4, |
| 127 buffer->width(), buffer->height()); |
125 } | 128 } |
126 | 129 |
127 // Trigger a repaint event for the whole window. | 130 // Trigger a repaint event for the whole window. |
128 Rect bounds; | 131 Rect bounds; |
129 InvalWindowRect(window_ref_, GetWindowPortBounds(window_ref_, &bounds)); | 132 InvalWindowRect(window_ref_, GetWindowPortBounds(window_ref_, &bounds)); |
130 return true; | 133 return true; |
131 } | 134 } |
132 | 135 |
133 bool CarbonVideoRenderer::Initialize() { | 136 bool CarbonVideoRenderer::Initialize() { |
134 OSStatus err; | 137 OSStatus err; |
(...skipping 29 matching lines...) Expand all Loading... |
164 if (err != noErr) { | 167 if (err != noErr) { |
165 LOG(LS_ERROR) << "Failed to install event handler, error code: " << err; | 168 LOG(LS_ERROR) << "Failed to install event handler, error code: " << err; |
166 return false; | 169 return false; |
167 } | 170 } |
168 SelectWindow(window_ref_); | 171 SelectWindow(window_ref_); |
169 ShowWindow(window_ref_); | 172 ShowWindow(window_ref_); |
170 return true; | 173 return true; |
171 } | 174 } |
172 | 175 |
173 } // namespace cricket | 176 } // namespace cricket |
OLD | NEW |