tizen 2.4 release
[framework/api/mediacodec.git] / src / media_codec_ini.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MEDIA_CODEC_INI_C__
18 #define __MEDIA_CODEC_INI_C__
19
20 /* includes here */
21 #include <glib.h>
22 #include <stdlib.h>
23 #include <glib/gstdio.h>
24 #include <mm_debug.h>
25 #include <mm_error.h>
26 #include "iniparser.h"
27 #include <media_codec_ini.h>
28 #include <media_codec_port.h>
29
30 #define DEFAULT_VALUE ""
31
32 #define DEFAULT_HW_DECODER_NAME ""
33 #define DEFAULT_HW_DECODER_MIME ""
34 #define DEFAULT_HW_DECODER_FORMAT ""
35
36 #define DEFAULT_HW_ENCODER_NAME ""
37 #define DEFAULT_HW_ENCODER_MIME ""
38 #define DEFAULT_HW_ENCODER_FORMAT ""
39
40 #define DEFAULT_SW_DECODER_NAME ""
41 #define DEFAULT_SW_DECODER_MIME ""
42 #define DEFAULT_SW_DECODER_FORMAT ""
43
44 #define DEFAULT_SW_ENCODER_NAME ""
45 #define DEFAULT_SW_ENCODER_MIME ""
46 #define DEFAULT_SW_ENCODER_FORMAT ""
47
48
49 #define CNAME_SIZE 512
50
51 typedef struct {
52     gchar cname[MEDIA_CODEC_INI_MAX_STRLEN];
53     mediacodec_codec_type_e ctype;
54 }codec_list_t;
55
56 static codec_list_t general_codec_list[]={
57     {"h261", MEDIACODEC_H261},
58     {"h263", MEDIACODEC_H263},
59     {"h264", MEDIACODEC_H264},
60     {"mjpeg", MEDIACODEC_MJPEG},
61     {"mpeg1", MEDIACODEC_MPEG1},
62     {"mpeg2", MEDIACODEC_MPEG2},
63     {"mpeg4", MEDIACODEC_MPEG4},
64     {"hevc", MEDIACODEC_HEVC},
65     {"vp8", MEDIACODEC_VP8},
66     {"vp9", MEDIACODEC_VP9},
67     {"vc1", MEDIACODEC_VC1},
68     {"aac_lc", MEDIACODEC_AAC_LC},
69     {"aac_he", MEDIACODEC_AAC_HE},
70     {"aac_he_ps", MEDIACODEC_AAC_HE_PS},
71     {"mp3", MEDIACODEC_MP3},
72     {"amr_nb", MEDIACODEC_AMR_NB},
73     {"amr_wb", MEDIACODEC_AMR_WB},
74     {"vorbis", MEDIACODEC_VORBIS},
75     {"flac", MEDIACODEC_FLAC},
76     {"wmav1", MEDIACODEC_WMAV1},
77     {"wmav2", MEDIACODEC_WMAV2},
78     {"wmapro", MEDIACODEC_WMAPRO},
79 };
80
81 /* internal functions, macros here */
82 #ifdef MEDIA_CODEC_DEFAULT_INI
83 static gboolean _generate_default_ini(void);
84 #endif
85
86 static void _mc_ini_check_ini_status(void);
87
88 /* macro */
89 #define MEDIA_CODEC_INI_GET_STRING( x_dict, x_item, x_ini, x_default ) \
90     do \
91 { \
92     gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
93     \
94     if ( str &&  \
95             ( strlen( str ) > 0 ) && \
96             ( strlen( str ) < MEDIA_CODEC_INI_MAX_STRLEN ) ) \
97     { \
98         strncpy ( x_item, str, strlen(str)+1 ); \
99     } \
100     else \
101     { \
102         strncpy ( x_item, x_default, strlen(x_default)+1 ); \
103     } \
104 }while(0)
105
106 #define MEDIA_CODEC_INI_GET_STRING_FROM_LIST( x_dict, x_list, x_ini, x_default ) \
107     do \
108 { \
109     char *token = NULL; \
110     char *usr_ptr = NULL; \
111     int index = 0; \
112     const char *delimiters = " ,"; \
113     gchar temp_arr[MEDIA_CODEC_INI_MAX_STRLEN] = {0}; \
114     MEDIA_CODEC_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \
115     token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
116     while (token) \
117     { \
118         if (index == 0) \
119         strncpy(x_list.name,token, MEDIA_CODEC_INI_MAX_STRLEN-1 );\
120         else if (index == 1) \
121         strncpy(x_list.mime,token, MEDIA_CODEC_INI_MAX_STRLEN-1 );\
122         else if (index == 2) \
123         strncpy(x_list.format,token, MEDIA_CODEC_INI_MAX_STRLEN-1 );\
124         index++;\
125         token = strtok_r( NULL, delimiters, &usr_ptr ); \
126     } \
127 }while(0)
128
129 #define MEDIA_CODEC_INI_GET_COLOR( x_dict, x_item, x_ini, x_default ) \
130     do \
131 { \
132     gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
133     \
134     if ( str &&  \
135             ( strlen( str ) > 0 ) && \
136             ( strlen( str ) < MEDIA_CODEC_INI_MAX_STRLEN ) ) \
137     { \
138         x_item = (guint) strtoul(str, NULL, 16); \
139     } \
140     else \
141     { \
142         x_item = (guint) strtoul(x_default, NULL, 16); \
143     } \
144 }while(0)
145
146 /* x_ini is the list of index to set TRUE at x_list[index] */
147 #define MEDIA_CODEC_INI_GET_BOOLEAN_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
148     do \
149 { \
150     int index = 0; \
151     const char *delimiters = " ,"; \
152     char *usr_ptr = NULL; \
153     char *token = NULL; \
154     gchar temp_arr[MEDIA_CODEC_INI_MAX_STRLEN] = {0}; \
155     MEDIA_CODEC_INI_GET_STRING( x_dict, temp_arr, x_ini, x_default); \
156     token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
157     while (token) \
158     { \
159         index = atoi(token); \
160         if (index < 0 || index > x_list_max -1) \
161         { \
162             LOGW("%d is not valid index\n", index); \
163         } \
164         else \
165         { \
166             x_list[index] = TRUE; \
167         } \
168         token = strtok_r( NULL, delimiters, &usr_ptr ); \
169     } \
170 }while(0)
171
172 /* x_ini is the list of value to be set at x_list[index] */
173 #define MEDIA_CODEC_INI_GET_INT_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
174     do \
175 { \
176     int index = 0; \
177     int value = 0; \
178     const char *delimiters = " ,"; \
179     char *usr_ptr = NULL; \
180     char *token = NULL; \
181     gchar temp_arr[MEDIA_CODEC_INI_MAX_STRLEN] = {0}; \
182     MEDIA_CODEC_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \
183     token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
184     while (token) \
185     { \
186         if ( index > x_list_max -1) \
187         { \
188             LOGE("%d is not valid index\n", index); \
189             break; \
190         } \
191         else \
192         { \
193             value = atoi(token); \
194             x_list[index] = value; \
195             index++; \
196         } \
197         token = strtok_r( NULL, delimiters, &usr_ptr ); \
198     } \
199 }while(0)
200
201 #define MEDIA_CODEC_GET_DEFAULT_LIST( x_list, x_default ) \
202     do \
203 { \
204     strncpy( x_list, x_default, MEDIA_CODEC_INI_MAX_STRLEN - 1);\
205 }while(0)
206 #define MEDIA_CODEC_PRINT_LIST( x_list,  x_message ) \
207     do \
208 { \
209     codec_info_t codec_list= x_list;\
210     printf("%s =", x_message);\
211     printf("%s %s %s\n", codec_list.name, codec_list.mime, codec_list.format);\
212 }while(0)
213
214 media_format_mimetype_e _mc_convert_media_format_str_to_int(char *sformat )
215 {
216
217     media_format_mimetype_e iformat = MEDIA_FORMAT_I420;
218     if (!strcmp(sformat,"I420")) {
219         iformat = MEDIA_FORMAT_I420;
220         goto endf;
221     } else if (!strcmp(sformat,"NV12")) {
222         iformat = MEDIA_FORMAT_NV12;
223         goto endf;
224     } else if (!strcmp(sformat,"NV12T")) {
225         iformat = MEDIA_FORMAT_NV12T;
226         goto endf;
227     } else if (!strcmp(sformat,"YV12")) {
228         iformat = MEDIA_FORMAT_YV12;
229         goto endf;
230     } else if (!strcmp(sformat,"NV21")) {
231         iformat = MEDIA_FORMAT_NV21;
232         goto endf;
233     } else if (!strcmp(sformat,"NV16")) {
234         iformat = MEDIA_FORMAT_NV16;
235     } else if (!strcmp(sformat,"YUYV")) {
236         iformat = MEDIA_FORMAT_YUYV;
237         goto endf;
238     } else if (!strcmp(sformat,"UYVY")) {
239         iformat = MEDIA_FORMAT_UYVY;
240         goto endf;
241     } else if (!strcmp(sformat,"422P")) {
242         iformat = MEDIA_FORMAT_422P;
243         goto endf;
244     } else if (!strcmp(sformat,"RGB565")) {
245         iformat = MEDIA_FORMAT_RGB565;
246         goto endf;
247     } else if (!strcmp(sformat,"RGB888")) {
248         iformat = MEDIA_FORMAT_RGB888;
249         goto endf;
250     } else if (!strcmp(sformat,"RGBA")) {
251         iformat = MEDIA_FORMAT_RGBA;
252         goto endf;
253     } else if (!strcmp(sformat,"ARGB")) {
254         iformat = MEDIA_FORMAT_ARGB;
255         goto endf;
256     } else if (!strcmp(sformat,"PCM")) {
257         iformat = MEDIA_FORMAT_PCM;
258         goto endf;
259     } else if (!strcmp(sformat,"H261")) {
260         iformat = MEDIA_FORMAT_H261;
261         goto endf;
262     } else if (!strcmp(sformat,"H263")) {
263         iformat = MEDIA_FORMAT_H263;
264         goto endf;
265     } else if (!strcmp(sformat,"H263P")) {
266         iformat = MEDIA_FORMAT_H263P;
267         goto endf;
268     } else if (!strcmp(sformat,"H264_SP")) {
269         iformat = MEDIA_FORMAT_H264_SP;
270         goto endf;
271     } else if (!strcmp(sformat,"H264_MP")) {
272         iformat = MEDIA_FORMAT_H264_MP;
273         goto endf;
274     } else if (!strcmp(sformat,"H264_HP")) {
275         iformat = MEDIA_FORMAT_H264_HP;
276         goto endf;
277     } else if (!strcmp(sformat,"MPEG4_SP")) {
278         iformat = MEDIA_FORMAT_MPEG4_SP;
279         goto endf;
280     } else if (!strcmp(sformat,"MPEG4_ASP")) {
281         iformat = MEDIA_FORMAT_MPEG4_ASP;
282         goto endf;
283     } else if (!strcmp(sformat,"AMR_NB")) {
284         iformat = MEDIA_FORMAT_AMR_NB;
285         goto endf;
286     } else if (!strcmp(sformat,"AMR_WB")) {
287         iformat = MEDIA_FORMAT_AMR_WB;
288         goto endf;
289     } else if (!strcmp(sformat,"AAC_LC")) {
290         iformat = MEDIA_FORMAT_AAC_LC;
291         goto endf;
292     } else if (!strcmp(sformat,"AAC_HE")) {
293         iformat = MEDIA_FORMAT_AAC_HE;
294         goto endf;
295     } else if (!strcmp(sformat,"AAC_HE_PS")) {
296         iformat = MEDIA_FORMAT_AAC_HE_PS;
297         goto endf;
298     } else if (!strcmp(sformat,"MP3")) {
299         iformat = MEDIA_FORMAT_MP3;
300         goto endf;
301     } else if (!strcmp(sformat,"VORBIS")) {
302         iformat = MEDIA_FORMAT_VORBIS;
303         goto endf;
304     } else if (!strcmp(sformat,"FLAC")) {
305         iformat = MEDIA_FORMAT_FLAC;
306         goto endf;
307     } else if (!strcmp(sformat,"WMAV1")) {
308         iformat = MEDIA_FORMAT_WMAV1;
309         goto endf;
310     } else if (!strcmp(sformat,"WMAV2")) {
311         iformat = MEDIA_FORMAT_WMAV2;
312         goto endf;
313     } else if (!strcmp(sformat,"WMAPRO")) {
314         iformat = MEDIA_FORMAT_WMAPRO;
315         goto endf;
316     }
317
318 endf:
319     LOGD("sformat : %x", iformat);
320     return iformat;
321 }
322
323 int mc_ini_load(mc_ini_t *ini)
324 {
325     gchar cname[CNAME_SIZE];
326     int i = 0;
327     dictionary *dict = NULL;
328
329     static const int codec_list = sizeof(general_codec_list) / sizeof(general_codec_list[0]);
330
331     _mc_ini_check_ini_status();
332
333     /* first, try to load existing ini file */
334     dict = iniparser_load(MEDIA_CODEC_INI_DEFAULT_PATH);
335
336     /* if no file exists. create one with set of default values */
337     if (!dict) {
338 #ifdef MEDIA_CODEC_DEFAULT_INI
339         LOGD("No inifile found. codec will create default inifile.\n");
340         if (FALSE == _generate_default_ini()) {
341             LOGW("Creating default inifile failed. Media Codec will use default values.\n");
342         } else {
343             /* load default ini */
344             dict = iniparser_load(MEDIA_CODEC_INI_DEFAULT_PATH);
345         }
346 #else
347         LOGD("No ini file found. \n");
348         return LOGERROR_FILE_NOT_FOUND;
349 #endif
350     }
351
352     /* get ini values */
353     memset(ini, 0, sizeof(mc_ini_t));
354
355     if (dict) {/* if dict is available */
356         /* general */
357         MEDIA_CODEC_INI_GET_STRING( dict, ini->port_name, "port_in_use:media_codec_port",DEFAULT_PORT);
358         /* codec */
359         for (i = 0; i < codec_list; i++) {
360             memset(cname, 0x00, CNAME_SIZE);
361             snprintf(cname, CNAME_SIZE, "%s", general_codec_list[i].cname);
362             int len = strlen(cname);
363
364             ini->codec[i].codec_id =  general_codec_list[i].ctype;
365             snprintf(cname+len, CNAME_SIZE-len, "%s", ":hw_decoder");
366             MEDIA_CODEC_INI_GET_STRING_FROM_LIST( dict, ini->codec[i].codec_info[0], cname, DEFAULT_VALUE);
367             snprintf(cname+len, CNAME_SIZE-len, "%s",":hw_encoder");
368             MEDIA_CODEC_INI_GET_STRING_FROM_LIST( dict, ini->codec[i].codec_info[1], cname, DEFAULT_VALUE);
369             snprintf(cname+len, CNAME_SIZE-len, "%s",":sw_decoder");
370             MEDIA_CODEC_INI_GET_STRING_FROM_LIST( dict, ini->codec[i].codec_info[2], cname, DEFAULT_VALUE);
371             snprintf(cname+len, CNAME_SIZE-len, "%s",":sw_encoder");
372             MEDIA_CODEC_INI_GET_STRING_FROM_LIST( dict, ini->codec[i].codec_info[3], cname, DEFAULT_VALUE);
373         }
374     } else {/* if dict is not available just fill the structure with default value */
375
376         LOGW("failed to load ini. using hardcoded default\n");
377         /* general */
378         snprintf(ini->port_name, sizeof(ini->port_name), "%s", DEFAULT_PORT);
379         for (i = 0;i < codec_list; i++) {
380             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[0].name,   DEFAULT_HW_DECODER_NAME);
381             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[0].mime,   DEFAULT_HW_DECODER_MIME);
382             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[0].format, DEFAULT_HW_DECODER_FORMAT);
383
384             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[1].name,   DEFAULT_HW_ENCODER_NAME);
385             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[1].mime,   DEFAULT_HW_ENCODER_MIME);
386             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[1].format, DEFAULT_HW_ENCODER_FORMAT);
387
388             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[2].name,   DEFAULT_SW_DECODER_NAME);
389             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[2].mime,   DEFAULT_SW_DECODER_MIME);
390             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[2].format, DEFAULT_SW_DECODER_FORMAT);
391
392             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[3].name,   DEFAULT_SW_ENCODER_NAME);
393             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[3].mime,   DEFAULT_SW_ENCODER_MIME);
394             MEDIA_CODEC_GET_DEFAULT_LIST(  ini->codec[i].codec_info[3].format, DEFAULT_SW_ENCODER_FORMAT);
395         }
396     }
397
398     if (0 == strcmp(ini->port_name, "GST_PORT"))
399         ini->port_type = GST_PORT;
400     else {
401         LOGE("Invalid port is set to [%s] [%d]\n", ini->port_name,ini->port_type);
402         iniparser_freedict(dict);
403         goto ERROR;
404     }
405     LOGD("The port is set to [%s] [%d]\n", ini->port_name, ini->port_type);
406
407     for (i = 0;i < codec_list; i++) {
408         memset(cname, 0x00, CNAME_SIZE);
409         snprintf(cname, CNAME_SIZE, "%s", general_codec_list[i].cname);
410         int len = strlen(cname);
411
412         snprintf(cname+len, CNAME_SIZE-len, "%s",":hw_decoder");
413         MEDIA_CODEC_PRINT_LIST(ini->codec[i].codec_info[0],cname);
414         snprintf(cname+len, CNAME_SIZE-len, "%s",":hw_encoder");
415         MEDIA_CODEC_PRINT_LIST(ini->codec[i].codec_info[1],cname);
416         snprintf(cname+len, CNAME_SIZE-len, "%s",":sw_decoder");
417         MEDIA_CODEC_PRINT_LIST(ini->codec[i].codec_info[2],cname);
418         snprintf(cname+len, CNAME_SIZE-len, "%s",":sw_encoder");
419         MEDIA_CODEC_PRINT_LIST(ini->codec[i].codec_info[3],cname);
420     }
421
422     /* free dict as we got our own structure */
423     iniparser_freedict(dict);
424
425     /* dump structure */
426     LOGD("codec settings -----------------------------------\n");
427
428     /* general */
429     LOGD("port_name: %s\n", ini->port_name);
430     LOGD("port_type : %d\n", ini->port_type);
431
432     return MC_ERROR_NONE;
433 ERROR:
434     return MC_COURRPTED_INI;
435
436 }
437
438 static void _mc_ini_check_ini_status(void)
439 {
440     struct stat ini_buff;
441
442     if (g_stat(MEDIA_CODEC_INI_DEFAULT_PATH, &ini_buff) < 0) {
443         LOGW("failed to get codec ini status\n");
444     } else {
445         if (ini_buff.st_size < 5) {
446             LOGW("codec.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
447
448             if (g_remove(MEDIA_CODEC_INI_DEFAULT_PATH) == -1) {
449                 LOGE("failed to delete corrupted ini");
450             }
451         }
452     }
453 }
454
455 #ifdef MEDIA_CODEC_DEFAULT_INI
456 static gboolean _generate_default_ini(void)
457 {
458     FILE *fp = NULL;
459     gchar *default_ini = MEDIA_CODEC_DEFAULT_INI;
460
461     /* create new file */
462     fp = fopen(MEDIA_CODEC_INI_DEFAULT_PATH, "wt");
463
464     if (!fp) {
465         return FALSE;
466     }
467
468     /* writing default ini file */
469     if (strlen(default_ini) !=
470             fwrite(default_ini, 1, strlen(default_ini), fp)) {
471         fclose(fp);
472         return FALSE;
473     }
474
475     fclose(fp);
476     return TRUE;
477 }
478 #endif
479
480 void _mc_create_decoder_map_from_ini(mc_handle_t *mediacodec)
481 {
482     int indx = 0, count = 0;
483     int codec_list = sizeof(general_codec_list) / sizeof(general_codec_list[0]);
484     for (indx=0;indx <codec_list;indx++) {
485         if (strcmp(mediacodec->ini.codec[indx].codec_info[0].name, "")) {
486             mediacodec->decoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
487             mediacodec->decoder_map[count].hardware = 1; // hardware
488             mediacodec->decoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[0].name;
489             mediacodec->decoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[0].mime;
490             mediacodec->decoder_map[count].type.out_format=  _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[0].format);
491             count++;
492         }
493
494         if (strcmp(mediacodec->ini.codec[indx].codec_info[2].name, "")) {
495             mediacodec->decoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
496             mediacodec->decoder_map[count].hardware = 0; // software
497             mediacodec->decoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[2].name;
498             mediacodec->decoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[2].mime;
499             mediacodec->decoder_map[count].type.out_format=  _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[2].format);
500             count++;
501         }
502     }
503     mediacodec->num_supported_decoder = count;
504     return;
505
506 }
507
508 void _mc_create_encoder_map_from_ini(mc_handle_t *mediacodec)
509 {
510     int indx = 0, count = 0;
511     int codec_list = sizeof(general_codec_list) / sizeof(general_codec_list[0]);
512
513     for (indx=0;indx <codec_list;indx++) {
514         if (strcmp(mediacodec->ini.codec[indx].codec_info[1].name, "")) {
515             mediacodec->encoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
516             mediacodec->encoder_map[count].hardware = 1;
517             mediacodec->encoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[1].name;
518             mediacodec->encoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[1].mime;
519             mediacodec->encoder_map[count].type.out_format=  _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[1].format);
520             count++;
521         }
522
523         if (strcmp(mediacodec->ini.codec[indx].codec_info[3].name, "")) {
524             mediacodec->encoder_map[count].id = mediacodec->ini.codec[indx].codec_id;
525             mediacodec->encoder_map[count].hardware = 0;
526             mediacodec->encoder_map[count].type.factory_name = mediacodec->ini.codec[indx].codec_info[3].name;
527             mediacodec->encoder_map[count].type.mime = mediacodec->ini.codec[indx].codec_info[3].mime;
528             mediacodec->encoder_map[count].type.out_format=  _mc_convert_media_format_str_to_int(mediacodec->ini.codec[indx].codec_info[3].format);
529             count++;
530         }
531     }
532     mediacodec->num_supported_encoder = count;
533     return;
534
535 }
536 void _mc_create_codec_map_from_ini(mc_handle_t *mediacodec, mc_codec_spec_t *spec_emul)
537 {
538     int indx = 0, count = 0;
539     int codec_list = sizeof(general_codec_list) / sizeof(general_codec_list[0]);
540     for (indx=0;indx <codec_list;indx++) {
541         if (strcmp(mediacodec->ini.codec[indx].codec_info[0].name, "")) {
542             spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
543             spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_HW;
544             spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
545             count++;
546         }
547         if (strcmp(mediacodec->ini.codec[indx].codec_info[1].name, "")) {
548             spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
549             spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_HW;
550             spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
551             count++;
552         }
553         if (strcmp(mediacodec->ini.codec[indx].codec_info[2].name, "")) {
554             spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
555             spec_emul[count].codec_type =  MEDIACODEC_DECODER | MEDIACODEC_SUPPORT_TYPE_SW;
556             spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
557             count++;
558         }
559         if (strcmp(mediacodec->ini.codec[indx].codec_info[3].name, "")) {
560             spec_emul[count].codec_id = mediacodec->ini.codec[indx].codec_id;
561             spec_emul[count].codec_type =  MEDIACODEC_ENCODER | MEDIACODEC_SUPPORT_TYPE_SW;
562             spec_emul[count].port_type =  MEDIACODEC_PORT_TYPE_GST;
563             count++;
564         }
565     }
566
567     mediacodec->num_supported_codecs = count;
568     return;
569 }
570
571 #endif /* #ifdef _MEDIA_CODEC_INI_C_ */