[0.6.152] use player variable to get audio track info
[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 int
44 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
45
46 /*===========================================================================================
47 |                                                                                                                                                                                                               |
48 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
49 |                                                                                                                                                                                                               |
50 ========================================================================================== */
51
52 int
53 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
54 {
55         int result = MM_ERROR_NONE;
56         MMHandleType attrs = 0;
57
58         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
59         /* if it's not want to know it. */
60         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
61         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
62
63         attrs = MM_PLAYER_GET_ATTRS(handle);
64
65         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
66
67         if (result != MM_ERROR_NONE)
68                 LOGE("failed to get %s attribute\n", attribute_name);
69
70         return result;
71 }
72
73 int
74 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
75 {
76         int result = MM_ERROR_NONE;
77         MMHandleType attrs = 0;
78
79         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
80         /* if it's not want to know it. */
81         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
82         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
83
84         attrs = MM_PLAYER_GET_ATTRS(handle);
85
86         /* set attributes and commit them */
87         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
88
89         if (result != MM_ERROR_NONE) {
90                 LOGE("failed to set %s attribute\n", attribute_name);
91                 return result;
92         }
93
94         result = __mmplayer_apply_attribute(handle, attribute_name);
95         if (result != MM_ERROR_NONE) {
96                 LOGE("failed to apply attributes\n");
97                 return result;
98         }
99
100         return result;
101 }
102
103 int
104 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
105 {
106         int result = MM_ERROR_NONE;
107         MMHandleType attrs = 0;
108         MMAttrsInfo src_info = {0, };
109
110         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
111         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
112         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
113
114         attrs = MM_PLAYER_GET_ATTRS(handle);
115
116         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
117
118         if (result != MM_ERROR_NONE) {
119                 LOGE("failed to get attribute info\n");
120                 return result;
121         }
122
123         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
124
125         dst_info->type = src_info.type;
126         dst_info->flag = src_info.flag;
127         dst_info->validity_type = src_info.validity_type;
128
129         switch (src_info.validity_type) {
130         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
131                 dst_info->int_array.array = src_info.int_array.array;
132                 dst_info->int_array.count = src_info.int_array.count;
133                 dst_info->int_array.d_val = src_info.int_array.dval;
134                 break;
135
136         case MM_ATTRS_VALID_TYPE_INT_RANGE:
137                 dst_info->int_range.min = src_info.int_range.min;
138                 dst_info->int_range.max = src_info.int_range.max;
139                 dst_info->int_range.d_val = src_info.int_range.dval;
140                 break;
141
142         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
143                 dst_info->double_array.array = src_info.double_array.array;
144                 dst_info->double_array.count = src_info.double_array.count;
145                 dst_info->double_array.d_val = src_info.double_array.dval;
146                 break;
147
148         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
149                 dst_info->double_range.min = src_info.double_range.min;
150                 dst_info->double_range.max = src_info.double_range.max;
151                 dst_info->double_range.d_val = src_info.double_range.dval;
152                 break;
153
154         default:
155                 break;
156         }
157
158         return result;
159 }
160
161 int
162 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
163 {
164         mm_player_t* player = 0;
165
166         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
167         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
168
169         player = MM_PLAYER_CAST(handle);
170         MMPlayerGstPipelineInfo *pipeline = player->pipeline;
171
172         /* Currently, there are only display related implementation at below */
173         if (!pipeline ||
174                 !pipeline->videobin ||
175                 !pipeline->videobin[MMPLAYER_V_SINK].gst) {
176                 /*
177                  * The attribute should be committed even though videobin is not created yet.
178                  * So, true should be returned here.
179                  * Otherwise, video can be diaplayed abnormal.
180                  */
181                 return MM_ERROR_NONE;
182         }
183
184         if (g_strrstr(attribute_name, "display")) {
185                 char *param_name = NULL;
186                 int str_len = strlen(attribute_name);
187                 param_name = g_malloc0(str_len + 1);
188                 if (!param_name) {
189                         LOGE("failed to alloc param_name");
190                         return MM_ERROR_PLAYER_INTERNAL;
191                 }
192                 strncpy(param_name, attribute_name, str_len);
193                 param_name[str_len] = '\0';
194                 LOGD(" param_name: %s", param_name);
195                 if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
196                         g_free(param_name);
197                         LOGE("failed to update video param");
198                         return MM_ERROR_PLAYER_INTERNAL;
199                 }
200                 g_free(param_name);
201         }
202
203         if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
204                 int gapless = 0;
205
206                 mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
207
208                 if (gapless > 0) {
209                         LOGD("disable last-sample at videosink");
210                         g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
211                 }
212         }
213
214         if (g_strrstr(attribute_name, MM_PLAYER_ENABLE_VIDEO_DECODED_CB)) {
215                 if (!player->set_mode.media_packet_video_stream) {
216                         LOGE("there is no callback for media_packet");
217                         return MM_ERROR_PLAYER_INTERNAL;
218                 }
219                 int enable = 0;
220                 mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
221                 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "signal-handoffs", enable ? TRUE : FALSE, NULL);
222         }
223
224         return MM_ERROR_NONE;
225 }
226
227 MMHandleType
228 _mmplayer_construct_attribute(MMHandleType handle)
229 {
230         int result = MM_ERROR_NONE;
231         int idx = 0;
232         MMHandleType attrs = 0;
233         int num_of_attrs = 0;
234         MMAttrsConstructInfo *base = NULL;
235
236         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
237
238         MMPlayerAttrsSpec player_attrs[] = {
239                 {
240                         "profile_uri",                                  // name
241                         MM_ATTRS_TYPE_STRING,           // type
242                         MM_ATTRS_FLAG_RW,                       // flag
243                         (void *) NULL,                          // default value
244                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
245                         0,                                                      // validity min value
246                         0                                                       // validity max value
247                 },
248                 {
249                         "profile_user_param",
250                         MM_ATTRS_TYPE_DATA,
251                         MM_ATTRS_FLAG_RW,
252                         (void *) NULL,
253                         MM_ATTRS_VALID_TYPE_NONE,
254                         0,
255                         0
256                 },
257                 {
258                         "profile_play_count",
259                         MM_ATTRS_TYPE_INT,
260                         MM_ATTRS_FLAG_RW,
261                         (void *) 1,                     /* -1 : repeat continually */
262                         MM_ATTRS_VALID_TYPE_INT_RANGE,
263                         -1,
264                         1
265                 },
266                 {
267                         "profile_prepare_async",
268                         MM_ATTRS_TYPE_INT,
269                         MM_ATTRS_FLAG_RW,
270                         (void *) 0,
271                         MM_ATTRS_VALID_TYPE_INT_RANGE,
272                         0,
273                         1
274                 },
275                 {
276                         "streaming_user_agent",
277                         MM_ATTRS_TYPE_STRING,
278                         MM_ATTRS_FLAG_RW,
279                         (void *) NULL,
280                         MM_ATTRS_VALID_TYPE_NONE,
281                         0,
282                         0
283                 },
284                 {
285                         "streaming_cookie",
286                         MM_ATTRS_TYPE_STRING,
287                         MM_ATTRS_FLAG_RW,
288                         (void *) NULL,
289                         MM_ATTRS_VALID_TYPE_NONE,
290                         0,
291                         0
292                 },
293                 {
294                         "subtitle_uri",
295                         MM_ATTRS_TYPE_STRING,
296                         MM_ATTRS_FLAG_RW,
297                         (void *) NULL,
298                         MM_ATTRS_VALID_TYPE_NONE,
299                         0,
300                         0
301                 },
302                 {
303                         "content_bitrate",
304                         MM_ATTRS_TYPE_INT,
305                         MM_ATTRS_FLAG_RW,
306                         (void *) 0,
307                         MM_ATTRS_VALID_TYPE_INT_RANGE,
308                         0,
309                         MMPLAYER_MAX_INT
310                 },
311                 {
312                         "content_max_bitrate",
313                         MM_ATTRS_TYPE_INT,
314                         MM_ATTRS_FLAG_RW,
315                         (void *) 0,
316                         MM_ATTRS_VALID_TYPE_INT_RANGE,
317                         0,
318                         MMPLAYER_MAX_INT
319                 },
320                 {
321                         "content_video_found",
322                         MM_ATTRS_TYPE_INT,
323                         MM_ATTRS_FLAG_RW,
324                         (void *) 0,
325                         MM_ATTRS_VALID_TYPE_INT_RANGE,
326                         0,
327                         1
328                 },
329                 {
330                         "content_video_codec",
331                         MM_ATTRS_TYPE_STRING,
332                         MM_ATTRS_FLAG_RW,
333                         (void *) NULL,
334                         MM_ATTRS_VALID_TYPE_NONE,
335                         0,
336                         0
337                 },
338                 {
339                         "content_video_bitrate",
340                         MM_ATTRS_TYPE_INT,
341                         MM_ATTRS_FLAG_RW,
342                         (void *) 0,
343                         MM_ATTRS_VALID_TYPE_INT_RANGE,
344                         0,
345                         MMPLAYER_MAX_INT
346                 },
347                 {
348                         "content_video_fps",
349                         MM_ATTRS_TYPE_INT,
350                         MM_ATTRS_FLAG_RW,
351                         (void *) 0,
352                         MM_ATTRS_VALID_TYPE_INT_RANGE,
353                         0,
354                         MMPLAYER_MAX_INT
355                 },
356                 {
357                         "content_video_width",
358                         MM_ATTRS_TYPE_INT,
359                         MM_ATTRS_FLAG_RW,
360                         (void *) 0,
361                         MM_ATTRS_VALID_TYPE_INT_RANGE,
362                         0,
363                         MMPLAYER_MAX_INT
364                 },
365                 {
366                         "content_video_height",
367                         MM_ATTRS_TYPE_INT,
368                         MM_ATTRS_FLAG_RW,
369                         (void *) 0,
370                         MM_ATTRS_VALID_TYPE_INT_RANGE,
371                         0,
372                         MMPLAYER_MAX_INT
373                 },
374                 {
375                         "content_audio_codec",
376                         MM_ATTRS_TYPE_STRING,
377                         MM_ATTRS_FLAG_RW,
378                         (void *) NULL,
379                         MM_ATTRS_VALID_TYPE_NONE,
380                         0,
381                         0
382                 },
383                 {
384                         "content_audio_bitrate",
385                         MM_ATTRS_TYPE_INT,
386                         MM_ATTRS_FLAG_RW,
387                         (void *) 0,
388                         MM_ATTRS_VALID_TYPE_INT_RANGE,
389                         0,
390                         MMPLAYER_MAX_INT
391                 },
392                 {
393                         "content_audio_channels",
394                         MM_ATTRS_TYPE_INT,
395                         MM_ATTRS_FLAG_RW,
396                         (void *) 0,
397                         MM_ATTRS_VALID_TYPE_INT_RANGE,
398                         0,
399                         MMPLAYER_MAX_INT
400                 },
401                 {
402                         "content_audio_samplerate",
403                         MM_ATTRS_TYPE_INT,
404                         MM_ATTRS_FLAG_RW,
405                         (void *) 0,
406                         MM_ATTRS_VALID_TYPE_INT_RANGE,
407                         0,
408                         MMPLAYER_MAX_INT
409                 },
410                 {
411                         "content_text_track_num",
412                         MM_ATTRS_TYPE_INT,
413                         MM_ATTRS_FLAG_RW,
414                         (void *) 0,
415                         MM_ATTRS_VALID_TYPE_INT_RANGE,
416                         0,
417                         MMPLAYER_MAX_INT
418                 },
419                 {
420                         "tag_artist",
421                         MM_ATTRS_TYPE_STRING,
422                         MM_ATTRS_FLAG_RW,
423                         (void *) NULL,
424                         MM_ATTRS_VALID_TYPE_NONE,
425                         0,
426                         0
427                 },
428                 {
429                         "tag_title",
430                         MM_ATTRS_TYPE_STRING,
431                         MM_ATTRS_FLAG_RW,
432                         (void *) NULL,
433                         MM_ATTRS_VALID_TYPE_NONE,
434                         0,
435                         0
436                 },
437                 {
438                         "tag_album",
439                         MM_ATTRS_TYPE_STRING,
440                         MM_ATTRS_FLAG_RW,
441                         (void *) NULL
442                 },
443                 {
444                         "tag_genre",
445                         MM_ATTRS_TYPE_STRING,
446                         MM_ATTRS_FLAG_RW,
447                         (void *) NULL,
448                         MM_ATTRS_VALID_TYPE_NONE,
449                         0,
450                         0
451                 },
452                 {
453                         "tag_author",
454                         MM_ATTRS_TYPE_STRING,
455                         MM_ATTRS_FLAG_RW,
456                         (void *) NULL,
457                         MM_ATTRS_VALID_TYPE_NONE,
458                         0,
459                         0
460                 },
461                 {
462                         "tag_copyright",
463                         MM_ATTRS_TYPE_STRING,
464                         MM_ATTRS_FLAG_RW,
465                         (void *) NULL,
466                         MM_ATTRS_VALID_TYPE_NONE,
467                         0,
468                         0
469                 },
470                 {
471                         "tag_date",
472                         MM_ATTRS_TYPE_STRING,
473                         MM_ATTRS_FLAG_RW,
474                         (void *) NULL,
475                         MM_ATTRS_VALID_TYPE_NONE,
476                         0,
477                         0
478                 },
479                 {
480                         "tag_description",
481                         MM_ATTRS_TYPE_STRING,
482                         MM_ATTRS_FLAG_RW,
483                         (void *) NULL,
484                         MM_ATTRS_VALID_TYPE_NONE,
485                         0,
486                         0
487                 },
488                 {
489                         "tag_track_num",
490                         MM_ATTRS_TYPE_INT,
491                         MM_ATTRS_FLAG_RW,
492                         (void *) 0,
493                         MM_ATTRS_VALID_TYPE_INT_RANGE,
494                         0,
495                         MMPLAYER_MAX_INT
496                 },
497                 {
498                         "tag_album_cover",
499                         MM_ATTRS_TYPE_DATA,
500                         MM_ATTRS_FLAG_RW,
501                         (void *) NULL,
502                         MM_ATTRS_VALID_TYPE_NONE,
503                         0,
504                         0
505                 },
506                 {
507                         "display_rotation",
508                         MM_ATTRS_TYPE_INT,
509                         MM_ATTRS_FLAG_RW,
510                         (void *) MM_DISPLAY_ROTATION_NONE,
511                         MM_ATTRS_VALID_TYPE_INT_RANGE,
512                         MM_DISPLAY_ROTATION_NONE,
513                         MM_DISPLAY_ROTATION_270
514                 },
515                 {
516                         "display_visible",
517                         MM_ATTRS_TYPE_INT,
518                         MM_ATTRS_FLAG_RW,
519                         (void *) FALSE,
520                         MM_ATTRS_VALID_TYPE_INT_RANGE,
521                         0,
522                         1
523                 },
524                 {
525                         "display_method",
526                         MM_ATTRS_TYPE_INT,
527                         MM_ATTRS_FLAG_RW,
528                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
529                         MM_ATTRS_VALID_TYPE_INT_RANGE,
530                         MM_DISPLAY_METHOD_LETTER_BOX,
531                         MM_DISPLAY_METHOD_CUSTOM_ROI
532                 },
533                 {
534                         "display_overlay",
535                         MM_ATTRS_TYPE_DATA,
536                         MM_ATTRS_FLAG_RW,
537                         (void *) NULL,
538                         MM_ATTRS_VALID_TYPE_NONE,
539                         0,
540                         0
541                 },
542                 {
543                         "display_win_roi_x",
544                         MM_ATTRS_TYPE_INT,
545                         MM_ATTRS_FLAG_RW,
546                         (void *) 0,
547                         MM_ATTRS_VALID_TYPE_INT_RANGE,
548                         0,
549                         MMPLAYER_MAX_INT
550                 },
551                 {
552                         "display_win_roi_y",
553                         MM_ATTRS_TYPE_INT,
554                         MM_ATTRS_FLAG_RW,
555                         (void *) 0,
556                         MM_ATTRS_VALID_TYPE_INT_RANGE,
557                         0,
558                         MMPLAYER_MAX_INT
559                 },
560                 {
561                         "display_win_roi_width",
562                         MM_ATTRS_TYPE_INT,
563                         MM_ATTRS_FLAG_RW,
564                         (void *) 0,
565                         MM_ATTRS_VALID_TYPE_INT_RANGE,
566                         0,
567                         MMPLAYER_MAX_INT
568                 },
569                 {
570                         "display_win_roi_height",
571                         MM_ATTRS_TYPE_INT,
572                         MM_ATTRS_FLAG_RW,
573                         (void *) 0,
574                         MM_ATTRS_VALID_TYPE_INT_RANGE,
575                         0,
576                         MMPLAYER_MAX_INT
577                 },
578                 {
579                         "display_surface_type",
580                         MM_ATTRS_TYPE_INT,
581                         MM_ATTRS_FLAG_RW,
582                         (void *) MM_DISPLAY_SURFACE_NULL,
583                         MM_ATTRS_VALID_TYPE_INT_RANGE,
584                         MM_DISPLAY_SURFACE_OVERLAY,
585                         MM_DISPLAY_SURFACE_NUM - 1
586                 },
587                 {
588                         "sound_stream_type",
589                         MM_ATTRS_TYPE_STRING,
590                         MM_ATTRS_FLAG_RW,
591                         (void *) NULL,
592                         MM_ATTRS_VALID_TYPE_NONE,
593                         0,
594                         0
595                 },
596                 {
597                         "sound_stream_index",
598                         MM_ATTRS_TYPE_INT,
599                         MM_ATTRS_FLAG_RW,
600                         0,
601                         MM_ATTRS_VALID_TYPE_INT_RANGE,
602                         -1,
603                         MMPLAYER_MAX_INT
604                 },
605                 {
606                         "sound_latency_mode",
607                         MM_ATTRS_TYPE_INT,
608                         MM_ATTRS_FLAG_RW,
609                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
610                         MM_ATTRS_VALID_TYPE_INT_RANGE,
611                         0,
612                         2
613                 },
614                 {
615                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
616                         MM_ATTRS_TYPE_INT,
617                         MM_ATTRS_FLAG_RW,
618                         (void *) 44100,                         // hz
619                         MM_ATTRS_VALID_TYPE_INT_RANGE,
620                         0,
621                         MMPLAYER_MAX_INT
622                 },
623                 {
624                         "pcm_extraction_channels",      // set channels for pcm extraction
625                         MM_ATTRS_TYPE_INT,
626                         MM_ATTRS_FLAG_RW,
627                         (void *) 1,
628                         MM_ATTRS_VALID_TYPE_INT_RANGE,
629                         0,
630                         MMPLAYER_MAX_INT
631                 },
632                 {
633                         "pd_mode",
634                         MM_ATTRS_TYPE_INT,
635                         MM_ATTRS_FLAG_RW,
636                         (void *) MM_PLAYER_PD_MODE_NONE,
637                         MM_ATTRS_VALID_TYPE_INT_RANGE,
638                         MM_PLAYER_PD_MODE_NONE,
639                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
640                 },
641                 {
642                         "pd_location",                  // location of the file to write
643                         MM_ATTRS_TYPE_STRING,
644                         MM_ATTRS_FLAG_RW,
645                         (void *) NULL,
646                         MM_ATTRS_VALID_TYPE_NONE,
647                         0,
648                         0
649                 },
650                 {
651                         "accurate_seek",
652                         MM_ATTRS_TYPE_INT,
653                         MM_ATTRS_FLAG_RW,
654                         (void *) 0,
655                         MM_ATTRS_VALID_TYPE_INT_RANGE,
656                         0,
657                         1
658                 },
659                 {
660                         "content_video_orientation",    // orientation of video content
661                         MM_ATTRS_TYPE_STRING,
662                         MM_ATTRS_FLAG_RW,
663                         (void *) NULL,
664                         MM_ATTRS_VALID_TYPE_NONE,
665                         0,
666                         0
667                 },
668                 {
669                         "pcm_audioformat",
670                         MM_ATTRS_TYPE_STRING,
671                         MM_ATTRS_FLAG_RW,
672                         (void *) NULL,
673                         MM_ATTRS_VALID_TYPE_NONE,
674                         0,
675                         0
676                 },
677                 {
678                         "drc_mode",
679                         MM_ATTRS_TYPE_INT,
680                         MM_ATTRS_FLAG_RW,
681                         (void *) FALSE,
682                         MM_ATTRS_VALID_TYPE_INT_RANGE,
683                         FALSE,
684                         TRUE
685                 },
686                 {
687                         "gapless_mode",
688                         MM_ATTRS_TYPE_INT,
689                         MM_ATTRS_FLAG_RW,
690                         (void *) FALSE,
691                         MM_ATTRS_VALID_TYPE_INT_RANGE,
692                         FALSE,
693                         TRUE
694                 },
695                 {
696                         "enable_video_decoded_cb",
697                         MM_ATTRS_TYPE_INT,
698                         MM_ATTRS_FLAG_RW,
699                         (void *) FALSE,
700                         MM_ATTRS_VALID_TYPE_INT_RANGE,
701                         FALSE,
702                         TRUE
703                 },
704                 {
705                         "content_video_is_spherical",
706                         MM_ATTRS_TYPE_INT,
707                         MM_ATTRS_FLAG_RW,
708                         (void *) -1,
709                         MM_ATTRS_VALID_TYPE_INT_RANGE,
710                         -1,
711                         MMPLAYER_MAX_INT
712                 },
713                 {
714                         "video_codec_type",
715                         MM_ATTRS_TYPE_INT,
716                         MM_ATTRS_FLAG_RW,
717                         (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
718                         MM_ATTRS_VALID_TYPE_INT_RANGE,
719                         MM_PLAYER_CODEC_TYPE_DEFAULT,
720                         MM_PLAYER_CODEC_TYPE_SW
721                 },
722                 {
723                         "audio_codec_type",
724                         MM_ATTRS_TYPE_INT,
725                         MM_ATTRS_FLAG_RW,
726                         (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
727                         MM_ATTRS_VALID_TYPE_INT_RANGE,
728                         MM_PLAYER_CODEC_TYPE_DEFAULT,
729                         MM_PLAYER_CODEC_TYPE_SW
730                 },
731         };
732
733         num_of_attrs = ARRAY_SIZE(player_attrs);
734
735         base = (MMAttrsConstructInfo*)malloc(num_of_attrs * sizeof(MMAttrsConstructInfo));
736
737         if (!base) {
738                 LOGE("failed to alloc attrs constructor");
739                 return 0;
740         }
741
742         /* initialize values of attributes */
743         for (idx = 0; idx < num_of_attrs; idx++) {
744                 base[idx].name = player_attrs[idx].name;
745                 base[idx].value_type = player_attrs[idx].value_type;
746                 base[idx].flags = player_attrs[idx].flags;
747                 base[idx].default_value = player_attrs[idx].default_value;
748         }
749
750         result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
751                                                         NULL, NULL, &attrs);
752
753         /* clean */
754         MMPLAYER_FREEIF(base);
755
756         if (result) {
757                 LOGE("failed to create player attrs");
758                 return 0;
759         }
760
761         /* set validity type and range */
762         for (idx = 0; idx < num_of_attrs; idx++) {
763                 switch (player_attrs[idx].valid_type) {
764                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
765                 {
766                         mm_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
767                         mm_attrs_set_valid_range(attrs, idx,
768                                         player_attrs[idx].value_min,
769                                         player_attrs[idx].value_max,
770                                         (int)(intptr_t)(player_attrs[idx].default_value));
771                 }
772                         break;
773
774                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
775                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
776                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
777                 default:
778                         break;
779                 }
780         }
781
782         /* commit */
783         if (mm_attrs_commit_all(attrs)) {
784                 LOGE("failed to update attributes\n");
785                 mm_attrs_free(attrs);
786                 return 0;
787         }
788
789         return attrs;
790 }
791
792 bool
793 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
794 {
795         mm_player_t *player = MM_PLAYER_CAST(handle);
796
797         MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
798
799         if (player->attrs) {
800                 mm_attrs_free(player->attrs);
801                 player->attrs = 0;
802         }
803
804         return TRUE;
805 }