Set audioformat of pcm extraction
[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 typedef struct{
43         char *name;
44         int value_type;
45         int flags;                              // r, w
46         void *default_value;
47         int valid_type;                 // validity type
48         int value_min;                  //<- set validity value range
49         int value_max;          //->
50 }MMPlayerAttrsSpec;
51
52 /*---------------------------------------------------------------------------
53 |    LOCAL FUNCTION PROTOTYPES:                                                                                         |
54 ---------------------------------------------------------------------------*/
55 int
56 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
57
58 /*===========================================================================================
59 |                                                                                                                                                                                                               |
60 |  FUNCTION DEFINITIONS                                                                                                                                                                 |
61 |                                                                                                                                                                                                               |
62 ========================================================================================== */
63
64 int
65 _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
66 {
67         int result = MM_ERROR_NONE;
68         MMHandleType attrs = 0;
69
70         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
71         /* if it's not want to know it. */
72         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
73         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
74
75         attrs = MM_PLAYER_GET_ATTRS(handle);
76
77         result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
78
79         if ( result != MM_ERROR_NONE)
80                 debug_error("failed to get %s attribute\n", attribute_name);
81
82         return result;
83 }
84
85 int
86 _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list args_list)
87 {
88         int result = MM_ERROR_NONE;
89         MMHandleType attrs = 0;
90
91         /* NOTE : Don't need to check err_attr_name because it can be set NULL */
92         /* if it's not want to know it. */
93         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
94         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
95
96         attrs = MM_PLAYER_GET_ATTRS(handle);
97
98         /* set attributes and commit them */
99         result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
100
101         if (result != MM_ERROR_NONE)
102         {
103                 debug_error("failed to set %s attribute\n", attribute_name);
104                 return result;
105         }
106
107         result = __mmplayer_apply_attribute(handle, attribute_name);
108         if (result != MM_ERROR_NONE)
109         {
110                 debug_error("failed to apply attributes\n");
111                 return result;
112         }
113
114         return result;
115 }
116
117 int
118 _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name, MMPlayerAttrsInfo *dst_info)
119 {
120         int result = MM_ERROR_NONE;
121         MMHandleType attrs = 0;
122         MMAttrsInfo src_info = {0, };
123
124         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
125         return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
126         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
127
128         attrs = MM_PLAYER_GET_ATTRS(handle);
129
130         result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
131
132         if ( result != MM_ERROR_NONE)
133         {
134                 debug_error("failed to get attribute info\n");
135                 return result;
136         }
137
138         memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
139
140         dst_info->type = src_info.type;
141         dst_info->flag = src_info.flag;
142         dst_info->validity_type= src_info.validity_type;
143
144         switch(src_info.validity_type)
145         {
146                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
147                         dst_info->int_array.array = src_info.int_array.array;
148                         dst_info->int_array.count = src_info.int_array.count;
149                         dst_info->int_array.d_val = src_info.int_array.dval;
150                 break;
151
152                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
153                         dst_info->int_range.min = src_info.int_range.min;
154                         dst_info->int_range.max = src_info.int_range.max;
155                         dst_info->int_range.d_val = src_info.int_range.dval;
156                 break;
157
158                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
159                         dst_info->double_array.array = src_info.double_array.array;
160                         dst_info->double_array.count = src_info.double_array.count;
161                         dst_info->double_array.d_val = src_info.double_array.dval;
162                 break;
163
164                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
165                         dst_info->double_range.min = src_info.double_range.min;
166                         dst_info->double_range.max = src_info.double_range.max;
167                         dst_info->double_range.d_val = src_info.double_range.dval;
168                 break;
169
170                 default:
171                 break;
172         }
173
174         return result;
175 }
176
177 int
178 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
179 {
180         mm_player_t* player = 0;
181
182         return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
183         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
184
185         player = MM_PLAYER_CAST(handle);
186
187         if ( g_strrstr(attribute_name, "display") )
188         {
189                 /* check videosink element is created */
190                 if ( !player->pipeline ||
191                         !player->pipeline->videobin ||
192                         !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
193                 {
194                         /*
195                          * The attribute should be committed even though videobin is not created yet.
196                          * So, true should be returned here.
197                          * Otherwise, video can be diaplayed abnormal.
198                          */
199                         return MM_ERROR_NONE;
200                 }
201
202                 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
203                 {
204                         debug_error("failed to update video param");
205                         return MM_ERROR_PLAYER_INTERNAL;
206                 }
207         }
208
209         return MM_ERROR_NONE;
210 }
211
212 MMHandleType
213 _mmplayer_construct_attribute(MMHandleType handle)
214 {
215         mm_player_t *player = NULL;
216         int idx = 0;
217         MMHandleType attrs = 0;
218         int num_of_attrs = 0;
219         mmf_attrs_construct_info_t *base = NULL;
220         //gchar *system_ua = NULL;
221         gchar *system_proxy = NULL;
222
223         return_val_if_fail (handle, 0);
224
225         player = MM_PLAYER_CAST(handle);
226
227         MMPlayerAttrsSpec player_attrs[] =
228         {
229                 {
230                         "profile_uri",                                  // name
231                         MM_ATTRS_TYPE_STRING,           // type
232                         MM_ATTRS_FLAG_RW,                       // flag
233                         (void *) NULL,                          // default value
234                         MM_ATTRS_VALID_TYPE_NONE,       // validity type
235                         0,                                                      // validity min value
236                         0                                                       // validity max value
237                 },
238                 {
239                         "profile_user_param",
240                         MM_ATTRS_TYPE_DATA,
241                         MM_ATTRS_FLAG_RW,
242                         (void *) NULL,
243                         MM_ATTRS_VALID_TYPE_NONE,
244                         0,
245                         0
246                 },
247                 {
248                         "profile_play_count",
249                         MM_ATTRS_TYPE_INT,
250                         MM_ATTRS_FLAG_RW,
251                         (void *) 1,                     // -1 : repeat continually
252                         MM_ATTRS_VALID_TYPE_INT_RANGE,
253                         -1,
254                         MMPLAYER_MAX_INT
255                 },
256                 {
257                         "profile_prepare_async",
258                         MM_ATTRS_TYPE_INT,
259                         MM_ATTRS_FLAG_RW,
260                         (void *) 0,
261                         MM_ATTRS_VALID_TYPE_INT_RANGE,
262                         0,
263                         1
264                 },
265                 {       /* update registry for downloadable codec */
266                         "profile_update_registry",
267                         MM_ATTRS_TYPE_INT,
268                         MM_ATTRS_FLAG_RW,
269                         (void *) 0,
270                         MM_ATTRS_VALID_TYPE_INT_RANGE,
271                         0,
272                         1
273                 },
274                 {
275                         "streaming_type",
276                         MM_ATTRS_TYPE_INT,
277                         MM_ATTRS_FLAG_RW,
278                         (void *) STREAMING_SERVICE_NONE,
279                         MM_ATTRS_VALID_TYPE_INT_RANGE,
280                         STREAMING_SERVICE_VOD,
281                         STREAMING_SERVICE_NUM
282                 },
283                 {
284                         "streaming_udp_timeout",
285                         MM_ATTRS_TYPE_INT,
286                         MM_ATTRS_FLAG_RW,
287                         (void *) 10000,
288                         MM_ATTRS_VALID_TYPE_INT_RANGE,
289                         0,
290                         MMPLAYER_MAX_INT
291                 },
292                 {
293                         "streaming_user_agent",
294                         MM_ATTRS_TYPE_STRING,
295                         MM_ATTRS_FLAG_RW,
296                         (void *) NULL,
297                         MM_ATTRS_VALID_TYPE_NONE,
298                         0,
299                         0
300                 },
301                 {
302                         "streaming_wap_profile",
303                         MM_ATTRS_TYPE_STRING,
304                         MM_ATTRS_FLAG_RW,
305                         (void *) NULL,
306                         MM_ATTRS_VALID_TYPE_NONE,
307                         0,
308                         0
309                 },
310                 {
311                         "streaming_network_bandwidth",
312                         MM_ATTRS_TYPE_INT,
313                         MM_ATTRS_FLAG_RW,
314                         (void *) 128000,
315                         MM_ATTRS_VALID_TYPE_INT_RANGE,
316                         0,
317                         MMPLAYER_MAX_INT
318                 },
319                 {
320                         "streaming_cookie",
321                         MM_ATTRS_TYPE_STRING,
322                         MM_ATTRS_FLAG_RW,
323                         (void *) NULL,
324                         MM_ATTRS_VALID_TYPE_NONE,
325                         0,
326                         0
327                 },
328                 {
329                         "streaming_proxy",
330                         MM_ATTRS_TYPE_STRING,
331                         MM_ATTRS_FLAG_RW,
332                         (void *) NULL,
333                         MM_ATTRS_VALID_TYPE_NONE,
334                         0,
335                         0
336                 },
337                 {
338                         "streaming_timeout",
339                         MM_ATTRS_TYPE_INT,
340                         MM_ATTRS_FLAG_RW,
341                         (void *) -1,    // DEFAULT_HTTP_TIMEOUT
342                         MM_ATTRS_VALID_TYPE_INT_RANGE,
343                         -1,
344                         MMPLAYER_MAX_INT
345                 },
346                 {
347                         "subtitle_uri",
348                         MM_ATTRS_TYPE_STRING,
349                         MM_ATTRS_FLAG_RW,
350                         (void *) NULL,
351                         MM_ATTRS_VALID_TYPE_NONE,
352                         0,
353                         0
354                 },
355                 {
356                         "content_duration",
357                         MM_ATTRS_TYPE_INT,
358                         MM_ATTRS_FLAG_RW,
359                         (void *) 0,
360                         MM_ATTRS_VALID_TYPE_INT_RANGE,
361                         0,
362                         MMPLAYER_MAX_INT
363                 },
364                 {
365                         "content_bitrate",
366                         MM_ATTRS_TYPE_INT,
367                         MM_ATTRS_FLAG_RW,
368                         (void *) 0,
369                         MM_ATTRS_VALID_TYPE_INT_RANGE,
370                         0,
371                         MMPLAYER_MAX_INT
372                 },
373                 {
374                         "content_max_bitrate",
375                         MM_ATTRS_TYPE_INT,
376                         MM_ATTRS_FLAG_RW,
377                         (void *) 0,
378                         MM_ATTRS_VALID_TYPE_INT_RANGE,
379                         0,
380                         MMPLAYER_MAX_INT
381                 },
382                 {
383                         "content_video_found",
384                         MM_ATTRS_TYPE_INT,
385                         MM_ATTRS_FLAG_RW,
386                         (void *) 0,
387                         MM_ATTRS_VALID_TYPE_INT_RANGE,
388                         0,
389                         1
390                 },
391                 {
392                         "content_video_codec",
393                         MM_ATTRS_TYPE_STRING,
394                         MM_ATTRS_FLAG_RW,
395                         (void *) NULL,
396                         MM_ATTRS_VALID_TYPE_NONE,
397                         0,
398                         0
399                 },
400                 {
401                         "content_video_bitrate",
402                         MM_ATTRS_TYPE_INT,
403                         MM_ATTRS_FLAG_RW,
404                         (void *) 0,
405                         MM_ATTRS_VALID_TYPE_INT_RANGE,
406                         0,
407                         MMPLAYER_MAX_INT
408                 },
409                 {
410                         "content_video_fps",
411                         MM_ATTRS_TYPE_INT,
412                         MM_ATTRS_FLAG_RW,
413                         (void *) 0,
414                         MM_ATTRS_VALID_TYPE_INT_RANGE,
415                         0,
416                         MMPLAYER_MAX_INT
417                 },
418                 {
419                         "content_video_width",
420                         MM_ATTRS_TYPE_INT,
421                         MM_ATTRS_FLAG_RW,
422                         (void *) 0,
423                         MM_ATTRS_VALID_TYPE_INT_RANGE,
424                         0,
425                         MMPLAYER_MAX_INT
426                 },
427                 {
428                         "content_video_height",
429                         MM_ATTRS_TYPE_INT,
430                         MM_ATTRS_FLAG_RW,
431                         (void *) 0,
432                         MM_ATTRS_VALID_TYPE_INT_RANGE,
433                         0,
434                         MMPLAYER_MAX_INT
435                 },
436                 {
437                         "content_video_track_num",
438                         MM_ATTRS_TYPE_INT,
439                         MM_ATTRS_FLAG_RW,
440                         (void *) 0,
441                         MM_ATTRS_VALID_TYPE_INT_RANGE,
442                         0,
443                         MMPLAYER_MAX_INT
444                 },
445                 {
446                         "content_audio_found",
447                         MM_ATTRS_TYPE_INT,
448                         MM_ATTRS_FLAG_RW,
449                         (void *) 0,
450                         MM_ATTRS_VALID_TYPE_INT_RANGE,
451                         0,
452                         1
453                 },
454                 {
455                         "content_audio_codec",
456                         MM_ATTRS_TYPE_STRING,
457                         MM_ATTRS_FLAG_RW,
458                         (void *) NULL,
459                         MM_ATTRS_VALID_TYPE_NONE,
460                         0,
461                         0
462                 },
463                 {
464                         "content_audio_bitrate",
465                         MM_ATTRS_TYPE_INT,
466                         MM_ATTRS_FLAG_RW,
467                         (void *) 0,
468                         MM_ATTRS_VALID_TYPE_INT_RANGE,
469                         0,
470                         MMPLAYER_MAX_INT
471                 },
472                 {
473                         "content_audio_channels",
474                         MM_ATTRS_TYPE_INT,
475                         MM_ATTRS_FLAG_RW,
476                         (void *) 0,
477                         MM_ATTRS_VALID_TYPE_INT_RANGE,
478                         0,
479                         MMPLAYER_MAX_INT
480                 },
481                 {
482                         "content_audio_samplerate",
483                         MM_ATTRS_TYPE_INT,
484                         MM_ATTRS_FLAG_RW,
485                         (void *) 0,
486                         MM_ATTRS_VALID_TYPE_INT_RANGE,
487                         0,
488                         MMPLAYER_MAX_INT
489                 },
490                 {
491                         "content_audio_track_num",
492                         MM_ATTRS_TYPE_INT,
493                         MM_ATTRS_FLAG_RW,
494                         (void *) 0,
495                         MM_ATTRS_VALID_TYPE_INT_RANGE,
496                         0,
497                         MMPLAYER_MAX_INT
498                 },
499                 {
500                         "content_audio_format",
501                         MM_ATTRS_TYPE_INT,
502                         MM_ATTRS_FLAG_RW,
503                         (void *) 0,
504                         MM_ATTRS_VALID_TYPE_INT_RANGE,
505                         0,
506                         MMPLAYER_MAX_INT
507                 },
508                 {
509                         "content_text_track_num",
510                         MM_ATTRS_TYPE_INT,
511                         MM_ATTRS_FLAG_RW,
512                         (void *) 0,
513                         MM_ATTRS_VALID_TYPE_INT_RANGE,
514                         0,
515                         MMPLAYER_MAX_INT
516                 },
517                 {
518                         "tag_artist",
519                         MM_ATTRS_TYPE_STRING,
520                         MM_ATTRS_FLAG_RW,
521                         (void *) NULL,
522                         MM_ATTRS_VALID_TYPE_NONE,
523                         0,
524                         0
525                 },
526                 {
527                         "tag_title",
528                         MM_ATTRS_TYPE_STRING,
529                         MM_ATTRS_FLAG_RW,
530                         (void *) NULL,
531                         MM_ATTRS_VALID_TYPE_NONE,
532                         0,
533                         0
534                 },
535                 {
536                         "tag_album",
537                         MM_ATTRS_TYPE_STRING,
538                         MM_ATTRS_FLAG_RW,
539                         (void *) NULL
540                 },
541                 {
542                         "tag_genre",
543                         MM_ATTRS_TYPE_STRING,
544                         MM_ATTRS_FLAG_RW,
545                         (void *) NULL,
546                         MM_ATTRS_VALID_TYPE_NONE,
547                         0,
548                         0
549                 },
550                 {
551                         "tag_author",
552                         MM_ATTRS_TYPE_STRING,
553                         MM_ATTRS_FLAG_RW,
554                         (void *) NULL,
555                         MM_ATTRS_VALID_TYPE_NONE,
556                         0,
557                         0
558                 },
559                 {
560                         "tag_copyright",
561                         MM_ATTRS_TYPE_STRING,
562                         MM_ATTRS_FLAG_RW,
563                         (void *) NULL,
564                         MM_ATTRS_VALID_TYPE_NONE,
565                         0,
566                         0
567                 },
568                 {
569                         "tag_date",
570                         MM_ATTRS_TYPE_STRING,
571                         MM_ATTRS_FLAG_RW,
572                         (void *) NULL,
573                         MM_ATTRS_VALID_TYPE_NONE,
574                         0,
575                         0
576                 },
577                 {
578                         "tag_description",
579                         MM_ATTRS_TYPE_STRING,
580                         MM_ATTRS_FLAG_RW,
581                         (void *) NULL,
582                         MM_ATTRS_VALID_TYPE_NONE,
583                         0,
584                         0
585                 },
586                 {
587                         "tag_track_num",
588                         MM_ATTRS_TYPE_INT,
589                         MM_ATTRS_FLAG_RW,
590                         (void *) 0,
591                         MM_ATTRS_VALID_TYPE_INT_RANGE,
592                         0,
593                         MMPLAYER_MAX_INT
594                 },
595                 {
596                         "tag_album_cover",
597                         MM_ATTRS_TYPE_DATA,
598                         MM_ATTRS_FLAG_RW,
599                         (void *) NULL,
600                         MM_ATTRS_VALID_TYPE_NONE,
601                         0,
602                         0
603                 },
604                 {
605                         "display_src_crop_x",
606                         MM_ATTRS_TYPE_INT,
607                         MM_ATTRS_FLAG_RW,
608                         (void *) 0,
609                         MM_ATTRS_VALID_TYPE_INT_RANGE,
610                         0,
611                         MMPLAYER_MAX_INT
612                 },
613                 {
614                         "display_src_crop_y",
615                         MM_ATTRS_TYPE_INT,
616                         MM_ATTRS_FLAG_RW,
617                         (void *) 0,
618                         MM_ATTRS_VALID_TYPE_INT_RANGE,
619                         0,
620                         MMPLAYER_MAX_INT
621                 },
622                 {
623                         "display_src_crop_width",
624                         MM_ATTRS_TYPE_INT,
625                         MM_ATTRS_FLAG_RW,
626                         (void *) 0,
627                         MM_ATTRS_VALID_TYPE_INT_RANGE,
628                         0,
629                         MMPLAYER_MAX_INT
630                 },
631                 {
632                         "display_src_crop_height",
633                         MM_ATTRS_TYPE_INT,
634                         MM_ATTRS_FLAG_RW,
635                         (void *) 0,
636                         MM_ATTRS_VALID_TYPE_INT_RANGE,
637                         0,
638                         MMPLAYER_MAX_INT
639                 },
640                 {
641                         "display_roi_x",
642                         MM_ATTRS_TYPE_INT,
643                         MM_ATTRS_FLAG_RW,
644                         (void *) 0,
645                         MM_ATTRS_VALID_TYPE_INT_RANGE,
646                         0,
647                         MMPLAYER_MAX_INT
648                 },
649                 {
650                         "display_roi_y",
651                         MM_ATTRS_TYPE_INT,
652                         MM_ATTRS_FLAG_RW,
653                         (void *) 0,
654                         MM_ATTRS_VALID_TYPE_INT_RANGE,
655                         0,
656                         MMPLAYER_MAX_INT
657                 },
658                 {
659                         "display_roi_width",
660                         MM_ATTRS_TYPE_INT,
661                         MM_ATTRS_FLAG_RW,
662                         (void *) 480,
663                         MM_ATTRS_VALID_TYPE_INT_RANGE,
664                         0,
665                         MMPLAYER_MAX_INT
666                 },
667                 {
668                         "display_roi_height",
669                         MM_ATTRS_TYPE_INT,
670                         MM_ATTRS_FLAG_RW,
671                         (void *) 800,
672                         MM_ATTRS_VALID_TYPE_INT_RANGE,
673                         0,
674                         MMPLAYER_MAX_INT
675                 },
676                 {
677                         "display_roi_mode",
678                         MM_ATTRS_TYPE_INT,
679                         MM_ATTRS_FLAG_RW,
680                         (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
681                         MM_ATTRS_VALID_TYPE_INT_RANGE,
682                         MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
683                         MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
684                 },
685                 {
686                         "display_rotation",
687                         MM_ATTRS_TYPE_INT,
688                         MM_ATTRS_FLAG_RW,
689                         (void *) MM_DISPLAY_ROTATION_NONE,
690                         MM_ATTRS_VALID_TYPE_INT_RANGE,
691                         MM_DISPLAY_ROTATION_NONE,
692                         MM_DISPLAY_ROTATION_270
693                 },
694                 {
695                         "display_visible",
696                         MM_ATTRS_TYPE_INT,
697                         MM_ATTRS_FLAG_RW,
698                         (void *) FALSE,
699                         MM_ATTRS_VALID_TYPE_INT_RANGE,
700                         0,
701                         1
702                 },
703                 {
704                         "display_method",
705                         MM_ATTRS_TYPE_INT,
706                         MM_ATTRS_FLAG_RW,
707                         (void *) MM_DISPLAY_METHOD_LETTER_BOX,
708                         MM_ATTRS_VALID_TYPE_INT_RANGE,
709                         MM_DISPLAY_METHOD_LETTER_BOX,
710                         MM_DISPLAY_METHOD_CUSTOM_ROI
711                 },
712                 {
713                         "display_overlay",
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 #ifdef HAVE_WAYLAND
722                 {
723                         "wl_display",
724                         MM_ATTRS_TYPE_DATA,
725                         MM_ATTRS_FLAG_RW,
726                         (void *) NULL,
727                         MM_ATTRS_VALID_TYPE_NONE,
728                         0,
729                         0
730                 },
731                 {
732                         "wl_window_render_x",
733                         MM_ATTRS_TYPE_INT,
734                         MM_ATTRS_FLAG_RW,
735                         (void *) 0,
736                         MM_ATTRS_VALID_TYPE_INT_RANGE,
737                         0,
738                         MMPLAYER_MAX_INT
739                 },
740                 {
741                         "wl_window_render_y",
742                         MM_ATTRS_TYPE_INT,
743                         MM_ATTRS_FLAG_RW,
744                         (void *) 0,
745                         MM_ATTRS_VALID_TYPE_INT_RANGE,
746                         0,
747                         MMPLAYER_MAX_INT
748                 },
749                 {
750                         "wl_window_render_width",
751                         MM_ATTRS_TYPE_INT,
752                         MM_ATTRS_FLAG_RW,
753                         (void *) 0,
754                         MM_ATTRS_VALID_TYPE_INT_RANGE,
755                         0,
756                         MMPLAYER_MAX_INT
757                 },
758                 {
759                         "wl_window_render_height",
760                         MM_ATTRS_TYPE_INT,
761                         MM_ATTRS_FLAG_RW,
762                         (void *) 0,
763                         MM_ATTRS_VALID_TYPE_INT_RANGE,
764                         0,
765                         MMPLAYER_MAX_INT
766                 },
767 #endif
768                 {
769                         "display_overlay_user_data",
770                         MM_ATTRS_TYPE_DATA,
771                         MM_ATTRS_FLAG_RW,
772                         (void *) NULL,
773                         MM_ATTRS_VALID_TYPE_NONE,
774                         0,
775                         0
776                 },
777                 {
778                         "display_zoom",
779                         MM_ATTRS_TYPE_DOUBLE,
780                         MM_ATTRS_FLAG_RW,
781                         (void *) 1,
782                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
783                         1.0,
784                         9.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_X,
793                         MM_DISPLAY_SURFACE_X_EXT
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                         0,
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
1085         num_of_attrs = ARRAY_SIZE(player_attrs);
1086
1087         base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1088
1089         if ( !base )
1090         {
1091                 debug_error("failed to alloc attrs constructor");
1092                 return 0;
1093         }
1094
1095         /* initialize values of attributes */
1096         for ( idx = 0; idx < num_of_attrs; idx++ )
1097         {
1098                 base[idx].name = player_attrs[idx].name;
1099                 base[idx].value_type = player_attrs[idx].value_type;
1100                 base[idx].flags = player_attrs[idx].flags;
1101                 base[idx].default_value = player_attrs[idx].default_value;
1102         }
1103
1104         attrs = mmf_attrs_new_from_data(
1105                                         "mmplayer_attrs",
1106                                         base,
1107                                         num_of_attrs,
1108                                         NULL,
1109                                         NULL);
1110
1111         /* clean */
1112         MMPLAYER_FREEIF(base);
1113
1114         if ( !attrs )
1115         {
1116                 debug_error("failed to create player attrs");
1117                 return 0;
1118         }
1119
1120         /* set validity type and range */
1121         for ( idx = 0; idx < num_of_attrs; idx++ )
1122         {
1123                 switch ( player_attrs[idx].valid_type)
1124                 {
1125                         case MM_ATTRS_VALID_TYPE_INT_RANGE:
1126                         {
1127                                 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1128                                 mmf_attrs_set_valid_range (attrs, idx,
1129                                                 player_attrs[idx].value_min,
1130                                                 player_attrs[idx].value_max,
1131                                                 (int)(player_attrs[idx].default_value));
1132                         }
1133                         break;
1134
1135                         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1136                         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1137                         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1138                         default:
1139                         break;
1140                 }
1141         }
1142
1143         #if 0
1144         /* set proxy and user agent */
1145         system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1146         system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1147
1148         if (system_ua)
1149         {
1150                         mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1151                         g_free(system_ua);
1152         }
1153         #endif
1154
1155         if (system_proxy)
1156         {
1157                         mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1158                         g_free(system_proxy);
1159         }
1160
1161         /* commit */
1162         mmf_attrs_commit(attrs);
1163
1164         return attrs;
1165 }
1166
1167 bool
1168 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1169 {
1170         mm_player_t *player = MM_PLAYER_CAST(handle);
1171
1172         return_val_if_fail ( player, FALSE );
1173
1174         if (player->attrs)
1175         {
1176                 mmf_attrs_free (player->attrs);
1177                 player->attrs = 0;
1178         }
1179
1180         return TRUE;
1181 }