diff --git a/examples/gstreamer-send-offer/main.go b/examples/gstreamer-send-offer/main.go index ddc022e02a6..cbda482b7ca 100644 --- a/examples/gstreamer-send-offer/main.go +++ b/examples/gstreamer-send-offer/main.go @@ -85,8 +85,8 @@ func main() { } // Start pushing buffers on these tracks - gst.CreatePipeline(webrtc.Opus, opusTrack, *audioSrc).Start() - gst.CreatePipeline(webrtc.VP8, vp8Track, *videoSrc).Start() + gst.CreatePipeline(webrtc.Opus, []*webrtc.Track{opusTrack}, *audioSrc).Start() + gst.CreatePipeline(webrtc.VP8, []*webrtc.Track{vp8Track}, *videoSrc).Start() // Block forever select {} diff --git a/examples/gstreamer-send/main.go b/examples/gstreamer-send/main.go index 4218f242389..8cd760ab157 100644 --- a/examples/gstreamer-send/main.go +++ b/examples/gstreamer-send/main.go @@ -85,8 +85,8 @@ func main() { fmt.Println(signal.Encode(answer)) // Start pushing buffers on these tracks - gst.CreatePipeline(webrtc.Opus, opusTrack, *audioSrc).Start() - gst.CreatePipeline(webrtc.VP8, vp8Track, *videoSrc).Start() + gst.CreatePipeline(webrtc.Opus, []*webrtc.Track{opusTrack}, *audioSrc).Start() + gst.CreatePipeline(webrtc.VP8, []*webrtc.Track{vp8Track}, *videoSrc).Start() // Block forever select {} diff --git a/examples/internal/gstreamer-src/gst.go b/examples/internal/gstreamer-src/gst.go index 62db8283141..ed45044f278 100644 --- a/examples/internal/gstreamer-src/gst.go +++ b/examples/internal/gstreamer-src/gst.go @@ -23,7 +23,7 @@ func init() { // Pipeline is a wrapper for a GStreamer Pipeline type Pipeline struct { Pipeline *C.GstElement - track *webrtc.Track + tracks []*webrtc.Track id int codecName string } @@ -32,7 +32,7 @@ var pipelines = make(map[int]*Pipeline) var pipelinesLock sync.Mutex // CreatePipeline creates a GStreamer Pipeline -func CreatePipeline(codecName string, track *webrtc.Track, pipelineSrc string) *Pipeline { +func CreatePipeline(codecName string, tracks []*webrtc.Track, pipelineSrc string) *Pipeline { pipelineStr := "appsink name=appsink" switch codecName { case webrtc.VP8: @@ -57,7 +57,7 @@ func CreatePipeline(codecName string, track *webrtc.Track, pipelineSrc string) * pipeline := &Pipeline{ Pipeline: C.gstreamer_send_create_pipeline(pipelineStrUnsafe), - track: track, + tracks: tracks, id: len(pipelines), codecName: codecName, } @@ -94,8 +94,10 @@ func goHandlePipelineBuffer(buffer unsafe.Pointer, bufferLen C.int, duration C.i } else { samples = uint32(videoClockRate * (float32(duration) / 1000000000)) } - if err := pipeline.track.WriteSample(media.Sample{Data: C.GoBytes(buffer, bufferLen), Samples: samples}); err != nil { - panic(err) + for _, t := range pipeline.tracks { + if err := t.WriteSample(media.Sample{Data: C.GoBytes(buffer, bufferLen), Samples: samples}); err != nil { + panic(err) + } } } else { fmt.Printf("discarding buffer, no pipeline with id %d", int(pipelineID)) diff --git a/examples/janus-gateway/video-room/main.go b/examples/janus-gateway/video-room/main.go index 912c34ccb22..c108b00d86c 100644 --- a/examples/janus-gateway/video-room/main.go +++ b/examples/janus-gateway/video-room/main.go @@ -146,8 +146,8 @@ func main() { } // Start pushing buffers on these tracks - gst.CreatePipeline(webrtc.Opus, opusTrack, "audiotestsrc").Start() - gst.CreatePipeline(webrtc.VP8, vp8Track, "videotestsrc").Start() + gst.CreatePipeline(webrtc.Opus, []*webrtc.Track{opusTrack}, "audiotestsrc").Start() + gst.CreatePipeline(webrtc.VP8, []*webrtc.Track{vp8Track}, "videotestsrc").Start() } select {}