mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
change ConnClient.Tracks() signature
This commit is contained in:
@@ -86,7 +86,7 @@ type ConnClient struct {
|
||||
state connClientState
|
||||
streamUrl *base.URL
|
||||
streamProtocol *StreamProtocol
|
||||
tracks map[int]*Track
|
||||
tracks Tracks
|
||||
rtcpReceivers map[int]*rtcpreceiver.RtcpReceiver
|
||||
udpLastFrameTimes map[int]*int64
|
||||
udpRtpListeners map[int]*connClientUDPListener
|
||||
@@ -137,7 +137,6 @@ func NewConnClient(conf ConnClientConf) (*ConnClient, error) {
|
||||
conf: conf,
|
||||
br: bufio.NewReaderSize(conf.Conn, clientReadBufferSize),
|
||||
bw: bufio.NewWriterSize(conf.Conn, clientWriteBufferSize),
|
||||
tracks: make(map[int]*Track),
|
||||
rtcpReceivers: make(map[int]*rtcpreceiver.RtcpReceiver),
|
||||
udpLastFrameTimes: make(map[int]*int64),
|
||||
udpRtpListeners: make(map[int]*connClientUDPListener),
|
||||
@@ -192,8 +191,8 @@ func (c *ConnClient) NetConn() net.Conn {
|
||||
return c.conf.Conn
|
||||
}
|
||||
|
||||
// Tracks returns all the tracks passed to SetupUDP() or SetupTCP().
|
||||
func (c *ConnClient) Tracks() map[int]*Track {
|
||||
// Tracks returns all the tracks that the connection is reading or publishing.
|
||||
func (c *ConnClient) Tracks() Tracks {
|
||||
return c.tracks
|
||||
}
|
||||
|
||||
@@ -569,7 +568,7 @@ func (c *ConnClient) SetupUDP(u *base.URL, mode TransportMode, track *Track, rtp
|
||||
streamProtocol := StreamProtocolUDP
|
||||
c.streamProtocol = &streamProtocol
|
||||
|
||||
c.tracks[track.Id] = track
|
||||
c.tracks = append(c.tracks, track)
|
||||
|
||||
if mode == TransportModePlay {
|
||||
c.rtcpReceivers[track.Id] = rtcpreceiver.New()
|
||||
@@ -635,7 +634,7 @@ func (c *ConnClient) SetupTCP(u *base.URL, mode TransportMode, track *Track) (*b
|
||||
streamProtocol := StreamProtocolTCP
|
||||
c.streamProtocol = &streamProtocol
|
||||
|
||||
c.tracks[track.Id] = track
|
||||
c.tracks = append(c.tracks, track)
|
||||
|
||||
if mode == TransportModePlay {
|
||||
c.rtcpReceivers[track.Id] = rtcpreceiver.New()
|
||||
|
@@ -24,7 +24,7 @@ func main() {
|
||||
defer wg.Wait()
|
||||
defer conn.CloseUDPListeners()
|
||||
|
||||
for trackId := range conn.Tracks() {
|
||||
for _, track := range conn.Tracks() {
|
||||
// read RTP frames
|
||||
wg.Add(1)
|
||||
go func(trackId int) {
|
||||
@@ -38,7 +38,7 @@ func main() {
|
||||
|
||||
fmt.Printf("frame from track %d, type RTP: %v\n", trackId, buf)
|
||||
}
|
||||
}(trackId)
|
||||
}(track.Id)
|
||||
|
||||
// read RTCP frames
|
||||
wg.Add(1)
|
||||
@@ -53,7 +53,7 @@ func main() {
|
||||
|
||||
fmt.Printf("frame from track %d, type RTCP: %v\n", trackId, buf)
|
||||
}
|
||||
}(trackId)
|
||||
}(track.Id)
|
||||
}
|
||||
|
||||
// wait until the connection is closed
|
||||
|
Reference in New Issue
Block a user