mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
allow setting additional properties of streams through description.Stream
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/bluenviron/gortsplib/v4"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/media"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/url"
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
@@ -31,31 +31,31 @@ func main() {
|
||||
defer reader.Close()
|
||||
|
||||
// find published medias
|
||||
medias, baseURL, _, err := reader.Describe(sourceURL)
|
||||
desc, _, err := reader.Describe(sourceURL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
log.Printf("republishing %d medias", len(medias))
|
||||
log.Printf("republishing %d medias", len(desc.Medias))
|
||||
|
||||
// setup all medias
|
||||
// this must be called before StartRecording(), since it overrides the control attribute.
|
||||
err = reader.SetupAll(baseURL, medias)
|
||||
err = reader.SetupAll(desc.BaseURL, desc.Medias)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// connect to the server and start recording the same medias
|
||||
publisher := gortsplib.Client{}
|
||||
err = publisher.StartRecording("rtsp://localhost:8554/mystream2", medias)
|
||||
err = publisher.StartRecording("rtsp://localhost:8554/mystream2", desc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer publisher.Close()
|
||||
|
||||
// read RTP packets from the reader and route them to the publisher
|
||||
reader.OnPacketRTPAny(func(medi *media.Media, forma format.Format, pkt *rtp.Packet) {
|
||||
publisher.WritePacketRTP(medi, pkt)
|
||||
reader.OnPacketRTPAny(func(medi *description.Media, forma format.Format, pkt *rtp.Packet) {
|
||||
publisher.WritePacketRTP(desc.Medias[0], pkt)
|
||||
})
|
||||
|
||||
// start playing
|
||||
|
Reference in New Issue
Block a user