1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __APP_MEDIA_PLAYER_H__ 5 #define __APP_MEDIA_PLAYER_H__ 6 7 #include "resources.h" 8 #include "app_bt_stream.h" 9 10 #define MEDIA_DEFAULT_LANGUAGE (0) 11 12 typedef enum 13 { 14 T_AUDIO_ID = 0x0, 15 16 T_AUDIO_NUMBER, 17 18 }MEDIA_AUDIO_TYPE; 19 20 #define MAX_PHB_NUMBER 20 21 22 #define PROMPT_ID_BIT_MASK_RAW_ID ((1 << 8) - 1) 23 #define PROMOT_ID_BIT_MASK_NOT_MERGING (1 << 8) 24 #define PROMOT_ID_BIT_MASK_NOT_ON_BOTH_SIDES (1 << 9) 25 26 #define IS_PROMPT_NON_MERGING(promptId) ((promptId)&PROMOT_ID_BIT_MASK_NOT_MERGING) 27 #define IS_PROMPT_PLAYED_LOCALLY(promptId) ((promptId)&PROMOT_ID_BIT_MASK_NOT_ON_BOTH_SIDES) 28 #define PROMPT_ID_FROM_ID_VALUE(promptIdVal) ((promptIdVal)&PROMPT_ID_BIT_MASK_RAW_ID) 29 30 typedef struct 31 { 32 uint16_t id; 33 uint16_t status; 34 // APP_AUDIO_STATUS 35 uint16_t aud_type; 36 uint16_t aud_id; 37 char phb_number[MAX_PHB_NUMBER]; 38 }msg_num_ptr; 39 40 typedef struct 41 { 42 uint16_t promptId; 43 int16_t volume_level_override; 44 float coeff_for_mix_prompt_for_music; 45 float coeff_for_mix_music_for_music; 46 float coeff_for_mix_prompt_for_call; 47 float coeff_for_mix_call_for_call; 48 49 } __attribute__((packed)) PROMPT_MIX_PROPERTY_T; 50 51 #define PROMPT_MIX_PROPERTY_TO_ADD(promptId, \ 52 volume_level_override, \ 53 coeff_for_mix_prompt_for_music, \ 54 coeff_for_mix_music_for_music, \ 55 coeff_for_mix_prompt_for_call, \ 56 coeff_for_mix_call_for_call) \ 57 static PROMPT_MIX_PROPERTY_T promptId##_entry __attribute__((used, section(".mixprompt_property_table"))) = \ 58 {(promptId), \ 59 (volume_level_override), \ 60 (coeff_for_mix_prompt_for_music), \ 61 (coeff_for_mix_music_for_music), \ 62 (coeff_for_mix_prompt_for_call), \ 63 (coeff_for_mix_call_for_call), \ 64 }; 65 66 extern uint32_t __mixprompt_property_table_start[]; 67 extern uint32_t __mixprompt_property_table_end[]; 68 69 #ifdef __cplusplus 70 extern "C" { 71 #endif 72 73 // Prompt will be played on the both sides if they're connected. 74 // If there are music/phone call on-going, the prompt will be mixed. 75 uint32_t media_PlayAudio(AUD_ID_ENUM id,uint8_t device_id); 76 77 // Prompt will be played locally no matter whether earbuds are connected or not 78 // If there are music/phone call on-going, the prompt will be mixed. 79 void media_PlayAudio_locally(AUD_ID_ENUM id, uint8_t device_id); 80 81 // Prompt will be played on peer device only if they're connected. 82 // If there are music/phone call on-going, the music or phone call output will be stopped 83 // until the prompt playing is completed. 84 void media_PlayAudio_remotely(AUD_ID_ENUM id, uint8_t device_id); 85 86 // Prompt will be played on the both sides if they're connected. 87 // If there are music/phone call on-going, the music or phone call output will be stopped 88 // until the prompt playing is completed. 89 void media_PlayAudio_standalone(AUD_ID_ENUM id, uint8_t device_id); 90 91 // Prompt will be played locally no matter whether earbuds are connected or not 92 // If there are music/phone call on-going, the music or phone call output will be stopped 93 // until the prompt playing is completed. 94 void media_PlayAudio_standalone_locally(AUD_ID_ENUM id, uint8_t device_id); 95 96 // Prompt will be played on the peer device only if they're connected. 97 // If there are music/phone call on-going, the music or phone call output will be stopped 98 // until the prompt playing is completed. 99 void media_PlayAudio_standalone_remotely(AUD_ID_ENUM id, uint8_t device_id); 100 101 void media_Set_IncomingNumber(const char* pNumber); 102 103 void media_FreeMemory(void* data); 104 105 int app_play_audio_onoff(bool on, APP_AUDIO_STATUS* status); 106 107 void stand_alone_prompt_supervision_timer_init(void); 108 109 void app_play_audio_set_lang(int L); 110 111 int app_play_audio_get_lang(); 112 113 void app_audio_playback_done(void); 114 115 void media_runtime_audio_prompt_update(uint16_t id, uint8_t** ptr, uint32_t* len); 116 117 PROMPT_MIX_PROPERTY_T* get_prompt_mix_property(uint16_t promptId); 118 119 AUD_ID_ENUM media_GetCurrentPrompt(uint8_t device_id); 120 121 AUD_ID_ENUM app_get_current_standalone_promptId(void); 122 123 void update_standalone_prompt_volume(int8_t vol); 124 125 void app_tws_cmd_stop_prompt_handler(uint8_t* ptrParam, uint16_t paramLen); 126 127 void app_stop_both_prompt_playing(void); 128 129 void app_tws_stop_peer_prompt(void); 130 131 int app_play_audio_stop(void); 132 133 int app_play_audio_get_aud_id(void); 134 135 void trigger_media_play(AUD_ID_ENUM id, uint8_t device_id, uint8_t isMerging); 136 137 #ifdef AUDIO_LINEIN 138 uint32_t app_play_audio_lineinmode_more_data(uint8_t *buf, uint32_t len); 139 140 int app_play_audio_lineinmode_init(uint8_t mode, uint32_t buff_len); 141 142 int app_play_audio_lineinmode_start(APP_AUDIO_STATUS* status); 143 144 int app_play_audio_lineinmode_stop(APP_AUDIO_STATUS* status); 145 146 #endif 147 148 void app_tws_sync_prompt_check(void); 149 150 void app_tws_sync_prompt_manager_reset(void); 151 152 #ifdef __cplusplus 153 } 154 #endif 155 156 #endif 157 158