VIDEO PIPELINE API
Overview
This section mainly describes the API introductions, and related data structures of the video pipeline. The video pipeline is a component that manages the flow of video data, including encoding, decoding, and display.
For detailed information about Video Pipeline, please refer to:
For Video Pipeline example projects, please refer to:
API Reference
Header File
Functions
-
avdk_err_t bk_video_pipeline_new(bk_video_pipeline_handle_t *handle, bk_video_pipeline_config_t *config)
Video Pipeline API.
This file provides the external interface for the video pipeline module, which handles various video operations including H264 encoding and image rotation. The video pipeline provides a unified management interface for functions such as video encoding/decoding and image rotation, simplifying the complexity of multi-module collaborative work.
Create a new video pipeline instance
This function creates and initializes a new video pipeline instance with the specified configuration.
- Parameters
handle – [out] Pointer to store the video pipeline handle
config – [in] Video pipeline configuration parameters
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_open_h264e(bk_video_pipeline_handle_t handle, bk_video_pipeline_h264e_config_t *config)
Open H.264 encoder.
This function opens and configures the H.264 encoder module in the video pipeline.
- Parameters
handle – [in] Video pipeline handle
config – [in] Video pipeline configuration parameters for H.264 encoding
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_close_h264e(bk_video_pipeline_handle_t handle)
Close H.264 encoder.
This function closes the H.264 encoder module in the video pipeline.
- Parameters
handle – [in] Video pipeline handle
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_open_rotate(bk_video_pipeline_handle_t handle, bk_video_pipeline_decode_config_t *config)
Open image rotation module.
This function opens and configures the image rotation module in the video pipeline.
- Parameters
handle – [in] Video pipeline handle
config – [in] Video pipeline configuration parameters for image rotation
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_close_rotate(bk_video_pipeline_handle_t handle)
Close image rotation module.
This function closes the image rotation module in the video pipeline.
- Parameters
handle – [in] Video pipeline handle
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_get_module_status(bk_video_pipeline_handle_t handler, video_pipeline_module_t module, video_pipeline_module_status_t *status)
Get the status of a video pipeline module.
This function retrieves the enable status of a specified module in the video pipeline.
- Parameters
handler – [in] Video pipeline handle
module – [in] Module to query (H264E or ROTATE)
status – [out] Pointer to store the module status
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_reset_decode(bk_video_pipeline_handle_t handler)
Reset the decode module to re-detect image format.
This function is used when switching cameras to internally re-acquire the image format. It resets the decode module in the video pipeline.
- Parameters
handler – [in] Video pipeline handle
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_delete(bk_video_pipeline_handle_t handle)
Delete the video pipeline instance.
This function deletes and frees resources associated with a video pipeline instance.
- Parameters
handle – [in] Video pipeline handle
- Returns
BK_OK: Success
Others: Fail
-
avdk_err_t bk_video_pipeline_ioctl(bk_video_pipeline_handle_t handle, video_pipeline_ioctl_cmd_t cmd, void *param)
Extended interface for video pipeline Used for additional functionalities like getting encoder status.
This function provides an extended interface for additional functionalities in the video pipeline.
- Parameters
handle – [in] Video pipeline handle
cmd – [in] Command code (defined in pipeline_ext_cmd_t)
param – [inout] Command parameters
- Returns
BK_OK: Success
Others: Fail
API Typedefs
Callback Function Usage Notes:
When implementing callback functions for video pipeline operations, please keep in mind:
bk_h264e_callback_t: Blocking operations (such as long waits, sleep, etc.) are NOT recommended in callback functions to avoid impacting encoding performance and system responsiveness. Callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc. Move time-consuming operations to other tasks.
jpeg_callback_t: Blocking operations are generally NOT recommended in callback functions to avoid impacting decoding performance and system responsiveness. However, the
read()callback is an exception - it may perform short blocking waits to acquire a ready JPEG buffer. Other callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc.decode_callback_t: Blocking operations (such as long waits, sleep, etc.) are NOT recommended in callback functions to avoid impacting decoding performance and system responsiveness. Callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc. Move time-consuming operations to other tasks.
Header File
Structures
-
struct bk_h264e_callback_t
H.264 encoder callback structure.
This structure defines the callback functions for H.264 encoding operations, including memory allocation and completion notification.
Warning
Callback Function Usage Notes:
Blocking operations (such as long waits, sleep, etc.) are NOT recommended in callback functions to avoid impacting encoding performance and system responsiveness.
Callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc. Move time-consuming operations to other tasks.
Public Members
-
frame_buffer_t *(*malloc)(uint32_t size)
Allocate memory for frame buffer.
- Param size
Size of memory to allocate
- Return
Pointer to allocated frame buffer
-
struct jpeg_callback_t
JPEG decode callback structure.
This structure defines the callback functions for JPEG decoding operations
Warning
Callback Function Usage Notes:
Blocking operations (such as long waits, sleep, etc.) are NOT recommended in callback functions to avoid impacting decoding performance and system responsiveness.
Callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc. Move time-consuming operations to other tasks.
Exception: The read() callback may perform short blocking waits to acquire a ready JPEG buffer.
-
struct decode_callback_t
Image codec callback structure.
This structure defines the callback functions for image codec operations
Warning
Callback Function Usage Notes:
Blocking operations (such as long waits, sleep, etc.) are NOT recommended in callback functions to avoid impacting decoding performance and system responsiveness.
Callback functions should only perform lightweight operations such as setting flags, sending messages/semaphores, etc. Move time-consuming operations to other tasks.
Public Members
-
frame_buffer_t *(*malloc)(uint32_t size)
Callback to allocate frame buffer
-
bk_err_t (*complete)(dec_end_type_t format_type, bk_err_t result, frame_buffer_t *out_frame)
Callback when processing is complete Rotation angle
-
struct bk_video_pipeline_h264e_config
Video pipeline H.264 encoder configuration structure.
This structure defines the configuration parameters for the H.264 encoder in the video pipeline
-
struct bk_video_pipeline_decode_config
Video pipeline decode configuration structure.
This structure defines the configuration parameters for the decode module in the video pipeline
-
struct bk_video_pipeline_config
Video pipeline configuration structure.
This structure defines the main configuration parameters for the video pipeline
Public Members
-
const jpeg_callback_t *jpeg_cbs
JPEG decode callback functions
-
const decode_callback_t *decode_cbs
Image codec callback functions
-
const jpeg_callback_t *jpeg_cbs
-
struct bk_video_pipeline
Video pipeline operations structure.
This structure defines the operations available for the video pipeline instance
Public Members
-
avdk_err_t (*open_h264e)(bk_video_pipeline_handle_t handle, bk_video_pipeline_h264e_config_t *config)
Open H.264 encoder
-
avdk_err_t (*close_h264e)(bk_video_pipeline_handle_t handle)
Close H.264 encoder
-
avdk_err_t (*open_rotate)(bk_video_pipeline_handle_t handle, bk_video_pipeline_decode_config_t *config)
Open image rotation module
-
avdk_err_t (*close_rotate)(bk_video_pipeline_handle_t handle)
Close image rotation module
-
avdk_err_t (*reset_decode)(bk_video_pipeline_handle_t handle)
Reset decode module, This function is used when switching cameras to internally re-acquire the image format.
-
avdk_err_t (*get_module_status)(bk_video_pipeline_handle_t handle, video_pipeline_module_t module, video_pipeline_module_status_t *status)
Get module enable state
-
avdk_err_t (*delete_video_pipeline)(bk_video_pipeline_handle_t handle)
Delete the video pipeline instance
-
avdk_err_t (*ioctl)(bk_video_pipeline_handle_t handle, video_pipeline_ioctl_cmd_t cmd, void *param)
Extended interface for additional functionalities
-
avdk_err_t (*open_h264e)(bk_video_pipeline_handle_t handle, bk_video_pipeline_h264e_config_t *config)
Macros
-
delete_video_pipeline
Video Pipeline Types.
This file defines the data types, enumerations, and structures used by the video pipeline module. The video pipeline provides a unified management interface for functions such as video encoding/decoding and image rotation, simplifying the complexity of multi-module collaborative work.
-
BK_H264_ENCODE_864X480_30FPS_CONFIG()
Default H.264 encoding configuration for 864x480 resolution at 30 FPS.
This macro provides a default configuration for H.264 encoding with:
Resolution: 864x480
Frame rate: 30 FPS
Software decode rotate angle: default:0 range:(0, 90, 180, 270)
Type Definitions
-
typedef struct bk_video_pipeline_h264e_config bk_video_pipeline_h264e_config_t
Video pipeline H.264 encoder configuration structure.
This structure defines the configuration parameters for the H.264 encoder in the video pipeline
-
typedef struct bk_video_pipeline_decode_config bk_video_pipeline_decode_config_t
Video pipeline decode configuration structure.
This structure defines the configuration parameters for the decode module in the video pipeline
-
typedef struct bk_video_pipeline_config bk_video_pipeline_config_t
Video pipeline configuration structure.
This structure defines the main configuration parameters for the video pipeline
-
typedef struct bk_video_pipeline *bk_video_pipeline_handle_t
Video pipeline handle type.
This is the handle type for the video pipeline instance
-
typedef struct bk_video_pipeline bk_video_pipeline_t
Video pipeline operations structure.
This structure defines the operations available for the video pipeline instance
Enumerations
-
enum dec_end_type_t
Decoder end type enumeration.
This enumeration defines the different types of decoder end operations
Values:
-
enumerator HW_DEC_END
Hardware decoding end
-
enumerator SW_DEC_END
Software decoding end
-
enumerator HW_DEC_END
-
enum h264e_state_t
H.264 encoder working state enumeration.
This enumeration defines the working states of the H.264 encoder
Values:
-
enumerator H264E_STATE_IDLE
Encoder idle state
-
enumerator H264E_STATE_ENCODING
Encoder encoding state
-
enumerator H264E_STATE_IDLE
-
enum video_pipeline_module_t
Video pipeline module type enumeration.
This enumeration defines the different module types in the video pipeline
Values:
-
enumerator VIDEO_PIPELINE_MODULE_H264E
H.264 encoder module
-
enumerator VIDEO_PIPELINE_MODULE_ROTATE
Image rotation module
-
enumerator VIDEO_PIPELINE_MODULE_H264E