From 88ea6adb94c6a1b6f3d91b39419fdc87b9be6847 Mon Sep 17 00:00:00 2001 From: Paul-Louis Ageneau Date: Tue, 30 Jul 2024 14:29:39 +0200 Subject: [PATCH] Add rtcIsNegotiationNeeded() to C API --- DOC.md | 12 ++++++++++++ include/rtc/rtc.h | 2 ++ pages/content/pages/reference.md | 12 ++++++++++++ src/capi.cpp | 5 +++++ 4 files changed, 31 insertions(+) diff --git a/DOC.md b/DOC.md index 50ad1758b..ca6d27cca 100644 --- a/DOC.md +++ b/DOC.md @@ -371,6 +371,18 @@ Return value: the maximun length of strings copied in buffers (including the ter If `local`, `remote`, or both, are `NULL`, the corresponding candidate is not copied, but the maximum length is still returned. +#### rtcIsNegotiationNeeded +``` +bool rtcIsNegotiationNeeded(int pc); +``` + +Return true if negotiation needs to be started or restarted, for instance to signal new tracks. If so, the user may call `rtcSetLocalDescription()` to start it. + +Arguments: +- `pc`: the Peer Connection identifier + +Return value: true if negotiation is needed + #### rtcGetMaxDataChannelStream ``` int rtcGetMaxDataChannelStream(int pc); diff --git a/include/rtc/rtc.h b/include/rtc/rtc.h index bc7aed65f..2fc70c90c 100644 --- a/include/rtc/rtc.h +++ b/include/rtc/rtc.h @@ -227,6 +227,8 @@ RTC_C_EXPORT int rtcGetRemoteAddress(int pc, char *buffer, int size); RTC_C_EXPORT int rtcGetSelectedCandidatePair(int pc, char *local, int localSize, char *remote, int remoteSize); +RTC_C_EXPORT bool rtcIsNegotiationNeeded(int pc); + RTC_C_EXPORT int rtcGetMaxDataChannelStream(int pc); RTC_C_EXPORT int rtcGetRemoteMaxMessageSize(int pc); diff --git a/pages/content/pages/reference.md b/pages/content/pages/reference.md index ea10e5c10..fd4049db2 100644 --- a/pages/content/pages/reference.md +++ b/pages/content/pages/reference.md @@ -374,6 +374,18 @@ Return value: the maximun length of strings copied in buffers (including the ter If `local`, `remote`, or both, are `NULL`, the corresponding candidate is not copied, but the maximum length is still returned. +#### rtcIsNegotiationNeeded +``` +bool rtcIsNegotiationNeeded(int pc); +``` + +Return true if negotiation needs to be started or restarted, for instance to signal new tracks. If so, the user may call `rtcSetLocalDescription()` to start it. + +Arguments: +- `pc`: the Peer Connection identifier + +Return value: true if negotiation is needed + #### rtcGetMaxDataChannelStream ``` int rtcGetMaxDataChannelStream(int pc); diff --git a/src/capi.cpp b/src/capi.cpp index bf7bca3c0..ead5cedf3 100644 --- a/src/capi.cpp +++ b/src/capi.cpp @@ -674,6 +674,11 @@ int rtcGetSelectedCandidatePair(int pc, char *local, int localSize, char *remote }); } +bool rtcIsNegotiationNeeded(int pc) { + return wrap([&] { return getPeerConnection(pc)->negotiationNeeded() ? 0 : 1; }) == 0 ? true + : false; +} + int rtcGetMaxDataChannelStream(int pc) { return wrap([&] { auto peerConnection = getPeerConnection(pc);