Apply Tizen coding rule and add doc 29/54929/2 accepted/tizen/mobile/20151221.100813 accepted/tizen/tv/20151221.100821 accepted/tizen/wearable/20151221.100912 submit/tizen/20151221.042723 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718
authorGilbok Lee <gilbok.lee@samsung.com>
Mon, 21 Dec 2015 01:28:52 +0000 (10:28 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Mon, 21 Dec 2015 01:39:46 +0000 (10:39 +0900)
Change-Id: I8da777bae479c2e87834aff35f198de7a4ed7ca4
Signed-off-by: Gilbok Lee <gilbok.lee@samsung.com>
packaging/capi-media-tool.spec
src/media_format.c
src/media_packet.c
src/media_packet_internal.c
test/media_packet_test.c

index 3d7f19900f6d6c4c4a364ebb4bf38af68bcb8a5f..0ade31cf4e91403a6ca7daf872f5d4d9e9a6005b 100755 (executable)
@@ -1,7 +1,7 @@
 Name:       capi-media-tool
 Summary:    A Core API media tool library in Tizen Native API
 Version:    0.1.1
-Release:    2
+Release:    3
 Group:      Multimedia/API
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index d8cf551a19b158a3981c3a40a14fe265b39fe565..35b01ee16a4765f342567ba25d76d6bebdcdea90 100755 (executable)
 #include <media_format.h>
 #include <media_format_private.h>
 
-static void _media_format_destroy(media_format_s * fmt);
+static void _media_format_destroy(media_format_s *fmt);
 
-int media_format_create(media_format_h * fmt)
+int media_format_create(media_format_h *fmt)
 {
        MEDIA_FORMAT_NULL_ARG_CHECK(fmt);
        int ret = MEDIA_FORMAT_ERROR_NONE;
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) malloc(sizeof(media_format_s));
-       if (fmt_handle) {
+       fmt_handle = (media_format_s *)malloc(sizeof(media_format_s));
+       if (fmt_handle)
                memset(fmt_handle, 0, sizeof(media_format_s));
-       } else {
+       else
                return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
-       }
 
        fmt_handle->ref_count = 1;
 
@@ -45,21 +44,21 @@ int media_format_create(media_format_h * fmt)
        return ret;
 }
 
-static void _media_format_destroy(media_format_s * fmt)
+static void _media_format_destroy(media_format_s *fmt)
 {
-       MEDIA_FORMAT_INSTANCE_CHEC_VOID (fmt);
+       MEDIA_FORMAT_INSTANCE_CHEC_VOID(fmt);
 
        free(fmt);
        fmt = NULL;
 }
 
-int media_format_get_type(media_format_h fmt, media_format_type_e * formattype)
+int media_format_get_type(media_format_h fmt, media_format_type_e *formattype)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!formattype)
                return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
@@ -80,13 +79,13 @@ int media_format_get_type(media_format_h fmt, media_format_type_e * formattype)
        return ret;
 }
 
-int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e * mimetype)
+int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e *mimetype)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_CONTAINER)) {
                LOGE("The format handle is not for MEDIA_FORMAT_CONTAINER..\n");
@@ -99,13 +98,13 @@ int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e
        return ret;
 }
 
-int media_format_get_text_info(media_format_h fmt, media_format_mimetype_e * mimetype, media_format_text_type_e * type)
+int media_format_get_text_info(media_format_h fmt, media_format_mimetype_e *mimetype, media_format_text_type_e *type)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_TEXT)) {
                LOGE("The format handle is not for MEDIA_FORMAT_TEXT..\n");
@@ -120,13 +119,13 @@ int media_format_get_text_info(media_format_h fmt, media_format_mimetype_e * mim
        return ret;
 }
 
-int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *width, int *height, int *avg_bps, int *max_bps)
+int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e *mimetype, int *width, int *height, int *avg_bps, int *max_bps)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -147,13 +146,13 @@ int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e * mi
        return ret;
 }
 
-int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *channel, int *samplerate, int *bit, int *avg_bps)
+int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e *mimetype, int *channel, int *samplerate, int *bit, int *avg_bps)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -173,13 +172,13 @@ int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e * mi
        return ret;
 }
 
-int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts)
+int media_format_get_audio_aac_type(media_format_h fmt, bool *is_adts)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype == MEDIA_FORMAT_AAC_LC || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE_PS)) {
                LOGE("The format handle is not aac format..\n");
@@ -192,14 +191,14 @@ int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts)
        return ret;
 }
 
-int media_format_get_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e * aac_header_type)
+int media_format_get_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e *aac_header_type)
 {
 
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype == MEDIA_FORMAT_AAC_LC || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE_PS)) {
                LOGE("The format handle is not aac format..\n");
@@ -218,7 +217,7 @@ int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate)
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -242,11 +241,10 @@ int media_format_set_container_mime(media_format_h fmt, media_format_mimetype_e
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
-       if (!(mimetype & MEDIA_FORMAT_CONTAINER)) {
+       if (!(mimetype & MEDIA_FORMAT_CONTAINER))
                return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-       }
 
        fmt_handle->mimetype = mimetype;
 
@@ -264,11 +262,10 @@ int media_format_set_text_mime(media_format_h fmt, media_format_mimetype_e mimet
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
-       if (!(mimetype & MEDIA_FORMAT_TEXT)) {
+       if (!(mimetype & MEDIA_FORMAT_TEXT))
                return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-       }
 
        fmt_handle->mimetype = mimetype;
 
@@ -286,11 +283,10 @@ int media_format_set_text_type(media_format_h fmt, media_format_text_type_e type
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
-       if (!(fmt_handle->mimetype & MEDIA_FORMAT_TEXT)) {
+       if (!(fmt_handle->mimetype & MEDIA_FORMAT_TEXT))
                return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-       }
 
        fmt_handle->detail.text.type = type;
 
@@ -308,11 +304,10 @@ int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mime
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
-       if (!(mimetype & MEDIA_FORMAT_VIDEO)) {
+       if (!(mimetype & MEDIA_FORMAT_VIDEO))
                return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-       }
 
        fmt_handle->mimetype = mimetype;
 
@@ -330,7 +325,7 @@ int media_format_set_video_width(media_format_h fmt, int width)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -353,7 +348,7 @@ int media_format_set_video_height(media_format_h fmt, int height)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -376,7 +371,7 @@ int media_format_set_video_avg_bps(media_format_h fmt, int avg_bps)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -399,7 +394,7 @@ int media_format_set_video_max_bps(media_format_h fmt, int max_bps)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -422,7 +417,7 @@ int media_format_set_video_frame_rate(media_format_h fmt, int frame_rate)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
@@ -446,7 +441,7 @@ int media_format_set_audio_mime(media_format_h fmt, media_format_mimetype_e mime
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -470,7 +465,7 @@ int media_format_set_audio_channel(media_format_h fmt, int channel)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -494,7 +489,7 @@ int media_format_set_audio_samplerate(media_format_h fmt, int samplerate)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -518,7 +513,7 @@ int media_format_set_audio_bit(media_format_h fmt, int bit)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -542,7 +537,7 @@ int media_format_set_audio_avg_bps(media_format_h fmt, int avg_bps)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -566,7 +561,7 @@ int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -590,7 +585,7 @@ int media_format_set_audio_aac_header_type(media_format_h fmt, media_format_aac_
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
                LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
@@ -608,11 +603,10 @@ int media_format_ref(media_format_h fmt)
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
-       if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0) {
+       if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0)
                return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
-       }
 
        g_atomic_int_inc(&fmt_handle->ref_count);
 
@@ -626,7 +620,7 @@ int media_format_unref(media_format_h fmt)
        bool is_zero;
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0) {
                LOGE("The format ref_count is less than 0..\n");
@@ -653,7 +647,7 @@ int media_format_is_writable(media_format_h fmt, bool * is_writable)
        }
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (g_atomic_int_get(&fmt_handle->ref_count) == 1) {
                /* if reference count is 1, the caller must be owner. */
@@ -665,13 +659,13 @@ int media_format_is_writable(media_format_h fmt, bool * is_writable)
        return ret;
 }
 
-int media_format_make_writable(media_format_h fmt, media_format_h * out_fmt)
+int media_format_make_writable(media_format_h fmt, media_format_h *out_fmt)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
        MEDIA_FORMAT_INSTANCE_CHECK(fmt);
 
        media_format_s *fmt_handle;
-       fmt_handle = (media_format_s *) fmt;
+       fmt_handle = (media_format_s *)fmt;
 
        if (MEDIA_FORMAT_IS_WRITABLE(fmt)) {
                /* If there is only one reference count on @fmt, the caller must be the owner */
@@ -680,12 +674,11 @@ int media_format_make_writable(media_format_h fmt, media_format_h * out_fmt)
                /* If there is more than one reference on the object, a new media_format_h object will be returned.
                   The caller's reference on @fmt will be removed, and instead the caller will own a reference to the returned object. */
                media_format_s *copy;
-               copy = (media_format_s *) malloc(sizeof(media_format_s));
-               if (copy) {
+               copy = (media_format_s *)malloc(sizeof(media_format_s));
+               if (copy)
                        memset(copy, 0, sizeof(media_format_s));
-               } else {
+               else
                        return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
-               }
 
                memcpy(copy, fmt_handle, sizeof(media_format_s));
                copy->ref_count = 1;
index 859a2757adc8f1b4e45d01b41b5667f1d633b5fd..6fcdc6b017b616d0615d8465505b4cca06dd47ec 100755 (executable)
 /* NOTE : static internal functions does not check anything on incomming parameters
  * Caller should takecare it
  */
-static int _pkt_alloc_buffer(media_packet_s * pkt);
-static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt);
-static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt);
-static uint64_t _pkt_calculate_text_buffer_size(media_packet_s * pkt);
+static int _pkt_alloc_buffer(media_packet_s *pkt);
+static uint64_t _pkt_calculate_video_buffer_size(media_packet_s *pkt);
+static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s *pkt);
+static uint64_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(uint64_t size, int alignment);
 static void _aligned_free_normal_buffer_type(void *buffer_ptr);
 
-int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
+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;
@@ -47,12 +47,13 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb,
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt) && !MEDIA_FORMAT_IS_TEXT(fmt)) {
+       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;
        }
 
-       handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+       handle = (media_packet_s *)malloc(sizeof(media_packet_s));
        if (handle != NULL)
                memset(handle, 0, sizeof(media_packet_s));
        else {
@@ -66,11 +67,10 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb,
        /* 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)) {
+       if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
                handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
-       } else {
+       else
                handle->type = MEDIA_BUFFER_TYPE_NORMAL;
-       }
 
        /* take fmt */
        handle->format = MEDIA_FORMAT_CAST(fmt);
@@ -91,14 +91,14 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb,
        handle->userdata = fcb_data;
 
        /* increase format reference count */
-       media_format_ref((media_format_h) handle->format);
+       media_format_ref((media_format_h)handle->format);
 
        /* take handle */
-       *packet = (media_packet_h) handle;
+       *packet = (media_packet_h)handle;
        LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
        return ret;
 
- fail:
+fail:
 
        if (handle) {
                free(handle);
@@ -109,7 +109,7 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb,
        return ret;
 }
 
-int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
+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;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -121,13 +121,14 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt) && !MEDIA_FORMAT_IS_TEXT(fmt)) {
+       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));
+       handle = (media_packet_s *)malloc(sizeof(media_packet_s));
        if (handle != NULL)
                memset(handle, 0, sizeof(media_packet_s));
        else {
@@ -140,11 +141,10 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *
        /* 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)) {
+       if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
                handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
-       } else {
+       else
                handle->type = MEDIA_BUFFER_TYPE_NORMAL;
-       }
 
        /* take fmt */
        handle->format = MEDIA_FORMAT_CAST(fmt);
@@ -157,16 +157,16 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *
        handle->userdata = fcb_data;
 
        /* increase format reference count */
-       media_format_ref((media_format_h) handle->format);
+       media_format_ref((media_format_h)handle->format);
 
        /* take handle */
-       *packet = (media_packet_h) handle;
+       *packet = (media_packet_h)handle;
        LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
        return ret;
 
 }
 
-int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * new_packet)
+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;
        media_packet_s *org_handle;
@@ -176,9 +176,9 @@ int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, v
        MEDIA_PACKET_INSTANCE_CHECK(org_packet);
        MEDIA_PACKET_NULL_ARG_CHECK(new_packet);
 
-       org_handle = (media_packet_s *) org_packet;
+       org_handle = (media_packet_s *)org_packet;
 
