Change the way to check mediademuxer prepared 41/136441/1 accepted/tizen/unified/20170717.170743 submit/tizen/20170717.022349
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 29 Jun 2017 11:36:25 +0000 (20:36 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 29 Jun 2017 11:36:25 +0000 (20:36 +0900)
[Version] 0.1.20
[Profile] Mobile, Wearable, TV
[Issue Type] Fix bugs

Change-Id: I8238a4d19cf4a9b6fa49660e405b617875ecfc92

packaging/capi-mediademuxer.spec
src/port_gst/mediademuxer_port_gst.c

index 1bafe37..add2edf 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-mediademuxer
 Summary:    A Media Demuxer library in Tizen Native API
-Version:    0.1.19
+Version:    0.1.20
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
index 61be3e3..4538aa4 100755 (executable)
@@ -881,6 +881,9 @@ static int _gst_create_pipeline(mdgst_handle_t *gst_handle, char *uri)
 #ifdef TIZEN_FEATURE_STREAMING
        int remote_streaming = 0;
 #endif
+       GstState element_state = GST_STATE_VOID_PENDING;
+       GstState element_pending_state = GST_STATE_VOID_PENDING;
+
        /* Initialize GStreamer */
        /* Note: Replace the arguments of gst_init to pass the command line args to GStreamer. */
        gst_init(NULL, NULL);
@@ -955,16 +958,20 @@ static int _gst_create_pipeline(mdgst_handle_t *gst_handle, char *uri)
        /* set pipeline state to PAUSED */
        MEDIADEMUXER_SET_STATE(gst_handle->pipeline, GST_STATE_PAUSED, ERROR);
 
-       int count = 0;
-       while (gst_handle->is_prepared != true) {
-               count++;
-               usleep(POLLING_INTERVAL);
-               MD_I("Inside while loop\n");
-               if (count > POLLING_INTERVAL) {
-                       MD_E("Error occure\n");
-                       ret = MD_ERROR;
-                       break;
-               }
+       if (gst_element_get_state(gst_handle->pipeline, &element_state, &element_pending_state, 1 * GST_SECOND)
+               == GST_STATE_CHANGE_FAILURE) {
+               MD_E(" [%s] state : %s   pending : %s \n",
+                       GST_ELEMENT_NAME(gst_handle->pipeline),
+                       gst_element_state_get_name(element_state),
+                       gst_element_state_get_name(element_pending_state));
+               ret = MD_ERROR;
+               goto ERROR;
+       }
+
+       if (gst_handle->is_prepared != true) {
+               MD_E("Error occure");
+               ret = MD_ERROR;
+               goto ERROR;
        }
 
        MEDIADEMUXER_FLEAVE();