gst - correctly destroy unused pipelines.

This commit is contained in:
Miroslav Šedivý 2020-10-29 17:51:17 +01:00
parent 96e99955fc
commit cd769c05d3
4 changed files with 14 additions and 3 deletions

View File

@ -68,6 +68,11 @@ GstElement *gstreamer_send_create_pipeline(char *pipeline) {
return gst_parse_launch(pipeline, &error); return gst_parse_launch(pipeline, &error);
} }
void gstreamer_send_destroy_pipeline(GstElement *pipeline) {
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
}
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId) { void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId) {
SampleHandlerUserData *s = calloc(1, sizeof(SampleHandlerUserData)); SampleHandlerUserData *s = calloc(1, sizeof(SampleHandlerUserData));
s->pipelineId = pipelineId; s->pipelineId = pipelineId;

View File

@ -231,6 +231,11 @@ func CreatePipeline(pipelineStr string, codecName string, clockRate float32) (*P
return p, nil return p, nil
} }
// Destroy GStreamer Pipeline
func (p *Pipeline) DestroyPipeline() {
C.gstreamer_send_destroy_pipeline(p.Pipeline)
}
// Start starts the GStreamer Pipeline // Start starts the GStreamer Pipeline
func (p *Pipeline) Start() { func (p *Pipeline) Start() {
C.gstreamer_send_start_pipeline(p.Pipeline, C.int(p.id)) C.gstreamer_send_start_pipeline(p.Pipeline, C.int(p.id))

View File

@ -9,6 +9,7 @@
extern void goHandlePipelineBuffer(void *buffer, int bufferLen, int samples, int pipelineId); extern void goHandlePipelineBuffer(void *buffer, int bufferLen, int samples, int pipelineId);
GstElement *gstreamer_send_create_pipeline(char *pipeline); GstElement *gstreamer_send_create_pipeline(char *pipeline);
void gstreamer_send_destroy_pipeline(GstElement *pipeline);
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId); void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId);
void gstreamer_send_play_pipeline(GstElement *pipeline); void gstreamer_send_play_pipeline(GstElement *pipeline);

View File

@ -84,8 +84,8 @@ func (manager *RemoteManager) Start() {
func (manager *RemoteManager) Shutdown() error { func (manager *RemoteManager) Shutdown() error {
manager.logger.Info().Msgf("remote shutting down") manager.logger.Info().Msgf("remote shutting down")
manager.video.Stop() manager.video.DestroyPipeline()
manager.audio.Stop() manager.audio.DestroyPipeline()
manager.broadcast.Stop() manager.broadcast.Stop()
manager.cleanup.Stop() manager.cleanup.Stop()
@ -170,7 +170,7 @@ func (manager *RemoteManager) ChangeResolution(width int, height int, rate int)
return fmt.Errorf("unknown configuration") return fmt.Errorf("unknown configuration")
} }
manager.video.Stop() manager.video.DestroyPipeline()
manager.broadcast.Stop() manager.broadcast.Stop()
defer func() { defer func() {