1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 * 4 */ 5 6 #ifndef __UVOICE_PLAYER_H__ 7 #define __UVOICE_PLAYER_H__ 8 9 #include "uvoice_types.h" 10 11 /** @defgroup uvoice_player_api uvoice_player 12 * @ingroup uvoice_aos_api 13 * @{ 14 */ 15 16 /** @brief 播放状态 */ 17 typedef enum { 18 PLAYER_STAT_IDLE = 0, 19 PLAYER_STAT_READY, 20 PLAYER_STAT_RUNNING, 21 PLAYER_STAT_PAUSED, 22 PLAYER_STAT_RESUME, 23 PLAYER_STAT_STOP, 24 PLAYER_STAT_COMPLETE, 25 PLAYER_STAT_SEEK_CPLT, 26 PLAYER_STAT_MEDIA_INFO, 27 PLAYER_STAT_SOURCE_INVALID, 28 PLAYER_STAT_FORMAT_UNSUPPORT, 29 PLAYER_STAT_LIST_PLAY_START, 30 PLAYER_STAT_LIST_PLAY_STOP, 31 PLAYER_STAT_ERROR, 32 } player_state_t; 33 34 /** @brief 播放接口 */ 35 typedef struct { 36 int (*start)(void); 37 int (*stop)(void); 38 int (*pause)(void); 39 int (*resume)(void); 40 int (*complete)(void); 41 int (*stop_async)(void); 42 int (*pause_async)(void); 43 int (*resume_async)(void); 44 int (*set_source)(char *source); 45 int (*clr_source)(void); 46 int (*set_stream)(media_format_t format, int cache_enable, int cache_size); 47 int (*put_stream)(const uint8_t *buffer, int nbytes); 48 int (*clr_stream)(int immediate); 49 int (*play_list)(char **list); 50 int (*set_pcminfo)(int rate, int channels, int bits, int frames); 51 int (*get_duration)(int *duration); 52 int (*get_position)(int *position); 53 int (*set_volume)(int volume); 54 int (*get_volume)(int *volume); 55 int (*volume_range)(int *max, int *min); 56 int (*seek)(int second); 57 int (*playback)(char *source); 58 int (*wait_complete)(void); 59 int (*download)(char *name); 60 int (*download_abort)(void); 61 int (*cache_config)(cache_config_t *config); 62 int (*set_fade)(int out_period, int in_period); 63 int (*set_format)(media_format_t format); 64 int (*set_out_device)(audio_out_device_t device); 65 int (*set_external_pa)(audio_extpa_info_t *info); 66 int (*set_standby)(int msec); 67 int (*eq_enable)(int enable); 68 int (*state_dump)(void); 69 int (*pcmdump_enable)(int enable); 70 int (*get_state)(player_state_t *state); 71 int (*get_delay)(int *delay_ms); 72 int (*get_mediainfo)(media_info_t *info); 73 int (*get_cacheinfo)(int *cache_size); 74 int (*format_support)(media_format_t format); 75 void *priv; 76 } uvoice_player_t; 77 78 /** 79 * 创建播放器 80 * 81 * @retrun 成功返回非NULL指针,失败返回NULL. 82 */ 83 uvoice_player_t *uvoice_player_create(void); 84 85 /** 86 * 释放播放器. 87 * 88 * @param[in] mplayer 创建播放器时返回的指针. 89 * 90 * @return 0成功,其他失败. 91 */ 92 int uvoice_player_release(uvoice_player_t *mplayer); 93 94 /** 95 * @} 96 */ 97 98 #endif /* __UVOICE_PLAYER_H__ */ 99