export.h 6.0 KB

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