| 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/base/videoframe.h" |   20 #include "webrtc/media/base/videoframe.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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  219     bmi_.bmiHeader.biSizeImage = width * height * 4; |  219     bmi_.bmiHeader.biSizeImage = width * height * 4; | 
|  220     image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); |  220     image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); | 
|  221   } |  221   } | 
|  222 } |  222 } | 
|  223  |  223  | 
|  224 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { |  224 void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { | 
|  225   if (!frame) { |  225   if (!frame) { | 
|  226     return; |  226     return; | 
|  227   } |  227   } | 
|  228   // Convert frame to ARGB format, which is accepted by GDI |  228   // Convert frame to ARGB format, which is accepted by GDI | 
|  229   frame->ConvertToRgbBuffer(cricket::FOURCC_ARGB, image_.get(), |  229   rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer( | 
|  230                             bmi_.bmiHeader.biSizeImage, |  230       frame->video_frame_buffer()); | 
|  231                             bmi_.bmiHeader.biWidth * 4); |  231   libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), | 
 |  232                      buffer->DataU(), buffer->StrideU(), | 
 |  233                      buffer->DataV(), buffer->StrideV(), | 
 |  234                      image_.get(), bmi_.bmiHeader.biWidth * 4, | 
 |  235                      buffer->width(), buffer->height()); | 
|  232   InvalidateRect(handle(), 0, 0); |  236   InvalidateRect(handle(), 0, 0); | 
|  233 } |  237 } | 
|  234  |  238  | 
|  235 ///////////////////////////////////////////////////////////////////////////// |  239 ///////////////////////////////////////////////////////////////////////////// | 
|  236 // Implementation of class GdiVideoRenderer |  240 // Implementation of class GdiVideoRenderer | 
|  237 ///////////////////////////////////////////////////////////////////////////// |  241 ///////////////////////////////////////////////////////////////////////////// | 
|  238 GdiVideoRenderer::GdiVideoRenderer(int x, int y) |  242 GdiVideoRenderer::GdiVideoRenderer(int x, int y) | 
|  239     : initial_x_(x), |  243     : initial_x_(x), | 
|  240       initial_y_(y) { |  244       initial_y_(y) { | 
|  241 } |  245 } | 
|  242 GdiVideoRenderer::~GdiVideoRenderer() {} |  246 GdiVideoRenderer::~GdiVideoRenderer() {} | 
|  243  |  247  | 
|  244 void GdiVideoRenderer::OnFrame(const VideoFrame& frame) { |  248 void GdiVideoRenderer::OnFrame(const VideoFrame& frame) { | 
|  245   if (!window_.get()) { // Create the window for the first frame |  249   if (!window_.get()) { // Create the window for the first frame | 
|  246     window_.reset( |  250     window_.reset( | 
|  247         new VideoWindow(initial_x_, initial_y_, frame.width(), frame.height())); |  251         new VideoWindow(initial_x_, initial_y_, frame.width(), frame.height())); | 
|  248   } |  252   } | 
|  249   window_->OnFrame(frame); |  253   window_->OnFrame(frame); | 
|  250 } |  254 } | 
|  251  |  255  | 
|  252 }  // namespace cricket |  256 }  // namespace cricket | 
|  253 #endif  // WIN32 |  257 #endif  // WIN32 | 
| OLD | NEW |