diff --git a/include/rtc/rtc.h b/include/rtc/rtc.h index 107763b..fa511c7 100644 --- a/include/rtc/rtc.h +++ b/include/rtc/rtc.h @@ -101,8 +101,8 @@ typedef struct { rtcReliability reliability; const char *protocol; // empty string if NULL bool negotiated; - bool manualId; - uint16_t id; // ignored if manualId is false + bool manualStream; + uint16_t stream; // numeric ID 0-65534, ignored if manualStream is false } rtcDataChannelInit; typedef void(RTC_API *rtcLogCallbackFunc)(rtcLogLevel level, const char *message); @@ -158,6 +158,7 @@ RTC_EXPORT int rtcCreateDataChannel(int pc, const char *label); // returns dc id RTC_EXPORT int rtcCreateDataChannelExt(int pc, const char *label, const rtcDataChannelInit *init); // returns dc id RTC_EXPORT int rtcDeleteDataChannel(int dc); +RTC_EXPORT int rtcGetDataChannelStream(int dc); RTC_EXPORT int rtcGetDataChannelLabel(int dc, char *buffer, int size); RTC_EXPORT int rtcGetDataChannelProtocol(int dc, char *buffer, int size); RTC_EXPORT int rtcGetDataChannelReliability(int dc, rtcReliability *reliability); diff --git a/src/capi.cpp b/src/capi.cpp index 9abfc68..44f495e 100644 --- a/src/capi.cpp +++ b/src/capi.cpp @@ -327,7 +327,7 @@ int rtcAddDataChannelExt(int pc, const char *label, const rtcDataChannelInit *in } dci.negotiated = init->negotiated; - dci.id = init->manualId ? std::make_optional(init->id) : nullopt; + dci.id = init->manualStream ? std::make_optional(init->stream) : nullopt; dci.protocol = init->protocol ? init->protocol : ""; } @@ -628,6 +628,13 @@ int rtcGetSelectedCandidatePair(int pc, char *local, int localSize, char *remote }); } +int rtcGetDataChannelStream(int dc) { + return WRAP({ + auto dataChannel = getDataChannel(dc); + return int(dataChannel->id()); + }); +} + int rtcGetDataChannelLabel(int dc, char *buffer, int size) { return WRAP({ auto dataChannel = getDataChannel(dc);