camera_start_encode()

Start encoding video

Synopsis:

#include <camera/camera_api.h>
camera_error_t camera_start_encode(camera_handle_t handle,
                                   void(*video_callback)(camera_handle_t,
                                   camera_buffer_t *,
                                   void *),
                                   void(*enc_video_callback)(camera_handle_t,
                                   camera_buffer_t *,
                                   void *),
                                   void(*enc_audio_callback)(camera_handle_t,
                                   camera_buffer_t *,
                                   void *),
                                   void(*status_callback)(camera_handle_t,
                                   camera_devstatus_t,
                                   uint16_t,
                                   void *),
                                   void *arg)

Arguments:

handle
The handle returned by a call to the camera_open() function.
video_callback
A function pointer to a function with the following signature:
void function_name( camera_handle_t,
                    camera_buffer_t*,
                    void* );
The function is a callback function that is invoked when an uncompressed video frame is available. You can use NULL if no function needs to be called. For information about the callback arguments, see "Callback mode" in the Camera Library Developer's Guide.
enc_video_callback
A function pointer to a function with the following signature:
void function_name( camera_handle_t,
                    camera_buffer_t*,
                    void* );
The function is a callback function that is invoked when an encoded video frame is available. This argument is mandatory and can't be a NULL value. For information about the callback arguments, see "Callback mode" in the Camera Library Developer's Guide.
enc_audio_callback
A function pointer to a function with the following signature:
void function_name( camera_handle_t,
                    camera_buffer_t*,
                    void* );
The function is a callback function that is invoked when an encoded audio frame is available. You can use NULL if no function needs to be called. For information about the callback arguments, see "Callback mode" in the Camera Library Developer's Guide.
status_callback
A function pointer to a function with the following signature:
void function_name( camera_handle_t,
                    camera_devstatus_t,
                    uint16_t,
                    void* );
The function is a callback function that is invoked when status events occur. You can use NULL if no function needs to be called. For information about the callback arguments, see "Callback mode" in the Camera Library Developer's Guide.
arg
The argument passed to all callback functions, which is the last argument in the callback functions.

Library:

libcamapi

Description:

This function can only be called if the CAMERA_FEATURE_VIDEO feature is available. You can determine whether this feature is available by calling the camera_can_feature() function.

The viewfinder must be started in a viewfinder mode that supports video encoding. For more information about viewfinder modes, see "Viewfinder mode" in the Camera Library Developer's Guide.

Video is encoded based on the configured properties. The audio track is encoded from the active audio input on the device.

Note:

Before calling this function, ensure that all required video encoding properties are set using camera_set_video_property(). For more information about encoding configurations, see the functions in camera_encoder.h.

It is important that your application follows the guidelines for resource management described in "Resource management" of the Camera Library Developer's Guide. If you do not observe these guidelines, your application is at risk of crashing due to memory access errors when resource arbitration is performed by the operating system.

Returns:

CAMERA_EOK when the function successfully completes, otherwise another camera_error_t value that provides the reason that the call failed. CAMERA_EINVAL is returned if there's a mismatch in the video properties that were set using camera_set_video_property().