Added rtcGetRemoteDescription() for the sake of completeness

This commit is contained in:
Paul-Louis Ageneau
2020-10-03 19:55:14 +02:00
parent ebc6a4b65c
commit cbc027f144
2 changed files with 24 additions and 0 deletions

View File

@ -122,6 +122,7 @@ RTC_EXPORT int rtcSetRemoteDescription(int pc, const char *sdp, const char *type
RTC_EXPORT int rtcAddRemoteCandidate(int pc, const char *cand, const char *mid);
RTC_EXPORT int rtcGetLocalDescription(int pc, char *buffer, int size);
RTC_EXPORT int rtcGetRemoteDescription(int pc, char *buffer, int size);
RTC_EXPORT int rtcGetLocalAddress(int pc, char *buffer, int size);
RTC_EXPORT int rtcGetRemoteAddress(int pc, char *buffer, int size);

View File

@ -552,6 +552,29 @@ int rtcGetLocalDescription(int pc, char *buffer, int size) {
});
}
int rtcGetRemoteDescription(int pc, char *buffer, int size) {
return WRAP({
auto peerConnection = getPeerConnection(pc);
if (size <= 0)
return 0;
if (!buffer)
throw std::invalid_argument("Unexpected null pointer for buffer");
if (auto desc = peerConnection->remoteDescription()) {
auto sdp = string(*desc);
const char *data = sdp.data();
size = std::min(size - 1, int(sdp.size()));
std::copy(data, data + size, buffer);
buffer[size] = '\0';
return size + 1;
}
return RTC_ERR_FAILURE;
});
}
int rtcGetLocalAddress(int pc, char *buffer, int size) {
return WRAP({
auto peerConnection = getPeerConnection(pc);