4G_module/include/cmiot/cm_audio_player.h

221 lines
6.9 KiB
C
Raw Normal View History

2024-09-02 17:54:29 +08:00
/**
* @file cm_audio_player.h
* @brief Audio player接口
* @copyright Copyright © 2021 China Mobile IOT. All rights reserved.
* @author By WangPeng
* @date 2021/4/12
*
* @defgroup audio_player
* @ingroup audio_player
* @{
*/
#ifndef __OPENCPU_AUDIO_PLAYER_H__
#define __OPENCPU_AUDIO_PLAYER_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include "cm_audio_common.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/** 音频播放通道支持 */
typedef enum
{
CM_AUDIO_PLAY_CHANNEL_RECEIVER = 1, /*!< 听筒通道,不支持设置 */
CM_AUDIO_PLAY_CHANNEL_HEADSET, /*!< 耳机通道,不支持设置 */
CM_AUDIO_PLAY_CHANNEL_SPEAKER, /*!< 扬声器通道,不支持设置 */
#if 0
CM_AUDIO_PLAY_CHANNEL_REMOTE, /*!< 远端播放(需建立通话),暂不支持 */
#endif
} cm_audio_play_channel_e;
/** 音频播放回调的事件类型 */
typedef enum
{
CM_AUDIO_PLAY_EVENT_FINISHED = 1, /*!< 播放结束 */
#if 0
CM_AUDIO_PLAY_EVENT_INTERRUPT, /*!< 播放中断 */
#endif
} cm_audio_play_event_e;
/** 音频播放设置类型 */
typedef enum
{
CM_AUDIO_PLAY_CFG_CHANNEL = 1, /*!< 播放通道支持范围参见cm_audio_play_channel_e枚举量不支持设置 */
CM_AUDIO_PLAY_CFG_VOLUME, /*!< 播放音量支持范围参见0~100 */
} cm_audio_play_cfg_type_e;
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/**
* @brief
*
* @param [in] event
* @param [in] param
*
* @details API中传入 \n
* 使UART打印log
*/
typedef void (*cm_audio_play_callback_t)(cm_audio_play_event_e event, void *param);
/**
* @brief
*
* @param [in] type
* @param [in] value
*
* @return
* = 0 - \n
* = -1 -
*
* @details 使// \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_play_set_cfg(cm_audio_play_cfg_type_e type, void *value);
/**
* @brief
*
* @param [in] type
* @param [out] value
*
* @return
* = 0 - \n
* = -1 -
*
* @details 使// \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_play_get_cfg(cm_audio_play_cfg_type_e type, void *value);
/**
* @brief
*
* @param [in] path /
* @param [in] format
* @param [in] sample_param PCM采样参数format参数为CM_AUDIO_PLAY_FORMAT_PCM使用NULL
* @param [in] cb 线
* @param [in] cb_param cm_audio_play_callback回调函数中param参数相对应8
*
* @return
* = 0 - \n
* = -1 -
*
* @details mp3amr格式 \n
* 使UART打印log \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_play_file(const char *path, cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_play_callback_t cb, void *cb_param);
/**
* @brief
*
* @return
* = 0 - \n
* = -1 -
*
* @details MP3AMR格式; \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_player_pause(void);
/**
* @brief
*
* @return
* = 0 - \n
* = -1 -
*
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_player_resume(void);
/**
* @brief
*
* @return
* = 0 - \n
* = -1 -
*
* @details MP3AMR格式; \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_player_stop(void);
/**
* @brief /
*
* @param [in] format PCM
* @param [in] sample_param PCM采样参数format参数为CM_AUDIO_PLAY_FORMAT_PCM使用NULL
*
* @return
* = 0 - \n
* = -1 -
*
* @details PCMMP3AMR格式 \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_player_stream_open(cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param);
/**
* @brief /
*
* @param [in] data
* @param [in] size
*
* @return
* >= 0 - \n
* = -1 -
*
* @details PCMMP3AMR格式 \n
* PCM格式8k 16bit的PCM数据320320 \n
* AMR格式 \n
* 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
int32_t cm_audio_player_stream_push(uint8_t *data, uint32_t size);
/**
* @brief /
*
* @details 8M版本ML307A-DSLN ML307A-GSLN ML305A-DSaudio功能
*/
void cm_audio_player_stream_close(void);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif
/** @}*/