Changed to previous codec data configuration logic 80/106780/2
authorSejun Park <sejun79.park@samsung.com>
Fri, 23 Dec 2016 04:56:04 +0000 (13:56 +0900)
committerSejun Park <sejun79.park@samsung.com>
Fri, 23 Dec 2016 07:13:28 +0000 (16:13 +0900)
Change-Id: I3a7a249c2a6ace6ca9e77171221c6675cb03394a

src/media_codec_port_gst.c

index 5d0d5d6..3a87d42 100755 (executable)
@@ -782,26 +782,22 @@ int __mc_set_caps_codecdata(mc_gst_core_t *core, GstMCBuffer *buff, guint fixed_
                media_packet_get_buffer_size(buff->pkt, &buffer_size);
                media_packet_get_buffer_data_ptr(buff->pkt, &buff_data);
 
-               ret = __mc_get_codecdata_size(core, buff, &codec_data_size);
-               LOGD("First Frame contains codec_data_size= %d", codec_data_size);
-
-               if ((ret == MC_ERROR_NONE) && (codec_data_size > 0)) {
-                       data = g_malloc0(codec_data_size);
+               /* For audio, it's necessary to change the offset value of buffer after extracting csd */
+               /* it's not necessary to set csd to caps in case of annex-b */
+               if (buffer_size > fixed_size) {
+                       data = g_malloc0(fixed_size);
                        gst_buffer_map(buff->buffer, &map, GST_MAP_READ);
-                       memcpy(data, map.data, codec_data_size);
-                       codecdata_buffer = gst_buffer_new_wrapped(data, codec_data_size);
+                       memcpy(data, map.data, fixed_size);
+                       codecdata_buffer = gst_buffer_new_wrapped(data, fixed_size);
                        gst_buffer_unmap(buff->buffer, &map);
                        gst_caps_set_simple(core->caps, "codec_data", GST_TYPE_BUFFER, codecdata_buffer, NULL);
                        gst_buffer_unref(codecdata_buffer);
 
-                       GstMemory *memory = NULL;
-                       memory = gst_buffer_peek_memory(buff->buffer, 0);
-                       gst_memory_resize(memory, codec_data_size, buffer_size - codec_data_size);
-                       LOGD("First frame remained size : %d", gst_buffer_get_size(buff->buffer));
-               } else {
-                       if (ret != MC_ERROR_NONE) {
-                               LOGE("No valid codec data in the packet!");
-                       }
+                       gst_buffer_replace_memory(buff->buffer, 0,
+                                       gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, buff_data + fixed_size , buffer_size - fixed_size, 0,
+                                               buffer_size - fixed_size, buff, NULL));
+
+                       LOGD("set codec data from packet: %" G_GSIZE_FORMAT "",  gst_buffer_get_size(buff->buffer));
                }
        }
        return ret;