3869e4deaeab9bb730aa1d1fb3bb7a9ecee564b6
[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);
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                 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         return MM_ERROR_NONE;
215 }
216
217 MMHandleType
218 _mmplayer_construct_attribute(MMHandleType handle)
219 {
220         mm_player_t *player = NULL;
221         int idx = 0;
222         MMHandleType attrs = 0;
223         int num_of_attrs = 0;
224         mmf_attrs_construct_info_t *base = NULL;
225
226         MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
227
228         player = MM_PLAYER_CAST(handle);
229
230         MMPlayerAttrsSpec player_attrs[] = {
231                 {
232                         "profile_uri",                                  // name
233                         MM_ATTRS_TYPE_STRING,           // type
234                         MM_ATTRS_FLAG_RW,                       // flag
235                         (void *) NULL,                          // default value
236                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
237                         0,                                                      // validity min value
238                         0                                                       // validity max value
239                 },
240                 {
241                         "profile_user_param",
242                         MM_ATTRS_TYPE_DATA,
243                         MM_ATTRS_FLAG_RW,
244                         (void *) NULL,
245                         MM_ATTRS_VALID_TYPE_NONE,
246                         0,
247                         0
248                 },
249                 {
250                         "profile_play_count",
251                         MM_ATTRS_TYPE_INT,
252                         MM_ATTRS_FLAG_RW,
253                         (void *) 1,                     // -1 : repeat continually
254                         MM_ATTRS_VALID_TYPE_INT_RANGE,
255                         -1,
256                         MMPLAYER_MAX_INT
257                 },
258                 {
259                         "profile_prepare_async",
260                         MM_ATTRS_TYPE_INT,
261                         MM_ATTRS_FLAG_RW,
262                         (void *) 0,
263                         MM_ATTRS_VALID_TYPE_INT_RANGE,
264                         0,
265                         1
266                 },
267                 {       /* update registry for downloadable codec */
268                         "profile_update_registry",
269                         MM_ATTRS_TYPE_INT,
270                         MM_ATTRS_FLAG_RW,
271                         (void *) 0,
272                         MM_ATTRS_VALID_TYPE_INT_RANGE,
273                         0,
274                         1
275                 },
276                 {
277                         "streaming_type",
278                         MM_ATTRS_TYPE_INT,
279                         MM_ATTRS_FLAG_RW,
280                         (void *) STREAMING_SERVICE_NONE,
281                         MM_ATTRS_VALID_TYPE_INT_RANGE,
282                         STREAMING_SERVICE_VOD,
283                         STREAMING_SERVICE_NUM
284                 },
285                 {
286                         "streaming_udp_timeout",
287                         MM_ATTRS_TYPE_INT,
288                         MM_ATTRS_FLAG_RW,
289                         (void *) 10000,
290                         MM_ATTRS_VALID_TYPE_INT_RANGE,
291                         0,
292                         MMPLAYER_MAX_INT
293                 },
294                 {
295                         "streaming_user_agent",
296                         MM_ATTRS_TYPE_STRING,
297                         MM_ATTRS_FLAG_RW,
298                         (void *) NULL,
299                         MM_ATTRS_VALID_TYPE_NONE,
300                         0,
301                         0
302                 },
303                 {
304                         "streaming_wap_profile",
305                         MM_ATTRS_TYPE_STRING,
306                         MM_ATTRS_FLAG_RW,
307                         (void *) NULL,
308                         MM_ATTRS_VALID_TYPE_NONE,
309                         0,
310                         0
311                 },
312                 {
313                         "streaming_network_bandwidth",
314                         MM_ATTRS_TYPE_INT,
315                         MM_ATTRS_FLAG_RW,
316                         (void *) 128000,
317                         MM_ATTRS_VALID_TYPE_INT_RANGE,
318                         0,
319                         MMPLAYER_MAX_INT
320                 },
321                 {
322                         "streaming_cookie",
323                         MM_ATTRS_TYPE_STRING,
324                         MM_ATTRS_FLAG_RW,
325                         (void *) NULL,
326                         MM_ATTRS_VALID_TYPE_NONE,
327                         0,
328                         0
329                 },
330                 {
331                         "streaming_proxy",
332                         MM_ATTRS_TYPE_STRING,
333                         MM_ATTRS_FLAG_RW,
334                         (void *) NULL,
335                         MM_ATTRS_VALID_TYPE_NONE,
336                         0,
337                         0
338                 },
339                 {
340                         "streaming_timeout",
341                         MM_ATTRS_TYPE_INT,
342                         MM_ATTRS_FLAG_RW,
343                         (void *) -1,    // DEFAULT_HTTP_TIMEOUT
344                         MM_ATTRS_VALID_TYPE_INT_RANGE,
345                         -1,
346                         MMPLAYER_MAX_INT
347                 },
348                 {
349                         "subtitle_uri",
350                         MM_ATTRS_TYPE_STRING,
351                         MM_ATTRS_FLAG_RW,
352                         (void *) NULL,
353                         MM_ATTRS_VALID_TYPE_NONE,
354                         0,
355                         0
356                 },
357                 {
358                         "content_duration",
359                         MM_ATTRS_TYPE_INT,
360                         MM_ATTRS_FLAG_RW,
361                         (void *) 0,
362                         MM_ATTRS_VALID_TYPE_INT_RANGE,
363                         0,
364                         MMPLAYER_MAX_INT
365                 },
366                 {
367                         "content_bitrate",
368                         MM_ATTRS_TYPE_INT,
369                         MM_ATTRS_FLAG_RW,
370                         (void *) 0,
371                         MM_ATTRS_VALID_TYPE_INT_RANGE,
372                         0,
373                         MMPLAYER_MAX_INT
374                 },
375                 {
376                         "content_max_bitrate",
377                         MM_ATTRS_TYPE_INT,
378                         MM_ATTRS_FLAG_RW,
379                         (void *) 0,
380                         MM_ATTRS_VALID_TYPE_INT_RANGE,
381                         0,
382                         MMPLAYER_MAX_INT
383                 },
384                 {
385                         "content_video_found",
386                         MM_ATTRS_TYPE_INT,
387                         MM_ATTRS_FLAG_RW,
388                         (void *) 0,
389                         MM_ATTRS_VALID_TYPE_INT_RANGE,
390                         0,
391                         1
392                 },
393                 {
394                         "content_video_codec",
395                         MM_ATTRS_TYPE_STRING,
396                         MM_ATTRS_FLAG_RW,
397                         (void *) NULL,
398                         MM_ATTRS_VALID_TYPE_NONE,
399                         0,
400                         0
401                 },
402                 {
403                         "content_video_bitrate",
404                         MM_ATTRS_TYPE_INT,
405                         MM_ATTRS_FLAG_RW,
406                         (void *) 0,
407                         MM_ATTRS_VALID_TYPE_INT_RANGE,
408                         0,
409                         MMPLAYER_MAX_INT
410                 },
411                 {
412                         "content_video_fps",
413                         MM_ATTRS_TYPE_INT,
414                         MM_ATTRS_FLAG_RW,
415                         (void *) 0,
416                         MM_ATTRS_VALID_TYPE_INT_RANGE,
417                         0,
418                         MMPLAYER_MAX_INT
419                 },
420                 {
421                         "content_video_width",
422                         MM_ATTRS_TYPE_INT,
423                         MM_ATTRS_FLAG_RW,
424                         (void *) 0,
425                         MM_ATTRS_VALID_TYPE_INT_RANGE,
426                         0,
427                         MMPLAYER_MAX_INT
428                 },
429                 {
430                         "content_video_height",
431                         MM_ATTRS_TYPE_INT,
432                         MM_ATTRS_FLAG_RW,
433                         (void *) 0,
434                         MM_ATTRS_VALID_TYPE_INT_RANGE,
435                         0,
436                         MMPLAYER_MAX_INT
437                 },
438                 {
439                         "content_video_track_num",
440                         MM_ATTRS_TYPE_INT,
441                         MM_ATTRS_FLAG_RW,
442                         (void *) 0,
443                         MM_ATTRS_VALID_TYPE_INT_RANGE,
444                         0,
445                         MMPLAYER_MAX_INT
446                 },
447                 {
448                         "content_audio_found",
449                         MM_ATTRS_TYPE_INT,
450                         MM_ATTRS_FLAG_RW,
451                         (void *) 0,
452                         MM_ATTRS_VALID_TYPE_INT_RANGE,
453                         0,
454                         1
455                 },
456                 {
457                         "content_audio_codec",
458                         MM_ATTRS_TYPE_STRING,
459                         MM_ATTRS_FLAG_RW,
460                         (void *) NULL,
461                         MM_ATTRS_VALID_TYPE_NONE,
462                         0,
463                         0
464                 },
465                 {
466                         "content_audio_bitrate",
467                         MM_ATTRS_TYPE_INT,
468                         MM_ATTRS_FLAG_RW,
469                         (void *) 0,
470                         MM_ATTRS_VALID_TYPE_INT_RANGE,
471                         0,
472                         MMPLAYER_MAX_INT
473                 },
474                 {
475                         "content_audio_channels",
476                         MM_ATTRS_TYPE_INT,
477                         MM_ATTRS_FLAG_RW,
478                         (void *) 0,
479                         MM_ATTRS_VALID_TYPE_INT_RANGE,
480                         0,
481                         MMPLAYER_MAX_INT
482                 },
483                 {
484                         "content_audio_samplerate",
485                         MM_ATTRS_TYPE_INT,
486                         MM_ATTRS_FLAG_RW,
487                         (void *) 0,
488                         MM_ATTRS_VALID_TYPE_INT_RANGE,
489                         0,
490                         MMPLAYER_MAX_INT
491                 },
492                 {
493                         "content_audio_track_num",
494                         MM_ATTRS_TYPE_INT,
495                         MM_ATTRS_FLAG_RW,
496                         (void *) 0,
497                         MM_ATTRS_VALID_TYPE_INT_RANGE,
498                         0,
499                         MMPLAYER_MAX_INT
500                 },
501                 {
502                         "content_audio_format",
503                         MM_ATTRS_TYPE_INT,
504                         MM_ATTRS_FLAG_RW,
505                         (void *) 0,
506                         MM_ATTRS_VALID_TYPE_INT_RANGE,
507                         0,
508                         MMPLAYER_MAX_INT
509                 },
510                 {
511                         "content_text_track_num",
512                         MM_ATTRS_TYPE_INT,
513                         MM_ATTRS_FLAG_RW,
514                         (void *) 0,
515                         MM_ATTRS_VALID_TYPE_INT_RANGE,
516                         0,
517                         MMPLAYER_MAX_INT
518                 },
519                 {
520                         "tag_artist",
521                         MM_ATTRS_TYPE_STRING,
522                         MM_ATTRS_FLAG_RW,
523                         (void *) NULL,
524                         MM_ATTRS_VALID_TYPE_NONE,
525                         0,
526                         0
527                 },
528                 {
529                         "tag_title",
530                         MM_ATTRS_TYPE_STRING,
531                         MM_ATTRS_FLAG_RW,
532                         (void *) NULL,
533                         MM_ATTRS_VALID_TYPE_NONE,
534                         0,
535                         0
536                 },
537                 {
538                         "tag_album",
539                         MM_ATTRS_TYPE_STRING,
540                         MM_ATTRS_FLAG_RW,
541                         (void *) NULL
542                 },
543                 {
544                         "tag_genre",
545                         MM_ATTRS_TYPE_STRING,
546                         MM_ATTRS_FLAG_RW,
547                         (void *) NULL,
548                         MM_ATTRS_VALID_TYPE_NONE,
549                         0,
550                         0
551                 },
552                 {
553                         "tag_author",
554                         MM_ATTRS_TYPE_STRING,
555                         MM_ATTRS_FLAG_RW,
556                         (void *) NULL,
557                         MM_ATTRS_VALID_TYPE_NONE,
558                         0,
559                         0
560                 },
561                 {
562                         "tag_copyright",
563                         MM_ATTRS_TYPE_STRING,
564                         MM_ATTRS_FLAG_RW,
565                         (void *) NULL,
566                         MM_ATTRS_VALID_TYPE_NONE,
567                         0,
568                         0
569                 },
570                 {
571                         "tag_date",
572                         MM_ATTRS_TYPE_STRING,
573                         MM_ATTRS_FLAG_RW,
574                         (void *) NULL,
575                         MM_ATTRS_VALID_TYPE_NONE,
576                         0,
577                         0
578                 },
579                 {
580                         "tag_description",
581                         MM_ATTRS_TYPE_STRING,
582                         MM_ATTRS_FLAG_RW,
583                         (void *) NULL,
584                         MM_ATTRS_VALID_TYPE_NONE,
585                         0,
586                         0
587                 },
588                 {
589                         "tag_track_num",
590                         MM_ATTRS_TYPE_INT,
591                         MM_ATTRS_FLAG_RW,
592                         (void *) 0,
593                         MM_ATTRS_VALID_TYPE_INT_RANGE,
594                         0,
595                         MMPLAYER_MAX_INT
596                 },
597                 {
598                         "tag_album_cover",
599                         MM_ATTRS_TYPE_DATA,
600                         MM_ATTRS_FLAG_RW,
601                         (void *) NULL,
602                         MM_ATTRS_VALID_TYPE_NONE,
603                         0,
604                         0
605                 },
606                 {
607                         "display_src_crop_x",
608                         MM_ATTRS_TYPE_INT,
609                         MM_ATTRS_FLAG_RW,
610                         (void *) 0,
611                         MM_ATTRS_VALID_TYPE_INT_RANGE,
612                         0,
613                         MMPLAYER_MAX_INT
614                 },
615                 {
616                         "display_src_crop_y",
617                         MM_ATTRS_TYPE_INT,
618                         MM_ATTRS_FLAG_RW,
619                         (void *) 0,
620                         MM_ATTRS_VALID_TYPE_INT_RANGE,
621                         0,
622                         MMPLAYER_MAX_INT
623                 },
624                 {
625                         "display_src_crop_width",
626                         MM_ATTRS_TYPE_INT,
627                         MM_ATTRS_FLAG_RW,
628                         (void *) 0,
629                         MM_ATTRS_VALID_TYPE_INT_RANGE,
630                         0,
631                         MMPLAYER_MAX_INT
632                 },
633                 {
634                         "display_src_crop_height",
635                         MM_ATTRS_TYPE_INT,
636                         MM_ATTRS_FLAG_RW,
637                         (void *) 0,
638                         MM_ATTRS_VALID_TYPE_INT_RANGE,
639                         0,
640                         MMPLAYER_MAX_INT
641                 },
642                 {
643                         "display_roi_x",
644                         MM_ATTRS_TYPE_INT,
645                         MM_ATTRS_FLAG_RW,
646                         (void *) 0,
647                         MM_ATTRS_VALID_TYPE_INT_RANGE,
648                         0,
649                         MMPLAYER_MAX_INT
650                 },
651                 {
652                         "display_roi_y",
653                         MM_ATTRS_TYPE_INT,
654                         MM_ATTRS_FLAG_RW,
655                         (void *) 0,
656                         MM_ATTRS_VALID_TYPE_INT_RANGE,
657                         0,
658                         MMPLAYER_MAX_INT
659                 },
660                 {
661                         "display_roi_width",
662                         MM_ATTRS_TYPE_INT,
663                         MM_ATTRS_FLAG_RW,
664                         (void *) 480,
665                         MM_ATTRS_VALID_TYPE_INT_RANGE,
666                         0,
667                         MMPLAYER_MAX_INT
668                 },
669                 {
670                         "display_roi_height",
671                         MM_ATTRS_TYPE_INT,
672                         MM_ATTRS_FLAG_RW,
673                         (void *) 800,
674                         MM_ATTRS_VALID_TYPE_INT_RANGE,
675                         0,
676                         MMPLAYER_MAX_INT
677                 },
678                 {
679                         "display_roi_mode",
680                         MM_ATTRS_TYPE_INT,
681                         MM_ATTRS_FLAG_RW,
682                         (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
683                         MM_ATTRS_VALID_TYPE_INT_RANGE,
684                         MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
685                         MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
686                 },
687                 {
688                         "display_rotation",
689                         MM_ATTRS_TYPE_INT,
690                         MM_ATTRS_FLAG_RW,
691                         (void *) MM_DISPLAY_ROTATION_NONE,
692                         MM_ATTRS_VALID_TYPE_INT_RANGE,
693                         MM_DISPLAY_ROTATION_NONE,
694                         MM_DISPLAY_ROTATION_270
695                 },
696                 {
697                         "display_visible",
698                         MM_ATTRS_TYPE_INT,
699                         MM_ATTRS_FLAG_RW,
700                         (void *) FALSE,
701                         MM_ATTRS_VALID_TYPE_INT_RANGE,
702                         0,
703                         1
704                 },
705                 {
706                         "display_method",
707                         MM_ATTRS_TYPE_INT,
708                         MM_ATTRS_FLAG_RW,
709                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
710                         MM_ATTRS_VALID_TYPE_INT_RANGE,
711                         MM_DISPLAY_METHOD_LETTER_BOX,
712                         MM_DISPLAY_METHOD_CUSTOM_ROI
713                 },
714                 {
715                         "display_overlay",
716                         MM_ATTRS_TYPE_DATA,
717                         MM_ATTRS_FLAG_RW,
718                         (void *) NULL,
719                         MM_ATTRS_VALID_TYPE_NONE,
720                         0,
721                         0
722                 },
723                 {
724                         "wl_display",
725                         MM_ATTRS_TYPE_DATA,
726                         MM_ATTRS_FLAG_RW,
727                         (void *) NULL,
728                         MM_ATTRS_VALID_TYPE_NONE,
729                         0,
730                         0
731                 },
732                 {
733                         "wl_window_render_x",
734                         MM_ATTRS_TYPE_INT,
735                         MM_ATTRS_FLAG_RW,
736                         (void *) 0,
737                         MM_ATTRS_VALID_TYPE_INT_RANGE,
738                         0,
739                         MMPLAYER_MAX_INT
740                 },
741                 {
742                         "wl_window_render_y",
743                         MM_ATTRS_TYPE_INT,
744                         MM_ATTRS_FLAG_RW,
745                         (void *) 0,
746                         MM_ATTRS_VALID_TYPE_INT_RANGE,
747                         0,
748                         MMPLAYER_MAX_INT
749                 },
750                 {
751                         "wl_window_render_width",
752                         MM_ATTRS_TYPE_INT,
753                         MM_ATTRS_FLAG_RW,
754                         (void *) 0,
755                         MM_ATTRS_VALID_TYPE_INT_RANGE,
756                         0,
757                         MMPLAYER_MAX_INT
758                 },
759                 {
760                         "wl_window_render_height",
761                         MM_ATTRS_TYPE_INT,
762                         MM_ATTRS_FLAG_RW,
763                         (void *) 0,
764                         MM_ATTRS_VALID_TYPE_INT_RANGE,
765                         0,
766                         MMPLAYER_MAX_INT
767                 },
768                 {
769                         "use_wl_surface",
770                         MM_ATTRS_TYPE_INT,
771                         MM_ATTRS_FLAG_RW,
772                         (void *) FALSE,
773                         MM_ATTRS_VALID_TYPE_INT_RANGE,
774                         FALSE,
775                         TRUE
776                 },
777                 {
778                         "display_overlay_user_data",
779                         MM_ATTRS_TYPE_DATA,
780                         MM_ATTRS_FLAG_RW,
781                         (void *) NULL,
782                         MM_ATTRS_VALID_TYPE_NONE,
783                         0,
784                         0
785                 },
786                 {
787                         "display_surface_type",
788                         MM_ATTRS_TYPE_INT,
789                         MM_ATTRS_FLAG_RW,
790                         (void *) MM_DISPLAY_SURFACE_NULL,
791                         MM_ATTRS_VALID_TYPE_INT_RANGE,
792                         MM_DISPLAY_SURFACE_OVERLAY,
793                         MM_DISPLAY_SURFACE_NUM - 1
794                 },
795                 {
796                         "display_evas_surface_sink",
797                         MM_ATTRS_TYPE_STRING,
798                         MM_ATTRS_FLAG_READABLE,
799                         (void *) player->ini.videosink_element_evas,
800                         MM_ATTRS_VALID_TYPE_NONE,
801                         0,
802                         0
803                 },
804                 {
805                         "display_force_aspect_ration",
806                         MM_ATTRS_TYPE_INT,
807                         MM_ATTRS_FLAG_RW,
808                         (void *) 1,
809                         MM_ATTRS_VALID_TYPE_INT_RANGE,
810                         0,
811                         MMPLAYER_MAX_INT
812                 },
813                 {
814                         "display_width",                // dest width of fimcconvert ouput
815                         MM_ATTRS_TYPE_INT,
816                         MM_ATTRS_FLAG_RW,
817                         (void *) 0,
818                         MM_ATTRS_VALID_TYPE_INT_RANGE,
819                         0,
820                         MMPLAYER_MAX_INT
821                 },
822                 {
823                         "display_height",               // dest height of fimcconvert ouput
824                         MM_ATTRS_TYPE_INT,
825                         MM_ATTRS_FLAG_RW,
826                         (void *) 0,
827                         MM_ATTRS_VALID_TYPE_INT_RANGE,
828                         0,
829                         MMPLAYER_MAX_INT
830                 },
831                 {
832                         "display_evas_do_scaling",
833                         MM_ATTRS_TYPE_INT,
834                         MM_ATTRS_FLAG_RW,
835                         (void *) TRUE,
836                         MM_ATTRS_VALID_TYPE_INT_RANGE,
837                         FALSE,
838                         TRUE
839                 },
840                 {
841                         "sound_fadeup",
842                         MM_ATTRS_TYPE_INT,
843                         MM_ATTRS_FLAG_RW,
844                         (void *) FALSE,
845                         MM_ATTRS_VALID_TYPE_INT_RANGE,
846                         FALSE,
847                         TRUE
848                 },
849                 {
850                         "sound_fadedown",
851                         MM_ATTRS_TYPE_INT,
852                         MM_ATTRS_FLAG_RW,
853                         (void *) FALSE,
854                         MM_ATTRS_VALID_TYPE_INT_RANGE,
855                         FALSE,
856                         TRUE
857                 },
858                 {
859                         "sound_volume_type",
860                         MM_ATTRS_TYPE_INT,
861                         MM_ATTRS_FLAG_RW,
862                         (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
863                         MM_ATTRS_VALID_TYPE_INT_RANGE,
864                         0,
865                         MMPLAYER_MAX_INT
866                 },
867                 {
868                         "sound_stream_type",
869                         MM_ATTRS_TYPE_STRING,
870                         MM_ATTRS_FLAG_RW,
871                         (void *) NULL,
872                         MM_ATTRS_VALID_TYPE_NONE,
873                         0,
874                         0
875                 },
876                 {
877                         "sound_stream_index",
878                         MM_ATTRS_TYPE_INT,
879                         MM_ATTRS_FLAG_RW,
880                         0,
881                         MM_ATTRS_VALID_TYPE_INT_RANGE,
882                         -1,
883                         MMPLAYER_MAX_INT
884                 },
885                 {
886                         "sound_route",
887                         MM_ATTRS_TYPE_INT,
888                         MM_ATTRS_FLAG_RW,
889                         (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
890                         MM_ATTRS_VALID_TYPE_INT_RANGE,
891                         MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
892                         MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
893                 },
894                 {
895                         "sound_stop_when_unplugged",
896                         MM_ATTRS_TYPE_INT,
897                         MM_ATTRS_FLAG_RW,
898                         (void *) TRUE,
899                         MM_ATTRS_VALID_TYPE_INT_RANGE,
900                         FALSE,
901                         TRUE
902                 },
903                 {
904                         "sound_application_pid",
905                         MM_ATTRS_TYPE_INT,
906                         MM_ATTRS_FLAG_RW,
907                         (void *) 0,
908                         MM_ATTRS_VALID_TYPE_INT_RANGE,
909                         0,
910                         MMPLAYER_MAX_INT
911                 },
912                 {
913                         "sound_spk_out_only",
914                         MM_ATTRS_TYPE_INT,
915                         MM_ATTRS_FLAG_RW,
916                         (void *) FALSE,
917                         MM_ATTRS_VALID_TYPE_INT_RANGE,
918                         FALSE,
919                         TRUE
920                 },
921                 {
922                         "sound_priority",
923                         MM_ATTRS_TYPE_INT,
924                         MM_ATTRS_FLAG_RW,
925                         (void *) 0,                     // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
926                         MM_ATTRS_VALID_TYPE_INT_RANGE,
927                         0,
928                         3
929                 },
930                 {
931                         "sound_close_resource",
932                         MM_ATTRS_TYPE_INT,
933                         MM_ATTRS_FLAG_RW,
934                         (void *) 0,
935                         MM_ATTRS_VALID_TYPE_INT_RANGE,
936                         0,
937                         1
938                 },
939                 {
940                         "sound_latency_mode",
941                         MM_ATTRS_TYPE_INT,
942                         MM_ATTRS_FLAG_RW,
943                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
944                         MM_ATTRS_VALID_TYPE_INT_RANGE,
945                         0,
946                         2
947                 },
948                 {
949                         "pcm_extraction",               // enable pcm extraction
950                         MM_ATTRS_TYPE_INT,
951                         MM_ATTRS_FLAG_RW,
952                         (void *) FALSE,
953                         MM_ATTRS_VALID_TYPE_INT_RANGE,
954                         FALSE,
955                         TRUE
956                 },
957                 {
958                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
959                         MM_ATTRS_TYPE_INT,
960                         MM_ATTRS_FLAG_RW,
961                         (void *) 44100,                         // hz
962                         MM_ATTRS_VALID_TYPE_INT_RANGE,
963                         0,
964                         MMPLAYER_MAX_INT
965                 },
966                 {
967                         "pcm_extraction_depth", // set depth for pcm extraction
968                         MM_ATTRS_TYPE_INT,
969                         MM_ATTRS_FLAG_RW,
970                         (void *) 16,                    // bits
971                         MM_ATTRS_VALID_TYPE_INT_RANGE,
972                         0,
973                         MMPLAYER_MAX_INT
974                 },
975                 {
976                         "pcm_extraction_channels",      // set channels for pcm extraction
977                         MM_ATTRS_TYPE_INT,
978                         MM_ATTRS_FLAG_RW,
979                         (void *) 1,
980                         MM_ATTRS_VALID_TYPE_INT_RANGE,
981                         0,
982                         MMPLAYER_MAX_INT
983                 },
984                 {
985                         "pcm_extraction_start_msec",    // set start position to extract pcm
986                         MM_ATTRS_TYPE_INT,
987                         MM_ATTRS_FLAG_RW,
988                         (void *) 0,
989                         MM_ATTRS_VALID_TYPE_INT_RANGE,
990                         0,
991                         MMPLAYER_MAX_INT
992                 },
993                 {
994                         "pcm_extraction_end_msec",      // set end position to extract pcm
995                         MM_ATTRS_TYPE_INT,
996                         MM_ATTRS_FLAG_RW,
997                         (void *) 0,
998                         MM_ATTRS_VALID_TYPE_INT_RANGE,
999                         0,
1000                         MMPLAYER_MAX_INT
1001                 },
1002                 {
1003                         "profile_smooth_repeat",
1004                         MM_ATTRS_TYPE_INT,
1005                         MM_ATTRS_FLAG_RW,
1006                         (void *) FALSE,
1007                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1008                         0,
1009                         MMPLAYER_MAX_INT
1010                 },
1011                 {
1012                         "profile_progress_interval",    // will be deprecated
1013                         MM_ATTRS_TYPE_INT,
1014                         MM_ATTRS_FLAG_RW,
1015                         (void *) 500,
1016                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1017                         0,
1018                         MMPLAYER_MAX_INT
1019                 },
1020                 {
1021                         "display_x",
1022                         MM_ATTRS_TYPE_INT,
1023                         MM_ATTRS_FLAG_RW,
1024                         (void *) 0,
1025                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1026                         0,
1027                         MMPLAYER_MAX_INT
1028                 },
1029                 {
1030                         "display_y",
1031                         MM_ATTRS_TYPE_INT,
1032                         MM_ATTRS_FLAG_RW,
1033                         (void *) 0,
1034                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1035                         0,
1036                         MMPLAYER_MAX_INT
1037                 },
1038                 {
1039                         "pd_mode",
1040                         MM_ATTRS_TYPE_INT,
1041                         MM_ATTRS_FLAG_RW,
1042                         (void *) MM_PLAYER_PD_MODE_NONE,
1043                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1044                         MM_PLAYER_PD_MODE_NONE,
1045                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
1046                 },
1047                 {
1048                         "pd_location",                  // location of the file to write
1049                         MM_ATTRS_TYPE_STRING,
1050                         MM_ATTRS_FLAG_RW,
1051                         (void *) NULL,
1052                         MM_ATTRS_VALID_TYPE_NONE,
1053                         0,
1054                         0
1055                 },
1056                 {
1057                         "accurate_seek",
1058                         MM_ATTRS_TYPE_INT,
1059                         MM_ATTRS_FLAG_RW,
1060                         (void *) 0,
1061                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1062                         0,
1063                         1
1064                 },
1065                 {
1066                         "content_video_orientation",    // orientation of video content
1067                         MM_ATTRS_TYPE_STRING,
1068                         MM_ATTRS_FLAG_RW,
1069                         (void *) NULL,
1070                         MM_ATTRS_VALID_TYPE_NONE,
1071                         0,
1072                         0
1073                 },
1074                 {
1075                         "pcm_audioformat",
1076                         MM_ATTRS_TYPE_STRING,
1077                         MM_ATTRS_FLAG_RW,
1078                         (void *) NULL,
1079                         MM_ATTRS_VALID_TYPE_NONE,
1080                         0,
1081                         0
1082                 },
1083                 {
1084                         "drc_mode",
1085                         MM_ATTRS_TYPE_INT,
1086                         MM_ATTRS_FLAG_RW,
1087                         (void *) FALSE,
1088                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1089                         FALSE,
1090                         TRUE
1091                 },
1092                 {
1093                         "gapless_mode",
1094                         MM_ATTRS_TYPE_INT,
1095                         MM_ATTRS_FLAG_RW,
1096                         (void *) FALSE,
1097                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1098                         FALSE,
1099                         TRUE
1100                 }
1101         };
1102
1103         num_of_attrs = ARRAY_SIZE(player_attrs);
1104
1105         base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1106
1107         if (!base) {
1108                 LOGE("failed to alloc attrs constructor");
1109                 return 0;
1110         }
1111
1112         /* initialize values of attributes */
1113         for (idx = 0; idx < num_of_attrs; idx++) {
1114                 base[idx].name = player_attrs[idx].name;
1115                 base[idx].value_type = player_attrs[idx].value_type;
1116                 base[idx].flags = player_attrs[idx].flags;
1117                 base[idx].default_value = player_attrs[idx].default_value;
1118         }
1119
1120         attrs = mmf_attrs_new_from_data(
1121                                         "mmplayer_attrs",
1122                                         base,
1123                                         num_of_attrs,
1124                                         NULL,
1125                                         NULL);
1126
1127         /* clean */
1128         MMPLAYER_FREEIF(base);
1129
1130         if (!attrs) {
1131                 LOGE("failed to create player attrs");
1132                 return 0;
1133         }
1134
1135         /* set validity type and range */
1136         for (idx = 0; idx < num_of_attrs; idx++) {
1137                 switch (player_attrs[idx].valid_type) {
1138                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1139                 {
1140                         mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1141                         mmf_attrs_set_valid_range(attrs, idx,
1142                                         player_attrs[idx].value_min,
1143                                         player_attrs[idx].value_max,
1144                                         (int)(intptr_t)(player_attrs[idx].default_value));
1145                 }
1146                         break;
1147
1148                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1149                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1150                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1151                 default:
1152                         break;
1153                 }
1154         }
1155
1156         /* commit */
1157         mmf_attrs_commit(attrs);
1158
1159         return attrs;
1160 }
1161
1162 bool
1163 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1164 {
1165         mm_player_t *player = MM_PLAYER_CAST(handle);
1166
1167         MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
1168
1169         if (player->attrs) {
1170                 mmf_attrs_free(player->attrs);
1171                 player->attrs = 0;
1172         }
1173
1174         return TRUE;
1175 }