## ApertureViewfinder

ApertureViewfinder — A GTK widget for displaying a camera feed and taking pictures and videos from it

## Functions

ApertureViewfinder * | aperture_viewfinder_new ()
void | aperture_viewfinder_set_camera ()
ApertureCamera * | aperture_viewfinder_get_camera ()
ApertureViewfinderState | aperture_viewfinder_get_state ()
void | aperture_viewfinder_set_detect_barcodes ()
gboolean | aperture_viewfinder_get_detect_barcodes ()
void | aperture_viewfinder_take_picture_async ()
GdkPixbuf * | aperture_viewfinder_take_picture_finish ()
void | aperture_viewfinder_start_recording_to_file ()
void | aperture_viewfinder_stop_recording_async ()
gboolean | aperture_viewfinder_stop_recording_finish ()
GQuark | aperture_media_capture_error_quark ()

## Properties

ApertureCamera * | camera | Read / Write
gboolean | detect-barcodes | Read / Write
ApertureViewfinderState | state | Read

## Signals

void | barcode-detected | Run Last

## Types and Values

enum | ApertureViewfinderState
enum | ApertureMediaCaptureError
#define | APERTURE_TYPE_VIEWFINDER
#define | APERTURE_MEDIA_CAPTURE_ERROR
| ApertureViewfinder

## Object Hierarchy

        GEnum
        ├── ApertureMediaCaptureError
        ╰── ApertureViewfinderState
        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GtkContainer
                    ╰── GtkBin
                        ╰── ApertureViewfinder

## Implemented Interfaces

ApertureViewfinder implements AtkImplementorIface and GtkBuildable.

## Description

The ApertureViewfinder is the main widget in Aperture. It is responsible for displaying a camera feed in your UI, and for using that camera feed to do useful things, like taking pictures, recording video, and detecting barcodes.

ApertureViewfinder does not contain camera controls, however--just the camera feed. You'll need to build a controls UI yourself.

## Functions

### aperture_viewfinder_new ()

    ApertureViewfinder *
    aperture_viewfinder_new (void);

Creates a new ApertureViewfinder.

#### Returns

a new ApertureViewfinder.

[transfer full]

Since: 0.1

### aperture_viewfinder_set_camera ()

    void
    aperture_viewfinder_set_camera (ApertureViewfinder *self,
                                    ApertureCamera *camera,
                                    GError **error);

Sets the camera that the ApertureViewfinder will use. See “camera”.

#### Parameters

self | an ApertureViewfinder |
camera | a camera index |
error | a location for a GError, or `NULL` |

Since: 0.1

### aperture_viewfinder_get_camera ()

    ApertureCamera *
    aperture_viewfinder_get_camera (ApertureViewfinder *self);

Gets the camera that the ApertureViewfinder is currently using. See “camera”.

#### Parameters

self | an ApertureViewfinder |

#### Returns

the current camera.

[transfer none]

Since: 0.1

### aperture_viewfinder_get_state ()

    ApertureViewfinderState
    aperture_viewfinder_get_state (ApertureViewfinder *self);

Gets the state of the ApertureViewfinder. See “state”.

#### Parameters

self | an ApertureViewfinder |

#### Returns

the viewfinder's state

Since: 0.1

### aperture_viewfinder_set_detect_barcodes ()

    void
    aperture_viewfinder_set_detect_barcodes
                                   (ApertureViewfinder *self,
                                    gboolean detect_barcodes);

Sets whether the ApertureViewfinder should look for barcodes in its camera feed. See “detect-barcodes”.

Before calling this function, use `aperture_is_barcode_detection_enabled()` to make sure the barcode detection feature is enabled.

#### Parameters

self | an ApertureViewfinder |
detect_barcodes | `TRUE` to detect barcodes, otherwise `FALSE` |

Since: 0.1

### aperture_viewfinder_get_detect_barcodes ()

    gboolean
    aperture_viewfinder_get_detect_barcodes
                                   (ApertureViewfinder *self);

Gets whether the ApertureViewfinder is looking for barcodes in its camera feed.

#### Parameters

self | an ApertureViewfinder |

#### Returns

`TRUE` if the viewfinder is looking for barcodes, otherwise `FALSE`

Since: 0.1

