## CheeseCamera

CheeseCamera — A representation of the video capture device inside CheeseWidget

## Stability Level

Unstable, unless otherwise indicated

## Functions

CheeseCamera * | cheese_camera_new ()
GPtrArray * | cheese_camera_get_camera_devices ()
const CheeseVideoFormat * | cheese_camera_get_current_video_format ()
GList * | cheese_camera_get_video_formats ()
void | cheese_camera_set_video_format ()
CheeseCameraDevice * | cheese_camera_get_selected_device ()
void | cheese_camera_set_device ()
void | cheese_camera_set_effect ()
gboolean | cheese_camera_get_balance_property_range ()
void | cheese_camera_set_balance_property ()
gchar * | cheese_camera_get_recorded_time ()
void | cheese_camera_connect_effect_texture ()
void | cheese_camera_play ()
void | cheese_camera_stop ()
void | cheese_camera_start_video_recording ()
void | cheese_camera_stop_video_recording ()
void | cheese_camera_switch_camera_device ()
gboolean | cheese_camera_take_photo ()
gboolean | cheese_camera_take_photo_pixbuf ()
void | cheese_camera_toggle_effects_pipeline ()
void | cheese_camera_setup ()

## Properties

CheeseCameraDevice * | device | Read / Write
CheeseVideoFormat * | format | Read / Write
guint | num-camera-devices | Read
gpointer | video-texture | Read / Write

## Signals

void | photo-saved | Action
void | photo-taken | Action
void | state-flags-changed | Action
void | video-saved | Action

## Types and Values

struct | CheeseCameraClass
struct | CheeseCamera
enum | CheeseCameraError

## Object Hierarchy

        GObject
        ╰── CheeseCamera

## Includes

    #include <cheese/cheese-camera.h>

## Description

CheeseCamera represents the video capture device used to drive a CheeseWidget.

## Functions

### cheese_camera_new ()

    CheeseCamera *
    cheese_camera_new (ClutterActor *video_texture,
                       const gchar *name,
                       gint x_resolution,
                       gint y_resolution);

Create a new CheeseCamera object.

#### Parameters

video_texture | an actor in which to render the video |
name | the name of the device. | [allow-none]
x_resolution | the resolution width |
y_resolution | the resolution height |

#### Returns

a new CheeseCamera

### cheese_camera_get_camera_devices ()

    GPtrArray *
    cheese_camera_get_camera_devices (CheeseCamera *camera);

Get the list of CheeseCameraDevice objects, representing active video capture devices on the system.

#### Parameters

camera | a CheeseCamera |

#### Returns

an array of CheeseCameraDevice.

[element-type Cheese.CameraDevice][transfer container]

### cheese_camera_get_current_video_format ()

    const CheeseVideoFormat *
    cheese_camera_get_current_video_format
                                   (CheeseCamera *camera);

Get the CheeseVideoFormat that is currently set on the `camera` .

#### Parameters

camera | a CheeseCamera |

#### Returns

the CheeseVideoFormat set on the CheeseCamera.

[transfer none]

### cheese_camera_get_video_formats ()

    GList *
    cheese_camera_get_video_formats (CheeseCamera *camera);

Gets the list of CheeseVideoFormat supported by the selected CheeseCameraDevice on the `camera` .

#### Parameters

camera | a CheeseCamera |

#### Returns

a GList of CheeseVideoFormat, or `NULL` if there was no device selected.

[element-type Cheese.VideoFormat][transfer container]

### cheese_camera_set_video_format ()

    void
    cheese_camera_set_video_format (CheeseCamera *camera,
                                    CheeseVideoFormat *format);

Sets a CheeseVideoFormat on a CheeseCamera, restarting the video stream if necessary.

#### Parameters

camera | a CheeseCamera |
format | a CheeseVideoFormat |

### cheese_camera_get_selected_device ()

    CheeseCameraDevice *
    cheese_camera_get_selected_device (CheeseCamera *camera);

