[0.6.244] Fix the bug that does not disconnect pad signal
[platform/core/multimedia/libmm-player.git] / src / mm_player_attrs.c
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 /*===========================================================================================
24 |                                                                                                                                                                                       |
25 |  INCLUDE FILES                                                                                                                                                        |
26 |                                                                                                                                                                                       |
27 ========================================================================================== */
28 #include <dlog.h>
29 #include <mm_attrs.h>
30 #include "mm_player_utils.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
33
34 /*===========================================================================================
35 |                                                                                                                                                                                       |
36 |  LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                        |
37 |                                                                                                                                                                                       |
38 ========================================================================================== */
39
40 /*-----------------------------------------------------------------------
41 |    LOCAL FUNCTION PROTOTYPES:                                         |
42 -----------------------------------------------------------------------*/
43 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
44 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
45 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
46
47 /*===========================================================================================
48 |                                                                                                                                                                                                               |
49 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
50 |                                                                                                                                                                                                               |
51 ========================================================================================== */
52
53 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
54 {
55         mmplayer_t *player = MM_PLAYER_CAST(handle);
56         mmplayer_gst_element_t *videobin = NULL;
57
58         MMPLAYER_FENTER();
59         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
60
61         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
62                 LOGD("will be applied when videosink is ready");
63                 return true;
64         }
65
66         if (!player->set_mode.video_export) {
67                 LOGW("there is no callback for enabling");
68                 return true;
69         }
70
71         videobin = player->pipeline->videobin;
72
73         LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
74
75         g_object_set(videobin[MMPLAYER_V_SINK].gst,
76                                 "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
77
78         return true;
79 }
80
81 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
82 {
83         mmplayer_t *player = MM_PLAYER_CAST(handle);
84         mmplayer_gst_element_t *videobin = NULL;
85
86         MMPLAYER_FENTER();
87         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
88
89         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
90                 LOGD("will be applied when videosink is ready");
91                 return true;
92         }
93
94         videobin = player->pipeline->videobin;
95
96         if (value->value.i_val > 0) {
97                 LOGD("[update plugin][videosink] disable last sample for gapless");
98                 g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
99         }
100
101         return true;
102 }
103
104 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
105 {
106         mmplayer_t *player = MM_PLAYER_CAST(handle);
107         mmplayer_pipeline_info_t *pipeline;
108         int pitch_control = 0;
109
110         MMPLAYER_FENTER();
111         MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
112         MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->audiobin, true);
113
114         pipeline = player->pipeline;
115         mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
116
117         if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
118                 LOGW("audio pitch is disabled");
119                 return true;
120         }
121
122         LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
123         g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
124
125         return true;
126 }
127
128 static int __mmplayer_get_array_count(MMHandleType handle, int type)
129 {
130         mmplayer_t *player = MM_PLAYER_CAST(handle);
131
132         int count = 0;
133         int i = 0;
134
135         if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
136                 while (player->ini.audio_offload_media_format[i++][0])
137                         count++;
138         } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
139                 while (player->ini.media_stream_input_format[i++][0])
140                         count++;
141         }
142         return count;
143 }
144
145 static media_format_mimetype_e __mmplayer_get_supported_format_mimetype(MMHandleType handle, int type, int i)
146 {
147         mmplayer_t *player = MM_PLAYER_CAST(handle);
148         media_format_mimetype_e format = MEDIA_FORMAT_MAX;
149         char *name = NULL;
150
151         if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
152                 name = player->ini.audio_offload_media_format[i];
153         } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
154                 name = player->ini.media_stream_input_format[i];
155         } else {
156                 LOGE("invalid ini type");
157                 goto EXIT;
158         }
159
160         if (!strcmp(name, "MP3"))
161                 format = MEDIA_FORMAT_MP3;
162         else if (!strcmp(name, "AAC"))
163                 format = MEDIA_FORMAT_AAC;
164         else if (!strcmp(name, "H264_SP"))
165                 format = MEDIA_FORMAT_H264_SP;
166         else if (!strcmp(name, "H264_MP"))
167                 format = MEDIA_FORMAT_H264_MP;
168         else if (!strcmp(name, "H264_HP"))
169                 format = MEDIA_FORMAT_H264_HP;
170         else if (!strcmp(name, "PCM"))
171                 format = MEDIA_FORMAT_PCM;
172         else if (!strcmp(name, "PCM_S16LE"))
173                 format = MEDIA_FORMAT_PCM_S16LE;
174         else if (!strcmp(name, "PCM_S24LE"))
175                 format = MEDIA_FORMAT_PCM_S24LE;
176         else if (!strcmp(name, "PCM_S32LE"))
177                 format = MEDIA_FORMAT_PCM_S32LE;
178         else if (!strcmp(name, "PCM_S16BE"))
179                 format = MEDIA_FORMAT_PCM_S16BE;
180         else if (!strcmp(name, "PCM_S24BE"))
181                 format = MEDIA_FORMAT_PCM_S24BE;
182         else if (!strcmp(name, "PCM_S32BE"))
183                 format = MEDIA_FORMAT_PCM_S32BE;
184         else if (!strcmp(name, "PCM_F32LE"))
185                 format = MEDIA_FORMAT_PCM_F32LE;
186         else if (!strcmp(name, "PCM_F32BE"))
187                 format = MEDIA_FORMAT_PCM_F32BE;
188         else if (!strcmp(name, "PCM_U16LE"))
189                 format = MEDIA_FORMAT_PCM_U16LE;
190         else if (!strcmp(name, "PCM_U24LE"))
191                 format = MEDIA_FORMAT_PCM_U24LE;
192         else if (!strcmp(name, "PCM_U32LE"))
193                 format = MEDIA_FORMAT_PCM_U32LE;
194         else if (!strcmp(name, "PCM_U16BE"))
195                 format = MEDIA_FORMAT_PCM_U16BE;
196         else if (!strcmp(name, "PCM_U24BE"))
197                 format = MEDIA_FORMAT_PCM_U24BE;
198         else if (!strcmp(name, "PCM_U32BE"))
199                 format = MEDIA_FORMAT_PCM_U32BE;
200         else
201                 LOGE("FIXME: need to modify function to support more format");
202
203 EXIT:
204         LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
205
206         return format;
207 }
208
209 static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
210 {
211         int *arr = NULL;
212         int total_count = 0;
213         int count = 0;
214         int i = 0;
215         int fmt = 0;
216
217         MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
218
219         count = __mmplayer_get_array_count(handle, type);
220
221         if (count <= 0)
222                 return -1;
223
224         arr = (int *) g_malloc0(count * sizeof(int));
225         for (i = 0 ; i < count ; i++) {
226                 fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
227                 if (fmt != MEDIA_FORMAT_MAX)
228                         arr[total_count++] = fmt;
229         }
230
231         if (total_count <= 0) {
232                 g_free(arr);
233                 return -1;
234         }
235
236         LOGD("[%d type] num of supported codec %d", type, total_count);
237
238         *format = arr;
239         return total_count;
240 }
241
242 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
243 {
244         mmplayer_t *player = MM_PLAYER_CAST(handle);
245         int *format = NULL;
246         int total_count = 0;
247
248         /* supported format of audio offload */
249         total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
250         if (format && total_count > 0) {
251                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
252                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
253         }
254
255         /* supported format of media stream input */
256         total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
257         if (format && total_count > 0) {
258                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
259                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
260         }
261
262         /* default codec type */
263         if (!strcmp(player->ini.audiocodec_default_type, "sw"))
264                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
265
266         if (!strcmp(player->ini.videocodec_default_type, "sw"))
267                 player->default_attrs[MMPLAYER_ATTRS_VIDEO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
268
269         return MM_ERROR_NONE;
270 }
271
272 static int __mmplayer_release_ini_info(MMHandleType handle)
273 {
274         mmplayer_t *player = MM_PLAYER_CAST(handle);
275         int *mem = NULL;
276
277         MMPLAYER_FENTER();
278
279         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
280         g_free(mem);
281         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
282         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
283
284         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
285         g_free(mem);
286         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
287         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
288
289         MMPLAYER_FLEAVE();
290         return MM_ERROR_NONE;
291 }
292
293 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
294 {
295         switch (value->type) {
296         case MM_ATTRS_TYPE_INT:
297                 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
298                 break;
299         case MM_ATTRS_TYPE_DOUBLE:
300                 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
301                 break;
302         case MM_ATTRS_TYPE_STRING:
303                 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
304                 break;
305         case MM_ATTRS_TYPE_DATA:
306                 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
307                 break;
308         default:
309                 break;
310         }
311
312         return;
313 }
314
315 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
316 {
317         bool ret = false;
318         mmplayer_t *player = MM_PLAYER_CAST(commit_param);
319
320         MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
321
322         if (player->default_attrs[attr_idx].attr_commit) {
323                 __mmplayer_print_attrs(attr_name, value, "Dynamic");
324                 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
325         } else {
326                 __mmplayer_print_attrs(attr_name, value, "Static");
327                 ret = true;
328         }
329
330         return ret;
331 }
332
333 int _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
334 {
335         int result = MM_ERROR_NONE;
336         MMHandleType attrs = NULL;
337
338         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
339         /* if it's not want to know it. */
340         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
341         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
342
343         attrs = MM_PLAYER_GET_ATTRS(handle);
344
345         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
346
347         if (result != MM_ERROR_NONE)
348                 LOGE("failed to get %s attribute", attribute_name);
349
350         return result;
351 }
352
353 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
354 {
355         mmplayer_t *player = NULL;
356
357         MMPLAYER_FENTER();
358         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
359         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
360
361         player = MM_PLAYER_CAST(handle);
362
363         /* apply display attr value to player handle */
364         if (!g_strrstr(attribute_name, "display"))
365                 return MM_ERROR_NONE;
366
367         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
368                 LOGD("will be applied when videosink is ready");
369                 return MM_ERROR_NONE;
370         }
371
372         if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
373                 LOGW("not supported video param %s", attribute_name);
374                 return MM_ERROR_NONE;
375         }
376
377         return MM_ERROR_NONE;
378 }
379
380 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
381 {
382         int result = MM_ERROR_NONE;
383         MMHandleType attrs = NULL;
384
385         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
386         /* if it's not want to know it. */
387         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
388         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
389
390         attrs = MM_PLAYER_GET_ATTRS(handle);
391
392         /* set attributes and commit them */
393         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
394         if (result != MM_ERROR_NONE) {
395                 LOGE("failed to set %s attribute", attribute_name);
396                 return result;
397         }
398
399         /* Note: 'attr_commit' function is called before committing the new value to attr struct.
400                  so if there is a value to apply after committing, it should be added below function. */
401         result = __mmplayer_apply_attribute(handle, attribute_name);
402         if (result != MM_ERROR_NONE) {
403                 LOGE("failed to apply attributes");
404                 return result;
405         }
406
407         return MM_ERROR_NONE;
408 }
409
410 int _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, mmplayer_attrs_info_t *dst_info)
411 {
412         int result = MM_ERROR_NONE;
413         MMHandleType attrs = NULL;
414         MMAttrsInfo src_info = {0, };
415
416         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
417         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
418         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
419
420         attrs = MM_PLAYER_GET_ATTRS(handle);
421
422         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
423
424         if (result != MM_ERROR_NONE) {
425                 LOGE("failed to get attribute info");
426                 return result;
427         }
428
429         memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
430
431         dst_info->type = src_info.type;
432         dst_info->flag = src_info.flag;
433         dst_info->validity_type = src_info.validity_type;
434
435         switch (src_info.validity_type) {
436         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
437                 dst_info->int_array.array = src_info.int_array.array;
438                 dst_info->int_array.count = src_info.int_array.count;
439                 dst_info->int_array.d_val = src_info.int_array.dval;
440                 break;
441
442         case MM_ATTRS_VALID_TYPE_INT_RANGE:
443                 dst_info->int_range.min = src_info.int_range.min;
444                 dst_info->int_range.max = src_info.int_range.max;
445                 dst_info->int_range.d_val = src_info.int_range.dval;
446                 break;
447
448         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
449                 dst_info->double_array.array = src_info.double_array.array;
450                 dst_info->double_array.count = src_info.double_array.count;
451                 dst_info->double_array.d_val = src_info.double_array.dval;
452                 break;
453
454         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
455                 dst_info->double_range.min = src_info.double_range.min;
456                 dst_info->double_range.max = src_info.double_range.max;
457                 dst_info->double_range.d_val = src_info.double_range.dval;
458                 break;
459
460         default:
461                 break;
462         }
463
464         return result;
465 }
466
467 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
468 {
469         mmplayer_t *player = MM_PLAYER_CAST(handle);
470         int result = MM_ERROR_NONE;
471         int idx = 0;
472         MMHandleType attrs = NULL;
473         int num_of_attrs = 0;
474         MMAttrsConstructInfo *base = NULL;
475
476         mmplayer_attrs_spec_t player_attrs[] = {
477                 {
478                         MMPLAYER_ATTRS_PROFILE_URI,                /* ID */
479                         (char *)"profile_uri",                             /* Name */
480                         MM_ATTRS_TYPE_STRING,                              /* Value Type */
481                         MM_ATTRS_FLAG_RW,                                          /* Flag */
482                         {(void *)NULL},                                            /* default value */
483                         MM_ATTRS_VALID_TYPE_NONE,                          /* validity type */
484                         {0},                                                               /* validity min value */
485                         {0},                                                               /* validity max value */
486                         NULL,                                                              /* Runtime setting function of the attribute */
487                 },
488                 {
489                         MMPLAYER_ATTRS_PROFILE_USER_PARAM,
490                         (char *)"profile_user_param",
491                         MM_ATTRS_TYPE_DATA,
492                         MM_ATTRS_FLAG_RW,
493                         {(void *)NULL},
494                         MM_ATTRS_VALID_TYPE_NONE,
495                         {0},
496                         {0},
497                         NULL,
498                 },
499                 {
500                         MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
501                         (char *)"profile_play_count",
502                         MM_ATTRS_TYPE_INT,
503                         MM_ATTRS_FLAG_RW,
504                         {(void *)1},                                            /* -1 : repeat continually */
505                         MM_ATTRS_VALID_TYPE_INT_RANGE,
506                         {.int_min = -1},
507                         {.int_max = 1},
508                         NULL,
509                 },
510                 {
511                         MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
512                         (char *)"profile_prepare_async",
513                         MM_ATTRS_TYPE_INT,
514                         MM_ATTRS_FLAG_RW,
515                         {(void *)0},
516                         MM_ATTRS_VALID_TYPE_INT_RANGE,
517                         {.int_min = 0},
518                         {.int_max = 1},
519                         NULL,
520                 },
521                 {
522                         MMPLAYER_ATTRS_STREAMING_USER_AGENT,
523                         (char *)"streaming_user_agent",
524                         MM_ATTRS_TYPE_STRING,
525                         MM_ATTRS_FLAG_RW,
526                         {(void *)NULL},
527                         MM_ATTRS_VALID_TYPE_NONE,
528                         {0},
529                         {0},
530                         NULL,
531                 },
532                 {
533                         MMPLAYER_ATTRS_STREAMING_COOKIE,
534                         (char *)"streaming_cookie",
535                         MM_ATTRS_TYPE_STRING,
536                         MM_ATTRS_FLAG_RW,
537                         {(void *)NULL},
538                         MM_ATTRS_VALID_TYPE_NONE,
539                         {0},
540                         {0},
541                         NULL,
542                 },
543                 {
544                         MMPLAYER_ATTRS_SUBTITLE_URI,
545                         (char *)"subtitle_uri",
546                         MM_ATTRS_TYPE_STRING,
547                         MM_ATTRS_FLAG_RW,
548                         {(void *)NULL},
549                         MM_ATTRS_VALID_TYPE_NONE,
550                         {0},
551                         {0},
552                         NULL,
553                 },
554                 {
555                         MMPLAYER_ATTRS_CONTENT_BITRATE,
556                         (char *)"content_bitrate",
557                         MM_ATTRS_TYPE_INT,
558                         MM_ATTRS_FLAG_RW,
559                         {(void *)0},
560                         MM_ATTRS_VALID_TYPE_INT_RANGE,
561                         {.int_min = 0},
562                         {.int_max = MMPLAYER_MAX_INT},
563                         NULL,
564                 },
565                 {
566                         MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
567                         (char *)"content_max_bitrate",
568                         MM_ATTRS_TYPE_INT,
569                         MM_ATTRS_FLAG_RW,
570                         {(void *)0},
571                         MM_ATTRS_VALID_TYPE_INT_RANGE,
572                         {.int_min = 0},
573                         {.int_max = MMPLAYER_MAX_INT},
574                         NULL,
575                 },
576                 {
577                         MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
578                         (char *)"content_video_found",
579                         MM_ATTRS_TYPE_INT,
580                         MM_ATTRS_FLAG_RW,
581                         {(void *)0},
582                         MM_ATTRS_VALID_TYPE_INT_RANGE,
583                         {.int_min = 0},
584                         {.int_max = 1},
585                         NULL,
586                 },
587                 {
588                         MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
589                         (char *)"content_video_codec",
590                         MM_ATTRS_TYPE_STRING,
591                         MM_ATTRS_FLAG_RW,
592                         {(void *)NULL},
593                         MM_ATTRS_VALID_TYPE_NONE,
594                         {0},
595                         {0},
596                         NULL,
597                 },
598                 {
599                         MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
600                         (char *)"content_video_bitrate",
601                         MM_ATTRS_TYPE_INT,
602                         MM_ATTRS_FLAG_RW,
603                         {(void *)0},
604                         MM_ATTRS_VALID_TYPE_INT_RANGE,
605                         {.int_min = 0},
606                         {.int_max = MMPLAYER_MAX_INT},
607                         NULL,
608                 },
609                 {
610                         MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
611                         (char *)"content_video_fps",
612                         MM_ATTRS_TYPE_INT,
613                         MM_ATTRS_FLAG_RW,
614                         {(void *)0},
615                         MM_ATTRS_VALID_TYPE_INT_RANGE,
616                         {.int_min = 0},
617                         {.int_max = MMPLAYER_MAX_INT},
618                         NULL,
619                 },
620                 {
621                         MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
622                         (char *)"content_video_width",
623                         MM_ATTRS_TYPE_INT,
624                         MM_ATTRS_FLAG_RW,
625                         {(void *)0},
626                         MM_ATTRS_VALID_TYPE_INT_RANGE,
627                         {.int_min = 0},
628                         {.int_max = MMPLAYER_MAX_INT},
629                         NULL,
630                 },
631                 {
632                         MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
633                         (char *)"content_video_height",
634                         MM_ATTRS_TYPE_INT,
635                         MM_ATTRS_FLAG_RW,
636                         {(void *)0},
637                         MM_ATTRS_VALID_TYPE_INT_RANGE,
638                         {.int_min = 0},
639                         {.int_max = MMPLAYER_MAX_INT},
640                         NULL,
641                 },
642                 {
643                         MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
644                         (char *)"content_video_orientation",   /* orientation of video content */
645                         MM_ATTRS_TYPE_STRING,
646                         MM_ATTRS_FLAG_RW,
647                         {(void *)NULL},
648                         MM_ATTRS_VALID_TYPE_NONE,
649                         {0},
650                         {0},
651                         NULL,
652                 },
653                 {
654                         MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
655                         (char *)"content_video_is_spherical",
656                         MM_ATTRS_TYPE_INT,
657                         MM_ATTRS_FLAG_RW,
658                         {(void *)-1},
659                         MM_ATTRS_VALID_TYPE_INT_RANGE,
660                         {.int_min = -1},
661                         {.int_max = MMPLAYER_MAX_INT},
662                         NULL,
663                 },
664                 {
665                         MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
666                         (char *)"content_audio_codec",
667                         MM_ATTRS_TYPE_STRING,
668                         MM_ATTRS_FLAG_RW,
669                         {(void *)NULL},
670                         MM_ATTRS_VALID_TYPE_NONE,
671                         {0},
672                         {0},
673                         NULL,
674                 },
675                 {
676                         MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
677                         (char *)"content_audio_bitrate",
678                         MM_ATTRS_TYPE_INT,
679                         MM_ATTRS_FLAG_RW,
680                         {(void *)0},
681                         MM_ATTRS_VALID_TYPE_INT_RANGE,
682                         {.int_min = 0},
683                         {.int_max = MMPLAYER_MAX_INT},
684                         NULL,
685                 },
686                 {
687                         MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
688                         (char *)"content_audio_channels",
689                         MM_ATTRS_TYPE_INT,
690                         MM_ATTRS_FLAG_RW,
691                         {(void *)0},
692                         MM_ATTRS_VALID_TYPE_INT_RANGE,
693                         {.int_min = 0},
694                         {.int_max = MMPLAYER_MAX_INT},
695                         NULL,
696                 },
697                 {
698                         MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
699                         (char *)"content_audio_samplerate",
700                         MM_ATTRS_TYPE_INT,
701                         MM_ATTRS_FLAG_RW,
702                         {(void *)0},
703                         MM_ATTRS_VALID_TYPE_INT_RANGE,
704                         {.int_min = 0},
705                         {.int_max = MMPLAYER_MAX_INT},
706                         NULL,
707                 },
708                 {
709                         MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
710                         (char *)"content_audio_format",
711                         MM_ATTRS_TYPE_STRING,
712                         MM_ATTRS_FLAG_RW,
713                         {(void *)NULL},
714                         MM_ATTRS_VALID_TYPE_NONE,
715                         {0},
716                         {0},
717                         NULL,
718                 },
719                 {
720                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
721                         (char *)"content_text_track_num",
722                         MM_ATTRS_TYPE_INT,
723                         MM_ATTRS_FLAG_RW,
724                         {(void *)0},
725                         MM_ATTRS_VALID_TYPE_INT_RANGE,
726                         {.int_min = 0},
727                         {.int_max = MMPLAYER_MAX_INT},
728                         NULL,
729                 },
730                 {
731                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
732                         (char *)"current_text_track_index",
733                         MM_ATTRS_TYPE_INT,
734                         MM_ATTRS_FLAG_RW,
735                         {(void *)-1},
736                         MM_ATTRS_VALID_TYPE_INT_RANGE,
737                         {.int_min = -1},
738                         {.int_max = MMPLAYER_MAX_INT},
739                         NULL,
740                 },
741                 {
742                         MMPLAYER_ATTRS_TAG_ARTIST,
743                         (char *)"tag_artist",
744                         MM_ATTRS_TYPE_STRING,
745                         MM_ATTRS_FLAG_RW,
746                         {(void *)NULL},
747                         MM_ATTRS_VALID_TYPE_NONE,
748                         {0},
749                         {0},
750                         NULL,
751                 },
752                 {
753                         MMPLAYER_ATTRS_TAG_TITLE,
754                         (char *)"tag_title",
755                         MM_ATTRS_TYPE_STRING,
756                         MM_ATTRS_FLAG_RW,
757                         {(void *)NULL},
758                         MM_ATTRS_VALID_TYPE_NONE,
759                         {0},
760                         {0},
761                         NULL,
762                 },
763                 {
764                         MMPLAYER_ATTRS_TAG_ALBUM,
765                         (char *)"tag_album",
766                         MM_ATTRS_TYPE_STRING,
767                         MM_ATTRS_FLAG_RW,
768                         {(void *)NULL},
769                         MM_ATTRS_VALID_TYPE_NONE,
770                         {0},
771                         {0},
772                         NULL,
773                 },
774                 {
775                         MMPLAYER_ATTRS_TAG_GENRE,
776                         (char *)"tag_genre",
777                         MM_ATTRS_TYPE_STRING,
778                         MM_ATTRS_FLAG_RW,
779                         {(void *)NULL},
780                         MM_ATTRS_VALID_TYPE_NONE,
781                         {0},
782                         {0},
783                         NULL,
784                 },
785                 {
786                         MMPLAYER_ATTRS_TAG_AUTHOR,
787                         (char *)"tag_author",
788                         MM_ATTRS_TYPE_STRING,
789                         MM_ATTRS_FLAG_RW,
790                         {(void *)NULL},
791                         MM_ATTRS_VALID_TYPE_NONE,
792                         {0},
793                         {0},
794                         NULL,
795                 },
796                 {
797                         MMPLAYER_ATTRS_TAG_COPYRIGHT,
798                         (char *)"tag_copyright",
799                         MM_ATTRS_TYPE_STRING,
800                         MM_ATTRS_FLAG_RW,
801                         {(void *)NULL},
802                         MM_ATTRS_VALID_TYPE_NONE,
803                         {0},
804                         {0},
805                         NULL,
806                 },
807                 {
808                         MMPLAYER_ATTRS_TAG_DATE,
809                         (char *)"tag_date",
810                         MM_ATTRS_TYPE_STRING,
811                         MM_ATTRS_FLAG_RW,
812                         {(void *)NULL},
813                         MM_ATTRS_VALID_TYPE_NONE,
814                         {0},
815                         {0},
816                         NULL,
817                 },
818                 {
819                         MMPLAYER_ATTRS_TAG_DESCRIPTION,
820                         (char *)"tag_description",
821                         MM_ATTRS_TYPE_STRING,
822                         MM_ATTRS_FLAG_RW,
823                         {(void *)NULL},
824                         MM_ATTRS_VALID_TYPE_NONE,
825                         {0},
826                         {0},
827                         NULL,
828                 },
829                 {
830                         MMPLAYER_ATTRS_TAG_TRACK_NUM,
831                         (char *)"tag_track_num",
832                         MM_ATTRS_TYPE_INT,
833                         MM_ATTRS_FLAG_RW,
834                         {(void *)0},
835                         MM_ATTRS_VALID_TYPE_INT_RANGE,
836                         {.int_min = 0},
837                         {.int_max = MMPLAYER_MAX_INT},
838                         NULL,
839                 },
840                 {
841                         MMPLAYER_ATTRS_TAG_ALBUM_COVER,
842                         (char *)"tag_album_cover",
843                         MM_ATTRS_TYPE_DATA,
844                         MM_ATTRS_FLAG_RW,
845                         {(void *)NULL},
846                         MM_ATTRS_VALID_TYPE_NONE,
847                         {0},
848                         {0},
849                         NULL,
850                 },
851                 {
852                         MMPLAYER_ATTRS_DISPLAY_ROTATION,
853                         (char *)"display_rotation",
854                         MM_ATTRS_TYPE_INT,
855                         MM_ATTRS_FLAG_RW,
856                         {(void *)MM_DISPLAY_ROTATION_NONE},
857                         MM_ATTRS_VALID_TYPE_INT_RANGE,
858                         {.int_min = MM_DISPLAY_ROTATION_NONE},
859                         {.int_max = MM_DISPLAY_ROTATION_270},
860                         NULL,
861                 },
862                 {
863                         MMPLAYER_ATTRS_DISPLAY_VISIBLE,
864                         (char *)"display_visible",
865                         MM_ATTRS_TYPE_INT,
866                         MM_ATTRS_FLAG_RW,
867                         {(void *)FALSE},
868                         MM_ATTRS_VALID_TYPE_INT_RANGE,
869                         {.int_min = FALSE},
870                         {.int_max = TRUE},
871                         NULL,
872                 },
873                 {
874                         MMPLAYER_ATTRS_DISPLAY_METHOD,
875                         (char *)"display_method",
876                         MM_ATTRS_TYPE_INT,
877                         MM_ATTRS_FLAG_RW,
878                         {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
879                         MM_ATTRS_VALID_TYPE_INT_RANGE,
880                         {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
881                         {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
882                         NULL,
883                 },
884                 {
885                         MMPLAYER_ATTRS_DISPLAY_OVERLAY,
886                         (char *)"display_overlay",
887                         MM_ATTRS_TYPE_INT,
888                         MM_ATTRS_FLAG_RW,
889                         {(void *)0},
890                         MM_ATTRS_VALID_TYPE_INT_RANGE,
891                         {.int_min = 0},
892                         {.int_max = MMPLAYER_MAX_INT},
893                         NULL,
894                 },
895                 {
896                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
897                         (char *)"display_win_roi_x",
898                         MM_ATTRS_TYPE_INT,
899                         MM_ATTRS_FLAG_RW,
900                         {(void *)0},
901                         MM_ATTRS_VALID_TYPE_INT_RANGE,
902                         {.int_min = MMPLAYER_MIN_INT},
903                         {.int_max = MMPLAYER_MAX_INT},
904                         NULL,
905                 },
906                 {
907                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
908                         (char *)"display_win_roi_y",
909                         MM_ATTRS_TYPE_INT,
910                         MM_ATTRS_FLAG_RW,
911                         {(void *)0},
912                         MM_ATTRS_VALID_TYPE_INT_RANGE,
913                         {.int_min = MMPLAYER_MIN_INT},
914                         {.int_max = MMPLAYER_MAX_INT},
915                         NULL,
916                 },
917                 {
918                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
919                         (char *)"display_win_roi_width",
920                         MM_ATTRS_TYPE_INT,
921                         MM_ATTRS_FLAG_RW,
922                         {(void *)0},
923                         MM_ATTRS_VALID_TYPE_INT_RANGE,
924                         {.int_min = 0},
925                         {.int_max = MMPLAYER_MAX_INT},
926                         NULL,
927                 },
928                 {
929                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
930                         (char *)"display_win_roi_height",
931                         MM_ATTRS_TYPE_INT,
932                         MM_ATTRS_FLAG_RW,
933                         {(void *)0},
934                         MM_ATTRS_VALID_TYPE_INT_RANGE,
935                         {.int_min = 0},
936                         {.int_max = MMPLAYER_MAX_INT},
937                         NULL,
938                 },
939                 {
940                         MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
941                         (char *)"display_surface_type",
942                         MM_ATTRS_TYPE_INT,
943                         MM_ATTRS_FLAG_RW,
944                         {(void *)MM_DISPLAY_SURFACE_NULL},
945                         MM_ATTRS_VALID_TYPE_INT_RANGE,
946                         {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
947                         {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
948                         NULL,
949                 },
950                 {
951                         MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
952                         (char *)"sound_stream_type",
953                         MM_ATTRS_TYPE_STRING,
954                         MM_ATTRS_FLAG_RW,
955                         {(void *)NULL},
956                         MM_ATTRS_VALID_TYPE_NONE,
957                         {0},
958                         {0},
959                         NULL,
960                 },
961                 {
962                         MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
963                         (char *)"sound_stream_index",
964                         MM_ATTRS_TYPE_INT,
965                         MM_ATTRS_FLAG_RW,
966                         {(void *)0},
967                         MM_ATTRS_VALID_TYPE_INT_RANGE,
968                         {.int_min = -1},
969                         {.int_max = MMPLAYER_MAX_INT},
970                         NULL,
971                 },
972                 {
973                         MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
974                         (char *)"sound_latency_mode",
975                         MM_ATTRS_TYPE_INT,
976                         MM_ATTRS_FLAG_RW,
977                         {(void *)1},                                             /* 0: low latency, 1: middle latency 2: high latency */
978                         MM_ATTRS_VALID_TYPE_INT_RANGE,
979                         {.int_min = 0},
980                         {.int_max = 2},
981                         NULL,
982                 },
983                 {
984                         MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
985                         (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
986                         MM_ATTRS_TYPE_INT,
987                         MM_ATTRS_FLAG_RW,
988                         {(void *)44100},
989                         MM_ATTRS_VALID_TYPE_INT_RANGE,
990                         {.int_min = 0},
991                         {.int_max = MMPLAYER_MAX_INT},
992                         NULL,
993                 },
994                 {
995                         MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
996                         (char *)"pcm_extraction_channels",       /* set channels for pcm extraction */
997                         MM_ATTRS_TYPE_INT,
998                         MM_ATTRS_FLAG_RW,
999                         {(void *)1},
1000                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1001                         {.int_min = 0},
1002                         {.int_max = MMPLAYER_MAX_INT},
1003                         NULL,
1004                 },
1005                 {
1006                         MMPLAYER_ATTRS_ACCURATE_SEEK,
1007                         (char *)"accurate_seek",
1008                         MM_ATTRS_TYPE_INT,
1009                         MM_ATTRS_FLAG_RW,
1010                         {(void *)0},
1011                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1012                         {.int_min = 0},
1013                         {.int_max = 1},
1014                         NULL,
1015                 },
1016                 {
1017                         MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1018                         (char *)"pcm_extraction_format",
1019                         MM_ATTRS_TYPE_STRING,
1020                         MM_ATTRS_FLAG_RW,
1021                         {(void *)NULL},
1022                         MM_ATTRS_VALID_TYPE_NONE,
1023                         {0},
1024                         {0},
1025                         NULL,
1026                 },
1027                 {
1028                         MMPLAYER_ATTRS_DRC_MODE,
1029                         (char *)"drc_mode",
1030                         MM_ATTRS_TYPE_INT,
1031                         MM_ATTRS_FLAG_RW,
1032                         {(void *)FALSE},
1033                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1034                         {.int_min = FALSE},
1035                         {.int_max = TRUE},
1036                         NULL,
1037                 },
1038                 {
1039                         MMPLAYER_ATTRS_GAPLESS_MODE,
1040                         (char *)"gapless_mode",
1041                         MM_ATTRS_TYPE_INT,
1042                         MM_ATTRS_FLAG_RW,
1043                         {(void *)FALSE},
1044                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1045                         {.int_min = FALSE},
1046                         {.int_max = TRUE},
1047                         __mmplayer_commit_gapless_mode,
1048                 },
1049                 {
1050                         MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1051                         (char *)"enable_video_decoded_cb",
1052                         MM_ATTRS_TYPE_INT,
1053                         MM_ATTRS_FLAG_RW,
1054                         {(void *)FALSE},
1055                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1056                         {.int_min = FALSE},
1057                         {.int_max = TRUE},
1058                         __mmplayer_commit_enable_video_decoded_cb,
1059                 },
1060                 {
1061                         MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1062                         (char *)"video_codec_type",
1063                         MM_ATTRS_TYPE_INT,
1064                         MM_ATTRS_FLAG_RW,
1065                         {(void *)MM_PLAYER_CODEC_TYPE_HW},
1066                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1067                         {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1068                         {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1069                         NULL,
1070                 },
1071                 {
1072                         MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1073                         (char *)"audio_codec_type",
1074                         MM_ATTRS_TYPE_INT,
1075                         MM_ATTRS_FLAG_RW,
1076                         {(void *)MM_PLAYER_CODEC_TYPE_HW},
1077                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1078                         {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1079                         {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1080                         NULL,
1081                 },
1082                 {
1083                         MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1084                         (char *)"video_buffer_total_size",
1085                         MM_ATTRS_TYPE_INT,
1086                         MM_ATTRS_FLAG_RW,
1087                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1088                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1089                         {.int_min = MMPLAYER_MIN_INT},
1090                         {.int_max = MMPLAYER_MAX_INT},
1091                         NULL,
1092                 },
1093                 {
1094                         MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1095                         (char *)"video_buffer_extra_size",
1096                         MM_ATTRS_TYPE_INT,
1097                         MM_ATTRS_FLAG_RW,
1098                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1099                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1100                         {.int_min = MMPLAYER_MIN_INT},
1101                         {.int_max = MMPLAYER_MAX_INT},
1102                         NULL,
1103                 },
1104                 {
1105                         MMPLAYER_ATTRS_PREBUFFER_MS,
1106                         (char *)"prebuffer_ms", /* user setting */
1107                         MM_ATTRS_TYPE_INT,
1108                         MM_ATTRS_FLAG_RW,
1109                         {(void *) MIN_BUFFERING_TIME},
1110                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1111                         {.int_min = MIN_BUFFERING_TIME},
1112                         {.int_max = MMPLAYER_MAX_INT},
1113                         NULL,
1114                 },
1115                 {
1116                         MMPLAYER_ATTRS_REBUFFER_MS,
1117                         (char *)"rebuffer_ms", /* user setting */
1118                         MM_ATTRS_TYPE_INT,
1119                         MM_ATTRS_FLAG_RW,
1120                         {(void *) MIN_BUFFERING_TIME},
1121                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1122                         {.int_min = MIN_BUFFERING_TIME},
1123                         {.int_max = MMPLAYER_MAX_INT},
1124                         NULL,
1125                 },
1126                 {
1127                         MMPLAYER_ATTRS_PITCH_CONTROL,
1128                         (char *)"pitch_control",        /* MM_PLAYER_PITCH_CONTROL */
1129                         MM_ATTRS_TYPE_INT,
1130                         MM_ATTRS_FLAG_RW,
1131                         {(void *)FALSE},
1132                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1133                         {.int_min = FALSE},
1134                         {.int_max = TRUE},
1135                         NULL,
1136                 },
1137                 {
1138                         MMPLAYER_ATTRS_PITCH_VALUE,
1139                         (char *)"pitch_value",          /* MM_PLAYER_PITCH_VALUE */
1140                         MM_ATTRS_TYPE_DOUBLE,
1141                         MM_ATTRS_FLAG_RW,
1142                         {.value_double = 1.0},
1143                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1144                         {.double_min = 0.5},
1145                         {.double_max = 2},
1146                         __mmplayer_commit_audio_pitch_value,
1147                 },
1148                 {
1149                         MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1150                         (char *)"audio_offload",        /* MM_PLAYER_AUDIO_OFFLOAD */
1151                         MM_ATTRS_TYPE_INT,
1152                         MM_ATTRS_FLAG_RW,
1153                         {(void *)FALSE},
1154                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1155                         {.int_min = FALSE},
1156                         {.int_max = TRUE},
1157                         NULL,
1158                 },
1159                 {
1160                         MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1161                         (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1162                         MM_ATTRS_TYPE_INT,
1163                         MM_ATTRS_FLAG_RW,
1164                         {(void *)NULL},
1165                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1166                         {.int_array = NULL},
1167                         {.count = 0},
1168                         NULL,
1169                 },
1170                 {
1171                         MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1172                         (char *)"media_stream_input_format",
1173                         MM_ATTRS_TYPE_INT,
1174                         MM_ATTRS_FLAG_RW,
1175                         {(void *)NULL},
1176                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1177                         {.int_array = NULL},
1178                         {.count = 0},
1179                         NULL,
1180                 },
1181                 {
1182                         MMPLAYER_ATTRS_AUDIO_ONLY,
1183                         (char *)"audio_only",   /* MM_PLAYER_AUDIO_ONLY */
1184                         MM_ATTRS_TYPE_INT,
1185                         MM_ATTRS_FLAG_RW,
1186                         {(void *)FALSE},
1187                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1188                         {.int_min = FALSE},
1189                         {.int_max = TRUE},
1190                         NULL,
1191                 },
1192         };
1193
1194         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1195
1196         num_of_attrs = ARRAY_SIZE(player_attrs);
1197
1198         base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1199         if (!base) {
1200                 LOGE("failed to alloc attrs constructor");
1201                 return NULL;
1202         }
1203
1204         /* alloc default attribute info */
1205         player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1206         if (player->default_attrs == NULL) {
1207                 LOGE("failed to alloc default attribute info");
1208                 goto ERROR;
1209         }
1210
1211         memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1212         __mmplayer_set_ini_to_valid_info(handle);
1213
1214         /* initialize values of attributes */
1215         for (idx = 0; idx < num_of_attrs; idx++) {
1216                 base[idx].name = player->default_attrs[idx].name;
1217                 base[idx].value_type = player->default_attrs[idx].value_type;
1218                 base[idx].flags = player->default_attrs[idx].flags;
1219                 base[idx].default_value = player->default_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1220         }
1221
1222         result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1223                                                         _mmplayer_commit_attribute, (void *)handle, &attrs);
1224
1225         /* clean */
1226         MMPLAYER_FREEIF(base);
1227
1228         if (result != MM_ERROR_NONE) {
1229                 LOGE("failed to create player attrs");
1230                 goto ERROR;
1231         }
1232
1233         /* set validity type and range */
1234         for (idx = 0; idx < num_of_attrs; idx++) {
1235                 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1236                 switch (player->default_attrs[idx].valid_type) {
1237                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1238                         mm_attrs_set_valid_range(attrs, idx,
1239                                         player->default_attrs[idx].validity_value_1.int_min,
1240                                         player->default_attrs[idx].validity_value_2.int_max,
1241                                         player->default_attrs[idx].default_value.value_int);
1242                         break;
1243                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1244                         if (player->default_attrs[idx].validity_value_1.int_array &&
1245                                         player->default_attrs[idx].validity_value_2.count > 0)
1246                                 mm_attrs_set_valid_array(attrs, idx,
1247                                                 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1248                                                 player->default_attrs[idx].validity_value_2.count,
1249                                                 player->default_attrs[idx].default_value.value_int);
1250                         break;
1251                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1252                         mm_attrs_set_valid_double_range(attrs, idx,
1253                                         player->default_attrs[idx].validity_value_1.double_min,
1254                                         player->default_attrs[idx].validity_value_2.double_max,
1255                                         player->default_attrs[idx].default_value.value_double);
1256                         break;
1257                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1258                         LOGW("FIXME: need to set range value if required.");
1259                 case MM_ATTRS_VALID_TYPE_NONE:
1260                 case MM_ATTRS_VALID_TYPE_INVALID:
1261                 default:
1262                         break;
1263                 }
1264         }
1265
1266         /* commit */
1267         if (mm_attrs_commit_all(attrs)) {
1268                 LOGE("failed to update attributes");
1269                 goto ERROR;
1270         }
1271
1272         __mmplayer_release_ini_info(handle);
1273
1274         return attrs;
1275
1276 ERROR:
1277         MMPLAYER_FREEIF(base);
1278         MMPLAYER_FREEIF(player->default_attrs);
1279
1280         if (attrs)
1281                 mm_attrs_free(attrs);
1282
1283         return NULL;
1284 }
1285
1286 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1287 {
1288         mmplayer_t *player = MM_PLAYER_CAST(handle);
1289
1290         MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1291
1292         if (player->attrs) {
1293                 mm_attrs_free(player->attrs);
1294                 player->attrs = NULL;
1295         }
1296
1297         MMPLAYER_FREEIF(player->default_attrs);
1298
1299         return true;
1300 }