### aperture_viewfinder_take_picture_async ()

    void
    aperture_viewfinder_take_picture_async
                                   (ApertureViewfinder *self,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Takes a picture.

This may take a while. The resolution might be changed temporarily, autofocusing might take place, etc. Basically everything you'd expect to happen when you click the photo button in a camera app.

When the picture has been taken, `callback` will be called. Use `aperture_viewfinder_take_picture_finish()` to get the picture as a GdkPixbuf.

#### Parameters

self | an ApertureViewfinder |
cancellable | a GCancellable. | [nullable]
callback | a GAsyncReadyCallback to execute upon completion |
user_data | closure data for `callback` |

Since: 0.1

### aperture_viewfinder_take_picture_finish ()

    GdkPixbuf *
    aperture_viewfinder_take_picture_finish
                                   (ApertureViewfinder *self,
                                    GAsyncResult *result,
                                    GError **error);

Finishes an operation started by `aperture_viewfinder_take_picture_async()`.

#### Parameters

self | an ApertureViewfinder |
result | a GAsyncResult provided to callback |
error | a location for a GError, or `NULL` |

#### Returns

the image that was taken, or `NULL` if there was an error.

[transfer full]

Since: 0.1

### aperture_viewfinder_start_recording_to_file ()

    void
    aperture_viewfinder_start_recording_to_file
                                   (ApertureViewfinder *self,
                                    const char *file,
                                    GError **error);

Starts recording a video. The video will be saved to `file` .

Call `aperture_viewfinder_stop_recording_async()` to stop recording.

#### Parameters

self | an ApertureViewfinder |
file | file path to save the video to |
error | a location for a GError, or `NULL` |

Since: 0.1

### aperture_viewfinder_stop_recording_async ()

    void
    aperture_viewfinder_stop_recording_async
                                   (ApertureViewfinder *self,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Stop recording video. `callback` will be called when this is complete.

#### Parameters

self | an ApertureViewfinder |
cancellable | a GCancellable. | [nullable]
callback | a GAsyncReadyCallback to execute upon completion |
user_data | closure data for `callback` |

Since: 0.1

### aperture_viewfinder_stop_recording_finish ()

    gboolean
    aperture_viewfinder_stop_recording_finish
                                   (ApertureViewfinder *self,
                                    GAsyncResult *result,
                                    GError **error);

Finishes an operation started by `aperture_viewfinder_stop_recording_async()`.

#### Parameters

self | an ApertureViewfinder |
result | a GAsyncResult provided to callback |
error | a location for a GError, or `NULL` |

#### Returns

`TRUE` if the process succeeded, otherwise `FALSE`

Since: 0.1

### aperture_media_capture_error_quark ()

    GQuark
    aperture_media_capture_error_quark (void);

## Types and Values

### enum ApertureViewfinderState

Indicates what the viewfinder is currently doing. Many tasks, like taking a picture, recording video, or switching cameras, requires the viewfinder to be in a particular state.

#### Members

APERTURE_VIEWFINDER_STATE_LOADING | The ApertureViewfinder is still loading. |
APERTURE_VIEWFINDER_STATE_READY | The ApertureViewfinder is ready to be used. |
APERTURE_VIEWFINDER_STATE_NO_CAMERAS | The ApertureViewfinder could not find any cameras to use. |
APERTURE_VIEWFINDER_STATE_ERROR | An error has occurred and the viewfinder is not usable. |

Since: 0.1

### enum ApertureMediaCaptureError

Indicates the error that caused an operation to fail.

Note that functions might set errors from other domains as well. For example, if an error occurs in the GStreamer pipeline during the operation, that error will be passed directly to your async handler.

#### Members

APERTURE_MEDIA_CAPTURE_ERROR_OPERATION_IN_PROGRESS | Another operation is in progress. Wait for it to finish before starting another operation. |
APERTURE_MEDIA_CAPTURE_ERROR_NO_RECORDING_TO_STOP | There is no recording to stop (applies to `aperture_viewfinder_stop_recording_async()`). |
APERTURE_MEDIA_CAPTURE_ERROR_CAMERA_DISCONNECTED | The active camera was disconnected during the operation. |
APERTURE_MEDIA_CAPTURE_ERROR_INTERRUPTED | The operation was interrupted by an unknown error. |
APERTURE_MEDIA_CAPTURE_ERROR_NOT_READY | The viewfinder is not in the `APERTURE_VIEWFINDER_STATE_READY` “state”. |

Since: 0.1

### APERTURE_TYPE_VIEWFINDER

    #define APERTURE_TYPE_VIEWFINDER (aperture_viewfinder_get_type())

### APERTURE_MEDIA_CAPTURE_ERROR

    #define APERTURE_MEDIA_CAPTURE_ERROR (aperture_media_capture_error_quark())

Error domain for errors that occur while using an ApertureViewfinder.

### ApertureViewfinder

    typedef struct _ApertureViewfinder ApertureViewfinder;

## Property Details

### The `“camera”` property

      “camera”                   ApertureCamera *

The camera that is currently being used.

Use ApertureDeviceManager to obtain ApertureCamera objects.

To successfully switch cameras, the ApertureViewfinder must be in the `APERTURE_VIEWFINDER_STATE_READY` state. This is because switching camera sources would interrupt any picture or video that is being taken.

Owner: ApertureViewfinder

Flags: Read / Write

Since: 0.1

### The `“detect-barcodes”` property

      “detect-barcodes”          gboolean

Whether the ApertureViewfinder should detect barcodes.

When a barcode is detected, the ::barcode-detected signal will be emitted.

This only works if barcode detection is enabled. See `aperture_is_barcode_detection_enabled()`. If barcode detection is not available, the value of this property will always be `FALSE`, even if you try to set it to `TRUE`.

Owner: ApertureViewfinder

Flags: Read / Write

Default value: FALSE

Since: 0.1

### The `“state”` property

      “state”                    ApertureViewfinderState

What the viewfinder is currently doing.

The state indicates what the viewfinder is currently doing, or sometimes that an error occurred. Many operations, like taking a picture or starting a recording, require that the ApertureViewfinder be in the `APERTURE_VIEWFINDER_STATE_READY` state.

Owner: ApertureViewfinder

Flags: Read

Default value: APERTURE_VIEWFINDER_STATE_LOADING

Since: 0.1

## Signal Details

### The `“barcode-detected”` signal

    void
    user_function (ApertureViewfinder *self,
                   ApertureBarcode     barcode_type,
                   char               *data,
                   gpointer            user_data)

Emitted when a barcode is detected in the camera feed.

This will only be emitted if “detect-barcodes” is `TRUE`.

Barcodes are only detected when they appear on the feed, not on every frame when they are visible.

#### Parameters

self | the ApertureViewfinder |
barcode_type | the type of barcode |
data | the data encoded in the barcode |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 0.1