-       handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+       handle = (media_packet_s *)malloc(sizeof(media_packet_s));
        if (handle != NULL)
                memset(handle, 0, sizeof(media_packet_s));
        else {
@@ -200,10 +200,10 @@ int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, v
        handle->userdata = fcb_data;
 
        /* increase format reference count */
-       media_format_ref((media_format_h) handle->format);
+       media_format_ref((media_format_h)handle->format);
 
        /* take handle */
-       *new_packet = (media_packet_h) handle;
+       *new_packet = (media_packet_h)handle;
        LOGI("[%s] new handle : %p", __FUNCTION__, *new_packet);
        return ret;
 
@@ -217,7 +217,7 @@ int media_packet_alloc(media_packet_h packet)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        /* alloc buffer */
        int err = _pkt_alloc_buffer(handle);
@@ -233,7 +233,7 @@ int media_packet_alloc(media_packet_h packet)
        LOGI("[%s] end", __FUNCTION__);
        return ret;
 
- fail:
+fail:
        if (handle) {
                free(handle);
                handle = NULL;
@@ -242,7 +242,7 @@ int media_packet_alloc(media_packet_h packet)
 
 }
 
-int _pkt_alloc_buffer(media_packet_s * pkt)
+int _pkt_alloc_buffer(media_packet_s *pkt)
 {
        /* skip validating pkt */
        uint64_t buffersize = 0;
@@ -262,23 +262,20 @@ int _pkt_alloc_buffer(media_packet_s * pkt)
                /* need to use format,width,height to get buffer size */
                if (MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
                        buffersize = _pkt_calculate_video_buffer_size(pkt);
-                       // 16bytes aligned malloc
+                       /* 16bytes aligned malloc */
                        pkt->data = _aligned_malloc_normal_buffer_type(buffersize, 16);
-                       if (!pkt->data) {
+                       if (!pkt->data)
                                return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
-                       }
                } else if (MEDIA_FORMAT_IS_AUDIO(pkt->format)) {
                        buffersize = _pkt_calculate_audio_buffer_size(pkt);
                        pkt->data = (void *)malloc(buffersize);
-                       if (!pkt->data) {
+                       if (!pkt->data)
                                return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
-                       }
                } else {
                        buffersize = _pkt_calculate_text_buffer_size(pkt);
                        pkt->data = (void *)malloc(buffersize);
-                       if (!pkt->data) {
+                       if (!pkt->data)
                                return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
-                       }
                }
                pkt->size = buffersize;
        } else if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
@@ -322,14 +319,14 @@ int _pkt_alloc_buffer(media_packet_s * pkt)
 
                        /* get tbm_surface_info */
                        tbm_surface_info_s surface_info;
-                       int err = tbm_surface_get_info((tbm_surface_h) pkt->surface_data, &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 = (uint64_t) surface_info.size;
+                               pkt->size = (uint64_t)surface_info.size;
                                LOGD("tbm_surface_created, pkt->size = %llu\n", pkt->size);
                        } else {
                                LOGE("tbm_surface_get_info() is failed.. err = 0x%08x \n", err);
-                               tbm_surface_destroy((tbm_surface_h) pkt->surface_data);
+                               tbm_surface_destroy((tbm_surface_h)pkt->surface_data);
                                return MEDIA_PACKET_ERROR_INVALID_OPERATION;
                        }
                } else {
@@ -346,7 +343,7 @@ int _pkt_alloc_buffer(media_packet_s * pkt)
 #define _ROUND_UP_X(v, x) (((v) + _GEN_MASK(x)) & ~_GEN_MASK(x))
 #define _DIV_ROUND_UP_X(v, x) (((v) + _GEN_MASK(x)) >> (x))
 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
-static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
+static uint64_t _pkt_calculate_video_buffer_size(media_packet_s *pkt)
 {
        unsigned char x_chroma_shift = 0;
        unsigned char y_chroma_shift = 0;
@@ -455,7 +452,7 @@ static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
 #define AMR_MAX_NCH                  (1)
 #define WMA_MAX_NCH                  (2)
 
-static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
+static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s *pkt)
 {
        int channel = 0;
        int bit = 0;
@@ -468,30 +465,30 @@ static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
 
        switch (pkt->format->mimetype) {
        case MEDIA_FORMAT_PCM:
-               buffersize = (PCM_MAX_FRM_SIZE * PCM_MAX_NCH) * (uint64_t) (bit / 8);
+               buffersize = (PCM_MAX_FRM_SIZE * PCM_MAX_NCH) * (uint64_t)(bit / 8);
                break;
        case MEDIA_FORMAT_AAC_LC:
        case MEDIA_FORMAT_AAC_HE:
        case MEDIA_FORMAT_AAC_HE_PS:
        case MEDIA_FORMAT_MP3:
-               buffersize = (MPEG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2);       /* 2 = (16bit/8) */
+               buffersize = (MPEG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2);        /* 2 = (16bit/8) */
                break;
                /* TODO : extenstion format */
        case MEDIA_FORMAT_AMR_NB:
        case MEDIA_FORMAT_AMR_WB:
-               buffersize = (AMR_MAX_FRM_SIZE * AMR_MAX_NCH) * (uint64_t) (2); /* 2 = (16bit/8) */
+               buffersize = (AMR_MAX_FRM_SIZE * AMR_MAX_NCH) * (uint64_t)(2);  /* 2 = (16bit/8) */
                break;
        case MEDIA_FORMAT_VORBIS:
-               buffersize = (OGG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2);        /* 2 = (16bit/8) */
+               buffersize = (OGG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8) */
                break;
        case MEDIA_FORMAT_FLAC:
-               buffersize = (FLAC_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2);       /* 2 = (16bit/8) */
+               buffersize = (FLAC_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2);        /* 2 = (16bit/8) */
                break;
        case MEDIA_FORMAT_WMAV1:
        case MEDIA_FORMAT_WMAV2:
        case MEDIA_FORMAT_WMAPRO:
        case MEDIA_FORMAT_WMALSL:
-               buffersize = (WMA_MAX_FRM_SIZE * WMA_MAX_NCH) * (uint64_t) (2); /* 2 = (16bit/8) */
+               buffersize = (WMA_MAX_FRM_SIZE * WMA_MAX_NCH) * (uint64_t)(2);  /* 2 = (16bit/8) */
                break;
        default:
                LOGE("Not supported format\n");
@@ -504,7 +501,7 @@ static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
 }
 
 #define TXT_MAX_FRM_SIZE (2048)
-static uint64_t _pkt_calculate_text_buffer_size(media_packet_s * pkt)
+static uint64_t _pkt_calculate_text_buffer_size(media_packet_s *pkt)
 {
        uint64_t buffersize = 0;
        switch (pkt->format->mimetype) {
@@ -518,7 +515,7 @@ static uint64_t _pkt_calculate_text_buffer_size(media_packet_s * pkt)
        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)
+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;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -534,7 +531,7 @@ int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surfa
                return MEDIA_PACKET_ERROR_INVALID_OPERATION;
        }
 
-       handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+       handle = (media_packet_s *)malloc(sizeof(media_packet_s));
        if (handle != NULL) {
                memset(handle, 0, sizeof(media_packet_s));
        } else {
@@ -550,10 +547,10 @@ int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surfa
 
        /* get tbm_surface_info */
        tbm_surface_info_s surface_info;
-       int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &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;
+               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;
@@ -568,14 +565,14 @@ int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surfa
        handle->userdata = fcb_data;
 
        /* increase format reference count */
-       ret = media_format_ref((media_format_h) handle->format);
+       ret = media_format_ref((media_format_h)handle->format);
 
        /* take handle */
-       *packet = (media_packet_h) handle;
+       *packet = (media_packet_h)handle;
        LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
        return ret;
 
- fail:
+fail:
 
        if (handle) {
                free(handle);
@@ -586,7 +583,7 @@ int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surfa
        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)
+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;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -610,7 +607,7 @@ int media_packet_create_from_external_memory(media_format_h fmt, void *mem_ptr,
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+       handle = (media_packet_s *)malloc(sizeof(media_packet_s));
        if (handle != NULL) {
                memset(handle, 0, sizeof(media_packet_s));
        } else {
@@ -635,10 +632,10 @@ int media_packet_create_from_external_memory(media_format_h fmt, void *mem_ptr,
        handle->userdata = fcb_data;
 
        /* increase format reference count */
-       ret = media_format_ref((media_format_h) handle->format);
+       ret = media_format_ref((media_format_h)handle->format);
 
        /* take handle */
-       *packet = (media_packet_h) handle;
+       *packet = (media_packet_h)handle;
        LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
 
        return ret;
@@ -652,14 +649,14 @@ int media_packet_get_buffer_data_ptr(media_packet_h packet, void **data)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(data);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *data = handle->data;
 
        return ret;
 }
 
-int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h * surface)
+int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h *surface)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -667,14 +664,14 @@ int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h * surface)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(surface);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
-       *surface = (tbm_surface_h) handle->surface_data;
+       *surface = (tbm_surface_h)handle->surface_data;
 
        return ret;
 }
 
-int media_packet_get_format(media_packet_h packet, media_format_h * fmt)
+int media_packet_get_format(media_packet_h packet, media_format_h *fmt)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -682,12 +679,12 @@ int media_packet_get_format(media_packet_h packet, media_format_h * fmt)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(fmt);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        /* ref exist format */
-       media_format_ref((media_format_h) handle->format);
+       media_format_ref((media_format_h)handle->format);
 
-       *fmt = (media_format_h) handle->format;
+       *fmt = (media_format_h)handle->format;
 
        return ret;
 }
@@ -700,7 +697,7 @@ int media_packet_set_format(media_packet_h packet, media_format_h fmt)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(fmt);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        /* if trying to set same format,  return */
        if (handle->format == MEDIA_FORMAT_CAST(fmt)) {
@@ -709,7 +706,7 @@ int media_packet_set_format(media_packet_h packet, media_format_h fmt)
        }
 
        /* unref exist format */
-       media_format_unref((media_format_h) handle->format);
+       media_format_unref((media_format_h)handle->format);
 
        /* set as new format to packet */
        handle->format = MEDIA_FORMAT_CAST(fmt);
@@ -727,7 +724,7 @@ int media_packet_set_pts(media_packet_h packet, uint64_t pts)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->pts = pts;
 
@@ -741,7 +738,7 @@ int media_packet_set_dts(media_packet_h packet, uint64_t dts)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->dts = dts;
 
@@ -755,7 +752,7 @@ int media_packet_set_duration(media_packet_h packet, uint64_t duration)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->duration = duration;
 
@@ -769,14 +766,14 @@ int media_packet_set_buffer_size(media_packet_h packet, uint64_t size)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->size = size;
 
        return ret;
 }
 
-int media_packet_get_pts(media_packet_h packet, uint64_t * pts)
+int media_packet_get_pts(media_packet_h packet, uint64_t *pts)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -784,14 +781,14 @@ int media_packet_get_pts(media_packet_h packet, uint64_t * pts)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(pts);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *pts = handle->pts;
 
        return ret;
 }
 
-int media_packet_get_dts(media_packet_h packet, uint64_t * dts)
+int media_packet_get_dts(media_packet_h packet, uint64_t *dts)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -799,14 +796,14 @@ int media_packet_get_dts(media_packet_h packet, uint64_t * dts)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(dts);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *dts = handle->dts;
 
        return ret;
 }
 
-int media_packet_get_duration(media_packet_h packet, uint64_t * duration)
+int media_packet_get_duration(media_packet_h packet, uint64_t *duration)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -814,14 +811,14 @@ int media_packet_get_duration(media_packet_h packet, uint64_t * duration)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(duration);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *duration = handle->duration;
 
        return ret;
 }
 
-int media_packet_get_buffer_size(media_packet_h packet, uint64_t * size)
+int media_packet_get_buffer_size(media_packet_h packet, uint64_t *size)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -829,7 +826,7 @@ int media_packet_get_buffer_size(media_packet_h packet, uint64_t * size)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(size);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *size = handle->size;
 
@@ -844,7 +841,7 @@ int media_packet_set_extra(media_packet_h packet, void *extra)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(extra);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->extradata = extra;
 
@@ -859,14 +856,14 @@ int media_packet_get_extra(media_packet_h packet, void **extra)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(extra);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *extra = handle->extradata;
 
        return ret;
 }
 
-int media_packet_is_video(media_packet_h packet, bool * is_video)
+int media_packet_is_video(media_packet_h packet, bool *is_video)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -874,7 +871,7 @@ int media_packet_is_video(media_packet_h packet, bool * is_video)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_video);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_FORMAT_IS_VIDEO(handle->format))
                *is_video = true;
@@ -884,7 +881,7 @@ int media_packet_is_video(media_packet_h packet, bool * is_video)
        return ret;
 }
 
-int media_packet_is_audio(media_packet_h packet, bool * is_audio)
+int media_packet_is_audio(media_packet_h packet, bool *is_audio)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -892,7 +889,7 @@ int media_packet_is_audio(media_packet_h packet, bool * is_audio)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_audio);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_FORMAT_IS_AUDIO(handle->format))
                *is_audio = true;
@@ -902,7 +899,7 @@ int media_packet_is_audio(media_packet_h packet, bool * is_audio)
        return ret;
 }
 
-int media_packet_is_text(media_packet_h packet, bool * is_text)
+int media_packet_is_text(media_packet_h packet, bool *is_text)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -910,7 +907,7 @@ int media_packet_is_text(media_packet_h packet, bool * is_text)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_text);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_FORMAT_IS_TEXT(handle->format))
                *is_text = true;
@@ -920,7 +917,7 @@ int media_packet_is_text(media_packet_h packet, bool * is_text)
        return ret;
 }
 
-int media_packet_is_encoded(media_packet_h packet, bool * is_encoded)
+int media_packet_is_encoded(media_packet_h packet, bool *is_encoded)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -928,7 +925,7 @@ int media_packet_is_encoded(media_packet_h packet, bool * is_encoded)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_encoded);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_FORMAT_IS_ENCODED(handle->format))
                *is_encoded = true;
@@ -938,7 +935,7 @@ int media_packet_is_encoded(media_packet_h packet, bool * is_encoded)
        return ret;
 }
 
-int media_packet_is_raw(media_packet_h packet, bool * is_raw)
+int media_packet_is_raw(media_packet_h packet, bool *is_raw)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -946,7 +943,7 @@ int media_packet_is_raw(media_packet_h packet, bool * is_raw)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_raw);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_FORMAT_IS_RAW(handle->format))
                *is_raw = true;
@@ -956,7 +953,7 @@ int media_packet_is_raw(media_packet_h packet, bool * is_raw)
        return ret;
 }
 
-int media_packet_get_flags(media_packet_h packet, media_buffer_flags_e * flags)
+int media_packet_get_flags(media_packet_h packet, media_buffer_flags_e *flags)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -964,7 +961,7 @@ int media_packet_get_flags(media_packet_h packet, media_buffer_flags_e * flags)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(flags);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        *flags = handle->flags;
 
@@ -978,7 +975,7 @@ int media_packet_set_flags(media_packet_h packet, media_buffer_flags_e flags)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->flags |= flags;
 
@@ -992,14 +989,14 @@ int media_packet_unset_flags(media_packet_h packet, media_buffer_flags_e flags)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        handle->flags &= ~flags;
 
        return ret;
 }
 
