| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 GdiVideoRenderer on Windows | 11 // Implementation of GdiVideoRenderer on Windows |
| 12 | 12 |
| 13 #ifdef WIN32 | 13 #ifdef WIN32 |
| 14 | 14 |
| 15 #include "webrtc/media/devices/gdivideorenderer.h" | 15 #include "webrtc/media/devices/gdivideorenderer.h" |
| 16 | 16 |
| 17 #include "libyuv/convert_argb.h" |
| 17 #include "webrtc/base/thread.h" | 18 #include "webrtc/base/thread.h" |
| 18 #include "webrtc/base/win32window.h" | 19 #include "webrtc/base/win32window.h" |
| 19 #include "webrtc/media/base/videocommon.h" | |
| 20 #include "webrtc/media/engine/webrtcvideoframe.h" | 20 #include "webrtc/media/engine/webrtcvideoframe.h" |
| 21 | 21 |
| 22 namespace cricket { | 22 namespace cricket { |
| 23 | 23 |
| 24 ///////////////////////////////////////////////////////////////////////////// | 24 ///////////////////////////////////////////////////////////////////////////// |
| 25 // Definition of private class VideoWindow. We use a worker thread to manage | 25 // Definition of private class VideoWindow. We use a worker thread to manage |
| 26 // the window. | 26 // the window. |
| 27 ///////////////////////////////////////////////////////////////////////////// | 27 ///////////////////////////////////////////////////////////////////////////// |
| 28 class GdiVideoRenderer::VideoWindow : public rtc::Win32Window { | 28 class GdiVideoRenderer::VideoWindow : public rtc::Win32Window { |
| 29 public: | 29 public: |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 bmi_.bmiHeader.biSizeImage = width * height * 4; | 222 bmi_.bmiHeader.biSizeImage = width * height * 4; |
| 223 image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); | 223 image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { | 227 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { |
| 228 if (!frame) { | 228 if (!frame) { |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 // Convert frame to ARGB format, which is accepted by GDI | 231 // Convert frame to ARGB format, which is accepted by GDI |
| 232 frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, image_.get(), | 232 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( |
| 233 bmi_.bmiHeader.biSizeImage, | 233 frame->video_frame_buffer()); |
| 234 bmi_.bmiHeader.biWidth * 4); | 234 libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), |
| 235 buffer->DataU(), buffer->StrideU(), |
| 236 buffer->DataV(), buffer->StrideV(), |
| 237 image_.get(), bmi_.bmiHeader.biWidth * 4, |
| 238 buffer->width(), buffer->height()); |
| 235 InvalidateRect(handle(), 0, 0); | 239 InvalidateRect(handle(), 0, 0); |
| 236 } | 240 } |
| 237 | 241 |
| 238 ///////////////////////////////////////////////////////////////////////////// | 242 ///////////////////////////////////////////////////////////////////////////// |
| 239 // Implementation of class GdiVideoRenderer | 243 // Implementation of class GdiVideoRenderer |
| 240 ///////////////////////////////////////////////////////////////////////////// | 244 ///////////////////////////////////////////////////////////////////////////// |
| 241 GdiVideoRenderer::GdiVideoRenderer(int x, int y) | 245 GdiVideoRenderer::GdiVideoRenderer(int x, int y) |
| 242 : initial_x_(x), | 246 : initial_x_(x), |
| 243 initial_y_(y) { | 247 initial_y_(y) { |
| 244 } | 248 } |
| 245 GdiVideoRenderer::~GdiVideoRenderer() {} | 249 GdiVideoRenderer::~GdiVideoRenderer() {} |
| 246 | 250 |
| 247 void GdiVideoRenderer::OnFrame(const VideoFrame& frame) { | 251 void GdiVideoRenderer::OnFrame(const VideoFrame& frame) { |
| 248 if (!window_.get()) { // Create the window for the first frame | 252 if (!window_.get()) { // Create the window for the first frame |
| 249 window_.reset( | 253 window_.reset( |
| 250 new VideoWindow(initial_x_, initial_y_, frame.width(), frame.height())); | 254 new VideoWindow(initial_x_, initial_y_, frame.width(), frame.height())); |
| 251 } | 255 } |
| 252 window_->OnFrame(frame); | 256 window_->OnFrame(frame); |
| 253 } | 257 } |
| 254 | 258 |
| 255 } // namespace cricket | 259 } // namespace cricket |
| 256 #endif // WIN32 | 260 #endif // WIN32 |
| OLD | NEW |