rtc.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 rtc 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_state_t;
  32. typedef enum {
  33. RTC_GATHERING_NEW = 0,
  34. RTC_GATHERING_INPROGRESS = 1,
  35. RTC_GATHERING_COMPLETE = 2
  36. } rtc_gathering_state_t;
  37. int rtcCreatePeerConnection(const char **iceServers, int iceServersCount);
  38. void rtcDeletePeerConnection(int pc);
  39. int rtcCreateDataChannel(int pc, const char *label);
  40. void rtcDeleteDataChannel(int dc);
  41. void rtcSetDataChannelCallback(int pc, void (*dataChannelCallback)(int, void *));
  42. void rtcSetLocalDescriptionCallback(int pc, void (*descriptionCallback)(const char *, const char *,
  43. void *));
  44. void rtcSetLocalCandidateCallback(int pc,
  45. void (*candidateCallback)(const char *, const char *, void *));
  46. void rtcSetStateChangeCallback(int pc, void (*stateCallback)(rtc_state_t state, void *));
  47. void rtcSetGatheringStateChangeCallback(int pc,
  48. void (*gatheringStateCallback)(rtc_gathering_state_t state,
  49. void *));
  50. void rtcSetRemoteDescription(int pc, const char *sdp, const char *type);
  51. void rtcAddRemoteCandidate(int pc, const char *candidate, const char *mid);
  52. int rtcGetDataChannelLabel(int dc, char *data, int size);
  53. void rtcSetOpenCallback(int dc, void (*openCallback)(void *));
  54. void rtcSetErrorCallback(int dc, void (*errorCallback)(const char *, void *));
  55. void rtcSetMessageCallback(int dc, void (*messageCallback)(const char *, int, void *));
  56. int rtcSendMessage(int dc, const char *data, int size);
  57. void rtcSetUserPointer(int i, void *ptr);
  58. #ifdef __cplusplus
  59. } // extern "C"
  60. #endif
  61. #endif