You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
397 lines
10 KiB
397 lines
10 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2009-2019. All rights reserved.
|
|
* Description: Defines avplay context api
|
|
* Author: Hisilicon
|
|
* Create: 2009-12-21
|
|
* History:
|
|
*/
|
|
#ifndef __AVPLAY_CONTEXT_H__
|
|
#define __AVPLAY_CONTEXT_H__
|
|
|
|
#include "avplay_common.h"
|
|
#include "mpi_media_ext.h"
|
|
#include "mpi_vdec_ext.h"
|
|
#include "mpi_adec_ext.h"
|
|
#include "mpi_avplay_ext.h"
|
|
#include "mpi_win_ext.h"
|
|
#include "drv_video_ext.h"
|
|
|
|
#include "avplay_loop.h"
|
|
#include "avplay_buffer.h"
|
|
#include "avplay_config.h"
|
|
|
|
#ifdef __cplusplus
|
|
#if __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#endif
|
|
|
|
#define avplay_get_handle(id) ((SOC_ID_AVPLAY << 24) | (id))
|
|
#define avplay_get_id(handle) ((handle) & 0xFFFF)
|
|
#define avplay_get_modid(handle) (((handle) >> 24) & 0xff)
|
|
|
|
typedef enum {
|
|
AVPLAY_AUD_MODE_ADEC,
|
|
AVPLAY_AUD_MODE_RENDER
|
|
} avplay_aud_mode;
|
|
|
|
/* idle->acquired->queued->dequeued->released->idle */
|
|
typedef enum {
|
|
AVPLAY_RESOURCE_STATE_IDLE = 0,
|
|
AVPLAY_RESOURCE_STATE_ACQUIRED,
|
|
AVPLAY_RESOURCE_STATE_RELEASED,
|
|
AVPLAY_RESOURCE_STATE_QUEUED,
|
|
AVPLAY_RESOURCE_STATE_DEQUEUED
|
|
} avplay_resource_state;
|
|
|
|
typedef enum {
|
|
AVPLAY_VFRAME_BUFFER_NORMAL = 0,
|
|
AVPLAY_VFRAME_BUFFER_OVERFLOW,
|
|
AVPLAY_VFRAME_BUFFER_UNDERFLOW,
|
|
AVPLAY_VFRAME_BUFFER_ABNORMAL
|
|
} avplay_vframe_buffer_state;
|
|
|
|
typedef enum {
|
|
AVPLAY_NOTIFY_EVENT_EOS = 0x0,
|
|
AVPLAY_NOTIFY_EVENT_STOP,
|
|
AVPLAY_NOTIFY_EVENT_STATUS_REPORT,
|
|
AVPLAY_NOTIFY_EVENT_SYNC_PTS_JUMP,
|
|
AVPLAY_NOTIFY_EVENT_SYNC_STATE_CHANGE,
|
|
|
|
AVPLAY_NOTIFY_EVENT_AUD_NEW_FRAME,
|
|
AVPLAY_NOTIFY_EVENT_AUD_NEW_ES,
|
|
AVPLAY_NOTIFY_EVENT_AUD_BUF_STATE_CHANGE,
|
|
AVPLAY_NOTIFY_EVENT_AUD_INFO_CHANGE,
|
|
AVPLAY_NOTIFY_EVENT_AUD_UNSUPPORT,
|
|
AVPLAY_NOTIFY_EVENT_AUD_FRAME_ERR,
|
|
AVPLAY_NOTIFY_EVENT_AUD_FIRST_DECODE_FRAME,
|
|
AVPLAY_NOTIFY_EVENT_ONLY_SUPPORT_PASSTHROUGH,
|
|
|
|
AVPLAY_NOTIFY_EVENT_VID_NEW_FRAME_DECODED,
|
|
AVPLAY_NOTIFY_EVENT_VID_FIRST_FRAME_DISPLAYED,
|
|
AVPLAY_NOTIFY_EVENT_VID_FRAME_DISPLAY_TIME,
|
|
AVPLAY_NOTIFY_EVENT_VID_NORM_SWITCH,
|
|
AVPLAY_NOTIFY_EVENT_VID_FRAMEPACKING_CHANGE,
|
|
AVPLAY_NOTIFY_EVENT_NEW_USER_DATA,
|
|
AVPLAY_NOTIFY_EVENT_VID_BUF_STATE_CHANGE,
|
|
AVPLAY_NOTIFY_EVENT_VID_UNSUPPORT,
|
|
AVPLAY_NOTIFY_EVENT_VID_ERR_TYPE,
|
|
AVPLAY_NOTIFY_EVENT_VID_FRAME_ERR,
|
|
AVPLAY_NOTIFY_EVENT_VID_FRAME_INFO,
|
|
AVPLAY_NOTIFY_EVENT_VID_TARGET_POSITION_DISPLAYED,
|
|
AVPLAY_NOTIFY_EVENT_VID_LAST_FRAME_FLAG,
|
|
AVPLAY_NOTIFY_EVENT_VID_EXT_SYNC_PROC,
|
|
|
|
AVPLAY_NOTIFY_EVENT_MAX
|
|
} avplay_notify_event_type;
|
|
|
|
#define FRAME_RATE_RATIO 1000
|
|
|
|
/* Video Peek */
|
|
typedef struct {
|
|
td_bool enable;
|
|
td_bool vid_seek;
|
|
td_bool aud_seek;
|
|
avplay_time_t idr_pts;
|
|
avplay_time_t start_pts;
|
|
} avplay_peek_frame_info;
|
|
|
|
/* UVMOS */
|
|
typedef struct {
|
|
td_bool underflow;
|
|
|
|
td_u32 rd;
|
|
td_u32 wr;
|
|
td_u32 cnt;
|
|
uapi_video_frame_qos info[AVPLAY_MAX_UVMOS_INFO_CNT];
|
|
} avplay_uvmos_data;
|
|
|
|
typedef struct {
|
|
avplay_mutex_t mutex;
|
|
td_bool enable;
|
|
|
|
td_u32 frmrate;
|
|
td_u32 same_frmrate_cnt;
|
|
td_u64 last_report_time;
|
|
td_u64 report_interval;
|
|
|
|
avplay_uvmos_data *data;
|
|
} avplay_uvmos_info;
|
|
|
|
/* sync info */
|
|
typedef struct {
|
|
td_s64 cur_vid_es_pts;
|
|
td_s64 cur_aud_es_pts;
|
|
} avplay_sync_info;
|
|
|
|
typedef struct {
|
|
td_bool is_vdec_speed_err_report;
|
|
td_bool is_adec_speed_err_report;
|
|
td_bool is_pts_normal_loop_err_report;
|
|
|
|
td_bool is_eos_fail_err_report;
|
|
td_bool aud_eos_report_check_status;
|
|
td_bool vid_eos_report_check_status;
|
|
td_u32 aud_eos_report_check_start_time;
|
|
td_u32 vid_eos_report_check_start_time;
|
|
} avplay_fc_info_status;
|
|
|
|
#ifdef AVPLAY_SUPPORT_VID_ES_BUF
|
|
typedef union {
|
|
td_u8 *pointer;
|
|
td_u64 integer;
|
|
} avplay_addr_pu8;
|
|
|
|
typedef struct {
|
|
td_mem_handle_t handle;
|
|
td_mem_size_t offset;
|
|
avplay_addr_pu8 buf_vir;
|
|
|
|
td_u32 buf_size; /* Buffer size(byte) */
|
|
avplay_time_t pts; /* Stream pts, -1 invalid */
|
|
td_bool is_end_of_frm;
|
|
} avplay_vid_buf;
|
|
#else
|
|
typedef ext_vdec_stream avplay_vid_buf;
|
|
#endif
|
|
|
|
typedef struct {
|
|
/* resource */
|
|
td_handle self;
|
|
td_handle sync;
|
|
td_handle ssm;
|
|
td_handle dmx_band;
|
|
td_handle pcr_dmx;
|
|
td_u32 pcr_pid;
|
|
|
|
/* control */
|
|
uapi_avplay_status cur_state;
|
|
uapi_avplay_status pre_state;
|
|
|
|
td_bool ts_live_play;
|
|
|
|
td_bool presync_finish;
|
|
|
|
/* fund stream */
|
|
td_bool prestrat_fund_finish;
|
|
td_bool prestart_fund_stream;
|
|
td_u32 prestrat_fund_time;
|
|
|
|
td_bool presync_fund_finish;
|
|
td_bool presync_fund_stream;
|
|
td_u32 presync_fund_time;
|
|
|
|
td_bool break_fund_finish;
|
|
td_bool break_fund_stream;
|
|
td_u32 break_fund_time;
|
|
td_u32 break_fund_count;
|
|
|
|
/* attribute */
|
|
uapi_avplay_attr attr;
|
|
uapi_avplay_buff_overflow_type overflow_policy;
|
|
uapi_avplay_low_delay_attr low_delay_attr;
|
|
uapi_avplay_tplay_opt tplay_option;
|
|
uapi_sync_attr sync_attr;
|
|
|
|
/* feature */
|
|
avplay_peek_frame_info peek_frame;
|
|
td_bool step_mode; /* step play */
|
|
td_bool step_play;
|
|
avplay_sync_info sync_info;
|
|
|
|
td_u32 pts_print_cnt; /* process_status_event_check_pts_diff:controls PTS print frequency. */
|
|
|
|
uapi_avplay_event_callback_fn evt_cb[AVPLAY_NOTIFY_EVENT_MAX];
|
|
} avplay_com_ctx;
|
|
|
|
typedef struct {
|
|
avplay_com_ctx *com;
|
|
|
|
/* resource */
|
|
td_u32 pid;
|
|
td_handle pid_ch;
|
|
td_handle dmx;
|
|
td_handle vdec;
|
|
td_handle frame_win; /* for queue/dequeue frame */
|
|
td_handle master_win;
|
|
td_handle virtual_win[AVPLAY_MAX_VIR_FRMCHAN];
|
|
td_u8 virtual_win_cnt;
|
|
|
|
/* date && buffer */
|
|
td_s64 first_ves_pts;
|
|
td_u64 first_vbuf_put_time;
|
|
avplay_vid_buf es_buf;
|
|
avplay_resource_state es_buf_state;
|
|
ext_drv_video_frame last_frame;
|
|
|
|
/* vdec first frame info */
|
|
td_s64 first_vframe_pts;
|
|
td_u64 first_vframe_acq_time;
|
|
|
|
#ifdef AVPLAY_SUPPORT_VID_ES_BUF
|
|
avplay_es_buffer es_buf_pool;
|
|
avplay_es_block es_block;
|
|
avplay_resource_state es_block_state;
|
|
#endif
|
|
|
|
#ifdef AVPLAY_SUPPORT_VID_FRM_BUF
|
|
avplay_fb_info fb_info;
|
|
#endif
|
|
avplay_mem_info user_data_mem;
|
|
|
|
/* control */
|
|
td_bool enable;
|
|
td_bool iframe_enable; /* for decode iframe */
|
|
td_bool pre_enable; /* for pre_start */
|
|
td_bool secure;
|
|
td_bool set_eos_flag; /* set by user */
|
|
td_bool eos_reported; /* report by sdk */
|
|
td_bool vdec_eos;
|
|
td_u32 capture_cnt;
|
|
td_bool has_hdr_info;
|
|
td_bool hdr_padding;
|
|
td_bool set_hdr_strategy;
|
|
|
|
td_bool peek_one_frame;
|
|
uapi_avplay_buf_state cur_buf_state;
|
|
td_u32 used_buf_percent;
|
|
td_u32 wait_output_frm_num;
|
|
td_u32 out_frm_rate;
|
|
td_u32 channel_delay;
|
|
td_bool discard_frame;
|
|
td_bool first_frame_disp;
|
|
td_bool first_frame_queue_win;
|
|
td_s64 first_frame_display_time;
|
|
td_u32 acquired_last_es_time;
|
|
td_u32 last_channel_delay;
|
|
td_u32 acquired_last_frame_time;
|
|
td_u32 frame_under_load_count;
|
|
|
|
/* attribute */
|
|
uapi_vdec_attr codec_attr;
|
|
uapi_avplay_dolby_hdr_attr dolbyvision_attr;
|
|
uapi_avplay_frame_rate_param frmrate_param;
|
|
avplay_bps_info bps_info;
|
|
ext_avplay_framebuffer_mode fb_mode;
|
|
|
|
/* feature */
|
|
avplay_uvmos_info uvmos;
|
|
uapi_hdr_info hdr_info;
|
|
|
|
td_u32 vid_drop_frame_cnt;
|
|
td_u32 private_disp_time;
|
|
td_u32 frame_time;
|
|
|
|
td_bool set_win_freeze;
|
|
ext_drv_win_sync last_sync_mode;
|
|
td_bool set_win_eos;
|
|
} avplay_vid_ctx;
|
|
|
|
typedef struct {
|
|
avplay_com_ctx *com;
|
|
|
|
/* resource */
|
|
td_u8 cur_chn_id;
|
|
td_u8 dmx_chn_cnt;
|
|
td_u32 pid[AVPLAY_MAX_DMX_AUD_CHAN_NUM];
|
|
td_handle pid_ch[AVPLAY_MAX_DMX_AUD_CHAN_NUM];
|
|
td_handle ad_pid_ch;
|
|
td_handle dmx[AVPLAY_MAX_DMX_AUD_CHAN_NUM];
|
|
td_handle ad_dmx;
|
|
|
|
td_handle adec;
|
|
td_handle ad_adec;
|
|
td_handle render_track;
|
|
td_handle sync_track; /* main track */
|
|
td_handle track[AVPLAY_MAX_TRACK_NUM];
|
|
td_u8 track_cnt;
|
|
|
|
/* date && buffer */
|
|
td_s64 first_aes_pts;
|
|
td_u64 first_abuf_put_time;
|
|
ext_stream_buf es_buf;
|
|
avplay_resource_state es_buf_state;
|
|
ext_stream_buf ad_es_buf;
|
|
avplay_resource_state ad_es_buf_state;
|
|
td_u32 send_last_es_time;
|
|
td_u32 last_es_cost_time;
|
|
td_u32 penult_cost_time;
|
|
|
|
/* adec first frame info */
|
|
td_s64 first_aframe_pts;
|
|
td_u64 first_aframe_acq_time;
|
|
|
|
/* control */
|
|
td_bool enable;
|
|
td_bool pre_enable;
|
|
td_bool enable_tplay; /* set by user */
|
|
td_bool support_tplay; /* judge with tplay option */
|
|
td_bool secure;
|
|
td_bool set_eos_flag; /* set by user */
|
|
td_bool eos_reported; /* report by sdk */
|
|
td_bool adec_eos;
|
|
avplay_aud_mode mode;
|
|
uapi_avplay_buf_state cur_buf_state;
|
|
td_u32 used_buf_percent;
|
|
td_u32 aud_dmx_buf_used_percent;
|
|
td_u32 channel_delay;
|
|
|
|
/* attribute */
|
|
ha_codec_name acodec_name; /* only for adec mode */
|
|
td_u32 codec_id; /* single track */
|
|
td_u32 adec_out_buf_num;
|
|
uapi_audio_decode_attr *codec_attr; /* support multi track, count is dmx_chn_cnt */
|
|
td_bool external_aud;
|
|
uapi_audio_decode_attr inner_codec_attr;
|
|
uapi_audio_decode_attr external_codec_attr;
|
|
uapi_avplay_ad_attr ad_attr;
|
|
td_s16 ad_balance;
|
|
avplay_bps_info bps_info;
|
|
td_bool ao_track_set_eos;
|
|
} avplay_aud_ctx;
|
|
|
|
typedef struct tag_avplay_context {
|
|
struct tag_avplay_loop *loop[AVPLAY_LOOP_TYPE_MAX];
|
|
|
|
avplay_com_ctx com;
|
|
avplay_vid_ctx vid;
|
|
avplay_aud_ctx aud;
|
|
avplay_fc_info_status fc_info;
|
|
} avplay_context;
|
|
|
|
typedef struct {
|
|
td_handle handle;
|
|
avplay_context *ctx;
|
|
avplay_mutex_t mutex;
|
|
} avplay_instance;
|
|
|
|
typedef struct {
|
|
const uapi_vdec_attr *attr;
|
|
td_u8 single_i_frame_flag;
|
|
td_bool frame_fence_en;
|
|
} avplay_vdec_attr;
|
|
|
|
avplay_instance *avplay_instance_get(td_handle handle);
|
|
|
|
td_u64 frame_rate_to_duration(td_u32 frmrate);
|
|
|
|
td_s32 avplay_context_init(avplay_context *ctx, td_handle self, const uapi_avplay_attr *attr);
|
|
td_s32 avplay_context_deinit(avplay_context *ctx);
|
|
|
|
td_s32 avplay_context_reset_vid(avplay_context *ctx, td_bool stop);
|
|
td_s32 avplay_context_reset_aud(avplay_context *ctx, td_bool stop);
|
|
td_s32 avplay_context_reset_com(avplay_com_ctx *com, td_bool stop);
|
|
|
|
td_s32 avplay_uvmos_create(avplay_vid_ctx *vid);
|
|
td_s32 avplay_uvmos_destroy(avplay_vid_ctx *vid);
|
|
td_s32 avplay_uvmos_push(avplay_vid_ctx *vid_ctx, const ext_vdec_frame *cur_frame);
|
|
td_s32 avplay_uvmos_pop(avplay_vid_ctx *vid_ctx, uapi_video_frame_qos *info);
|
|
|
|
#ifdef __cplusplus
|
|
#if __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
#endif
|