55adff7f069b42e80e254847aaa6ce3dc83d8dfa
[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->mainbin, 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_S16LE"))
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_get_default_audio_codec_type(MMHandleType handle)
243 {
244         mmplayer_t *player = MM_PLAYER_CAST(handle);
245
246         if (!strcmp(player->ini.audiocodec_default_type, "hw"))
247                 return MM_PLAYER_CODEC_TYPE_HW;
248         else
249                 return MM_PLAYER_CODEC_TYPE_SW;
250 }
251
252 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
253 {
254         mmplayer_t *player = MM_PLAYER_CAST(handle);
255         int *format = NULL;
256         int total_count = 0;
257
258         /* supported format of audio offload */
259         total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
260         if (format && total_count > 0) {
261                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
262                 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
263         }
264
265         /* supported format of media stream input */
266         total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
267         if (format && total_count > 0) {
268                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
269                 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
270         }
271
272         /* default audio codec type */
273         player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = __mmplayer_get_default_audio_codec_type(handle);
274
275         return MM_ERROR_NONE;
276 }
277
278 static int __mmplayer_release_ini_info(MMHandleType handle)
279 {
280         mmplayer_t *player = MM_PLAYER_CAST(handle);
281         int *mem = NULL;
282
283         MMPLAYER_FENTER();
284
285         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
286         g_free(mem);
287         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
288         player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
289
290         mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
291         g_free(mem);
292         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
293         player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
294
295         MMPLAYER_FLEAVE();
296         return MM_ERROR_NONE;
297 }
298
299 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
300 {
301         switch (value->type) {
302         case MM_ATTRS_TYPE_INT:
303                 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
304                 break;
305         case MM_ATTRS_TYPE_DOUBLE:
306                 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
307                 break;
308         case MM_ATTRS_TYPE_STRING:
309                 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
310                 break;
311         case MM_ATTRS_TYPE_DATA:
312                 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
313                 break;
314         default:
315                 break;
316         }
317
318         return;
319 }
320
321 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
322 {
323         bool ret = false;
324         mmplayer_t *player = MM_PLAYER_CAST(commit_param);
325
326         MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
327
328         if (player->default_attrs[attr_idx].attr_commit) {
329                 __mmplayer_print_attrs(attr_name, value, "Dynamic");
330                 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
331         } else {
332                 __mmplayer_print_attrs(attr_name, value, "Static");
333                 ret = true;
334         }
335
336         return ret;
337 }
338
339 int _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
340 {
341         int result = MM_ERROR_NONE;
342         MMHandleType attrs = NULL;
343
344         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
345         /* if it's not want to know it. */
346         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
347         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
348
349         attrs = MM_PLAYER_GET_ATTRS(handle);
350
351         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
352
353         if (result != MM_ERROR_NONE)
354                 LOGE("failed to get %s attribute", attribute_name);
355
356         return result;
357 }
358
359 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
360 {
361         mmplayer_t *player = NULL;
362
363         MMPLAYER_FENTER();
364         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
365         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
366
367         player = MM_PLAYER_CAST(handle);
368
369         /* apply display attr value to player handle */
370         if (!g_strrstr(attribute_name, "display"))
371                 return MM_ERROR_NONE;
372
373         if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
374                 LOGD("will be applied when videosink is ready");
375                 return MM_ERROR_NONE;
376         }
377
378         if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
379                 LOGW("not supported video param %s", attribute_name);
380                 return MM_ERROR_NONE;
381         }
382
383         return MM_ERROR_NONE;
384 }
385
386 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
387 {
388         int result = MM_ERROR_NONE;
389         MMHandleType attrs = NULL;
390
391         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
392         /* if it's not want to know it. */
393         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
394         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
395
396         attrs = MM_PLAYER_GET_ATTRS(handle);
397
398         /* set attributes and commit them */
399         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
400         if (result != MM_ERROR_NONE) {
401                 LOGE("failed to set %s attribute", attribute_name);
402                 return result;
403         }
404
405         /* Note: 'attr_commit' function is called before committing the new value to attr struct.
406                  so if there is a value to apply after committing, it should be added below function. */
407         result = __mmplayer_apply_attribute(handle, attribute_name);
408         if (result != MM_ERROR_NONE) {
409                 LOGE("failed to apply attributes");
410                 return result;
411         }
412
413         return MM_ERROR_NONE;
414 }
415
416 int _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, mmplayer_attrs_info_t *dst_info)
417 {
418         int result = MM_ERROR_NONE;
419         MMHandleType attrs = NULL;
420         MMAttrsInfo src_info = {0, };
421
422         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
423         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
424         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
425
426         attrs = MM_PLAYER_GET_ATTRS(handle);
427
428         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
429
430         if (result != MM_ERROR_NONE) {
431                 LOGE("failed to get attribute info");
432                 return result;
433         }
434
435         memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
436
437         dst_info->type = src_info.type;
438         dst_info->flag = src_info.flag;
439         dst_info->validity_type = src_info.validity_type;
440
441         switch (src_info.validity_type) {
442         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
443                 dst_info->int_array.array = src_info.int_array.array;
444                 dst_info->int_array.count = src_info.int_array.count;
445                 dst_info->int_array.d_val = src_info.int_array.dval;
446                 break;
447
448         case MM_ATTRS_VALID_TYPE_INT_RANGE:
449                 dst_info->int_range.min = src_info.int_range.min;
450                 dst_info->int_range.max = src_info.int_range.max;
451                 dst_info->int_range.d_val = src_info.int_range.dval;
452                 break;
453
454         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
455                 dst_info->double_array.array = src_info.double_array.array;
456                 dst_info->double_array.count = src_info.double_array.count;
457                 dst_info->double_array.d_val = src_info.double_array.dval;
458                 break;
459
460         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
461                 dst_info->double_range.min = src_info.double_range.min;
462                 dst_info->double_range.max = src_info.double_range.max;
463                 dst_info->double_range.d_val = src_info.double_range.dval;
464                 break;
465
466         default:
467                 break;
468         }
469
470         return result;
471 }
472
473 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
474 {
475         mmplayer_t *player = MM_PLAYER_CAST(handle);
476         int result = MM_ERROR_NONE;
477         int idx = 0;
478         MMHandleType attrs = NULL;
479         int num_of_attrs = 0;
480         MMAttrsConstructInfo *base = NULL;
481
482         mmplayer_attrs_spec_t player_attrs[] = {
483                 {
484                         MMPLAYER_ATTRS_PROFILE_URI,                /* ID */
485                         (char *)"profile_uri",                             /* Name */
486                         MM_ATTRS_TYPE_STRING,                              /* Value Type */
487                         MM_ATTRS_FLAG_RW,                                          /* Flag */
488                         {(void *)NULL},                                            /* default value */
489                         MM_ATTRS_VALID_TYPE_NONE,                          /* validity type */
490                         {0},                                                               /* validity min value */
491                         {0},                                                               /* validity max value */
492                         NULL,                                                              /* Runtime setting function of the attribute */
493                 },
494                 {
495                         MMPLAYER_ATTRS_PROFILE_USER_PARAM,
496                         (char *)"profile_user_param",
497                         MM_ATTRS_TYPE_DATA,
498                         MM_ATTRS_FLAG_RW,
499                         {(void *)NULL},
500                         MM_ATTRS_VALID_TYPE_NONE,
501                         {0},
502                         {0},
503                         NULL,
504                 },
505                 {
506                         MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
507                         (char *)"profile_play_count",
508                         MM_ATTRS_TYPE_INT,
509                         MM_ATTRS_FLAG_RW,
510                         {(void *)1},                                            /* -1 : repeat continually */
511                         MM_ATTRS_VALID_TYPE_INT_RANGE,
512                         {.int_min = -1},
513                         {.int_max = 1},
514                         NULL,
515                 },
516                 {
517                         MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
518                         (char *)"profile_prepare_async",
519                         MM_ATTRS_TYPE_INT,
520                         MM_ATTRS_FLAG_RW,
521                         {(void *)0},
522                         MM_ATTRS_VALID_TYPE_INT_RANGE,
523                         {.int_min = 0},
524                         {.int_max = 1},
525                         NULL,
526                 },
527                 {
528                         MMPLAYER_ATTRS_STREAMING_USER_AGENT,
529                         (char *)"streaming_user_agent",
530                         MM_ATTRS_TYPE_STRING,
531                         MM_ATTRS_FLAG_RW,
532                         {(void *)NULL},
533                         MM_ATTRS_VALID_TYPE_NONE,
534                         {0},
535                         {0},
536                         NULL,
537                 },
538                 {
539                         MMPLAYER_ATTRS_STREAMING_COOKIE,
540                         (char *)"streaming_cookie",
541                         MM_ATTRS_TYPE_STRING,
542                         MM_ATTRS_FLAG_RW,
543                         {(void *)NULL},
544                         MM_ATTRS_VALID_TYPE_NONE,
545                         {0},
546                         {0},
547                         NULL,
548                 },
549                 {
550                         MMPLAYER_ATTRS_SUBTITLE_URI,
551                         (char *)"subtitle_uri",
552                         MM_ATTRS_TYPE_STRING,
553                         MM_ATTRS_FLAG_RW,
554                         {(void *)NULL},
555                         MM_ATTRS_VALID_TYPE_NONE,
556                         {0},
557                         {0},
558                         NULL,
559                 },
560                 {
561                         MMPLAYER_ATTRS_CONTENT_BITRATE,
562                         (char *)"content_bitrate",
563                         MM_ATTRS_TYPE_INT,
564                         MM_ATTRS_FLAG_RW,
565                         {(void *)0},
566                         MM_ATTRS_VALID_TYPE_INT_RANGE,
567                         {.int_min = 0},
568                         {.int_max = MMPLAYER_MAX_INT},
569                         NULL,
570                 },
571                 {
572                         MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
573                         (char *)"content_max_bitrate",
574                         MM_ATTRS_TYPE_INT,
575                         MM_ATTRS_FLAG_RW,
576                         {(void *)0},
577                         MM_ATTRS_VALID_TYPE_INT_RANGE,
578                         {.int_min = 0},
579                         {.int_max = MMPLAYER_MAX_INT},
580                         NULL,
581                 },
582                 {
583                         MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
584                         (char *)"content_video_found",
585                         MM_ATTRS_TYPE_INT,
586                         MM_ATTRS_FLAG_RW,
587                         {(void *)0},
588                         MM_ATTRS_VALID_TYPE_INT_RANGE,
589                         {.int_min = 0},
590                         {.int_max = 1},
591                         NULL,
592                 },
593                 {
594                         MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
595                         (char *)"content_video_codec",
596                         MM_ATTRS_TYPE_STRING,
597                         MM_ATTRS_FLAG_RW,
598                         {(void *)NULL},
599                         MM_ATTRS_VALID_TYPE_NONE,
600                         {0},
601                         {0},
602                         NULL,
603                 },
604                 {
605                         MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
606                         (char *)"content_video_bitrate",
607                         MM_ATTRS_TYPE_INT,
608                         MM_ATTRS_FLAG_RW,
609                         {(void *)0},
610                         MM_ATTRS_VALID_TYPE_INT_RANGE,
611                         {.int_min = 0},
612                         {.int_max = MMPLAYER_MAX_INT},
613                         NULL,
614                 },
615                 {
616                         MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
617                         (char *)"content_video_fps",
618                         MM_ATTRS_TYPE_INT,
619                         MM_ATTRS_FLAG_RW,
620                         {(void *)0},
621                         MM_ATTRS_VALID_TYPE_INT_RANGE,
622                         {.int_min = 0},
623                         {.int_max = MMPLAYER_MAX_INT},
624                         NULL,
625                 },
626                 {
627                         MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
628                         (char *)"content_video_width",
629                         MM_ATTRS_TYPE_INT,
630                         MM_ATTRS_FLAG_RW,
631                         {(void *)0},
632                         MM_ATTRS_VALID_TYPE_INT_RANGE,
633                         {.int_min = 0},
634                         {.int_max = MMPLAYER_MAX_INT},
635                         NULL,
636                 },
637                 {
638                         MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
639                         (char *)"content_video_height",
640                         MM_ATTRS_TYPE_INT,
641                         MM_ATTRS_FLAG_RW,
642                         {(void *)0},
643                         MM_ATTRS_VALID_TYPE_INT_RANGE,
644                         {.int_min = 0},
645                         {.int_max = MMPLAYER_MAX_INT},
646                         NULL,
647                 },
648                 {
649                         MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
650                         (char *)"content_video_orientation",   /* orientation of video content */
651                         MM_ATTRS_TYPE_STRING,
652                         MM_ATTRS_FLAG_RW,
653                         {(void *)NULL},
654                         MM_ATTRS_VALID_TYPE_NONE,
655                         {0},
656                         {0},
657                         NULL,
658                 },
659                 {
660                         MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
661                         (char *)"content_video_is_spherical",
662                         MM_ATTRS_TYPE_INT,
663                         MM_ATTRS_FLAG_RW,
664                         {(void *)-1},
665                         MM_ATTRS_VALID_TYPE_INT_RANGE,
666                         {.int_min = -1},
667                         {.int_max = MMPLAYER_MAX_INT},
668                         NULL,
669                 },
670                 {
671                         MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
672                         (char *)"content_audio_codec",
673                         MM_ATTRS_TYPE_STRING,
674                         MM_ATTRS_FLAG_RW,
675                         {(void *)NULL},
676                         MM_ATTRS_VALID_TYPE_NONE,
677                         {0},
678                         {0},
679                         NULL,
680                 },
681                 {
682                         MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
683                         (char *)"content_audio_bitrate",
684                         MM_ATTRS_TYPE_INT,
685                         MM_ATTRS_FLAG_RW,
686                         {(void *)0},
687                         MM_ATTRS_VALID_TYPE_INT_RANGE,
688                         {.int_min = 0},
689                         {.int_max = MMPLAYER_MAX_INT},
690                         NULL,
691                 },
692                 {
693                         MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
694                         (char *)"content_audio_channels",
695                         MM_ATTRS_TYPE_INT,
696                         MM_ATTRS_FLAG_RW,
697                         {(void *)0},
698                         MM_ATTRS_VALID_TYPE_INT_RANGE,
699                         {.int_min = 0},
700                         {.int_max = MMPLAYER_MAX_INT},
701                         NULL,
702                 },
703                 {
704                         MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
705                         (char *)"content_audio_samplerate",
706                         MM_ATTRS_TYPE_INT,
707                         MM_ATTRS_FLAG_RW,
708                         {(void *)0},
709                         MM_ATTRS_VALID_TYPE_INT_RANGE,
710                         {.int_min = 0},
711                         {.int_max = MMPLAYER_MAX_INT},
712                         NULL,
713                 },
714                 {
715                         MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
716                         (char *)"content_audio_format",
717                         MM_ATTRS_TYPE_STRING,
718                         MM_ATTRS_FLAG_RW,
719                         {(void *)NULL},
720                         MM_ATTRS_VALID_TYPE_NONE,
721                         {0},
722                         {0},
723                         NULL,
724                 },
725                 {
726                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
727                         (char *)"content_text_track_num",
728                         MM_ATTRS_TYPE_INT,
729                         MM_ATTRS_FLAG_RW,
730                         {(void *)0},
731                         MM_ATTRS_VALID_TYPE_INT_RANGE,
732                         {.int_min = 0},
733                         {.int_max = MMPLAYER_MAX_INT},
734                         NULL,
735                 },
736                 {
737                         MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
738                         (char *)"current_text_track_index",
739                         MM_ATTRS_TYPE_INT,
740                         MM_ATTRS_FLAG_RW,
741                         {(void *)-1},
742                         MM_ATTRS_VALID_TYPE_INT_RANGE,
743                         {.int_min = -1},
744                         {.int_max = MMPLAYER_MAX_INT},
745                         NULL,
746                 },
747                 {
748                         MMPLAYER_ATTRS_TAG_ARTIST,
749                         (char *)"tag_artist",
750                         MM_ATTRS_TYPE_STRING,
751                         MM_ATTRS_FLAG_RW,
752                         {(void *)NULL},
753                         MM_ATTRS_VALID_TYPE_NONE,
754                         {0},
755                         {0},
756                         NULL,
757                 },
758                 {
759                         MMPLAYER_ATTRS_TAG_TITLE,
760                         (char *)"tag_title",
761                         MM_ATTRS_TYPE_STRING,
762                         MM_ATTRS_FLAG_RW,
763                         {(void *)NULL},
764                         MM_ATTRS_VALID_TYPE_NONE,
765                         {0},
766                         {0},
767                         NULL,
768                 },
769                 {
770                         MMPLAYER_ATTRS_TAG_ALBUM,
771                         (char *)"tag_album",
772                         MM_ATTRS_TYPE_STRING,
773                         MM_ATTRS_FLAG_RW,
774                         {(void *)NULL},
775                         MM_ATTRS_VALID_TYPE_NONE,
776                         {0},
777                         {0},
778                         NULL,
779                 },
780                 {
781                         MMPLAYER_ATTRS_TAG_GENRE,
782                         (char *)"tag_genre",
783                         MM_ATTRS_TYPE_STRING,
784                         MM_ATTRS_FLAG_RW,
785                         {(void *)NULL},
786                         MM_ATTRS_VALID_TYPE_NONE,
787                         {0},
788                         {0},
789                         NULL,
790                 },
791                 {
792                         MMPLAYER_ATTRS_TAG_AUTHOR,
793                         (char *)"tag_author",
794                         MM_ATTRS_TYPE_STRING,
795                         MM_ATTRS_FLAG_RW,
796                         {(void *)NULL},
797                         MM_ATTRS_VALID_TYPE_NONE,
798                         {0},
799                         {0},
800                         NULL,
801                 },
802                 {
803                         MMPLAYER_ATTRS_TAG_COPYRIGHT,
804                         (char *)"tag_copyright",
805                         MM_ATTRS_TYPE_STRING,
806                         MM_ATTRS_FLAG_RW,
807                         {(void *)NULL},
808                         MM_ATTRS_VALID_TYPE_NONE,
809                         {0},
810                         {0},
811                         NULL,
812                 },
813                 {
814                         MMPLAYER_ATTRS_TAG_DATE,
815                         (char *)"tag_date",
816                         MM_ATTRS_TYPE_STRING,
817                         MM_ATTRS_FLAG_RW,
818                         {(void *)NULL},
819                         MM_ATTRS_VALID_TYPE_NONE,
820                         {0},
821                         {0},
822                         NULL,
823                 },
824                 {
825                         MMPLAYER_ATTRS_TAG_DESCRIPTION,
826                         (char *)"tag_description",
827                         MM_ATTRS_TYPE_STRING,
828                         MM_ATTRS_FLAG_RW,
829                         {(void *)NULL},
830                         MM_ATTRS_VALID_TYPE_NONE,
831                         {0},
832                         {0},
833                         NULL,
834                 },
835                 {
836                         MMPLAYER_ATTRS_TAG_TRACK_NUM,
837                         (char *)"tag_track_num",
838                         MM_ATTRS_TYPE_INT,
839                         MM_ATTRS_FLAG_RW,
840                         {(void *)0},
841                         MM_ATTRS_VALID_TYPE_INT_RANGE,
842                         {.int_min = 0},
843                         {.int_max = MMPLAYER_MAX_INT},
844                         NULL,
845                 },
846                 {
847                         MMPLAYER_ATTRS_TAG_ALBUM_COVER,
848                         (char *)"tag_album_cover",
849                         MM_ATTRS_TYPE_DATA,
850                         MM_ATTRS_FLAG_RW,
851                         {(void *)NULL},
852                         MM_ATTRS_VALID_TYPE_NONE,
853                         {0},
854                         {0},
855                         NULL,
856                 },
857                 {
858                         MMPLAYER_ATTRS_DISPLAY_ROTATION,
859                         (char *)"display_rotation",
860                         MM_ATTRS_TYPE_INT,
861                         MM_ATTRS_FLAG_RW,
862                         {(void *)MM_DISPLAY_ROTATION_NONE},
863                         MM_ATTRS_VALID_TYPE_INT_RANGE,
864                         {.int_min = MM_DISPLAY_ROTATION_NONE},
865                         {.int_max = MM_DISPLAY_ROTATION_270},
866                         NULL,
867                 },
868                 {
869                         MMPLAYER_ATTRS_DISPLAY_VISIBLE,
870                         (char *)"display_visible",
871                         MM_ATTRS_TYPE_INT,
872                         MM_ATTRS_FLAG_RW,
873                         {(void *)FALSE},
874                         MM_ATTRS_VALID_TYPE_INT_RANGE,
875                         {.int_min = FALSE},
876                         {.int_max = TRUE},
877                         NULL,
878                 },
879                 {
880                         MMPLAYER_ATTRS_DISPLAY_METHOD,
881                         (char *)"display_method",
882                         MM_ATTRS_TYPE_INT,
883                         MM_ATTRS_FLAG_RW,
884                         {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
885                         MM_ATTRS_VALID_TYPE_INT_RANGE,
886                         {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
887                         {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
888                         NULL,
889                 },
890                 {
891                         MMPLAYER_ATTRS_DISPLAY_OVERLAY,
892                         (char *)"display_overlay",
893                         MM_ATTRS_TYPE_INT,
894                         MM_ATTRS_FLAG_RW,
895                         {(void *)0},
896                         MM_ATTRS_VALID_TYPE_INT_RANGE,
897                         {.int_min = 0},
898                         {.int_max = MMPLAYER_MAX_INT},
899                         NULL,
900                 },
901                 {
902                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
903                         (char *)"display_win_roi_x",
904                         MM_ATTRS_TYPE_INT,
905                         MM_ATTRS_FLAG_RW,
906                         {(void *)0},
907                         MM_ATTRS_VALID_TYPE_INT_RANGE,
908                         {.int_min = MMPLAYER_MIN_INT},
909                         {.int_max = MMPLAYER_MAX_INT},
910                         NULL,
911                 },
912                 {
913                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
914                         (char *)"display_win_roi_y",
915                         MM_ATTRS_TYPE_INT,
916                         MM_ATTRS_FLAG_RW,
917                         {(void *)0},
918                         MM_ATTRS_VALID_TYPE_INT_RANGE,
919                         {.int_min = MMPLAYER_MIN_INT},
920                         {.int_max = MMPLAYER_MAX_INT},
921                         NULL,
922                 },
923                 {
924                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
925                         (char *)"display_win_roi_width",
926                         MM_ATTRS_TYPE_INT,
927                         MM_ATTRS_FLAG_RW,
928                         {(void *)0},
929                         MM_ATTRS_VALID_TYPE_INT_RANGE,
930                         {.int_min = 0},
931                         {.int_max = MMPLAYER_MAX_INT},
932                         NULL,
933                 },
934                 {
935                         MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
936                         (char *)"display_win_roi_height",
937                         MM_ATTRS_TYPE_INT,
938                         MM_ATTRS_FLAG_RW,
939                         {(void *)0},
940                         MM_ATTRS_VALID_TYPE_INT_RANGE,
941                         {.int_min = 0},
942                         {.int_max = MMPLAYER_MAX_INT},
943                         NULL,
944                 },
945                 {
946                         MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
947                         (char *)"display_surface_type",
948                         MM_ATTRS_TYPE_INT,
949                         MM_ATTRS_FLAG_RW,
950                         {(void *)MM_DISPLAY_SURFACE_NULL},
951                         MM_ATTRS_VALID_TYPE_INT_RANGE,
952                         {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
953                         {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
954                         NULL,
955                 },
956                 {
957                         MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
958                         (char *)"sound_stream_type",
959                         MM_ATTRS_TYPE_STRING,
960                         MM_ATTRS_FLAG_RW,
961                         {(void *)NULL},
962                         MM_ATTRS_VALID_TYPE_NONE,
963                         {0},
964                         {0},
965                         NULL,
966                 },
967                 {
968                         MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
969                         (char *)"sound_stream_index",
970                         MM_ATTRS_TYPE_INT,
971                         MM_ATTRS_FLAG_RW,
972                         {(void *)0},
973                         MM_ATTRS_VALID_TYPE_INT_RANGE,
974                         {.int_min = -1},
975                         {.int_max = MMPLAYER_MAX_INT},
976                         NULL,
977                 },
978                 {
979                         MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
980                         (char *)"sound_latency_mode",
981                         MM_ATTRS_TYPE_INT,
982                         MM_ATTRS_FLAG_RW,
983                         {(void *)1},                                             /* 0: low latency, 1: middle latency 2: high latency */
984                         MM_ATTRS_VALID_TYPE_INT_RANGE,
985                         {.int_min = 0},
986                         {.int_max = 2},
987                         NULL,
988                 },
989                 {
990                         MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
991                         (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
992                         MM_ATTRS_TYPE_INT,
993                         MM_ATTRS_FLAG_RW,
994                         {(void *)44100},
995                         MM_ATTRS_VALID_TYPE_INT_RANGE,
996                         {.int_min = 0},
997                         {.int_max = MMPLAYER_MAX_INT},
998                         NULL,
999                 },
1000                 {
1001                         MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
1002                         (char *)"pcm_extraction_channels",       /* set channels for pcm extraction */
1003                         MM_ATTRS_TYPE_INT,
1004                         MM_ATTRS_FLAG_RW,
1005                         {(void *)1},
1006                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1007                         {.int_min = 0},
1008                         {.int_max = MMPLAYER_MAX_INT},
1009                         NULL,
1010                 },
1011                 {
1012                         MMPLAYER_ATTRS_ACCURATE_SEEK,
1013                         (char *)"accurate_seek",
1014                         MM_ATTRS_TYPE_INT,
1015                         MM_ATTRS_FLAG_RW,
1016                         {(void *)0},
1017                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1018                         {.int_min = 0},
1019                         {.int_max = 1},
1020                         NULL,
1021                 },
1022                 {
1023                         MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1024                         (char *)"pcm_extraction_format",
1025                         MM_ATTRS_TYPE_STRING,
1026                         MM_ATTRS_FLAG_RW,
1027                         {(void *)NULL},
1028                         MM_ATTRS_VALID_TYPE_NONE,
1029                         {0},
1030                         {0},
1031                         NULL,
1032                 },
1033                 {
1034                         MMPLAYER_ATTRS_DRC_MODE,
1035                         (char *)"drc_mode",
1036                         MM_ATTRS_TYPE_INT,
1037                         MM_ATTRS_FLAG_RW,
1038                         {(void *)FALSE},
1039                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1040                         {.int_min = FALSE},
1041                         {.int_max = TRUE},
1042                         NULL,
1043                 },
1044                 {
1045                         MMPLAYER_ATTRS_GAPLESS_MODE,
1046                         (char *)"gapless_mode",
1047                         MM_ATTRS_TYPE_INT,
1048                         MM_ATTRS_FLAG_RW,
1049                         {(void *)FALSE},
1050                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1051                         {.int_min = FALSE},
1052                         {.int_max = TRUE},
1053                         __mmplayer_commit_gapless_mode,
1054                 },
1055                 {
1056                         MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1057                         (char *)"enable_video_decoded_cb",
1058                         MM_ATTRS_TYPE_INT,
1059                         MM_ATTRS_FLAG_RW,
1060                         {(void *)FALSE},
1061                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1062                         {.int_min = FALSE},
1063                         {.int_max = TRUE},
1064                         __mmplayer_commit_enable_video_decoded_cb,
1065                 },
1066                 {
1067                         MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1068                         (char *)"video_codec_type",
1069                         MM_ATTRS_TYPE_INT,
1070                         MM_ATTRS_FLAG_RW,
1071                         {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1072                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1073                         {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1074                         {.int_max = MM_PLAYER_CODEC_TYPE_DEFAULT},
1075                         NULL,
1076                 },
1077                 {
1078                         MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1079                         (char *)"audio_codec_type",
1080                         MM_ATTRS_TYPE_INT,
1081                         MM_ATTRS_FLAG_RW,
1082                         {(void *)MM_PLAYER_CODEC_TYPE_SW},
1083                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1084                         {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1085                         {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1086                         NULL,
1087                 },
1088                 {
1089                         MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1090                         (char *)"video_buffer_total_size",
1091                         MM_ATTRS_TYPE_INT,
1092                         MM_ATTRS_FLAG_RW,
1093                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1094                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1095                         {.int_min = MMPLAYER_MIN_INT},
1096                         {.int_max = MMPLAYER_MAX_INT},
1097                         NULL,
1098                 },
1099                 {
1100                         MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1101                         (char *)"video_buffer_extra_size",
1102                         MM_ATTRS_TYPE_INT,
1103                         MM_ATTRS_FLAG_RW,
1104                         {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1105                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1106                         {.int_min = MMPLAYER_MIN_INT},
1107                         {.int_max = MMPLAYER_MAX_INT},
1108                         NULL,
1109                 },
1110                 {
1111                         MMPLAYER_ATTRS_PREBUFFER_MS,
1112                         (char *)"prebuffer_ms", /* user setting */
1113                         MM_ATTRS_TYPE_INT,
1114                         MM_ATTRS_FLAG_RW,
1115                         {(void *) MIN_BUFFERING_TIME},
1116                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1117                         {.int_min = MIN_BUFFERING_TIME},
1118                         {.int_max = MMPLAYER_MAX_INT},
1119                         NULL,
1120                 },
1121                 {
1122                         MMPLAYER_ATTRS_REBUFFER_MS,
1123                         (char *)"rebuffer_ms", /* user setting */
1124                         MM_ATTRS_TYPE_INT,
1125                         MM_ATTRS_FLAG_RW,
1126                         {(void *) MIN_BUFFERING_TIME},
1127                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1128                         {.int_min = MIN_BUFFERING_TIME},
1129                         {.int_max = MMPLAYER_MAX_INT},
1130                         NULL,
1131                 },
1132                 {
1133                         MMPLAYER_ATTRS_PITCH_CONTROL,
1134                         (char *)"pitch_control",        /* MM_PLAYER_PITCH_CONTROL */
1135                         MM_ATTRS_TYPE_INT,
1136                         MM_ATTRS_FLAG_RW,
1137                         {(void *)FALSE},
1138                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1139                         {.int_min = FALSE},
1140                         {.int_max = TRUE},
1141                         NULL,
1142                 },
1143                 {
1144                         MMPLAYER_ATTRS_PITCH_VALUE,
1145                         (char *)"pitch_value",          /* MM_PLAYER_PITCH_VALUE */
1146                         MM_ATTRS_TYPE_DOUBLE,
1147                         MM_ATTRS_FLAG_RW,
1148                         {.value_double = 1.0},
1149                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1150                         {.double_min = 0.5},
1151                         {.double_max = 2},
1152                         __mmplayer_commit_audio_pitch_value,
1153                 },
1154                 {
1155                         MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1156                         (char *)"audio_offload",        /* MM_PLAYER_AUDIO_OFFLOAD */
1157                         MM_ATTRS_TYPE_INT,
1158                         MM_ATTRS_FLAG_RW,
1159                         {(void *)FALSE},
1160                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1161                         {.int_min = FALSE},
1162                         {.int_max = TRUE},
1163                         NULL,
1164                 },
1165                 {
1166                         MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1167                         (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1168                         MM_ATTRS_TYPE_INT,
1169                         MM_ATTRS_FLAG_RW,
1170                         {(void *)NULL},
1171                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1172                         {.int_array = NULL},
1173                         {.count = 0},
1174                         NULL,
1175                 },
1176                 {
1177                         MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1178                         (char *)"media_stream_input_format",
1179                         MM_ATTRS_TYPE_INT,
1180                         MM_ATTRS_FLAG_RW,
1181                         {(void *)NULL},
1182                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1183                         {.int_array = NULL},
1184                         {.count = 0},
1185                         NULL,
1186                 },
1187         };
1188
1189         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1190
1191         num_of_attrs = ARRAY_SIZE(player_attrs);
1192
1193         base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1194         if (!base) {
1195                 LOGE("failed to alloc attrs constructor");
1196                 return NULL;
1197         }
1198
1199         /* initialize values of attributes */
1200         for (idx = 0; idx < num_of_attrs; idx++) {
1201                 base[idx].name = player_attrs[idx].name;
1202                 base[idx].value_type = player_attrs[idx].value_type;
1203                 base[idx].flags = player_attrs[idx].flags;
1204                 base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1205         }
1206
1207         result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1208                                                         _mmplayer_commit_attribute, (void *)handle, &attrs);
1209
1210         /* clean */
1211         MMPLAYER_FREEIF(base);
1212
1213         if (result) {
1214                 LOGE("failed to create player attrs");
1215                 return NULL;
1216         }
1217
1218         /* alloc default attribute info */
1219         player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1220         if (player->default_attrs == NULL) {
1221                 LOGE("failed to alloc default attribute info");
1222                 goto ERROR;
1223         }
1224
1225         memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1226
1227         __mmplayer_set_ini_to_valid_info(handle);
1228
1229         /* set validity type and range */
1230         for (idx = 0; idx < num_of_attrs; idx++) {
1231                 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1232                 switch (player->default_attrs[idx].valid_type) {
1233                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1234                         mm_attrs_set_valid_range(attrs, idx,
1235                                         player->default_attrs[idx].validity_value_1.int_min,
1236                                         player->default_attrs[idx].validity_value_2.int_max,
1237                                         player->default_attrs[idx].default_value.value_int);
1238                         break;
1239                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1240                         if (player->default_attrs[idx].validity_value_1.int_array &&
1241                                         player->default_attrs[idx].validity_value_2.count > 0)
1242                                 mm_attrs_set_valid_array(attrs, idx,
1243                                                 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1244                                                 player->default_attrs[idx].validity_value_2.count,
1245                                                 player->default_attrs[idx].default_value.value_int);
1246                         break;
1247                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1248                         mm_attrs_set_valid_double_range(attrs, idx,
1249                                         player->default_attrs[idx].validity_value_1.double_min,
1250                                         player->default_attrs[idx].validity_value_2.double_max,
1251                                         player->default_attrs[idx].default_value.value_double);
1252                         break;
1253                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1254                         LOGW("FIXME: need to set range value if required.");
1255                 case MM_ATTRS_VALID_TYPE_NONE:
1256                 case MM_ATTRS_VALID_TYPE_INVALID:
1257                 default:
1258                         break;
1259                 }
1260         }
1261
1262         /* commit */
1263         if (mm_attrs_commit_all(attrs)) {
1264                 LOGE("failed to update attributes");
1265                 goto ERROR;
1266         }
1267
1268         __mmplayer_release_ini_info(handle);
1269
1270         return attrs;
1271
1272 ERROR:
1273         MMPLAYER_FREEIF(player->default_attrs);
1274
1275         if (attrs)
1276                 mm_attrs_free(attrs);
1277
1278         return NULL;
1279 }
1280
1281 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1282 {
1283         mmplayer_t *player = MM_PLAYER_CAST(handle);
1284
1285         MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1286
1287         if (player->attrs) {
1288                 mm_attrs_free(player->attrs);
1289                 player->attrs = NULL;
1290         }
1291
1292         MMPLAYER_FREEIF(player->default_attrs);
1293
1294         return true;
1295 }