godot_webrtc.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**************************************************************************/
  2. /* godot_webrtc.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef GODOT_WEBRTC_H
  31. #define GODOT_WEBRTC_H
  32. #include <gdnative/gdnative.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #define GODOT_NET_WEBRTC_API_MAJOR 3
  37. #define GODOT_NET_WEBRTC_API_MINOR 4
  38. /* Library Interface (used to set default GDNative WebRTC implementation */
  39. typedef struct {
  40. godot_gdnative_api_version version; /* version of our API */
  41. /* Called when the library is unset as default interface via godot_net_set_webrtc_library */
  42. void (*unregistered)();
  43. /* Used by WebRTCPeerConnection create when GDNative is the default implementation. */
  44. /* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */
  45. godot_error (*create_peer_connection)(godot_object *);
  46. void *next; /* For extension */
  47. } godot_net_webrtc_library;
  48. /* WebRTCPeerConnection interface */
  49. typedef struct {
  50. godot_gdnative_api_version version; /* version of our API */
  51. godot_object *data; /* User reference */
  52. /* This is WebRTCPeerConnection */
  53. godot_int (*get_connection_state)(const void *);
  54. godot_error (*initialize)(void *, const godot_dictionary *);
  55. godot_object *(*create_data_channel)(void *, const char *p_channel_name, const godot_dictionary *);
  56. godot_error (*create_offer)(void *);
  57. godot_error (*create_answer)(void *); /* unused for now, should be done automatically on set_local_description */
  58. godot_error (*set_remote_description)(void *, const char *, const char *);
  59. godot_error (*set_local_description)(void *, const char *, const char *);
  60. godot_error (*add_ice_candidate)(void *, const char *, int, const char *);
  61. godot_error (*poll)(void *);
  62. void (*close)(void *);
  63. void *next; /* For extension? */
  64. } godot_net_webrtc_peer_connection;
  65. /* WebRTCDataChannel interface */
  66. typedef struct {
  67. godot_gdnative_api_version version; /* version of our API */
  68. godot_object *data; /* User reference */
  69. /* This is PacketPeer */
  70. godot_error (*get_packet)(void *, const uint8_t **, int *);
  71. godot_error (*put_packet)(void *, const uint8_t *, int);
  72. godot_int (*get_available_packet_count)(const void *);
  73. godot_int (*get_max_packet_size)(const void *);
  74. /* This is WebRTCDataChannel */
  75. void (*set_write_mode)(void *, godot_int);
  76. godot_int (*get_write_mode)(const void *);
  77. bool (*was_string_packet)(const void *);
  78. godot_int (*get_ready_state)(const void *);
  79. const char *(*get_label)(const void *);
  80. bool (*is_ordered)(const void *);
  81. int (*get_id)(const void *);
  82. int (*get_max_packet_life_time)(const void *);
  83. int (*get_max_retransmits)(const void *);
  84. const char *(*get_protocol)(const void *);
  85. bool (*is_negotiated)(const void *);
  86. godot_error (*poll)(void *);
  87. void (*close)(void *);
  88. void *next; /* For extension? */
  89. } godot_net_webrtc_data_channel;
  90. /* Extensions to WebRTCDataChannel */
  91. typedef struct {
  92. int (*get_buffered_amount)(const void *);
  93. void *next; /* For extension? */
  94. } godot_net_webrtc_data_channel_ext;
  95. /* Set the default GDNative library */
  96. godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *);
  97. /* Binds a WebRTCPeerConnectionGDNative to the provided interface */
  98. void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *);
  99. /* Binds a WebRTCDataChannelGDNative to the provided interface */
  100. void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif // GODOT_WEBRTC_H