Delete cricket::VideoRenderer.

TBR=glaznev@webrtc.org (deleting an #include in main_wnd.h)
BUG=webrtc:5426

Review URL: https://codereview.webrtc.org/1819103003

Cr-Commit-Position: refs/heads/master@{#12101}
This commit is contained in:
nisse 2016-03-23 04:05:57 -07:00 committed by Commit bot
parent de3185521b
commit 1509fa1aa9
14 changed files with 63 additions and 122 deletions

View File

@ -66,7 +66,6 @@
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/media/base/videocapturer.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/devices/videorendererfactory.h"
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"

View File

@ -26,7 +26,7 @@ class FakeVideoTrackRenderer
~FakeVideoTrackRenderer() { video_track_->RemoveSink(this); }
virtual void OnFrame(const cricket::VideoFrame& video_frame) override {
fake_renderer_.RenderFrame(&video_frame);
fake_renderer_.OnFrame(video_frame);
}
int errors() const { return fake_renderer_.errors(); }

View File

@ -21,7 +21,6 @@
#include "webrtc/media/base/mediachannel.h"
#include "webrtc/media/base/videocommon.h"
#include "webrtc/media/base/videoframe.h"
#include "webrtc/media/base/videorenderer.h"
class MainWndCallback {
public:

View File

@ -14,12 +14,12 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/media/base/videoframe.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosinkinterface.h"
namespace cricket {
// Faked video renderer that has a callback for actions on rendering.
class FakeVideoRenderer : public VideoRenderer {
class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
public:
FakeVideoRenderer()
: errors_(0),
@ -30,24 +30,18 @@ class FakeVideoRenderer : public VideoRenderer {
num_rendered_frames_(0),
black_frame_(false) {}
virtual bool RenderFrame(const VideoFrame* frame) {
virtual void OnFrame(const VideoFrame& frame) {
rtc::CritScope cs(&crit_);
// TODO(zhurunz) Check with VP8 team to see if we can remove this
// tolerance on Y values.
black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, frame);
black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, &frame);
// Treat unexpected frame size as error.
if (!frame) {
LOG(LS_WARNING) << "RenderFrame expected non-null frame.";
++errors_;
return false;
}
++num_rendered_frames_;
width_ = static_cast<int>(frame->GetWidth());
height_ = static_cast<int>(frame->GetHeight());
rotation_ = frame->GetVideoRotation();
timestamp_ = frame->GetTimeStamp();
SignalRenderFrame(frame);
return true;
width_ = static_cast<int>(frame.GetWidth());
height_ = static_cast<int>(frame.GetHeight());
rotation_ = frame.GetVideoRotation();
timestamp_ = frame.GetTimeStamp();
SignalRenderFrame(&frame);
}
int errors() const { return errors_; }

View File

@ -1,35 +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.
*/
#ifndef WEBRTC_MEDIA_BASE_VIDEORENDERER_H_
#define WEBRTC_MEDIA_BASE_VIDEORENDERER_H_
#include "webrtc/media/base/videosinkinterface.h"
namespace cricket {
class VideoFrame;
// Abstract interface for rendering VideoFrames.
class VideoRenderer : public rtc::VideoSinkInterface<VideoFrame> {
public:
virtual ~VideoRenderer() {}
// Called when a new frame is available for display.
virtual bool RenderFrame(const VideoFrame *frame) = 0;
// Intended to replace RenderFrame.
void OnFrame(const cricket::VideoFrame& frame) override {
// Unused return value
RenderFrame(&frame);
}
};
} // namespace cricket
#endif // WEBRTC_MEDIA_BASE_VIDEORENDERER_H_

View File

@ -92,7 +92,7 @@ bool CarbonVideoRenderer::DrawFrame() {
return true;
}
bool CarbonVideoRenderer::SetSize(int width, int height, int reserved) {
bool CarbonVideoRenderer::SetSize(int width, int height) {
if (width != image_width_ || height != image_height_) {
// Grab the image lock while changing its size.
rtc::CritScope cs(&image_crit_);
@ -104,10 +104,7 @@ bool CarbonVideoRenderer::SetSize(int width, int height, int reserved) {
return true;
}
bool CarbonVideoRenderer::RenderFrame(const VideoFrame* video_frame) {
if (!video_frame) {
return false;
}
void CarbonVideoRenderer::OnFrame(const VideoFrame& video_frame) {
{
const VideoFrame* frame = video_frame->GetCopyWithRotationApplied();

View File

@ -19,25 +19,24 @@
#include <Carbon/Carbon.h>
#include "webrtc/base/criticalsection.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosinkinterface.h"
namespace cricket {
class CarbonVideoRenderer : public VideoRenderer {
class CarbonVideoRenderer
: public rtc::VideoSinkInterface<cricket::VideoFrame> {
public:
CarbonVideoRenderer(int x, int y);
virtual ~CarbonVideoRenderer();
// Implementation of pure virtual methods of VideoRenderer.
// These two methods may be executed in different threads.
// SetSize is called before RenderFrame.
virtual bool SetSize(int width, int height, int reserved);
virtual bool RenderFrame(const VideoFrame* frame);
// Implementation of VideoSinkInterface.
void OnFrame(const VideoFrame& frame) override;
// Needs to be called on the main thread.
bool Initialize();
private:
bool SetSize(int width, int height);
bool DrawFrame();
static OSStatus DrawEventHandler(EventHandlerCallRef handler,

View File

@ -30,25 +30,27 @@ class GdiVideoRenderer::VideoWindow : public rtc::Win32Window {
VideoWindow(int x, int y, int width, int height);
virtual ~VideoWindow();
// 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);
// 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.
bool RenderFrame(const VideoFrame* frame);
void OnFrame(const VideoFrame& frame);
protected:
// Override virtual method of rtc::Win32Window. Context: worker Thread.
virtual bool OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,
LRESULT& result);
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) {}
@ -128,20 +130,17 @@ bool GdiVideoRenderer::VideoWindow::SetSize(int width, int height) {
return true;
}
bool GdiVideoRenderer::VideoWindow::RenderFrame(const VideoFrame* video_frame) {
void GdiVideoRenderer::VideoWindow::OnFrame(const VideoFrame& video_frame) {
if (!handle()) {
return false;
return;
}
const VideoFrame* frame = video_frame->GetCopyWithRotationApplied();
const VideoFrame* frame = video_frame.GetCopyWithRotationApplied();
if (!SetSize(static_cast<int>(frame->GetWidth()),
static_cast<int>(frame->GetHeight()))) {
return false;
if (SetSize(static_cast<int>(frame->GetWidth()),
static_cast<int>(frame->GetHeight()))) {
SendMessage(handle(), kRenderFrameMsg, reinterpret_cast<WPARAM>(frame), 0);
}
SendMessage(handle(), kRenderFrameMsg, reinterpret_cast<WPARAM>(frame), 0);
return true;
}
bool GdiVideoRenderer::VideoWindow::OnMessage(UINT uMsg, WPARAM wParam,
@ -243,18 +242,13 @@ GdiVideoRenderer::GdiVideoRenderer(int x, int y)
}
GdiVideoRenderer::~GdiVideoRenderer() {}
bool GdiVideoRenderer::SetSize(int width, int height, int reserved) {
if (!window_.get()) { // Create the window for the first frame
window_.reset(new VideoWindow(initial_x_, initial_y_, width, height));
void GdiVideoRenderer::OnFrame(const VideoFrame& frame) {
if (!window_.get()) { // Create the window for the first frame
window_.reset(new VideoWindow(initial_x_, initial_y_,
static_cast<int>(frame.GetWidth()),
static_cast<int>(frame.GetHeight())));
}
return window_->SetSize(width, height);
}
bool GdiVideoRenderer::RenderFrame(const VideoFrame* frame) {
if (!frame || !window_.get()) {
return false;
}
return window_->RenderFrame(frame);
window_->OnFrame(frame);
}
} // namespace cricket

View File

@ -18,20 +18,19 @@
#include <memory>
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosinkinterface.h"
namespace cricket {
class GdiVideoRenderer : public VideoRenderer {
class VideoFrame;
class GdiVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> {
public:
GdiVideoRenderer(int x, int y);
virtual ~GdiVideoRenderer();
// Implementation of pure virtual methods of VideoRenderer.
// These two methods may be executed in different threads.
// SetSize is called before RenderFrame.
virtual bool SetSize(int width, int height, int reserved);
virtual bool RenderFrame(const VideoFrame* frame);
// Implementation of VideoSinkInterface
void OnFrame(const VideoFrame& frame) override;
private:
class VideoWindow; // forward declaration, defined in the .cc file

View File

@ -59,7 +59,7 @@ GtkVideoRenderer::~GtkVideoRenderer() {
// implicitly destroyed by the above.
}
bool GtkVideoRenderer::SetSize(int width, int height, int reserved) {
bool GtkVideoRenderer::SetSize(int width, int height) {
ScopedGdkLock lock;
// If the dimension is the same, no-op.
@ -80,16 +80,12 @@ bool GtkVideoRenderer::SetSize(int width, int height, int reserved) {
return true;
}
bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) {
if (!video_frame) {
return false;
}
const VideoFrame* frame = video_frame->GetCopyWithRotationApplied();
void GtkVideoRenderer::OnFrame(const VideoFrame& video_frame) {
const VideoFrame* frame = video_frame.GetCopyWithRotationApplied();
// Need to set size as the frame might be rotated.
if (!SetSize(frame->GetWidth(), frame->GetHeight(), 0)) {
return false;
if (!SetSize(frame->GetWidth(), frame->GetHeight())) {
return;
}
// convert I420 frame to ABGR format, which is accepted by GTK
@ -101,7 +97,7 @@ bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) {
ScopedGdkLock lock;
if (IsClosed()) {
return false;
return;
}
// draw the ABGR image
@ -117,7 +113,6 @@ bool GtkVideoRenderer::RenderFrame(const VideoFrame* video_frame) {
// Run the Gtk main loop to refresh the window.
Pump();
return true;
}
bool GtkVideoRenderer::Initialize(int width, int height) {

View File

@ -17,24 +17,24 @@
#include <memory>
#include "webrtc/base/basictypes.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosinkinterface.h"
typedef struct _GtkWidget GtkWidget; // forward declaration, defined in gtk.h
namespace cricket {
class GtkVideoRenderer : public VideoRenderer {
class VideoFrame;
class GtkVideoRenderer : public rtc::VideoSinkInterface<VideoFrame> {
public:
GtkVideoRenderer(int x, int y);
virtual ~GtkVideoRenderer();
// Implementation of pure virtual methods of VideoRenderer.
// These two methods may be executed in different threads.
// SetSize is called before RenderFrame.
virtual bool SetSize(int width, int height, int reserved);
virtual bool RenderFrame(const VideoFrame* frame);
// Implementation of VideoSinkInterface.
void OnFrame(const VideoFrame& frame) override;
private:
bool SetSize(int width, int height);
// Initialize the attributes when the first frame arrives.
bool Initialize(int width, int height);
// Pump the Gtk event loop until there are no events left.

View File

@ -14,7 +14,7 @@
#ifndef WEBRTC_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_
#define WEBRTC_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosinkinterface.h"
#if defined(WEBRTC_LINUX) && defined(HAVE_GTK)
#include "webrtc/media/devices/gtkvideorenderer.h"
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && !defined(CARBON_DEPRECATED)
@ -27,7 +27,9 @@ namespace cricket {
class VideoRendererFactory {
public:
static VideoRenderer* CreateGuiVideoRenderer(int x, int y) {
static rtc::VideoSinkInterface<cricket::VideoFrame>* CreateGuiVideoRenderer(
int x,
int y) {
#if defined(WEBRTC_LINUX) && defined(HAVE_GTK)
return new GtkVideoRenderer(x, y);
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && \

View File

@ -22,7 +22,6 @@
#include "webrtc/base/trace_event.h"
#include "webrtc/call.h"
#include "webrtc/media/base/videocapturer.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/engine/constants.h"
#include "webrtc/media/engine/simulcast.h"
#include "webrtc/media/engine/webrtcmediaengine.h"

View File

@ -70,7 +70,6 @@
'base/videoframe.h',
'base/videoframefactory.cc',
'base/videoframefactory.h',
'base/videorenderer.h',
'base/videosourcebase.cc',
'base/videosourcebase.h',
'base/yuvframegenerator.cc',