Delete videorendererfactory.h and cricket::GdiVideoRenderer.

Ultimately, all of webrtc/media/devices should be deleted, since it is
unused in webrtc and has no unit tests. But for the time being we
need to keep cricket::GtkVideoRenderer since there are a few
applications depending on it.

BUG=webrtc:5924

Review-Url: https://codereview.webrtc.org/2460793002
Cr-Commit-Position: refs/heads/master@{#14835}
This commit is contained in:
nisse 2016-10-31 00:59:47 -07:00 committed by Commit bot
parent 18b8774792
commit a144be384f
5 changed files with 0 additions and 378 deletions

View File

@ -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",

View File

@ -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<uint8_t[]> image_;
std::unique_ptr<WindowThread> 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<WPARAM>(&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<const VideoFrame*>(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<webrtc::VideoFrameBuffer> 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

View File

@ -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 <memory>
// 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<cricket::VideoFrame> {
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<VideoWindow> window_;
// The initial position of the window.
int initial_x_;
int initial_y_;
};
} // namespace cricket
#endif // WIN32
#endif // WEBRTC_MEDIA_DEVICES_GDIVIDEORENDERER_H_

View File

@ -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<cricket::VideoFrame>* 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_

View File

@ -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 @@
'<!@(pkg-config --cflags gobject-2.0 gthread-2.0 gtk+-2.0)',
],
}],
['OS=="win"', {
'sources': [
'devices/gdivideorenderer.cc',
'devices/gdivideorenderer.h',
],
'msvs_settings': {
'VCLibrarianTool': {
'AdditionalDependencies': [
'd3d9.lib',
'gdi32.lib',
'strmiids.lib',
],
},
},
}],
],
}, # target rtc_media
], # targets.