Added internal API for static loading ini when binding c# API 99/93399/8
authorSejun Park <sejun79.park@samsung.com>
Mon, 24 Oct 2016 06:22:19 +0000 (15:22 +0900)
committerSejun Park <sejun79.park@samsung.com>
Tue, 25 Oct 2016 04:37:52 +0000 (13:37 +0900)
Change-Id: Id4e51da2d93957fd2735f93ae47aabcdc66ebdd3

include/media_codec_ini.h
include/media_codec_internal.h [new file with mode: 0755]
include/media_codec_port.h
include/media_codec_spec_emul.h
packaging/capi-media-codec.spec
src/media_codec.c
src/media_codec_internal.c [new file with mode: 0755]
src/media_codec_port.c
test/media_codec_test.c

index b51404e..ba0704f 100755 (executable)
@@ -66,7 +66,9 @@ struct _codec_t {
 
 /* @ mark means the item has tested */
 struct _mc_ini_t {
-       int codec_list;
+       gboolean loaded;
+       gint codec_list;
+       gint num_supported_codecs;
        port_mode port_type;
        /* general */
        gchar port_name[MEDIA_CODEC_INI_MAX_STRLEN];
@@ -107,6 +109,8 @@ media_codec_port = GST_PORT \n\
 \n\
 "
 
+extern mc_ini_t mc_ini;
+
 int mc_ini_load(mc_ini_t *ini);
 media_format_mimetype_e _mc_convert_media_format_str_to_int(char *sformat);
 
diff --git a/include/media_codec_internal.h b/include/media_codec_internal.h
new file mode 100755 (executable)
index 0000000..87eac43
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_INTERNAL_H__
+#define __TIZEN_MEDIA_CODEC_INTERNAL_H__
+
+#include <media_codec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @file media_codec_internal.h
+* @brief This file contains the internal capi media codec API.
+*/
+
+/**
+* @addtogroup CAPI_MEDIA_CODEC_MODULE
+* @{
+*/
+
+/**
+ * @brief Retrieves all supported codecs by invoking callback function once for each supported codecs.
+ * @since_tizen 3.0
+ * @param[in] callback  The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see mediacodec_foreach_supported_codec()
+ */
+int mediacodec_foreach_supported_codec_static(mediacodec_supported_codec_cb callback, void *user_data);
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+#endif /*__TIZEN_MEDIA_CODEC_INTERNAL_H__*/
index 2b7ec12..30937c2 100755 (executable)
@@ -86,6 +86,38 @@ typedef enum {
        MC_OUT_OF_MEMORY                        =       -20,    /**< when memory is not allocated */
 } mc_ret_e;
 
+typedef enum {
+       NONE,
+       L16,
+       ALAW,
+       ULAW,
+       AMR_NB,
+       AMR_WB,
+       G729,
+       AAC_LC,
+       AAC_HE,
+       AAC_HE_PS,
+       MP3,
+       VORBIS,
+       FLAC,
+       WMAV1,
+       WMAV2,
+       WMAPRO,
+       WMALSL,
+       H261,
+       H263,
+       H264,
+       MJPEG,
+       MPEG1,
+       MPEG2,
+       MPEG4,
+       HEVC,
+       VP8,
+       VP9,
+       VC1,
+       CODEC_NR_ITEMS
+} codec_type_e;
+
 /*---------------------------------------------------------------------------
 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                         |
 ---------------------------------------------------------------------------*/
@@ -175,7 +207,6 @@ struct _mc_handle_t {
        bool is_hw;
        bool is_prepared;
 
-       GList *supported_codecs;
        mediacodec_port_type_e port_type;
        mediacodec_codec_type_e codec_id;
        mc_vendor_e vendor;
@@ -195,11 +226,10 @@ struct _mc_handle_t {
        mc_codec_map_t encoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
        mc_codec_map_t decoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
 
-       int num_supported_codecs;
        int num_supported_decoder;
        int num_supported_encoder;
 
-       mc_ini_t ini;
+       mc_ini_t *ini;
 };
 
 /*===========================================================================================
@@ -249,12 +279,16 @@ int mc_unset_eos_cb(MMHandleType mediacodec);
 int mc_set_buffer_status_cb(MMHandleType mediacodec, mediacodec_buffer_status_cb callback, void* user_data);
 int mc_unset_buffer_status_cb(MMHandleType mediacodec);
 int mc_set_supported_codec_cb(MMHandleType mediacodec, mediacodec_supported_codec_cb callback, void* user_data);
-int _mediacodec_foreach_supported_codec(MMHandleType mediacodec, mediacodec_supported_codec_cb callback, void* user_data);
+int _mediacodec_foreach_supported_codec(mediacodec_supported_codec_cb callback, void* user_data);
 
 void _mc_create_codec_map_from_ini(mc_handle_t *mc_handle, mc_codec_spec_t *spec_emul);
+void _mc_create_codec_map_from_ini_static(mc_ini_t *ini, mc_codec_spec_t *spec_emul);
 void _mc_create_decoder_map_from_ini(mc_handle_t *mc_handle);
 void _mc_create_encoder_map_from_ini(mc_handle_t *mc_handle);
 
+const int simple_to_codec_type_enumeration(codec_type_e codec_id);
+const int codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id);
+
 #ifdef __cplusplus
 }
 #endif
index 4fc7f6f..96bb3fb 100755 (executable)
@@ -23,6 +23,8 @@ extern "C" {
 
 #include <media_codec_private.h>
 
+#define MEDIA_CODEC_MAX_CODEC_TYPE 100
+
 enum {DECODER, ENCODER};
 enum {SOFTWARE, HARDWARE};
 
@@ -48,6 +50,7 @@ struct _mc_codec_map_t {
        mc_codec_type_t type;
 };
 
+extern mc_codec_spec_t spec_emul[MEDIA_CODEC_MAX_CODEC_TYPE];
 
 #ifdef __cplusplus
 }
index 94a969c..92cb31b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-codec
 Summary:    A Media Codec library in Tizen Native API
-Version:    0.4.3
+Version:    0.5.0
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c8d6e20..22cd3d8 100755 (executable)
@@ -479,7 +479,7 @@ int mediacodec_foreach_supported_codec(mediacodec_h mediacodec, mediacodec_suppo
        handle->supported_codec_cb_userdata = user_data;
 
        LOGD("set supported_codec_cb(%p)", callback);
-       int ret = _mediacodec_foreach_supported_codec(handle->mc_handle, callback, handle);
+       int ret = _mediacodec_foreach_supported_codec(callback, handle);
 
        if (ret != MEDIACODEC_ERROR_NONE)
                return __convert_error_code(ret, (char *)__FUNCTION__);
diff --git a/src/media_codec_internal.c b/src/media_codec_internal.c
new file mode 100755 (executable)
index 0000000..bdf24a5
--- /dev/null
@@ -0,0 +1,110 @@
+#include <dlog.h>
+#include <media_codec.h>
+#include <media_codec_port.h>
+#include <media_codec_ini.h>
+#include <media_codec_spec_emul.h>
+#include <media_codec_internal.h>
+
+mc_codec_spec_t spec_emul[MEDIA_CODEC_MAX_CODEC_TYPE];
+mc_ini_t mc_ini;
+
+int __convert_error_code_internal(int code, char *func_name)
+{
+       int ret = MEDIACODEC_ERROR_INVALID_OPERATION;
+       char *msg = "MEDIACOODEC_INVALID_OPERATION";
+
+       switch (code) {
+       case MC_ERROR_NONE:
+               ret = MEDIACODEC_ERROR_NONE;
+               msg = "MEDIACODEC_ERROR_NONE";
+               break;
+       case MC_PARAM_ERROR:
+       case MC_INVALID_ARG:
+               ret = MEDIACODEC_ERROR_INVALID_PARAMETER;
+               msg = "MEDIACODEC_ERROR_INVALID_PARAMETER";
+               break;
+       case MC_PERMISSION_DENIED:
+               ret = MEDIACODEC_ERROR_PERMISSION_DENIED;
+               msg = "MEDIACODEC_ERROR_PERMISSION_DENIED";
+               break;
+       case MC_INVALID_STATUS:
+               ret = MEDIACODEC_ERROR_INVALID_STATE;
+               msg = "MEDIACODEC_ERROR_INVALID_STATE";
+               break;
+       case MC_NOT_SUPPORTED:
+               ret = MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE;
+               msg = "MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE";
+               break;
+       case MC_ERROR:
+       case MC_INTERNAL_ERROR:
+       case MC_HW_ERROR:
+               ret = MEDIACODEC_ERROR_INVALID_OPERATION;
+               msg = "MEDIACODEC_ERROR_INVALID_OPERATION";
+               break;
+       case MC_INVALID_STREAM:
+               ret = MEDIACODEC_ERROR_INVALID_STREAM;
+               msg = "MEDIACODEC_ERROR_INVALID_STREAM";
+               break;
+       case MC_CODEC_NOT_FOUND:
+               ret = MEDIACODEC_ERROR_CODEC_NOT_FOUND;
+               msg = "MEDIACODEC_ERROR_CODEC_NOT_FOUND";
+               break;
+       case MC_ERROR_DECODE:
+               ret = MEDIACODEC_ERROR_DECODE;
+               msg = "MEDIACODEC_ERROR_DECODE";
+               break;
+       case MC_INVALID_IN_BUF:
+               ret = MEDIACODEC_ERROR_INVALID_INBUFFER;
+               msg = "MEDIACODEC_ERROR_INVALID_INBUFFER";
+               break;
+       case MC_INVALID_OUT_BUF:
+               ret = MEDIACODEC_ERROR_INVALID_OUTBUFFER;
+               msg = "MEDIACODEC_ERROR_INVALID_OUTBUFFER";
+               break;
+       case MC_NOT_INITIALIZED:
+               ret = MEDIACODEC_ERROR_NOT_INITIALIZED;
+               msg = "MEDIACODEC_ERROR_NOT_INITIALIZED";
+               break;
+       case MC_OUTPUT_BUFFER_EMPTY:
+       case MC_OUTPUT_BUFFER_OVERFLOW:
+               ret = MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE;
+               msg = "MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE";
+               break;
+       case MC_OUT_OF_MEMORY:
+               ret = MEDIACODEC_ERROR_OUT_OF_MEMORY;
+               msg = "MEDIACODEC_ERROR_OUT_OF_MEMORY";
+               break;
+       default:
+               ret = MEDIACODEC_ERROR_INTERNAL;
+               msg = "MEDIACODEC_ERROR_INTERNAL";
+               break;
+       }
+       LOGD("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
+       return ret;
+}
+
+int mediacodec_foreach_supported_codec_static(mediacodec_supported_codec_cb callback, void *user_data)
+{
+       int ret;
+
+       if (!mc_ini.loaded) {
+               ret = mc_ini_load(&mc_ini);
+               if (ret != MC_ERROR_NONE)
+                       goto ERROR;
+
+               mc_ini.loaded = TRUE;
+       }
+
+       _mc_create_codec_map_from_ini_static(&mc_ini, spec_emul);
+
+       LOGD("set supported_codec_cb(%p)", callback);
+       ret = _mediacodec_foreach_supported_codec(callback, user_data);
+
+       if (ret != MEDIACODEC_ERROR_NONE)
+               return __convert_error_code_internal(ret, (char *)__FUNCTION__);
+       else
+               return MEDIACODEC_ERROR_NONE;
+
+ERROR:
+       return MEDIACODEC_ERROR_INVALID_PARAMETER;
+}
index 76e49cc..83b618f 100755 (executable)
 #include <media_codec_port_gst.h>
 #include <media_codec_spec_emul.h>
 
-static mc_codec_spec_t spec_emul[MEDIA_CODEC_MAX_CODEC_TYPE];
+mc_ini_t mc_ini;
+mc_codec_spec_t spec_emul[MEDIA_CODEC_MAX_CODEC_TYPE];
 
 int mc_create(MMHandleType *mediacodec)
 {
        mc_handle_t *new_mediacodec = NULL;
        int ret = MC_ERROR_NONE;
-       int i;
 
        /* alloc mediacodec structure */
        new_mediacodec = (mc_handle_t *)g_malloc(sizeof(mc_handle_t));
@@ -43,7 +43,6 @@ int mc_create(MMHandleType *mediacodec)
                goto ERROR;
        }
        memset(new_mediacodec, 0, sizeof(mc_handle_t));
-       memset(spec_emul, 0, sizeof(mc_codec_spec_t)*MEDIA_CODEC_MAX_CODEC_TYPE);
 
        new_mediacodec->is_encoder = false;
        new_mediacodec->is_video = false;
@@ -54,23 +53,23 @@ int mc_create(MMHandleType *mediacodec)
        new_mediacodec->ports[0] = NULL;
        new_mediacodec->ports[1] = NULL;
 
-       new_mediacodec->num_supported_codecs  = 0;
        new_mediacodec->num_supported_decoder = 0;
        new_mediacodec->num_supported_encoder = 0;
 
        new_mediacodec->core = NULL;
+       new_mediacodec->ini = &mc_ini;
 
        /* load ini files */
-       ret = mc_ini_load(&new_mediacodec->ini);
-       if (ret != MC_ERROR_NONE)
-               goto ERROR;
-       _mc_create_codec_map_from_ini(new_mediacodec, spec_emul);
+       if (!mc_ini.loaded) {
+               ret = mc_ini_load(&mc_ini);
+               if (ret != MC_ERROR_NONE)
+                       goto ERROR;
 
-       for (i = 0; i < new_mediacodec->num_supported_codecs; i++) {
-               new_mediacodec->supported_codecs =
-                       g_list_append(new_mediacodec->supported_codecs, GINT_TO_POINTER(spec_emul[i].codec_id));
+               mc_ini.loaded = TRUE;
        }
 
+       _mc_create_codec_map_from_ini(new_mediacodec, spec_emul);
+
        /* create decoder map from ini */
        _mc_create_decoder_map_from_ini(new_mediacodec);
 
@@ -106,7 +105,6 @@ int mc_destroy(MMHandleType mediacodec)
        }
 
        mc_handle->is_prepared = false;
-       g_list_free(mc_handle->supported_codecs);
 
        /* free mediacodec structure */
        if (mc_handle) {
@@ -138,13 +136,13 @@ int mc_set_codec(MMHandleType mediacodec, mediacodec_codec_type_e codec_id, int
        if (!GET_IS_HW(flags) && !GET_IS_SW(flags))
                flags |= MEDIACODEC_SUPPORT_TYPE_SW;
 
-       for (i = 0; i < mc_handle->num_supported_codecs; i++) {
+       for (i = 0; i < mc_handle->ini->num_supported_codecs; i++) {
                if ((codec_id == spec_emul[i].codec_id) && (flags == spec_emul[i].codec_type))
                        break;
        }
-       LOGD("support_list : %d, i : %d", mc_handle->num_supported_codecs, i);
+       LOGD("support_list : %d, i : %d", mc_handle->ini->num_supported_codecs, i);
 
-       if (i == mc_handle->num_supported_codecs)
+       if (i == mc_handle->ini->num_supported_codecs)
                return MC_NOT_SUPPORTED;
 
        mc_handle->port_type = spec_emul[i].port_type;
@@ -682,37 +680,31 @@ int mc_set_supported_codec_cb(MMHandleType mediacodec, mediacodec_supported_code
        return ret;
 }
 
-int _mediacodec_foreach_supported_codec(MMHandleType mediacodec, mediacodec_supported_codec_cb callback, void *user_data)
+int _mediacodec_foreach_supported_codec(mediacodec_supported_codec_cb callback, void *user_data)
 {
-       int ret = MC_ERROR_NONE;
-       mc_handle_t *mc_handle = (mc_handle_t *)mediacodec;
-       int codecs_num;
-       gpointer tmp;
+       int ret = MEDIACODEC_NONE;
+       int i;
+       int index;
 
-       if (!mc_handle) {
-               LOGE("fail invaild param\n");
-               return MC_INVALID_ARG;
-       }
+       gboolean codec[CODEC_NR_ITEMS] = {0,};
 
-       if (mc_handle->supported_codecs) {
-               codecs_num = g_list_length(mc_handle->supported_codecs);
-               LOGD("supported_codecs : %d", codecs_num);
+       for (i = 0; i < mc_ini.num_supported_codecs; i++) {
+               index = codec_type_to_simple_enumeration(spec_emul[i].codec_id);
+               codec[index] = TRUE;
+       }
 
-               while (codecs_num) {
-                       tmp = g_list_nth_data(mc_handle->supported_codecs, codecs_num - 1);
-                       if (tmp) {
-                               if (!callback(GPOINTER_TO_INT(tmp), user_data)) {
-                                       ret = MEDIACODEC_ERROR_INTERNAL;
-                                       goto CALLBACK_ERROR;
-                               }
+       for (i = 0; i < CODEC_NR_ITEMS; i++) {
+               if (codec[i]) {
+                       index = simple_to_codec_type_enumeration(i);
+                       if (!callback(index, user_data)) {
+                               goto CALLBACK_ERROR;
                        }
-                       codecs_num--;
                }
+       }
 
-               if (!callback(-1, user_data)) {
-                       ret = MEDIACODEC_ERROR_INTERNAL;
-                       goto CALLBACK_ERROR;
-               }
+       if (!callback(-1, user_data)) {
+               ret = MEDIACODEC_ERROR_INTERNAL;
+               goto CALLBACK_ERROR;
        }
 
 CALLBACK_ERROR:
@@ -752,25 +744,25 @@ int mc_get_packet_pool(MMHandleType mediacodec, media_packet_pool_h *pool)
 void _mc_create_decoder_map_from_ini(mc_handle_t *mediacodec)
 {
        int indx = 0, count = 0;
-       int codec_list = mediacodec->ini.codec_list;
+       int codec_list = mediacodec->ini->codec_list;
        for (indx = 0; indx < codec_list; indx++) {
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[0].name, "")) {
-                       mediacodec->decoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[0].name, "")) {
+                       mediacodec->decoder_map[count].id = mediacodec->ini->codec[indx].codec_id;
                        mediacodec->decoder_map[count].hardware = 1; /* hardware */
-                       mediacodec->decoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[0].name;
-                       mediacodec->decoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[0].mime;
+                       mediacodec->decoder_map[count].type.factory_name = mediacodec->ini->codec[indx].codec_info[0].name;
+                       mediacodec->decoder_map[count].type.mime = mediacodec->ini->codec[indx].codec_info[0].mime;
                        mediacodec->decoder_map[count].type.out_format =
-                               _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[0].format);
+                               _mc_convert_media_format_str_to_int(mediacodec->ini->codec[indx].codec_info[0].format);
                        count++;
                }
 
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[2].name, "")) {
-                       mediacodec->decoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[2].name, "")) {
+                       mediacodec->decoder_map[count].id = mediacodec->ini->codec[indx].codec_id;
                        mediacodec->decoder_map[count].hardware = 0; /* software */
-                       mediacodec->decoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[2].name;
-                       mediacodec->decoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[2].mime;
+                       mediacodec->decoder_map[count].type.factory_name = mediacodec->ini->codec[indx].codec_info[2].name;
+                       mediacodec->decoder_map[count].type.mime = mediacodec->ini->codec[indx].codec_info[2].mime;
                        mediacodec->decoder_map[count].type.out_format =
-                               _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[2].format);
+                               _mc_convert_media_format_str_to_int(mediacodec->ini->codec[indx].codec_info[2].format);
                        count++;
                }
        }
@@ -782,26 +774,26 @@ void _mc_create_decoder_map_from_ini(mc_handle_t *mediacodec)
 void _mc_create_encoder_map_from_ini(mc_handle_t *mediacodec)
 {
        int indx = 0, count = 0;
-       int codec_list = mediacodec->ini.codec_list;
+       int codec_list = mediacodec->ini->codec_list;
 
        for (indx = 0; indx < codec_list; indx++) {
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[1].name, "")) {
-                       mediacodec->encoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[1].name, "")) {
+                       mediacodec->encoder_map[count].id = mediacodec->ini->codec[indx].codec_id;
                        mediacodec->encoder_map[count].hardware = 1;
-                       mediacodec->encoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[1].name;
-                       mediacodec->encoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[1].mime;
+                       mediacodec->encoder_map[count].type.factory_name = mediacodec->ini->codec[indx].codec_info[1].name;
+                       mediacodec->encoder_map[count].type.mime = mediacodec->ini->codec[indx].codec_info[1].mime;
                        mediacodec->encoder_map[count].type.out_format =
-                               _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[1].format);
+                               _mc_convert_media_format_str_to_int(mediacodec->ini->codec[indx].codec_info[1].format);
                        count++;
                }
 
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[3].name, "")) {
-                       mediacodec->encoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[3].name, "")) {
+                       mediacodec->encoder_map[count].id = mediacodec->ini->codec[indx].codec_id;
                        mediacodec->encoder_map[count].hardware = 0;
-                       mediacodec->encoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[3].name;
-                       mediacodec->encoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[3].mime;
+                       mediacodec->encoder_map[count].type.factory_name = mediacodec->ini->codec[indx].codec_info[3].name;
+                       mediacodec->encoder_map[count].type.mime = mediacodec->ini->codec[indx].codec_info[3].mime;
                        mediacodec->encoder_map[count].type.out_format =
-                               _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[3].format);
+                               _mc_convert_media_format_str_to_int(mediacodec->ini->codec[indx].codec_info[3].format);
                        count++;
                }
        }
