export.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. #ifndef RECORDER_EXPORT
  2. #define RECORDER_EXPORT
  3. #include "ultra_low_latency_recorder_config.h"
  4. #include <stdint.h>
  5. // #ifdef AMRECORDER_IMPORT
  6. // #define AMRECORDER_API extern "C" __declspec(dllimport)
  7. // #else
  8. // #define AMRECORDER_API extern "C" __declspec(dllexport)
  9. // #endif
  10. #define AMRECORDER_API
  11. /**
  12. * AMRECORDER_DEVICE
  13. */
  14. #pragma pack(push,1)
  15. typedef struct {
  16. /**
  17. * Device id in utf8
  18. */
  19. char id[260];
  20. /**
  21. * Device name in utf8
  22. */
  23. char name[260];
  24. /**
  25. * Is default device
  26. */
  27. uint8_t is_default;
  28. }AMRECORDER_DEVICE;
  29. #pragma pack(pop)
  30. /**
  31. * AMRECORDER_SETTING
  32. */
  33. #pragma pack(push,1)
  34. typedef struct {
  35. /**
  36. * Left of desktop area
  37. */
  38. int v_left;
  39. /**
  40. * Top of desktop area
  41. */
  42. int v_top;
  43. /**
  44. * Width of desktop area
  45. */
  46. int v_width;
  47. /**
  48. * Height of desktop area
  49. */
  50. int v_height;
  51. /**
  52. * Output video quality, value must be between 0 and 100, 0 is least, 100 is best
  53. */
  54. int v_qb;
  55. /**
  56. * Output video bitrate, the larger value you set,
  57. * the better video quality you get, but the file size is also larger.
  58. * Suggestion: 960|1280|2500 *1000
  59. */
  60. int v_bit_rate;
  61. /**
  62. * FPS(frame per second)
  63. */
  64. int v_frame_rate;
  65. /**
  66. * Video encoder id
  67. * Must get by recorder_get_vencoders
  68. */
  69. int v_enc_id;
  70. /**
  71. * Output file path,the output file format is depended on the ext name.
  72. * Support .mp4|.mkv for now.
  73. */
  74. char output[260];
  75. /**
  76. * Desktop device
  77. * Unused
  78. */
  79. AMRECORDER_DEVICE v_device;
  80. /**
  81. * Microphone device info
  82. */
  83. AMRECORDER_DEVICE a_mic;
  84. /**
  85. * Speaker device info
  86. */
  87. AMRECORDER_DEVICE a_speaker;
  88. }AMRECORDER_SETTING;
  89. #pragma pack(pop)
  90. /**
  91. * AMRECORDER_ENCODERS
  92. */
  93. #pragma pack(push,1)
  94. typedef struct {
  95. /**
  96. * Encoder id
  97. */
  98. int id;
  99. /**
  100. * Encoder name
  101. */
  102. char name[260];
  103. }AMRECORDER_ENCODERS;
  104. #pragma pack(pop)
  105. /**
  106. * Recording duration callback function
  107. * @param[in] duration time in millisecond
  108. */
  109. typedef void(*AMRECORDER_FUNC_DURATION)(uint64_t duration);
  110. /**
  111. * Recording error callback function
  112. * Should call recorder_err2str to get stringify error info
  113. * @param[in] error
  114. */
  115. typedef void(*AMRECORDER_FUNC_ERROR)(int error);
  116. /**
  117. * Device changed callback function
  118. * Should refresh devices
  119. * @param[in] type 0 for video, 1 for speaker, 2 for microphone
  120. */
  121. typedef void(*AMRECORDER_FUNC_DEVICE_CHANGE)(int type);
  122. /**
  123. * YUV data callback function
  124. * Should refresh devices
  125. * @param[in] data yuv buffer
  126. * @param[in] size yuv buffer size
  127. * @param[in] width picture with
  128. * @param[in] height picture height
  129. * @param[in] type yuv type, 0 for 420, 1 fro 444
  130. */
  131. typedef void(*AMRECORDER_FUNC_PREVIEW_YUV)(
  132. const unsigned char *data,
  133. unsigned int size,
  134. int width,
  135. int height,
  136. int type
  137. );
  138. /**
  139. * Unused callback function
  140. */
  141. typedef void(*AMRECORDER_FUNC_PREVIEW_AUDIO)();
  142. /**
  143. * Remux progress callback function
  144. * @param[in] path source file path
  145. * @param[in] progress remuxing progress in total
  146. * @param[in] total always will be 100
  147. */
  148. typedef void(*AMRECORDER_FUNC_REMUX_PROGRESS)(const char *path, int progress, int total);
  149. /**
  150. * Remux state callback function
  151. * @param[in] path source file path
  152. * @param[in] state 0 for unremuxing,1 for remuxing
  153. * @param[in] error 0 for succed,otherwhise error code
  154. */
  155. typedef void(*AMRECORDER_FUNC_REMUX_STATE)(const char *path, int state, int error);
  156. /**
  157. * Callback functions structure
  158. */
  159. #pragma pack(push,1)
  160. typedef struct {
  161. AMRECORDER_FUNC_DURATION func_duration;
  162. AMRECORDER_FUNC_ERROR func_error;
  163. AMRECORDER_FUNC_DEVICE_CHANGE func_device_change;
  164. AMRECORDER_FUNC_PREVIEW_YUV func_preview_yuv;
  165. AMRECORDER_FUNC_PREVIEW_AUDIO func_preview_audio;
  166. }AMRECORDER_CALLBACK;
  167. #pragma pack(pop)
  168. /**
  169. * Get error string by specified error code
  170. * @return error string
  171. */
  172. AMRECORDER_API const char * recorder_err2str(int error);
  173. /**
  174. * Initialize recorder with specified seetings��speaker��mic��encoder...
  175. * @return 0 if succeed,error code otherwise
  176. */
  177. AMRECORDER_API int recorder_init(const AMRECORDER_SETTING &setting, const AMRECORDER_CALLBACK &callbacks);
  178. /**
  179. * Release all recorder resources
  180. */
  181. AMRECORDER_API void recorder_release();
  182. /**
  183. * Start recording
  184. * @return 0 if succeed,error code otherwise
  185. */
  186. AMRECORDER_API int recorder_start();
  187. /**
  188. * Stop recording
  189. */
  190. AMRECORDER_API void recorder_stop();
  191. /**
  192. * Pause recording
  193. * @return 0 if succeed,error code otherwise
  194. */
  195. AMRECORDER_API int recorder_pause();
  196. /**
  197. * Resume recording
  198. * @return 0 if succeed,error code otherwise
  199. */
  200. AMRECORDER_API int recorder_resume();
  201. /**
  202. * Get valid speaker devices
  203. * @param[in] devices a pointer to a device array,should call recorder_free_array to free memory
  204. * @return count of speakers
  205. */
  206. AMRECORDER_API int recorder_get_speakers(AMRECORDER_DEVICE **devices);
  207. /**
  208. * Get valid mic devices
  209. * @param[in] devices a pointer to a device array,should call recorder_free_array to free memory
  210. * @return count of mics
  211. */
  212. AMRECORDER_API int recorder_get_mics(AMRECORDER_DEVICE **devices);
  213. /**
  214. * Get valid camera devices
  215. * @param[in] devices a pointer to a device array,should call recorder_free_array to free memory
  216. * @return count of cameras
  217. */
  218. AMRECORDER_API int recorder_get_cameras(AMRECORDER_DEVICE **devices);
  219. /**
  220. * Get valid encoders
  221. */
  222. AMRECORDER_API int recorder_get_vencoders(AMRECORDER_ENCODERS **encoders);
  223. /**
  224. * Free array memory allocated by recorder APIs
  225. */
  226. AMRECORDER_API void recorder_free_array(void *array_address);
  227. /**
  228. * Remux a file
  229. */
  230. AMRECORDER_API int recorder_remux(
  231. const char *src, const char *dst,
  232. AMRECORDER_FUNC_REMUX_PROGRESS func_progress,
  233. AMRECORDER_FUNC_REMUX_STATE func_state);
  234. /**
  235. * Enable/Disable preview callback
  236. */
  237. AMRECORDER_API void recorder_set_preview_enabled(int enable);
  238. /**
  239. * Set log file path
  240. */
  241. AMRECORDER_API void recorder_set_logpath(const char* path);
  242. /**
  243. * Ring buffer diagnostics (video)
  244. */
  245. AMRECORDER_API uint64_t recorder_get_video_rb_dropped();
  246. AMRECORDER_API int recorder_get_video_rb_pending();
  247. AMRECORDER_API int recorder_get_video_rb_max();
  248. AMRECORDER_API void recorder_set_video_rb_max(int max_frames);
  249. AMRECORDER_API void recorder_reset_video_rb_dropped();
  250. /**
  251. * Ring buffer diagnostics (audio)
  252. */
  253. AMRECORDER_API uint64_t recorder_get_audio_rb_dropped();
  254. AMRECORDER_API int recorder_get_audio_rb_pending();
  255. AMRECORDER_API int recorder_get_audio_rb_max();
  256. AMRECORDER_API void recorder_set_audio_rb_max(int max_frames);
  257. AMRECORDER_API void recorder_reset_audio_rb_dropped();
  258. #endif