add ConnClient.Tracks(); remove Tracks from DialRead returned values

This commit is contained in:
aler9
2020-10-10 15:29:03 +02:00
parent d33ee9a73e
commit 6e4eaaea18
5 changed files with 25 additions and 14 deletions

View File

@@ -86,6 +86,7 @@ type ConnClient struct {
state connClientState
streamUrl *url.URL
streamProtocol *StreamProtocol
tracks map[int]*Track
rtcpReceivers map[int]*rtcpreceiver.RtcpReceiver
udpLastFrameTimes map[int]*int64
udpRtpListeners map[int]*connClientUDPListener
@@ -131,6 +132,7 @@ 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),
@@ -184,6 +186,11 @@ 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 {
return c.tracks
}
func (c *ConnClient) readFrameTCPOrResponse() (interface{}, error) {
frame := c.tcpFrames.next()
@@ -579,6 +586,8 @@ func (c *ConnClient) SetupUDP(u *url.URL, mode TransportMode, track *Track, rtpP
streamProtocol := StreamProtocolUDP
c.streamProtocol = &streamProtocol
c.tracks[track.Id] = track
if mode == TransportModePlay {
c.rtcpReceivers[track.Id] = rtcpreceiver.New()
@@ -643,6 +652,8 @@ func (c *ConnClient) SetupTCP(u *url.URL, mode TransportMode, track *Track) (*ba
streamProtocol := StreamProtocolTCP
c.streamProtocol = &streamProtocol
c.tracks[track.Id] = track
if mode == TransportModePlay {
c.rtcpReceivers[track.Id] = rtcpreceiver.New()
}