Remove dead code for GtkVideoRenderer.
Pulls in unnecessary GTK dependencies that breaks the chromium GTK3 build. This removes the last of webrtc/media/devices. BUG=chromium:668446 Review-Url: https://codereview.webrtc.org/2646793008 Cr-Commit-Position: refs/heads/master@{#16198}
This commit is contained in:
parent
f33491ebaf
commit
2197e91860
@ -32,16 +32,6 @@ config("rtc_media_warnings_config") {
|
||||
}
|
||||
}
|
||||
|
||||
if (is_linux && rtc_use_gtk) {
|
||||
pkg_config("gtk-lib") {
|
||||
packages = [
|
||||
"gobject-2.0",
|
||||
"gthread-2.0",
|
||||
"gtk+-2.0",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_static_library("rtc_media_base") {
|
||||
defines = []
|
||||
libs = []
|
||||
@ -198,13 +188,6 @@ rtc_static_library("rtc_media") {
|
||||
public_configs += [ ":rtc_media_defines_config" ]
|
||||
deps += [ "../modules/video_capture:video_capture_internal_impl" ]
|
||||
}
|
||||
if (is_linux && rtc_use_gtk) {
|
||||
sources += [
|
||||
"devices/gtkvideorenderer.cc",
|
||||
"devices/gtkvideorenderer.h",
|
||||
]
|
||||
public_configs += [ ":gtk-lib" ]
|
||||
}
|
||||
deps += [
|
||||
":rtc_media_base",
|
||||
"..:webrtc_common",
|
||||
|
||||
@ -1,163 +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 GtkVideoRenderer
|
||||
|
||||
#include "webrtc/api/video/i420_buffer.h"
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/media/devices/gtkvideorenderer.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libyuv/convert_argb.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class ScopedGdkLock {
|
||||
public:
|
||||
ScopedGdkLock() {
|
||||
gdk_threads_enter();
|
||||
}
|
||||
|
||||
~ScopedGdkLock() {
|
||||
gdk_threads_leave();
|
||||
}
|
||||
};
|
||||
|
||||
GtkVideoRenderer::GtkVideoRenderer(int x, int y)
|
||||
: window_(NULL),
|
||||
draw_area_(NULL),
|
||||
initial_x_(x),
|
||||
initial_y_(y),
|
||||
width_(0),
|
||||
height_(0) {
|
||||
g_type_init();
|
||||
// g_thread_init API is deprecated since glib 2.31.0, see release note:
|
||||
// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html
|
||||
#if !GLIB_CHECK_VERSION(2, 31, 0)
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
gdk_threads_init();
|
||||
}
|
||||
|
||||
GtkVideoRenderer::~GtkVideoRenderer() {
|
||||
if (window_) {
|
||||
ScopedGdkLock lock;
|
||||
gtk_widget_destroy(window_);
|
||||
// Run the Gtk main loop to tear down the window.
|
||||
Pump();
|
||||
}
|
||||
// Don't need to destroy draw_area_ because it is not top-level, so it is
|
||||
// implicitly destroyed by the above.
|
||||
}
|
||||
|
||||
bool GtkVideoRenderer::SetSize(int width, int height) {
|
||||
ScopedGdkLock lock;
|
||||
|
||||
// If the dimension is the same, no-op.
|
||||
if (width_ == width && height_ == height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// For the first frame, initialize the GTK window
|
||||
if ((!window_ && !Initialize(width, height)) || IsClosed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
image_.reset(new uint8_t[width * height * 4]);
|
||||
gtk_widget_set_size_request(draw_area_, width, height);
|
||||
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GtkVideoRenderer::OnFrame(const webrtc::VideoFrame& video_frame) {
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
|
||||
video_frame.video_frame_buffer());
|
||||
if (video_frame.rotation() != webrtc::kVideoRotation_0) {
|
||||
buffer = webrtc::I420Buffer::Rotate(*buffer, video_frame.rotation());
|
||||
}
|
||||
|
||||
// Need to set size as the frame might be rotated.
|
||||
if (!SetSize(buffer->width(), buffer->height())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// convert I420 frame to ABGR format, which is accepted by GTK
|
||||
libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(),
|
||||
buffer->DataU(), buffer->StrideU(),
|
||||
buffer->DataV(), buffer->StrideV(),
|
||||
image_.get(), buffer->width() * 4,
|
||||
buffer->width(), buffer->height());
|
||||
|
||||
ScopedGdkLock lock;
|
||||
|
||||
if (IsClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// draw the ABGR image
|
||||
gdk_draw_rgb_32_image(draw_area_->window,
|
||||
draw_area_->style->fg_gc[GTK_STATE_NORMAL],
|
||||
0,
|
||||
0,
|
||||
buffer->width(),
|
||||
buffer->height(),
|
||||
GDK_RGB_DITHER_MAX,
|
||||
image_.get(),
|
||||
buffer->width() * 4);
|
||||
|
||||
// Run the Gtk main loop to refresh the window.
|
||||
Pump();
|
||||
}
|
||||
|
||||
bool GtkVideoRenderer::Initialize(int width, int height) {
|
||||
gtk_init(NULL, NULL);
|
||||
window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
draw_area_ = gtk_drawing_area_new();
|
||||
if (!window_ || !draw_area_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gtk_window_set_position(GTK_WINDOW(window_), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_title(GTK_WINDOW(window_), "Video Renderer");
|
||||
gtk_window_set_resizable(GTK_WINDOW(window_), FALSE);
|
||||
gtk_widget_set_size_request(draw_area_, width, height);
|
||||
gtk_container_add(GTK_CONTAINER(window_), draw_area_);
|
||||
gtk_widget_show_all(window_);
|
||||
gtk_window_move(GTK_WINDOW(window_), initial_x_, initial_y_);
|
||||
|
||||
image_.reset(new uint8_t[width * height * 4]);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GtkVideoRenderer::Pump() {
|
||||
while (gtk_events_pending()) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
}
|
||||
|
||||
bool GtkVideoRenderer::IsClosed() const {
|
||||
if (!window_) {
|
||||
// Not initialized yet, so hasn't been closed.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GTK_IS_WINDOW(window_) || !GTK_IS_DRAWING_AREA(draw_area_)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
@ -1,60 +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 GtkVideoRenderer that implements the abstract class
|
||||
// cricket::VideoRenderer via GTK.
|
||||
|
||||
#ifndef WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_
|
||||
#define WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/media/base/videosinkinterface.h"
|
||||
|
||||
typedef struct _GtkWidget GtkWidget; // forward declaration, defined in gtk.h
|
||||
namespace webrtc {
|
||||
class VideoFrame;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class GtkVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
public:
|
||||
GtkVideoRenderer(int x, int y);
|
||||
virtual ~GtkVideoRenderer();
|
||||
|
||||
// Implementation of VideoSinkInterface.
|
||||
void OnFrame(const webrtc::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.
|
||||
void Pump();
|
||||
// Check if the window has been closed.
|
||||
bool IsClosed() const;
|
||||
|
||||
std::unique_ptr<uint8_t[]> image_;
|
||||
GtkWidget* window_;
|
||||
GtkWidget* draw_area_;
|
||||
// The initial position of the window.
|
||||
int initial_x_;
|
||||
int initial_y_;
|
||||
|
||||
int width_;
|
||||
int height_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_
|
||||
Loading…
x
Reference in New Issue
Block a user