@@ -812,38 +804,201 @@ void _mc_create_encoder_map_from_ini(mc_handle_t *mediacodec)
 void _mc_create_codec_map_from_ini(mc_handle_t *mediacodec, mc_codec_spec_t *spec_emul)
 {
        int indx = 0, count = 0;
-       int codec_list = mediacodec->ini.codec_list;
+       int codec_list = mediacodec->ini->codec_list;
 
        for (indx = 0; indx < codec_list; indx++) {
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[0].name, "")) {
-                       spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[0].name, "")) {
+                       spec_emul[count].codec_id = mediacodec->ini->codec[indx].codec_id;
                        spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_HW;
                        spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
                        count++;
                }
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[1].name, "")) {
-                       spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[1].name, "")) {
+                       spec_emul[count].codec_id = mediacodec->ini->codec[indx].codec_id;
                        spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_HW;
                        spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
                        count++;
                }
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[2].name, "")) {
-                       spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[2].name, "")) {
+                       spec_emul[count].codec_id = mediacodec->ini->codec[indx].codec_id;
                        spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_SW;
                        spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
                        count++;
                }
-               if (strcmp(mediacodec->ini.codec[indx].codec_info[3].name, "")) {
-                       spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
+               if (strcmp(mediacodec->ini->codec[indx].codec_info[3].name, "")) {
+                       spec_emul[count].codec_id = mediacodec->ini->codec[indx].codec_id;
                        spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_SW;
                        spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
                        count++;
                }
        }
 
