Update to version tizen 2.3 API base on Gstreamer 1.x
[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                 {
722                         "display_overlay_user_data",
723                         MM_ATTRS_TYPE_DATA,
724                         MM_ATTRS_FLAG_RW,
725                         (void *) NULL,
726                         MM_ATTRS_VALID_TYPE_NONE,
727                         0,
728                         0
729                 },
730                 {
731                         "display_zoom",
732                         MM_ATTRS_TYPE_DOUBLE,
733                         MM_ATTRS_FLAG_RW,
734                         (void *) 1,
735                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
736                         1.0,
737                         9.0
738                 },
739                 {
740                         "display_surface_type",
741                         MM_ATTRS_TYPE_INT,
742                         MM_ATTRS_FLAG_RW,
743                         (void *) MM_DISPLAY_SURFACE_NULL,
744                         MM_ATTRS_VALID_TYPE_INT_RANGE,
745                         MM_DISPLAY_SURFACE_X,
746                         MM_DISPLAY_SURFACE_X_EXT
747                 },
748                 {
749                         "display_evas_surface_sink",
750                         MM_ATTRS_TYPE_STRING,
751                         MM_ATTRS_FLAG_READABLE,
752                         (void *) player->ini.videosink_element_evas,
753                         MM_ATTRS_VALID_TYPE_NONE,
754                         0,
755                         0
756                 },
757                 {
758                         "display_force_aspect_ration",
759                         MM_ATTRS_TYPE_INT,
760                         MM_ATTRS_FLAG_RW,
761                         (void *) 1,
762                         MM_ATTRS_VALID_TYPE_INT_RANGE,
763                         0,
764                         MMPLAYER_MAX_INT
765                 },
766                 {
767                         "display_width",                // dest width of fimcconvert ouput
768                         MM_ATTRS_TYPE_INT,
769                         MM_ATTRS_FLAG_RW,
770                         (void *) 0,
771                         MM_ATTRS_VALID_TYPE_INT_RANGE,
772                         0,
773                         MMPLAYER_MAX_INT
774                 },
775                 {
776                         "display_height",               // dest height of fimcconvert ouput
777                         MM_ATTRS_TYPE_INT,
778                         MM_ATTRS_FLAG_RW,
779                         (void *) 0,
780                         MM_ATTRS_VALID_TYPE_INT_RANGE,
781                         0,
782                         MMPLAYER_MAX_INT
783                 },
784                 {
785                         "display_evas_do_scaling",
786                         MM_ATTRS_TYPE_INT,
787                         MM_ATTRS_FLAG_RW,
788                         (void *) TRUE,
789                         MM_ATTRS_VALID_TYPE_INT_RANGE,
790                         FALSE,
791                         TRUE
792                 },
793                 {
794                         "sound_fadeup",
795                         MM_ATTRS_TYPE_INT,
796                         MM_ATTRS_FLAG_RW,
797                         (void *) FALSE,
798                         MM_ATTRS_VALID_TYPE_INT_RANGE,
799                         FALSE,
800                         TRUE
801                 },
802                 {
803                         "sound_fadedown",
804                         MM_ATTRS_TYPE_INT,
805                         MM_ATTRS_FLAG_RW,
806                         (void *) FALSE,
807                         MM_ATTRS_VALID_TYPE_INT_RANGE,
808                         FALSE,
809                         TRUE
810                 },
811                 {
812                         "sound_volume_type",
813                         MM_ATTRS_TYPE_INT,
814                         MM_ATTRS_FLAG_RW,
815                         (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
816                         MM_ATTRS_VALID_TYPE_INT_RANGE,
817                         0,
818                         MMPLAYER_MAX_INT
819                 },
820                 {
821                         "sound_route",
822                         MM_ATTRS_TYPE_INT,
823                         MM_ATTRS_FLAG_RW,
824                         (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
825                         MM_ATTRS_VALID_TYPE_INT_RANGE,
826                         MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
827                         MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
828                 },
829                 {
830                         "sound_stop_when_unplugged",
831                         MM_ATTRS_TYPE_INT,
832                         MM_ATTRS_FLAG_RW,
833                         (void *) TRUE,
834                         MM_ATTRS_VALID_TYPE_INT_RANGE,
835                         FALSE,
836                         TRUE
837                 },
838                 {
839                         "sound_application_pid",
840                         MM_ATTRS_TYPE_INT,
841                         MM_ATTRS_FLAG_RW,
842                         (void *) 0,
843                         MM_ATTRS_VALID_TYPE_INT_RANGE,
844                         0,
845                         MMPLAYER_MAX_INT
846                 },
847                 {
848                         "sound_spk_out_only",
849                         MM_ATTRS_TYPE_INT,
850                         MM_ATTRS_FLAG_RW,
851                         (void *) FALSE,
852                         MM_ATTRS_VALID_TYPE_INT_RANGE,
853                         FALSE,
854                         TRUE
855                 },
856                 {
857                         "sound_priority",
858                         MM_ATTRS_TYPE_INT,
859                         MM_ATTRS_FLAG_RW,
860                         (void *) 0,                     // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
861                         MM_ATTRS_VALID_TYPE_INT_RANGE,
862                         0,
863                         3
864                 },
865                 {
866                         "sound_close_resource",
867                         MM_ATTRS_TYPE_INT,
868                         MM_ATTRS_FLAG_RW,
869                         (void *) 0,
870                         MM_ATTRS_VALID_TYPE_INT_RANGE,
871                         0,
872                         1
873                 },
874                 {
875                         "sound_latency_mode",
876                         MM_ATTRS_TYPE_INT,
877                         MM_ATTRS_FLAG_RW,
878                         (void *) 1,                     // 0: low latency, 1: middle latency 2: high latency
879                         MM_ATTRS_VALID_TYPE_INT_RANGE,
880                         0,
881                         2
882                 },
883                 {
884                         "pcm_extraction",               // enable pcm extraction
885                         MM_ATTRS_TYPE_INT,
886                         MM_ATTRS_FLAG_RW,
887                         (void *) FALSE,
888                         MM_ATTRS_VALID_TYPE_INT_RANGE,
889                         FALSE,
890                         TRUE
891                 },
892                 {
893                         "pcm_extraction_samplerate",    // set samplerate for pcm extraction
894                         MM_ATTRS_TYPE_INT,
895                         MM_ATTRS_FLAG_RW,
896                         (void *) 44100,                         // hz
897                         MM_ATTRS_VALID_TYPE_INT_RANGE,
898                         0,
899                         MMPLAYER_MAX_INT
900                 },
901                 {
902                         "pcm_extraction_depth", // set depth for pcm extraction
903                         MM_ATTRS_TYPE_INT,
904                         MM_ATTRS_FLAG_RW,
905                         (void *) 16,                    // bits
906                         MM_ATTRS_VALID_TYPE_INT_RANGE,
907                         0,
908                         MMPLAYER_MAX_INT
909                 },
910                 {
911                         "pcm_extraction_channels",      // set channels for pcm extraction
912                         MM_ATTRS_TYPE_INT,
913                         MM_ATTRS_FLAG_RW,
914                         (void *) 1,
915                         MM_ATTRS_VALID_TYPE_INT_RANGE,
916                         0,
917                         MMPLAYER_MAX_INT
918                 },
919                 {
920                         "pcm_extraction_start_msec",    // set start position to extract pcm
921                         MM_ATTRS_TYPE_INT,
922                         MM_ATTRS_FLAG_RW,
923                         (void *) 0,
924                         MM_ATTRS_VALID_TYPE_INT_RANGE,
925                         0,
926                         MMPLAYER_MAX_INT
927                 },
928                 {
929                         "pcm_extraction_end_msec",      // set end position to extract pcm
930                         MM_ATTRS_TYPE_INT,
931                         MM_ATTRS_FLAG_RW,
932                         (void *) 0,
933                         MM_ATTRS_VALID_TYPE_INT_RANGE,
934                         0,
935                         MMPLAYER_MAX_INT
936                 },
937                 {
938                         "profile_smooth_repeat",
939                         MM_ATTRS_TYPE_INT,
940                         MM_ATTRS_FLAG_RW,
941                         (void *) FALSE,
942                         MM_ATTRS_VALID_TYPE_INT_RANGE,
943                         0,
944                         MMPLAYER_MAX_INT
945                 },
946                 {
947                         "profile_progress_interval",    // will be deprecated
948                         MM_ATTRS_TYPE_INT,
949                         MM_ATTRS_FLAG_RW,
950                         (void *) 500,
951                         MM_ATTRS_VALID_TYPE_INT_RANGE,
952                         0,
953                         MMPLAYER_MAX_INT
954                 },
955                 {
956                         "display_x",
957                         MM_ATTRS_TYPE_INT,
958                         MM_ATTRS_FLAG_RW,
959                         (void *) 0,
960                         MM_ATTRS_VALID_TYPE_INT_RANGE,
961                         0,
962                         MMPLAYER_MAX_INT
963                 },
964                 {
965                         "display_y",
966                         MM_ATTRS_TYPE_INT,
967                         MM_ATTRS_FLAG_RW,
968                         (void *) 0,
969                         MM_ATTRS_VALID_TYPE_INT_RANGE,
970                         0,
971                         MMPLAYER_MAX_INT
972                 },
973                 {
974                         "pd_mode",
975                         MM_ATTRS_TYPE_INT,
976                         MM_ATTRS_FLAG_RW,
977                         (void *) MM_PLAYER_PD_MODE_NONE,
978                         MM_ATTRS_VALID_TYPE_INT_RANGE,
979                         MM_PLAYER_PD_MODE_NONE,
980                         MM_PLAYER_PD_MODE_URI           // not tested yet, because of no fixed scenario
981                 },
982                 {
983                         "pd_location",                  // location of the file to write
984                         MM_ATTRS_TYPE_STRING,
985                         MM_ATTRS_FLAG_RW,
986                         (void *) NULL,
987                         MM_ATTRS_VALID_TYPE_NONE,
988                         0,
989                         0
990                 },
991                 {
992                         "accurate_seek",
993                         MM_ATTRS_TYPE_INT,
994                         MM_ATTRS_FLAG_RW,
995                         (void *) 0,
996                         MM_ATTRS_VALID_TYPE_INT_RANGE,
997                         0,
998                         1
999                 }
1000         };
1001
1002         num_of_attrs = ARRAY_SIZE(player_attrs);
1003
1004         base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1005
1006         if ( !base )
1007         {
1008                 debug_error("failed to alloc attrs constructor");
1009                 return 0;
1010         }
1011
1012         /* initialize values of attributes */
1013         for ( idx = 0; idx < num_of_attrs; idx++ )
1014         {
1015                 base[idx].name = player_attrs[idx].name;
1016                 base[idx].value_type = player_attrs[idx].value_type;
1017                 base[idx].flags = player_attrs[idx].flags;
1018                 base[idx].default_value = player_attrs[idx].default_value;
1019         }
1020
1021         attrs = mmf_attrs_new_from_data(
1022                                         "mmplayer_attrs",
1023                                         base,
1024                                         num_of_attrs,
1025                                         NULL,
1026                                         NULL);
1027
1028         /* clean */
1029         MMPLAYER_FREEIF(base);
1030
1031         if ( !attrs )
1032         {
1033                 debug_error("failed to create player attrs");
1034                 return 0;
1035         }
1036
1037         /* set validity type and range */
1038         for ( idx = 0; idx < num_of_attrs; idx++ )
1039         {
1040                 switch ( player_attrs[idx].valid_type)
1041                 {
1042                         case MM_ATTRS_VALID_TYPE_INT_RANGE:
1043                         {
1044                                 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1045                                 mmf_attrs_set_valid_range (attrs, idx,
1046                                                 player_attrs[idx].value_min,
1047                                                 player_attrs[idx].value_max,
1048                                                 (int)(player_attrs[idx].default_value));
1049                         }
1050                         break;
1051
1052                         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1053                         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1054                         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1055                         default:
1056                         break;
1057                 }
1058         }
1059
1060         #if 0
1061         /* set proxy and user agent */
1062         system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1063         system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1064
1065         if (system_ua)
1066         {
1067                         mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1068                         g_free(system_ua);
1069         }
1070         #endif
1071
1072         if (system_proxy)
1073         {
1074                         mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1075                         g_free(system_proxy);
1076         }
1077
1078         /* commit */
1079         mmf_attrs_commit(attrs);
1080
1081         return attrs;
1082 }
1083
1084 bool
1085 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1086 {
1087         mm_player_t *player = MM_PLAYER_CAST(handle);
1088
1089         return_val_if_fail ( player, FALSE );
1090
1091         if (player->attrs)
1092         {
1093                 mmf_attrs_free (player->attrs);
1094                 player->attrs = 0;
1095         }
1096
1097         return TRUE;
1098 }