This commit is contained in:
刘可亮
2024-09-03 11:16:08 +08:00
parent cf270df8d6
commit 803cac77d5
2931 changed files with 614364 additions and 31222 deletions

View File

@@ -0,0 +1,324 @@
/*
* Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Author: <jun.ma@artinchip.com>
* Desc: middle media component desc
*/
#ifndef MM_COMPONENT_H
#define MM_COMPONENT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <aic_common.h>
#include <inttypes.h>
#include <mm_index.h>
#define MM_CLOCK_PORT0 0x00000001
#define MM_CLOCK_PORT1 0x00000002
#define MM_CLOCK_PORT2 0x00000004
typedef void *mm_handle;
typedef enum MM_COMMAND_TYPE {
MM_COMMAND_UNKNOWN,
MM_COMMAND_STATE_SET, /* Change the component state */
MM_COMMAND_FLUSH, /* Flush the data queue(s) of a component */
MM_COMMAND_STOP,
MM_COMMAND_NOPS,
MM_COMMAND_WKUP,
MM_COMMAND_EOS,
} MM_COMMAND_TYPE;
typedef enum MM_STATE_TYPE {
MM_STATE_INVALID,
/* component has been loaded but has not completed initialization. */
MM_STATE_LOADED,
/* component initialization has been completed successfully
and the component is ready to start. */
MM_STATE_IDLE,
/**< component has accepted the start command and
is processing data (if data is available) */
MM_STATE_EXECUTING,
/**< component has received pause command */
MM_STATE_PAUSE,
} MM_STATE_TYPE;
typedef enum MM_AUDIO_CODING_TYPE {
MM_AUDIO_CODING_UNUSED = 0, /* Placeholder value when coding is N/A */
MM_AUDIO_CODING_AUTODETECT, /* auto detection of audio format */
MM_AUDIO_CODING_PCM, /* Any variant of PCM coding */
MM_AUDIO_CODING_AAC, /* Any variant of AAC encoded data */
MM_AUDIO_CODING_MP3, /* Any variant of MP3 encoded data */
MM_AUDIO_CODING_MAX = 0x7FFFFFFF
} MM_AUDIO_CODING_TYPE;
typedef enum MM_VIDEO_CODING_TYPE {
MM_VIDEO_CODING_UNUSED, /* Value when coding is N/A */
MM_VIDEO_CODING_AUTODETECT, /* Autodetection of coding type */
MM_VIDEO_CODING_MPEG2, /* AKA: H.262 */
MM_VIDEO_CODING_H263, /* H.263 */
MM_VIDEO_CODING_MPEG4, /* MPEG-4 */
MM_VIDEO_CODING_AVC, /* H.264/AVC */
MM_VIDEO_CODING_MJPEG, /* Motion JPEG */
MM_VIDEO_CODING_MAX = 0x7FFFFFFF
} MM_VIDEO_CODING_TYPE;
typedef enum MM_COLOR_FORMAT_TYPE {
MM_COLOR_FORMAT_UNUSED,
MM_COLOR_FORMAT_YUV420P,
MM_COLOR_FORMAT_NV12,
MM_COLOR_FORMAT_NV21,
MM_COLOR_FORMAT_RGB565,
MM_COLOR_FORMAT_ARGB8888,
MM_COLOR_FORMAT_RGB888,
MM_COLOR_FORMAT_ARGB1555,
MM_COLOR_FORMAT_MAX = 0x7FFFFFFF
} MM_COLOR_FORMAT_TYPE;
typedef enum MM_BUFFER_DATA_TYPE {
MM_BUFFER_DATA_UNKNOWN,
MM_BUFFER_DATA_PACKET,
MM_BUFFER_DATA_FRAME,
} MM_BUFFER_DATA_TYPE;
typedef enum MM_VIDEO_IN_SOURCE_TYPE {
MM_VIDEO_IN_SOURCE_UNKNOWN,
MM_VIDEO_IN_SOURCE_FILE,
MM_VIDEO_IN_SOURCE_DVP,
MM_VIDEO_IN_SOURCE_USB,
MM_VIDEO_IN_SOURCE_MAX = 0x7FFFFFFF
} MM_VIDEO_IN_SOURCE_TYPE;
typedef enum MM_TIME_CLOCK_STATE {
MM_TIME_CLOCK_STATE_RUNNING, /* Clock running. */
/* Clock waiting until the prescribed clients emit their start time. */
MM_TIME_CLOCK_STATE_WAITING_FOR_START_TIME,
MM_TIME_CLOCK_STATE_STOPPED, /**< Clock stopped. */
MM_TIME_CLOCK_STATE_MAX = 0x7FFFFFFF
} MM_TIME_CLOCK_STATE;
typedef enum MM_TIME_REF_CLOCK_TYPE {
MM_TIME_REF_CLOCK_NONE, /* Use no references. */
MM_TIME_REF_CLOCK_AUDIO,
MM_TIME_REF_CLOCK_VIDEO,
MM_TIME_REF_CLOCK_MAX = 0x7FFFFFFF
} MM_TIME_REF_CLOCK_TYPE;
typedef struct mm_param_content_uri {
/* size of the structure in bytes, including actual URI name */
u32 size;
u8 content_uri[1]; /* The URI name */
} mm_param_content_uri;
typedef struct mm_param_u32 {
u32 port_index; /* port that this structure applies to */
u32 u32; /* U32 value */
} mm_param_u32;
typedef struct mm_audio_param_port_format {
u32 port_index; /* Indicates which port to set */
u32 index; /* Indicates the enumeration index for the format from 0x0 to N-1 */
/* Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */
MM_AUDIO_CODING_TYPE encoding;
} mm_audio_param_port_format;
typedef struct ms_audio_port_def {
/* Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */
MM_AUDIO_CODING_TYPE encoding;
u32 channels;
u32 bitrate;
u32 sample_rate;
} ms_audio_port_def;
typedef struct mm_video_param_port_format {
u32 port_index;
u32 index;
MM_VIDEO_CODING_TYPE compression_format;
MM_COLOR_FORMAT_TYPE color_format;
u32 framerate;
} mm_video_param_port_format;
typedef struct mm_image_param_qfactor {
u32 port_index;
u32 q_factor;
} mm_image_param_qfactor;
typedef struct ms_video_port_def {
u32 frame_width;
u32 frame_height;
s32 stride;
u32 slice_height;
u32 bitrate;
u32 framerate;
MM_VIDEO_CODING_TYPE compression_format;
MM_COLOR_FORMAT_TYPE color_format;
} ms_video_port_def;
typedef struct mm_param_port_def {
u32 port_index; /* Port number the structure applies to */
u32 dir; /* Direction (input or output) of this port */
MM_BOOL enable; /* Ports default to enabled and are enabled/disabled */
union {
ms_audio_port_def audio;
ms_video_port_def video;
} format;
} mm_param_port_def;
typedef struct mm_param_skip_track {
u32 port_index;
} mm_param_skip_track;
typedef struct mm_param_screen_size {
u32 port_index;
s32 width;
s32 height;
} mm_param_screen_size;
typedef struct mm_param_audio_volume {
u32 port_index;
s32 volume;
} mm_param_audio_volume;
typedef struct mm_param_frame_end {
u32 port_index; /* port that this structure applies to */
MM_BOOL b_frame_end; /* 0-clear 1- set */
} mm_param_frame_end;
typedef struct mm_param_record_file_info {
u32 port_index;
s32 file_num;
s64 duration;
s32 muxer_type;
} mm_param_record_file_info;
typedef struct mm_param_video_capture {
u32 port_index;
s8 *p_file_path;
s32 width;
s32 height;
s32 quality;
} mm_param_video_capture;
typedef struct mm_config_rect {
u32 port_index;
s32 left;
s32 top;
u32 width;
u32 height;
} mm_config_rect;
typedef struct mm_config_rotation {
u32 port_index;
u32 rotation;
} mm_config_rotation;
typedef struct mm_time_config_timestamp {
u32 port_index; /* port that this structure applies to */
s64 timestamp; /* timestamp .*/
} mm_time_config_timestamp;
typedef struct mm_time_config_clock_state {
MM_TIME_CLOCK_STATE state; /* state of the media time. */
s64 start_time; /* start time of the media time. */
/* Time to offset the media time by * (e.g. preroll). Media time will be
* reported to be nOffset ticks earlier.*/
s64 offset;
u32 wait_mask; /* mask values. */
} mm_time_config_clock_state;
typedef struct mm_time_config_active_ref_clock {
MM_TIME_REF_CLOCK_TYPE clock; /* Reference clock used to compute media time */
} mm_time_config_active_ref_clock;
typedef struct mm_buffer
{
u8* p_buffer; /*p_buffer data reference MM_BUFFER_DATA_TYPE*/
u32 buffer_size;
s64 time_stamp;
u32 flags;
u32 output_port_index;
u32 input_port_index;
MM_BUFFER_DATA_TYPE data_type;
} mm_buffer;
typedef struct mm_callback {
/* The event_handler method is used to notify the application when an
event of interest occurs.*/
s32 (*event_handler)(mm_handle h_component, void *p_app_data, u32 event,
u32 data1, u32 data2, void *p_event_data);
/*When app send buffer to component, the component need
do this giveback_buffer callback api to give back buffer*/
s32 (*giveback_buffer)(mm_handle h_component, void* p_app_data,
mm_buffer* p_buffer);
} mm_callback;
typedef struct mm_component {
/* p_comp_private is a pointer to the component private data area.
The application should not access this data area. */
void *p_comp_private;
/* p_app_private is application private data*/
void *p_app_private;
s32 (*send_command)(mm_handle h_component, MM_COMMAND_TYPE cmd, u32 param,
void *p_cmd_data);
s32 (*get_parameter)(mm_handle h_component, MM_INDEX_TYPE index,
void *p_param);
s32 (*set_parameter)(mm_handle h_component, MM_INDEX_TYPE index,
void *p_param);
s32 (*get_config)(mm_handle h_component, MM_INDEX_TYPE index,
void *p_config);
s32 (*set_config)(mm_handle h_component, MM_INDEX_TYPE index,
void *p_config);
s32 (*get_state)(mm_handle h_component, MM_STATE_TYPE *p_state);
s32 (*bind_request)(mm_handle h_comp, u32 n_port, mm_handle h_bind_comp,
u32 n_port_bind);
s32 (*set_callback)(mm_handle h_component, mm_callback *p_cb,
void *p_app_data);
/*When app run send_buffer api to component, the component need do callback func
to give back this buffer; or when the component run send_buffer api to other
component, the other component need run give_buffer api*/
s32 (*send_buffer)(mm_handle h_component, mm_buffer *p_buffer);
/*When app get buffer from component, the app need
run giveback_buffer api to give back this buffer to component,
when other component get buffer from the component, other component
need run giveback_buffer api*/
s32 (*get_buffer)(mm_handle h_component, mm_buffer *p_buffer);
/*App give back this buffer to component,
when app run get_buffer api, then need run giveback_buffer api;
or when one component run send_buffer api to this component,
then need run giveback_buffer api*/
s32 (*giveback_buffer)(mm_handle h_component, mm_buffer *p_buffer);
s32 (*deinit)(mm_handle h_component);
} mm_component;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */

View File

@@ -0,0 +1,186 @@
/*
* Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Author: <jun.ma@artinchip.com>
* Desc: middle media core desc
*/
#ifndef MM_CORE_h
#define MM_CORE_h
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <mm_component.h>
#define MM_MAX_STRINGNAME_SIZE 128
#define MM_COMPONENT_DEMUXER_NAME "MM.AIC.DEMUXER.ALL"
#define MM_COMPONENT_VDEC_NAME "MM.AIC.VDEC.ALL"
#define MM_COMPONENT_VIDEO_RENDER_NAME "MM.AIC.VIDEORENDER.ALL"
#define MM_COMPONENT_ADEC_NAME "MM.AIC.ADEC.ALL"
#define MM_COMPONENT_AUDIO_RENDER_NAME "MM.AIC.AUDIORENDER.ALL"
#define MM_COMPONENT_CLOCK_NAME "MM.AIC.CLOCK.ALL"
#define MM_COMPONENT_MUXER_NAME "MM.AIC.MUXER.ALL"
#define MM_COMPONENT_VENC_NAME "MM.AIC.VENC.ALL"
#define MM_COMPONENT_AENC_NAME "MM.AIC.AENC.ALL"
#define MM_COMPONENT_VIN_NAME "MM.AIC.VIN.ALL"
#define MM_COMPONENT_AIN_NAME "MM.AIC.AIN.ALL"
#define MM_COMPONENT_DEMUXER_THREAD_PRIORITY (23)
#define MM_COMPONENT_VDEC_THREAD_PRIORITY (22)
#define MM_COMPONENT_ADEC_THREAD_PRIORITY (22)
#define MM_COMPONENT_VIDEO_RENDER_THREAD_PRIORITY (21)
#define MM_COMPONENT_AUDIO_RENDER_THREAD_PRIORITY (22)
#define MM_COMPONENT_MUXER_THREAD_PRIORITY (23)
#define MM_COMPONENT_VENC_THREAD_PRIORITY (22)
#define MM_COMPONENT_AENC_THREAD_PRIORITY (22)
#define MM_COMPONENT_VIN_THREAD_PRIORITY (22)
#define MM_COMPONENT_AIN_THREAD_PRIORITY (22)
#define DEMUX_PORT_AUDIO_INDEX 0
#define DEMUX_PORT_VIDEO_INDEX 1
#define DEMUX_PORT_CLOCK_INDEX 2
#define MUX_PORT_AUDIO_INDEX 0
#define MUX_PORT_VIDEO_INDEX 1
#define MUX_PORT_CLOCK_INDEX 2
#define VDEC_PORT_IN_INDEX 0
#define VDEC_PORT_OUT_INDEX 1
#define VENC_PORT_IN_INDEX 0
#define VENC_PORT_OUT_INDEX 1
#define VIDEO_RENDER_PORT_IN_VIDEO_INDEX 0
#define VIDEO_RENDER_PORT_IN_CLOCK_INDEX 1
#define VIN_PORT_IN_INDEX 0
#define VIN_PORT_OUT_INDEX 1
#define ADEC_PORT_IN_INDEX 0
#define ADEC_PORT_OUT_INDEX 1
#define AENC_PORT_IN_INDEX 0
#define AENC_PORT_OUT_INDEX 1
#define AUDIO_RENDER_PORT_IN_AUDIO_INDEX 0
#define AUDIO_RENDER_PORT_IN_CLOCK_INDEX 1
#define AIN_PORT_IN_INDEX 0
#define AIN_PORT_OUT_INDEX 1
#define CLOCK_PORT_OUT_VIDEO 0
#define CLOCK_PORT_OUT_AUDIO 1
typedef enum MM_ERROR_TYPE {
MM_ERROR_NONE = 0,
MM_ERROR_UNDEFINED = 1,
MM_ERROR_UNSUPPORT,
MM_ERROR_NULL_POINTER,
MM_ERROR_EMPTY_DATA,
MM_ERROR_READ_FAILED,
MM_ERROR_SAME_STATE,
MM_ERROR_INVALID_STATE,
MM_ERROR_BAD_PARAMETER,
MM_ERROR_MB_ERRORS_IN_FRAME,
MM_ERROR_FORMAT_NOT_DETECTED,
MM_ERROR_COMPONENT_NOT_FOUND,
MM_ERROR_PORT_NOT_COMPATIBLE,
MM_ERROR_INSUFFICIENT_RESOURCES,
MM_ERROR_INCORRECT_STATE_TRANSITION,
} MM_ERROR_TYPE;
typedef enum MM_EVENT_TYPE {
MM_EVENT_CMD_COMPLETE, /* component has sucessfully completed a command */
MM_EVENT_ERROR, /* component has detected an error condition */
MM_EVENT_BUFFER_FLAG, /* component has detected an EOS */
MM_EVENT_PORT_FORMAT_DETECTED, /* Component has detected a supported format. */
MM_EVENT_VIDEO_RENDER_PTS,
MM_EVENT_VIDEO_RENDER_FIRST_FRAME,
MM_EVENT_AUDIO_RENDER_PTS,
MM_EVENT_AUDIO_RENDER_FIRST_FRAME,
MM_EVENT_MUXER_NEED_NEXT_FILE,
MM_EVENT_MAX = 0x7FFFFFFF
} MM_EVENT_TYPE;
typedef s32 (*mm_component_init)(mm_handle h_component);
typedef struct mm_component_register {
const char *p_name;
mm_component_init p_init;
} mm_component_register;
typedef struct mm_bind_info {
u32 flag;
u32 port_index; /* port index. */
mm_handle p_self_comp;
u32 bind_port_index; /* bind port index. */
mm_handle p_bind_comp; /* bind component handle. */
} mm_bind_info;
typedef struct mm_port_param {
u32 size; /* size of the structure in bytes */
u32 ports; /* The number of ports for this component */
u32 start_port_num; /* first port number for this type of port */
} mm_port_param;
#define mm_send_command(h_component, cmd, param, p_cmd_data) \
((mm_component *)h_component) \
->send_command(h_component, cmd, param, p_cmd_data) /* Macro End */
#define mm_get_parameter(h_component, index, p_param) \
((mm_component *)h_component) \
->get_parameter(h_component, index, p_param) /* Macro End */
#define mm_set_parameter(h_component, index, p_param) \
((mm_component *)h_component) \
->set_parameter(h_component, index, p_param) /* Macro End */
#define mm_get_config(h_component, index, p_config) \
((mm_component *)h_component) \
->get_config(h_component, index, p_config) /* Macro End */
#define mm_set_config(h_component, index, p_config) \
((mm_component *)h_component) \
->set_config(h_component, index, p_config) /* Macro End */
#define mm_get_state(h_component, p_state) \
((mm_component *)h_component) \
->get_state(h_component, p_state) /* Macro End */
#define mm_send_buffer(h_component, p_buffer) \
((mm_component *)h_component) \
->send_buffer(h_component, p_buffer) /* Macro End */
#define mm_get_buffer(h_component, p_buffer) \
((mm_component *)h_component) \
->get_buffer(h_component, p_buffer) /* Macro End */
#define mm_giveback_buffer(h_component, p_buffer) \
((mm_component *)h_component) \
->giveback_buffer(h_component, p_buffer) /* Macro End */
s32 mm_init();
s32 mm_deinit();
s32 mm_get_handle(mm_handle *p_handle, char *component_name, void *p_app_data,
mm_callback *p_cb);
s32 mm_free_handle(mm_handle h_component);
s32 mm_set_bind(mm_handle h_out, u32 out_port, mm_handle h_in, u32 in_port);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */

View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Author: <jun.ma@artinchip.com>
* Desc: middle media index desc
*/
#ifndef MM_INDEX_H
#define MM_INDEX_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum MM_BOOL {
MM_FALSE = 0,
MM_TRUE = !MM_FALSE,
} MM_BOOL;
typedef enum MM_DIR_TYPE {
MM_DIR_INPUT, /* Port is an input port */
MM_DIR_OUTPUT, /* Port is an output port */
MM_DIR_MAX = 0x7FFFFFFF
} MM_DIR_TYPE;
typedef enum MM_INDEX_TYPE {
MM_INDEX_COMP_START_UNUSED,
MM_INDEX_CONFIG_TIME_POSITION = 0x100,
MM_INDEX_CONFIG_TIME_SEEK_MODE,
MM_INDEX_CONFIG_TIME_CLOCK_STATE,
MM_INDEX_CONFIG_TIME_CUR_MEDIA_TIME,
MM_INDEX_CONFIG_TIME_CUR_AUDIO_REFERENCE,
MM_INDEX_CONFIG_TIME_CUR_VIDEO_REFERENCE,
MM_INDEX_CONFIG_TIME_CLIENT_START_TIME,
MM_INDEX_CONFIG_COMMON_ROTATE,
MM_INDEX_CONFIG_COMMON_OUTPUT_CROP,
MM_INDEX_CONFIG_VIDEO_DECODER_EXT_FRAME_ALLOCATOR,
MM_INDEX_CONFIG_VIDEO_DECODER_CROP_INFO,
MM_INDEX_PARAM_PORT_DEFINITION = 0x200,
MM_INDEX_PARAM_ACTIVE_STREAM,
MM_INDEX_PARAM_NUM_AVAILABLE_STREAM,
MM_INDEX_PARAM_CONTENT_URI,
MM_INDEX_PARAM_VIDEO_PORT_FORMAT,
MM_INDEX_PARAM_AUDIO_PORT_FORMAT,
MM_INDEX_PARAM_VIDEO_DECODER_HANDLE,
MM_INDEX_PARAM_AUDIO_DECODER_HANDLE,
MM_INDEX_PARAM_VIDEO_STREAM_END_FLAG,
MM_INDEX_PARAM_QFACTOR,
MM_INDEX_PARAM_AUDIO_MP3,
MM_INDEX_PARAM_VIDEO_INPUT_SOURCE,
MM_INDEX_PARAM_PRINT_DEBUG_INFO,
MM_INDEX_VENDOR_STREAM_FRAME_END = 0x300,
MM_INDEX_VENDOR_VIDEO_RENDER_INIT,
MM_INDEX_VENDOR_AUDIO_RENDER_INIT,
MM_INDEX_VENDOR_CLEAR_BUFFER,
MM_INDEX_VENDOR_VIDEO_RENDER_SCREEN_SIZE,
MM_INDEX_VENDOR_AUDIO_RENDER_VOLUME,
MM_INDEX_VENDOR_DEMUXER_SKIP_TRACK,
MM_INDEX_VENDOR_VIDEO_RENDER_CAPTURE,
MM_INDEX_VENDOR_MUXER_RECORD_FILE_INFO,
MM_INDEX_VENDOR_VIDEO_ENC_CAPTURE,
} MM_INDEX_TYPE;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* File EOF */