Browse Source

Merge pull request #993 from paullouisageneau/capi-max-message-size

Expose channel maxMessageSize in C API
Paul-Louis Ageneau 1 year ago
parent
commit
3adaadb3e5
4 changed files with 64 additions and 1 deletions
  1. 28 0
      DOC.md
  2. 1 1
      include/rtc/rtc.h
  3. 28 0
      pages/content/pages/reference.md
  4. 7 0
      src/capi.cpp

+ 28 - 0
DOC.md

@@ -383,6 +383,20 @@ Arguments:
 
 Return value: the maximum stream ID (`stream` for a Data Channel may be set from 0 to this value included) or a negative error code
 
+#### rtcGetRemoteMaxMessageSize
+
+```
+int rtcGetRemoteMaxMessageSize(int pc)
+```
+
+Retrieves the maximum message size for data channels on the peer connection as negotiated with the remote peer.
+
+Arguments:
+
+- `pc`: the Peer Connection identifier
+
+Return value: the maximum message size for data channels or a negative error code
+
 ### Channel (Common API for Data Channel, Track, and WebSocket)
 
 The following common functions might be called with a generic channel identifier. It may be the identifier of either a Data Channel, a Track, or a WebSocket.
@@ -519,6 +533,20 @@ Arguments:
 
 Return value: `true` if the channel exists and is closed (not open and not connecting), `false` otherwise
 
+#### rtcGetMaxMessageSize
+
+```
+int rtcGetMaxMessageSize(int id)
+```
+
+Retrieves the maximum message size for the channel.
+
+Arguments:
+
+- `id`: the channel identifier
+
+Return value: the maximum message size or a negative error code
+
 #### rtcGetBufferedAmount
 
 ```

+ 1 - 1
include/rtc/rtc.h

@@ -213,7 +213,6 @@ RTC_C_EXPORT int rtcGetSelectedCandidatePair(int pc, char *local, int localSize,
                                              int remoteSize);
 
 RTC_C_EXPORT int rtcGetMaxDataChannelStream(int pc);
-
 RTC_C_EXPORT int rtcGetRemoteMaxMessageSize(int pc);
 
 // DataChannel, Track, and WebSocket common API
@@ -228,6 +227,7 @@ RTC_C_EXPORT int rtcDelete(int id);
 RTC_C_EXPORT bool rtcIsOpen(int id);
 RTC_C_EXPORT bool rtcIsClosed(int id);
 
+RTC_C_EXPORT int rtcMaxMessageSize(int id);
 RTC_C_EXPORT int rtcGetBufferedAmount(int id); // total size buffered to send
 RTC_C_EXPORT int rtcSetBufferedAmountLowThreshold(int id, int amount);
 RTC_C_EXPORT int rtcSetBufferedAmountLowCallback(int id, rtcBufferedAmountLowCallbackFunc cb);

+ 28 - 0
pages/content/pages/reference.md

@@ -386,6 +386,20 @@ Arguments:
 
 Return value: the maximum stream ID (`stream` for a Data Channel may be set from 0 to this value included) or a negative error code
 
+#### rtcGetRemoteMaxMessageSize
+
+```
+int rtcGetRemoteMaxMessageSize(int pc)
+```
+
+Retrieves the maximum message size for data channels on the peer connection as negotiated with the remote peer.
+
+Arguments:
+
+- `pc`: the Peer Connection identifier
+
+Return value: the maximum message size for data channels or a negative error code
+
 ### Channel (Common API for Data Channel, Track, and WebSocket)
 
 The following common functions might be called with a generic channel identifier. It may be the identifier of either a Data Channel, a Track, or a WebSocket.
@@ -522,6 +536,20 @@ Arguments:
 
 Return value: `true` if the channel exists and is closed (not open and not connecting), `false` otherwise
 
+#### rtcGetMaxMessageSize
+
+```
+int rtcGetMaxMessageSize(int id)
+```
+
+Retrieves the maximum message size for the channel.
+
+Arguments:
+
+- `id`: the channel identifier
+
+Return value: the maximum message size or a negative error code
+
 #### rtcGetBufferedAmount
 
 ```

+ 7 - 0
src/capi.cpp

@@ -807,6 +807,13 @@ bool rtcIsClosed(int id) {
 	return wrap([id] { return getChannel(id)->isClosed() ? 0 : 1; }) == 0 ? true : false;
 }
 
+int rtcMaxMessageSize(int id) {
+	return wrap([id] {
+		auto channel = getChannel(id);
+		return int(channel->maxMessageSize());
+	});
+}
+
 int rtcGetBufferedAmount(int id) {
 	return wrap([id] {
 		auto channel = getChannel(id);