-int media_packet_is_codec_config(media_packet_h packet, bool * is_codec_config)
+int media_packet_is_codec_config(media_packet_h packet, bool *is_codec_config)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -1007,7 +1004,7 @@ int media_packet_is_codec_config(media_packet_h packet, bool * is_codec_config)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_codec_config);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_PACKET_CODEC_CONFIG_DATA(packet))
                *is_codec_config = true;
@@ -1017,7 +1014,7 @@ int media_packet_is_codec_config(media_packet_h packet, bool * is_codec_config)
        return ret;
 }
 
-int media_packet_is_end_of_stream(media_packet_h packet, bool * is_eos)
+int media_packet_is_end_of_stream(media_packet_h packet, bool *is_eos)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -1025,7 +1022,7 @@ int media_packet_is_end_of_stream(media_packet_h packet, bool * is_eos)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_eos);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_PACKET_CODEC_END_OF_STREAM(packet))
                *is_eos = true;
@@ -1035,7 +1032,7 @@ int media_packet_is_end_of_stream(media_packet_h packet, bool * is_eos)
        return ret;
 }
 
-int media_packet_is_sync_frame(media_packet_h packet, bool * is_sync)
+int media_packet_is_sync_frame(media_packet_h packet, bool *is_sync)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -1043,7 +1040,7 @@ int media_packet_is_sync_frame(media_packet_h packet, bool * is_sync)
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(is_sync);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        if (MEDIA_PACKET_CODEC_SYNC_FRAME(packet))
                *is_sync = true;
@@ -1053,7 +1050,7 @@ int media_packet_is_sync_frame(media_packet_h packet, bool * is_sync)
        return ret;
 }
 
