## CheeseCameraDeviceMonitor

CheeseCameraDeviceMonitor — Simple object to enumerate video devices

## Stability Level

Unstable, unless otherwise indicated

## Functions

CheeseCameraDeviceMonitor * | cheese_camera_device_monitor_new ()
void | cheese_camera_device_monitor_new_async ()
CheeseCameraDeviceMonitor * | cheese_camera_device_monitor_new_finish ()
void | cheese_camera_device_monitor_coldplug ()

## Signals

void | added | Action
void | removed | Action

## Types and Values

struct | CheeseCameraDeviceMonitorClass
struct | CheeseCameraDeviceMonitor

## Object Hierarchy

        GObject
        ╰── CheeseCameraDeviceMonitor

## Implemented Interfaces

CheeseCameraDeviceMonitor implements GInitable and GAsyncInitable.

## Includes

    #include <cheese/cheese-camera-device-monitor.h>

## Description

CheeseCameraDeviceMonitor provides a basic interface for video device enumeration and hotplugging.

It uses GstDeviceMonitor to list video devices. It is also capable to monitor device plugging and emit a CheeseCameraDeviceMonitor::added or CheeseCameraDeviceMonitor::removed signal when an event happens.

## Functions

### cheese_camera_device_monitor_new ()

    CheeseCameraDeviceMonitor *
    cheese_camera_device_monitor_new (void);

Returns a new CheeseCameraDeviceMonitor object. The initialization may block. See `cheese_camera_device_monitor_new_async()` for the asynchronous version.

#### Returns

a new CheeseCameraDeviceMonitor object.

### cheese_camera_device_monitor_new_async ()

    void
    cheese_camera_device_monitor_new_async
                                   (GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Creates a new CheeseCameraDeviceMonitor object asynchronously. Callback will be called when it is done. Use `cheese_camera_device_monitor_new_finish()` to get the result.

See `cheese_camera_device_monitor_new()` for the synchronous version.

#### Parameters

cancellable | a GCancellable or NULL |
callback | a GAsyncReadyCallback to call when the initialization is finished |
user_data | user data to pass to callback |

### cheese_camera_device_monitor_new_finish ()

    CheeseCameraDeviceMonitor *
    cheese_camera_device_monitor_new_finish
                                   (GAsyncResult *result,
                                    GError **error);

Finishes creating a new CheeseCameraDeviceMonitor object.

#### Parameters

result | the GAsyncResult from the callback |
error | return location for errors, or NULL to ignore |

#### Returns

a new CheeseCameraDeviceMonitor object or NULL if error is set.

### cheese_camera_device_monitor_coldplug ()

    void
    cheese_camera_device_monitor_coldplug (CheeseCameraDeviceMonitor *monitor);

Enumerate plugged in cameras and emit ::added for those which already exist. This is only required when your program starts, so be sure to connect to at least the ::added signal before calling this function.

#### Parameters

monitor | a CheeseCameraDeviceMonitor |

## Types and Values

### struct CheeseCameraDeviceMonitorClass

    struct CheeseCameraDeviceMonitorClass {
      void (*added)   (CheeseCameraDeviceMonitor *monitor,
                       CheeseCameraDevice        *device);
      void (*removed) (CheeseCameraDeviceMonitor *monitor,
                       CheeseCameraDevice        *device);
    };

Class for CheeseCameraDeviceMonitor.

#### Members

`added` () | invoked when a new video capture device is connected |
`removed` () | invoked when a video capture device is removed |

### struct CheeseCameraDeviceMonitor

    struct CheeseCameraDeviceMonitor;

Use the accessor functions below.

## Signal Details

### The `“added”` signal

    void
    user_function (CheeseCameraDeviceMonitor *monitor,
                   CheeseCameraDevice        *device,
                   gpointer                   user_data)

The ::added signal is emitted when a camera is added, or on start-up after `cheese_camera_device_monitor_coldplug()` is called.

#### Parameters

monitor | the CheeseCameraDeviceMonitor that emitted the signal |
device | a new CheeseCameraDevice representing the video capture device |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“removed”` signal

    void
    user_function (CheeseCameraDeviceMonitor *monitor,
                   CheeseCameraDevice        *device,
                   gpointer                   user_data)

The ::removed signal is emitted when a camera is unplugged, or disabled on the system.

#### Parameters

monitor | the CheeseCameraDeviceMonitor that emitted the signal |
device | the CheeseCameraDevice that was removed |
user_data | user data set when the signal handler was connected. |

Flags: Action