Skip to content

Commit

Permalink
Support SRT listen ep in UDP.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 5, 2024
1 parent 0556fe7 commit 2120738
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion proxy/rtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (v *RTCConnection) connectBackend(ctx context.Context) error {

_, _, udpPort, err := parseListenEndpoint(backend.RTC[0])
if err != nil {
return errors.Wrapf(err, "parse endpoint %v", backend.RTC[0])
return errors.Wrapf(err, "parse udp port %v of %v for %v", backend.RTC[0], backend, v.StreamURL)
}

// Connect to backend SRS server via UDP client.
Expand Down
11 changes: 4 additions & 7 deletions proxy/srt.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/binary"
"fmt"
"net"
"strconv"
"strings"
stdSync "sync"
"time"
Expand Down Expand Up @@ -351,16 +350,14 @@ func (v *SRTConnection) connectBackend(ctx context.Context, streamID string) err
return errors.Errorf("no udp server %v for %v", backend, streamURL)
}

var udpPort int
if iv, err := strconv.ParseInt(backend.SRT[0], 10, 64); err != nil {
_, _, udpPort, err := parseListenEndpoint(backend.SRT[0])
if err != nil {
return errors.Wrapf(err, "parse udp port %v of %v for %v", backend.SRT[0], backend, streamURL)
} else {
udpPort = int(iv)
}

// Connect to backend SRS server via UDP client.
// TODO: FIXME: Support close the connection when timeout or DTLS alert.
backendAddr := net.UDPAddr{IP: net.ParseIP(backend.IP), Port: udpPort}
// TODO: FIXME: Support close the connection when timeout or client disconnected.
backendAddr := net.UDPAddr{IP: net.ParseIP(backend.IP), Port: int(udpPort)}
if backendUDP, err := net.DialUDP("udp", nil, &backendAddr); err != nil {
return errors.Wrapf(err, "dial udp to %v of %v for %v", backendAddr, backend, streamURL)
} else {
Expand Down

0 comments on commit 2120738

Please sign in to comment.