webrtc_data_channel_extension.cpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**************************************************************************/
  2. /* webrtc_data_channel_extension.cpp */
  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. #include "webrtc_data_channel_extension.h"
  31. void WebRTCDataChannelExtension::_bind_methods() {
  32. ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
  33. GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
  34. GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
  35. GDVIRTUAL_BIND(_get_available_packet_count);
  36. GDVIRTUAL_BIND(_get_max_packet_size);
  37. GDVIRTUAL_BIND(_poll);
  38. GDVIRTUAL_BIND(_close);
  39. GDVIRTUAL_BIND(_set_write_mode, "p_write_mode");
  40. GDVIRTUAL_BIND(_get_write_mode);
  41. GDVIRTUAL_BIND(_was_string_packet);
  42. GDVIRTUAL_BIND(_get_ready_state);
  43. GDVIRTUAL_BIND(_get_label);
  44. GDVIRTUAL_BIND(_is_ordered);
  45. GDVIRTUAL_BIND(_get_id);
  46. GDVIRTUAL_BIND(_get_max_packet_life_time);
  47. GDVIRTUAL_BIND(_get_max_retransmits);
  48. GDVIRTUAL_BIND(_get_protocol);
  49. GDVIRTUAL_BIND(_is_negotiated);
  50. GDVIRTUAL_BIND(_get_buffered_amount);
  51. }
  52. Error WebRTCDataChannelExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
  53. Error err;
  54. if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
  55. return err;
  56. }
  57. WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_packet_native is unimplemented!");
  58. return FAILED;
  59. }
  60. Error WebRTCDataChannelExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
  61. Error err;
  62. if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
  63. return err;
  64. }
  65. WARN_PRINT_ONCE("WebRTCDataChannelExtension::_put_packet_native is unimplemented!");
  66. return FAILED;
  67. }