# Gst::XOverlay Class Reference
[gstreamermm Interfaces]

An interface for setting/getting a Window on elements supporting it. More...

Inherits Glib::Interface.

Inherited by Gst::XImageSink, and Gst::XvImageSink.

Collaboration diagram for Gst::XOverlay:
[legend]

List of all members.

## Public Member Functions

virtual | ~XOverlay ()
GstXOverlay* | gobj ()
| Provides access to the underlying C GObject.
const GstXOverlay* | gobj () const
| Provides access to the underlying C GObject.
void | set_xwindow_id (gulong xwindow_id)
| This will call the video overlay's set_xwindow_id method.
void | got_xwindow_id (gulong xwindow_id)
| This will post a "have-xwindow-id" element message on the bus.
void | prepare_xwindow_id ()
| This will post a "prepare-xwindow-id" element message on the bus to give applications an opportunity to call gst_x_overlay_set_xwindow_id() before a plugin creates its own window.
void | expose ()
| Tell an overlay that it has been exposed.
void | handle_events (bool handle_events)
| Tell an overlay that it should handle events from the window system.
virtual void | set_xwindow_id_vfunc (gulong xwindow_id)
| Virtual method to configure the XWindow id.
virtual void | expose_vfunc ()
| Virtual method to handle expose events.
virtual void | handle_events_vfunc (bool handle_events)
| Virtual method to handle events.

## Static Public Member Functions

static void | add_interface (GType gtype_implementer)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gst::XOverlay > | wrap (GstXOverlay* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

An interface for setting/getting a Window on elements supporting it.

The XOverlay interface is used for 2 main purposes :

- To get a grab on the Window where the video sink element is going to render. This is achieved by either being informed about the Window identifier that the video sink element generated, or by forcing the video sink element to use a specific Window identifier for rendering.

- To force a redrawing of the latest video frame the video sink element displayed on the Window. Indeed if the Pipeline is in STATE_PAUSED state, moving the Window around will damage its content. Application developers will want to handle the Expose events themselves and force the video sink element to refresh the Window's content.

Using the Window created by the video sink is probably the simplest scenario, in some cases, though, it might not be flexible enough for application developers if they need to catch events such as mouse moves and button clicks.

Setting a specific Window identifier on the video sink element is the most flexible solution but it has some issues. Indeed the application needs to set its Window identifier at the right time to avoid internal Window creation from the video sink element. To solve this issue a Message is posted on the bus to inform the application that it should set the Window identifier immediately. Here is an example on how to do that correctly:

     #include <gdk/gdkx.h>
     ...
     void PlayerWindow::on_bus_message_sync(
         const Glib::RefPtr<Gst::Message>& message)
     {
       // ignore anything but 'prepare-xwindow-id' element messages
       if(message->get_message_type() != Gst::MESSAGE_ELEMENT)
        return;

       if(!message->get_structure().has_name("prepare-xwindow-id"))
          return;

       Glib::RefPtr<Gst::Element> element =
           Glib::RefPtr<Gst::Element>::cast_dynamic(message->get_source());

       Glib::RefPtr< Gst::ElementInterfaced<Gst::XOverlay> > xoverlay =
           Gst::Interface::cast <Gst::XOverlay>(element);

       if(xoverlay)
       {
         const gulong xWindowId =
         GDK_WINDOW_XID(widget->get_window()->gobj());
         xoverlay->set_xwindow_id(xWindowId);
       }
     }
     ...
     int main (int argc, char *argv[])
     {
       ...
       // Get the bus from the pipeline:
       Glib::RefPtr<Gst::Bus> bus = pipeline->get_bus();

      // Enable synchronous message emission:
      bus->enable_sync_message_emission();

      // Connect to bus's synchronous message signal:
      bus->signal_sync_message().connect(
        sigc::mem_fun(*this, &PlayerWindow::on_bus_message_sync));
       ...
     }

## Constructor & Destructor Documentation

virtual Gst::XOverlay::~XOverlay | ( |  | ) | `[virtual]`

## Member Function Documentation

static void Gst::XOverlay::add_interface | ( | GType | gtype_implementer | ) | `[static]`

void Gst::XOverlay::expose | ( |  | ) |

Tell an overlay that it has been exposed.

This will redraw the current frame in the drawable even if the pipeline is PAUSED.

virtual void Gst::XOverlay::expose_vfunc | ( |  | ) | `[virtual]`

Virtual method to handle expose events.

GstXOverlay* Gst::XOverlay::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

Reimplemented in Gst::XImageSink.

const GstXOverlay* Gst::XOverlay::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

Reimplemented in Gst::XImageSink.

void Gst::XOverlay::got_xwindow_id | ( | gulong | xwindow_id | ) |

This will post a "have-xwindow-id" element message on the bus.

This function should only be used by video overlay plugin developers.

Parameters:

  | xwindow_id | A X::ID referencing the XWindow.

void Gst::XOverlay::handle_events | ( | bool | handle_events | ) |

Tell an overlay that it should handle events from the window system.

These events are forwared upstream as navigation events. In some window system, events are not propagated in the window hierarchy if a client is listening for them. This method allows you to disable events handling completely from the XOverlay.

Since gstreamermm 0.10:
  .12

Parameters:

  | handle_events | A `bool` indicating if events should be handled or not.

virtual void Gst::XOverlay::handle_events_vfunc | ( | bool | handle_events | ) | `[virtual]`

Virtual method to handle events.

void Gst::XOverlay::prepare_xwindow_id | ( |  | ) |

This will post a "prepare-xwindow-id" element message on the bus to give applications an opportunity to call gst_x_overlay_set_xwindow_id() before a plugin creates its own window.

This function should only be used by video overlay plugin developers.

void Gst::XOverlay::set_xwindow_id | ( | gulong | xwindow_id | ) |

This will call the video overlay's set_xwindow_id method.

You should use this method to tell to a XOverlay to display video output to a specific XWindow. Passing 0 as the xwindow_id will tell the overlay to stop using that window and create an internal one.

Parameters:

  | xwindow_id | A X::ID referencing the XWindow.

virtual void Gst::XOverlay::set_xwindow_id_vfunc | ( | gulong | xwindow_id | ) | `[virtual]`

Virtual method to configure the XWindow id.

## Friends And Related Function Documentation

Glib::RefPtr< Gst::XOverlay > wrap | ( | GstXOverlay * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gstreamermm/xoverlay.h