[C-API] check gstreamer initialization status in ml_single_open() accepted/tizen/unified/20190723.112130 submit/tizen/20190722.095424
authorSangjung Woo <sangjung.woo@samsung.com>
Fri, 19 Jul 2019 09:45:14 +0000 (18:45 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 22 Jul 2019 09:15:11 +0000 (18:15 +0900)
Before calling gstreamer function, this patch checks its initialization
status by calling gst_init_check() in ml_single_open().

Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
api/capi/src/nnstreamer-capi-single.c

index aeed7a6..0553f0e 100644 (file)
@@ -57,6 +57,7 @@ ml_single_open (ml_single_h * single, const char *model,
   ml_pipeline *pipe_h;
   GstElement *appsrc, *appsink, *filter;
   GstCaps *caps;
+  GError *err = NULL;
   int status = ML_ERROR_NONE;
   gchar *pipeline_desc = NULL;
   gchar *path_down;
@@ -73,6 +74,16 @@ ml_single_open (ml_single_h * single, const char *model,
   /* init null */
   *single = NULL;
 
+  if (FALSE == gst_init_check (NULL, NULL, &err)) {
+    if (err) {
+      ml_loge ("GStreamer has the following error: %s", err->message);
+      g_error_free (err);
+    } else {
+      ml_loge ("Cannot initialize GStreamer. Unknown reason.");
+    }
+    return ML_ERROR_STREAMS_PIPE;
+  }
+
   in_tensors_info = (ml_tensors_info_s *) input_info;
   out_tensors_info = (ml_tensors_info_s *) output_info;