encode_write.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _ENCODE_WRITE_H
  2. #define _ENCODE_WRITE_H
  3. #include "app_config.h"
  4. #include "system/includes.h"
  5. #include "system/os/os_cpu.h"
  6. #include "system/fs/fs.h"
  7. #include "dev_manager.h"
  8. enum {
  9. ENC_WRITE_FILE_EVT_WRITE_ERR = 0x10,
  10. ENC_WRITE_FILE_EVT_FILE_CLOSE, // 0-err, 非0-起始簇号
  11. ENC_WRITE_FLASH_EVT_WRITE_ERR = 0x20,
  12. ENC_WRITE_FLASH_EVT_OUTOF_LEN,
  13. };
  14. struct audio_enc_write_input {
  15. int (*get)(void *, s16 **frame, u16 frame_len);
  16. void (*put)(void *, s16 *frame);
  17. };
  18. typedef struct enc_tmark_info {
  19. unsigned int len;
  20. u8 data[0];
  21. } Tmark_info;
  22. //////////////////////////////////////////////////////////////////////////////
  23. int enc_write_file_resume(void *hdl); // 调用该函数激活写文件
  24. void enc_write_file_close(void *hdl);
  25. void *enc_write_file_open(char *logo, const char *folder, const char *filename);
  26. int enc_write_file_start(void *hdl);
  27. void enc_write_file_stop(void *hdl, u32 delay_ms); // delay_ms:超时等待完成
  28. // 录音结束后需要重新写头部数据
  29. void enc_write_file_set_head_handler(void *hdl, int (*set_head)(void *, char **head), void *set_head_hdl);
  30. void enc_write_file_set_evt_handler(void *hdl, void (*evt_cb)(void *, int, int), void *evt_hdl);
  31. void enc_write_file_set_input(void *hdl, struct audio_enc_write_input *input, void *input_hdl, u32 input_frame_len);
  32. int get_enc_file_len(void *hdl);
  33. // cut_size:结束后砍掉的尾部长度
  34. // limit_size:文件小于该长度时,不保留文件
  35. void enc_write_file_set_limit(void *hdl, u32 cut_size, u32 limit_size);
  36. //////////////////////////////////////////////////////////////////////////////
  37. int enc_write_flash_resume(void *hdl); // 调用该函数激活写
  38. void enc_write_flash_close(void *hdl);
  39. void *enc_write_flash_open(const char *dev_name, void *arg, u32 addr_start, u32 max_len);
  40. int enc_write_flash_start(void *hdl);
  41. void enc_write_flash_stop(void *hdl, u32 delay_ms); // delay_ms:超时等待完成
  42. // 录音结束后需要重新写头部数据
  43. void enc_write_flash_set_head_handler(void *hdl, int (*set_head)(void *, char **head), void *set_head_hdl);
  44. void enc_write_flash_set_evt_handler(void *hdl, void (*evt_cb)(void *, int, int), void *evt_hdl);
  45. void enc_write_flash_set_input(void *hdl, struct audio_enc_write_input *input, void *input_hdl, u32 input_frame_len);
  46. // cut_size:结束后砍掉的尾部长度
  47. // limit_size:文件小于该长度时,不保留文件
  48. void enc_write_flash_set_limit(void *hdl, u32 cut_size, u32 limit_size);
  49. void last_enc_file_codeing_type_save(u32 type);
  50. int last_enc_file_path_get(char path[64]);
  51. void *get_wfil_head_hdl(void *enc_whdl);
  52. FILE *get_wfil_file(void *enc_whdl);
  53. #endif