Browse Source

Added WebSocket protocols to C API

Paul-Louis Ageneau 3 years ago
parent
commit
48a7e7e729
2 changed files with 5 additions and 0 deletions
  1. 2 0
      include/rtc/rtc.h
  2. 3 0
      src/capi.cpp

+ 2 - 0
include/rtc/rtc.h

@@ -366,6 +366,8 @@ int rtcSetSsrcForType(const char *mediaType, const char *sdp, char *buffer, cons
 typedef struct {
 	bool disableTlsVerification; // if true, don't verify the TLS certificate
 	const char *proxyServer;     // unsupported for now
+	const char **protocols;
+	int protocolsCount;
 } rtcWsConfiguration;
 
 RTC_EXPORT int rtcCreateWebSocket(const char *url); // returns ws id

+ 3 - 0
src/capi.cpp

@@ -1288,6 +1288,9 @@ int rtcCreateWebSocketEx(const char *url, const rtcWsConfiguration *config) {
 		if (config->proxyServer)
 			c.proxyServer.emplace(config->proxyServer);
 
+		for (int i = 0; i < config->protocolsCount; ++i)
+			c.protocols.emplace_back(string(config->protocols[i]));
+
 		auto webSocket = std::make_shared<WebSocket>(std::move(c));
 		webSocket->open(url);
 		return emplaceWebSocket(webSocket);