diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn index 0cdd80496c..16fa090e53 100644 --- a/webrtc/media/BUILD.gn +++ b/webrtc/media/BUILD.gn @@ -82,7 +82,6 @@ rtc_static_library("rtc_media") { "base/videoframe.h", "base/videosourcebase.cc", "base/videosourcebase.h", - "devices/videorendererfactory.h", "engine/nullwebrtcvideoengine.h", "engine/payload_type_mapper.cc", "engine/payload_type_mapper.h", @@ -163,17 +162,6 @@ rtc_static_library("rtc_media") { ] public_configs += [ ":gtk-lib" ] } - if (is_win) { - sources += [ - "devices/gdivideorenderer.cc", - "devices/gdivideorenderer.h", - ] - libs += [ - "d3d9.lib", - "gdi32.lib", - "strmiids.lib", - ] - } deps += [ "..:webrtc_common", "../api:call_api", diff --git a/webrtc/media/devices/gdivideorenderer.cc b/webrtc/media/devices/gdivideorenderer.cc deleted file mode 100644 index 92c692b394..0000000000 --- a/webrtc/media/devices/gdivideorenderer.cc +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// Implementation of GdiVideoRenderer on Windows - -#ifdef WIN32 - -#include "webrtc/media/devices/gdivideorenderer.h" - -#include "libyuv/convert_argb.h" -#include "webrtc/base/thread.h" -#include "webrtc/base/win32window.h" -#include "webrtc/media/engine/webrtcvideoframe.h" - -namespace cricket { - -///////////////////////////////////////////////////////////////////////////// -// Definition of private class VideoWindow. We use a worker thread to manage -// the window. -///////////////////////////////////////////////////////////////////////////// -class GdiVideoRenderer::VideoWindow : public rtc::Win32Window { - public: - VideoWindow(int x, int y, int width, int height); - virtual ~VideoWindow(); - - // Called when a new frame is available. Upon this call, we send - // kRenderFrameMsg to the window thread. Context: non-worker thread. It may be - // better to pass RGB bytes to VideoWindow. However, we pass VideoFrame to put - // all the thread synchronization within VideoWindow. - void OnFrame(const VideoFrame& frame); - - protected: - // Override virtual method of rtc::Win32Window. Context: worker Thread. - bool OnMessage(UINT uMsg, - WPARAM wParam, - LPARAM lParam, - LRESULT& result) override; - - private: - enum { kSetSizeMsg = WM_USER, kRenderFrameMsg}; - - // Called when the video size changes. If it is called the first time, we - // create and start the thread. Otherwise, we send kSetSizeMsg to the thread. - // Context: non-worker thread. - bool SetSize(int width, int height); - - class WindowThread : public rtc::Thread { - public: - explicit WindowThread(VideoWindow* window) : window_(window) {} - - virtual ~WindowThread() { - Stop(); - } - - // Override virtual method of rtc::Thread. Context: worker Thread. - virtual void Run() { - // Initialize the window - if (!window_ || !window_->Initialize()) { - return; - } - // Run the message loop - MSG msg; - while (GetMessage(&msg, NULL, 0, 0) > 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - private: - VideoWindow* window_; - }; - - // Context: worker Thread. - bool Initialize(); - void OnPaint(); - void OnSize(int width, int height, bool frame_changed); - void OnRenderFrame(const VideoFrame* frame); - - BITMAPINFO bmi_; - std::unique_ptr image_; - std::unique_ptr window_thread_; - // The initial position of the window. - int initial_x_; - int initial_y_; -}; - -///////////////////////////////////////////////////////////////////////////// -// Implementation of class VideoWindow -///////////////////////////////////////////////////////////////////////////// -GdiVideoRenderer::VideoWindow::VideoWindow( - int x, int y, int width, int height) - : initial_x_(x), - initial_y_(y) { - memset(&bmi_.bmiHeader, 0, sizeof(bmi_.bmiHeader)); - bmi_.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi_.bmiHeader.biPlanes = 1; - bmi_.bmiHeader.biBitCount = 32; - bmi_.bmiHeader.biCompression = BI_RGB; - bmi_.bmiHeader.biWidth = width; - bmi_.bmiHeader.biHeight = -height; - bmi_.bmiHeader.biSizeImage = width * height * 4; - - image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); -} - -GdiVideoRenderer::VideoWindow::~VideoWindow() { - // Context: caller Thread. We cannot call Destroy() since the window was - // created by another thread. Instead, we send WM_CLOSE message. - if (handle()) { - SendMessage(handle(), WM_CLOSE, 0, 0); - } -} - -bool GdiVideoRenderer::VideoWindow::SetSize(int width, int height) { - if (!window_thread_.get()) { - // Create and start the window thread. - window_thread_.reset(new WindowThread(this)); - return window_thread_->Start(); - } else if (width != bmi_.bmiHeader.biWidth || - height != -bmi_.bmiHeader.biHeight) { - SendMessage(handle(), kSetSizeMsg, 0, MAKELPARAM(width, height)); - } - return true; -} - -void GdiVideoRenderer::VideoWindow::OnFrame(const VideoFrame& video_frame) { - if (!handle()) { - return; - } - - const cricket::WebRtcVideoFrame frame( - webrtc::I420Buffer::Rotate(video_frame.video_frame_buffer(), - video_frame.rotation()), - webrtc::kVideoRotation_0, video_frame.timestamp_us()); - - if (SetSize(frame.width(), frame.height())) { - SendMessage(handle(), kRenderFrameMsg, reinterpret_cast(&frame), 0); - } -} - -bool GdiVideoRenderer::VideoWindow::OnMessage(UINT uMsg, WPARAM wParam, - LPARAM lParam, LRESULT& result) { - switch (uMsg) { - case WM_PAINT: - OnPaint(); - return true; - - case WM_DESTROY: - PostQuitMessage(0); // post WM_QUIT to end the message loop in Run() - return false; - - case WM_SIZE: // The window UI was resized. - OnSize(LOWORD(lParam), HIWORD(lParam), false); - return true; - - case kSetSizeMsg: // The video resolution changed. - OnSize(LOWORD(lParam), HIWORD(lParam), true); - return true; - - case kRenderFrameMsg: - OnRenderFrame(reinterpret_cast(wParam)); - return true; - } - return false; -} - -bool GdiVideoRenderer::VideoWindow::Initialize() { - if (!rtc::Win32Window::Create( - NULL, L"Video Renderer", - WS_OVERLAPPEDWINDOW | WS_SIZEBOX, - WS_EX_APPWINDOW, - initial_x_, initial_y_, - bmi_.bmiHeader.biWidth, -bmi_.bmiHeader.biHeight)) { - return false; - } - OnSize(bmi_.bmiHeader.biWidth, -bmi_.bmiHeader.biHeight, false); - return true; -} - -void GdiVideoRenderer::VideoWindow::OnPaint() { - RECT rcClient; - GetClientRect(handle(), &rcClient); - PAINTSTRUCT ps; - HDC hdc = BeginPaint(handle(), &ps); - StretchDIBits(hdc, - 0, 0, rcClient.right, rcClient.bottom, // destination rect - 0, 0, bmi_.bmiHeader.biWidth, -bmi_.bmiHeader.biHeight, // source rect - image_.get(), &bmi_, DIB_RGB_COLORS, SRCCOPY); - EndPaint(handle(), &ps); -} - -void GdiVideoRenderer::VideoWindow::OnSize(int width, int height, - bool frame_changed) { - // Get window and client sizes - RECT rcClient, rcWindow; - GetClientRect(handle(), &rcClient); - GetWindowRect(handle(), &rcWindow); - - // Find offset between window size and client size - POINT ptDiff; - ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; - ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; - - // Resize client - MoveWindow(handle(), rcWindow.left, rcWindow.top, - width + ptDiff.x, height + ptDiff.y, false); - UpdateWindow(handle()); - ShowWindow(handle(), SW_SHOW); - - if (frame_changed && (width != bmi_.bmiHeader.biWidth || - height != -bmi_.bmiHeader.biHeight)) { - // Update the bmi and image buffer - bmi_.bmiHeader.biWidth = width; - bmi_.bmiHeader.biHeight = -height; - bmi_.bmiHeader.biSizeImage = width * height * 4; - image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); - } -} - -void GdiVideoRenderer::VideoWindow::OnRenderFrame(const VideoFrame* frame) { - if (!frame) { - return; - } - // Convert frame to ARGB format, which is accepted by GDI - rtc::scoped_refptr buffer( - frame->video_frame_buffer()); - libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), - buffer->DataU(), buffer->StrideU(), - buffer->DataV(), buffer->StrideV(), - image_.get(), bmi_.bmiHeader.biWidth * 4, - buffer->width(), buffer->height()); - InvalidateRect(handle(), 0, 0); -} - -///////////////////////////////////////////////////////////////////////////// -// Implementation of class GdiVideoRenderer -///////////////////////////////////////////////////////////////////////////// -GdiVideoRenderer::GdiVideoRenderer(int x, int y) - : initial_x_(x), - initial_y_(y) { -} -GdiVideoRenderer::~GdiVideoRenderer() {} - -void GdiVideoRenderer::OnFrame(const VideoFrame& frame) { - if (!window_.get()) { // Create the window for the first frame - window_.reset( - new VideoWindow(initial_x_, initial_y_, frame.width(), frame.height())); - } - window_->OnFrame(frame); -} - -} // namespace cricket -#endif // WIN32 diff --git a/webrtc/media/devices/gdivideorenderer.h b/webrtc/media/devices/gdivideorenderer.h deleted file mode 100644 index eaf49ca26b..0000000000 --- a/webrtc/media/devices/gdivideorenderer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// Definition of class GdiVideoRenderer that implements the abstract class -// cricket::VideoRenderer via GDI on Windows. - -#ifndef WEBRTC_MEDIA_DEVICES_GDIVIDEORENDERER_H_ -#define WEBRTC_MEDIA_DEVICES_GDIVIDEORENDERER_H_ -#ifdef WIN32 - -#include - -// TODO(nisse): Temporarily; to be replaced with a forward declaration -// of webrtc::VideoFrame when dependency on cricket::VideoFrame is deleted. -#include "webrtc/media/base/videoframe.h" -#include "webrtc/media/base/videosinkinterface.h" - -namespace cricket { - -class GdiVideoRenderer : public rtc::VideoSinkInterface { - public: - GdiVideoRenderer(int x, int y); - virtual ~GdiVideoRenderer(); - - // Implementation of VideoSinkInterface - void OnFrame(const VideoFrame& frame) override; - - private: - class VideoWindow; // forward declaration, defined in the .cc file - std::unique_ptr window_; - // The initial position of the window. - int initial_x_; - int initial_y_; -}; - -} // namespace cricket - -#endif // WIN32 -#endif // WEBRTC_MEDIA_DEVICES_GDIVIDEORENDERER_H_ diff --git a/webrtc/media/devices/videorendererfactory.h b/webrtc/media/devices/videorendererfactory.h deleted file mode 100644 index bdc56861e8..0000000000 --- a/webrtc/media/devices/videorendererfactory.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// A factory to create a GUI video renderer. - -#ifndef WEBRTC_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_ -#define WEBRTC_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_ - -#include "webrtc/media/base/videosinkinterface.h" -#if defined(WEBRTC_LINUX) && defined(HAVE_GTK) -#include "webrtc/media/devices/gtkvideorenderer.h" -#elif defined(WIN32) -#include "webrtc/media/devices/gdivideorenderer.h" -#endif - -namespace cricket { - -class VideoRendererFactory { - public: - static rtc::VideoSinkInterface* CreateGuiVideoRenderer( - int x, - int y) { - #if defined(WEBRTC_LINUX) && defined(HAVE_GTK) - return new GtkVideoRenderer(x, y); - #elif defined(WIN32) - return new GdiVideoRenderer(x, y); - #else - return NULL; - #endif - } -}; - -} // namespace cricket - -#endif // WEBRTC_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_ diff --git a/webrtc/media/media.gyp b/webrtc/media/media.gyp index f022ffca81..40c3bce168 100644 --- a/webrtc/media/media.gyp +++ b/webrtc/media/media.gyp @@ -61,7 +61,6 @@ 'base/videoframe.h', 'base/videosourcebase.cc', 'base/videosourcebase.h', - 'devices/videorendererfactory.h', 'engine/nullwebrtcvideoengine.h', 'engine/payload_type_mapper.cc', 'engine/payload_type_mapper.h', @@ -150,21 +149,6 @@ '