4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7 * YoungHwan An <younghwan_.an@samsung.com>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 /*===========================================================================================
27 ========================================================================================== */
29 #include <mm_attrs_private.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"
36 /*===========================================================================================
38 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
40 ========================================================================================== */
47 int valid_type; // validity type
48 int value_min; //<- set validity value range
52 /*---------------------------------------------------------------------------
53 | LOCAL FUNCTION PROTOTYPES: |
54 ---------------------------------------------------------------------------*/
56 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
58 /*===========================================================================================
60 | FUNCTION DEFINITIONS |
62 ========================================================================================== */
65 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
67 int result = MM_ERROR_NONE;
68 MMHandleType attrs = 0;
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);
75 attrs = MM_PLAYER_GET_ATTRS(handle);
77 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
79 if ( result != MM_ERROR_NONE)
80 debug_error("failed to get %s attribute\n", attribute_name);
86 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
88 int result = MM_ERROR_NONE;
89 MMHandleType attrs = 0;
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);
96 attrs = MM_PLAYER_GET_ATTRS(handle);
98 /* set attributes and commit them */
99 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
101 if (result != MM_ERROR_NONE)
103 debug_error("failed to set %s attribute\n", attribute_name);
107 result = __mmplayer_apply_attribute(handle, attribute_name);
108 if (result != MM_ERROR_NONE)
110 debug_error("failed to apply attributes\n");
118 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
120 int result = MM_ERROR_NONE;
121 MMHandleType attrs = 0;
122 MMAttrsInfo src_info = {0, };
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);
128 attrs = MM_PLAYER_GET_ATTRS(handle);
130 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
132 if ( result != MM_ERROR_NONE)
134 debug_error("failed to get attribute info\n");
138 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
140 dst_info->type = src_info.type;
141 dst_info->flag = src_info.flag;
142 dst_info->validity_type= src_info.validity_type;
144 switch(src_info.validity_type)
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;
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;
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;
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;
178 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
180 mm_player_t* player = 0;
182 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
183 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
185 player = MM_PLAYER_CAST(handle);
187 if ( g_strrstr(attribute_name, "display") )
189 /* check videosink element is created */
190 if ( !player->pipeline ||
191 !player->pipeline->videobin ||
192 !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
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.
199 return MM_ERROR_NONE;
202 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
204 debug_error("failed to update video param");
205 return MM_ERROR_PLAYER_INTERNAL;
209 return MM_ERROR_NONE;
213 _mmplayer_construct_attribute(MMHandleType handle)
215 mm_player_t *player = NULL;
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;
223 return_val_if_fail (handle, 0);
225 player = MM_PLAYER_CAST(handle);
227 MMPlayerAttrsSpec player_attrs[] =
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
239 "profile_user_param",
243 MM_ATTRS_VALID_TYPE_NONE,
248 "profile_play_count",
251 (void *) 1, // -1 : repeat continually
252 MM_ATTRS_VALID_TYPE_INT_RANGE,
257 "profile_prepare_async",
261 MM_ATTRS_VALID_TYPE_INT_RANGE,
265 { /* update registry for downloadable codec */
266 "profile_update_registry",
270 MM_ATTRS_VALID_TYPE_INT_RANGE,
278 (void *) STREAMING_SERVICE_NONE,
279 MM_ATTRS_VALID_TYPE_INT_RANGE,
280 STREAMING_SERVICE_VOD,
281 STREAMING_SERVICE_NUM
284 "streaming_udp_timeout",
288 MM_ATTRS_VALID_TYPE_INT_RANGE,
293 "streaming_user_agent",
294 MM_ATTRS_TYPE_STRING,
297 MM_ATTRS_VALID_TYPE_NONE,
302 "streaming_wap_profile",
303 MM_ATTRS_TYPE_STRING,
306 MM_ATTRS_VALID_TYPE_NONE,
311 "streaming_network_bandwidth",
315 MM_ATTRS_VALID_TYPE_INT_RANGE,
321 MM_ATTRS_TYPE_STRING,
324 MM_ATTRS_VALID_TYPE_NONE,
330 MM_ATTRS_TYPE_STRING,
333 MM_ATTRS_VALID_TYPE_NONE,
341 (void *) -1, // DEFAULT_HTTP_TIMEOUT
342 MM_ATTRS_VALID_TYPE_INT_RANGE,
348 MM_ATTRS_TYPE_STRING,
351 MM_ATTRS_VALID_TYPE_NONE,
360 MM_ATTRS_VALID_TYPE_INT_RANGE,
369 MM_ATTRS_VALID_TYPE_INT_RANGE,
374 "content_max_bitrate",
378 MM_ATTRS_VALID_TYPE_INT_RANGE,
383 "content_video_found",
387 MM_ATTRS_VALID_TYPE_INT_RANGE,
392 "content_video_codec",
393 MM_ATTRS_TYPE_STRING,
396 MM_ATTRS_VALID_TYPE_NONE,
401 "content_video_bitrate",
405 MM_ATTRS_VALID_TYPE_INT_RANGE,
414 MM_ATTRS_VALID_TYPE_INT_RANGE,
419 "content_video_width",
423 MM_ATTRS_VALID_TYPE_INT_RANGE,
428 "content_video_height",
432 MM_ATTRS_VALID_TYPE_INT_RANGE,
437 "content_video_track_num",
441 MM_ATTRS_VALID_TYPE_INT_RANGE,
446 "content_audio_found",
450 MM_ATTRS_VALID_TYPE_INT_RANGE,
455 "content_audio_codec",
456 MM_ATTRS_TYPE_STRING,
459 MM_ATTRS_VALID_TYPE_NONE,
464 "content_audio_bitrate",
468 MM_ATTRS_VALID_TYPE_INT_RANGE,
473 "content_audio_channels",
477 MM_ATTRS_VALID_TYPE_INT_RANGE,
482 "content_audio_samplerate",
486 MM_ATTRS_VALID_TYPE_INT_RANGE,
491 "content_audio_track_num",
495 MM_ATTRS_VALID_TYPE_INT_RANGE,
500 "content_audio_format",
504 MM_ATTRS_VALID_TYPE_INT_RANGE,
509 "content_text_track_num",
513 MM_ATTRS_VALID_TYPE_INT_RANGE,
519 MM_ATTRS_TYPE_STRING,
522 MM_ATTRS_VALID_TYPE_NONE,
528 MM_ATTRS_TYPE_STRING,
531 MM_ATTRS_VALID_TYPE_NONE,
537 MM_ATTRS_TYPE_STRING,
543 MM_ATTRS_TYPE_STRING,
546 MM_ATTRS_VALID_TYPE_NONE,
552 MM_ATTRS_TYPE_STRING,
555 MM_ATTRS_VALID_TYPE_NONE,
561 MM_ATTRS_TYPE_STRING,
564 MM_ATTRS_VALID_TYPE_NONE,
570 MM_ATTRS_TYPE_STRING,
573 MM_ATTRS_VALID_TYPE_NONE,
579 MM_ATTRS_TYPE_STRING,
582 MM_ATTRS_VALID_TYPE_NONE,
591 MM_ATTRS_VALID_TYPE_INT_RANGE,
600 MM_ATTRS_VALID_TYPE_NONE,
605 "display_src_crop_x",
609 MM_ATTRS_VALID_TYPE_INT_RANGE,
614 "display_src_crop_y",
618 MM_ATTRS_VALID_TYPE_INT_RANGE,
623 "display_src_crop_width",
627 MM_ATTRS_VALID_TYPE_INT_RANGE,
632 "display_src_crop_height",
636 MM_ATTRS_VALID_TYPE_INT_RANGE,
645 MM_ATTRS_VALID_TYPE_INT_RANGE,
654 MM_ATTRS_VALID_TYPE_INT_RANGE,
663 MM_ATTRS_VALID_TYPE_INT_RANGE,
668 "display_roi_height",
672 MM_ATTRS_VALID_TYPE_INT_RANGE,
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
689 (void *) MM_DISPLAY_ROTATION_NONE,
690 MM_ATTRS_VALID_TYPE_INT_RANGE,
691 MM_DISPLAY_ROTATION_NONE,
692 MM_DISPLAY_ROTATION_270
699 MM_ATTRS_VALID_TYPE_INT_RANGE,
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
717 MM_ATTRS_VALID_TYPE_NONE,
727 MM_ATTRS_VALID_TYPE_NONE,
732 "wl_window_render_x",
736 MM_ATTRS_VALID_TYPE_INT_RANGE,
741 "wl_window_render_y",
745 MM_ATTRS_VALID_TYPE_INT_RANGE,
750 "wl_window_render_width",
754 MM_ATTRS_VALID_TYPE_INT_RANGE,
759 "wl_window_render_height",
763 MM_ATTRS_VALID_TYPE_INT_RANGE,
769 "display_overlay_user_data",
773 MM_ATTRS_VALID_TYPE_NONE,
779 MM_ATTRS_TYPE_DOUBLE,
782 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
787 "display_surface_type",
790 (void *) MM_DISPLAY_SURFACE_NULL,
791 MM_ATTRS_VALID_TYPE_INT_RANGE,
792 MM_DISPLAY_SURFACE_X,
793 MM_DISPLAY_SURFACE_X_EXT
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,
805 "display_force_aspect_ration",
809 MM_ATTRS_VALID_TYPE_INT_RANGE,
814 "display_width", // dest width of fimcconvert ouput
818 MM_ATTRS_VALID_TYPE_INT_RANGE,
823 "display_height", // dest height of fimcconvert ouput
827 MM_ATTRS_VALID_TYPE_INT_RANGE,
832 "display_evas_do_scaling",
836 MM_ATTRS_VALID_TYPE_INT_RANGE,
845 MM_ATTRS_VALID_TYPE_INT_RANGE,
854 MM_ATTRS_VALID_TYPE_INT_RANGE,
862 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
863 MM_ATTRS_VALID_TYPE_INT_RANGE,
869 MM_ATTRS_TYPE_STRING,
872 MM_ATTRS_VALID_TYPE_NONE,
877 "sound_stream_index",
881 MM_ATTRS_VALID_TYPE_INT_RANGE,
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
895 "sound_stop_when_unplugged",
899 MM_ATTRS_VALID_TYPE_INT_RANGE,
904 "sound_application_pid",
908 MM_ATTRS_VALID_TYPE_INT_RANGE,
913 "sound_spk_out_only",
917 MM_ATTRS_VALID_TYPE_INT_RANGE,
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,
931 "sound_close_resource",
935 MM_ATTRS_VALID_TYPE_INT_RANGE,
940 "sound_latency_mode",
943 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
944 MM_ATTRS_VALID_TYPE_INT_RANGE,
949 "pcm_extraction", // enable pcm extraction
953 MM_ATTRS_VALID_TYPE_INT_RANGE,
958 "pcm_extraction_samplerate", // set samplerate for pcm extraction
961 (void *) 44100, // hz
962 MM_ATTRS_VALID_TYPE_INT_RANGE,
967 "pcm_extraction_depth", // set depth for pcm extraction
971 MM_ATTRS_VALID_TYPE_INT_RANGE,
976 "pcm_extraction_channels", // set channels for pcm extraction
980 MM_ATTRS_VALID_TYPE_INT_RANGE,
985 "pcm_extraction_start_msec", // set start position to extract pcm
989 MM_ATTRS_VALID_TYPE_INT_RANGE,
994 "pcm_extraction_end_msec", // set end position to extract pcm
998 MM_ATTRS_VALID_TYPE_INT_RANGE,
1003 "profile_smooth_repeat",
1007 MM_ATTRS_VALID_TYPE_INT_RANGE,
1012 "profile_progress_interval", // will be deprecated
1016 MM_ATTRS_VALID_TYPE_INT_RANGE,
1025 MM_ATTRS_VALID_TYPE_INT_RANGE,
1034 MM_ATTRS_VALID_TYPE_INT_RANGE,
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
1048 "pd_location", // location of the file to write
1049 MM_ATTRS_TYPE_STRING,
1052 MM_ATTRS_VALID_TYPE_NONE,
1061 MM_ATTRS_VALID_TYPE_INT_RANGE,
1066 "content_video_orientation", // orientation of video content
1067 MM_ATTRS_TYPE_STRING,
1070 MM_ATTRS_VALID_TYPE_NONE,
1076 num_of_attrs = ARRAY_SIZE(player_attrs);
1078 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1082 debug_error("failed to alloc attrs constructor");
1086 /* initialize values of attributes */
1087 for ( idx = 0; idx < num_of_attrs; idx++ )
1089 base[idx].name = player_attrs[idx].name;
1090 base[idx].value_type = player_attrs[idx].value_type;
1091 base[idx].flags = player_attrs[idx].flags;
1092 base[idx].default_value = player_attrs[idx].default_value;
1095 attrs = mmf_attrs_new_from_data(
1103 MMPLAYER_FREEIF(base);
1107 debug_error("failed to create player attrs");
1111 /* set validity type and range */
1112 for ( idx = 0; idx < num_of_attrs; idx++ )
1114 switch ( player_attrs[idx].valid_type)
1116 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1118 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1119 mmf_attrs_set_valid_range (attrs, idx,
1120 player_attrs[idx].value_min,
1121 player_attrs[idx].value_max,
1122 (int)(player_attrs[idx].default_value));
1126 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1127 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1128 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1135 /* set proxy and user agent */
1136 system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
1137 system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1141 mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1148 mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1149 g_free(system_proxy);
1153 mmf_attrs_commit(attrs);
1159 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1161 mm_player_t *player = MM_PLAYER_CAST(handle);
1163 return_val_if_fail ( player, FALSE );
1167 mmf_attrs_free (player->attrs);