webrtc_peer_connection_extension.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*************************************************************************/
  2. /* webrtc_peer_connection_extension.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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_peer_connection_extension.h"
  31. void WebRTCPeerConnectionExtension::_bind_methods() {
  32. GDVIRTUAL_BIND(_get_connection_state);
  33. GDVIRTUAL_BIND(_initialize, "p_config");
  34. GDVIRTUAL_BIND(_create_data_channel, "p_label", "p_config");
  35. GDVIRTUAL_BIND(_create_offer);
  36. GDVIRTUAL_BIND(_set_remote_description, "p_type", "p_sdp");
  37. GDVIRTUAL_BIND(_set_local_description, "p_type", "p_sdp");
  38. GDVIRTUAL_BIND(_add_ice_candidate, "p_sdp_mid_name", "p_sdp_mline_index", "p_sdp_name");
  39. GDVIRTUAL_BIND(_poll);
  40. GDVIRTUAL_BIND(_close);
  41. }
  42. WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionExtension::get_connection_state() const {
  43. int state;
  44. if (GDVIRTUAL_CALL(_get_connection_state, state)) {
  45. return (ConnectionState)state;
  46. }
  47. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_get_connection_state is unimplemented!");
  48. return STATE_DISCONNECTED;
  49. }
  50. Error WebRTCPeerConnectionExtension::initialize(Dictionary p_config) {
  51. int err;
  52. if (GDVIRTUAL_CALL(_initialize, p_config, err)) {
  53. return (Error)err;
  54. }
  55. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_initialize is unimplemented!");
  56. return ERR_UNCONFIGURED;
  57. }
  58. Ref<WebRTCDataChannel> WebRTCPeerConnectionExtension::create_data_channel(String p_label, Dictionary p_options) {
  59. Object *ret = nullptr;
  60. if (GDVIRTUAL_CALL(_create_data_channel, p_label, p_options, ret)) {
  61. WebRTCDataChannel *ch = Object::cast_to<WebRTCDataChannel>(ret);
  62. ERR_FAIL_COND_V_MSG(ret && !ch, nullptr, "Returned object must be an instance of WebRTCDataChannel.");
  63. return ch;
  64. }
  65. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_data_channel is unimplemented!");
  66. return nullptr;
  67. }
  68. Error WebRTCPeerConnectionExtension::create_offer() {
  69. int err;
  70. if (GDVIRTUAL_CALL(_create_offer, err)) {
  71. return (Error)err;
  72. }
  73. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_offer is unimplemented!");
  74. return ERR_UNCONFIGURED;
  75. }
  76. Error WebRTCPeerConnectionExtension::set_local_description(String p_type, String p_sdp) {
  77. int err;
  78. if (GDVIRTUAL_CALL(_set_local_description, p_type, p_sdp, err)) {
  79. return (Error)err;
  80. }
  81. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_local_description is unimplemented!");
  82. return ERR_UNCONFIGURED;
  83. }
  84. Error WebRTCPeerConnectionExtension::set_remote_description(String p_type, String p_sdp) {
  85. int err;
  86. if (GDVIRTUAL_CALL(_set_remote_description, p_type, p_sdp, err)) {
  87. return (Error)err;
  88. }
  89. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_remote_description is unimplemented!");
  90. return ERR_UNCONFIGURED;
  91. }
  92. Error WebRTCPeerConnectionExtension::add_ice_candidate(String p_sdp_mid_name, int p_sdp_mline_index, String p_sdp_name) {
  93. int err;
  94. if (GDVIRTUAL_CALL(_add_ice_candidate, p_sdp_mid_name, p_sdp_mline_index, p_sdp_name, err)) {
  95. return (Error)err;
  96. }
  97. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_add_ice_candidate is unimplemented!");
  98. return ERR_UNCONFIGURED;
  99. }
  100. Error WebRTCPeerConnectionExtension::poll() {
  101. int err;
  102. if (GDVIRTUAL_CALL(_poll, err)) {
  103. return (Error)err;
  104. }
  105. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_poll is unimplemented!");
  106. return ERR_UNCONFIGURED;
  107. }
  108. void WebRTCPeerConnectionExtension::close() {
  109. if (GDVIRTUAL_CALL(_close)) {
  110. return;
  111. }
  112. WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_close is unimplemented!");
  113. }