bizchan.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef BIZCHAN_H
  2. #define BIZCHAN_H
  3. #pragma once
  4. #include <crtdbg.h>
  5. #include <stdarg.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #ifdef LIBBIZCHAN_EXPORTS
  10. #define BIZCHAN_API(type) _declspec(dllexport) type __stdcall
  11. #else
  12. #define BIZCHAN_API(type) _declspec(dllimport) type __stdcall
  13. #endif
  14. typedef struct bizchan_t bizchan_t;
  15. typedef struct bizchan_config_t {
  16. char *proxy_server;
  17. int proxy_server_port;
  18. char *bak_proxy_server;
  19. int bak_proxy_server_port;
  20. union {
  21. char *agent_id;
  22. char *call_no;
  23. };
  24. char *client_id;
  25. char *session_id;
  26. struct {
  27. int rtp_port;
  28. int desc;
  29. }video;
  30. }bizchan_config_t;
  31. typedef struct bizchan_callback_t {
  32. void (*on_recv_photo)(bizchan_t *chan, int id, int error, int width, int height, const char *rgb24, int size, void *user_data);
  33. void (*on_recv_screen)(bizchan_t *chan, int id, int error, int width, int height, const char *rgb24, int size, void *user_data);
  34. void (*on_recv_pkt)(bizchan_t *chan, int type, int sub_type, int id, const char *pkt, int pkt_size, void *user_data);
  35. void (*on_connect)(bizchan_t *chan, int error, const char *remote_ip, int remote_video_rtp, int remote_video_desc, const char *remote_client_id, void *user_data);
  36. void (*on_close)(bizchan_t *chan, void *user_data);
  37. void (*on_destroy)(bizchan_t *chan, void *user_data);
  38. void (*dbg)(void *user_data, const char* fmt, va_list arg);
  39. void *user_data;
  40. }bizchan_callback_t;
  41. BIZCHAN_API(int) bizchan_lib_init();
  42. BIZCHAN_API(int) bizchan_lib_term();
  43. BIZCHAN_API(int) bizchan_create(const bizchan_config_t *config, const bizchan_callback_t *cb, bizchan_t **p_chan);
  44. BIZCHAN_API(void) bizchan_destroy(bizchan_t *chan);
  45. BIZCHAN_API(void) bizchan_set_tag(bizchan_t *chan, void *tag);
  46. BIZCHAN_API(void*) bizchan_get_tag(bizchan_t *chan);
  47. BIZCHAN_API(int) bizchan_start_connect(bizchan_t *chan);
  48. BIZCHAN_API(int) bizchan_start_close(bizchan_t *chan);
  49. BIZCHAN_API(int) bizchan_close(bizchan_t *chan);
  50. BIZCHAN_API(int) bizchan_post_pkt(bizchan_t *chan, int type, int compress, int encrypt, int sub_type, int id, const char *pkt, int pkt_size);
  51. typedef void (*OnRecvPacket)(int sub_type, const void *buf, int size, void *user_data);
  52. typedef void (*OnMode)(int writeable, void *user_data);
  53. BIZCHAN_API(int) bizchan_winsync_send(bizchan_t *chan, int sub_type, const void *buf, int size);
  54. BIZCHAN_API(int) bizchan_winsync_set_cb(bizchan_t *chan, OnRecvPacket pkt_cb, OnMode mode_cb, void *user_data);
  55. #ifdef __cplusplus
  56. } // extern "C" {
  57. #endif
  58. #endif // BIZCHAN_H