client: do not override media controls inside Announce()

this fixes the client-read-republish example and allows users to set
their own media controls.

Function medias.SetControls() is provided in order to automatically set
media controls and must be called manually.
This commit is contained in:
aler9
2022-12-22 18:53:24 +01:00
parent ffe8c87c38
commit cabfcd627b
13 changed files with 81 additions and 63 deletions

View File

@@ -36,20 +36,20 @@ func main() {
log.Println("stream connected")
// create a media that contains a Opus format
medi := &media.Media{
medias := media.Medias{&media.Media{
Type: media.TypeAudio,
Formats: []format.Format{&format.Opus{
PayloadTyp: 96,
SampleRate: 48000,
ChannelCount: 2,
}},
}
}}
medias.SetControls()
c := gortsplib.Client{}
// connect to the server and start recording the media
err = c.StartRecording("rtsp://localhost:8554/mystream",
media.Medias{medi})
err = c.StartRecording("rtsp://localhost:8554/mystream", medias)
if err != nil {
panic(err)
}
@@ -64,7 +64,7 @@ func main() {
}
// route RTP packet to the server
err = c.WritePacketRTP(medi, &pkt)
err = c.WritePacketRTP(medias[0], &pkt)
if err != nil {
panic(err)
}