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