catch gstreamer errors.

This commit is contained in:
Miroslav Šedivý 2021-01-12 16:12:05 +01:00
parent 49c3b6d4fe
commit f32ebe7935
3 changed files with 11 additions and 8 deletions

View File

@ -61,11 +61,6 @@ 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);
}
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId) {
SampleHandlerUserData *s = calloc(1, sizeof(SampleHandlerUserData));
s->pipelineId = pipelineId;

View File

@ -197,8 +197,18 @@ func CreatePipeline(pipelineStr string, codecName string, clockRate float32) (*P
pipelinesLock.Lock()
defer pipelinesLock.Unlock()
var gstPipeline *C.GstElement
var gstError *C.GError
gstPipeline = C.gst_parse_launch(pipelineStrUnsafe, &gstError)
defer C.g_error_free(gstError)
if gstPipeline == nil || gstError != nil {
return nil, fmt.Errorf("(pipeline error) %s", C.GoString(gstError.message))
}
p := &Pipeline{
Pipeline: C.gstreamer_send_create_pipeline(pipelineStrUnsafe),
Pipeline: gstPipeline,
Sample: make(chan types.Sample),
CodecName: codecName,
ClockRate: clockRate,

View File

@ -5,8 +5,6 @@
extern void goHandlePipelineBuffer(void *buffer, int bufferLen, int samples, int pipelineId);
GstElement *gstreamer_send_create_pipeline(char *pipeline);
void gstreamer_send_start_pipeline(GstElement *pipeline, int pipelineId);
void gstreamer_send_play_pipeline(GstElement *pipeline);
void gstreamer_send_stop_pipeline(GstElement *pipeline);