Add sink_msg_callback function. 84/94284/1
authorSeokHoon Lee <andy.shlee@samsung.com>
Fri, 28 Oct 2016 04:23:58 +0000 (13:23 +0900)
committerSeokHoon Lee <andy.shlee@samsung.com>
Fri, 28 Oct 2016 04:24:24 +0000 (13:24 +0900)
[Version] 0.2.211
[Profile] Common
[Issue Type] Bug fix
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161027.1]

Change-Id: I5b82c4895465dde113a29b1a0b8f01414dc6e3cc
Signed-off-by: SeokHoon Lee <andy.shlee@samsung.com>
packaging/libmm-wfd.spec
src/mm_wfd_sink_priv.c

index f524151..ddaf038 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.2.210
+Version:    0.2.211
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 31e2426..e960c2a 100644 (file)
@@ -47,6 +47,7 @@ static int __mm_wfd_sink_destroy_audio_sinkbin(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_destroy_video_sinkbin(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink);
 static int __mm_wfd_sink_set_pipeline_state(mm_wfd_sink_t *wfd_sink, GstState state, gboolean async);
+static gboolean _mm_wfd_sink_msg_callback(GstBus *bus, GstMessage *msg, gpointer data);
 
 /* state */
 static int __mm_wfd_sink_set_state(mm_wfd_sink_t *wfd_sink, MMWFDSinkStateType state);
@@ -545,17 +546,26 @@ _mm_wfd_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data)
                break;
        case GST_MESSAGE_STATE_CHANGED:
                /* we only handle state change messages from pipeline */
-               if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
-                       ret = GST_BUS_DROP;
+               if (GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
+                       _mm_wfd_sink_msg_callback(bus, message, data);
+
+               ret = GST_BUS_DROP;
                break;
        case GST_MESSAGE_ASYNC_DONE:
-               if (!GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
-                       ret = GST_BUS_DROP;
+               if (GST_IS_PIPELINE(GST_MESSAGE_SRC(message)))
+                       _mm_wfd_sink_msg_callback(bus, message, data);
+
+               ret = GST_BUS_DROP;
                break;
        default:
                break;
        }
 
+       if (ret == GST_BUS_DROP) {
+               gst_message_unref(message);
+               message = NULL;
+       }
+
        return ret;
 }
 
