Skip to content

Commit bc3b637

Browse files
author
Thomas
committed
examples handle remote description exceptions
1 parent 1a2e8fa commit bc3b637

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ Run the RTSP device:
6060
-k key.pem --secret <secret> \
6161
-r rtsp://127.0.0.1:8554/video`
6262
```
63+
64+
## Limitations
65+
66+
The libdatachannel WebRTC library used by the examples does not currently support offers generated with `restartIce()` due to this [issue](https://github.com/paullouisageneau/libdatachannel/issues/545). This means if one of the peers experiences a network failure or switches to a different network, any open WebRTC connections cannot be renegotiated. Instead the connection has to be recreated from scratch.

examples/libdatachannel/src/common/webrtc_connection/webrtc_connection.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ void WebrtcConnection::handleMessage(const nlohmann::json& msg) {
109109
"discarding the received offer";
110110
return;
111111
}
112-
113-
pc_->setRemoteDescription(remDesc);
112+
try {
113+
pc_->setRemoteDescription(remDesc);
114+
} catch (std::exception& ex) {
115+
NPLOGE << "Failed to set remote description: " << remDesc.generateSdp()
116+
<< " Failed with exception: " << ex.what();
117+
pc_->close();
118+
}
114119
} else if (type == "CANDIDATE") {
115120
try {
116121
rtc::Candidate cand(
@@ -195,7 +200,7 @@ void WebrtcConnection::handleStateChange(
195200
// \o/ we should use the connection
196201
break;
197202
case rtc::PeerConnection::State::Failed:
198-
// connection fail and we should fix it
203+
// connection failed
199204
case rtc::PeerConnection::State::Closed:
200205
// connection closed we should clean up
201206
NPLOGI << "Webrtc Connection " << state;

0 commit comments

Comments
 (0)