Fixed a problem when packet with codec config flag queued 50/175050/1 accepted/tizen/unified/20180410.063543 submit/tizen/20180406.080421
authorSejun Park <sejun79.park@samsung.com>
Fri, 6 Apr 2018 07:21:32 +0000 (16:21 +0900)
committerSejun Park <sejun79.park@samsung.com>
Fri, 6 Apr 2018 07:29:51 +0000 (16:29 +0900)
Change-Id: I1051324d90fc2ba1125b51b706f2ab25a37e82c8

packaging/capi-media-codec.spec
src/media_codec_port_gst.c

index 0d2a3bb..88d1a85 100755 (executable)
@@ -4,7 +4,7 @@
 
 Name:       capi-media-codec
 Summary:    A Media Codec library in Tizen Native API
-Version:    0.5.10
+Version:    0.5.11
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 753b309..a9ea98a 100755 (executable)
@@ -80,7 +80,7 @@ static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest,
 static void _mc_send_eos_signal(mc_gst_core_t *core);
 static void _mc_wait_for_eos(mc_gst_core_t *core);
 static int _mc_get_mime(mc_gst_core_t *core);
-static int _mc_set_codec_data(mc_gst_core_t *core, GstMCBuffer *mcbuffer);
+static int _mc_set_codec_data(mc_gst_core_t *core, GstMCBuffer *mcbuffer, bool codec_config);
 GstCaps *_mc_gst_vid_caps_new(mc_gst_core_t *core, mediacodec_codec_type_e codec_id, gint index);
 GstCaps *_mc_gst_aud_caps_new(mc_gst_core_t *core, mediacodec_codec_type_e codec_id, gint index);
 
@@ -1129,7 +1129,7 @@ gboolean _mc_update_packet_info(mc_gst_core_t *core, media_format_h format)
        return is_format_change;
 }
 
-static int _mc_set_codec_data(mc_gst_core_t *core, GstMCBuffer *mcbuffer)
+static int _mc_set_codec_data(mc_gst_core_t *core, GstMCBuffer *mcbuffer, bool codec_config)
 {
        MEDIACODEC_FENTER();
 
@@ -1142,23 +1142,29 @@ static int _mc_set_codec_data(mc_gst_core_t *core, GstMCBuffer *mcbuffer)
        case MEDIACODEC_AAC:
        case MEDIACODEC_AAC_HE:
        case MEDIACODEC_AAC_HE_PS:
-               ret = __mc_set_caps_codecdata(core, mcbuffer, AAC_CODECDATA_SIZE);
-               if (ret != MC_ERROR_NONE)
-                       LOGW("__mc_set_caps_codecdata failed");
+               if (codec_config) {
+                       ret = __mc_set_caps_codecdata(core, mcbuffer, AAC_CODECDATA_SIZE);
+                       if (ret != MC_ERROR_NONE)
+                               LOGW("__mc_set_caps_codecdata failed");
+               }
                break;
        case MEDIACODEC_WMAV1:
        case MEDIACODEC_WMAV2:
        case MEDIACODEC_WMAPRO:
        case MEDIACODEC_WMALSL:
-               ret = __mc_set_caps_codecdata(core, mcbuffer, WMA_CODECDATA_SIZE);
-               if (ret != MC_ERROR_NONE)
-                       LOGW("__mc_set_caps_codecdata failed");
+               if (codec_config) {
+                       ret = __mc_set_caps_codecdata(core, mcbuffer, WMA_CODECDATA_SIZE);
+                       if (ret != MC_ERROR_NONE)
+                               LOGW("__mc_set_caps_codecdata failed");
+               }
                break;
        case MEDIACODEC_VORBIS:
        case MEDIACODEC_FLAC:
-               ret = __mc_set_caps_streamheader(core, mcbuffer, VORBIS_CODECDATA_SIZE);
-               if (ret != MC_ERROR_NONE)
-                       LOGW("__mc_set_caps_streamheader failed");
+               if (codec_config) {
+                       ret = __mc_set_caps_streamheader(core, mcbuffer, VORBIS_CODECDATA_SIZE);
+                       if (ret != MC_ERROR_NONE)
+                               LOGW("__mc_set_caps_streamheader failed");
+               }
                break;
        case MEDIACODEC_H264:
        case MEDIACODEC_MPEG4:
@@ -1237,12 +1243,14 @@ static gpointer feed_task(gpointer data)
                input_buffer = NULL;
 
                if (codec_config || initiative) {
-                       GstPad *pad;
-                       ret = _mc_set_codec_data(core, mcbuffer);
-                       if (ret != MC_ERROR_NONE) {
-                               LOGE("failed to set codec data");
-                               gst_buffer_unref(mcbuffer->buffer);
-                               goto ERROR;
+                       GstPad *pad = NULL;
+                       if (!core->encoder) {
+                               ret = _mc_set_codec_data(core, mcbuffer, codec_config);
+                               if (ret != MC_ERROR_NONE) {
+                                       LOGE("failed to set codec data");
+                                       gst_buffer_unref(mcbuffer->buffer);
+                                       goto ERROR;
+                               }
                        }
                        pad = gst_element_get_static_pad(core->appsrc, "src");
                        gst_pad_push_event(pad, gst_event_new_stream_start("start"));
@@ -1257,6 +1265,7 @@ static gpointer feed_task(gpointer data)
                        g_object_set(core->appsrc, "caps", caps, NULL);
                        gst_caps_unref(caps);
                        LOGD("caps updated");
+                       is_format_change = FALSE;
                }
 
 
@@ -1747,6 +1756,7 @@ mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle)
        /* set caps in capsfilter as default*/
        caps = new_core->mc_caps_new(new_core, id, out_port_index);
 
+       new_core->caps = caps;
        /* FIXME will parse input format from ini. format is needed when linking elements*/
        if (new_core->video && new_core->encoder) {
                gchar *format = NULL;