Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: always open firewall before sending messages #666

Merged
merged 1 commit into from
Dec 24, 2024
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
14 changes: 7 additions & 7 deletions server_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,13 @@ func TestServerRecord(t *testing.T) {
doRecord(t, conn, "rtsp://localhost:8554/teststream", session)

for i := 0; i < 2; i++ {
// skip firewall opening
if transport == "udp" {
buf := make([]byte, 2048)
_, _, err = l2s[i].ReadFrom(buf)
require.NoError(t, err)
}

// server -> client (direct)
if transport == "udp" {
buf := make([]byte, 2048)
Expand All @@ -728,13 +735,6 @@ func TestServerRecord(t *testing.T) {
require.Equal(t, testRTCPPacketMarshaled, f.Payload)
}

// skip firewall opening
if transport == "udp" {
buf := make([]byte, 2048)
_, _, err = l2s[i].ReadFrom(buf)
require.NoError(t, err)
}

// client -> server
if transport == "udp" {
_, err = l1s[i].WriteTo(testRTPPacketMarshaled, &net.UDPAddr{
Expand Down
7 changes: 5 additions & 2 deletions server_session_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ func (sm *serverSessionMedia) start() {
sm.ss.s.udpRTCPListener.addClient(sm.ss.author.ip(), sm.udpRTCPReadPort, sm.readRTCPUDPPlay)
} else {
// open the firewall by sending empty packets to the counterpart.
sm.ss.WritePacketRTP(sm.media, &rtp.Packet{Header: rtp.Header{Version: 2}}) //nolint:errcheck
sm.ss.WritePacketRTCP(sm.media, &rtcp.ReceiverReport{}) //nolint:errcheck
byts, _ := (&rtp.Packet{Header: rtp.Header{Version: 2}}).Marshal()
sm.ss.s.udpRTPListener.write(byts, sm.udpRTPWriteAddr) //nolint:errcheck

byts, _ = (&rtcp.ReceiverReport{}).Marshal()
sm.ss.s.udpRTCPListener.write(byts, sm.udpRTCPWriteAddr) //nolint:errcheck

sm.ss.s.udpRTPListener.addClient(sm.ss.author.ip(), sm.udpRTPReadPort, sm.readRTPUDPRecord)
sm.ss.s.udpRTCPListener.addClient(sm.ss.author.ip(), sm.udpRTCPReadPort, sm.readRTCPUDPRecord)
Expand Down