Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct Args {

// webrtc
int jpeg_quality = 30;
int peer_timeout = 10;
int peer_timeout = 60;
bool hw_accel = false;
bool no_adaptive = false;
std::string uid = "";
Expand Down
19 changes: 17 additions & 2 deletions src/rtc/rtc_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ std::shared_ptr<RtcChannel> RtcPeer::CreateDataChannel(ChannelMode mode) {
}

std::string RtcPeer::RestartIce(std::string ice_ufrag, std::string ice_pwd) {
if (!peer_connection_ || !peer_connection_->remote_description()) {
ERROR_PRINT("RestartIce ignored: peer connection (%s) is gone or has no remote sdp.",
id_.c_str());
return "";
}

std::string remote_sdp;
peer_connection_->remote_description()->ToString(&remote_sdp);

Expand Down Expand Up @@ -173,8 +179,8 @@ void RtcPeer::OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState
}),
webrtc::TimeDelta::Seconds(timeout_));
} else if (new_state == webrtc::PeerConnectionInterface::SignalingState::kStable &&
is_connected_.load() && !needs_renegotiation_ && !is_sfu_peer_) {
// Renegotiation completed — clean up signaling callbacks
is_connected_.load() && !needs_renegotiation_ && !is_sfu_peer_ &&
has_candidates_in_sdp_) {
DEBUG_PRINT("Renegotiation completed, cleaning up signaling callbacks.");
on_local_ice_fn_ = nullptr;
on_local_sdp_fn_ = nullptr;
Expand Down Expand Up @@ -348,6 +354,10 @@ void RtcPeer::OnFailure(webrtc::RTCError error) {
}

void RtcPeer::SetRemoteSdp(const std::string &sdp, const std::string &sdp_type) {
if (!peer_connection_) {
DEBUG_PRINT("SetRemoteSdp ignored: peer connection (%s) is gone.", id_.c_str());
return;
}
if (!is_negotiating_.load() && sdp_type != "offer") {
return;
}
Expand Down Expand Up @@ -391,6 +401,11 @@ void RtcPeer::SetRemoteSdp(const std::string &sdp, const std::string &sdp_type)

void RtcPeer::SetRemoteIce(const std::string &sdp_mid, int sdp_mline_index,
const std::string &candidate) {
if (!peer_connection_) {
DEBUG_PRINT("SetRemoteIce ignored: peer connection (%s) is gone.", id_.c_str());
return;
}

// Only reject ICE before remote description is established (no session yet).
if (!peer_connection_->remote_description()) {
DEBUG_PRINT("Buffering early ICE candidate (no remote description yet).");
Expand Down
Loading