mirror of
https://github.com/pion/webrtc.git
synced 2025-11-02 19:44:01 +08:00
@@ -22,11 +22,8 @@ func init() {
|
||||
|
||||
// Pipeline is a wrapper for a GStreamer Pipeline
|
||||
type Pipeline struct {
|
||||
Pipeline *C.GstElement
|
||||
track *webrtc.Track
|
||||
// stop acts as a signal that this pipeline is stopped
|
||||
// any pending sends to Pipeline.in should be cancelled
|
||||
stop chan interface{}
|
||||
Pipeline *C.GstElement
|
||||
track *webrtc.Track
|
||||
id int
|
||||
codecName string
|
||||
}
|
||||
@@ -71,17 +68,11 @@ func CreatePipeline(codecName string, track *webrtc.Track, pipelineSrc string) *
|
||||
|
||||
// Start starts the GStreamer Pipeline
|
||||
func (p *Pipeline) Start() {
|
||||
// This will signal to goHandlePipelineBuffer
|
||||
// and provide a method for cancelling sends.
|
||||
p.stop = make(chan interface{})
|
||||
C.gstreamer_send_start_pipeline(p.Pipeline, C.int(p.id))
|
||||
}
|
||||
|
||||
// Stop stops the GStreamer Pipeline
|
||||
func (p *Pipeline) Stop() {
|
||||
// To run gstreamer_send_stop_pipeline we need to make sure
|
||||
// that appsink isn't being hung by any goHandlePipelineBuffers
|
||||
close(p.stop)
|
||||
C.gstreamer_send_stop_pipeline(p.Pipeline)
|
||||
}
|
||||
|
||||
@@ -103,8 +94,6 @@ func goHandlePipelineBuffer(buffer unsafe.Pointer, bufferLen C.int, duration C.i
|
||||
} else {
|
||||
samples = uint32(videoClockRate * (float32(duration) / 1000000000))
|
||||
}
|
||||
// We need to be able to cancel this function even f pipeline.in isn't being serviced
|
||||
// When pipeline.stop is closed the sending of data will be cancelled.
|
||||
if err := pipeline.track.WriteSample(media.Sample{Data: C.GoBytes(buffer, bufferLen), Samples: samples}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user