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