-       mediacodec->num_supported_codecs = count;
+       mediacodec->ini->num_supported_codecs = count;
        LOGE("supported codecs :%d", count);
        return;
 }
 
+void _mc_create_codec_map_from_ini_static(mc_ini_t *ini, mc_codec_spec_t *spec_emul)
+{
+       int indx = 0, count = 0;
+       int codec_list = ini->codec_list;
 
+       for (indx = 0; indx < codec_list; indx++) {
+               if (strcmp(ini->codec[indx].codec_info[0].name, "")) {
+                       spec_emul[count].codec_id = ini->codec[indx].codec_id;
+                       spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_HW;
+                       spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
+                       count++;
+               }
+               if (strcmp(ini->codec[indx].codec_info[1].name, "")) {
+                       spec_emul[count].codec_id = ini->codec[indx].codec_id;
+                       spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_HW;
+                       spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
+                       count++;
+               }
+               if (strcmp(ini->codec[indx].codec_info[2].name, "")) {
+                       spec_emul[count].codec_id = ini->codec[indx].codec_id;
+                       spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_SW;
+                       spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
+                       count++;
+               }
+               if (strcmp(ini->codec[indx].codec_info[3].name, "")) {
+                       spec_emul[count].codec_id = ini->codec[indx].codec_id;
+                       spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_SW;
+                       spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
+                       count++;
+               }
+       }
+
+       ini->num_supported_codecs = count;
+       LOGE("supported codecs :%d", count);
+       return;
+}
+
+const int codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id)
+{
+       guint media_codec_id_u = (guint)media_codec_id;
+
+       switch (media_codec_id_u) {
+       case MEDIACODEC_L16:
+               return L16;
+       case MEDIACODEC_ALAW:
+               return ALAW;
+       case MEDIACODEC_ULAW:
+               return ULAW;
+       case MEDIACODEC_AMR_NB:
+               return AMR_NB;
+       case MEDIACODEC_AMR_WB:
+               return AMR_WB;
+       case MEDIACODEC_G729:
+               return G729;
+       case MEDIACODEC_AAC_LC:
+               return AAC_LC;
+       case MEDIACODEC_AAC_HE:
+               return AAC_HE;
+       case MEDIACODEC_AAC_HE_PS:
+               return AAC_HE_PS;
+       case MEDIACODEC_MP3:
+               return MP3;
+       case MEDIACODEC_VORBIS:
+               return VORBIS;
+       case MEDIACODEC_FLAC:
+               return FLAC;
+       case MEDIACODEC_WMAV1:
+               return WMAV1;
+       case MEDIACODEC_WMAV2:
+               return WMAV2;
+       case MEDIACODEC_WMAPRO:
+               return WMAPRO;
+       case MEDIACODEC_WMALSL:
+               return WMALSL;
+       case MEDIACODEC_H261:
+               return H261;
+       case MEDIACODEC_H263:
+               return H263;
+       case MEDIACODEC_H264:
+               return H264;
+       case MEDIACODEC_MJPEG:
+               return MJPEG;
+       case MEDIACODEC_MPEG1:
+               return MPEG1;
+       case MEDIACODEC_MPEG2:
+               return MPEG2;
+       case MEDIACODEC_MPEG4:
+               return MPEG4;
+       case MEDIACODEC_HEVC:
+               return HEVC;
+       case MEDIACODEC_VP8:
+               return VP8;
+       case MEDIACODEC_VP9:
+               return VP9;
+       case MEDIACODEC_VC1:
+               return VC1;
+       default:
+               return NONE;
+       }
+}
+
+const int simple_to_codec_type_enumeration(codec_type_e codec_id)
+{
+       guint codec_id_u = (guint)codec_id;
+
+       switch (codec_id_u) {
+       case L16:
+               return MEDIACODEC_L16;
+       case ALAW:
+               return MEDIACODEC_ALAW;
+       case ULAW:
+               return MEDIACODEC_ULAW;
+       case AMR_NB:
+               return MEDIACODEC_AMR_NB;
+       case AMR_WB:
+               return MEDIACODEC_AMR_WB;
+       case G729:
+               return MEDIACODEC_G729;
+       case AAC_LC:
+               return MEDIACODEC_AAC_LC;
+       case AAC_HE:
+               return MEDIACODEC_AAC_HE;
+       case AAC_HE_PS:
+               return MEDIACODEC_AAC_HE_PS;
+       case MP3:
+               return MEDIACODEC_MP3;
+       case VORBIS:
+               return MEDIACODEC_VORBIS;
+       case FLAC:
+               return MEDIACODEC_FLAC;
+       case WMAV1:
+               return MEDIACODEC_WMAV1;
+       case WMAV2:
+               return MEDIACODEC_WMAV2;
+       case WMAPRO:
+               return MEDIACODEC_WMAPRO;
+       case WMALSL:
+               return MEDIACODEC_WMALSL;
+       case H261:
+               return MEDIACODEC_H261;
+       case H263:
+               return MEDIACODEC_H263;
+       case H264:
+               return MEDIACODEC_H264;
+       case MJPEG:
+               return MEDIACODEC_MJPEG;
+       case MPEG1:
+               return MEDIACODEC_MPEG1;
+       case MPEG2:
+               return MEDIACODEC_MPEG2;
+       case MPEG4:
+               return MEDIACODEC_MPEG4;
+       case HEVC:
+               return MEDIACODEC_HEVC;
+       case VP8:
+               return MEDIACODEC_VP8;
+       case VP9:
+               return MEDIACODEC_VP9;
+       case VC1:
+               return MEDIACODEC_VC1;
+       default:
+               return NONE;
+       }
+}
index 949f4ef..d5ab042 100755 (executable)
 #include <appcore-efl.h>
 #include <gst/gst.h>
 
