|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2009-2019. All rights reserved.
|
|
|
* Description: Defines avplay loop thread api
|
|
|
* Author: Hisilicon
|
|
|
* Create: 2009-12-21
|
|
|
* History:
|
|
|
*/
|
|
|
#ifndef __AVPLAY_LOOP_H__
|
|
|
#define __AVPLAY_LOOP_H__
|
|
|
|
|
|
#include "avplay_common.h"
|
|
|
#include "avplay_config.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
typedef enum {
|
|
|
AVPLAY_LOOP_TYPE_AUD = 0,
|
|
|
AVPLAY_LOOP_TYPE_VID,
|
|
|
AVPLAY_LOOP_TYPE_EVT,
|
|
|
AVPLAY_LOOP_TYPE_REPORT,
|
|
|
AVPLAY_LOOP_TYPE_MAX
|
|
|
} avplay_loop_type;
|
|
|
|
|
|
/* idle->running->pause->stop */
|
|
|
typedef enum {
|
|
|
AVPLAY_LOOP_STATE_IDLE = 0,
|
|
|
AVPLAY_LOOP_STATE_PAUSE,
|
|
|
AVPLAY_LOOP_STATE_PREPLAY,
|
|
|
AVPLAY_LOOP_STATE_RUNNING,
|
|
|
AVPLAY_LOOP_STATE_STOP,
|
|
|
AVPLAY_LOOP_STATE_MAX
|
|
|
} avplay_loop_state;
|
|
|
|
|
|
typedef enum {
|
|
|
AVPLAY_LOOP_PAUSE_DEFAULT = 0, /* 默认pause状态,只pause帧数据操作 */
|
|
|
AVPLAY_LOOP_PAUSE_RESET, /* pause 并执行reset操作 */
|
|
|
AVPLAY_LOOP_PAUSE_FREEZE /* pause状态,暂停所有的数据操作,包括帧数据操作 */
|
|
|
} avplay_loop_pause_opt;
|
|
|
|
|
|
typedef enum {
|
|
|
AVPLAY_LOOP_PLAY_INFO = 0,
|
|
|
AVPLAY_LOOP_SYNC_INFO,
|
|
|
AVPLAY_LOOP_FRAME_INFO
|
|
|
} avplay_loop_info_id;
|
|
|
|
|
|
typedef enum {
|
|
|
AVPLAY_LOOP_STAGE_WATING = 0,
|
|
|
AVPLAY_LOOP_STAGE_RUNNING,
|
|
|
} avplay_loop_stage;
|
|
|
|
|
|
struct tag_avplay_loop;
|
|
|
struct tag_avplay_context;
|
|
|
|
|
|
typedef td_s32 (*get_info_fn)(const struct tag_avplay_loop *loop, td_u32 id, void *info, td_u32 info_size);
|
|
|
typedef td_s32 (*recv_event_fn)(struct tag_avplay_loop *loop, td_u32 event, const void *param, td_u32 param_size);
|
|
|
typedef td_s32 (*state_prepare_fn)(struct tag_avplay_loop *loop, avplay_loop_state state, td_u64 param);
|
|
|
|
|
|
typedef td_s32 (*main_process_fn)(struct tag_avplay_loop *loop, td_s64 *wait_time);
|
|
|
typedef td_s32 (*post_process_fn)(struct tag_avplay_loop *loop);
|
|
|
typedef td_s32 (*sync_process_fn)(const struct tag_avplay_loop *loop);
|
|
|
|
|
|
typedef struct tag_avplay_loop {
|
|
|
avplay_thread_info thread;
|
|
|
|
|
|
struct tag_avplay_context *ctx;
|
|
|
avplay_loop_type type;
|
|
|
|
|
|
avplay_mutex_t mutex;
|
|
|
avplay_cond_info cond;
|
|
|
avplay_cond_info sync_cond;
|
|
|
td_bool wakeup;
|
|
|
td_bool wakeup_sync;
|
|
|
sync_process_fn wakeup_sync_process;
|
|
|
|
|
|
avplay_loop_stage stage;
|
|
|
avplay_loop_state state;
|
|
|
td_u64 state_param;
|
|
|
state_prepare_fn state_prepare;
|
|
|
recv_event_fn recv_event;
|
|
|
get_info_fn get_info;
|
|
|
|
|
|
main_process_fn main_process;
|
|
|
post_process_fn post_process;
|
|
|
void *private;
|
|
|
|
|
|
td_u32 counter;
|
|
|
td_bool is_changing_loop_state;
|
|
|
} avplay_loop;
|
|
|
|
|
|
avplay_loop *avplay_loop_create(struct tag_avplay_context *ctx, avplay_loop_type type);
|
|
|
td_s32 avplay_loop_destroy(avplay_loop *loop);
|
|
|
td_s32 avplay_loop_setstate(avplay_loop *loop, avplay_loop_state state, td_u64 param);
|
|
|
td_s32 avplay_loop_report_event(avplay_loop *loop, td_u32 event, const void *param, td_u32 param_size);
|
|
|
td_s32 avplay_loop_notify_event(avplay_loop *loop, td_u32 event, const void *param, td_u32 param_size);
|
|
|
td_s32 avplay_loop_get_info(const avplay_loop *loop, td_u32 id, void *info, td_u32 info_size);
|
|
|
td_s32 avplay_loop_show(const avplay_loop *loop, td_char *show_buf, td_u32 buf_len, td_bool show_ctx);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#endif |