Merge "es_playback: add buffer status signal connection in push mode" into tizen
[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 <vconf.h>
29 #include <mm_attrs_private.h>
30 #include <mm_attrs.h>
31 #include <gst/video/videooverlay.h>
32 #include "mm_player_utils.h"
33 #include "mm_player_priv.h"
34 #include "mm_player_attrs.h"
35
36 /*===========================================================================================
37 |                                                                                                                                                                                       |
38 |  LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                        |
39 |                                                                                                                                                                                       |
40 ========================================================================================== */
41
42 /*---------------------------------------------------------------------------
43 |    LOCAL FUNCTION PROTOTYPES:                                                                                         |
44 ---------------------------------------------------------------------------*/
45 int
46 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
47
48 /*===========================================================================================
49 |                                                                                                                                                                                                               |
50 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
51 |                                                                                                                                                                                                               |
52 ========================================================================================== */
53
54 int
55 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
56 {
57         int result = MM_ERROR_NONE;
58         MMHandleType attrs = 0;
59
60         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
61         /* if it's not want to know it. */
62         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
63         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
64
65         attrs = MM_PLAYER_GET_ATTRS(handle);
66
67         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
68
69         if ( result != MM_ERROR_NONE)
70                 debug_error("failed to get %s attribute\n", attribute_name);
71
72         return result;
73 }
74
75 int
76 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
77 {
78         int result = MM_ERROR_NONE;
79         MMHandleType attrs = 0;
80
81         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
82         /* if it's not want to know it. */
83         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
84         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
85
86         attrs = MM_PLAYER_GET_ATTRS(handle);
87
88         /* set attributes and commit them */
89         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
90
91         if (result != MM_ERROR_NONE)
92         {
93                 debug_error("failed to set %s attribute\n", attribute_name);
94                 return result;
95         }
96
97         result = __mmplayer_apply_attribute(handle, attribute_name);
98         if (result != MM_ERROR_NONE)
99         {
100                 debug_error("failed to apply attributes\n");
101                 return result;
102         }
103
104         return result;
105 }
106
107 int
108 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
109 {
110         int result = MM_ERROR_NONE;
111         MMHandleType attrs = 0;
112         MMAttrsInfo src_info = {0, };
113
114         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
115         return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
116         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
117
118         attrs = MM_PLAYER_GET_ATTRS(handle);
119
120         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
121
122         if ( result != MM_ERROR_NONE)
123         {
124                 debug_error("failed to get attribute info\n");
125                 return result;
126         }
127
128         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
129
130         dst_info->type = src_info.type;
131         dst_info->flag = src_info.flag;
132         dst_info->validity_type= src_info.validity_type;
133
134         switch(src_info.validity_type)
135         {
136                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
137                         dst_info->int_array.array = src_info.int_array.array;
138                         dst_info->int_array.count = src_info.int_array.count;
139                         dst_info->int_array.d_val = src_info.int_array.dval;
140                 break;
141
142                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
143                         dst_info->int_range.min = src_info.int_range.min;
144                         dst_info->int_range.max = src_info.int_range.max;
145                         dst_info->int_range.d_val = src_info.int_range.dval;
146                 break;
147
148                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
149                         dst_info->double_array.array = src_info.double_array.array;
150                         dst_info->double_array.count = src_info.double_array.count;
151                         dst_info->double_array.d_val = src_info.double_array.dval;
152                 break;
153
154                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
155                         dst_info->double_range.min = src_info.double_range.min;
156                         dst_info->double_range.max = src_info.double_range.max;
157                         dst_info->double_range.d_val = src_info.double_range.dval;
158                 break;
159
160                 default:
161                 break;
162         }
163
164         return result;
165 }
166
167 int
168 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
169 {
170         mm_player_t* player = 0;
171
172         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
173         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
174
175         player = MM_PLAYER_CAST(handle);
176
177         if ( g_strrstr(attribute_name, "display") )
178         {
179                 /* check videosink element is created */
180                 if ( !player->pipeline ||
181                         !player->pipeline->videobin ||
182                         !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
183                 {
184                         /*
185                          * The attribute should be committed even though videobin is not created yet.
186                          * So, true should be returned here.
187                          * Otherwise, video can be diaplayed abnormal.
188                          */
189                         return MM_ERROR_NONE;
190                 }
191
192                 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
193                 {
194                         debug_error("failed to update video param");
195                         return MM_ERROR_PLAYER_INTERNAL;
196                 }
197         }
198
199         return MM_ERROR_NONE;
200 }
201
202 MMHandleType
203 _mmplayer_construct_attribute(MMHandleType handle)
204 {
205         mm_player_t *player = NULL;
206         int idx = 0;
207         MMHandleType attrs = 0;
208         int num_of_attrs = 0;
209         mmf_attrs_construct_info_t *base = NULL;
210         //gchar *system_ua = NULL;
211         gchar *system_proxy = NULL;
212
213         return_val_if_fail (handle, 0);
214
215         player = MM_PLAYER_CAST(handle);
216
217         MMPlayerAttrsSpec player_attrs[] =
218         {
219                 {
220                         "profile_uri",                                  // name
221                         MM_ATTRS_TYPE_STRING,           // type
222                         MM_ATTRS_FLAG_RW,                       // flag
223                         (void *) NULL,                          // default value
224                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
225                         0,                                                      // validity min value
226                         0                                                       // validity max value
227                 },
228                 {
229                         "profile_user_param",
230                         MM_ATTRS_TYPE_DATA,
231                         MM_ATTRS_FLAG_RW,
232                         (void *) NULL,
233                         MM_ATTRS_VALID_TYPE_NONE,
234                         0,
235                         0
236                 },
237                 {
238                         "profile_play_count",
239                         MM_ATTRS_TYPE_INT,
240                         MM_ATTRS_FLAG_RW,
241                         (void *) 1,                     // -1 : repeat continually
242                         MM_ATTRS_VALID_TYPE_INT_RANGE,
243                         -1,
244                         MMPLAYER_MAX_INT
245                 },
246                 {
247                         "profile_prepare_async",
248                         MM_ATTRS_TYPE_INT,
249                         MM_ATTRS_FLAG_RW,
250                         (void *) 0,
251                         MM_ATTRS_VALID_TYPE_INT_RANGE,
252                         0,
253                         1
254                 },
255                 {       /* update registry for downloadable codec */
256                         "profile_update_registry",
257                         MM_ATTRS_TYPE_INT,
258                         MM_ATTRS_FLAG_RW,
259                         (void *) 0,
260                         MM_ATTRS_VALID_TYPE_INT_RANGE,
261                         0,
262                         1
263                 },
264                 {
265                         "streaming_type",
266                         MM_ATTRS_TYPE_INT,
267                         MM_ATTRS_FLAG_RW,
268                         (void *) STREAMING_SERVICE_NONE,
269                         MM_ATTRS_VALID_TYPE_INT_RANGE,
270                         STREAMING_SERVICE_VOD,
271                         STREAMING_SERVICE_NUM
272                 },
273                 {
274                         "streaming_udp_timeout",
275                         MM_ATTRS_TYPE_INT,
276                         MM_ATTRS_FLAG_RW,
277                         (void *) 10000,
278                         MM_ATTRS_VALID_TYPE_INT_RANGE,
279                         0,
280                         MMPLAYER_MAX_INT
281                 },
282                 {
283                         "streaming_user_agent",
284                         MM_ATTRS_TYPE_STRING,
285                         MM_ATTRS_FLAG_RW,
286                         (void *) NULL,
287                         MM_ATTRS_VALID_TYPE_NONE,
288                         0,
289                         0
290                 },
291                 {
292                         "streaming_wap_profile",
293                         MM_ATTRS_TYPE_STRING,
294                         MM_ATTRS_FLAG_RW,
295                         (void *) NULL,
296                         MM_ATTRS_VALID_TYPE_NONE,
297                         0,
298                         0
299                 },
300                 {
301                         "streaming_network_bandwidth",
302                         MM_ATTRS_TYPE_INT,
303                         MM_ATTRS_FLAG_RW,
304                         (void *) 128000,
305                         MM_ATTRS_VALID_TYPE_INT_RANGE,
306                         0,
307                         MMPLAYER_MAX_INT
308                 },
309                 {
310                         "streaming_cookie",
311                         MM_ATTRS_TYPE_STRING,
312                         MM_ATTRS_FLAG_RW,
313                         (void *) NULL,
314                         MM_ATTRS_VALID_TYPE_NONE,
315                         0,
316                         0
317                 },
318                 {
319                         "streaming_proxy",
320                         MM_ATTRS_TYPE_STRING,
321                         MM_ATTRS_FLAG_RW,
322                         (void *) NULL,
323                         MM_ATTRS_VALID_TYPE_NONE,
324                         0,
325                         0
326                 },
327                 {
328                         "streaming_timeout",
329                         MM_ATTRS_TYPE_INT,
330                         MM_ATTRS_FLAG_RW,
331                         (void *) -1,    // DEFAULT_HTTP_TIMEOUT
332                         MM_ATTRS_VALID_TYPE_INT_RANGE,
333                         -1,
334                         MMPLAYER_MAX_INT
335                 },
336                 {
337                         "subtitle_uri",
338                         MM_ATTRS_TYPE_STRING,
339                         MM_ATTRS_FLAG_RW,
340                         (void *) NULL,
341                         MM_ATTRS_VALID_TYPE_NONE,
342                         0,
343                         0
344                 },
345                 {
346                         "content_duration",
347                         MM_ATTRS_TYPE_INT,
348                         MM_ATTRS_FLAG_RW,
349                         (void *) 0,
350                         MM_ATTRS_VALID_TYPE_INT_RANGE,
351                         0,
352                         MMPLAYER_MAX_INT
353                 },
354                 {
355                         "content_bitrate",
356                         MM_ATTRS_TYPE_INT,
357                         MM_ATTRS_FLAG_RW,
358                         (void *) 0,
359                         MM_ATTRS_VALID_TYPE_INT_RANGE,
360                         0,
361                         MMPLAYER_MAX_INT
362                 },
363                 {
364                         "content_max_bitrate",
365                         MM_ATTRS_TYPE_INT,
366                         MM_ATTRS_FLAG_RW,
367                         (void *) 0,
368                         MM_ATTRS_VALID_TYPE_INT_RANGE,
369                         0,
370                         MMPLAYER_MAX_INT
371                 },
372                 {
373                         "content_video_found",
374                         MM_ATTRS_TYPE_INT,
375                         MM_ATTRS_FLAG_RW,
376                         (void *) 0,
377                         MM_ATTRS_VALID_TYPE_INT_RANGE,
378                         0,
379                         1
380                 },
381                 {
382                         "content_video_codec",
383                         MM_ATTRS_TYPE_STRING,
384                         MM_ATTRS_FLAG_RW,
385                         (void *) NULL,
386                         MM_ATTRS_VALID_TYPE_NONE,
387                         0,
388                         0
389                 },
390                 {
391                         "content_video_bitrate",
392                         MM_ATTRS_TYPE_INT,
393                         MM_ATTRS_FLAG_RW,
394                         (void *) 0,
395                         MM_ATTRS_VALID_TYPE_INT_RANGE,
396                         0,
397                         MMPLAYER_MAX_INT
398                 },
399                 {
400                         "content_video_fps",
401                         MM_ATTRS_TYPE_INT,
402                         MM_ATTRS_FLAG_RW,
403                         (void *) 0,
404                         MM_ATTRS_VALID_TYPE_INT_RANGE,
405                         0,
406                         MMPLAYER_MAX_INT
407                 },
408                 {
409                         "content_video_width",
410                         MM_ATTRS_TYPE_INT,
411                         MM_ATTRS_FLAG_RW,
412                         (void *) 0,
413                         MM_ATTRS_VALID_TYPE_INT_RANGE,
414                         0,
415                         MMPLAYER_MAX_INT
416                 },
417                 {
418                         "content_video_height",
419                         MM_ATTRS_TYPE_INT,
420                         MM_ATTRS_FLAG_RW,
421                         (void *) 0,
422                         MM_ATTRS_VALID_TYPE_INT_RANGE,
423                         0,
424                         MMPLAYER_MAX_INT
425                 },
426                 {
427                         "content_video_track_num",
428                         MM_ATTRS_TYPE_INT,
429                         MM_ATTRS_FLAG_RW,
430                         (void *) 0,
431                         MM_ATTRS_VALID_TYPE_INT_RANGE,
432                         0,
433                         MMPLAYER_MAX_INT
434                 },
435                 {
436                         "content_audio_found",
437                         MM_ATTRS_TYPE_INT,
438                         MM_ATTRS_FLAG_RW,
439                         (void *) 0,
440                         MM_ATTRS_VALID_TYPE_INT_RANGE,
441                         0,
442                         1
443                 },
444                 {
445                         "content_audio_codec",
446                         MM_ATTRS_TYPE_STRING,
447                         MM_ATTRS_FLAG_RW,
448                         (void *) NULL,
449                         MM_ATTRS_VALID_TYPE_NONE,
450                         0,
451                         0
452                 },
453                 {
454                         "content_audio_bitrate",
455                         MM_ATTRS_TYPE_INT,
456                         MM_ATTRS_FLAG_RW,
457                         (void *) 0,
458                         MM_ATTRS_VALID_TYPE_INT_RANGE,
459                         0,
460                         MMPLAYER_MAX_INT
461                 },
462                 {
463                         "content_audio_channels",
464                         MM_ATTRS_TYPE_INT,
465                         MM_ATTRS_FLAG_RW,
466                         (void *) 0,
467                         MM_ATTRS_VALID_TYPE_INT_RANGE,
468                         0,
469                         MMPLAYER_MAX_INT
470                 },
471                 {
472                         "content_audio_samplerate",
473                         MM_ATTRS_TYPE_INT,
474                         MM_ATTRS_FLAG_RW,
475                         (void *) 0,
476                         MM_ATTRS_VALID_TYPE_INT_RANGE,
477                         0,
478                         MMPLAYER_MAX_INT
479                 },
480                 {
481                         "content_audio_track_num",
482                         MM_ATTRS_TYPE_INT,
483                         MM_ATTRS_FLAG_RW,
484                         (void *) 0,
485                         MM_ATTRS_VALID_TYPE_INT_RANGE,
486                         0,
487                         MMPLAYER_MAX_INT
488                 },
489                 {
490                         "content_audio_format",
491                         MM_ATTRS_TYPE_INT,
492                         MM_ATTRS_FLAG_RW,
493                         (void *) 0,
494                         MM_ATTRS_VALID_TYPE_INT_RANGE,
495                         0,
496                         MMPLAYER_MAX_INT
497                 },
498                 {
499                         "content_text_track_num",
500                         MM_ATTRS_TYPE_INT,
501                         MM_ATTRS_FLAG_RW,
502                         (void *) 0,
503                         MM_ATTRS_VALID_TYPE_INT_RANGE,
504                         0,
505                         MMPLAYER_MAX_INT
506                 },
507                 {
508                         "tag_artist",
509                         MM_ATTRS_TYPE_STRING,
510                         MM_ATTRS_FLAG_RW,
511                         (void *) NULL,
512                         MM_ATTRS_VALID_TYPE_NONE,
513                         0,
514                         0
515                 },
516                 {
517                         "tag_title",
518                         MM_ATTRS_TYPE_STRING,
519                         MM_ATTRS_FLAG_RW,
520                         (void *) NULL,
521                         MM_ATTRS_VALID_TYPE_NONE,
522                         0,
523                         0
524                 },
525                 {
526                         "tag_album",
527                         MM_ATTRS_TYPE_STRING,
528                         MM_ATTRS_FLAG_RW,
529                         (void *) NULL
530                 },
531                 {
532                         "tag_genre",
533                         MM_ATTRS_TYPE_STRING,
534                         MM_ATTRS_FLAG_RW,
535                         (void *) NULL,
536                         MM_ATTRS_VALID_TYPE_NONE,
537                         0,
538                         0
539                 },
540                 {
541                         "tag_author",
542                         MM_ATTRS_TYPE_STRING,
543                         MM_ATTRS_FLAG_RW,
544                         (void *) NULL,
545                         MM_ATTRS_VALID_TYPE_NONE,
546                         0,
547                         0
548                 },
549                 {
550                         "tag_copyright",
551                         MM_ATTRS_TYPE_STRING,
552                         MM_ATTRS_FLAG_RW,
553                         (void *) NULL,
554                         MM_ATTRS_VALID_TYPE_NONE,
555                         0,
556                         0
557                 },
558                 {
559                         "tag_date",
560                         MM_ATTRS_TYPE_STRING,
561                         MM_ATTRS_FLAG_RW,
562                         (void *) NULL,
563                         MM_ATTRS_VALID_TYPE_NONE,
564                         0,
565                         0
566                 },
567                 {
568                         "tag_description",
569                         MM_ATTRS_TYPE_STRING,
570                         MM_ATTRS_FLAG_RW,
571                         (void *) NULL,
572                         MM_ATTRS_VALID_TYPE_NONE,
573                         0,
574                         0
575                 },
576                 {
577                         "tag_track_num",
578                         MM_ATTRS_TYPE_INT,
579                         MM_ATTRS_FLAG_RW,
580                         (void *) 0,
581                         MM_ATTRS_VALID_TYPE_INT_RANGE,
582                         0,
583                         MMPLAYER_MAX_INT
584                 },
585                 {
586                         "tag_album_cover",
587                         MM_ATTRS_TYPE_DATA,
588                         MM_ATTRS_FLAG_RW,
589                         (void *) NULL,
590                         MM_ATTRS_VALID_TYPE_NONE,
591                         0,
592                         0
593                 },
594                 {
595                         "display_src_crop_x",
596                         MM_ATTRS_TYPE_INT,
597                         MM_ATTRS_FLAG_RW,
598                         (void *) 0,
599                         MM_ATTRS_VALID_TYPE_INT_RANGE,
600                         0,
601                         MMPLAYER_MAX_INT
602                 },
603                 {
604                         "display_src_crop_y",
605                         MM_ATTRS_TYPE_INT,
606                         MM_ATTRS_FLAG_RW,
607                         (void *) 0,
608                         MM_ATTRS_VALID_TYPE_INT_RANGE,
609                         0,
610                         MMPLAYER_MAX_INT
611                 },
612                 {
613                         "display_src_crop_width",
614                         MM_ATTRS_TYPE_INT,
615                         MM_ATTRS_FLAG_RW,
616                         (void *) 0,
617                         MM_ATTRS_VALID_TYPE_INT_RANGE,
618                         0,
619                         MMPLAYER_MAX_INT
620                 },
621                 {
622                         "display_src_crop_height",
623                         MM_ATTRS_TYPE_INT,
624                         MM_ATTRS_FLAG_RW,
625                         (void *) 0,
626                         MM_ATTRS_VALID_TYPE_INT_RANGE,
627                         0,
628                         MMPLAYER_MAX_INT
629                 },
630                 {
631                         "display_roi_x",
632                         MM_ATTRS_TYPE_INT,
633                         MM_ATTRS_FLAG_RW,
634                         (void *) 0,
635                         MM_ATTRS_VALID_TYPE_INT_RANGE,
636                         0,
637                         MMPLAYER_MAX_INT
638                 },
639                 {
640                         "display_roi_y",
641                         MM_ATTRS_TYPE_INT,
642                         MM_ATTRS_FLAG_RW,
643                         (void *) 0,
644                         MM_ATTRS_VALID_TYPE_INT_RANGE,
645                         0,
646                         MMPLAYER_MAX_INT
647                 },
648                 {
649                         "display_roi_width",
650                         MM_ATTRS_TYPE_INT,
651                         MM_ATTRS_FLAG_RW,
652                         (void *) 480,
653                         MM_ATTRS_VALID_TYPE_INT_RANGE,
654                         0,
655                         MMPLAYER_MAX_INT
656                 },
657                 {
658                         "display_roi_height",
659                         MM_ATTRS_TYPE_INT,
660                         MM_ATTRS_FLAG_RW,
661                         (void *) 800,
662                         MM_ATTRS_VALID_TYPE_INT_RANGE,
663                         0,
664                         MMPLAYER_MAX_INT
665                 },
666                 {
667                         "display_roi_mode",
668                         MM_ATTRS_TYPE_INT,
669                         MM_ATTRS_FLAG_RW,
670                         (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
671                         MM_ATTRS_VALID_TYPE_INT_RANGE,
672                         MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
673                         MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
674                 },
675                 {
676                         "display_rotation",
677                         MM_ATTRS_TYPE_INT,
678                         MM_ATTRS_FLAG_RW,
679                         (void *) MM_DISPLAY_ROTATION_NONE,
680                         MM_ATTRS_VALID_TYPE_INT_RANGE,
681                         MM_DISPLAY_ROTATION_NONE,
682                         MM_DISPLAY_ROTATION_270
683                 },
684                 {
685                         "display_visible",
686                         MM_ATTRS_TYPE_INT,
687                         MM_ATTRS_FLAG_RW,
688                         (void *) FALSE,
689                         MM_ATTRS_VALID_TYPE_INT_RANGE,
690                         0,
691                         1
692                 },
693                 {
694                         "display_method",
695                         MM_ATTRS_TYPE_INT,
696                         MM_ATTRS_FLAG_RW,
697                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
698                         MM_ATTRS_VALID_TYPE_INT_RANGE,
699                         MM_DISPLAY_METHOD_LETTER_BOX,
700                         MM_DISPLAY_METHOD_CUSTOM_ROI
701                 },
702                 {
703                         "display_overlay",
704                         MM_ATTRS_TYPE_DATA,
705                         MM_ATTRS_FLAG_RW,
706                         (void *) NULL,
707                         MM_ATTRS_VALID_TYPE_NONE,
708                         0,
709                         0
710                 },
711 #ifdef HAVE_WAYLAND
712                 {
713                         "wl_display",
714                         MM_ATTRS_TYPE_DATA,
715                         MM_ATTRS_FLAG_RW,
716                         (void *) NULL,
717                         MM_ATTRS_VALID_TYPE_NONE,
718                         0,
719                         0
720                 },
721                 {
722                         "wl_window_render_x",
723                         MM_ATTRS_TYPE_INT,
724                         MM_ATTRS_FLAG_RW,
725                         (void *) 0,
726                         MM_ATTRS_VALID_TYPE_INT_RANGE,
727                         0,
728                         MMPLAYER_MAX_INT
729                 },
730                 {
731                         "wl_window_render_y",
732                         MM_ATTRS_TYPE_INT,
733                         MM_ATTRS_FLAG_RW,
734                         (void *) 0,
735                         MM_ATTRS_VALID_TYPE_INT_RANGE,
736                         0,
737                         MMPLAYER_MAX_INT
738                 },
739                 {
740                         "wl_window_render_width",
741                         MM_ATTRS_TYPE_INT,
742                         MM_ATTRS_FLAG_RW,
743                         (void *) 0,
744                         MM_ATTRS_VALID_TYPE_INT_RANGE,
745                         0,
746                         MMPLAYER_MAX_INT
747                 },
748                 {
749                         "wl_window_render_height",
750                         MM_ATTRS_TYPE_INT,
751                         MM_ATTRS_FLAG_RW,
752                         (void *) 0,
753                         MM_ATTRS_VALID_TYPE_INT_RANGE,
754                         0,
755                         MMPLAYER_MAX_INT
756                 },
757 #endif
758                 {
759                         "display_overlay_user_data",
760                         MM_ATTRS_TYPE_DATA,
761                         MM_ATTRS_FLAG_RW,
762                         (void *) NULL,
763                         MM_ATTRS_VALID_TYPE_NONE,
764                         0,
765                         0
766                 },
767                 {
768                         "display_surface_type",
769                         MM_ATTRS_TYPE_INT,
770                         MM_ATTRS_FLAG_RW,
771                         (void *) MM_DISPLAY_SURFACE_NULL,
772                         MM_ATTRS_VALID_TYPE_INT_RANGE,
773                         MM_DISPLAY_SURFACE_X,
774                         MM_DISPLAY_SURFACE_NUM - 1
775                 },
776                 {
777                         "display_evas_surface_sink",
778                         MM_ATTRS_TYPE_STRING,
779                         MM_ATTRS_FLAG_READABLE,
780                         (void *) player->ini.videosink_element_evas,
781                         MM_ATTRS_VALID_TYPE_NONE,
782                         0,
783                         0
784                 },
785                 {
786                         "display_force_aspect_ration",
787                         MM_ATTRS_TYPE_INT,
788                         MM_ATTRS_FLAG_RW,
789                         (void *) 1,
790                         MM_ATTRS_VALID_TYPE_INT_RANGE,
791                         0,
792                         MMPLAYER_MAX_INT
793                 },
794                 {
795                         "display_width",                // dest width of fimcconvert ouput
796                         MM_ATTRS_TYPE_INT,
797                         MM_ATTRS_FLAG_RW,
798                         (void *) 0,
799                         MM_ATTRS_VALID_TYPE_INT_RANGE,
800                         0,
801                         MMPLAYER_MAX_INT
802                 },
803                 {
804                         "display_height",               // dest height of fimcconvert ouput
805                         MM_ATTRS_TYPE_INT,
806                         MM_ATTRS_FLAG_RW,
807                         (void *) 0,
808                         MM_ATTRS_VALID_TYPE_INT_RANGE,
809                         0,
810                         MMPLAYER_MAX_INT
811                 },
812                 {
813                         "display_evas_do_scaling",
814                         MM_ATTRS_TYPE_INT,
815                         MM_ATTRS_FLAG_RW,
816                         (void *) TRUE,
817                         MM_ATTRS_VALID_TYPE_INT_RANGE,
818                         FALSE,
819                         TRUE
820                 },
821                 {
822                         "sound_fadeup",
823                         MM_ATTRS_TYPE_INT,
824                         MM_ATTRS_FLAG_RW,
825                         (void *) FALSE,
826                         MM_ATTRS_VALID_TYPE_INT_RANGE,
827                         FALSE,
828                         TRUE
829                 },
830                 {
831                         "sound_fadedown",
832                         MM_ATTRS_TYPE_INT,
833                         MM_ATTRS_FLAG_RW,
834                         (void *) FALSE,
835                         MM_ATTRS_VALID_TYPE_INT_RANGE,
836                         FALSE,
837                         TRUE
838                 },
839                 {
840                         "sound_volume_type",
841                         MM_ATTRS_TYPE_INT,
842                         MM_ATTRS_FLAG_RW,
843                         (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
844                         MM_ATTRS_VALID_TYPE_INT_RANGE,
845                         0,
846                         MMPLAYER_MAX_INT
847                 },
848                 {
849                         "sound_stream_type",
850                         MM_ATTRS_TYPE_STRING,
851                         MM_ATTRS_FLAG_RW,
852                         (void *) NULL,
853                         MM_ATTRS_VALID_TYPE_NONE,
854                         0,
855                         0
856                 },
857                 {
858                         "sound_stream_index",
859                         MM_ATTRS_TYPE_INT,
860                         MM_ATTRS_FLAG_RW,
861                         0,
862                         MM_ATTRS_VALID_TYPE_INT_RANGE,
863                         0,
864                         MMPLAYER_MAX_INT
865                 },
866                 {
867                         "sound_route",
868                         MM_ATTRS_TYPE_INT,
869                         MM_ATTRS_FLAG_RW,
870                         (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
871                         MM_ATTRS_VALID_TYPE_INT_RANGE,
872                         MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
873                         MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
874                 },
875                 {
876                         "sound_stop_when_unplugged",
877                         MM_ATTRS_TYPE_INT,
878                         MM_ATTRS_FLAG_RW,
879                         (void *) TRUE,
880                         MM_ATTRS_VALID_TYPE_INT_RANGE,
881                         FALSE,
882                         TRUE
883                 },
884                 {
885                         "sound_application_pid",
886                         MM_ATTRS_TYPE_INT,
887                         MM_ATTRS_FLAG_RW,
888                         (void *) 0,
889                         MM_ATTRS_VALID_TYPE_INT_RANGE,
890                         0,
891                         MMPLAYER_MAX_INT
892                 },
893                 {
894                         "sound_spk_out_only",
895                         MM_ATTRS_TYPE_INT,
896                         MM_ATTRS_FLAG_RW,
897                         (void *) FALSE,
898                         MM_ATTRS_VALID_TYPE_INT_RANGE,
899                         FALSE,
900                         TRUE
901                 },
902                 {
903                         "sound_priority",
904                         MM_ATTRS_TYPE_INT,
905                         MM_ATTRS_FLAG_RW,
906                         (void *) 0,                     // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
907                         MM_ATTRS_VALID_TYPE_INT_RANGE,
908                         0,
909                         3
910                 },
911                 {
912                         "sound_close_resource",
913                         MM_ATTRS_TYPE_INT,
914                         MM_ATTRS_FLAG_RW,
915                         (void *) 0,
916                         MM_ATTRS_VALID_TYPE_INT_RANGE,
917                         0,
918                         1
919                 },
920                 {
921                         "sound_latency_mode",
922                         MM_ATTRS_TYPE_INT,
923                         MM_ATTRS_FLAG_RW,
924                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
925                         MM_ATTRS_VALID_TYPE_INT_RANGE,
926                         0,
927                         2
928                 },
929                 {
930                         "pcm_extraction",               // enable pcm extraction
931                         MM_ATTRS_TYPE_INT,
932                         MM_ATTRS_FLAG_RW,
933                         (void *) FALSE,
934                         MM_ATTRS_VALID_TYPE_INT_RANGE,
935                         FALSE,
936                         TRUE
937                 },
938                 {
939                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
940                         MM_ATTRS_TYPE_INT,
941                         MM_ATTRS_FLAG_RW,
942                         (void *) 44100,                         // hz
943                         MM_ATTRS_VALID_TYPE_INT_RANGE,
944                         0,
945                         MMPLAYER_MAX_INT
946                 },
947                 {
948                         "pcm_extraction_depth", // set depth for pcm extraction
949                         MM_ATTRS_TYPE_INT,
950                         MM_ATTRS_FLAG_RW,
951                         (void *) 16,                    // bits
952                         MM_ATTRS_VALID_TYPE_INT_RANGE,
953                         0,
954                         MMPLAYER_MAX_INT
955                 },
956                 {
957                         "pcm_extraction_channels",      // set channels for pcm extraction
958                         MM_ATTRS_TYPE_INT,
959                         MM_ATTRS_FLAG_RW,
960                         (void *) 1,
961                         MM_ATTRS_VALID_TYPE_INT_RANGE,
962                         0,
963                         MMPLAYER_MAX_INT
964                 },
965                 {
966                         "pcm_extraction_start_msec",    // set start position to extract pcm
967                         MM_ATTRS_TYPE_INT,
968                         MM_ATTRS_FLAG_RW,
969                         (void *) 0,
970                         MM_ATTRS_VALID_TYPE_INT_RANGE,
971                         0,
972                         MMPLAYER_MAX_INT
973                 },
974                 {
975                         "pcm_extraction_end_msec",      // set end position to extract pcm
976                         MM_ATTRS_TYPE_INT,
977                         MM_ATTRS_FLAG_RW,
978                         (void *) 0,
979                         MM_ATTRS_VALID_TYPE_INT_RANGE,
980                         0,
981                         MMPLAYER_MAX_INT
982                 },
983                 {
984                         "profile_smooth_repeat",
985                         MM_ATTRS_TYPE_INT,
986                         MM_ATTRS_FLAG_RW,
987                         (void *) FALSE,
988                         MM_ATTRS_VALID_TYPE_INT_RANGE,
989                         0,
990                         MMPLAYER_MAX_INT
991                 },
992                 {
993                         "profile_progress_interval",    // will be deprecated
994                         MM_ATTRS_TYPE_INT,
995                         MM_ATTRS_FLAG_RW,
996                         (void *) 500,
997                         MM_ATTRS_VALID_TYPE_INT_RANGE,
998                         0,
999                         MMPLAYER_MAX_INT
1000                 },
1001                 {
1002                         "display_x",
1003                         MM_ATTRS_TYPE_INT,
1004                         MM_ATTRS_FLAG_RW,
1005                         (void *) 0,
1006                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1007                         0,
1008                         MMPLAYER_MAX_INT
1009                 },
1010                 {
1011                         "display_y",
1012                         MM_ATTRS_TYPE_INT,
1013                         MM_ATTRS_FLAG_RW,
1014                         (void *) 0,
1015                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1016                         0,
1017                         MMPLAYER_MAX_INT
1018                 },
1019                 {
1020                         "pd_mode",
1021                         MM_ATTRS_TYPE_INT,
1022                         MM_ATTRS_FLAG_RW,
1023                         (void *) MM_PLAYER_PD_MODE_NONE,
1024                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1025                         MM_PLAYER_PD_MODE_NONE,
1026                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
1027                 },
1028                 {
1029                         "pd_location",                  // location of the file to write
1030                         MM_ATTRS_TYPE_STRING,
1031                         MM_ATTRS_FLAG_RW,
1032                         (void *) NULL,
1033                         MM_ATTRS_VALID_TYPE_NONE,
1034                         0,
1035                         0
1036                 },
1037                 {
1038                         "accurate_seek",
1039                         MM_ATTRS_TYPE_INT,
1040                         MM_ATTRS_FLAG_RW,
1041                         (void *) 0,
1042                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1043                         0,
1044                         1
1045                 },
1046                 {
1047                         "content_video_orientation",    // orientation of video content
1048                         MM_ATTRS_TYPE_STRING,
1049                         MM_ATTRS_FLAG_RW,
1050                         (void *) NULL,
1051                         MM_ATTRS_VALID_TYPE_NONE,
1052                         0,
1053                         0
1054                 },
1055                 {
1056                         "pcm_audioformat",
1057                         MM_ATTRS_TYPE_STRING,
1058                         MM_ATTRS_FLAG_RW,
1059                         (void *) NULL,
1060                         MM_ATTRS_VALID_TYPE_NONE,
1061                         0,
1062                         0
1063                 },
1064                 {
1065                         "shm_stream_path",
1066                         MM_ATTRS_TYPE_STRING,
1067                         MM_ATTRS_FLAG_RW,
1068                         (void *) NULL,
1069                         MM_ATTRS_VALID_TYPE_NONE,
1070                         0,
1071                         0
1072                 },
1073                 {
1074                         "display_surface_client_type",
1075                         MM_ATTRS_TYPE_INT,
1076                         MM_ATTRS_FLAG_RW,
1077                         (void *) MM_DISPLAY_SURFACE_NULL,
1078                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1079                         MM_DISPLAY_SURFACE_X,
1080                         MM_DISPLAY_SURFACE_NUM - 1
1081                 }
1082         };
1083
1084         num_of_attrs = ARRAY_SIZE(player_attrs);
1085
1086         base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1087
1088         if ( !base )
1089         {
1090                 debug_error("failed to alloc attrs constructor");
1091                 return 0;
1092         }
1093
1094         /* initialize values of attributes */
1095         for ( idx = 0; idx < num_of_attrs; idx++ )
1096         {
1097                 base[idx].name = player_attrs[idx].name;
1098                 base[idx].value_type = player_attrs[idx].value_type;
1099                 base[idx].flags = player_attrs[idx].flags;
1100                 base[idx].default_value = player_attrs[idx].default_value;
1101         }
1102
1103         attrs = mmf_attrs_new_from_data(
1104                                         "mmplayer_attrs",
1105                                         base,
1106                                         num_of_attrs,
1107                                         NULL,
1108                                         NULL);
1109
1110         /* clean */
1111         MMPLAYER_FREEIF(base);
1112
1113         if ( !attrs )
1114         {
1115                 debug_error("failed to create player attrs");
1116                 return 0;
1117         }
1118
1119         /* set validity type and range */
1120         for ( idx = 0; idx < num_of_attrs; idx++ )
1121         {
1122                 switch ( player_attrs[idx].valid_type)
1123                 {
1124                         case MM_ATTRS_VALID_TYPE_INT_RANGE:
1125                         {
1126                                 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1127                                 mmf_attrs_set_valid_range (attrs, idx,
1128                                                 player_attrs[idx].value_min,
1129                                                 player_attrs[idx].value_max,
1130                                                 (int)(intptr_t)(player_attrs[idx].default_value));
1131                         }
1132                         break;
1133
1134                         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1135                         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1136                         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1137                         default:
1138                         break;
1139                 }
1140         }
1141
1142         #if 0
1143         /* set proxy and user agent */
1144         system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1145         system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1146
1147         if (system_ua)
1148         {
1149                         mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1150                         g_free(system_ua);
1151         }
1152         #endif
1153
1154         if (system_proxy)
1155         {
1156                         mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1157                         g_free(system_proxy);
1158         }
1159
1160         /* commit */
1161         mmf_attrs_commit(attrs);
1162
1163         return attrs;
1164 }
1165
1166 bool
1167 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1168 {
1169         mm_player_t *player = MM_PLAYER_CAST(handle);
1170
1171         return_val_if_fail ( player, FALSE );
1172
1173         if (player->attrs)
1174         {
1175                 mmf_attrs_free (player->attrs);
1176                 player->attrs = 0;
1177         }
1178
1179         return TRUE;
1180 }