/* NOTE : static internal functions does not check anything on incomming parameters
* Caller should takecare it
*/
+static int __pkt_init(media_buffer_type_e type, media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_s **handle);
+static void __pkt_deinit(media_packet_s *handle);
static size_t __pkt_calculate_video_buffer_size(media_packet_s *pkt);
static size_t __pkt_calculate_audio_buffer_size(media_packet_s *pkt);
static size_t __pkt_calculate_text_buffer_size(media_packet_s *pkt);
static uint32_t _convert_to_tbm_surface_format(media_format_mimetype_e format_type);
static void *__aligned_malloc_normal_buffer_type(size_t size, int alignment);
static void __aligned_free_normal_buffer_type(void *buffer_ptr);
-static int __pkt_alloc_buffer(media_packet_s *pkt);
+static int __pkt_alloc_buffer(media_packet_s *handle);
static int __pkt_dealloc_buffer(media_packet_s *handle);
-int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+static int __pkt_init(media_buffer_type_e type, media_format_h fmt,
+ media_packet_finalize_cb fcb, void *fcb_data, media_packet_s **handle)
{
- media_packet_s *handle = NULL;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *new_handle = NULL;
MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(handle);
+
if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1) {
- LOGE("The media format handle is corrupted or Not set media info"); //LCOV_EXCL_LINE
+ LOGE("The media format is corrupted or Not set media info"); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)
- && !MEDIA_FORMAT_IS_TEXT(fmt)) {
- LOGE("The media format handle is not specified. set video info, audio info or text info..."); //LCOV_EXCL_LINE
+ if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt) && !MEDIA_FORMAT_IS_TEXT(fmt)) {
+ LOGE("The media format is not specified. set video info, audio info or text info");
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
- handle = (media_packet_s *)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else {
+ new_handle = calloc(1, sizeof(media_packet_s));
+ if (!new_handle) {
LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
- ret = MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- goto fail;
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
}
- /* TODO : need to consider to give application to select buffer type(tbm or heap) */
+ new_handle->type = type;
+ new_handle->format = MEDIA_FORMAT_CAST(fmt);
+ new_handle->finalizecb_func = fcb;
+ new_handle->userdata = fcb_data;
- /* check if tbm surface is needed.
- * This time, Only raw video format is considered to be allocated in TBM
- */
- if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
- handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
- else
- handle->type = MEDIA_BUFFER_TYPE_NORMAL;
+ media_format_ref((media_format_h)new_handle->format);
- /* take fmt */
- handle->format = MEDIA_FORMAT_CAST(fmt);
+ *handle = new_handle;
- /* alloc buffer */
- ret = __pkt_alloc_buffer(handle);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("failed __pkt_alloc_buffer(), err = (0x%08x)", ret); //LCOV_EXCL_LINE
- goto fail;
- }
-
- /* allocated buffer */
- handle->is_allocated = true;
+ LOGI("new packet[type:%d] %p", type, *handle);
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- media_format_ref((media_format_h)handle->format);
+ return MEDIA_PACKET_ERROR_NONE;
+}
- /* take handle */
- *packet = (media_packet_h)handle;
- LOGI("new handle : %p", *packet);
- return ret;
+static void __pkt_deinit(media_packet_s *handle)
+{
+ MEDIA_PACKET_NULL_ARG_CHECK(handle);
-fail:
+ media_format_unref(handle->format);
+ handle->format = NULL;
- if (handle) {
- free(handle);
- handle = NULL;
- }
+ memset(handle, 0x0, sizeof(media_packet_s));
- *packet = NULL;
- return ret;
+ free(handle);
}
+
int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
{
- media_packet_s *handle = NULL;
-
MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1) {
- LOGE("The media format handle is corrupted or Not set media info"); //LCOV_EXCL_LINE
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)
- && !MEDIA_FORMAT_IS_TEXT(fmt)) {
- LOGE("The media format handle is not specified. set video info, audio info or text info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- /* TODO : need more validation on fmt */
-
- handle = (media_packet_s *)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else {
- LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
-
- /* TODO : need to consider to give application to select buffer type(tbm or heap) */
- /* check if tbm surface is needed.
- * This time, Only raw video format is considered to be allocated in TBM
- */
if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
- handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
+ return __pkt_init(MEDIA_BUFFER_TYPE_TBM_SURFACE, fmt, fcb, fcb_data, packet);
else
- handle->type = MEDIA_BUFFER_TYPE_NORMAL;
+ return __pkt_init(MEDIA_BUFFER_TYPE_NORMAL, fmt, fcb, fcb_data, packet);
+}
- /* take fmt */
- handle->format = MEDIA_FORMAT_CAST(fmt);
- /* NOT allocated buffer */
- handle->is_allocated = false;
+int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+{
+ media_packet_s *handle = NULL;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
+ ret = media_packet_create(fmt, fcb, fcb_data, (media_packet_h)&handle);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed 0x%x", ret);
+ return ret;
+ }
- /* increase format reference count */
- media_format_ref((media_format_h)handle->format);
+ /* alloc buffer */
+ ret = __pkt_alloc_buffer(handle);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed __pkt_alloc_buffer(), err = (0x%08x)", ret); //LCOV_EXCL_LINE
+ __pkt_deinit(handle); //LCOV_EXCL_LINE
+ return ret;
+ }
/* take handle */
*packet = (media_packet_h)handle;
+
LOGI("new handle : %p", *packet);
- return MEDIA_PACKET_ERROR_NONE;
+ return MEDIA_PACKET_ERROR_NONE;
}
+
int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *new_packet)
{
media_packet_s *handle;
org_handle = (media_packet_s *)org_packet;
- handle = (media_packet_s *)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else {
+ handle = calloc(1, sizeof(media_packet_s));
+ if (!handle) {
LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
}
/* take handle */
*new_packet = (media_packet_h)handle;
+
LOGI("new handle : %p", *new_packet);
- return MEDIA_PACKET_ERROR_NONE;
+ return MEDIA_PACKET_ERROR_NONE;
}
int media_packet_alloc(media_packet_h packet)
{
LOGI("start");
- media_packet_s *handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
-
- handle = (media_packet_s *)packet;
-
- /* alloc buffer */
- int err = __pkt_alloc_buffer(handle);
- if (err != MEDIA_PACKET_ERROR_NONE) {
- LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
- ret = err;
- goto fail;
- }
-
- /* allocated buffer */
- handle->is_allocated = true;
-
- LOGI("end");
- return ret;
-
-fail:
- if (handle) {
- free(handle);
- handle = NULL;
- }
- return ret;
+ return __pkt_alloc_buffer((media_packet_s *)packet);
}
-static int __pkt_alloc_buffer(media_packet_s *pkt)
+static int __pkt_alloc_buffer(media_packet_s *handle)
{
- /* skip validating pkt */
+ int tbm_ret = TBM_SURFACE_ERROR_NONE;
size_t buffersize = 0;
+ tbm_surface_info_s surface_info;
+
+ MEDIA_PACKET_INSTANCE_CHECK(handle);
+
+ if (handle->is_allocated) {
+ LOGE("already allocated");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
/* initialize packet */
- pkt->pts = CLOCK_TIME_NONE;
- pkt->dts = CLOCK_TIME_NONE;
- pkt->duration = CLOCK_TIME_NONE;
- pkt->method = MEDIA_PACKET_ROTATE_IDENTITY;
+ handle->pts = CLOCK_TIME_NONE;
+ handle->dts = CLOCK_TIME_NONE;
+ handle->duration = CLOCK_TIME_NONE;
+ handle->method = MEDIA_PACKET_ROTATE_IDENTITY;
- if (pkt->type == MEDIA_BUFFER_TYPE_NORMAL) {
+ if (handle->type == MEDIA_BUFFER_TYPE_NORMAL) {
/* need to use format,width,height to get buffer size */
- if (MEDIA_FORMAT_IS_VIDEO(pkt->format))
- buffersize = __pkt_calculate_video_buffer_size(pkt);
- else if (MEDIA_FORMAT_IS_AUDIO(pkt->format))
- buffersize = __pkt_calculate_audio_buffer_size(pkt);
+ if (MEDIA_FORMAT_IS_VIDEO(handle->format))
+ buffersize = __pkt_calculate_video_buffer_size(handle);
+ else if (MEDIA_FORMAT_IS_AUDIO(handle->format))
+ buffersize = __pkt_calculate_audio_buffer_size(handle);
else
- buffersize = __pkt_calculate_text_buffer_size(pkt);
+ buffersize = __pkt_calculate_text_buffer_size(handle);
if (buffersize == 0)
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
/* 16bytes aligned malloc */
- pkt->data = __aligned_malloc_normal_buffer_type(buffersize, 16);
- if (!pkt->data)
+ handle->data = __aligned_malloc_normal_buffer_type(buffersize, 16);
+ if (!handle->data) {
+ LOGE("alloc normal buffer failed, size %zu", buffersize);
return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- pkt->size = buffersize;
- } else if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
-
- /* convert to tbm_format */
- uint32_t tbm_format;
- tbm_format = _convert_to_tbm_surface_format(pkt->format->mimetype);
-
-#if 0
- /*check whether given tbm_format is supported or not */
- uint32_t *supported_formats;
- uint32_t supported_format_num;
- bool is_supported_format;
- int i;
-
- if (tbm_surface_query_formats(&supported_formats, &supported_format_num)) {
- is_supported_format = false;
- for (i = 0; i < supported_format_num; i++) {
- if (supported_formats[i] == tbm_format) {
- is_supported_format = true;
- break;
- }
- }
-
- free(supported_formats);
- } else {
- /* tbm_surface_query_format returns error */
- LOGE("tbm_surface_query_format is failed..");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
- /* if not supported tbm_format by backend, don't need to do tbm_surface_create() */
- if (!is_supported_format) {
- LOGE("the backend doesn't support 0x%x mimetype", pkt->format->mimetype);
+ handle->size = buffersize;
+ } else if (handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
+ /*create tbm_surface */
+ handle->surface_data = (void *)tbm_surface_create(handle->format->detail.video.width,
+ handle->format->detail.video.height, _convert_to_tbm_surface_format(handle->format->mimetype));
+ if (handle->surface_data == NULL) {
+ LOGE("tbm_surface_create() is failed!!"); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
-#endif
- /*create tbm_surface */
- pkt->surface_data = (void *)tbm_surface_create(pkt->format->detail.video.width, pkt->format->detail.video.height, tbm_format);
- if (pkt->surface_data != NULL) {
-
- /* get tbm_surface_info */
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)pkt->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE) {
- pkt->data = surface_info.planes[0].ptr;
- pkt->size = (size_t)surface_info.size;
- LOGD("tbm_surface_created, pkt->size = %d\n", pkt->size);
- } else {
- LOGE("tbm_surface_get_info() is failed.. err = 0x%08x \n", err); //LCOV_EXCL_LINE
- tbm_surface_destroy((tbm_surface_h)pkt->surface_data);
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- } else {
- LOGE("\n tbm_surface_create() is failed!! \n"); //LCOV_EXCL_LINE
+
+ /* get tbm_surface_info */
+ tbm_ret = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
+ if (tbm_ret != TBM_SURFACE_ERROR_NONE) {
+ LOGE("tbm_surface_get_info() is failed 0x%x", tbm_ret); //LCOV_EXCL_LINE
+ tbm_surface_destroy((tbm_surface_h)handle->surface_data);
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
+ handle->data = surface_info.planes[0].ptr;
+ handle->size = (size_t)surface_info.size;
+
+ LOGD("tbm_surface_created, size = %d", handle->size);
+ } else {
+ LOGE("should not be reached here, type %d", handle->type);
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
+ handle->is_allocated = true;
+
return MEDIA_PACKET_ERROR_NONE;
}
handle->codec_data_size = 0;
}
+ handle->is_allocated = false;
+
return MEDIA_PACKET_ERROR_NONE;
}
buffersize = (stride + (_ROUND_UP_16(width) / 2)) * height;
break;
default:
- LOGE("Not supported format\n"); //LCOV_EXCL_LINE
+ LOGE("Not supported format"); //LCOV_EXCL_LINE
return 0;
}
buffersize += BUFFER_PADDING_SIZE;
- LOGD("format 0x%x, buffersize %d\n", pkt->format->mimetype, buffersize);
+ LOGD("format 0x%x, buffersize %d", pkt->format->mimetype, buffersize);
return buffersize;
}
buffersize = (OPUS_MAX_FRM_SIZE * OPUS_MAX_NCH) * 2; /* 2 = (16bit/8) */
break;
default:
- LOGE("Not supported format\n"); //LCOV_EXCL_LINE
+ LOGE("Not supported format"); //LCOV_EXCL_LINE
return 0;
}
buffersize += BUFFER_PADDING_SIZE;
- LOGD("format 0x%x, buffersize %d\n", pkt->format->mimetype, buffersize);
+ LOGD("format 0x%x, buffersize %d", pkt->format->mimetype, buffersize);
return buffersize;
}
buffersize = TXT_MAX_FRM_SIZE;
break;
default:
- LOGE("Not supported text format\n"); //LCOV_EXCL_LINE
+ LOGE("Not supported text format"); //LCOV_EXCL_LINE
return 0;
}
return buffersize;
int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surface, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
{
- media_packet_s *handle;
+ media_packet_s *handle = NULL;
+ tbm_surface_info_s surface_info;
int ret = MEDIA_PACKET_ERROR_NONE;
+ int tbm_ret = TBM_SURFACE_ERROR_NONE;
- if (surface == NULL)
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
-
- MEDIA_PACKET_INSTANCE_CHECK(fmt);
MEDIA_PACKET_INSTANCE_CHECK(surface);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
- LOGE("The media format handle is not specified. set video info or audio info..."); //LCOV_EXCL_LINE
+
+ tbm_ret = tbm_surface_get_info(surface, &surface_info);
+ if (tbm_ret != TBM_SURFACE_ERROR_NONE) {
+ LOGE("tbm surface[%p] info failed 0x%x", surface, tbm_ret);
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
- handle = (media_packet_s *)malloc(sizeof(media_packet_s));
- if (handle != NULL) {
- memset(handle, 0, sizeof(media_packet_s));
- } else {
- LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ ret = __pkt_init(MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE, fmt, fcb, fcb_data, &handle);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("handle init failed 0x%x", ret);
+ return ret;
}
- handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE;
handle->surface_data = (void *)surface;
-
- /* alloc handle->format */
- handle->format = MEDIA_FORMAT_CAST(fmt);
-
- /* get tbm_surface_info */
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE) {
- handle->data = surface_info.planes[0].ptr;
- handle->size = (uint64_t)surface_info.size;
- } else {
- LOGE("tbm_surface_get_info() is failed.. err =0x%08x", err);
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- goto fail;
- }
-
- /* allocated buffer */
+ handle->data = surface_info.planes[0].ptr;
+ handle->size = (uint64_t)surface_info.size;
handle->is_allocated = true;
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- ret = media_format_ref((media_format_h)handle->format);
-
- /* take handle */
*packet = (media_packet_h)handle;
- LOGI("new handle : %p", *packet);
- return ret;
-
-fail:
- if (handle) {
- free(handle);
- handle = NULL;
- }
+ LOGI("surface %p, data %p, size %zu", handle->surface_data, handle->data, handle->size);
- *packet = NULL;
return ret;
}
int media_packet_create_from_external_memory(media_format_h fmt, void *mem_ptr, uint64_t size, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
{
- media_packet_s *handle;
+ media_packet_s *handle = NULL;
int ret = MEDIA_PACKET_ERROR_NONE;
- if (mem_ptr == NULL)
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
-
- if (!(size > 0))
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
-
MEDIA_PACKET_INSTANCE_CHECK(fmt);
+ MEDIA_PACKET_NULL_ARG_CHECK(mem_ptr);
MEDIA_PACKET_NULL_ARG_CHECK(packet);
-
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
- LOGE("The media format handle is not specified. set video info or audio info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
+ MEDIA_PACKET_CHECK_CONDITION(size > 0, "invalid size", MEDIA_PACKET_ERROR_INVALID_PARAMETER);
if (MEDIA_FORMAT_IS_RAW(fmt) && MEDIA_FORMAT_IS_VIDEO(fmt)) {
LOGE("failed!. it supports only 'MEDIA_FORMAT_ENCODED' type."); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
- handle = (media_packet_s *)malloc(sizeof(media_packet_s));
- if (handle != NULL) {
- memset(handle, 0, sizeof(media_packet_s));
- } else {
- LOGE("MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIA_PACKET_ERROR_OUT_OF_MEMORY); //LCOV_EXCL_LINE
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ ret = __pkt_init(MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY, fmt, fcb, fcb_data, &handle);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("handle init failed 0x%x", ret);
+ return ret;
}
- handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY;
-
- /* alloc handle->format */
- handle->format = MEDIA_FORMAT_CAST(fmt);
-
- /* set external allocated memory & external memory size */
handle->size = size;
handle->data = mem_ptr;
-
- /* allocated buffer */
handle->is_allocated = true;
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- ret = media_format_ref((media_format_h)handle->format);
-
- /* take handle */
*packet = (media_packet_h)handle;
- LOGI("new handle : %p", *packet);
+
+ LOGI("data %p, size %zu", handle->data, handle->size);
return ret;
}
/* if trying to set same format, return */
if (handle->format == MEDIA_FORMAT_CAST(fmt)) {
- LOGE("The packet handle already refers the format handle..\n"); //LCOV_EXCL_LINE
+ LOGE("The packet handle already refers the format handle"); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
if (err == TBM_SURFACE_ERROR_NONE) {
*num = surface_info.num_planes;
- LOGD(" surface_info the number of planes = %d\n", (int)surface_info.num_planes);
+ LOGD(" surface_info the number of planes = %d", (int)surface_info.num_planes);
} else {
*num = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err); //LCOV_EXCL_LINE
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x", err); //LCOV_EXCL_LINE
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
} else {
*num = 0;
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ LOGE("The packet handle doesn't have tbm_surface buffer type");
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
MEDIA_PACKET_INSTANCE_CHECK(packet);
MEDIA_PACKET_NULL_ARG_CHECK(stride_width);
if (plane_idx < 0) {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
+ LOGE("Invalid plane_idx : %d, must not be negative number", plane_idx);
return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
if (surface_info.num_planes > plane_idx) {
*stride_width = surface_info.planes[plane_idx].stride;
} else {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
+ LOGE("the plane_idx is invalid, The number of planes = %lu", surface_info.num_planes);
*stride_width = 0;
ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
} else {
*stride_width = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err); //LCOV_EXCL_LINE
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x", err); //LCOV_EXCL_LINE
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
} else {
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ LOGE("The packet handle doesn't have tbm_surface buffer type");
*stride_width = 0;
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
MEDIA_PACKET_INSTANCE_CHECK(packet);
MEDIA_PACKET_NULL_ARG_CHECK(stride_height);
if (plane_idx < 0) {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx); //LCOV_EXCL_LINE
+ LOGE("Invalid plane_idx : %d, must not be negative number", plane_idx); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
if (surface_info.num_planes > plane_idx) {
*stride_height = surface_info.planes[plane_idx].size / surface_info.planes[plane_idx].stride;
} else {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes); //LCOV_EXCL_LINE
+ LOGE("the plane_idx is invalid, The number of planes = %lu", surface_info.num_planes); //LCOV_EXCL_LINE
*stride_height = 0;
ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
} else {
*stride_height = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err); //LCOV_EXCL_LINE
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x", err); //LCOV_EXCL_LINE
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
} else {
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ LOGE("The packet handle doesn't have tbm_surface buffer type");
*stride_height = 0;
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
MEDIA_PACKET_INSTANCE_CHECK(packet);
MEDIA_PACKET_NULL_ARG_CHECK(plane_data_ptr);
if (plane_idx < 0) {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx); //LCOV_EXCL_LINE
+ LOGE("Invalid plane_idx : %d, must not be negative number", plane_idx); //LCOV_EXCL_LINE
return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
if (err == TBM_SURFACE_ERROR_NONE) {
if (surface_info.num_planes > plane_idx) {
*plane_data_ptr = surface_info.planes[plane_idx].ptr;
- LOGD("the tbm_surface_info.planes[%d].ptr = %p\n", plane_idx, surface_info.planes[plane_idx].ptr);
+ LOGD("the tbm_surface_info.planes[%d].ptr = %p", plane_idx, surface_info.planes[plane_idx].ptr);
} else {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes); //LCOV_EXCL_LINE
+ LOGE("the plane_idx is invalid, The number of planes = %lu", surface_info.num_planes); //LCOV_EXCL_LINE
*plane_data_ptr = NULL;
ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
}
} else {
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err); //LCOV_EXCL_LINE
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x", err); //LCOV_EXCL_LINE
*plane_data_ptr = NULL;
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
} else {
- LOGI("The packet handle doesn't have tbm_surface buffer type...\n");
+ LOGI("The packet handle doesn't have tbm_surface buffer type");
*plane_data_ptr = NULL;
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
handle = (media_packet_s *)packet;
- LOGI("Get: codec data = %p, codec_data_size = %u\n", handle->codec_data, handle->codec_data_size); //LCOV_EXCL_LINE
+ LOGI("Get: codec data = %p, codec_data_size = %u", handle->codec_data, handle->codec_data_size); //LCOV_EXCL_LINE
if (handle->codec_data) {
*codec_data_size = handle->codec_data_size;
*codec_data = NULL;
*codec_data_size = 0;
- LOGE("There is no codec data..\n");
+ LOGE("There is no codec data");
ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
}
LOGE("failed __pkt_dealloc_buffer(), err = (0x%08x)", ret); //LCOV_EXCL_LINE
return ret;
}
- /* unreference media_format */
- media_format_unref(handle->format);
- LOGI("The packet handle(%p) will be destroyed..\n", handle); //LCOV_EXCL_LINE
+ LOGI("The packet handle(%p) will be destroyed", handle); //LCOV_EXCL_LINE
- free(handle);
- handle = NULL;
+ __pkt_deinit(handle);
return ret;
}