Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
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; > }
Since: 1.4
Synopsis
- newtype DeviceMonitor = DeviceMonitor (ManagedPtr DeviceMonitor)
- class (GObject o, IsDescendantOf DeviceMonitor o) => IsDeviceMonitor o
- toDeviceMonitor :: (MonadIO m, IsDeviceMonitor o) => o -> m DeviceMonitor
- deviceMonitorAddFilter :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Maybe Text -> Maybe Caps -> m Word32
- deviceMonitorGetBus :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bus
- deviceMonitorGetDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m [Device]
- deviceMonitorGetProviders :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m [Text]
- deviceMonitorGetShowAllDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bool
- deviceMonitorNew :: (HasCallStack, MonadIO m) => m DeviceMonitor
- deviceMonitorRemoveFilter :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Word32 -> m Bool
- deviceMonitorSetShowAllDevices :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> Bool -> m ()
- deviceMonitorStart :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m Bool
- deviceMonitorStop :: (HasCallStack, MonadIO m, IsDeviceMonitor a) => a -> m ()
- constructDeviceMonitorShowAll :: (IsDeviceMonitor o, MonadIO m) => Bool -> m (GValueConstruct o)
- getDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> m Bool
- setDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> Bool -> m ()
Exported types
newtype DeviceMonitor Source #
Memory-managed wrapper type.
DeviceMonitor (ManagedPtr DeviceMonitor) |
Instances
Eq DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor (==) :: DeviceMonitor -> DeviceMonitor -> Bool # (/=) :: DeviceMonitor -> DeviceMonitor -> Bool # | |
GObject DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor | |
ManagedPtrNewtype DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor toManagedPtr :: DeviceMonitor -> ManagedPtr DeviceMonitor | |
TypedObject DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor | |
HasParentTypes DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor | |
IsGValue (Maybe DeviceMonitor) Source # | Convert |
Defined in GI.Gst.Objects.DeviceMonitor gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe DeviceMonitor -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe DeviceMonitor) | |
type ParentTypes DeviceMonitor Source # | |
Defined in GI.Gst.Objects.DeviceMonitor |
class (GObject o, IsDescendantOf DeviceMonitor o) => IsDeviceMonitor o Source #
Type class for types which can be safely cast to DeviceMonitor
, for instance with toDeviceMonitor
.
Instances
(GObject o, IsDescendantOf DeviceMonitor o) => IsDeviceMonitor o Source # | |
Defined in GI.Gst.Objects.DeviceMonitor |
toDeviceMonitor :: (MonadIO m, IsDeviceMonitor o) => o -> m DeviceMonitor Source #
Cast to DeviceMonitor
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
addControlBinding, addFilter, bindProperty, bindPropertyFull, defaultError, forceFloating, freezeNotify, getv, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, isFloating, notify, notifyByPspec, ref, refSink, removeControlBinding, removeFilter, runDispose, start, stealData, stealQdata, stop, suggestNextSync, syncValues, thawNotify, unparent, unref, watchClosure.
Getters
getBus, getControlBinding, getControlRate, getData, getDevices, getGValueArray, getName, getParent, getPathString, getProperty, getProviders, getQdata, getShowAllDevices, getValue.
Setters
setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setData, setDataFull, setName, setParent, setProperty, setShowAllDevices.
addFilter
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
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m Bus | Returns: a |
Gets the Bus
of this DeviceMonitor
Since: 1.4
getDevices
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
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
deviceMonitorGetShowAllDevices Source #
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m Bool | Returns: |
Get if monitor
is currently 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
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
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
:: (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
:: (HasCallStack, MonadIO m, IsDeviceMonitor a) | |
=> a |
|
-> m () |
Stops monitoring the devices.
Since: 1.4
Properties
showAll
No description available in the introspection data.
constructDeviceMonitorShowAll :: (IsDeviceMonitor o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “show-all
” property. This is rarely needed directly, but it is used by new
.
getDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> m Bool Source #
Get the value of the “show-all
” property.
When overloading is enabled, this is equivalent to
get
deviceMonitor #showAll
setDeviceMonitorShowAll :: (MonadIO m, IsDeviceMonitor o) => o -> Bool -> m () Source #
Set the value of the “show-all
” property.
When overloading is enabled, this is equivalent to
set
deviceMonitor [ #showAll:=
value ]