blob: 63a3ea900b1145d17e27dfc421f25d86c7046b6b [file] [log] [blame]
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00009 */
10
henrike@webrtc.org28e20752013-07-10 00:45:36 +000011// Definition of class GtkVideoRenderer that implements the abstract class
12// cricket::VideoRenderer via GTK.
13
kjellandera96e2d72016-02-04 23:52:28 -080014#ifndef WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_
15#define WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000016
kwiberg686a8ef2016-02-26 03:00:35 -080017#include <memory>
18
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000019#include "webrtc/base/basictypes.h"
nisse1509fa12016-03-23 04:05:57 -070020#include "webrtc/media/base/videosinkinterface.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000021
22typedef struct _GtkWidget GtkWidget; // forward declaration, defined in gtk.h
nisseacd935b2016-11-11 03:55:13 -080023namespace webrtc {
24class VideoFrame;
25}
henrike@webrtc.org28e20752013-07-10 00:45:36 +000026
27namespace cricket {
28
nisseacd935b2016-11-11 03:55:13 -080029class GtkVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030 public:
31 GtkVideoRenderer(int x, int y);
32 virtual ~GtkVideoRenderer();
33
nisse1509fa12016-03-23 04:05:57 -070034 // Implementation of VideoSinkInterface.
nisseacd935b2016-11-11 03:55:13 -080035 void OnFrame(const webrtc::VideoFrame& frame) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036
37 private:
nisse1509fa12016-03-23 04:05:57 -070038 bool SetSize(int width, int height);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 // Initialize the attributes when the first frame arrives.
40 bool Initialize(int width, int height);
41 // Pump the Gtk event loop until there are no events left.
42 void Pump();
43 // Check if the window has been closed.
44 bool IsClosed() const;
45
kwiberg686a8ef2016-02-26 03:00:35 -080046 std::unique_ptr<uint8_t[]> image_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047 GtkWidget* window_;
48 GtkWidget* draw_area_;
49 // The initial position of the window.
50 int initial_x_;
51 int initial_y_;
guoweis@webrtc.org00c509a2015-03-12 21:37:26 +000052
53 int width_;
54 int height_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055};
56
57} // namespace cricket
58
kjellandera96e2d72016-02-04 23:52:28 -080059#endif // WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_