Some rabbit nitpick fixes 2

This commit is contained in:
DatCaptainHorse
2025-11-07 10:01:22 +02:00
parent 8d5895fc5e
commit 9bee9d4935
3 changed files with 22 additions and 10 deletions

View File

@@ -123,8 +123,6 @@ export class WebRTCStream {
} else { } else {
iceHolder.push(cand); iceHolder.push(cand);
} }
} else {
iceHolder.push(cand);
} }
}); });
@@ -143,6 +141,14 @@ export class WebRTCStream {
sdp: data.sdp.sdp, sdp: data.sdp.sdp,
type: data.sdp.type as RTCSdpType, type: data.sdp.type as RTCSdpType,
}); });
// Add held candidates
iceHolder.forEach((candidate) => {
this._pc!.addIceCandidate(candidate).catch((err) => {
console.error("Error adding held ICE candidate:", err);
});
});
iceHolder = [];
// Create our answer // Create our answer
const answer = await this._pc!.createAnswer(); const answer = await this._pc!.createAnswer();
// Force stereo in Chromium browsers // Force stereo in Chromium browsers

View File

@@ -271,12 +271,16 @@ func (sp *StreamProtocol) handleStreamRequest(stream network.Stream) {
} }
candInit := candidate.ToJSON() candInit := candidate.ToJSON()
biggified := uint32(*candInit.SDPMLineIndex) var sdpMLineIndex *uint32
if candInit.SDPMLineIndex != nil {
idx := uint32(*candInit.SDPMLineIndex)
sdpMLineIndex = &idx
}
iceMsg, err := common.CreateMessage( iceMsg, err := common.CreateMessage(
&gen.ProtoICE{ &gen.ProtoICE{
Candidate: &gen.RTCIceCandidateInit{ Candidate: &gen.RTCIceCandidateInit{
Candidate: candInit.Candidate, Candidate: candInit.Candidate,
SdpMLineIndex: &biggified, SdpMLineIndex: sdpMLineIndex,
SdpMid: candInit.SDPMid, SdpMid: candInit.SDPMid,
}, },
}, },
@@ -338,13 +342,15 @@ func (sp *StreamProtocol) handleStreamRequest(stream network.Stream) {
case "ice-candidate": case "ice-candidate":
iceMsg := msgWrapper.GetIce() iceMsg := msgWrapper.GetIce()
if iceMsg != nil { if iceMsg != nil {
smollified := uint16(*iceMsg.Candidate.SdpMLineIndex)
cand := webrtc.ICECandidateInit{ cand := webrtc.ICECandidateInit{
Candidate: iceMsg.Candidate.Candidate, Candidate: iceMsg.Candidate.Candidate,
SDPMid: iceMsg.Candidate.SdpMid, SDPMid: iceMsg.Candidate.SdpMid,
SDPMLineIndex: &smollified,
UsernameFragment: iceMsg.Candidate.UsernameFragment, UsernameFragment: iceMsg.Candidate.UsernameFragment,
} }
if iceMsg.Candidate.SdpMLineIndex != nil {
smollified := uint16(*iceMsg.Candidate.SdpMLineIndex)
cand.SDPMLineIndex = &smollified
}
iceHelper.AddCandidate(cand) iceHelper.AddCandidate(cand)
} else { } else {
slog.Error("Could not GetIce from ice-candidate") slog.Error("Could not GetIce from ice-candidate")

View File

@@ -63,13 +63,13 @@ func (p *Participant) SetTrack(trackType webrtc.RTPCodecType, track *webrtc.Trac
p.AudioTrack = track p.AudioTrack = track
_, err := p.PeerConnection.AddTrack(track) _, err := p.PeerConnection.AddTrack(track)
if err != nil { if err != nil {
slog.Error("Failed to add Participant audio track", "participant", p.ID, "err", err) slog.Error("Failed to add audio track", "participant", p.ID, "err", err)
} }
case webrtc.RTPCodecTypeVideo: case webrtc.RTPCodecTypeVideo:
p.VideoTrack = track p.VideoTrack = track
_, err := p.PeerConnection.AddTrack(track) _, err := p.PeerConnection.AddTrack(track)
if err != nil { if err != nil {
slog.Error("Failed to add Participant video track", "participant", p.ID, "err", err) slog.Error("Failed to add video track", "participant", p.ID, "err", err)
} }
default: default:
slog.Warn("Unknown track type", "participant", p.ID, "trackType", trackType) slog.Warn("Unknown track type", "participant", p.ID, "trackType", trackType)
@@ -84,14 +84,14 @@ func (p *Participant) Close() {
if p.DataChannel != nil { if p.DataChannel != nil {
err := p.DataChannel.Close() err := p.DataChannel.Close()
if err != nil { if err != nil {
slog.Error("Failed to close Participant DataChannel", err) slog.Error("Failed to close DataChannel", "participant", p.ID, "err", err)
} }
p.DataChannel = nil p.DataChannel = nil
} }
if p.PeerConnection != nil { if p.PeerConnection != nil {
err := p.PeerConnection.Close() err := p.PeerConnection.Close()
if err != nil { if err != nil {
slog.Error("Failed to close Participant PeerConnection", err) slog.Error("Failed to close PeerConnection", "participant", p.ID, "err", err)
} }
p.PeerConnection = nil p.PeerConnection = nil
} }