jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 4 | * 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.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 11 | // Definition of class GtkVideoRenderer that implements the abstract class |
| 12 | // cricket::VideoRenderer via GTK. |
| 13 | |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 14 | #ifndef WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_ |
| 15 | #define WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 17 | #include <memory> |
| 18 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 19 | #include "webrtc/base/basictypes.h" |
nisse | 1509fa1 | 2016-03-23 04:05:57 -0700 | [diff] [blame] | 20 | #include "webrtc/media/base/videosinkinterface.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 21 | |
| 22 | typedef struct _GtkWidget GtkWidget; // forward declaration, defined in gtk.h |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 23 | namespace webrtc { |
| 24 | class VideoFrame; |
| 25 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 26 | |
| 27 | namespace cricket { |
| 28 | |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 29 | class GtkVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | public: |
| 31 | GtkVideoRenderer(int x, int y); |
| 32 | virtual ~GtkVideoRenderer(); |
| 33 | |
nisse | 1509fa1 | 2016-03-23 04:05:57 -0700 | [diff] [blame] | 34 | // Implementation of VideoSinkInterface. |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 35 | void OnFrame(const webrtc::VideoFrame& frame) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | |
| 37 | private: |
nisse | 1509fa1 | 2016-03-23 04:05:57 -0700 | [diff] [blame] | 38 | bool SetSize(int width, int height); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | // 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 | |
kwiberg | 686a8ef | 2016-02-26 03:00:35 -0800 | [diff] [blame] | 46 | std::unique_ptr<uint8_t[]> image_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | GtkWidget* window_; |
| 48 | GtkWidget* draw_area_; |
| 49 | // The initial position of the window. |
| 50 | int initial_x_; |
| 51 | int initial_y_; |
guoweis@webrtc.org | 00c509a | 2015-03-12 21:37:26 +0000 | [diff] [blame] | 52 | |
| 53 | int width_; |
| 54 | int height_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace cricket |
| 58 | |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 59 | #endif // WEBRTC_MEDIA_DEVICES_GTKVIDEORENDERER_H_ |