Debian Codegraph @

gstreamer/src/videooverlay.hg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gst/video/videooverlay.h>
21 #include <glibmm/interface.h>
22
23 _DEFS(gstreamermm,gst)
24
25 namespace Gst
26 {
27
28 /** An interface for setting/getting a Window on elements supporting it.
29 * The VideoOverlay interface is used for 2 main purposes :
30 *
31 * - To get a grab on the Window where the video sink element is going to
32 * render. This is achieved by either being informed about the Window
33 * identifier that the video sink element generated, or by forcing the video
34 * sink element to use a specific Window identifier for rendering.
35 *
36 * - To force a redrawing of the latest video frame the video sink element
37 * displayed on the Window. Indeed if the Pipeline is in STATE_PAUSED state,
38 * moving the Window around will damage its content. Application developers
39 * will want to handle the Expose events themselves and force the video sink
40 * element to refresh the Window's content.
41 *
42 * Using the Window created by the video sink is probably the simplest
43 * scenario, in some cases, though, it might not be flexible enough for
44 * application developers if they need to catch events such as mouse moves and
45 * button clicks.
46 *
47 * Setting a specific Window identifier on the video sink element is the most
48 * flexible solution but it has some issues. Indeed the application needs to
49 * set its Window identifier at the right time to avoid internal Window
50 * creation from the video sink element. To solve this issue a Message is
51 * posted on the bus to inform the application that it should set the Window
52 * identifier immediately. Here is an example on how to do that correctly:
53 *
54 * @code
55 * #include <gdk/gdkx.h>
56 * ...
57 * void PlayerWindow::on_bus_message_sync(
58 * const Glib::RefPtr<Gst::Message>& message)
59 * {
60 * // ignore anything but 'prepare-xwindow-id' element messages
61 * if(message->get_message_type() != Gst::MESSAGE_ELEMENT)
62 * return;
63 *
64 * if(!message->get_structure().has_name("prepare-xwindow-id"))
65 * return;
66 *
67 * Glib::RefPtr<Gst::Element> element =
68 * Glib::RefPtr<Gst::Element>::cast_dynamic(message->get_source());
69 *
70 * Glib::RefPtr< Gst::ElementInterfaced<Gst::XOverlay> > xoverlay =
71 * Gst::Interface::cast <Gst::XOverlay>(element);
72 *
73 * if(xoverlay)
74 * {
75 * const gulong xWindowId =
76 * GDK_WINDOW_XID(widget->get_window()->gobj());
77 * xoverlay->set_xwindow_id(xWindowId);
78 * }
79 * }
80 * ...
81 * int main (int argc, char *argv[])
82 * {
83 * ...
84 * // Get the bus from the pipeline:
85 * Glib::RefPtr<Gst::Bus> bus = pipeline->get_bus();
86 *
87 * // Enable synchronous message emission:
88 * bus->enable_sync_message_emission();
89 *
90 * // Connect to bus's synchronous message signal:
91 * bus->signal_sync_message().connect(
92 * sigc::mem_fun(*this, &PlayerWindow::on_bus_message_sync));
93 * ...
94 * }
95 * @endcode
96 * @ingroup GstInterfaces
97 */
98 class VideoOverlay : public Glib::Interface
99 {
100 _CLASS_INTERFACE(VideoOverlay, GstVideoOverlay, GST_VIDEO_OVERLAY, GstVideoOverlayInterface)
101
102 public:
103 _WRAP_METHOD(void set_window_handle(guintptr window_handle), gst_video_overlay_set_window_handle)
104 _WRAP_METHOD(void got_window_handle(guintptr window_handle), gst_video_overlay_got_window_handle)
105 _WRAP_METHOD(void prepare_window_handle(), gst_video_overlay_prepare_window_handle)
106 _WRAP_METHOD(void expose(), gst_video_overlay_expose)
107 _WRAP_METHOD(void handle_events(bool handle_events), gst_video_overlay_handle_events)
108 _WRAP_METHOD(bool set_render_rectangle(int x, int y, int width, int height), gst_video_overlay_set_render_rectangle)
109
110 /** Virtual method to configure the window handle.
111 */
112 _WRAP_VFUNC(void set_window_handle(guintptr handle), "set_window_handle")
113
114 /** Virtual method to handle expose events.
115 */
116 _WRAP_VFUNC(void expose(), "expose")
117
118 /** Virtual method to handle events.
119 */
120 _WRAP_VFUNC(void handle_events(bool handle_events), "handle_events")
121
122 /** Virtual method to set the render rectangle.
123 */
124 _WRAP_VFUNC(void set_render_rectangle(int x, int y, int width, int height), "set_render_rectangle")
125
126 };
127
128 } // namespace Gst
129