plyRec.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __PLY_REC_H_
  2. #define __PLY_REC_H_
  3. #include "main.h"
  4. #include "datatype.h"
  5. #define PCM_FRAME_BYTE_SIZE 320 //8K 采样时20ms得到的一帧pcm语音数据字节大小
  6. //#define RECORD_TO_FLASH //录制数据保存在FLASH中
  7. #define RECORD_TO_RAM //录制数据保存在RAM中
  8. #if defined RECORD_TO_FLASH && defined RECORD_TO_RAM
  9. #error "can not define both at the same time"
  10. #elif defined RECORD_TO_FLASH
  11. #elif defined RECORD_TO_RAM
  12. #else
  13. #error "need to define type"
  14. #endif
  15. //#ifndef (RECORD_TO_FLASH & RECORD_TO_RAM)
  16. //#error "need to define RECORD_TO_RAM or RECORD_TO_FLASH"
  17. //#endif
  18. typedef struct{
  19. T_UINT8 type;
  20. T_UINT32 framelen;
  21. T_UINT32 framenum;
  22. }FINI_DEF;
  23. #define RECORD_TIME_LIMIT 30 //the max time to record limited
  24. #define FRAMES_BY_TIME_TO_RECORD (RECORD_TIME_LIMIT*1000/20) //the numbers of frames we need to record by spicified time:RECORD_TIME_LIMIT
  25. #define THE_MAX_BYTE_PER_FRAME_AFTER_ENCODE 32 //the max size of one frame that after encode
  26. #define MAX_FRAMS_PCM_DATA FRAMES_BY_TIME_TO_RECORD*THE_MAX_BYTE_PER_FRAME_AFTER_ENCODE
  27. #define MAX_FRAMS_FILE_DATA (sizeof(FINI_DEF)+MAX_FRAMS_PCM_DATA) //the max size of encode file that we encode
  28. const unsigned char amr_file_header[6];
  29. #define AMR_FILE_HEADER_LEN sizeof(amr_file_header)
  30. #define AMR_FILE_SIZE_MAX (AMR_FILE_HEADER_LEN+MAX_FRAMS_PCM_DATA)
  31. #if defined RECORD_TO_RAM
  32. typedef struct{
  33. FINI_DEF head;
  34. unsigned char pcm[AMR_FILE_HEADER_LEN+MAX_FRAMS_PCM_DATA];
  35. }SAVE_RAM_DEF;
  36. extern SAVE_RAM_DEF ramsave;
  37. #endif
  38. PT_THREAD (ptPlayerTask(pt_timer_t *ptPool, struct pt *pt));
  39. PT_THREAD (ptRecorderTask(pt_timer_t *ptPool, struct pt *pt));
  40. void RecCloseNowApi(void);
  41. void PlyCloseNowApi(void);
  42. void RecOpenNowApi(void);
  43. void PlyOpenNowApi(void);
  44. T_BOOL isPlayerIsOff(void);
  45. T_BOOL isRecordIsOff(void);
  46. void setAudioChannelAndVol(void);
  47. void setPlayBuf(unsigned char flag);
  48. PT_THREAD (ptQueueRecordReadTask(pt_timer_t *ptPool, struct pt *pt));
  49. void ClearRecBuffer(void);
  50. void playToneNow(T_UINT16 lf,T_UINT16 hf,T_UINT8 time);
  51. #endif