+#include <tbm_surface.h>
+#include <dlog.h>
+#include <time.h>
 #include <camera.h>
 #include <media_codec.h>
 #include <media_packet.h>
 #include <media_packet_pool.h>
-#include <tbm_surface.h>
-#include <dlog.h>
-#include <time.h>
+#include <media_codec_internal.h>
 
 #define PACKAGE "media_codec_test"
 #define MAX_HANDLE                     4
@@ -182,6 +183,7 @@ static void mc_hex_dump(char *desc, void *addr, int len);
 static void decoder_output_dump(App *app, media_packet_h pkt);
 static void output_dump(App *app, media_packet_h pkt);
 /* */
+const char* codec_type_to_string(mediacodec_codec_type_e media_codec_id);
 
 void (*extractor)(App *app, unsigned char** data, int *size, bool *have_frame);
 
@@ -1228,10 +1230,19 @@ static bool _mediacodec_eos_cb(void *user_data)
        return TRUE;
 }
 
+void _foreach_cb(mediacodec_codec_type_e codec_type, void *user_data)
+{
+       printf ("codec type : %x %s\n", codec_type, codec_type_to_string(codec_type));
+       return;
+}
+
 static void _mediacodec_prepare(App *app, bool frame_all)
 {
        int ret;
 
+       printf("supported codec lists -internal-\n");
+       mediacodec_foreach_supported_codec_static((mediacodec_supported_codec_cb)_foreach_cb, app);
+
        /* create instance */
        ret = mediacodec_create(&app->mc_handle[0]);
        if (ret  != MEDIACODEC_ERROR_NONE) {
@@ -1290,6 +1301,8 @@ static void _mediacodec_prepare(App *app, bool frame_all)
        }
 
        /* set callback */
+       printf("supported codec lists\n");
+       mediacodec_foreach_supported_codec(app->mc_handle[0], (mediacodec_supported_codec_cb)_foreach_cb, app);
        mediacodec_set_input_buffer_used_cb(app->mc_handle[0], (mediacodec_input_buffer_used_cb)_mediacodec_inbuf_used_cb, NULL);
        mediacodec_set_output_buffer_available_cb(app->mc_handle[0], (mediacodec_output_buffer_available_cb) _mediacodec_outbuf_available_cb, app);
        if (frame_all)
@@ -1311,6 +1324,8 @@ static void _mediacodec_prepare(App *app, bool frame_all)
                g_print("mediacodec_get_packet_pool failed\n");
                return;
        }
