Top |
Description
Applications should create a GstDeviceMonitor when they want to probe, list and monitor devices of a specific type. The GstDeviceMonitor will create the appropriate GstDeviceProvider objects and manage them. It will then post messages on its GstBus 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
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); 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); 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; } |
Functions
gst_device_monitor_new ()
GstDeviceMonitor *
gst_device_monitor_new (void
);
Create a new GstDeviceMonitor
Since 1.4
gst_device_monitor_get_bus ()
GstBus *
gst_device_monitor_get_bus (GstDeviceMonitor *monitor
);
Gets the GstBus of this GstDeviceMonitor
Since 1.4
gst_device_monitor_add_filter ()
guint gst_device_monitor_add_filter (GstDeviceMonitor *monitor
,const gchar *classes
,GstCaps *caps
);
Adds a filter for which GstDevice will be monitored, any device that matches all classes and the GstCaps will be returned.
Filters must be added before the GstDeviceMonitor is started.
Since 1.4
gst_device_monitor_remove_filter ()
gboolean gst_device_monitor_remove_filter (GstDeviceMonitor *monitor
,guint filter_id
);
Removes a filter from the GstDeviceMonitor using the id that was returned
by gst_device_monitor_add_filter()
.
Since 1.4
gst_device_monitor_start ()
gboolean
gst_device_monitor_start (GstDeviceMonitor *monitor
);
Starts monitoring the devices, one this has succeeded, the
GST_MESSAGE_DEVICE_ADDED
and GST_MESSAGE_DEVICE_REMOVED
messages
will be emitted on the bus when the list of devices changes.
Since 1.4
gst_device_monitor_stop ()
void
gst_device_monitor_stop (GstDeviceMonitor *monitor
);
Stops monitoring the devices.
Since 1.4
gst_device_monitor_get_devices ()
GList *
gst_device_monitor_get_devices (GstDeviceMonitor *monitor
);
Gets a list of devices from all of the relevant monitors. This may actually probe the hardware if the monitor is not currently started.
Since 1.4