Change fuction set_state to set_state_with_parent in have-type callback 06/143006/3 accepted/tizen_3.0_ivi accepted/tizen/3.0/common/20170810.115027 accepted/tizen/3.0/ivi/20170809.222459 accepted/tizen/3.0/mobile/20170809.222451 accepted/tizen/3.0/tv/20170809.222447 accepted/tizen/3.0/wearable/20170809.222455 submit/tizen_3.0/20170808.102955
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 8 Aug 2017 06:11:27 +0000 (15:11 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 8 Aug 2017 07:35:35 +0000 (16:35 +0900)
sometimes state hang during demux state shange

[Version] 0.1.22
[Profile] Mobile, Wearable, TV
[Issue Type] Fix bugs

Change-Id: Ib5256c4d381dac72c34b1bba33ff02f7ced05941

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

index 9737be4..c784b81 100755 (executable)
@@ -42,6 +42,15 @@ extern "C" {
                } \
        } while (0)
 
+#define MEDIADEMUXER_SYNC_STATE_WITH_PARENT(x_element, error) \
+       do { \
+               MD_I("Sync state with parent [%s]\n", GST_ELEMENT_NAME(x_element)); \
+               if (GST_STATE_CHANGE_FAILURE == gst_element_sync_state_with_parent(x_element)) { \
+                       MD_E("failed to sync %s state with parent\n", GST_ELEMENT_NAME(x_element)); \
+                       goto error; \
+               } \
+       } while (0)
+
 #define MEDIADEMUXER_LINK_PAD(srcpad, sinkpad, error) \
        do { \
                if (GST_PAD_LINK_OK != gst_pad_link(srcpad, sinkpad)) { \
index 2912044..13e07f2 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-mediademuxer
 Summary:    A Media Demuxer library in Tizen Native API
-Version:    0.1.20
+Version:    0.1.22
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
index 4538aa4..3cc57aa 100755 (executable)
@@ -451,8 +451,8 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
                goto ERROR;
        }
 
-       MEDIADEMUXER_SET_STATE(temp->queue, GST_STATE_PAUSED, ERROR);
        MEDIADEMUXER_LINK_PAD(pad, queue_sink_pad, ERROR);
+       MEDIADEMUXER_SYNC_STATE_WITH_PARENT(temp->queue, ERROR);
 
        temp->appsink = gst_element_factory_make("appsink", NULL);
        if (!temp->appsink) {
@@ -470,7 +470,6 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
 
        gst_app_sink_set_max_buffers((GstAppSink *) temp->appsink, (guint) 0);
        gst_app_sink_set_drop((GstAppSink *) temp->appsink, true);
-       MEDIADEMUXER_SET_STATE(temp->appsink, GST_STATE_PAUSED, ERROR);
 
        queue_src_pad = gst_element_get_static_pad(temp->queue, "src");
        if (!queue_src_pad) {
@@ -511,10 +510,11 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
                                MD_E("sink pad of video parse(%s) not available", GST_ELEMENT_NAME(parse_element));
                                goto ERROR;
                        }
-                       MEDIADEMUXER_SET_STATE(parse_element, GST_STATE_PAUSED, ERROR);
                        /* Link demuxer pad with sink pad of parse element */
                        MEDIADEMUXER_LINK_PAD(queue_src_pad, parse_sink_pad, ERROR);
 
+                       MEDIADEMUXER_SYNC_STATE_WITH_PARENT(parse_element, ERROR);
+
                        if (strstr(temp->caps_string, "h264")) {
                                outcaps = gst_caps_new_simple("video/x-h264", "stream-format", G_TYPE_STRING, "byte-stream", NULL);
                                gst_element_link_filtered(parse_element, temp->appsink, outcaps);
@@ -564,7 +564,7 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
                                goto ERROR;
                        }
                        MEDIADEMUXER_LINK_PAD(queue_src_pad, id3_sinkpad, ERROR);
-                       MEDIADEMUXER_SET_STATE(id3tag, GST_STATE_PAUSED, ERROR);
+                       MEDIADEMUXER_SYNC_STATE_WITH_PARENT(id3tag, ERROR);
                        id3_srcpad = gst_element_get_static_pad(id3tag, "src");
                        if (!id3_srcpad) {
                                MD_E("fail to get id3demux src pad.\n");
@@ -608,7 +608,6 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
                                MD_E("sink pad of audio parse(%s) not available", GST_ELEMENT_NAME(parse_element));
                                goto ERROR;
                        }
-                       MEDIADEMUXER_SET_STATE(parse_element, GST_STATE_PAUSED, ERROR);
 
                        /* Link demuxer pad with sink pad of parse element */
                        if (id3tag)
@@ -616,6 +615,8 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
                        else
                                MEDIADEMUXER_LINK_PAD(queue_src_pad, parse_sink_pad, ERROR);
 
+                       MEDIADEMUXER_SYNC_STATE_WITH_PARENT(parse_element, ERROR);
+
                        /* Link src pad with appSink element */
                        gst_element_link(parse_element, temp->appsink);
                } else {
@@ -624,6 +625,8 @@ int __gst_add_track_info(GstPad *pad, GstCaps *caps, track **head,
        } else {
                MEDIADEMUXER_LINK_PAD(queue_src_pad, apppad, ERROR);
        }
+
+       MEDIADEMUXER_SYNC_STATE_WITH_PARENT(temp->appsink, ERROR);
        /* gst_pad_link(pad, fpad) */
        if (*head == NULL) {
                *head = temp;
@@ -797,8 +800,13 @@ static void __gst_cb_typefind(GstElement *tf, guint probability,
                                                                G_CALLBACK(__gst_on_pad_added), gst_handle);
                                g_signal_connect(gst_handle->demux, "no-more-pads",
                                                                G_CALLBACK(__gst_no_more_pad), gst_handle);
-                               gst_bin_add_many(GST_BIN(gst_handle->pipeline),
-                                                               gst_handle->demux, NULL);
+                               if (!gst_bin_add(GST_BIN(gst_handle->pipeline), gst_handle->demux)) {
+                                       gst_object_unref(gst_handle->demux);
+                                       MD_E("fail add demuxer(%s) in pipeline",
+                                               GST_ELEMENT_NAME(gst_handle->demux));
+                                       goto ERROR;
+                               }
+
                                pad = gst_element_get_static_pad(gst_handle->typefind, "src");
                                if (!pad) {
                                        MD_E("fail to get typefind src pad.\n");
@@ -816,8 +824,8 @@ static void __gst_cb_typefind(GstElement *tf, guint probability,
                                }
                                gst_pad_unlink(pad, fake_pad);
                                MEDIADEMUXER_LINK_PAD(pad, demuxer_pad, ERROR);
-                               MEDIADEMUXER_SET_STATE(gst_handle->demux,
-                                                                       GST_STATE_PAUSED, ERROR);
+
+                               MEDIADEMUXER_SYNC_STATE_WITH_PARENT(gst_handle->demux, ERROR);
                                if (pad)
                                        gst_object_unref(pad);
                                if (demuxer_pad)