track: expose Set/GetControl

This is useful for clients that need to override the control field, which was
possible prior to 6d5bf0c1bb via the Media field.
This commit is contained in:
Tristan Matthews
2022-02-11 13:56:26 -05:00
committed by Alessandro Ros
parent 247571eec8
commit 1b2a78a744
7 changed files with 24 additions and 14 deletions

View File

@@ -28,7 +28,7 @@ func invalidURLAnnounceReq(t *testing.T, control string) base.Request {
Body: func() []byte { Body: func() []byte {
track, err := NewTrackH264(96, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, nil) track, err := NewTrackH264(96, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, nil)
require.NoError(t, err) require.NoError(t, err)
track.setControl(control) track.SetControl(control)
sout := &psdp.SessionDescription{ sout := &psdp.SessionDescription{
SessionName: psdp.SessionName("Stream"), SessionName: psdp.SessionName("Stream"),
@@ -260,7 +260,7 @@ func TestServerPublishSetupPath(t *testing.T) {
track, err := NewTrackH264(96, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, nil) track, err := NewTrackH264(96, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, nil)
require.NoError(t, err) require.NoError(t, err)
track.setControl(ca.control) track.SetControl(ca.control)
sout := &psdp.SessionDescription{ sout := &psdp.SessionDescription{
SessionName: psdp.SessionName("Stream"), SessionName: psdp.SessionName("Stream"),

View File

@@ -15,8 +15,10 @@ type Track interface {
// ClockRate returns the track clock rate. // ClockRate returns the track clock rate.
ClockRate() int ClockRate() int
clone() Track clone() Track
getControl() string // GetControl returns the track control
setControl(string) GetControl() string
// SetControl returns the track control
SetControl(string)
url(*base.URL) (*base.URL, error) url(*base.URL) (*base.URL, error)
// MediaDescription returns structured SDP media information // MediaDescription returns structured SDP media information
MediaDescription() *psdp.MediaDescription MediaDescription() *psdp.MediaDescription
@@ -76,7 +78,7 @@ func trackURL(t Track, contentBase *base.URL) (*base.URL, error) {
return nil, fmt.Errorf("no Content-Base header provided") return nil, fmt.Errorf("no Content-Base header provided")
} }
control := t.getControl() control := t.GetControl()
// no control attribute, use base URL // no control attribute, use base URL
if control == "" { if control == "" {

View File

@@ -138,11 +138,13 @@ func (t *TrackAAC) clone() Track {
} }
} }
func (t *TrackAAC) getControl() string { // GetControl gets the track control.
func (t *TrackAAC) GetControl() string {
return t.control return t.control
} }
func (t *TrackAAC) setControl(c string) { // SetControl sets the track control.
func (t *TrackAAC) SetControl(c string) {
t.control = c t.control = c
} }

View File

@@ -139,11 +139,13 @@ func (t *TrackGeneric) clone() Track {
} }
} }
func (t *TrackGeneric) getControl() string { // GetControl returns the track control.
func (t *TrackGeneric) GetControl() string {
return t.control return t.control
} }
func (t *TrackGeneric) setControl(c string) { // SetControl set the track control.
func (t *TrackGeneric) SetControl(c string) {
t.control = c t.control = c
} }

View File

@@ -111,11 +111,13 @@ func (t *TrackH264) clone() Track {
} }
} }
func (t *TrackH264) getControl() string { // GetControl gets the track control.
func (t *TrackH264) GetControl() string {
return t.control return t.control
} }
func (t *TrackH264) setControl(c string) { // SetControl sets the track control.
func (t *TrackH264) SetControl(c string) {
t.control = c t.control = c
} }

View File

@@ -69,11 +69,13 @@ func (t *TrackOpus) clone() Track {
} }
} }
func (t *TrackOpus) getControl() string { // GetControl returns the track control.
func (t *TrackOpus) GetControl() string {
return t.control return t.control
} }
func (t *TrackOpus) setControl(c string) { // SetControl sets the track control.
func (t *TrackOpus) SetControl(c string) {
t.control = c t.control = c
} }

View File

@@ -44,7 +44,7 @@ func (ts Tracks) clone() Tracks {
func (ts Tracks) setControls() { func (ts Tracks) setControls() {
for i, t := range ts { for i, t := range ts {
t.setControl("trackID=" + strconv.FormatInt(int64(i), 10)) t.SetControl("trackID=" + strconv.FormatInt(int64(i), 10))
} }
} }