@@ -2546,8 +2556,6 @@ __mm_wfd_sink_update_stream_info(GstElement *wfdsrc, GstStructure *str, gpointer
        MMWFDSinkStreamInfo *stream_info = NULL;
        gint is_valid_audio_format = FALSE;
        gint is_valid_video_format = FALSE;
-       gint audio_codec = MM_WFD_SINK_AUDIO_CODEC_NONE;
-       gint video_codec = MM_WFD_SINK_VIDEO_CODEC_NONE;
        gchar *audio_format;
        gchar *video_format;
 
@@ -2558,9 +2566,6 @@ __mm_wfd_sink_update_stream_info(GstElement *wfdsrc, GstStructure *str, gpointer
 
        stream_info = &wfd_sink->stream_info;
 
-       audio_codec = wfd_sink->stream_info.audio_stream_info.codec;
-       video_codec = wfd_sink->stream_info.video_stream_info.codec;
-
        if (gst_structure_has_field(str, "audio_format")) {
                is_valid_audio_format = TRUE;
                audio_format = g_strdup(gst_structure_get_string(str, "audio_format"));
@@ -2583,12 +2588,7 @@ __mm_wfd_sink_update_stream_info(GstElement *wfdsrc, GstStructure *str, gpointer
                        if (gst_structure_has_field(str, "audio_bitwidth"))
                                gst_structure_get_int(str, "audio_bitwidth", &stream_info->audio_stream_info.bitwidth);
 
-                       if (audio_codec != MM_WFD_SINK_AUDIO_CODEC_NONE) {
-                               if (audio_codec != stream_info->audio_stream_info.codec)
-                                       wfd_sink_debug("audio codec is changed...need to change audio decodebin");
-                       } else {
-                               WFD_SINK_MANAGER_APPEND_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_PREPARE_A_PIPELINE);
-                       }
+                       WFD_SINK_MANAGER_APPEND_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_PREPARE_A_PIPELINE);
 
                        wfd_sink_debug("audio_format : %s \n \t rate :  %d \n \t channels :  %d \n \t bitwidth :  %d \n \t      \n",
                                                        audio_format,
@@ -2618,12 +2618,7 @@ __mm_wfd_sink_update_stream_info(GstElement *wfdsrc, GstStructure *str, gpointer
                        if (gst_structure_has_field(str, "video_framerate"))
                                gst_structure_get_int(str, "video_framerate", &stream_info->video_stream_info.frame_rate);
 
-                       if (video_codec != MM_WFD_SINK_AUDIO_CODEC_NONE) {
-                               if (video_codec != stream_info->video_stream_info.codec)
-                                       wfd_sink_debug("video codec is changed...need to change video decodebin");
-                       } else {
-                               WFD_SINK_MANAGER_APPEND_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_PREPARE_V_PIPELINE);
-                       }
+                       WFD_SINK_MANAGER_APPEND_CMD(wfd_sink, WFD_SINK_MANAGER_CMD_PREPARE_V_PIPELINE);
 
                        wfd_sink_debug("video_format : %s \n \t width :  %d \n \t height :  %d \n \t frame_rate :  %d \n \t",
                                                        video_format,
@@ -2874,14 +2869,18 @@ static int __mm_wfd_sink_prepare_demux(mm_wfd_sink_t *wfd_sink, GstElement *demu
        return MM_ERROR_NONE;
 }
 
-static void __mm_wfd_sink_queue_overrun(GstElement *element, gpointer u_data)
+static void __mm_wfd_sink_queue_overrun(GstElement *queue, gpointer u_data)
 {
+       guint64 time = 0;
+
        wfd_sink_debug_fenter();
 
-       return_if_fail(element);
+       return_if_fail(queue);
+
+       g_object_get(G_OBJECT(queue), "current-level-time", &time, NULL);
 
-       wfd_sink_warning("%s is overrun",
-                                       GST_STR_NULL(GST_ELEMENT_NAME(element)));
+       wfd_sink_warning("%s is overrun(%" GST_TIME_FORMAT")",
+                                               GST_ELEMENT_NAME(queue), GST_TIME_ARGS(time));
 
        wfd_sink_debug_fleave();
 
@@ -3402,12 +3401,14 @@ int __mm_wfd_sink_create_audio_decodebin(mm_wfd_sink_t *wfd_sink)
        /* create queue */
        MMWFDSINK_CREATE_ELEMENT(a_decodebin, WFD_SINK_A_D_QUEUE, "queue", "audio_queue", FALSE);
        MMWFDSINK_PAD_PROBE(wfd_sink, NULL, a_decodebin[WFD_SINK_A_D_QUEUE].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, a_decodebin[WFD_SINK_A_D_QUEUE].gst,  "src");
        if (a_decodebin[WFD_SINK_A_D_QUEUE].gst)
                __mm_wfd_sink_prepare_queue(wfd_sink, a_decodebin[WFD_SINK_A_D_QUEUE].gst);
 
        /* create hdcp */
        MMWFDSINK_CREATE_ELEMENT(a_decodebin, WFD_SINK_A_D_HDCP, wfd_sink->ini.name_of_audio_hdcp, "audio_hdcp", FALSE);
        MMWFDSINK_PAD_PROBE(wfd_sink, NULL, a_decodebin[WFD_SINK_A_D_HDCP].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, a_decodebin[WFD_SINK_A_D_HDCP].gst,  "src");
 
        /* create codec */
        audio_codec = wfd_sink->ini.wfd_audio_codecs.audio_codec;
@@ -4185,6 +4186,7 @@ int __mm_wfd_sink_create_video_decodebin(mm_wfd_sink_t *wfd_sink)
        /* create queue */
        MMWFDSINK_CREATE_ELEMENT(v_decodebin, WFD_SINK_V_D_QUEUE, "queue", "video_queue", FALSE);
        MMWFDSINK_PAD_PROBE(wfd_sink, NULL, v_decodebin[WFD_SINK_V_D_QUEUE].gst,  "sink");
+       MMWFDSINK_PAD_PROBE(wfd_sink, NULL, v_decodebin[WFD_SINK_V_D_QUEUE].gst,  "src");
        if (v_decodebin[WFD_SINK_V_D_QUEUE].gst)
                __mm_wfd_sink_prepare_queue(wfd_sink, v_decodebin[WFD_SINK_V_D_QUEUE].gst);
 
@@ -4525,6 +4527,7 @@ CREATE_ERROR:
 static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink)
 {
        GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+       GstBus *bus = NULL;
 
        wfd_sink_debug_fenter();
 
@@ -4535,6 +4538,9 @@ static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink)
                MMWFDSinkGstElement *mainbin = wfd_sink->pipeline->mainbin;
 
                if (mainbin) {
+
+                       PRINT_WFD_REF_COUNT(wfd_sink);
+
                        ret = gst_element_set_state(mainbin[WFD_SINK_M_PIPE].gst, GST_STATE_NULL);
                        if (ret != GST_STATE_CHANGE_SUCCESS) {
                                wfd_sink_error("failed to change state of pipeline to NULL");
@@ -4543,6 +4549,20 @@ static int __mm_wfd_sink_destroy_pipeline(mm_wfd_sink_t *wfd_sink)
                                wfd_sink_debug("Successed to change state of pipeline to NULL");
                        }
 
+                       bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[WFD_SINK_M_PIPE].gst));
+                       if (bus) {
+                               GstMessage *gst_msg = NULL;
+                               while ((gst_msg = gst_bus_pop(bus)) != NULL) {
+                                       _mm_wfd_sink_msg_callback(bus, gst_msg, (gpointer)wfd_sink);
+                                       gst_message_unref(gst_msg);
+                                       gst_msg = NULL;
+                               }
+                               gst_object_unref(bus);
+                               bus = NULL;
+                       }
+
+                       PRINT_WFD_REF_COUNT(wfd_sink);
+
                        if (MM_ERROR_NONE != __mm_wfd_sink_destroy_video_decodebin(wfd_sink)) {
                                wfd_sink_error("failed to destroy video decodebin");
                                return MM_ERROR_WFD_INTERNAL;