Get the currently-selected CheeseCameraDevice of the `camera` .

#### Parameters

camera | a CheeseCamera |

#### Returns

a CheeseCameraDevice, or `NULL` if there is no selected device.

[transfer none]

### cheese_camera_set_device ()

    void
    cheese_camera_set_device (CheeseCamera *camera,
                              CheeseCameraDevice *device);

Set the active video capture device of the `camera` .

#### Parameters

camera | a CheeseCamera |
device | the device object |

### cheese_camera_set_effect ()

    void
    cheese_camera_set_effect (CheeseCamera *camera,
                              CheeseEffect *effect);

Set the `effect` on the `camera` .

#### Parameters

camera | a CheeseCamera |
effect | a CheeseEffect |

### cheese_camera_get_balance_property_range ()

    gboolean
    cheese_camera_get_balance_property_range
                                   (CheeseCamera *camera,
                                    const gchar *property,
                                    gdouble *min,
                                    gdouble *max,
                                    gdouble *def);

Get the minimum, maximum and default values for the requested `property` of the `camera` .

#### Parameters

camera | a CheeseCamera |
property | name of the balance property |
min | minimum value. | [out]
max | maximum value. | [out]
def | default value. | [out]

#### Returns

`TRUE` if the operation was successful, `FALSE` otherwise

### cheese_camera_set_balance_property ()

    void
    cheese_camera_set_balance_property (CheeseCamera *camera,
                                        const gchar *property,
                                        gdouble value);

Set the requested `property` on the `camera` to `value` .

#### Parameters

camera | A CheeseCamera |
property | name of the balance property |
value | value to be set |

### cheese_camera_get_recorded_time ()

    gchar *
    cheese_camera_get_recorded_time (CheeseCamera *camera);

Get a string representation of the playing time of the current video recording

#### Parameters

camera | A CheeseCamera |

#### Returns

A string with the time representation.

### cheese_camera_connect_effect_texture ()

    void
    cheese_camera_connect_effect_texture (CheeseCamera *camera,
                                          CheeseEffect *effect,
                                          ClutterActor *texture);

Connect the supplied `texture` to the `camera` , using `effect` .

#### Parameters

camera | a CheeseCamera |
effect | a CheeseEffect |
texture | a ClutterActor |

### cheese_camera_play ()

    void
    cheese_camera_play (CheeseCamera *camera);

Set the state of the GStreamer pipeline associated with the CheeseCamera to playing.

#### Parameters

camera | a CheeseCamera |

### cheese_camera_stop ()

    void
    cheese_camera_stop (CheeseCamera *camera);

Set the state of the GStreamer pipeline associated with the CheeseCamera to NULL.

#### Parameters

camera | a CheeseCamera |

### cheese_camera_start_video_recording ()

    void
    cheese_camera_start_video_recording (CheeseCamera *camera,
                                         const gchar *filename);

Start a video recording with the `camera` and save it to `filename` .

#### Parameters

camera | a CheeseCamera |
filename | the name of the video file to where the recording will be saved. | [type filename]

### cheese_camera_stop_video_recording ()

    void
    cheese_camera_stop_video_recording (CheeseCamera *camera);

Stop recording video on the `camera` .

#### Parameters

camera | a CheeseCamera |

### cheese_camera_switch_camera_device ()

    void
    cheese_camera_switch_camera_device (CheeseCamera *camera);

Toggle the playing/recording state of the `camera` .

#### Parameters

camera | a CheeseCamera |

### cheese_camera_take_photo ()

    gboolean
    cheese_camera_take_photo (CheeseCamera *camera,
                              const gchar *filename);

Save a photo taken with the `camera` to a new file at `filename` .

#### Parameters

camera | a CheeseCamera |
filename | name of the file to save a photo to. | [type filename]

#### Returns

`TRUE` on success, `FALSE` if an error occurred

