new track system

This commit is contained in:
aler9
2022-01-28 17:42:20 +01:00
committed by Alessandro Ros
parent cd0db96a5d
commit 6d5bf0c1bb
31 changed files with 1523 additions and 1432 deletions

View File

@@ -21,8 +21,6 @@ import (
"sync/atomic"
"time"
psdp "github.com/pion/sdp/v3"
"github.com/aler9/gortsplib/pkg/auth"
"github.com/aler9/gortsplib/pkg/base"
"github.com/aler9/gortsplib/pkg/headers"
@@ -53,7 +51,7 @@ const (
)
type clientTrack struct {
track *Track
track Track
udpRTPListener *clientUDPListener
udpRTCPListener *clientUDPListener
tcpChannel int
@@ -97,7 +95,7 @@ type announceReq struct {
type setupReq struct {
forPlay bool
track *Track
track Track
baseURL *base.URL
rtpPort int
rtcpPort int
@@ -1177,14 +1175,7 @@ func (c *Client) doAnnounce(u *base.URL, tracks Tracks) (*base.Response, error)
// (tested with ffmpeg and gstreamer)
baseURL := u.Clone()
for i, t := range tracks {
if !t.hasControlAttribute() {
t.Media.Attributes = append(t.Media.Attributes, psdp.Attribute{
Key: "control",
Value: "trackID=" + strconv.FormatInt(int64(i), 10),
})
}
}
tracks.setControls()
res, err := c.do(&base.Request{
Method: base.Announce,
@@ -1225,7 +1216,7 @@ func (c *Client) Announce(u *base.URL, tracks Tracks) (*base.Response, error) {
func (c *Client) doSetup(
forPlay bool,
track *Track,
track Track,
baseURL *base.URL,
rtpPort int,
rtcpPort int) (*base.Response, error) {
@@ -1330,7 +1321,7 @@ func (c *Client) doSetup(
th.InterleavedIDs = &[2]int{(trackID * 2), (trackID * 2) + 1}
}
trackURL, err := track.URL(baseURL)
trackURL, err := track.url(baseURL)
if err != nil {
if proto == TransportUDP {
rtpListener.close()
@@ -1444,11 +1435,11 @@ func (c *Client) doSetup(
}
}
clockRate, _ := track.ClockRate()
cct := clientTrack{
track: track,
}
clockRate := track.ClockRate()
if mode == headers.TransportModePlay {
c.state = clientStatePrePlay
cct.rtcpReceiver = rtcpreceiver.New(nil, clockRate)
@@ -1555,7 +1546,7 @@ func (c *Client) doSetup(
// if rtpPort and rtcpPort are zero, they are chosen automatically.
func (c *Client) Setup(
forPlay bool,
track *Track,
track Track,
baseURL *base.URL,
rtpPort int,
rtcpPort int) (*base.Response, error) {