Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
Applications should create a DeviceMonitor
when they want
to probe, list and monitor devices of a specific type. The
DeviceMonitor
will create the appropriate
DeviceProvider
objects and manage them. It will then post
messages on its 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: %sn", 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: %sn", 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; > }
- newtype DeviceMonitor = DeviceMonitor (ManagedPtr DeviceMonitor)
- class GObject o => IsDeviceMonitor o
- toDeviceMonitor :: IsDeviceMonitor o => o -> IO DeviceMonitor
- noDeviceMonitor :: Maybe DeviceMonitor
- data DeviceMonitorAddFilterMethodInfo
- deviceMonitorAddFilter :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Maybe Text -> Maybe Caps -> m Word32
- data DeviceMonitorGetBusMethodInfo
- deviceMonitorGetBus :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bus
- data DeviceMonitorGetDevicesMethodInfo
- deviceMonitorGetDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m [Device]
- data DeviceMonitorGetProvidersMethodInfo
- deviceMonitorGetProviders :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m [Text]
- data DeviceMonitorGetShowAllDevicesMethodInfo
- deviceMonitorGetShowAllDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bool
- deviceMonitorNew :: (HasCallStack, MonadIO m) => m DeviceMonitor
- data DeviceMonitorRemoveFilterMethodInfo
- deviceMonitorRemoveFilter :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Word32 -> m Bool
- data DeviceMonitorSetShowAllDevicesMethodInfo
- deviceMonitorSetShowAllDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Bool -> m ()
- data DeviceMonitorStartMethodInfo
- deviceMonitorStart :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bool
- data DeviceMonitorStopMethodInfo
- deviceMonitorStop :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m ()
- data DeviceMonitorShowAllPropertyInfo
- constructDeviceMonitorShowAll :: IsDeviceMonitor o => Bool -> IO (GValueConstruct o)
- deviceMonitorShowAll :: AttrLabelProxy "showAll"
- getDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> m Bool
- setDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> Bool -> m ()
Exported types
newtype DeviceMonitor Source #
GObject DeviceMonitor Source # | |
IsObject DeviceMonitor Source # | |
IsObject DeviceMonitor Source # | |
IsDeviceMonitor DeviceMonitor Source # | |
((~) * info (ResolveDeviceMonitorMethod t DeviceMonitor), MethodInfo * info DeviceMonitor p) => IsLabel t (DeviceMonitor -> p) Source # | |
((~) * info (ResolveDeviceMonitorMethod t DeviceMonitor), MethodInfo * info DeviceMonitor p) => IsLabelProxy t (DeviceMonitor -> p) Source # | |
HasAttributeList * DeviceMonitor Source # | |
type AttributeList DeviceMonitor Source # | |
type SignalList DeviceMonitor Source # | |
class GObject o => IsDeviceMonitor o Source #
toDeviceMonitor :: IsDeviceMonitor o => o -> IO DeviceMonitor Source #
Methods
addFilter
data DeviceMonitorAddFilterMethodInfo Source #
((~) * signature (Maybe Text -> Maybe Caps -> m Word32), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorAddFilterMethodInfo a signature Source # | |
deviceMonitorAddFilter Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> Maybe Text |
|
-> Maybe Caps | |
-> m Word32 | Returns: The id of the new filter or 0 if no provider matched the filter's classes. |
Adds a filter for which Device
will be monitored, any device that matches
all these classes and the 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 Caps
supported by the device as returned by deviceGetCaps
are
not intersected with caps filters added using this function.
Filters must be added before the DeviceMonitor
is started.
Since: 1.4
getBus
data DeviceMonitorGetBusMethodInfo Source #
((~) * signature (m Bus), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorGetBusMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m Bus | Returns: a |
Gets the Bus
of this DeviceMonitor
Since: 1.4
getDevices
data DeviceMonitorGetDevicesMethodInfo Source #
((~) * signature (m [Device]), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorGetDevicesMethodInfo a signature Source # | |
deviceMonitorGetDevices Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m [Device] |
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
getProviders
data DeviceMonitorGetProvidersMethodInfo Source #
((~) * signature (m [Text]), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorGetProvidersMethodInfo a signature Source # | |
deviceMonitorGetProviders Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m [Text] | Returns:
A list of device provider factory names that are currently being
monitored by |
Get a list of the currently selected device provider factories.
This
Since: 1.6
getShowAllDevices
data DeviceMonitorGetShowAllDevicesMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorGetShowAllDevicesMethodInfo a signature Source # | |
deviceMonitorGetShowAllDevices Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m Bool | Returns: |
Get if monitor
is curretly showing all devices, even those from hidden
providers.
Since: 1.6
new
:: (HasCallStack, MonadIO m) | |
=> m DeviceMonitor | Returns: a new device monitor. |
Create a new DeviceMonitor
Since: 1.4
removeFilter
data DeviceMonitorRemoveFilterMethodInfo Source #
((~) * signature (Word32 -> m Bool), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorRemoveFilterMethodInfo a signature Source # | |
deviceMonitorRemoveFilter Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> Word32 |
|
-> m Bool |
Removes a filter from the DeviceMonitor
using the id that was returned
by deviceMonitorAddFilter
.
Since: 1.4
setShowAllDevices
data DeviceMonitorSetShowAllDevicesMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorSetShowAllDevicesMethodInfo a signature Source # | |
deviceMonitorSetShowAllDevices Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> Bool |
|
-> m () |
Set if all devices should be visible, even those devices from hidden
providers. Setting showAll
to true might show some devices multiple times.
Since: 1.6
start
data DeviceMonitorStartMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorStartMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m Bool | Returns: |
Starts monitoring the devices, one this has succeeded, the
MessageTypeDeviceAdded
and MessageTypeDeviceRemoved
messages
will be emitted on the bus when the list of devices changes.
Since: 1.4
stop
data DeviceMonitorStopMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsDeviceMonitor a) => MethodInfo * DeviceMonitorStopMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m () |
Stops monitoring the devices.
Since: 1.4
Properties
showAll
data DeviceMonitorShowAllPropertyInfo Source #
constructDeviceMonitorShowAll :: IsDeviceMonitor o => Bool -> IO (GValueConstruct o) Source #
deviceMonitorShowAll :: AttrLabelProxy "showAll" Source #
getDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> m Bool Source #
setDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> Bool -> m () Source #