### cheese_camera_take_photo_pixbuf ()

    gboolean
    cheese_camera_take_photo_pixbuf (CheeseCamera *camera);

Take a photo with the `camera` and emit it in the ::capture-start signal as a GdkPixbuf.

#### Parameters

camera | a CheeseCamera |

#### Returns

`TRUE` if the photo was successfully captured, `FALSE` otherwise

### cheese_camera_toggle_effects_pipeline ()

    void
    cheese_camera_toggle_effects_pipeline (CheeseCamera *camera,
                                           gboolean active);

Control whether the effects pipeline is enabled for `camera` .

#### Parameters

camera | a CheeseCamera |
active | `TRUE` if effects pipeline is active, `FALSE` otherwise |

### cheese_camera_setup ()

    void
    cheese_camera_setup (CheeseCamera *camera,
                         CheeseCameraDevice *device,
                         GError **error);

Setup a video capture device.

#### Parameters

camera | a CheeseCamera |
device | the video capture device, or `NULL`. | [allow-none]
error | return location for a GError, or `NULL` |

## Types and Values

### struct CheeseCameraClass

    struct CheeseCameraClass {
      void (*photo_saved)(CheeseCamera *camera);
      void (*photo_taken)(CheeseCamera *camera, GdkPixbuf *pixbuf);
      void (*video_saved)(CheeseCamera *camera);
      void (*state_flags_changed)(CheeseCamera *camera, GstState new_state);
    };

Class for CheeseCamera.

#### Members

`photo_saved` () | invoked when a photo was saved to disk |
`photo_taken` () | invoked when a photo was taken |
`video_saved` () | invoked when a video was saved to disk |
`state_flags_changed` () | invoked when the state of the camera GstElement changed |

### struct CheeseCamera

    struct CheeseCamera;

Use the accessor functions below.

### enum CheeseCameraError

Errors that can occur during camera setup, when calling `cheese_camera_setup()`.

#### Members

CHEESE_CAMERA_ERROR_UNKNOWN | unknown error |
CHEESE_CAMERA_ERROR_ELEMENT_NOT_FOUND | a required GStreamer element was not found |
CHEESE_CAMERA_ERROR_NO_DEVICE | a CheeseCameraDevice was not found |

## Property Details

### The `“device”` property

      “device”                   CheeseCameraDevice *

The device object to capture from.

Flags: Read / Write

### The `“format”` property

      “format”                   CheeseVideoFormat *

The format of the video capture device.

Flags: Read / Write

### The `“num-camera-devices”` property

      “num-camera-devices”       guint

The currently number of camera devices available for being used.

Flags: Read

Allowed values: <= 255

Default value: 0

### The `“video-texture”` property

      “video-texture”            gpointer

The video texture for the CheeseCamera to render into.

Flags: Read / Write

## Signal Details

### The `“photo-saved”` signal

    void
    user_function (CheeseCamera *camera,
                   gpointer      user_data)

Emitted when a photo was saved to disk.

#### Parameters

camera | a CheeseCamera |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“photo-taken”` signal

    void
    user_function (CheeseCamera *camera,
                   GdkPixbuf    *pixbuf,
                   gpointer      user_data)

Emitted when a photo was taken.

#### Parameters

camera | a CheeseCamera |
pixbuf | a GdkPixbuf of the photo which was taken |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“state-flags-changed”` signal

    void
    user_function (CheeseCamera *camera,
                   gint          state,
                   gpointer      user_data)

Emitted when the state of the `camera` GstElement changed.

#### Parameters

camera | a CheeseCamera |
state | the GstState which `camera` changed to |
user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“video-saved”` signal

    void
    user_function (CheeseCamera *camera,
                   gpointer      user_data)

Emitted when a video was saved to disk.

#### Parameters

camera | a CheeseCamera |
user_data | user data set when the signal handler was connected. |

Flags: Action