media_service.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*
  2. * Copyright (c) 2018 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file media service interface
  8. */
  9. #ifndef __MEDIA_SERVICE_H__
  10. #define __MEDIA_SERVICE_H__
  11. #include <os_common_api.h>
  12. #include <msg_manager.h>
  13. #include <stream.h>
  14. #include <thread_timer.h>
  15. #include <arithmetic.h>
  16. #include <media_type.h>
  17. #ifdef CONFIG_BT_MANAGER
  18. #include <btservice_api.h>
  19. #endif
  20. /**
  21. * @defgroup media_service_apis App Media Service APIs
  22. * @ingroup media_system_apis
  23. * @{
  24. */
  25. /**
  26. * @cond INTERNAL_HIDDEN
  27. */
  28. /**
  29. * @brief media service event notify callback
  30. *
  31. * This routine called by media service, notify media service state changed
  32. * event media_event_type_e
  33. *
  34. * @param event event type of media_srv_status_e.
  35. * @param data event data.
  36. * @param len event data length.
  37. * @param user_data user_data passed in media_init_param_t during media_player_open
  38. *
  39. * @return N/A.
  40. */
  41. typedef void (*media_srv_event_notify_t)(uint32_t event, void *data, uint32_t len, void *user_data);
  42. typedef void (*MIX_CALLBAK)(io_stream_t, int, void*);
  43. typedef struct {
  44. uint8_t in_rate;
  45. uint8_t out_rate;
  46. uint8_t channels;
  47. uint8_t format;
  48. uint8_t sample_bits;
  49. /*master channel gain -12db - 0db*/
  50. short master_db;
  51. /*master channel gain -12db - 0db*/
  52. short mix_db;
  53. /*for close input stream*/
  54. MIX_CALLBAK callback;
  55. io_stream_t input_stream;
  56. } mix_service_param_t;
  57. /** media service operation message type*/
  58. enum media_srv_operation_e {
  59. /** open a new media service instance*/
  60. MSG_MEDIA_SRV_OPEN = MSG_SRV_MESSAGE_START,
  61. /** close target media service instance*/
  62. MSG_MEDIA_SRV_CLOSE,
  63. /** start to play*/
  64. MSG_MEDIA_SRV_PLAY,
  65. /** stop to play*/
  66. MSG_MEDIA_SRV_STOP,
  67. /** media service pause*/
  68. MSG_MEDIA_SRV_PAUSE,
  69. /** media service resume*/
  70. MSG_MEDIA_SRV_RESUME,
  71. MSG_MEDIA_SRV_START_STOP_DECODE,
  72. /** media service trigger to process data*/
  73. MSG_MEDIA_SRV_DATA_PROCESS,
  74. /** media service dump data*/
  75. MSG_MEDIA_SRV_DUMP_DATA,
  76. /** media service seek to play*/
  77. MSG_MEDIA_SRV_SEEK,
  78. /** media service query parameter*/
  79. MSG_MEDIA_SRV_GET_PARAMETER,
  80. /** media service set parameter*/
  81. MSG_MEDIA_SRV_SET_PARAMETER,
  82. /** media service get global parameter*/
  83. MSG_MEDIA_SRV_GET_GLOBAL_PARAMETER,
  84. /** media service set global parameter*/
  85. MSG_MEDIA_SRV_SET_GLOBAL_PARAMETER,
  86. /** media service set mix stream*/
  87. MSG_MEDIA_SRV_SET_MIX_STREAM,
  88. };
  89. /** dumpable data tag */
  90. enum media_dump_data_tag_e {
  91. /** mic left channel */
  92. MEDIA_DATA_TAG_MIC1 = 0,
  93. /** mic right channel */
  94. MEDIA_DATA_TAG_MIC2,
  95. /** reference (single channel) */
  96. MEDIA_DATA_TAG_REF,
  97. /** AEC left channel */
  98. MEDIA_DATA_TAG_AEC1,
  99. /** AEC right channel */
  100. MEDIA_DATA_TAG_AEC2,
  101. /** encoder (left channel) input */
  102. MEDIA_DATA_TAG_ENCODE_IN1,
  103. /** encoder right channel input */
  104. MEDIA_DATA_TAG_ENCODE_IN2,
  105. /** encoder output stream */
  106. MEDIA_DATA_TAG_ENCODE_OUT,
  107. /* resample in data*/
  108. MEDIA_DATA_TAG_RESAMPLE_IN,
  109. /*resample out data*/
  110. MEDIA_DATA_TAG_RESAMPLE_OUT,
  111. /** decoder input stream */
  112. MEDIA_DATA_TAG_DECODE_IN,
  113. /** decoder (left channel) output */
  114. MEDIA_DATA_TAG_DECODE_OUT1,
  115. /** decoder right channel output */
  116. MEDIA_DATA_TAG_DECODE_OUT2,
  117. /** plc output */
  118. MEDIA_DATA_TAG_PLC,
  119. /** dac (left channel) output */
  120. MEDIA_DATA_TAG_DAC1,
  121. /** dac right channel output */
  122. MEDIA_DATA_TAG_DAC2,
  123. MEDIA_TAG_FFVP_DATA,
  124. MEDIA_TAG_ENCODED_DATA,
  125. };
  126. /** media service state */
  127. typedef enum {
  128. /** media service stop state */
  129. MEDIA_SRV_STATUS_STOP = 0,
  130. /** media service configed state */
  131. MEDIA_SRV_STATUS_CONFIG,
  132. /** media service ready state */
  133. MEDIA_SRV_STATUS_READY,
  134. /** media service playing state */
  135. MEDIA_SRV_STATUS_PLAY,
  136. /** media service paused state */
  137. MEDIA_SRV_STATUS_PAUSE,
  138. /** media service finished state */
  139. MEDIA_SRV_STATUS_FINISHED,
  140. /** media service Error state */
  141. MEDIA_SRV_STATUS_ERROR,
  142. /** media service NULL state */
  143. MEDIA_SRV_STATUS_NULL,
  144. } media_srv_status_e;
  145. /** media service parameter name */
  146. typedef enum {
  147. /** media service global parameter */
  148. /** set background recording */
  149. MEDIA_PARAM_SET_RECORD,
  150. /** media player parameter */
  151. /** media info */
  152. MEDIA_PARAM_MEDIAINFO,
  153. /** break point */
  154. MEDIA_PARAM_BREAKPOINT,
  155. /** output mode */
  156. MEDIA_PARAM_OUTPUT_MODE,
  157. /** get state */
  158. MEDIA_PARAM_GET_STATE,
  159. /** energy filter param */
  160. MEDIA_PARAM_ENERGY_FILTER,
  161. /** audio max lantency param */
  162. MEDIA_PARAM_AUDIO_LATENCY,
  163. /** audio sync play time */
  164. MEDIA_PARAM_SET_PLAY_TIME,
  165. /** get record time */
  166. MEDIA_PARAM_GET_RECORD_TIME,
  167. /** The following are audio effect operations, do not mix other operation types */
  168. /** audio effect operation set volume */
  169. MEDIA_EFFECT_EXT_SET_VOLUME,
  170. /** audio effect operation set mic mute */
  171. MEDIA_EFFECT_EXT_SET_MIC_MUTE,
  172. /** audio effect operation set hfp connected flag */
  173. MEDIA_EFFECT_EXT_HFP_CONNECTED,
  174. /** audio effect operation enable dae all functions */
  175. MEDIA_EFFECT_EXT_SET_DAE_ENABLE,
  176. /** audio effect operation bypass dae all functions, except fade in/out */
  177. MEDIA_EFFECT_EXT_SET_DAE_BYPASS,
  178. /** audio effect operation bypass dae all functions, except fade in/out */
  179. MEDIA_EFFECT_EXT_SET_EFFECT_BYPASS,
  180. /** audio effect operation set dae output mode*/
  181. MEDIA_EFFECT_EXT_SET_DAE_OUTPUT_MODE,
  182. /** audio effect operation update effect param*/
  183. MEDIA_EFFECT_EXT_UPDATE_PARAM,
  184. MEDIA_EFFECT_EXT_UPDATE_AEC_PARAM,
  185. /** audio effect operation get dae output mode*/
  186. MEDIA_EFFECT_EXT_GET_DAE_OUTPUT_MODE,
  187. /** audio effect operation get freq point energy*/
  188. MEDIA_EFFECT_EXT_GET_FREQPOINT_ENERGY,
  189. MEDIA_EFFECT_EXT_GET_TIMEDOMAIN_ENERGY,
  190. MEDIA_EFFECT_EXT_GET_FREQBAND_ENERGY,
  191. MEDIA_EFFECT_EXT_GET_EFFECT_ENABLE,
  192. /** audio effect operation set energy freq points */
  193. MEDIA_EFFECT_EXT_SET_ENERGY_FREQPOINT,
  194. /** audio effect operation set fade in*/
  195. MEDIA_EFFECT_EXT_FADEIN,
  196. MEDIA_EFFECT_EXT_GET_FADEIN_TIME,
  197. MEDIA_EFFECT_EXT_GET_FADEIN_STATUS,
  198. /** audio effect operation set fade out*/
  199. MEDIA_EFFECT_EXT_FADEOUT,
  200. MEDIA_EFFECT_EXT_GET_FADEOUT_TIME,
  201. MEDIA_EFFECT_EXT_GET_FADEOUT_STATUS,
  202. /** audio effect operation check fade out finished*/
  203. MEDIA_EFFECT_EXT_CHECK_FADEOUT_FINISHED,
  204. MEDIA_EFFECT_EXT_SET_ENERGY_PARAM,
  205. /** audio effect operation set subwoofer volume */
  206. MEDIA_EFFECT_EXT_SET_SUBWOOFER_VOLUME,
  207. /** audio effect operation set LR balance*/
  208. MEDIA_EFFECT_EXT_SET_LR_BALANCE,
  209. MEDIA_EFFECT_EXT_SET_SUBEFFECT,
  210. MEDIA_EFFECT_EXT_SET_UPSTREAM_DAE_ENABLE,
  211. } media_param_e;
  212. /* MEDIA_PARAM_OUTPUT_MODE */
  213. typedef enum {
  214. MEDIA_OUTPUT_MODE_DEFAULT = 0,
  215. MEDIA_OUTPUT_MODE_LEFT = 1,
  216. MEDIA_OUTPUT_MODE_RIGHT = 2,
  217. NUM_MEDIA_OUTPUT_MODES,
  218. } media_output_mode_e;
  219. /* MEDIA_PARAM_OUTPUT_MODE */
  220. typedef enum {
  221. CAPTURE_INPUT_FROM_STREAM = 0,
  222. CAPTURE_INPUT_FROM_DSP_ADC_FIFO = 1,
  223. CAPTURE_INPUT_FROM_DSP_DEC_OUTPUT = 2,
  224. NUM_CAPTURE_INPUT_MODES,
  225. } media_capture_input_mode_e;
  226. /* MEDIA_EFFECT_EXT_SET_DAE_OUTPUT_MODE */
  227. typedef enum {
  228. MEDIA_EFFECT_OUTPUT_DEFAULT = 0,
  229. MEDIA_EFFECT_OUTPUT_L_R_SWAP = 1,
  230. MEDIA_EFFECT_OUTPUT_L_R_MIX = 2,
  231. MEDIA_EFFECT_OUTPUT_L_ONLY = 3,
  232. MEDIA_EFFECT_OUTPUT_R_ONLY = 4,
  233. NUM_MEDIA_EFFECT_OUTPUT_MODES,
  234. } media_effect_output_mode_e;
  235. typedef struct {
  236. /** param type */
  237. int type;
  238. /** param buffer */
  239. void *pbuf;
  240. /** param buffer length */
  241. unsigned int plen;
  242. } media_param_t;
  243. typedef struct {
  244. /** media handle */
  245. void *handle;
  246. /** param */
  247. media_param_t param;
  248. /** store the result: 0 successful, others failed */
  249. int result;
  250. } media_srv_param_t;
  251. typedef struct {
  252. int total_time; /* total time in milliseconds */
  253. int avg_bitrate; /* average bit reate in kbps */
  254. int sample_rate; /* sample rate in Hz */
  255. int channels; /* channels */
  256. unsigned int file_hdr_len; /* file header(tags) length */
  257. } media_info_t;
  258. typedef struct {
  259. uint8_t type;
  260. uint32_t overlay_id;
  261. as_parser_ops_t ops;
  262. } parser_config_info_t;
  263. typedef struct {
  264. /** required in ms*/
  265. int time_offset;
  266. /** optional, may accelerate the seeking for some codec format (mp3, etc.)
  267. * must set <= 0, if not available. in bytes
  268. */
  269. int file_offset;
  270. } media_breakpoint_info_t;
  271. typedef struct {
  272. int num_points;
  273. short values[10];
  274. } media_freqpoint_energy_info_t;
  275. #define MEDIA_SEEK_SET SEEK_DIR_BEG
  276. #define MEDIA_SEEK_CUR SEEK_DIR_CUR
  277. #define MEDIA_SEEK_END SEEK_DIR_END
  278. /** media seek info structure*/
  279. typedef struct {
  280. /** should be one of AP_SEEK_SET, AP_SEEK_CUR and AP_SEEK_END */
  281. int whence;
  282. /** required in ms*/
  283. int time_offset;
  284. /** optional, may accelerate the seeking for some codec format (mp3, etc.)
  285. * must set <= 0, if not available.
  286. */
  287. int file_offset;
  288. /* return seeking result */
  289. int chunk_time_offset; /* in ms */
  290. int chunk_file_offset; /* in bytes */
  291. } media_seek_info_t;
  292. typedef struct {
  293. /* number of data tags */
  294. int num;
  295. /* data tags array */
  296. const uint8_t *tags;
  297. /* buffer array to stort data */
  298. struct acts_ringbuf **bufs;
  299. } media_data_dump_info_t;
  300. typedef struct {
  301. uint8_t state;
  302. int result;
  303. } media_state_info_t;
  304. typedef enum {
  305. MEDIA_PLAYBACK = 0,
  306. MEDIA_CAPTURE,
  307. MEDIA_PARSER,
  308. NUM_MEDIA_SUBSRVS,
  309. } media_subsrv_index_e;
  310. typedef enum {
  311. MEDIA_SRV_TYPE_PLAYBACK = BIT(MEDIA_PLAYBACK),
  312. MEDIA_SRV_TYPE_CAPTURE = BIT(MEDIA_CAPTURE),
  313. MEDIA_SRV_TYPE_PLAYBACK_AND_CAPTURE = (MEDIA_SRV_TYPE_PLAYBACK | MEDIA_SRV_TYPE_CAPTURE),
  314. MEDIA_SRV_TYPE_PARSER = BIT(MEDIA_PARSER),
  315. MEDIA_SRV_TYPE_PARSER_AND_PLAYBACK = (MEDIA_SRV_TYPE_PLAYBACK | MEDIA_SRV_TYPE_PARSER),
  316. } media_srv_sub_type_e;
  317. typedef struct {
  318. uint8_t type;
  319. uint8_t flag;
  320. uint8_t status;
  321. uint8_t prev_status;
  322. void *subsrv_handles[NUM_MEDIA_SUBSRVS];
  323. #ifdef CONFIG_THREAD_TIMER
  324. struct thread_timer srv_data_process_timer;
  325. #endif
  326. os_tid_t srv_thread;
  327. char *srv_thread_stack;
  328. uint16_t srv_thread_stack_size;
  329. uint8_t srv_thread_stack_allocated : 1;
  330. uint8_t srv_thread_terminal : 1;
  331. uint8_t srv_thread_terminaled : 1;
  332. os_mutex srv_process_mutex;
  333. os_sem srv_process_sem;
  334. /* evnet notify */
  335. media_srv_event_notify_t event_notify;
  336. void *user_data;
  337. /* reference buffer for sub services */
  338. struct acts_ringbuf *refbuf;
  339. /* attached background recorder */
  340. void *bg_recorder;
  341. uint8_t bg_recorder_can_run : 1;
  342. } media_srv_handle_t;
  343. typedef struct {
  344. uint8_t type;
  345. uint8_t dumpable:1;
  346. uint8_t support_tws:1;
  347. uint8_t aec_enable:1;
  348. uint8_t auto_mute:1;
  349. uint8_t dsp_output:1;
  350. uint8_t dsp_latency_calc:1;
  351. uint8_t dsp_sleep:1;
  352. uint8_t dsp_sleep_mode:1;
  353. uint8_t sleep_stat_log:1;
  354. uint8_t stream_type;
  355. uint8_t efx_stream_type;
  356. uint8_t format;
  357. uint8_t sample_rate; /* kHz */
  358. uint8_t sample_bits;
  359. uint8_t channels;
  360. uint16_t auto_mute_threshold;
  361. io_stream_t input_stream;
  362. io_stream_t output_stream;
  363. io_stream_t output_stream_subwoofer;
  364. uint8_t capture_format;
  365. /* capture input sample rate (kHz) */
  366. uint8_t capture_sample_rate_input;
  367. /* capture output sample rate (kHz) */
  368. uint8_t capture_sample_rate_output;
  369. /* capture input sample bits, 16, 24, etc. */
  370. uint8_t capture_sample_bits;
  371. /* capture input channels */
  372. uint8_t capture_channels_input;
  373. /* capture output (encoding) channels */
  374. uint8_t capture_channels_output;
  375. uint8_t capture_input_src;
  376. uint16_t capture_bit_rate; /* kbps */
  377. io_stream_t capture_input_stream;
  378. io_stream_t capture_output_stream;
  379. /** break point of time ms */
  380. uint32_t bp_time_offset;
  381. /** break point of file offset byte */
  382. uint32_t bp_file_offset;
  383. media_srv_event_notify_t event_notify_handle;
  384. /* will be passed to event_notify_handle as parameter "user_data".
  385. * If set NULL, it will fallback to the media_player_t returned by media_player_open.
  386. */
  387. void *user_data;
  388. uint8_t capture_complexity;
  389. } media_init_param_t;
  390. typedef enum {
  391. /* transmit and output channeles decided by decoding output channels */
  392. MEDIA_TWS_MODE_DEFAULT = 0,
  393. /* mono transmit to slave, mono output on master/slave */
  394. MEDIA_TWS_MODE_MONO,
  395. /* (force) stereo transmit to slave, (force) stereo output on master/slave */
  396. MEDIA_TWS_MODE_STEREO,
  397. } media_tws_mode_e;
  398. typedef struct {
  399. /** public parameters for application */
  400. media_init_param_t *user_param;
  401. /** private parameters for media sub-services */
  402. void *mediasrv_handle;
  403. #ifdef CONFIG_BT_MANAGER
  404. tws_runtime_observer_t *tws_observer;
  405. #endif
  406. uint8_t tws_mode; /* see media_tws_mode_e */
  407. /* whether tws only support samplerate 44 or 48kHz */
  408. uint8_t tws_samplerate_44_48_only;
  409. } media_srv_init_param_t;
  410. #define NUM_MEDIA_RECORDS (MEDIA_CAPTURE + 1)
  411. typedef enum {
  412. MEDIA_RECORD_PLAYBACK = BIT(MEDIA_PLAYBACK),
  413. MEDIA_RECORD_CAPTURE = BIT(MEDIA_CAPTURE),
  414. MEDIA_RECORD_PLAYBACK_AND_CAPTURE = MEDIA_RECORD_PLAYBACK | MEDIA_RECORD_CAPTURE,
  415. } media_record_type_t;
  416. typedef struct {
  417. /* record type */
  418. uint8_t type;
  419. /* encoder parameters */
  420. uint8_t format;
  421. uint8_t sample_rate;
  422. uint8_t channels;
  423. uint16_t bit_rate; /* kbps */
  424. io_stream_t stream;
  425. } media_record_info_t;
  426. /*
  427. * @struct effect_f_energy_set_t
  428. *
  429. * @brief Use to enable/disable time and freq energy sample, or set the frequency of the
  430. * frequency sample.
  431. */
  432. typedef struct {
  433. /** Enable time domain energy sample */
  434. uint16_t t_energy_en;
  435. /** Enable frequency domain (band mode) energy sample */
  436. uint16_t f_band_energy_en;
  437. /** Frequency domain (band mode) sample time window width(ms)*/
  438. uint16_t f_band_energy_timewindow_ms;
  439. /** The count of the bands energy to sample */
  440. uint16_t f_band_energy_num;
  441. /** Bandwidth in band mode */
  442. uint16_t f_band_bandwidth;
  443. /** Center frequency of the band 0 */
  444. uint16_t f_band_energy_f0;
  445. /** Center frequency of the band 1 */
  446. uint16_t f_band_energy_f1;
  447. /** Center frequency of the band 2 */
  448. uint16_t f_band_energy_f2;
  449. /** Center frequency of the band 3 */
  450. uint16_t f_band_energy_f3;
  451. /** Center frequency of the band 4 */
  452. uint16_t f_band_energy_f4;
  453. /** Center frequency of the band 5 */
  454. uint16_t f_band_energy_f5;
  455. /** Center frequency of the band 6 */
  456. uint16_t f_band_energy_f6;
  457. /** Center frequency of the band 7 */
  458. uint16_t f_band_energy_f7;
  459. /** Center frequency of the band 8 */
  460. uint16_t f_band_energy_f8;
  461. /** Center frequency of the band 9 */
  462. uint16_t f_band_energy_f9;
  463. /** Enable frequency domain (point mode) energy sample */
  464. uint16_t f_pt_energy_en;
  465. /** The count of the points energy to sample */
  466. uint16_t f_pt_energy_num;
  467. uint16_t f_pt_energy[16];
  468. } effect_f_energy_set_t;
  469. #define MEDIA_SRV_DEVICE_USED_FLAG (1 << 0)
  470. #define MEDIA_SRV_SET_USED_FLAG(HANDLE, FLAG) (((HANDLE)->flag) |= (FLAG))
  471. #define MEDIA_SRV_CLEAR_USED_FLAG(HANDLE, FLAG) (((HANDLE)->flag) &= ~(FLAG))
  472. #define MEDIA_SRV_IS_FLAG_SET(HANDLE, FLAG) (((HANDLE)->flag & (FLAG)) == (FLAG))
  473. /**
  474. * @brief open new media service instance
  475. *
  476. * This routine provides open new media service instance, if open failed
  477. * or no more media handle ,return NULL. this operation is sync operation,
  478. * may block calling thread.
  479. *
  480. * @param msg message of open service
  481. * msg.type = MSG_MEDIA_SRV_OPEN;
  482. * msg.ptr = init_param;
  483. * msg.callback = _media_service_open_callback;
  484. * msg.sync_sem sem for sync operation;
  485. *
  486. * @return handle of new service instance
  487. */
  488. void *media_service_open(struct app_msg *msg);
  489. /**
  490. * @brief start play for media service
  491. *
  492. * This routine provides to start meida service play
  493. *
  494. * @param msg message of service play
  495. * msg.type = MSG_MEDIA_SRV_PLAY;
  496. * msg.ptr = handle->media_srv_handle handle of media service ;
  497. *
  498. * @return 0 excute successed , others failed
  499. */
  500. int media_service_play(struct app_msg *msg);
  501. /**
  502. * @brief triggle media service process data
  503. *
  504. * This routine provides to triggle media service process data,
  505. * always triggle from thread timer
  506. *
  507. * @param msg message of service play
  508. * msg.type = MSG_MEDIA_SRV_DATA_PROCESS;
  509. * msg.ptr = handle->media_srv_handle handle of media service ;
  510. *
  511. * @return 0 excute successed , others failed
  512. */
  513. int media_service_data_process(struct app_msg *msg);
  514. /**
  515. * @brief pause for media service
  516. *
  517. * This routine provides to pause meida service . only excute when meida
  518. * service playing.
  519. *
  520. * @param msg message of service play
  521. * msg.type = MSG_MEDIA_SRV_PAUSE;
  522. * msg.ptr = handle->media_srv_handle handle of media service ;
  523. *
  524. * @return 0 excute successed , others failed
  525. */
  526. int media_service_pause(struct app_msg *msg);
  527. /**
  528. * @brief resume for media service
  529. *
  530. * This routine provides to resume media service, only excute when meida
  531. * service paused.
  532. *
  533. * @param msg message of service play
  534. * msg.type = MSG_MEDIA_SRV_RESUME;
  535. * msg.ptr = handle->media_srv_handle handle of media service ;
  536. *
  537. * @return 0 excute successed , others failed
  538. */
  539. int media_service_resume(struct app_msg *msg);
  540. /**
  541. * @brief seek for media service
  542. *
  543. * This routine provides to seek meida service
  544. *
  545. * @param msg message of service play
  546. * msg.type = MSG_MEDIA_SRV_SEEK
  547. * msg.ptr = param seek param @see media_srv_seek_param_t;
  548. *
  549. * @return 0 excute successed , others failed
  550. */
  551. int media_service_seek(struct app_msg *msg);
  552. /**
  553. * @brief stop media service
  554. *
  555. * This routine provides to stop meida service, if media service stop
  556. * inner process must be stoped, but resource of media service may not
  557. * free in this function .
  558. *
  559. * @param msg message of service stop
  560. * msg.type = MSG_MEDIA_SRV_STOP;
  561. * msg.ptr = handle->media_srv_handle handle of media service ;
  562. *
  563. * @return 0 excute successed , others failed
  564. */
  565. int media_service_stop(struct app_msg *msg);
  566. /**
  567. * @brief close media service handle
  568. *
  569. * This routine provides to close media service handle, media service must
  570. * release all resource of this media servie handle,and put the handle to
  571. * free media service handle pool.
  572. *
  573. * @param msg message of service close
  574. * msg.type = MSG_MEDIA_SRV_CLOSE;
  575. * msg.ptr = handle->media_srv_handle handle of media service ;
  576. *
  577. * @return 0 excute successed , others failed
  578. */
  579. int media_service_close(struct app_msg *msg);
  580. /**
  581. * @brief dump media service data
  582. *
  583. * This routine provides to dump media service inner data for debug or
  584. * for other debug tools , such as asqt ,aset ,ectt.
  585. *
  586. * @param msg message of service dump data
  587. msg.type = MSG_MEDIA_SRV_DUMP_DATA;
  588. msg.ptr = pointer to media_srv_data_dump_param_t
  589. *
  590. * @return 0 excute successed , others failed
  591. */
  592. int media_service_dump_data(struct app_msg *msg);
  593. /**
  594. * @brief get media service parameter
  595. *
  596. * This routine provides to get media service parameter.
  597. *
  598. * @param msg message of service dump data
  599. msg.type = MSG_MEDIA_SRV_GET_PARAMETER;
  600. msg.ptr = pointer to media_srv_param_t
  601. *
  602. * @return 0 excute successed , others failed
  603. */
  604. int media_service_get_parameter(struct app_msg *msg);
  605. /**
  606. * @brief set media service parameter
  607. *
  608. * This routine provides to set media service parameter.
  609. *
  610. * @param msg message of service dump data
  611. msg.type = MSG_MEDIA_SRV_SET_PARAMETER;
  612. msg.ptr = pointer to media_srv_param_t
  613. *
  614. * @return 0 excute successed , others failed
  615. */
  616. int media_service_set_parameter(struct app_msg *msg);
  617. /**
  618. * @brief get media service global parameter
  619. *
  620. * This routine provides to get media service global parameter.
  621. *
  622. * @param msg message of service dump data
  623. msg.type = MSG_MEDIA_SRV_GET_GLOBAL_PARAMETER;
  624. msg.ptr = pointer to media_srv_param_t
  625. *
  626. * @return 0 excute successed , others failed
  627. */
  628. int media_service_get_global_parameter(struct app_msg *msg);
  629. /**
  630. * @brief set media service global parameter
  631. *
  632. * This routine provides to set media service global parameter.
  633. *
  634. * @param msg message of service dump data
  635. msg.type = MSG_MEDIA_SRV_SET_GLOBAL_PARAMETER;
  636. msg.ptr = pointer to media_srv_param_t
  637. *
  638. * @return 0 excute successed , others failed
  639. */
  640. int media_service_set_global_parameter(struct app_msg *msg);
  641. int codec_get_overlay_id(enum media_type format, enum codec_type type);
  642. void *codec_get_ops(enum media_type format, enum codec_type type);
  643. bool codec_support_hw_acceleration(enum media_type format, enum codec_type type);
  644. const char *codec_get_hw_acceleration_dec_lib(enum media_type format, enum codec_type type);
  645. const char *codec_get_hw_acceleration_effect_lib(enum media_type format, enum codec_type type);
  646. int media_service_init(void);
  647. /**
  648. * INTERNAL_HIDDEN @endcond
  649. */
  650. /**
  651. * @} end defgroup media_service_apis
  652. */
  653. #endif /* __MEDIA_SERVICE_H__ */