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;