rtc.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright (c) 2019 Paul-Louis Ageneau
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef RTC_C_API
  19. #define RTC_C_API
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. // libdatachannel C API
  24. typedef enum {
  25. RTC_NEW = 0,
  26. RTC_CONNECTING = 1,
  27. RTC_CONNECTED = 2,
  28. RTC_DISCONNECTED = 3,
  29. RTC_FAILED = 4,
  30. RTC_CLOSED = 5,
  31. RTC_DESTROYING = 6 // internal
  32. } rtc_state_t;
  33. typedef enum {
  34. RTC_GATHERING_NEW = 0,
  35. RTC_GATHERING_INPROGRESS = 1,
  36. RTC_GATHERING_COMPLETE = 2
  37. } rtc_gathering_state_t;
  38. // Don't change, it must match plog severity
  39. typedef enum {
  40. RTC_LOG_NONE = 0,
  41. RTC_LOG_FATAL = 1,
  42. RTC_LOG_ERROR = 2,
  43. RTC_LOG_WARNING = 3,
  44. RTC_LOG_INFO = 4,
  45. RTC_LOG_DEBUG = 5,
  46. RTC_LOG_VERBOSE = 6
  47. } rtc_log_level_t;
  48. void rtcInitLogger(rtc_log_level_t level);
  49. int rtcCreatePeerConnection(const char **iceServers, int iceServersCount);
  50. void rtcDeletePeerConnection(int pc);
  51. int rtcCreateDataChannel(int pc, const char *label);
  52. void rtcDeleteDataChannel(int dc);
  53. void rtcSetDataChannelCallback(int pc, void (*dataChannelCallback)(int, void *));
  54. void rtcSetLocalDescriptionCallback(int pc, void (*descriptionCallback)(const char *, const char *,
  55. void *));
  56. void rtcSetLocalCandidateCallback(int pc,
  57. void (*candidateCallback)(const char *, const char *, void *));
  58. void rtcSetStateChangeCallback(int pc, void (*stateCallback)(rtc_state_t state, void *));
  59. void rtcSetGatheringStateChangeCallback(int pc,
  60. void (*gatheringStateCallback)(rtc_gathering_state_t state,
  61. void *));
  62. void rtcSetRemoteDescription(int pc, const char *sdp, const char *type);
  63. void rtcAddRemoteCandidate(int pc, const char *candidate, const char *mid);
  64. int rtcGetDataChannelLabel(int dc, char *data, int size);
  65. void rtcSetOpenCallback(int dc, void (*openCallback)(void *));
  66. void rtcSetErrorCallback(int dc, void (*errorCallback)(const char *, void *));
  67. void rtcSetMessageCallback(int dc, void (*messageCallback)(const char *, int, void *));
  68. int rtcSendMessage(int dc, const char *data, int size);
  69. void rtcSetUserPointer(int i, void *ptr);
  70. #ifdef __cplusplus
  71. } // extern "C"
  72. #endif
  73. #endif