MT2523 API Reference  LinkIt SDK v4
mp3_codec.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 
36 #ifndef __MP3_CODEC_H__
37 #define __MP3_CODEC_H__
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <stdint.h>
44 #include <stdbool.h>
45 
46 #if defined(MTK_AUDIO_MIXER_SUPPORT)
47  #include "audio_mixer.h"
48  #include "audio_mixer_internal.h"
49 #endif
50 
148 typedef enum {
153  MP3_CODEC_AWS_CHECK_CLOCK_SKEW,
154  MP3_CODEC_AWS_CHECK_UNDERFLOW,
156 }
158 
160 typedef enum {
168 
169 
170 typedef enum {
174 
175 typedef enum {
179 
189 typedef struct {
190  uint8_t *buffer_base;
191  uint32_t buffer_size;
192  uint32_t write;
193  uint32_t read;
194  void *param;
196 
197 
199 typedef struct {
200  bool has_id3v2;
201  uint32_t id3v2_tage_length;
203 
205 typedef struct {
206  int32_t frame_size;
207  uint8_t *frame;
208  int32_t sampling_rate;
209  void *param;
211 
217  mp3_codec_state_t state;
219  bool underflow;
220  bool waiting;
221  bool linear_buff;
222  uint16_t audio_id;
223  uint32_t jump_file_to_specified_position;
225  int32_t flush_data_flag;
226  void *private_data;
227  void (*handler)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id);
228  void (*set_share_buffer)(mp3_codec_media_handle_t *handle, uint8_t *buffer, uint32_t length);
229  void (*get_write_buffer)(mp3_codec_media_handle_t *handle, uint8_t **buffer, uint32_t *length);
230  void (*get_read_buffer)(mp3_codec_media_handle_t *handle, uint8_t **buffer, uint32_t *length);
231  void (*write_data_done)(mp3_codec_media_handle_t *handle, uint32_t length);
233  void (*flush)(mp3_codec_media_handle_t *handle, int32_t flush_data_flag);
235  void (*read_data_done)(mp3_codec_media_handle_t *handle, uint32_t length);
239  int32_t (*get_silence_frame_information)(mp3_codec_media_handle_t *handle, int32_t *byte_count);
241  int32_t (*fill_silence_frame)(mp3_codec_media_handle_t *handle, uint8_t *buffer);
245  mp3_codec_function_return_state_t (*process)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id);
249  mp3_codec_function_return_state_t (*set_bitstream_buffer)(mp3_codec_media_handle_t *handle, uint8_t *bitstrean_buffer, uint32_t length);
250 #ifdef MTK_BT_AWS_ENABLE
253  mp3_codec_function_return_state_t (*aws_set_clock_skew_compensation_value)(mp3_codec_media_handle_t *handle, int32_t sample_count);
254  mp3_codec_function_return_state_t (*aws_get_clock_skew_status)(mp3_codec_media_handle_t *handle, int32_t *aws_clock_skew_status);
255  mp3_codec_function_return_state_t (*aws_set_clock_skew)(mp3_codec_media_handle_t *handle, bool flag);
256 #endif
257 #if defined(MTK_AUDIO_MIXER_SUPPORT)
258  audio_mixer_track_id_t mixer_track_id;
259  audio_mixer_role_t mixer_track_role;
260  void (*set_track_role)(mp3_codec_media_handle_t *handle, audio_mixer_role_t role);
261 #endif
262 };
263 
276 typedef void (*mp3_codec_callback_t)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id);
277 
278 
290 
298 
299 
304 #if defined(MTK_AUDIO_MIXER_SUPPORT)
306 #else
308 #endif
309 
310 #if 0
311 
315 mp3_codec_function_return_state_t mp3_codec_enter_resume(void);
316 
321 mp3_codec_function_return_state_t mp3_codec_enter_suspend(void);
322 #endif
323 
331 
339 
347 
354 
355 #ifdef __cplusplus
356 }
357 #endif
358 
365 #endif /* __MP3_CODEC_H__ */
366 
367 
mp3_codec_function_return_state_t(* set_bitstream_buffer)(mp3_codec_media_handle_t *handle, uint8_t *bitstrean_buffer, uint32_t length)
Set the bitstream buffer(constant array).
Definition: mp3_codec.h:249
mp3_codec_data_type_t
Definition: mp3_codec.h:175
uint8_t * buffer_base
Pointer to the ring buffer.
Definition: mp3_codec.h:190
Silence Frame Information structure.
Definition: mp3_codec.h:205
mp3_codec_function_return_state_t(* resume)(mp3_codec_media_handle_t *handle)
The MP3 codec resume function.
Definition: mp3_codec.h:244
void(* get_read_buffer)(mp3_codec_media_handle_t *handle, uint8_t **buffer, uint32_t *length)
Get the available length to read from a shared buffer and a pointer to the shared buffer...
Definition: mp3_codec.h:230
void(* handler)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id)
The MP3 codec handler.
Definition: mp3_codec.h:227
mp3_codec_media_handle_t * mp3_codec_open(mp3_codec_callback_t callback)
This function opens the MP3 codec.
mp3_codec_function_return_state_t(* process)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id)
The MP3 codec process function.
Definition: mp3_codec.h:245
uint8_t * frame
One mp3 frame.
Definition: mp3_codec.h:207
mp3_codec_function_return_state_t mp3_codec_set_memory2(void)
This function sets the memory for MP3 decoder.
Tha MP3 codec play constant array end.
Definition: mp3_codec.h:155
Data type for samples per channel.
Definition: mp3_codec.h:177
int32_t(* get_silence_frame_information)(mp3_codec_media_handle_t *handle, int32_t *byte_count)
Get silence frame information.
Definition: mp3_codec.h:239
mp3_codec_function_return_state_t mp3_codec_close(mp3_codec_media_handle_t *handle)
This function closes the MP3 codec.
The MP3 codec has stopped.
Definition: mp3_codec.h:166
int32_t(* fill_silence_frame)(mp3_codec_media_handle_t *handle, uint8_t *buffer)
Fill silence frame.
Definition: mp3_codec.h:241
void(* read_data_done)(mp3_codec_media_handle_t *handle, uint32_t length)
Update the read pointer to the shared buffer.
Definition: mp3_codec.h:235
uint32_t read
Index of the ring buffer to read the data.
Definition: mp3_codec.h:193
The MP3 codec reported an error.
Definition: mp3_codec.h:171
bool underflow
The MP3 codec data underflow occurred.
Definition: mp3_codec.h:219
bool has_id3v2
The MP3 file has ID3v2 header.
Definition: mp3_codec.h:200
void(* mp3_codec_callback_t)(mp3_codec_media_handle_t *handle, mp3_codec_event_t event_id)
This defines the MP3 codec callback function prototype.
Definition: mp3_codec.h:276
mp3_codec_function_return_state_t(* close_codec)(mp3_codec_media_handle_t *handle)
The MP3 codec close_codec function.
Definition: mp3_codec.h:247
mp3_codec_function_return_state_t(* skip_id3v2_and_reach_next_frame)(mp3_codec_media_handle_t *handle, uint32_t file_size)
Skip id3v2 header and reach next frame.
Definition: mp3_codec.h:248
mp3_codec_function_return_state_t mp3_codec_get_memory_size(uint32_t *memory_size)
This function gets the memory requirement of MP3 decoder.
The MP3 codec is in pause state.
Definition: mp3_codec.h:165
The MP3 codec is ready to play the media.
Definition: mp3_codec.h:163
bt_avrcp_continuation_data_req_type
Definition: bt_avrcp.h:334
void(* get_data_status)(mp3_codec_media_handle_t *handle, mp3_codec_data_type_t data_type, int32_t *data_status)
Get data status.
Definition: mp3_codec.h:238
int32_t frame_size
Size of one mp3 frame.
Definition: mp3_codec.h:206
An error occurred.
Definition: mp3_codec.h:161
bool waiting
The MP3 codec is waiting to fill data.
Definition: mp3_codec.h:220
void(* write_data_done)(mp3_codec_media_handle_t *handle, uint32_t length)
Update the write pointer to the shared buffer.
Definition: mp3_codec.h:231
uint32_t write
Index of the ring buffer to write the data.
Definition: mp3_codec.h:192
mp3_codec_state_t
MP3 codec state.
Definition: mp3_codec.h:160
void(* get_write_buffer)(mp3_codec_media_handle_t *handle, uint8_t **buffer, uint32_t *length)
Get the available length to write into a shared buffer and a pointer to the shared buffer...
Definition: mp3_codec.h:229
int32_t(* get_data_count)(mp3_codec_media_handle_t *handle)
Get available data amount of the shared buffer.
Definition: mp3_codec.h:237
void(* reset_share_buffer)(mp3_codec_media_handle_t *handle)
Reset the shared buffer&#39;s information.
Definition: mp3_codec.h:234
The bitstream has an underflow.
Definition: mp3_codec.h:151
Shared buffer structure.
Definition: mp3_codec.h:189
uint32_t id3v2_tage_length
The ID3v2 header length.
Definition: mp3_codec.h:201
mp3_codec_audio_buffer_t share_buff
The shared buffer information for the MP3 codec.
Definition: mp3_codec.h:218
The codec operation was successful.
Definition: mp3_codec.h:149
The MP3 codec requested a bitstream.
Definition: mp3_codec.h:150
MP3 id3v2 structure.
Definition: mp3_codec.h:199
void(* flush)(mp3_codec_media_handle_t *handle, int32_t flush_data_flag)
Flush the shared buffer to decode.
Definition: mp3_codec.h:233
mp3_codec_function_return_state_t
Definition: mp3_codec.h:170
mp3_codec_mp3_id3v2_information_t id3v2_information
< MP3 codec uses the event MP3_CODEC_MEDIA_JUMP_FILE_TO to jump to a specified location (in bytes) in...
Definition: mp3_codec.h:224
int32_t sampling_rate
Sampling Rate.
Definition: mp3_codec.h:208
Data type for audio.
Definition: mp3_codec.h:176
The MP3 codec requested to jump to specific position on the file.
Definition: mp3_codec.h:152
uint16_t audio_id
The audio ID of the MP3 codec.
Definition: mp3_codec.h:222
MP3 codec handle structure.
Definition: mp3_codec.h:216
The MP3 codec is in playing state.
Definition: mp3_codec.h:164
mp3_codec_state_t state
The MP3 codec state.
Definition: mp3_codec.h:217
The MP3 codec is inactive.
Definition: mp3_codec.h:162
void * param
Extended parameter or information.
Definition: mp3_codec.h:209
bool linear_buff
The MP3 codec use linear buffer or not.
Definition: mp3_codec.h:221
uint32_t buffer_size
Size of the ring buffer.
Definition: mp3_codec.h:191
int32_t(* get_free_space)(mp3_codec_media_handle_t *handle)
Get the free space length available in the shared buffer.
Definition: mp3_codec.h:236
int32_t(* set_silence_frame_information)(mp3_codec_media_handle_t *handle, silence_frame_information_t *frm_info)
Get silence frame information.
Definition: mp3_codec.h:240
mp3_codec_function_return_state_t mp3_codec_set_memory(uint8_t *memory)
This function sets the memory for MP3 decoder.
void * private_data
Internal use only.
Definition: mp3_codec.h:226
mp3_codec_function_return_state_t mp3_codec_aws_set_initial_sync(mp3_codec_media_handle_t *handle)
This function sets the advanced wireless stereo initial synchronization.
void(* finish_write_data)(mp3_codec_media_handle_t *handle)
Indicate last data transfer.
Definition: mp3_codec.h:232
void(* set_share_buffer)(mp3_codec_media_handle_t *handle, uint8_t *buffer, uint32_t length)
Set the shared buffer for bitstream.
Definition: mp3_codec.h:228
int32_t flush_data_flag
The flag to flush data.
Definition: mp3_codec.h:225
The MP3 codec works normally.
Definition: mp3_codec.h:172
mp3_codec_function_return_state_t(* stop)(mp3_codec_media_handle_t *handle)
The MP3 codec stop function.
Definition: mp3_codec.h:246
mp3_codec_function_return_state_t(* pause)(mp3_codec_media_handle_t *handle)
The MP3 codec pause function.
Definition: mp3_codec.h:243
mp3_codec_function_return_state_t(* play)(mp3_codec_media_handle_t *handle)
The MP3 codec play function.
Definition: mp3_codec.h:242
mp3_codec_function_return_state_t mp3_codec_aws_set_flag(mp3_codec_media_handle_t *handle, bool flag)
This function sets the advanced wireless stereo flag.
mp3_codec_event_t
This enumeration defines the MP3 codec events.
Definition: mp3_codec.h:148
void * param
Extended parameter or information.
Definition: mp3_codec.h:194