-int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool * has_tbm_surface)
+int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool *has_tbm_surface)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -1061,9 +1058,10 @@ int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool * has_tbm_su
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(has_tbm_surface);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
-       if ((handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE) && handle->surface_data) {
+       if ((handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE)
+               && handle->surface_data) {
                *has_tbm_surface = true;
        } else {
                *has_tbm_surface = false;
@@ -1071,7 +1069,7 @@ int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool * has_tbm_su
        return ret;
 }
 
-int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t * num)
+int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t *num)
 {
        media_packet_s *handle;
        int ret = MEDIA_PACKET_ERROR_NONE;
@@ -1080,13 +1078,13 @@ int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t * nu
        MEDIA_PACKET_INSTANCE_CHECK(packet);
        MEDIA_PACKET_NULL_ARG_CHECK(num);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        media_packet_has_tbm_surface_buffer(packet, &has_tbm);
 
        if (has_tbm) {
                tbm_surface_info_s surface_info;
-               int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+               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);
@@ -1118,13 +1116,13 @@ int media_packet_get_video_stride_width(media_packet_h packet, int plane_idx, in
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        media_packet_has_tbm_surface_buffer(packet, &has_tbm);
 
        if (has_tbm) {
                tbm_surface_info_s surface_info;
-               int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+               int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
                if (err == TBM_SURFACE_ERROR_NONE) {
 
                        if (surface_info.num_planes > plane_idx) {
@@ -1161,13 +1159,13 @@ int media_packet_get_video_stride_height(media_packet_h packet, int plane_idx, i
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        media_packet_has_tbm_surface_buffer(packet, &has_tbm);
 
        if (has_tbm) {
                tbm_surface_info_s surface_info;
-               int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+               int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
                if (err == TBM_SURFACE_ERROR_NONE) {
                        if (surface_info.num_planes > plane_idx) {
                                *stride_height = surface_info.planes[plane_idx].size / surface_info.planes[plane_idx].stride;
@@ -1204,13 +1202,13 @@ int media_packet_get_video_plane_data_ptr(media_packet_h packet, int plane_idx,
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        media_packet_has_tbm_surface_buffer(packet, &has_tbm);
 
        if (has_tbm) {
                tbm_surface_info_s surface_info;
-               int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+               int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
                if (err == TBM_SURFACE_ERROR_NONE) {
                        if (surface_info.num_planes > plane_idx) {
                                *plane_data_ptr = surface_info.planes[plane_idx].ptr;
@@ -1243,7 +1241,7 @@ int media_packet_get_codec_data(media_packet_h packet, void **codec_data, unsign
        MEDIA_PACKET_NULL_ARG_CHECK(codec_data);
        MEDIA_PACKET_NULL_ARG_CHECK(codec_data_size);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        LOGI("Get: codec data = %p, codec_data_size = %u\n", handle->codec_data, handle->codec_data_size);
 
@@ -1268,12 +1266,12 @@ int media_packet_destroy(media_packet_h packet)
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        /* finailize callback */
        if (handle->finalizecb_func) {
                int finalize_cb_ret;
-               finalize_cb_ret = handle->finalizecb_func((media_packet_h) handle, MEDIA_PACKET_ERROR_NONE, handle->userdata);
+               finalize_cb_ret = handle->finalizecb_func((media_packet_h)handle, MEDIA_PACKET_ERROR_NONE, handle->userdata);
 
                /* creator do not want to destroy media packet handle */
                if (finalize_cb_ret == MEDIA_PACKET_REUSE) {
@@ -1283,16 +1281,15 @@ int media_packet_destroy(media_packet_h packet)
        }
 
        if (handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
-               if (handle->surface_data) {
-                       tbm_surface_destroy((tbm_surface_h) handle->surface_data);
-               }
+               if (handle->surface_data)
+                       tbm_surface_destroy((tbm_surface_h)handle->surface_data);
        } else if (handle->type == MEDIA_BUFFER_TYPE_NORMAL) {
                if (handle->data) {
                        _aligned_free_normal_buffer_type(handle->data);
                        handle->data = NULL;
                }
        } else if (handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY) {
-               // there is nothing to do, Do not free the buffer which is created by external module.
+               /* there is nothing to do, Do not free the buffer which is created by external module. */
        }
 
        /* free codec_data if it is allocated */
@@ -1375,9 +1372,8 @@ static void *_aligned_malloc_normal_buffer_type(uint64_t size, int alignment)
        if ((temp_ptr = (unsigned char *)malloc(size + alignment)) != NULL) {
                buffer_ptr = (unsigned char *)((unsigned long int)(temp_ptr + alignment - 1) & (~(unsigned long int)(alignment - 1)));
 
-               if (buffer_ptr == temp_ptr) {
+               if (buffer_ptr == temp_ptr)
                        buffer_ptr += alignment;
-               }
 
                *(buffer_ptr - 1) = (unsigned char)(buffer_ptr - temp_ptr);
                return (void *)buffer_ptr;
@@ -1394,11 +1390,11 @@ static void _aligned_free_normal_buffer_type(void *buffer_ptr)
 
        ptr = (unsigned char *)buffer_ptr;
 
-       // *(ptr - 1) holds the offset to the real allocated block
-       // we sub that offset os we free the real pointer
+       /* *(ptr - 1) holds the offset to the real allocated block
+        we sub that offset os we free the real pointer */
        ptr -= *(ptr - 1);
 
-       // Free the memory
+       /* Free the memory */
        free(ptr);
        ptr = NULL;
 }
index 24e909daa59277dfe662d6dfc53f7d26fca0a77f..e27a3070d307ad60eef57d0ded697c03cab5bc5e 100755 (executable)
@@ -32,7 +32,7 @@ int media_packet_set_codec_data(media_packet_h packet, void *codec_data, unsigne
 
        MEDIA_PACKET_INSTANCE_CHECK(packet);
 
-       handle = (media_packet_s *) packet;
+       handle = (media_packet_s *)packet;
 
        LOGI("Set: codec data = %p, codec_data_size = %u\n", codec_data, codec_data_size);
 
index fadc10b0ac4655ab066d7fcdcd548e5630c4e62d..5aa0a812ce2b85456744a134af97c05309ed414f 100755 (executable)
 #define MAX_HANDLE 10
 #define MEDIA_FORMAT_MAX_HANDLE 3
 
-
-enum
-{
-    CURRENT_STATUS_MAINMENU,
-    CURRENT_STATUS_PACKET_SET_FORMAT,
-    CURRENT_STATUS_DURATION,
-    CURRENT_STATUS_FORMAT_SET_VIDEO_MIME,
-    CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH,
-    CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT,
-    CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS,
-    CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_MIME,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_BIT,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS,
-    CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE,
+enum {
+       CURRENT_STATUS_MAINMENU,
+       CURRENT_STATUS_PACKET_SET_FORMAT,
+       CURRENT_STATUS_DURATION,
+       CURRENT_STATUS_FORMAT_SET_VIDEO_MIME,
+       CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH,
+       CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT,
+       CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS,
+       CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_MIME,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_BIT,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS,
+       CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE,
 };
 
-
 char g_uri[MAX_STRING_LEN];
 int g_menu_state = CURRENT_STATUS_MAINMENU;
 int g_handle_num = 1;
-static media_packet_h g_media_packet[MAX_HANDLE] = {0};
- media_format_h g_media_format[MEDIA_FORMAT_MAX_HANDLE] = {0};
+static media_packet_h g_media_packet[MAX_HANDLE] = {0,  };
+media_format_h g_media_format[MEDIA_FORMAT_MAX_HANDLE] = {0, };
+
 int media_format_idx = -1;
 bool is_only_created_handle;
 bool is_excute_create;
 
 unsigned char codec_data[0x04] = {0x00, 0x01, 0x02, 0x03};
-unsigned int codec_data_size = 4;
-unsigned char* codec_data_ptr = codec_data;
 
+unsigned int codec_data_size = 4;
+unsigned char *codec_data_ptr = codec_data;
 
 /***********************************************/
 /***  Test API part
 /***********************************************/
 static void _media_format_create(void)
 {
-    int ret;
-
-    if (g_media_format[0] == NULL)
-    {
-        int ret = media_format_create(&g_media_format[0]);
-        if (ret == MEDIA_FORMAT_ERROR_NONE)
-       {
-            g_print("media_format_h[0] is created successfully! \n");
-            media_format_idx = 0;
-            g_print("ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-       }
-        else
-        {
-            g_print("media_format_create failed...\n");
-            g_print("==> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-        }
-    }
-    else
-    {
-        ret = MEDIA_FORMAT_ERROR_INVALID_OPERATION;
-        g_print("\n can not create media_format_h handle anymore...already exist.\n");
-    }
-
+       int ret;
+
+       if (g_media_format[0] == NULL) {
+               int ret = media_format_create(&g_media_format[0]);
+               if (ret == MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_h[0] is created successfully! \n");
+                       media_format_idx = 0;
+                       g_print("ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+               } else {
+                       g_print("media_format_create failed...\n");
+                       g_print("==> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+               }
+       } else {
+               ret = MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+               g_print("\n can not create media_format_h handle anymore...already exist.\n");
+       }
 
 }
 
 static void _media_format_set_video_mime(int num)
 {
-    int ret;
-    if (num == 0)
-    {
-        ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_H264_HP);
-    }
-    else if (num == 1)
-    {
-        ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_RGB888);
-    }
-    else if (num == 2)
-    {
-        ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_I420);
-    }
-    else
-    {
-        g_print("Invalid number...\n");
-    }
-
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_video_mime is succeeded!!\n");
-    else
-        g_print("media_format_set_video_mime is failed...!!\n");
+       int ret;
+       if (num == 0)
+               ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_H264_HP);
+       else if (num == 1)
+               ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_RGB888);
+       else if (num == 2)
+               ret = media_format_set_video_mime(g_media_format[media_format_idx], MEDIA_FORMAT_I420);
+       else
+               g_print("Invalid number...\n");
+
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_mime is succeeded!!\n");
+       else
+               g_print("media_format_set_video_mime is failed...!!\n");
 
 }
 
 static void _media_format_set_video_width(int w)
 {
-    int ret;
-    ret = media_format_set_video_width(g_media_format[media_format_idx], w);
+       int ret;
+       ret = media_format_set_video_width(g_media_format[media_format_idx], w);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_video_width is succeeded!!\n");
-    else
-        g_print("media_format_set_video_width is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_width is succeeded!!\n");
+       else
+               g_print("media_format_set_video_width is failed...!!\n");
 }
 
 static void _media_format_set_video_height(int h)
 {
-    int ret;
-    ret = media_format_set_video_height(g_media_format[media_format_idx], h);
-
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_video_height is succeeded!!\n");
-    else
-        g_print("media_format_set_video_height is failed...!!\n");
+       int ret;
+       ret = media_format_set_video_height(g_media_format[media_format_idx], h);
 
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_height is succeeded!!\n");
+       else
+               g_print("media_format_set_video_height is failed...!!\n");
 
 }
 
 static void _media_format_set_video_avg_bps(int avg_bps)
 {
-    int ret;
-    ret = media_format_set_video_avg_bps(g_media_format[media_format_idx], avg_bps);
+       int ret;
+       ret = media_format_set_video_avg_bps(g_media_format[media_format_idx], avg_bps);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_video_avg_bps is succeeded!!\n");
-    else
-        g_print("media_format_set_video_avg_bps is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_avg_bps is succeeded!!\n");
+       else
+               g_print("media_format_set_video_avg_bps is failed...!!\n");
 }
 
 static void _media_format_set_video_max_bps(int max_bps)
 {
-    int ret;
-    ret = media_format_set_video_max_bps(g_media_format[media_format_idx], max_bps);
+       int ret;
+       ret = media_format_set_video_max_bps(g_media_format[media_format_idx], max_bps);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_video_max_bps is succeeded!!\n");
-    else
-        g_print("media_format_set_video_max_bps is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_max_bps is succeeded!!\n");
+       else
+               g_print("media_format_set_video_max_bps is failed...!!\n");
 }
 
 static void _media_format_set_audio_mime(int num)
 {
-    int ret;
-    if (num == 0)
-    {
-        ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_AMR);
-    }
-    else if (num == 1)
-    {
-        ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_PCM);
-    }
-    else if (num == 2)
-    {
-        ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_AAC);
-    }
-    else
-    {
-        g_print("Invalid number...\n");
-    }
-
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_mime is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_mime is failed...!!\n");
+       int ret;
+       if (num == 0)
+               ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_AMR);
+       else if (num == 1)
+               ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_PCM);
+       else if (num == 2)
+               ret = media_format_set_audio_mime(g_media_format[media_format_idx], MEDIA_FORMAT_AAC);
+       else
+               g_print("Invalid number...\n");
+
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_mime is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_mime is failed...!!\n");
 
 }
 
 static void _media_format_set_audio_channel(int channel)
 {
-    int ret;
-    ret = media_format_set_audio_channel(g_media_format[media_format_idx], channel);
+       int ret;
+       ret = media_format_set_audio_channel(g_media_format[media_format_idx], channel);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_channel is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_channel is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_channel is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_channel is failed...!!\n");
 }
 
 static void _media_format_set_audio_samplerate(int samplerate)
 {
-    int ret;
-    ret = media_format_set_audio_samplerate(g_media_format[media_format_idx], samplerate);
+       int ret;
+       ret = media_format_set_audio_samplerate(g_media_format[media_format_idx], samplerate);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_samplerate is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_samplerate is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_samplerate is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_samplerate is failed...!!\n");
 }
 
 static void _media_format_set_audio_bit(int bit)
 {
-    int ret;
-    ret = media_format_set_audio_bit(g_media_format[media_format_idx], bit);
+       int ret;
+       ret = media_format_set_audio_bit(g_media_format[media_format_idx], bit);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_bit is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_bit is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_bit is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_bit is failed...!!\n");
 }
 
 static void _media_format_set_audio_avg_bps(int avg_bps)
 {
-    int ret;
-    ret = media_format_set_audio_avg_bps(g_media_format[media_format_idx], avg_bps);
+       int ret;
+       ret = media_format_set_audio_avg_bps(g_media_format[media_format_idx], avg_bps);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_avg_bps is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_avg_bps is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_avg_bps is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_avg_bps is failed...!!\n");
 }
 
 static void _media_format_set_audio_aac_type(bool is_adts)
 {
-    int ret;
-    ret = media_format_set_audio_aac_type(g_media_format[media_format_idx], is_adts);
+       int ret;
+       ret = media_format_set_audio_aac_type(g_media_format[media_format_idx], is_adts);
 
-    if (ret == MEDIA_FORMAT_ERROR_NONE)
-        g_print("media_format_set_audio_aac_type is succeeded!!\n");
-    else
-        g_print("media_format_set_audio_aac_type is failed...!!\n");
+       if (ret == MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_aac_type is succeeded!!\n");
+       else
+               g_print("media_format_set_audio_aac_type is failed...!!\n");
 }
 
 static void _create_format_320_240_es(void)
 {
 
-    if (media_format_create(&g_media_format[1]) == MEDIA_FORMAT_ERROR_NONE)
-    {
-        g_print("media_format_create is succeeded! \n");
-        g_print("the media_format_h[1] is created..\n");
-        int ret = MEDIA_FORMAT_ERROR_NONE;
-        media_format_idx = 1;
-
-        media_format_mimetype_e mime = MEDIA_FORMAT_H264_HP;
-        int w = 320;
-        int h = 240;
-        int avg_bps = 3000000;
-        int max_bps = 15000000;
-        ret = media_format_set_video_mime(g_media_format[1], MEDIA_FORMAT_H264_HP);
-        ret = media_format_set_video_width(g_media_format[1], 320);
-        ret = media_format_set_video_height(g_media_format[1], 240);
-        ret = media_format_set_video_avg_bps(g_media_format[1], 3000000);
-        ret = media_format_set_video_max_bps(g_media_format[1], 15000000);
-        if (ret == MEDIA_FORMAT_ERROR_NONE)
-        {
-            g_print("media_format_set_video_xxx succeed! w:%d, h:%d, 0x%x, avg_bps: %d, max_bps: %d\n", w, h, mime, avg_bps, max_bps);
-            g_print("\t\t\t\t ====>> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[1]));
-        }
-        else
-            g_print("media_format_set_video_xxx failed..\n");
-    }
-    else
-    {
-        g_print("media_format_create failed..\n");
-    }
+       if (media_format_create(&g_media_format[1]) == MEDIA_FORMAT_ERROR_NONE) {
+               g_print("media_format_create is succeeded! \n");
+               g_print("the media_format_h[1] is created..\n");
+               int ret = MEDIA_FORMAT_ERROR_NONE;
+               media_format_idx = 1;
+
+               media_format_mimetype_e mime = MEDIA_FORMAT_H264_HP;
+               int w = 320;
+               int h = 240;
+               int avg_bps = 3000000;
+               int max_bps = 15000000;
+               ret = media_format_set_video_mime(g_media_format[1], MEDIA_FORMAT_H264_HP);
+               ret = media_format_set_video_width(g_media_format[1], 320);
+               ret = media_format_set_video_height(g_media_format[1], 240);
+               ret = media_format_set_video_avg_bps(g_media_format[1], 3000000);
+               ret = media_format_set_video_max_bps(g_media_format[1], 15000000);
+               if (ret == MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_set_video_xxx succeed! w:%d, h:%d, 0x%x, avg_bps: %d, max_bps: %d\n", w, h, mime, avg_bps, max_bps);
+                       g_print("\t\t\t\t ====>> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[1]));
+               } else
+                       g_print("media_format_set_video_xxx failed..\n");
+       } else {
+               g_print("media_format_create failed..\n");
+       }
 
 }
 
-
 static void _create_format_raw(void)
 {
 
-    if (media_format_create(&g_media_format[2]) == MEDIA_FORMAT_ERROR_NONE)
-    {
-        g_print("media_format_create is succeeded! \n");
-        int ret = MEDIA_FORMAT_ERROR_NONE;
-
-        media_format_mimetype_e mime = MEDIA_FORMAT_I420;
-        int w = 128;
-        int h = 128;
-        int avg_bps = 2000000;
-        int max_bps = 15000000;
-        ret = media_format_set_video_mime(g_media_format[2], mime);
-        ret = media_format_set_video_width(g_media_format[2], w);
-        ret = media_format_set_video_height(g_media_format[2], h);
-        ret = media_format_set_video_avg_bps(g_media_format[2], avg_bps);
-        ret = media_format_set_video_max_bps(g_media_format[2], max_bps);
-        if (ret == MEDIA_FORMAT_ERROR_NONE)
-        {
-            g_print("media_format_set_video_xxx success! w:%d, h:%d, 0x%x, avg_bps: %d, max_bps: %d\n", w, h, mime, avg_bps, max_bps);
-            g_print("\t\t\t\t ====>> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
-        }
-        else
-            g_print("media_format_set_video_xxx failed..\n");
-    }
-    else
-    {
-        g_print("media_format_create failed..\n");
-    }
-
+       if (media_format_create(&g_media_format[2]) == MEDIA_FORMAT_ERROR_NONE) {
+               g_print("media_format_create is succeeded! \n");
+               int ret = MEDIA_FORMAT_ERROR_NONE;
+
+               media_format_mimetype_e mime = MEDIA_FORMAT_I420;
+               int w = 128;
+               int h = 128;
+               int avg_bps = 2000000;
+               int max_bps = 15000000;
+               ret = media_format_set_video_mime(g_media_format[2], mime);
+               ret = media_format_set_video_width(g_media_format[2], w);
+               ret = media_format_set_video_height(g_media_format[2], h);
+               ret = media_format_set_video_avg_bps(g_media_format[2], avg_bps);
+               ret = media_format_set_video_max_bps(g_media_format[2], max_bps);
+               if (ret == MEDIA_FORMAT_ERROR_NONE) {
+                       g_print("media_format_set_video_xxx success! w:%d, h:%d, 0x%x, avg_bps: %d, max_bps: %d\n", w, h, mime, avg_bps, max_bps);
+                       g_print("\t\t\t\t ====>> ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
+               } else
+                       g_print("media_format_set_video_xxx failed..\n");
+       } else {
+               g_print("media_format_create failed..\n");
+       }
 
 }
 
-static int _finalize_callback(media_packet_h packet, int err, voiduserdata)
+static int _finalize_callback(media_packet_h packet, int err, void *userdata)
 {
-    g_print("==> finalize callback func is called\n");
-    return MEDIA_PACKET_FINALIZE;
+       g_print("==> finalize callback func is called\n");
+       return MEDIA_PACKET_FINALIZE;
 }
 
 static void _media_packet_create_alloc(void)
 {
-    g_print("=== create_and_alloc!!\n");
-    int i;
-
-    for(i = 0; i < g_handle_num; i++)
-    {
-        if(g_media_packet[i] != NULL)
-        {
-            int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
-            media_packet_destroy(g_media_packet[i]);
-            if (ref_count == 1)
-            {
-                g_media_format[media_format_idx] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
-            }
-            g_media_packet[i] = NULL;
-        }
-
-        if(g_media_format[0] == NULL)
-        {
-            g_print("media_format_h is NULL!! create media_format_h handle \n");
-            break;
-        }
-
-        if (media_packet_create_alloc(g_media_format[0], _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE)
-        {
-            g_print("media_packet create is failed\n");
-        }
-        else
-        {
-            media_format_idx = 0;
-            g_print("succeeded media_packet_create_alloc !!\n");
-            g_print(" ==> media_format_h[0] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-            media_format_unref(g_media_format[0]);
-            g_print(" ====> media_format_unref, media_format_h[0] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-            is_excute_create = true;
-        }
-
-    }
+       g_print("=== create_and_alloc!!\n");
+       int i;
+
+       for (i = 0; i < g_handle_num; i++) {
+               if (g_media_packet[i] != NULL) {
+                       int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       media_packet_destroy(g_media_packet[i]);
+                       if (ref_count == 1) {
+                               g_media_format[media_format_idx] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
+                       }
+                       g_media_packet[i] = NULL;
+               }
+
+               if (g_media_format[0] == NULL) {
+                       g_print("media_format_h is NULL!! create media_format_h handle \n");
+                       break;
+               }
+
+               if (media_packet_create_alloc(g_media_format[0], _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE) {
+                       g_print("media_packet create is failed\n");
+               } else {
+                       media_format_idx = 0;
+                       g_print("succeeded media_packet_create_alloc !!\n");
+                       g_print(" ==> media_format_h[0] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+                       media_format_unref(g_media_format[0]);
+                       g_print(" ====> media_format_unref, media_format_h[0] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+                       is_excute_create = true;
+               }
+
+       }
 }
 
 static void _media_packet_create(void)
 {
-    g_print("=== create!!\n");
-    is_only_created_handle = true;
-    int i;
-
-    for(i = 0; i < g_handle_num; i++)
-    {
-        if(g_media_packet[i] != NULL)
-        {
-            int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
-            media_packet_destroy(g_media_packet[i]);
-            if (ref_count == 1)
-            {
-                g_media_format[media_format_idx] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
-            }
-            g_media_packet[i] = NULL;
-        }
-
-        if(g_media_format[0] == NULL)
-        {
-            g_print("media_format_h is NULL!! create media_format_h handle \n");
-            break;
-        }
-
-        /* only ES format , if you want to another format, see _create_format_es() */
-        if (media_packet_create(g_media_format[0], _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE)
-        {
-            g_print("media_packet create is failed\n");
-        }
-        else
-        {
-            media_format_idx = 0;
-            g_print("media_packet_create is sucess!!\n");
-            g_print(" ==> media_format_h[0] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-            media_format_unref(g_media_format[0]);
-            g_print(" ====> media_format_unref, media_format_h[0] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-            is_excute_create = true;
-        }
-    }
+       g_print("=== create!!\n");
+       is_only_created_handle = true;
+       int i;
+
+       for (i = 0; i < g_handle_num; i++) {
+               if (g_media_packet[i] != NULL) {
+                       int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       media_packet_destroy(g_media_packet[i]);
+                       if (ref_count == 1) {
+                               g_media_format[media_format_idx] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
+                       }
+                       g_media_packet[i] = NULL;
+               }
+
+               if (g_media_format[0] == NULL) {
+                       g_print("media_format_h is NULL!! create media_format_h handle \n");
+                       break;
+               }
+
+               /* only ES format , if you want to another format, see _create_format_es() */
+               if (media_packet_create(g_media_format[0], _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE) {
+                       g_print("media_packet create is failed\n");
+               } else {
+                       media_format_idx = 0;
+                       g_print("media_packet_create is sucess!!\n");
+                       g_print(" ==> media_format_h[0] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+                       media_format_unref(g_media_format[0]);
+                       g_print(" ====> media_format_unref, media_format_h[0] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+                       is_excute_create = true;
+               }
+       }
 }
 
 static void _media_packet_alloc(void)
 {
-    g_print("=== alloc!!\n");
-    if (is_only_created_handle)
-    {
-        if (media_packet_alloc(g_media_packet[0]) == MEDIA_PACKET_ERROR_NONE)
-            g_print("media_packet_alloc is sucess\n");
-        else
-            g_print("media_packet_alloc is failed\n");
-    }
-    else
-    {
-        g_print("*** can not excute!! fisrt excute media_packet_create() before this alloc. \n");
-    }
+       g_print("=== alloc!!\n");
+       if (is_only_created_handle) {
+               if (media_packet_alloc(g_media_packet[0]) == MEDIA_PACKET_ERROR_NONE)
+                       g_print("media_packet_alloc is sucess\n");
+               else
+                       g_print("media_packet_alloc is failed\n");
+       } else {
+               g_print("*** can not excute!! fisrt excute media_packet_create() before this alloc. \n");
+       }
 }
 
 static void _media_packet_create_from_tbm_surface(void)
 {
-    g_print("=== create_from_tbm_surface!!\n");
-
-    tbm_surface_h surface;
-    surface = tbm_surface_create(128, 128, TBM_FORMAT_YUV420);
-
-    if (surface)
-    {
-        int i;
-
-        for(i = 0; i < g_handle_num; i++)
-        {
-            if(g_media_packet[i] != NULL)
-            {
-                int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
-                media_packet_destroy(g_media_packet[i]);
-
-                if (ref_count == 1 )
-                {
-                    g_media_format[media_format_idx] = NULL;
-                    g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
-                }
-
-                g_media_packet[i] = NULL;
-            }
-
-            if(g_media_format[2] == NULL)
-            {
-                g_print("create raw video type media_format_h[2]... \n");
-                _create_format_raw();
-            }
-
-            /* only RAW format , if you want to another format, see _create_format_raw() */
-            if (media_packet_create_from_tbm_surface(g_media_format[2], surface, _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE)
-            {
-                g_print("media_packet_create_from_tbm_surface is failed\n");
-            }
-            else
-            {
-                g_print("media_packet_create_from_tbm_surface is sucess!!\n");
-                g_print(" ==> media_format_h[2] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
-                media_format_unref(g_media_format[2]);
-                g_print(" ====> media_format_unref, media_format_h[2] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
-                media_format_idx = 2;
-                is_excute_create = true;
-            }
-        }
-
-    }
-    else
-    {
-        g_print("tbm_surface_create failed...\n");
-    }
+       g_print("=== create_from_tbm_surface!!\n");
+
+       tbm_surface_h surface;
+       surface = tbm_surface_create(128, 128, TBM_FORMAT_YUV420);
+
+       if (surface) {
+               int i;
+
+               for (i = 0; i < g_handle_num; i++) {
+                       if (g_media_packet[i] != NULL) {
+                               int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                               media_packet_destroy(g_media_packet[i]);
+
+                               if (ref_count == 1) {
+                                       g_media_format[media_format_idx] = NULL;
+                                       g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
+                               }
+
+                               g_media_packet[i] = NULL;
+                       }
+
+                       if (g_media_format[2] == NULL) {
+                               g_print("create raw video type media_format_h[2]... \n");
+                               _create_format_raw();
+                       }
+
+                       /* only RAW format , if you want to another format, see _create_format_raw() */
+                       if (media_packet_create_from_tbm_surface(g_media_format[2], surface, _finalize_callback, NULL, &g_media_packet[i]) != MEDIA_PACKET_ERROR_NONE) {
+                               g_print("media_packet_create_from_tbm_surface is failed\n");
+                       } else {
+                               g_print("media_packet_create_from_tbm_surface is sucess!!\n");
+                               g_print(" ==> media_format_h[2] ref_count =%d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
+                               media_format_unref(g_media_format[2]);
+                               g_print(" ====> media_format_unref, media_format_h[2] ref_count = %d\n", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[2]));
+                               media_format_idx = 2;
+                               is_excute_create = true;
+                       }
+               }
+
+       } else {
+               g_print("tbm_surface_create failed...\n");
+       }
 }
 
 static void _media_packet_copy(void)
 {
-    g_print("=== copy!!\n");
-
-    if (is_excute_create)
-    {
-        if (media_packet_copy(g_media_packet[0], _finalize_callback, NULL, &g_media_packet[1]) == MEDIA_PACKET_ERROR_NONE)
-        {
-            g_print("media_packet_copy sucess !!");
-            is_only_created_handle = true;
-            memset (g_media_packet[0], 0, sizeof(media_packet_s));
-            if(!g_media_packet[1])
-            {
-                g_print("g_media_packet[1] is NULL\n");
-                return;
-            }
-            memcpy (g_media_packet[0], g_media_packet[1], sizeof(media_packet_s));
-            free(g_media_packet[1]);
-            g_media_packet[1] = NULL;
-        }
-        else
-        {
-            g_print("media_packet_copy failed");
-        }
-    }
-    else
-    {
-        g_print("denied... excute create or create_alloc or create_from_surface");
-    }
+       g_print("=== copy!!\n");
+
+       if (is_excute_create) {
+               if (media_packet_copy(g_media_packet[0], _finalize_callback, NULL, &g_media_packet[1]) == MEDIA_PACKET_ERROR_NONE) {
+                       g_print("media_packet_copy sucess !!");
+                       is_only_created_handle = true;
+                       memset(g_media_packet[0], 0, sizeof(media_packet_s));
+                       if (!g_media_packet[1]) {
+                               g_print("g_media_packet[1] is NULL\n");
+                               return;
+                       }
+                       memcpy(g_media_packet[0], g_media_packet[1], sizeof(media_packet_s));
+                       free(g_media_packet[1]);
+                       g_media_packet[1] = NULL;
+               } else {
+                       g_print("media_packet_copy failed");
+               }
+       } else {
+               g_print("denied... excute create or create_alloc or create_from_surface");
+       }
 
 }
 
 static void _media_packet_destroy()
 {
-    g_print("=== destroy!!\n");
-    int i;
-    int ret;
-
-    int ref_count;
-
-    for (i = 0; i < g_handle_num ; i++)
-    {
-        if(g_media_packet[i]!=NULL)
-        {
-            ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
-            ret = media_packet_destroy(g_media_packet[i]);
-            g_media_packet[i] = NULL;
-
-            if (ref_count == 1)
-            {
-                g_media_format[media_format_idx] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
-            }
-
-            if (ret == MEDIA_PACKET_ERROR_NONE)
-            {
-                g_print("media_packet_destroy is succeeded!!\n");
-                if (g_media_format[media_format_idx] != NULL)
-                    g_print(" ==> media_format_h[%d] ref_count = %d\n", media_format_idx, MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]));
-            }
-            else
-                g_print("media_packet_destroy is failed...\n");
-        }
-        else
-            g_print("There is nothing to destroy media_packet_h[%d] handle...\n", i);
-    }
+       g_print("=== destroy!!\n");
+       int i;
+       int ret;
+
+       int ref_count;
+
+       for (i = 0; i < g_handle_num; i++) {
+               if (g_media_packet[i] != NULL) {
+                       ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       ret = media_packet_destroy(g_media_packet[i]);
+                       g_media_packet[i] = NULL;
+
+                       if (ref_count == 1) {
+                               g_media_format[media_format_idx] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
+                       }
+
+                       if (ret == MEDIA_PACKET_ERROR_NONE) {
+                               g_print("media_packet_destroy is succeeded!!\n");
+                               if (g_media_format[media_format_idx] != NULL)
+                                       g_print(" ==> media_format_h[%d] ref_count = %d\n", media_format_idx, MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]));
+                       } else
+                               g_print("media_packet_destroy is failed...\n");
+               } else
+                       g_print("There is nothing to destroy media_packet_h[%d] handle...\n", i);
+       }
 }
 
 static void _media_packet_get_buffer_size(void)
 {
-    uint64_t size;
-    if (media_packet_get_buffer_size(g_media_packet[0],&size) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_buffer_size is sucess!!");
-        g_print("\t\t[media_packet]===> size = %llu\n", size);
-    }
-    else
-    {
-        g_print("media_packet_get_buffer_size is failed...");
-    }
+       uint64_t size;
+       if (media_packet_get_buffer_size(g_media_packet[0], &size) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_buffer_size is sucess!!");
+               g_print("\t\t[media_packet]===> size = %llu\n", size);
+       } else {
+               g_print("media_packet_get_buffer_size is failed...");
+       }
 }
 
 static void _media_packet_get_duration(void)
 {
-    uint64_t duration;
-
-    if (media_packet_get_duration(g_media_packet[0], &duration) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_duration is sucess!!");
-        g_print("\t\t[media_packet]===> duration = %llu\n", duration);
-    }
-    else
-    {
-        g_print("media_packet_get_duration is failed...");
-    }
+       uint64_t duration;
+
+       if (media_packet_get_duration(g_media_packet[0], &duration) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_duration is sucess!!");
+               g_print("\t\t[media_packet]===> duration = %llu\n", duration);
+       } else {
+               g_print("media_packet_get_duration is failed...");
+       }
 }
 
 static void _media_packet_get_buffer_data_ptr(void)
 {
-    void* ptr;
-    media_packet_s* packet = g_media_packet[0];
-    ptr = (void*)malloc(sizeof(packet->size));
-
-    if (ptr)
-        memset(packet, 0, sizeof(packet->size));
-    else
-        g_print("_get_buffer_ptr , malloc failed...");
-
-    if (media_packet_get_buffer_data_ptr(g_media_packet[0], &ptr) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_buffer_data_ptr is sucess!!");
-        g_print("\t\t[media_packet]===> buffer_data_ptr = %p\n", ptr);
-    }
-    else
-    {
-        g_print("media_packet_get_buffer_data_ptr is failed...");
-    }
+       void *ptr;
+       media_packet_s *packet = g_media_packet[0];
+       ptr = (void *)malloc(sizeof(packet->size));
+
+       if (ptr)
+               memset(packet, 0, sizeof(packet->size));
+       else
+               g_print("_get_buffer_ptr , malloc failed...");
+
+       if (media_packet_get_buffer_data_ptr(g_media_packet[0], &ptr) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_buffer_data_ptr is sucess!!");
+               g_print("\t\t[media_packet]===> buffer_data_ptr = %p\n", ptr);
+       } else {
+               g_print("media_packet_get_buffer_data_ptr is failed...");
+       }
 
 }
 
 static void _media_packet_get_tbm_surface()
 {
-    tbm_surface_h tbm_surface;
-
-    if (media_packet_get_tbm_surface(g_media_packet[0], &tbm_surface) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_tbm_surface is sucess!!");
-        g_print("\t\t[media_packet]===> tbm_surface = %p\n", (void*)tbm_surface);
-    }
-    else
-    {
-        g_print("media_packet_get_duration is failed...");
-    }
+       tbm_surface_h tbm_surface;
+
+       if (media_packet_get_tbm_surface(g_media_packet[0], &tbm_surface) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_tbm_surface is sucess!!");
+               g_print("\t\t[media_packet]===> tbm_surface = %p\n", (void *)tbm_surface);
+       } else {
+               g_print("media_packet_get_duration is failed...");
+       }
 }
 
 static void _media_packet_get_number_of_video_planes()
 {
-    uint32_t num = 0;
-    if (media_packet_get_number_of_video_planes(g_media_packet[0], &num)== MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_number_of_video_planes is sucess!!\n");
-        g_print("\t\t[media_packet]===> number of planes = %ld\n", num);
-
-    }
-    else
-    {
-        g_print("media_packet_get_number_of_video_planes is failed...");
-    }
+       uint32_t num = 0;
+       if (media_packet_get_number_of_video_planes(g_media_packet[0], &num) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_number_of_video_planes is sucess!!\n");
+               g_print("\t\t[media_packet]===> number of planes = %ld\n", num);
+
+       } else {
+               g_print("media_packet_get_number_of_video_planes is failed...");
+       }
 }
 
 static void _media_packet_get_video_stride_width()
 {
-    int stride_w;
-    if (media_packet_get_video_stride_width(g_media_packet[0], 0, &stride_w)== MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_video_stride_width is sucess!!\n");
-        g_print("\t\t[media_packet]===> stride width = %d\n", stride_w);
-
-    }
-    else
-    {
-        g_print("media_packet_get_video_stride_width is failed...");
-    }
+       int stride_w;
+       if (media_packet_get_video_stride_width(g_media_packet[0], 0, &stride_w) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_video_stride_width is sucess!!\n");
+               g_print("\t\t[media_packet]===> stride width = %d\n", stride_w);
+
+       } else {
+               g_print("media_packet_get_video_stride_width is failed...");
+       }
 }
 
 static void _media_packet_get_video_stride_height()
 {
-    int stride_h;
-    if (media_packet_get_video_stride_height(g_media_packet[0], 0, &stride_h)== MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_video_stride_height is sucess!!\n");
-        g_print("\t\t[media_packet]===> stride height = %d\n", stride_h);
-
-    }
-    else
-    {
-        g_print("media_packet_get_video_stride_height is failed...");
-    }
+       int stride_h;
+       if (media_packet_get_video_stride_height(g_media_packet[0], 0, &stride_h) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_video_stride_height is sucess!!\n");
+               g_print("\t\t[media_packet]===> stride height = %d\n", stride_h);
+
+       } else {
+               g_print("media_packet_get_video_stride_height is failed...");
+       }
 }
 
 static void _media_packet_get_video_plane_data_ptr()
 {
-    void* ptr;
-    if (media_packet_get_video_plane_data_ptr(g_media_packet[0], 0, &ptr)== MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_video_plane_data_ptr is sucess!!\n");
-        g_print("\t\t[media_packet]===> ptr = %p\n", ptr);
-
-    }
-    else
-    {
-        g_print("_media_packet_get_plane_data_ptr is failed...");
-    }
+       void *ptr;
+       if (media_packet_get_video_plane_data_ptr(g_media_packet[0], 0, &ptr) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_video_plane_data_ptr is sucess!!\n");
+               g_print("\t\t[media_packet]===> ptr = %p\n", ptr);
+
+       } else {
+               g_print("_media_packet_get_plane_data_ptr is failed...");
+       }
 }
 
 static void _media_packet_set_codec_data()
 {
-    if (media_packet_set_codec_data(g_media_packet[0], (void*)codec_data_ptr, codec_data_size) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_set_codec_data is sucess..!\n");
-    }
-    else
-    {
-        g_print("media_packet_set_codec_data is failed...\n");
-    }
+       if (media_packet_set_codec_data(g_media_packet[0], (void *)codec_data_ptr, codec_data_size) == MEDIA_PACKET_ERROR_NONE)
+               g_print("media_packet_set_codec_data is sucess..!\n");
+       else
+               g_print("media_packet_set_codec_data is failed...\n");
 }
 
 static void _media_packet_get_codec_data()
 {
-    unsigned char* get_codec_data;
-    unsigned int get_codec_data_size;
-
-    if (media_packet_get_codec_data(g_media_packet[0], &get_codec_data, &get_codec_data_size) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_codec_data is sucess ... !\n");
-        g_print("codec_data_size = %u\n", get_codec_data_size);
-
-        if (get_codec_data_size == 0)
-            return;
-
-        int i;
-        for (i=0 ; i < get_codec_data_size; i++)
-        {
-            g_print("codec_data[%d] ", i);
-            g_print(" = 0x%x\n", get_codec_data[i]);
-        }
-    }
-    else
-    {
-        g_print("media_packet_get_codec_data is failed...\n");
-    }
+       unsigned char *get_codec_data;
+       unsigned int get_codec_data_size;
+
+       if (media_packet_get_codec_data(g_media_packet[0], &get_codec_data, &get_codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_codec_data is sucess ... !\n");
+               g_print("codec_data_size = %u\n", get_codec_data_size);
+
+               if (get_codec_data_size == 0)
+                       return;
+
+               int i;
+               for (i = 0; i < get_codec_data_size; i++) {
+                       g_print("codec_data[%d] ", i);
+                       g_print(" = 0x%x\n", get_codec_data[i]);
+               }
+       } else {
+               g_print("media_packet_get_codec_data is failed...\n");
+       }
 }
 
 static void _media_packet_set_duration(uint64_t duration)
 {
-    if (media_packet_set_duration(g_media_packet[0], duration) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_set_duration is sucess!!\n");
-    }
-    else
-    {
-        g_print("media_packet_set_duration is failed..\n");
-    }
+       if (media_packet_set_duration(g_media_packet[0], duration) == MEDIA_PACKET_ERROR_NONE)
+               g_print("media_packet_set_duration is sucess!!\n");
+       else
+               g_print("media_packet_set_duration is failed..\n");
 }
 
 static void _media_packet_is_video(void)
 {
-    bool is_video;
-    if (media_packet_is_video(g_media_packet[0], &is_video) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_is_video is sucess!!\n");
-        g_print("\t\t[media_packet]===> is_video = %d", is_video);
-    }
-    else
-    {
-        g_print("media_packet_is_video is failed...");
-    }
+       bool is_video;
+       if (media_packet_is_video(g_media_packet[0], &is_video) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_is_video is sucess!!\n");
+               g_print("\t\t[media_packet]===> is_video = %d", is_video);
+       } else {
+               g_print("media_packet_is_video is failed...");
+       }
 }
 
 static void _media_packet_is_audio(void)
 {
-    bool is_audio;
-    if (media_packet_is_audio(g_media_packet[0], &is_audio) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_is_audio is sucess!!\n");
-        g_print("\t\t[media_packet]===> is_audio = %d", is_audio);
-    }
-    else
-    {
-        g_print("media_packet_is_audio is failed...");
-    }
+       bool is_audio;
+       if (media_packet_is_audio(g_media_packet[0], &is_audio) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_is_audio is sucess!!\n");
+               g_print("\t\t[media_packet]===> is_audio = %d", is_audio);
+       } else {
+               g_print("media_packet_is_audio is failed...");
+       }
 }
 
 static void _media_packet_is_encoded(void)
 {
-    bool is_encoded;
-    if (media_packet_is_encoded(g_media_packet[0], &is_encoded) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_is_encoded is sucess!!\n");
-        g_print("\t\t[media_packet]===> is_encoded = %d", is_encoded);
-    }
-    else
-    {
-        g_print("media_packet_is_encoded is failed...");
-    }
+       bool is_encoded;
+       if (media_packet_is_encoded(g_media_packet[0], &is_encoded) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_is_encoded is sucess!!\n");
+               g_print("\t\t[media_packet]===> is_encoded = %d", is_encoded);
+       } else {
+               g_print("media_packet_is_encoded is failed...");
+       }
 
 }
+
 static void _media_packet_is_raw(void)
 {
-    bool is_raw;
-    if (media_packet_is_raw(g_media_packet[0], &is_raw) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_is_raw is sucess!!\n");
-        g_print("\t\t[media_packet]===> is_raw = %d", is_raw);
-    }
-    else
-    {
-        g_print("media_packet_is_raw is failed...");
-    }
+       bool is_raw;
+       if (media_packet_is_raw(g_media_packet[0], &is_raw) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_is_raw is sucess!!\n");
+               g_print("\t\t[media_packet]===> is_raw = %d", is_raw);
+       } else {
+               g_print("media_packet_is_raw is failed...");
+       }
 
 }
 
 static void _media_packet_get_format(void)
 {
-    media_format_h fmt;
-    if (media_packet_get_format(g_media_packet[0], &fmt) == MEDIA_PACKET_ERROR_NONE)
-    {
-        int w;
-        int h;
-
-        int channel;
-        int samplerate;
-        int bit;
-        int audio_avg_bps;
-
-        g_print("media_packet_get_format is sucess! %p \n", fmt);
-
-        if (MEDIA_FORMAT_IS_VIDEO(fmt))
-        {
-            if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE)
-            {
-                g_print("\t\t [media_format] width = %d, height =%d", w, h);
-            }
-            else
-            {
-                g_print("media_format_get_video is failed...");
-            }
-        }
-        else if (MEDIA_FORMAT_IS_AUDIO(fmt))
-        {
-             if (media_format_get_audio_info(fmt, NULL, &channel, &samplerate, &bit, &audio_avg_bps) == MEDIA_PACKET_ERROR_NONE)
-            {
-                g_print("\t\t [media_format] channel = %d, samplerate = %d, bit = %d, avg_bps = %d", channel, samplerate, bit, audio_avg_bps);
-            }
-            else
-            {
-                g_print("media_format_get_video is failed...");
-            }
-        }
-
-    }
-    else
-    {
-        g_print("media_packet_get_format is failed...");
-    }
+       media_format_h fmt;
+       if (media_packet_get_format(g_media_packet[0], &fmt) == MEDIA_PACKET_ERROR_NONE) {
+               int w;
+               int h;
+
+               int channel;
+               int samplerate;
+               int bit;
+               int audio_avg_bps;
+
+               g_print("media_packet_get_format is sucess! %p \n", fmt);
+
+               if (MEDIA_FORMAT_IS_VIDEO(fmt)) {
+                       if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE)
+                               g_print("\t\t [media_format] width = %d, height =%d", w, h);
+                       else
+                       g_print("media_format_get_video is failed...");
+               } else if (MEDIA_FORMAT_IS_AUDIO(fmt)) {
+                       if (media_format_get_audio_info(fmt, NULL, &channel, &samplerate, &bit, &audio_avg_bps) == MEDIA_PACKET_ERROR_NONE)
+                               g_print("\t\t [media_format] channel = %d, samplerate = %d, bit = %d, avg_bps = %d", channel, samplerate, bit, audio_avg_bps);
+                       else
+                               g_print("media_format_get_video is failed...");
+               }
+
+       } else {
+               g_print("media_packet_get_format is failed...");
+       }
 
 }
 
-
 static void _media_packet_set_format(media_format_h fmt)
 {
-    if (media_packet_set_format(g_media_packet[0], fmt) == MEDIA_PACKET_ERROR_NONE)
-    {
-        media_format_unref(fmt);
-        g_print("media_packet_set_format is sucess!\n");
-    }
-    else
-    {
-        g_print("media_packet_get_format is failed...");
-    }
+       if (media_packet_set_format(g_media_packet[0], fmt) == MEDIA_PACKET_ERROR_NONE) {
+               media_format_unref(fmt);
+               g_print("media_packet_set_format is sucess!\n");
+       } else {
+               g_print("media_packet_get_format is failed...");
+       }
 
 }
 
 static void _media_packet_set_extra(void)
 {
-    char* extra = "extra";
-
-    if (media_packet_set_extra(g_media_packet[0], (void*)extra) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_set_extra is sucess!\n");
-    }
-    else
-    {
-        g_print("media_packet_set_extra is failed...");
-    }
+       char *extra = "extra";
 
+       if (media_packet_set_extra(g_media_packet[0], (void *)extra) == MEDIA_PACKET_ERROR_NONE)
+               g_print("media_packet_set_extra is sucess!\n");
+       else
+               g_print("media_packet_set_extra is failed...");
 }
 
 static void _media_packet_get_extra(void)
 {
-    void* extra;
-
-    if (media_packet_get_extra(g_media_packet[0], &extra) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_get_extra is sucess!\n");
-        g_print("\t\t extra = %s\n", (char*)extra);
-    }
-    else
-    {
-        g_print("media_packet_get_extra is failed...");
-    }
+       void *extra;
+
+       if (media_packet_get_extra(g_media_packet[0], &extra) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_get_extra is sucess!\n");
+               g_print("\t\t extra = %s\n", (char *)extra);
+       } else {
+               g_print("media_packet_get_extra is failed...");
+       }
 
 }
 
 static void _media_packet_has_tbm_surface_buffer(void)
 {
-    bool has_tbm;
-
-    if (media_packet_has_tbm_surface_buffer(g_media_packet[0], &has_tbm) == MEDIA_PACKET_ERROR_NONE)
-    {
-        g_print("media_packet_has_tbm_surface_buffer is sucess! \n");
-        g_print("\t\t has_tbm_surface_buffer = %d \n", has_tbm);
-    }
-    else
-    {
-        g_print("media_packet_has_tbm_surface_buffer is failed! \n");
-    }
+       bool has_tbm;
+
+       if (media_packet_has_tbm_surface_buffer(g_media_packet[0], &has_tbm) == MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_has_tbm_surface_buffer is sucess! \n");
+               g_print("\t\t has_tbm_surface_buffer = %d \n", has_tbm);
+       } else {
+               g_print("media_packet_has_tbm_surface_buffer is failed! \n");
+       }
 }
 
 static void _media_format_get_video_info(void)
 {
-    media_format_mimetype_e mime;
-    int w = 0;
-    int h = 0;
-    int avg_bps = 0;
-    int max_bps = 0;
-
-    if (media_format_get_video_info(g_media_format[0], &mime, &w, &h, &avg_bps, &max_bps) == MEDIA_FORMAT_ERROR_NONE)
-    {
-        g_print("media_format_get_video is sucess!\n");
-        g_print("\t\t[media_format_get_video]mime:0x%x, width :%d, height :%d\n", mime, w, h);
-        g_print("packet format ref_count: %d", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-    }
-    else
-    {
-        g_print("media_format_get_video is failed..");
-    }
+       media_format_mimetype_e mime;
+       int w = 0;
+       int h = 0;
+       int avg_bps = 0;
+       int max_bps = 0;
+
+       if (media_format_get_video_info(g_media_format[0], &mime, &w, &h, &avg_bps, &max_bps) == MEDIA_FORMAT_ERROR_NONE) {
+               g_print("media_format_get_video is sucess!\n");
+               g_print("\t\t[media_format_get_video]mime:0x%x, width :%d, height :%d\n", mime, w, h);
+               g_print("packet format ref_count: %d", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+       } else {
+               g_print("media_format_get_video is failed..");
+       }
 }
 
 static void _media_format_get_audio_info(void)
 {
-    media_format_mimetype_e mime;
-    int channel = 0;
-    int samplerate = 0;
-    int bit = 0;
-    int avg_bps = 0;
-
-    if (media_format_get_audio_info(g_media_format[0], &mime, &channel, &samplerate, &bit, &avg_bps)== MEDIA_FORMAT_ERROR_NONE)
-    {
-        g_print("media_format_get_audio_info is sucess!\n");
-        g_print("\t\t[media_format_get_audio_info]mime:0x%x, channel :%d, samplerate :%d, bit: %d, avg_bps:%d, is_adts:%d \n", mime, channel, samplerate, bit, avg_bps);
-        g_print("packet format ref_count: %d", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
-    }
-    else
-    {
-        g_print("media_format_get_audio_info is failed..");
-    }
+       media_format_mimetype_e mime;
+       int channel = 0;
+       int samplerate = 0;
+       int bit = 0;
+       int avg_bps = 0;
+
+       if (media_format_get_audio_info(g_media_format[0], &mime, &channel, &samplerate, &bit, &avg_bps) == MEDIA_FORMAT_ERROR_NONE) {
+               g_print("media_format_get_audio_info is sucess!\n");
+               g_print("\t\t[media_format_get_audio_info]mime:0x%x, channel :%d, samplerate :%d, bit: %d, avg_bps:%d, is_adts:%d \n", mime, channel, samplerate, bit, avg_bps);
+               g_print("packet format ref_count: %d", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0]));
+       } else {
+               g_print("media_format_get_audio_info is failed..");
+       }
 }
 
-
 /***********************************************/
 /***  Test suit frame API part
 /***********************************************/
 static int _create_app(void *data)
 {
-    printf("media_packet_test is started!\n");
-    return 0;
+       printf("media_packet_test is started!\n");
+       return 0;
 }
 
 static int _terminate_app(void *data)
 {
-    printf("media_packet_test is terminated!\n");
-    return 0;
+       printf("media_packet_test is terminated!\n");
+       return 0;
 }
 
-
 struct appcore_ops ops = {
-    .create = _create_app,
-    .terminate = _terminate_app,
+       .create = _create_app,
+       .terminate = _terminate_app,
 };
 
 void reset_menu_state()
 {
-    g_menu_state = CURRENT_STATUS_MAINMENU;
+       g_menu_state = CURRENT_STATUS_MAINMENU;
 }
 
 void quit_program(void)
 {
-    int i = 0;
-    int ref_count;
-
-    for (i = 0; i < g_handle_num; i++)
-    {
-        if(g_media_packet[i] != NULL)
-        {
-            ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
-            media_packet_destroy(g_media_packet[i]);
-            g_media_packet[i] = NULL;
-            if (ref_count == 1)
-            {
-                g_media_format[media_format_idx] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
-            }
-        }
-    }
-
-
-    for (i = 0; i < MEDIA_FORMAT_MAX_HANDLE; i++)
-    {
-        if (g_media_format[i] != NULL)
-        {
-            int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[i]);
-            g_print("media_format_h[%d] ref_count:%d. excute media_format_unref().\n", i, ref_count);
-
-            if (ref_count == 1)
-            {
-                media_format_unref(g_media_format[i]);
-                g_media_format[i] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", i);
-            }
-            else
-            {
-
-                int j = 1;
-                for (j = 1; j <= ref_count; j++)
-                {
-                    g_print("(%d) media_format_unref\n", j);
-                    media_format_unref(g_media_format[i]);
-
-                }
-                g_media_format[i] = NULL;
-                g_print("media_format_h[%d] is destroyed...\n", i);
-            }
-
-        }
-    }
-
-    elm_exit();
+       int i = 0;
+       int ref_count;
+
+       for (i = 0; i < g_handle_num; i++) {
+               if (g_media_packet[i] != NULL) {
+                       ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[media_format_idx]);
+                       media_packet_destroy(g_media_packet[i]);
+                       g_media_packet[i] = NULL;
+                       if (ref_count == 1) {
+                               g_media_format[media_format_idx] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", media_format_idx);
+                       }
+               }
+       }
+
+       for (i = 0; i < MEDIA_FORMAT_MAX_HANDLE; i++) {
+               if (g_media_format[i] != NULL) {
+                       int ref_count = MEDIA_FORMAT_GET_REFCOUNT(g_media_format[i]);
+                       g_print("media_format_h[%d] ref_count:%d. excute media_format_unref().\n", i, ref_count);
+
+                       if (ref_count == 1) {
+                               media_format_unref(g_media_format[i]);
+                               g_media_format[i] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", i);
+                       } else {
+
+                               int j = 1;
+                               for (j = 1; j <= ref_count; j++) {
+                                       g_print("(%d) media_format_unref\n", j);
+                                       media_format_unref(g_media_format[i]);
+
+                               }
+                               g_media_format[i] = NULL;
+                               g_print("media_format_h[%d] is destroyed...\n", i);
+                       }
+
+               }
+       }
+
+       elm_exit();
 }
 
 void _interpret_main_menu(char *cmd)
 {
-    int len =  strlen(cmd);
-    if (len == 1)
-    {
-        if (strncmp(cmd, "a", 1) == 0)
-        {
-            _media_packet_create_alloc();
-        }
-        else if (strncmp(cmd, "d", 1) == 0)
-        {
-            _media_packet_destroy();
-        }
-        else if (strncmp(cmd, "b", 1) == 0)
-        {
-            _media_packet_create_from_tbm_surface();
-        }
-        else if (strncmp(cmd, "c", 1) == 0)
-        {
-            _media_packet_copy();
-        }
-        else if (strncmp(cmd, "q", 1) == 0)
-        {
-            quit_program();
-        }
-    }
-    else if (len == 2)
-    {
-        if (strncmp(cmd, "aa", 2) == 0)
-        {
-            _media_packet_create();
-        }
-        else if (strncmp(cmd, "ab", 2) == 0)
-        {
-            _media_packet_alloc();
-        }
-        else if (strncmp(cmd, "iv", 2) == 0)
-        {
-            _media_packet_is_video();
-        }
-        else if (strncmp(cmd, "ia", 2) == 0)
-        {
-            _media_packet_is_audio();
-        }
-        else if (strncmp(cmd, "ie", 2) == 0)
-        {
-            _media_packet_is_encoded();
-        }
-        else if (strncmp(cmd, "ir", 2) == 0)
-        {
-            _media_packet_is_raw();
-        }
-        else if (strncmp(cmd, "gd", 2) == 0)
-        {
-            _media_packet_get_duration();
-        }
-        else if (strncmp(cmd, "sd", 2) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_DURATION;
-        }
-        else if (strncmp(cmd, "gf", 2) == 0)
-        {
-            _media_packet_get_format();
-        }
-        else if (strncmp(cmd, "gs", 2) == 0)
-        {
-            _media_packet_get_buffer_size();
-        }
-        else if (strncmp(cmd, "sf", 2) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_PACKET_SET_FORMAT;
-        }
-        else if (strncmp(cmd, "se", 2) == 0)
-        {
-            _media_packet_set_extra();
-        }
-        else if (strncmp(cmd, "ge", 2) == 0)
-        {
-            _media_packet_get_extra();
-        }
-        else if (strncmp(cmd, "ht", 2) == 0)
-        {
-            _media_packet_has_tbm_surface_buffer();
-        }
-        else if (strncmp(cmd, "cf", 2) == 0)
-        {
-            _media_format_create();
-        }
-
-    }
-    else if (len == 3)
-    {
-        if (strncmp(cmd, "gbp", 3) == 0)
-        {
-            _media_packet_get_buffer_data_ptr();
-        }
-        else if (strncmp(cmd, "gts", 3) == 0)
-        {
-            _media_packet_get_tbm_surface();
-        }
-        else if (strncmp(cmd, "fgv", 3) == 0)
-        {
-            _media_format_get_video_info();
-        }
-        else if (strncmp(cmd, "fga", 3) == 0)
-        {
-            _media_format_get_audio_info();
-        }
-        else if (strncmp(cmd, "svm", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_MIME;
-        }
-        else if (strncmp(cmd, "svw", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH;
-        }
-        else if (strncmp(cmd, "svh", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT;
-        }
-        else if (strncmp(cmd, "sam", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_MIME;
-        }
-        else if (strncmp(cmd, "sac", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL;
-        }
-        else if (strncmp(cmd, "sas", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE;
-        }
-        else if (strncmp(cmd, "sab", 3) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_BIT;
-        }
-        else if (strncmp(cmd, "gnp", 3) == 0)
-        {
-            _media_packet_get_number_of_video_planes();
-        }
-        else if (strncmp(cmd, "gsw", 3) == 0)
-        {
-            _media_packet_get_video_stride_width();
-        }
-        else if (strncmp(cmd, "gsh", 3) == 0)
-        {
-            _media_packet_get_video_stride_height();
-        }
-        else if (strncmp(cmd, "gpp", 3) == 0)
-        {
-            _media_packet_get_video_plane_data_ptr();
-        }
-        else if (strncmp(cmd, "scd", 3) == 0)
-        {
-            _media_packet_set_codec_data();
-        }
-        else if (strncmp(cmd, "gcd", 3) == 0)
-        {
-            _media_packet_get_codec_data();
-        }
-
-    }
-    else if (len == 4)
-    {
-        if (strncmp(cmd, "fraw", 4) == 0)
-        {
-            _create_format_raw();
-        }
-        else if (strncmp(cmd, "fes2", 4) == 0)
-        {
-            _create_format_320_240_es();
-        }
-        else if (strncmp(cmd, "svab", 4) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS;
-        }
-        else if (strncmp(cmd, "svmb", 4) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS;
-        }
-        else if (strncmp(cmd, "saab", 4) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS;
-        }
-        else if (strncmp(cmd, "saat", 4) == 0)
-        {
-            g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE;
-        }
-    }
-
+       int len = strlen(cmd);
+       if (len == 1) {
+               if (strncmp(cmd, "a", 1) == 0)
+                       _media_packet_create_alloc();
+               else if (strncmp(cmd, "d", 1) == 0)
+                       _media_packet_destroy();
+               else if (strncmp(cmd, "b", 1) == 0)
+                       _media_packet_create_from_tbm_surface();
+               else if (strncmp(cmd, "c", 1) == 0)
+                       _media_packet_copy();
+               else if (strncmp(cmd, "q", 1) == 0)
+                       quit_program();
+
+       } else if (len == 2) {
+               if (strncmp(cmd, "aa", 2) == 0)
+                       _media_packet_create();
+               else if (strncmp(cmd, "ab", 2) == 0)
+                       _media_packet_alloc();
+               else if (strncmp(cmd, "iv", 2) == 0)
+                       _media_packet_is_video();
+               else if (strncmp(cmd, "ia", 2) == 0)
+                       _media_packet_is_audio();
+               else if (strncmp(cmd, "ie", 2) == 0)
+                       _media_packet_is_encoded();
+               else if (strncmp(cmd, "ir", 2) == 0)
+                       _media_packet_is_raw();
+               else if (strncmp(cmd, "gd", 2) == 0)
+                       _media_packet_get_duration();
+               else if (strncmp(cmd, "sd", 2) == 0)
+                       g_menu_state = CURRENT_STATUS_DURATION;
+               else if (strncmp(cmd, "gf", 2) == 0)
+                       _media_packet_get_format();
+               else if (strncmp(cmd, "gs", 2) == 0)
+                       _media_packet_get_buffer_size();
+               else if (strncmp(cmd, "sf", 2) == 0)
+                       g_menu_state = CURRENT_STATUS_PACKET_SET_FORMAT;
+               else if (strncmp(cmd, "se", 2) == 0)
+                       _media_packet_set_extra();
+               else if (strncmp(cmd, "ge", 2) == 0)
+                       _media_packet_get_extra();
+               else if (strncmp(cmd, "ht", 2) == 0)
+                       _media_packet_has_tbm_surface_buffer();
+               else if (strncmp(cmd, "cf", 2) == 0)
+                       _media_format_create();
+
+       } else if (len == 3) {
+               if (strncmp(cmd, "gbp", 3) == 0)
+                       _media_packet_get_buffer_data_ptr();
+               else if (strncmp(cmd, "gts", 3) == 0)
+                       _media_packet_get_tbm_surface();
+               else if (strncmp(cmd, "fgv", 3) == 0)
+                       _media_format_get_video_info();
+               else if (strncmp(cmd, "fga", 3) == 0)
+                       _media_format_get_audio_info();
+               else if (strncmp(cmd, "svm", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_MIME;
+               else if (strncmp(cmd, "svw", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH;
+               else if (strncmp(cmd, "svh", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT;
+               else if (strncmp(cmd, "sam", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_MIME;
+               else if (strncmp(cmd, "sac", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL;
+               else if (strncmp(cmd, "sas", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE;
+               else if (strncmp(cmd, "sab", 3) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_BIT;
+               else if (strncmp(cmd, "gnp", 3) == 0)
+                       _media_packet_get_number_of_video_planes();
+               else if (strncmp(cmd, "gsw", 3) == 0)
+                       _media_packet_get_video_stride_width();
+               else if (strncmp(cmd, "gsh", 3) == 0)
+                       _media_packet_get_video_stride_height();
+               else if (strncmp(cmd, "gpp", 3) == 0)
+                       _media_packet_get_video_plane_data_ptr();
+               else if (strncmp(cmd, "scd", 3) == 0)
+                       _media_packet_set_codec_data();
+               else if (strncmp(cmd, "gcd", 3) == 0)
+                       _media_packet_get_codec_data();
+
+       } else if (len == 4) {
+               if (strncmp(cmd, "fraw", 4) == 0)
+                       _create_format_raw();
+               else if (strncmp(cmd, "fes2", 4) == 0)
+                       _create_format_320_240_es();
+               else if (strncmp(cmd, "svab", 4) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS;
+               else if (strncmp(cmd, "svmb", 4) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS;
+               else if (strncmp(cmd, "saab", 4) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS;
+               else if (strncmp(cmd, "saat", 4) == 0)
+                       g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE;
+       }
 
 }
 
 static void displaymenu(void)
 {
-    if (g_menu_state == CURRENT_STATUS_MAINMENU)
-    {
-        display_sub_basic();
-    }
-    else if (g_menu_state == CURRENT_STATUS_PACKET_SET_FORMAT)
-    {
-        g_print("*** choose format.\n");
-        g_print("1. 320x240 , MEDIA_FORMAT_H264_HP\n");
-        g_print("2. 128x128 , MEDIA_FORMAT_I420\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_DURATION)
-    {
-        g_print("*** input duration: \n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_MIME)
-    {
-        g_print("choose video media format mime type\n");
-        g_print("0. MEDIA_FORMAT_H264_HP\n");
-        g_print("1. MEDIA_FORMAT_RGB888\n");
-        g_print("2. MEDIA_FORMAT_I420\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH)
-    {
-        g_print("input video width:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT)
-    {
-        g_print("input video height:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS)
-    {
-        g_print("input video avg_bps:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS)
-    {
-        g_print("input video max_bps:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_MIME)
-    {
-        g_print("choose audio media format mime type\n");
-        g_print("0. MEDIA_FORMAT_AMR\n");
-        g_print("1. MEDIA_FORMAT_PCM\n");
-        g_print("2. MEDIA_FORMAT_AAC\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL)
-    {
-        g_print("input audio channel:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE)
-    {
-       g_print("input audio sample rate:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_BIT)
-    {
-        g_print("input audio bit:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS)
-    {
-        g_print("input audio average bps:\n");
-    }
-    else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE)
-    {
-        g_print("input audio aac type (0 or 1):\n");
-    }
-    else
-    {
-        g_print("*** unknown status.\n");
-        quit_program();
-    }
-    g_print(" >>> ");
+       if (g_menu_state == CURRENT_STATUS_MAINMENU) {
+               display_sub_basic();
+       } else if (g_menu_state == CURRENT_STATUS_PACKET_SET_FORMAT) {
+               g_print("*** choose format.\n");
+               g_print("1. 320x240 , MEDIA_FORMAT_H264_HP\n");
+               g_print("2. 128x128 , MEDIA_FORMAT_I420\n");
+       } else if (g_menu_state == CURRENT_STATUS_DURATION) {
+               g_print("*** input duration: \n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_MIME) {
+               g_print("choose video media format mime type\n");
+               g_print("0. MEDIA_FORMAT_H264_HP\n");
+               g_print("1. MEDIA_FORMAT_RGB888\n");
+               g_print("2. MEDIA_FORMAT_I420\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH) {
+               g_print("input video width:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT) {
+               g_print("input video height:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS) {
+               g_print("input video avg_bps:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS) {
+               g_print("input video max_bps:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_MIME) {
+               g_print("choose audio media format mime type\n");
+               g_print("0. MEDIA_FORMAT_AMR\n");
+               g_print("1. MEDIA_FORMAT_PCM\n");
+               g_print("2. MEDIA_FORMAT_AAC\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL) {
+               g_print("input audio channel:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE) {
+               g_print("input audio sample rate:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_BIT) {
+               g_print("input audio bit:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS) {
+               g_print("input audio average bps:\n");
+       } else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE) {
+               g_print("input audio aac type (0 or 1):\n");
+       } else {
+               g_print("*** unknown status.\n");
+               quit_program();
+       }
+       g_print(" >>> ");
 }
 
-
-gboolean timeout_menu_display(void* data)
+gboolean timeout_menu_display(void *data)
 {
-    displaymenu();
-    return FALSE;
+       displaymenu();
+       return FALSE;
 }
 
-static void interpret (char *cmd)
+static void interpret(char *cmd)
 {
-    switch (g_menu_state)
-    {
-        case CURRENT_STATUS_MAINMENU:
-            {
-                _interpret_main_menu(cmd);
-            }
-            break;
-        case CURRENT_STATUS_PACKET_SET_FORMAT:
-            {
-                int num = atoi(cmd);
-                switch (num)
-                 {
-                    case 1:
-                        if(g_media_format[1])
-                        {
-                            _media_packet_set_format(g_media_format[1]);
-                        }
-                        else
-                        {
-                            _create_format_320_240_es();
-                            _media_packet_set_format(g_media_format[1]);
-                        }
-                        break;
-                    case 2:
-                        if(g_media_format[2])
-                        {
-                            _media_packet_set_format(g_media_format[2]);
-                        }
-                        else
-                        {
-                            _create_format_raw();
-                            _media_packet_set_format(g_media_format[2]);
-                        }
-                        break;
-                    default:
-                        g_print("invalid number..");
-
-
-                 }
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_VIDEO_MIME:
-            {
-                int video_mime_idx = atoi(cmd);
-                _media_format_set_video_mime(video_mime_idx);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH:
-            {
-                int width = atoi(cmd);
-                _media_format_set_video_width(width);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT:
-            {
-                int height = atoi(cmd);
-                _media_format_set_video_height(height);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS:
-            {
-                int video_avg_bps = atoi(cmd);
-                _media_format_set_video_avg_bps(video_avg_bps);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS:
-            {
-                int max_bps = atoi(cmd);
-                _media_format_set_video_max_bps(max_bps);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_MIME:
-            {
-                int audio_mime_idx = atoi(cmd);
-                _media_format_set_audio_mime(audio_mime_idx);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL:
-            {
-                int channel = atoi(cmd);
-                _media_format_set_audio_channel(channel);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE:
-            {
-                int samplerate = atoi(cmd);
-                _media_format_set_audio_samplerate(samplerate);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_BIT:
-            {
-                int bit = atoi(cmd);
-                _media_format_set_audio_bit(bit);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS:
-            {
-                int audio_avg_bps = atoi(cmd);
-                _media_format_set_audio_avg_bps(audio_avg_bps);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE:
-            {
-                bool is_ats = atoi(cmd);
-                _media_format_set_audio_aac_type(is_ats);
-                reset_menu_state();
-            }
-            break;
-        case CURRENT_STATUS_DURATION:
-            {
-                uint64_t duration = (uint64_t)atoi(cmd);
-                _media_packet_set_duration(duration);
-                reset_menu_state();
-            }
-    }
-
-    g_timeout_add(100, timeout_menu_display, 0);
+       switch (g_menu_state) {
+       case CURRENT_STATUS_MAINMENU:
+               {
+                       _interpret_main_menu(cmd);
+               }
+               break;
+       case CURRENT_STATUS_PACKET_SET_FORMAT:
+               {
+                       int num = atoi(cmd);
+                       switch (num) {
+                       case 1:
+                               if (g_media_format[1]) {
+                                       _media_packet_set_format(g_media_format[1]);
+                               } else {
+                                       _create_format_320_240_es();
+                                       _media_packet_set_format(g_media_format[1]);
+                               }
+                               break;
+                       case 2:
+                               if (g_media_format[2]) {
+                                       _media_packet_set_format(g_media_format[2]);
+                               } else {
+                                       _create_format_raw();
+                                       _media_packet_set_format(g_media_format[2]);
+                               }
+                               break;
+                       default:
+                               g_print("invalid number..");
+
+                       }
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_VIDEO_MIME:
+               {
+                       int video_mime_idx = atoi(cmd);
+                       _media_format_set_video_mime(video_mime_idx);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_VIDEO_WIDTH:
+               {
+                       int width = atoi(cmd);
+                       _media_format_set_video_width(width);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_VIDEO_HEIGHT:
+               {
+                       int height = atoi(cmd);
+                       _media_format_set_video_height(height);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_VIDEO_AVG_BPS:
+               {
+                       int video_avg_bps = atoi(cmd);
+                       _media_format_set_video_avg_bps(video_avg_bps);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_VIDEO_MAX_BPS:
+               {
+                       int max_bps = atoi(cmd);
+                       _media_format_set_video_max_bps(max_bps);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_MIME:
+               {
+                       int audio_mime_idx = atoi(cmd);
+                       _media_format_set_audio_mime(audio_mime_idx);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_CHANNEL:
+               {
+                       int channel = atoi(cmd);
+                       _media_format_set_audio_channel(channel);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE:
+               {
+                       int samplerate = atoi(cmd);
+                       _media_format_set_audio_samplerate(samplerate);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_BIT:
+               {
+                       int bit = atoi(cmd);
+                       _media_format_set_audio_bit(bit);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS:
+               {
+                       int audio_avg_bps = atoi(cmd);
+                       _media_format_set_audio_avg_bps(audio_avg_bps);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE:
+               {
+                       bool is_ats = atoi(cmd);
+                       _media_format_set_audio_aac_type(is_ats);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_DURATION:
+               {
+                       uint64_t duration = (uint64_t) atoi(cmd);
+                       _media_packet_set_duration(duration);
+                       reset_menu_state();
+               }
+       }
+
+       g_timeout_add(100, timeout_menu_display, 0);
 }
 
 void display_sub_basic()
 {
-    g_print("\n");
-    g_print("=========================================================================================\n");
-    g_print("                                    media tool test\n");
-    g_print("-----------------------------------------------------------------------------------------\n");
-    g_print(" *** How to use ***\n");
-    g_print(" : You can create 1 media_format_h handle by 'cf' and 1 media_packet_handle \n");
-    g_print(" : ex) cf > svm > svw > svh > svab > svmb >fgv > > a > iv > ir ...> d\n");
-    g_print(" : media_format_create is set to 'media_format_h[0]' \n");
-    g_print(" : media_packet_create_alloc & media_packet_create use 'media_format_h[0]' \n");
-    g_print(" : media_packet_create_from_tbm_surface use 'media_format_h[2]' \n");
-    g_print("\n");
-    g_print("cf. media_format_create\t\t");
-    g_print("\n");
-    g_print("svm. media_format_set_video_mime\t");
-    g_print("svw. media_format_set_video_width\t");
-    g_print("svh. media_format_set_video_height\t");
-    g_print("svab. media_format_set_video_avg_bps\t");
-    g_print("svmb. media_format_set_video_max_bps\t");
-    g_print("\n");
-    g_print("sam. media_format_set_audio_mime\t");
-    g_print("sac. media_format_set_audio_channel\t");
-    g_print("sas. media_format_set_audio_samplerate\t");
-    g_print("sab. media_format_set_audio_bit \t");
-    g_print("saab. media_format_set_audio_avg_bps\t");
-    g_print("saat. media_format_set_audio_aac_type\t");
-    g_print("\n");
-    g_print("fgv. media_format_get_video_info \t");
-    g_print("fga. media_format_get_audio_info \t\t");
-    g_print("\n");
-    g_print("\n");
-    g_print("a. media_packet_create_alloc(+media_format_unref)  \t");
-    g_print("aa. media_packet_create(+media_format_unref) \t");
-    g_print("b. media_packet_create_from_tbm_surface(+media_format_unref) \n");
-    g_print("ab. media_packet_alloc \t\t");
-    g_print("c. media_packet_copy  \t");
-    g_print("\n");
-    g_print("\n");
-    g_print("iv. media_packet_is_video \t");
-    g_print("ia. media_packet_is_audio \t");
-    g_print("ie. media_packet_is_encoded \t");
-    g_print("ir. media_packet_is_raw \t");
-    g_print("ht. media_packet_has_tbm_surface_buffer \t");
-    g_print("\n");
-    g_print("sd. media_packet_set_duration \t");
-    g_print("sf. media_packet_set_format(+media_format_unref) \t");
-    g_print("se. media_packet_set_extra \t");
-    g_print("\n");
-    g_print("gd. media_packet_get_duration \t");
-    g_print("gbp. media_packet_get_buffer_data_ptr \t");
-    g_print("gts. media_packet_get_tbm_surface \t");
-    g_print("gf. media_packet_get_format \t");
-    g_print("ge. media_packet_get_extra \t");
-    g_print("\n");
-    g_print("gs. media_packet_get_buffer_size\t");
-    g_print("\n");
-    g_print("gnp. media_packet_get_number_of_video_planes\t");
-    g_print("gsw. media_packet_get_video_stride_width\t");
-    g_print("gsh. media_packet_get_video_stride_height\t");
-    g_print("gpp. media_packet_get_video_plane_data_ptr\t");
-    g_print("\n");
-    g_print("scd. media_packet_set_codec_data\t");
-    g_print("gcd. media_packet_get_codec_data\t");
-    g_print("\n");
-    g_print("d. media_packet_destroy \n");
-    g_print("q. quit test suite(if exist alive media_format, do media_format_unref)");
-    g_print("\n");
-    g_print("=========================================================================================\n");
+       g_print("\n");
+       g_print("=========================================================================================\n");
+       g_print("                                    media tool test\n");
+       g_print("-----------------------------------------------------------------------------------------\n");
+       g_print(" *** How to use ***\n");
+       g_print(" : You can create 1 media_format_h handle by 'cf' and 1 media_packet_handle \n");
+       g_print(" : ex) cf > svm > svw > svh > svab > svmb >fgv > > a > iv > ir ...> d\n");
+       g_print(" : media_format_create is set to 'media_format_h[0]' \n");
+       g_print(" : media_packet_create_alloc & media_packet_create use 'media_format_h[0]' \n");
+       g_print(" : media_packet_create_from_tbm_surface use 'media_format_h[2]' \n");
+       g_print("\n");
+       g_print("cf. media_format_create\t\t");
+       g_print("\n");
+       g_print("svm. media_format_set_video_mime\t");
+       g_print("svw. media_format_set_video_width\t");
+       g_print("svh. media_format_set_video_height\t");
+       g_print("svab. media_format_set_video_avg_bps\t");
+       g_print("svmb. media_format_set_video_max_bps\t");
+       g_print("\n");
+       g_print("sam. media_format_set_audio_mime\t");
+       g_print("sac. media_format_set_audio_channel\t");
+       g_print("sas. media_format_set_audio_samplerate\t");
+       g_print("sab. media_format_set_audio_bit \t");
+       g_print("saab. media_format_set_audio_avg_bps\t");
+       g_print("saat. media_format_set_audio_aac_type\t");
+       g_print("\n");
+       g_print("fgv. media_format_get_video_info \t");
+       g_print("fga. media_format_get_audio_info \t\t");
+       g_print("\n");
+       g_print("\n");
+       g_print("a. media_packet_create_alloc(+media_format_unref)  \t");
+       g_print("aa. media_packet_create(+media_format_unref) \t");
+       g_print("b. media_packet_create_from_tbm_surface(+media_format_unref) \n");
+       g_print("ab. media_packet_alloc \t\t");
+       g_print("c. media_packet_copy  \t");
+       g_print("\n");
+       g_print("\n");
+       g_print("iv. media_packet_is_video \t");
+       g_print("ia. media_packet_is_audio \t");
+       g_print("ie. media_packet_is_encoded \t");
+       g_print("ir. media_packet_is_raw \t");
+       g_print("ht. media_packet_has_tbm_surface_buffer \t");
+       g_print("\n");
+       g_print("sd. media_packet_set_duration \t");
+       g_print("sf. media_packet_set_format(+media_format_unref) \t");
+       g_print("se. media_packet_set_extra \t");
+       g_print("\n");
+       g_print("gd. media_packet_get_duration \t");
+       g_print("gbp. media_packet_get_buffer_data_ptr \t");
+       g_print("gts. media_packet_get_tbm_surface \t");
+       g_print("gf. media_packet_get_format \t");
+       g_print("ge. media_packet_get_extra \t");
+       g_print("\n");
+       g_print("gs. media_packet_get_buffer_size\t");
+       g_print("\n");
+       g_print("gnp. media_packet_get_number_of_video_planes\t");
+       g_print("gsw. media_packet_get_video_stride_width\t");
+       g_print("gsh. media_packet_get_video_stride_height\t");
+       g_print("gpp. media_packet_get_video_plane_data_ptr\t");
+       g_print("\n");
+       g_print("scd. media_packet_set_codec_data\t");
+       g_print("gcd. media_packet_get_codec_data\t");
+       g_print("\n");
+       g_print("d. media_packet_destroy \n");
+       g_print("q. quit test suite(if exist alive media_format, do media_format_unref)");
+       g_print("\n");
+       g_print("=========================================================================================\n");
 }
 
-
-gboolean input (GIOChannel *channel)
+gboolean input(GIOChannel *channel)
 {
-    gchar buf[MAX_STRING_LEN];
-    gsize read;
-    GError *error = NULL;
+       gchar buf[MAX_STRING_LEN];
+       gsize read;
+       GError *error = NULL;
 
-    g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
-    buf[read] = '\0';
-    g_strstrip(buf);
-    interpret (buf);
+       g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
+       buf[read] = '\0';
+       g_strstrip(buf);
+       interpret(buf);
 
-    return TRUE;
+       return TRUE;
 }
 
 int main(int argc, char *argv[])
 {
-    GIOChannel *stdin_channel;
-    stdin_channel = g_io_channel_unix_new(0);
-    g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
-    g_io_add_watch (stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
+       GIOChannel *stdin_channel;
+       stdin_channel = g_io_channel_unix_new(0);
+       g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+       g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
 
-    displaymenu();
+       displaymenu();
 
-    ops.data = NULL;
+       ops.data = NULL;
 
-    return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 
 }
-