[0.6.116] use nsec unit instead of msec
[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_private.h>
30 #include <mm_attrs.h>
31 #include "mm_player_utils.h"
32 #include "mm_player_priv.h"
33 #include "mm_player_attrs.h"
34
35 /*===========================================================================================
36 |                                                                                                                                                                                       |
37 |  LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                        |
38 |                                                                                                                                                                                       |
39 ========================================================================================== */
40
41 /*---------------------------------------------------------------------------
42 |    LOCAL FUNCTION PROTOTYPES:                                                                                         |
43 ---------------------------------------------------------------------------*/
44 int
45 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
46
47 /*===========================================================================================
48 |                                                                                                                                                                                                               |
49 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
50 |                                                                                                                                                                                                               |
51 ========================================================================================== */
52
53 int
54 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
55 {
56         int result = MM_ERROR_NONE;
57         MMHandleType attrs = 0;
58
59         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
60         /* if it's not want to know it. */
61         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
62         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
63
64         attrs = MM_PLAYER_GET_ATTRS(handle);
65
66         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
67
68         if (result != MM_ERROR_NONE)
69                 LOGE("failed to get %s attribute\n", attribute_name);
70
71         return result;
72 }
73
74 int
75 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
76 {
77         int result = MM_ERROR_NONE;
78         MMHandleType attrs = 0;
79
80         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
81         /* if it's not want to know it. */
82         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
83         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
84
85         attrs = MM_PLAYER_GET_ATTRS(handle);
86
87         /* set attributes and commit them */
88         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
89
90         if (result != MM_ERROR_NONE) {
91                 LOGE("failed to set %s attribute\n", attribute_name);
92                 return result;
93         }
94
95         result = __mmplayer_apply_attribute(handle, attribute_name);
96         if (result != MM_ERROR_NONE) {
97                 LOGE("failed to apply attributes\n");
98                 return result;
99         }
100
101         return result;
102 }
103
104 int
105 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
106 {
107         int result = MM_ERROR_NONE;
108         MMHandleType attrs = 0;
109         MMAttrsInfo src_info = {0, };
110
111         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
112         MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
113         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
114
115         attrs = MM_PLAYER_GET_ATTRS(handle);
116
117         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
118
119         if (result != MM_ERROR_NONE) {
120                 LOGE("failed to get attribute info\n");
121                 return result;
122         }
123
124         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
125
126         dst_info->type = src_info.type;
127         dst_info->flag = src_info.flag;
128         dst_info->validity_type = src_info.validity_type;
129
130         switch (src_info.validity_type) {
131         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
132                 dst_info->int_array.array = src_info.int_array.array;
133                 dst_info->int_array.count = src_info.int_array.count;
134                 dst_info->int_array.d_val = src_info.int_array.dval;
135                 break;
136
137         case MM_ATTRS_VALID_TYPE_INT_RANGE:
138                 dst_info->int_range.min = src_info.int_range.min;
139                 dst_info->int_range.max = src_info.int_range.max;
140                 dst_info->int_range.d_val = src_info.int_range.dval;
141                 break;
142
143         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
144                 dst_info->double_array.array = src_info.double_array.array;
145                 dst_info->double_array.count = src_info.double_array.count;
146                 dst_info->double_array.d_val = src_info.double_array.dval;
147                 break;
148
149         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
150                 dst_info->double_range.min = src_info.double_range.min;
151                 dst_info->double_range.max = src_info.double_range.max;
152                 dst_info->double_range.d_val = src_info.double_range.dval;
153                 break;
154
155         default:
156                 break;
157         }
158
159         return result;
160 }
161
162 int
163 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
164 {
165         mm_player_t* player = 0;
166
167         MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
168         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
169
170         player = MM_PLAYER_CAST(handle);
171         MMPlayerGstPipelineInfo *pipeline = player->pipeline;
172
173         /* Currently, there are only display related implementation at below */
174         if (!pipeline ||
175                 !pipeline->videobin ||
176                 !pipeline->videobin[MMPLAYER_V_SINK].gst) {
177                 /*
178                  * The attribute should be committed even though videobin is not created yet.
179                  * So, true should be returned here.
180                  * Otherwise, video can be diaplayed abnormal.
181                  */
182                 return MM_ERROR_NONE;
183         }
184
185         if (g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x")) {
186                 char *param_name = NULL;
187                 int str_len = strlen(attribute_name);
188                 param_name = g_malloc0(str_len + 1);
189                 if (!param_name) {
190                         LOGE("failed to alloc param_name");
191                         return MM_ERROR_PLAYER_INTERNAL;
192                 }
193                 strncpy(param_name, attribute_name, str_len);
194                 param_name[str_len] = '\0';
195                 LOGD(" param_name: %s", param_name);
196                 if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
197                         g_free(param_name);
198                         LOGE("failed to update video param");
199                         return MM_ERROR_PLAYER_INTERNAL;
200                 }
201                 g_free(param_name);
202         }
203
204         if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
205                 int gapless = 0;
206
207                 mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
208
209                 if (gapless > 0) {
210                         LOGD("disable last-sample at videosink");
211                         g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
212                 }
213         }
214
215         if (g_strrstr(attribute_name, MM_PLAYER_ENABLE_VIDEO_DECODED_CB)) {
216                 if (!player->set_mode.media_packet_video_stream) {
217                         LOGE("there is no callback for media_packet");
218                         return MM_ERROR_PLAYER_INTERNAL;
219                 }
220                 int enable = 0;
221                 mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
222                 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "signal-handoffs", enable ? TRUE : FALSE, NULL);
223         }
224
225         return MM_ERROR_NONE;
226 }
227
228 MMHandleType
229 _mmplayer_construct_attribute(MMHandleType handle)
230 {
231         int idx = 0;
232         MMHandleType attrs = 0;
233         int num_of_attrs = 0;
234         mmf_attrs_construct_info_t *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_audio_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                         "content_text_track_num",
421                         MM_ATTRS_TYPE_INT,
422                         MM_ATTRS_FLAG_RW,
423                         (void *) 0,
424                         MM_ATTRS_VALID_TYPE_INT_RANGE,
425                         0,
426                         MMPLAYER_MAX_INT
427                 },
428                 {
429                         "tag_artist",
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_title",
439                         MM_ATTRS_TYPE_STRING,
440                         MM_ATTRS_FLAG_RW,
441                         (void *) NULL,
442                         MM_ATTRS_VALID_TYPE_NONE,
443                         0,
444                         0
445                 },
446                 {
447                         "tag_album",
448                         MM_ATTRS_TYPE_STRING,
449                         MM_ATTRS_FLAG_RW,
450                         (void *) NULL
451                 },
452                 {
453                         "tag_genre",
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_author",
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_copyright",
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_date",
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_description",
490                         MM_ATTRS_TYPE_STRING,
491                         MM_ATTRS_FLAG_RW,
492                         (void *) NULL,
493                         MM_ATTRS_VALID_TYPE_NONE,
494                         0,
495                         0
496                 },
497                 {
498                         "tag_track_num",
499                         MM_ATTRS_TYPE_INT,
500                         MM_ATTRS_FLAG_RW,
501                         (void *) 0,
502                         MM_ATTRS_VALID_TYPE_INT_RANGE,
503                         0,
504                         MMPLAYER_MAX_INT
505                 },
506                 {
507                         "tag_album_cover",
508                         MM_ATTRS_TYPE_DATA,
509                         MM_ATTRS_FLAG_RW,
510                         (void *) NULL,
511                         MM_ATTRS_VALID_TYPE_NONE,
512                         0,
513                         0
514                 },
515                 {
516                         "display_rotation",
517                         MM_ATTRS_TYPE_INT,
518                         MM_ATTRS_FLAG_RW,
519                         (void *) MM_DISPLAY_ROTATION_NONE,
520                         MM_ATTRS_VALID_TYPE_INT_RANGE,
521                         MM_DISPLAY_ROTATION_NONE,
522                         MM_DISPLAY_ROTATION_270
523                 },
524                 {
525                         "display_visible",
526                         MM_ATTRS_TYPE_INT,
527                         MM_ATTRS_FLAG_RW,
528                         (void *) FALSE,
529                         MM_ATTRS_VALID_TYPE_INT_RANGE,
530                         0,
531                         1
532                 },
533                 {
534                         "display_method",
535                         MM_ATTRS_TYPE_INT,
536                         MM_ATTRS_FLAG_RW,
537                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
538                         MM_ATTRS_VALID_TYPE_INT_RANGE,
539                         MM_DISPLAY_METHOD_LETTER_BOX,
540                         MM_DISPLAY_METHOD_CUSTOM_ROI
541                 },
542                 {
543                         "display_overlay",
544                         MM_ATTRS_TYPE_DATA,
545                         MM_ATTRS_FLAG_RW,
546                         (void *) NULL,
547                         MM_ATTRS_VALID_TYPE_NONE,
548                         0,
549                         0
550                 },
551                 {
552                         "wl_window_render_x",
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                         "wl_window_render_y",
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                         "wl_window_render_width",
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                         "wl_window_render_height",
580                         MM_ATTRS_TYPE_INT,
581                         MM_ATTRS_FLAG_RW,
582                         (void *) 0,
583                         MM_ATTRS_VALID_TYPE_INT_RANGE,
584                         0,
585                         MMPLAYER_MAX_INT
586                 },
587                 {
588                         "display_surface_type",
589                         MM_ATTRS_TYPE_INT,
590                         MM_ATTRS_FLAG_RW,
591                         (void *) MM_DISPLAY_SURFACE_NULL,
592                         MM_ATTRS_VALID_TYPE_INT_RANGE,
593                         MM_DISPLAY_SURFACE_OVERLAY,
594                         MM_DISPLAY_SURFACE_NUM - 1
595                 },
596                 {
597                         "sound_stream_type",
598                         MM_ATTRS_TYPE_STRING,
599                         MM_ATTRS_FLAG_RW,
600                         (void *) NULL,
601                         MM_ATTRS_VALID_TYPE_NONE,
602                         0,
603                         0
604                 },
605                 {
606                         "sound_stream_index",
607                         MM_ATTRS_TYPE_INT,
608                         MM_ATTRS_FLAG_RW,
609                         0,
610                         MM_ATTRS_VALID_TYPE_INT_RANGE,
611                         -1,
612                         MMPLAYER_MAX_INT
613                 },
614                 {
615                         "sound_latency_mode",
616                         MM_ATTRS_TYPE_INT,
617                         MM_ATTRS_FLAG_RW,
618                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
619                         MM_ATTRS_VALID_TYPE_INT_RANGE,
620                         0,
621                         2
622                 },
623                 {
624                         "pcm_extraction",               // enable pcm extraction
625                         MM_ATTRS_TYPE_INT,
626                         MM_ATTRS_FLAG_RW,
627                         (void *) FALSE,
628                         MM_ATTRS_VALID_TYPE_INT_RANGE,
629                         FALSE,
630                         TRUE
631                 },
632                 {
633                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
634                         MM_ATTRS_TYPE_INT,
635                         MM_ATTRS_FLAG_RW,
636                         (void *) 44100,                         // hz
637                         MM_ATTRS_VALID_TYPE_INT_RANGE,
638                         0,
639                         MMPLAYER_MAX_INT
640                 },
641                 {
642                         "pcm_extraction_depth", // set depth for pcm extraction
643                         MM_ATTRS_TYPE_INT,
644                         MM_ATTRS_FLAG_RW,
645                         (void *) 16,                    // bits
646                         MM_ATTRS_VALID_TYPE_INT_RANGE,
647                         0,
648                         MMPLAYER_MAX_INT
649                 },
650                 {
651                         "pcm_extraction_channels",      // set channels for pcm extraction
652                         MM_ATTRS_TYPE_INT,
653                         MM_ATTRS_FLAG_RW,
654                         (void *) 1,
655                         MM_ATTRS_VALID_TYPE_INT_RANGE,
656                         0,
657                         MMPLAYER_MAX_INT
658                 },
659                 {
660                         "pcm_extraction_start_msec",    // set start position to extract pcm
661                         MM_ATTRS_TYPE_INT,
662                         MM_ATTRS_FLAG_RW,
663                         (void *) 0,
664                         MM_ATTRS_VALID_TYPE_INT_RANGE,
665                         0,
666                         MMPLAYER_MAX_INT
667                 },
668                 {
669                         "pcm_extraction_end_msec",      // set end position to extract pcm
670                         MM_ATTRS_TYPE_INT,
671                         MM_ATTRS_FLAG_RW,
672                         (void *) 0,
673                         MM_ATTRS_VALID_TYPE_INT_RANGE,
674                         0,
675                         MMPLAYER_MAX_INT
676                 },
677                 {
678                         "pd_mode",
679                         MM_ATTRS_TYPE_INT,
680                         MM_ATTRS_FLAG_RW,
681                         (void *) MM_PLAYER_PD_MODE_NONE,
682                         MM_ATTRS_VALID_TYPE_INT_RANGE,
683                         MM_PLAYER_PD_MODE_NONE,
684                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
685                 },
686                 {
687                         "pd_location",                  // location of the file to write
688                         MM_ATTRS_TYPE_STRING,
689                         MM_ATTRS_FLAG_RW,
690                         (void *) NULL,
691                         MM_ATTRS_VALID_TYPE_NONE,
692                         0,
693                         0
694                 },
695                 {
696                         "accurate_seek",
697                         MM_ATTRS_TYPE_INT,
698                         MM_ATTRS_FLAG_RW,
699                         (void *) 0,
700                         MM_ATTRS_VALID_TYPE_INT_RANGE,
701                         0,
702                         1
703                 },
704                 {
705                         "content_video_orientation",    // orientation of video content
706                         MM_ATTRS_TYPE_STRING,
707                         MM_ATTRS_FLAG_RW,
708                         (void *) NULL,
709                         MM_ATTRS_VALID_TYPE_NONE,
710                         0,
711                         0
712                 },
713                 {
714                         "pcm_audioformat",
715                         MM_ATTRS_TYPE_STRING,
716                         MM_ATTRS_FLAG_RW,
717                         (void *) NULL,
718                         MM_ATTRS_VALID_TYPE_NONE,
719                         0,
720                         0
721                 },
722                 {
723                         "drc_mode",
724                         MM_ATTRS_TYPE_INT,
725                         MM_ATTRS_FLAG_RW,
726                         (void *) FALSE,
727                         MM_ATTRS_VALID_TYPE_INT_RANGE,
728                         FALSE,
729                         TRUE
730                 },
731                 {
732                         "gapless_mode",
733                         MM_ATTRS_TYPE_INT,
734                         MM_ATTRS_FLAG_RW,
735                         (void *) FALSE,
736                         MM_ATTRS_VALID_TYPE_INT_RANGE,
737                         FALSE,
738                         TRUE
739                 },
740                 {
741                         "enable_video_decoded_cb",
742                         MM_ATTRS_TYPE_INT,
743                         MM_ATTRS_FLAG_RW,
744                         (void *) FALSE,
745                         MM_ATTRS_VALID_TYPE_INT_RANGE,
746                         FALSE,
747                         TRUE
748                 },
749                 {
750                         "content_video_is_spherical",
751                         MM_ATTRS_TYPE_INT,
752                         MM_ATTRS_FLAG_RW,
753                         (void *) -1,
754                         MM_ATTRS_VALID_TYPE_INT_RANGE,
755                         -1,
756                         MMPLAYER_MAX_INT
757                 },
758                 {
759                         "video_codec_type",
760                         MM_ATTRS_TYPE_INT,
761                         MM_ATTRS_FLAG_RW,
762                         (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
763                         MM_ATTRS_VALID_TYPE_INT_RANGE,
764                         MM_PLAYER_CODEC_TYPE_DEFAULT,
765                         MM_PLAYER_CODEC_TYPE_SW
766                 },
767                 {
768                         "audio_codec_type",
769                         MM_ATTRS_TYPE_INT,
770                         MM_ATTRS_FLAG_RW,
771                         (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
772                         MM_ATTRS_VALID_TYPE_INT_RANGE,
773                         MM_PLAYER_CODEC_TYPE_DEFAULT,
774                         MM_PLAYER_CODEC_TYPE_SW
775                 },
776         };
777
778         num_of_attrs = ARRAY_SIZE(player_attrs);
779
780         base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
781
782         if (!base) {
783                 LOGE("failed to alloc attrs constructor");
784                 return 0;
785         }
786
787         /* initialize values of attributes */
788         for (idx = 0; idx < num_of_attrs; idx++) {
789                 base[idx].name = player_attrs[idx].name;
790                 base[idx].value_type = player_attrs[idx].value_type;
791                 base[idx].flags = player_attrs[idx].flags;
792                 base[idx].default_value = player_attrs[idx].default_value;
793         }
794
795         attrs = mmf_attrs_new_from_data(
796                                         "mmplayer_attrs",
797                                         base,
798                                         num_of_attrs,
799                                         NULL,
800                                         NULL);
801
802         /* clean */
803         MMPLAYER_FREEIF(base);
804
805         if (!attrs) {
806                 LOGE("failed to create player attrs");
807                 return 0;
808         }
809
810         /* set validity type and range */
811         for (idx = 0; idx < num_of_attrs; idx++) {
812                 switch (player_attrs[idx].valid_type) {
813                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
814                 {
815                         mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
816                         mmf_attrs_set_valid_range(attrs, idx,
817                                         player_attrs[idx].value_min,
818                                         player_attrs[idx].value_max,
819                                         (int)(intptr_t)(player_attrs[idx].default_value));
820                 }
821                         break;
822
823                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
824                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
825                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
826                 default:
827                         break;
828                 }
829         }
830
831         /* commit */
832         if (mmf_attrs_commit(attrs)) {
833                 LOGE("failed to update attributes\n");
834                 mmf_attrs_free(attrs);
835                 return 0;
836         }
837
838         return attrs;
839 }
840
841 bool
842 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
843 {
844         mm_player_t *player = MM_PLAYER_CAST(handle);
845
846         MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
847
848         if (player->attrs) {
849                 mmf_attrs_free(player->attrs);
850                 player->attrs = 0;
851         }
852
853         return TRUE;
854 }