catch errors from gst pipeline.

This commit is contained in:
Miroslav Šedivý
2021-08-15 15:37:27 +02:00
parent 6708ce2caf
commit 9e466b08cc
7 changed files with 47 additions and 19 deletions

View File

@ -63,9 +63,8 @@ GstFlowReturn gstreamer_send_new_sample_handler(GstElement *object, gpointer use
return GST_FLOW_OK;
}
GstElement *gstreamer_send_create_pipeline(char *pipeline) {
GError *error = NULL;
return gst_parse_launch(pipeline, &error);
GstElement *gstreamer_send_create_pipeline(char *pipeline, GError **error) {
return gst_parse_launch(pipeline, error);
}
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId) {

View File

@ -208,8 +208,15 @@ func CreatePipeline(pipelineStr string) (*Pipeline, error) {
pipelinesLock.Lock()
defer pipelinesLock.Unlock()
var err *C.GError
gstPipeline := C.gstreamer_send_create_pipeline(pipelineStrUnsafe, &err)
if err != nil {
defer C.g_error_free(err)
return nil, fmt.Errorf("%s", C.GoString(err.message))
}
p := &Pipeline{
Pipeline: C.gstreamer_send_create_pipeline(pipelineStrUnsafe),
Pipeline: gstPipeline,
Sample: make(chan types.Sample),
Src: pipelineStr,
id: len(pipelines),

View File

@ -8,7 +8,7 @@
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, GError **error);
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId);
void gstreamer_send_play_pipeline(GstElement *pipeline);