Skip to main content

CaptureSession

Trait CaptureSession 

Source
pub trait CaptureSession {
    // Required methods
    fn format(&self) -> CameraFormat;
    fn state(&self) -> CaptureState;
    fn video_rotation_angle_for_horizon_level_preview(&self) -> u32;
    fn video_rotation_angle_for_horizon_level_capture(&self) -> u32;
    fn changed(&self) -> MediaChangeFuture;
    fn take_photo(&self) -> PhotoFuture;
    fn start_recording(&self, path: PathBuf) -> RecordingFuture;
    fn stop_recording(&self);
}
Expand description

A camera running for the app, controlled on the app’s main thread. Dropped, it stops for the app: its preview leaves the layer it showed on, and its reader reads nothing more.

Required Methods§

Source

fn format(&self) -> CameraFormat

The format it runs in: the one picked, unless it joined the format the camera ran in for another session.

Source

fn state(&self) -> CaptureState

The session’s state now.

Source

fn video_rotation_angle_for_horizon_level_preview(&self) -> u32

The turn, in degrees clockwise, 0, 90, 180 or 270, that keeps the preview level relative to gravity: Apple’s AVCaptureDevice.RotationCoordinator’s videoRotationAngleForHorizonLevelPreview. The system’s preview on a layer is turned so already; an app lays the layer out at the turned size. On Android it is the capture angle. WaOS’s capture-session gives both angles as one record, and a stream of their changes.

Source

fn video_rotation_angle_for_horizon_level_capture(&self) -> u32

The turn, in degrees clockwise, that keeps what is captured level relative to gravity: the coordinator’s videoRotationAngleForHorizonLevelCapture. A photo is taken turned so, in its EXIF, and a frame reports what of it its pixels do not carry as its rotation. It differs from the preview’s only while the device turns, and on Android never: there both are the sensor’s orientation against the display’s.

Source

fn changed(&self) -> MediaChangeFuture

Resolves once state or either rotation angle may answer something else than when this was called, or once the session is gone.

Source

fn take_photo(&self) -> PhotoFuture

Takes a photo while the session runs with photos among its outputs, answering it once the system has encoded it.

Source

fn start_recording(&self, path: PathBuf) -> RecordingFuture

Records to a new file at path, as a QuickTime movie, while the session runs with movies among its outputs, until stop_recording; answers once the file is written whole, or why it was not.

Source

fn stop_recording(&self)

Ends the recording, whose future then answers.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§