+       g_print("mediacodec start\n");
+
        return;
 }
 
@@ -1974,3 +1989,68 @@ static void output_dump(App *app, media_packet_h pkt)
        fclose(fp);
 
 }
+
+const char* codec_type_to_string(mediacodec_codec_type_e media_codec_id)
+{
+       guint media_codec_id_u = (guint)media_codec_id;
+
+       switch (media_codec_id_u) {
+       case MEDIACODEC_L16:
+               return "L16";
+       case MEDIACODEC_ALAW:
+               return "ALAW";
+       case MEDIACODEC_ULAW:
+               return "ULAW";
+       case MEDIACODEC_AMR_NB:
+               return "AMR_NB";
+       case MEDIACODEC_AMR_WB:
+               return "AMR_WB";
+       case MEDIACODEC_G729:
+               return "G729";
+       case MEDIACODEC_AAC_LC:
+               return "AAC_LC";
+       case MEDIACODEC_AAC_HE:
+               return "AAC_HE";
+       case MEDIACODEC_AAC_HE_PS:
+               return "AAC_HE_PS";
+       case MEDIACODEC_MP3:
+               return "MP3";
+       case MEDIACODEC_VORBIS:
+               return "VORBIS";
+       case MEDIACODEC_FLAC:
+               return "FLAC";
+       case MEDIACODEC_WMAV1:
+               return "WMAV1";
+       case MEDIACODEC_WMAV2:
+               return "WMAV2";
+       case MEDIACODEC_WMAPRO:
+               return "WMAPRO";
+       case MEDIACODEC_WMALSL:
+               return "WMALSL";
+       case MEDIACODEC_H261:
+               return "H261";
+       case MEDIACODEC_H263:
+               return "H263";
+       case MEDIACODEC_H264:
+               return "H264";
+       case MEDIACODEC_MJPEG:
+               return "MJPEG";
+       case MEDIACODEC_MPEG1:
+               return "MPEG1";
+       case MEDIACODEC_MPEG2:
+               return "MPEG2";
+       case MEDIACODEC_MPEG4:
+               return "MPEG4";
+       case MEDIACODEC_HEVC:
+               return "HEVC";
+       case MEDIACODEC_VP8:
+               return "VP8";
+       case MEDIACODEC_VP9:
+               return "VP9";
+       case MEDIACODEC_VC1:
+               return "VC1";
+       default:
+               return "NONE";
+       }
+}
+