Gst.DeviceMonitor

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gst.DeviceMonitor Gst.DeviceMonitor Gst.Object->Gst.DeviceMonitor

Subclasses:

None

Methods

Inherited:

Gst.Object (27), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_filter (classes, caps)

get_bus ()

get_devices ()

get_providers ()

get_show_all_devices ()

remove_filter (filter_id)

set_show_all_devices (show_all)

start ()

stop ()

Virtual Methods

Inherited:

Gst.Object (1), GObject.Object (7)

Properties

Inherited:

Gst.Object (2)

Name

Type

Flags

Short Description

show-all

bool

r/w

Show all devices, even those from hidden providers

Signals

Inherited:

Gst.Object (1), GObject.Object (1)

Fields

Inherited:

Gst.Object (1), GObject.Object (1)

Name

Type

Access

Description

parent

Gst.Object

r

the parent Gst.Object structure

Class Details

class Gst.DeviceMonitor(**kwargs)
Bases:

Gst.Object

Abstract:

No

Structure:

Gst.DeviceMonitorClass

Applications should create a Gst.DeviceMonitor when they want to probe, list and monitor devices of a specific type. The Gst.DeviceMonitor will create the appropriate Gst.DeviceProvider objects and manage them. It will then post messages on its Gst.Bus for devices that have been added and removed.

The device monitor will monitor all devices matching the filters that the application has set.

The basic use pattern of a device monitor is as follows:

static gboolean
my_bus_func (GstBus * bus, GstMessage * message, gpointer user_data)
{
   GstDevice *device;
   gchar *name;

   switch (GST_MESSAGE_TYPE (message)) {
     case GST_MESSAGE_DEVICE_ADDED:
       gst_message_parse_device_added (message, &device);
       name = gst_device_get_display_name (device);
       g_print("Device added: %s\n", name);
       g_free (name);
       gst_object_unref (device);
       break;
     case GST_MESSAGE_DEVICE_REMOVED:
       gst_message_parse_device_removed (message, &device);
       name = gst_device_get_display_name (device);
       g_print("Device removed: %s\n", name);
       g_free (name);
       gst_object_unref (device);
       break;
     default:
       break;
   }

   return G_SOURCE_CONTINUE;
}

GstDeviceMonitor *
setup_raw_video_source_device_monitor (void) {
   GstDeviceMonitor *monitor;
   GstBus *bus;
   GstCaps *caps;

   monitor = gst_device_monitor_new ();

   bus = gst_device_monitor_get_bus (monitor);
   gst_bus_add_watch (bus, my_bus_func, NULL);
   gst_object_unref (bus);

   caps = gst_caps_new_empty_simple ("video/x-raw");
   gst_device_monitor_add_filter (monitor, "Video/Source", caps);
   gst_caps_unref (caps);

   gst_device_monitor_start (monitor);

   return monitor;
}

New in version 1.4.

classmethod new()[source]
Returns:

a new device monitor.

Return type:

Gst.DeviceMonitor

Create a new Gst.DeviceMonitor

New in version 1.4.

add_filter(classes, caps)[source]
Parameters:
Returns:

The id of the new filter or 0 if no provider matched the filter’s classes.

Return type:

int

Adds a filter for which Gst.Device will be monitored, any device that matches all these classes and the Gst.Caps will be returned.

If this function is called multiple times to add more filters, each will be matched independently. That is, adding more filters will not further restrict what devices are matched.

The Gst.Caps supported by the device as returned by Gst.Device.get_caps() are not intersected with caps filters added using this function.

Filters must be added before the Gst.DeviceMonitor is started.

New in version 1.4.

get_bus()[source]
Returns:

a Gst.Bus

Return type:

Gst.Bus

Gets the Gst.Bus of this Gst.DeviceMonitor

New in version 1.4.

get_devices()[source]
Returns:

a GLib.List of Gst.Device

Return type:

[Gst.Device] or None

Gets a list of devices from all of the relevant monitors. This may actually probe the hardware if the monitor is not currently started.

New in version 1.4.

get_providers()[source]
Returns:

A list of device provider factory names that are currently being monitored by self or None when nothing is being monitored.

Return type:

[str]

Get a list of the currently selected device provider factories.

This

New in version 1.6.

get_show_all_devices()[source]
Returns:

True when all devices will be shown.

Return type:

bool

Get if self is currently showing all devices, even those from hidden providers.

New in version 1.6.

remove_filter(filter_id)[source]
Parameters:

filter_id (int) – the id of the filter

Returns:

True of the filter id was valid, False otherwise

Return type:

bool

Removes a filter from the Gst.DeviceMonitor using the id that was returned by Gst.DeviceMonitor.add_filter().

New in version 1.4.

set_show_all_devices(show_all)[source]
Parameters:

show_all (bool) – show all devices

Set if all devices should be visible, even those devices from hidden providers. Setting show_all to true might show some devices multiple times.

New in version 1.6.

start()[source]
Returns:

True if the device monitoring could be started, i.e. at least a single device provider was started successfully.

Return type:

bool

Starts monitoring the devices, one this has succeeded, the Gst.MessageType.DEVICE_ADDED and Gst.MessageType.DEVICE_REMOVED messages will be emitted on the bus when the list of devices changes.

New in version 1.4.

stop()[source]

Stops monitoring the devices.

New in version 1.4.

Property Details

Gst.DeviceMonitor.props.show_all
Name:

show-all

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Show all devices, even those from hidden providers