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>, YoungHwan An <younghwan_.an@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /*===========================================================================================
26 ========================================================================================== */
28 #include <mm_attrs_private.h>
30 #include <gst/interfaces/xoverlay.h>
32 #include "mm_player_priv.h"
33 #include "mm_player_attrs.h"
35 /*===========================================================================================
37 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
39 ========================================================================================== */
46 int valid_type; // validity type
47 int value_min; //<- set validity value range
51 /*---------------------------------------------------------------------------
52 | LOCAL FUNCTION PROTOTYPES: |
53 ---------------------------------------------------------------------------*/
55 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
57 /*===========================================================================================
59 | FUNCTION DEFINITIONS |
61 ========================================================================================== */
64 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
66 int result = MM_ERROR_NONE;
67 MMHandleType attrs = 0;
71 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
72 /* if it's not want to know it. */
73 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
74 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
76 attrs = MM_PLAYER_GET_ATTRS(handle);
78 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
80 if ( result != MM_ERROR_NONE)
81 debug_error("failed to get %s attribute\n", attribute_name);
89 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
91 int result = MM_ERROR_NONE;
92 MMHandleType attrs = 0;
96 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
97 /* if it's not want to know it. */
98 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
99 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
101 attrs = MM_PLAYER_GET_ATTRS(handle);
103 /* set attributes and commit them */
104 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
106 if (result != MM_ERROR_NONE)
108 debug_error("failed to set %s attribute\n", attribute_name);
112 result = __mmplayer_apply_attribute(handle, attribute_name);
113 if (result != MM_ERROR_NONE)
115 debug_error("failed to apply attributes\n");
125 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
127 int result = MM_ERROR_NONE;
128 MMHandleType attrs = 0;
129 MMAttrsInfo src_info = {0, };
133 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
134 return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
135 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
137 attrs = MM_PLAYER_GET_ATTRS(handle);
139 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
141 if ( result != MM_ERROR_NONE)
143 debug_error("failed to get attribute info\n");
147 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
149 dst_info->type = src_info.type;
150 dst_info->flag = src_info.flag;
151 dst_info->validity_type= src_info.validity_type;
153 switch(src_info.validity_type)
155 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
156 dst_info->int_array.array = src_info.int_array.array;
157 dst_info->int_array.count = src_info.int_array.count;
158 dst_info->int_array.d_val = src_info.int_array.dval;
161 case MM_ATTRS_VALID_TYPE_INT_RANGE:
162 dst_info->int_range.min = src_info.int_range.min;
163 dst_info->int_range.max = src_info.int_range.max;
164 dst_info->int_range.d_val = src_info.int_range.dval;
167 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
168 dst_info->double_array.array = src_info.double_array.array;
169 dst_info->double_array.count = src_info.double_array.count;
170 dst_info->double_array.d_val = src_info.double_array.dval;
173 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
174 dst_info->double_range.min = src_info.double_range.min;
175 dst_info->double_range.max = src_info.double_range.max;
176 dst_info->double_range.d_val = src_info.double_range.dval;
189 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
191 MMHandleType attrs = 0;
192 mm_player_t* player = 0;
196 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
197 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
199 attrs = MM_PLAYER_GET_ATTRS(handle);
200 player = MM_PLAYER_CAST(handle);
202 if ( g_strrstr(attribute_name, "display") )
204 /* check videosink element is created */
205 if ( !player->pipeline ||
206 !player->pipeline->videobin ||
207 !player->pipeline->videobin[MMPLAYER_V_SINK].gst )
209 debug_warning("videosink element is not yet ready");
211 * The attribute should be committed even though videobin is not created yet.
212 * So, true should be returned here.
213 * Otherwise, video can be diaplayed abnormal.
215 return MM_ERROR_NONE;
218 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
220 debug_error("failed to update video param");
221 return MM_ERROR_PLAYER_INTERNAL;
227 return MM_ERROR_NONE;
231 _mmplayer_construct_attribute(MMHandleType handle)
234 MMHandleType attrs = 0;
235 int num_of_attrs = 0;
236 mmf_attrs_construct_info_t *base = NULL;
237 gchar *system_ua = NULL;
238 gchar *system_proxy = NULL;
242 return_val_if_fail (handle, 0);
244 MMPlayerAttrsSpec player_attrs[] =
247 "profile_uri", // name
248 MM_ATTRS_TYPE_STRING, // type
249 MM_ATTRS_FLAG_RW, // flag
250 (void *) NULL, // default value
251 MM_ATTRS_VALID_TYPE_NONE, // validity type
252 0, // validity min value
253 0 // validity max value
256 "profile_user_param",
260 MM_ATTRS_VALID_TYPE_NONE,
265 "profile_play_count",
268 (void *) 1, // -1 : repeat continually
269 MM_ATTRS_VALID_TYPE_INT_RANGE,
274 "profile_prepare_async",
278 MM_ATTRS_VALID_TYPE_INT_RANGE,
282 { /* update registry for downloadable codec */
283 "profile_update_registry",
287 MM_ATTRS_VALID_TYPE_INT_RANGE,
295 (void *) STREAMING_SERVICE_NONE,
296 MM_ATTRS_VALID_TYPE_INT_RANGE,
297 STREAMING_SERVICE_VOD,
298 STREAMING_SERVICE_NUM
301 "streaming_udp_timeout",
305 MM_ATTRS_VALID_TYPE_INT_RANGE,
310 "streaming_user_agent",
311 MM_ATTRS_TYPE_STRING,
314 MM_ATTRS_VALID_TYPE_NONE,
319 "streaming_wap_profile",
320 MM_ATTRS_TYPE_STRING,
323 MM_ATTRS_VALID_TYPE_NONE,
328 "streaming_network_bandwidth",
332 MM_ATTRS_VALID_TYPE_INT_RANGE,
338 MM_ATTRS_TYPE_STRING,
341 MM_ATTRS_VALID_TYPE_NONE,
347 MM_ATTRS_TYPE_STRING,
350 MM_ATTRS_VALID_TYPE_NONE,
356 MM_ATTRS_TYPE_STRING,
359 MM_ATTRS_VALID_TYPE_NONE,
368 MM_ATTRS_VALID_TYPE_INT_RANGE,
377 MM_ATTRS_VALID_TYPE_INT_RANGE,
382 "content_max_bitrate",
386 MM_ATTRS_VALID_TYPE_INT_RANGE,
391 "content_video_found",
395 MM_ATTRS_VALID_TYPE_INT_RANGE,
400 "content_video_codec",
401 MM_ATTRS_TYPE_STRING,
404 MM_ATTRS_VALID_TYPE_NONE,
409 "content_video_bitrate",
413 MM_ATTRS_VALID_TYPE_INT_RANGE,
422 MM_ATTRS_VALID_TYPE_INT_RANGE,
427 "content_video_width",
431 MM_ATTRS_VALID_TYPE_INT_RANGE,
436 "content_video_height",
440 MM_ATTRS_VALID_TYPE_INT_RANGE,
445 "content_video_track_num",
449 MM_ATTRS_VALID_TYPE_INT_RANGE,
454 "content_audio_found",
458 MM_ATTRS_VALID_TYPE_INT_RANGE,
463 "content_audio_codec",
464 MM_ATTRS_TYPE_STRING,
467 MM_ATTRS_VALID_TYPE_NONE,
472 "content_audio_bitrate",
476 MM_ATTRS_VALID_TYPE_INT_RANGE,
481 "content_audio_channels",
485 MM_ATTRS_VALID_TYPE_INT_RANGE,
490 "content_audio_samplerate",
494 MM_ATTRS_VALID_TYPE_INT_RANGE,
499 "content_audio_track_num",
503 MM_ATTRS_VALID_TYPE_INT_RANGE,
508 "content_audio_format",
512 MM_ATTRS_VALID_TYPE_INT_RANGE,
518 MM_ATTRS_TYPE_STRING,
521 MM_ATTRS_VALID_TYPE_NONE,
527 MM_ATTRS_TYPE_STRING,
530 MM_ATTRS_VALID_TYPE_NONE,
536 MM_ATTRS_TYPE_STRING,
542 MM_ATTRS_TYPE_STRING,
545 MM_ATTRS_VALID_TYPE_NONE,
551 MM_ATTRS_TYPE_STRING,
554 MM_ATTRS_VALID_TYPE_NONE,
560 MM_ATTRS_TYPE_STRING,
563 MM_ATTRS_VALID_TYPE_NONE,
569 MM_ATTRS_TYPE_STRING,
572 MM_ATTRS_VALID_TYPE_NONE,
578 MM_ATTRS_TYPE_STRING,
581 MM_ATTRS_VALID_TYPE_NONE,
590 MM_ATTRS_VALID_TYPE_INT_RANGE,
599 MM_ATTRS_VALID_TYPE_NONE,
608 MM_ATTRS_VALID_TYPE_INT_RANGE,
617 MM_ATTRS_VALID_TYPE_INT_RANGE,
626 MM_ATTRS_VALID_TYPE_INT_RANGE,
631 "display_roi_height",
635 MM_ATTRS_VALID_TYPE_INT_RANGE,
643 (void *) MM_DISPLAY_ROTATION_NONE,
644 MM_ATTRS_VALID_TYPE_INT_RANGE,
645 MM_DISPLAY_ROTATION_NONE,
646 MM_DISPLAY_ROTATION_270
653 MM_ATTRS_VALID_TYPE_INT_RANGE,
661 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
662 MM_ATTRS_VALID_TYPE_INT_RANGE,
663 MM_DISPLAY_METHOD_LETTER_BOX,
664 MM_DISPLAY_METHOD_CUSTOM_ROI
671 MM_ATTRS_VALID_TYPE_NONE,
676 "display_overlay_user_data",
680 MM_ATTRS_VALID_TYPE_NONE,
689 MM_ATTRS_VALID_TYPE_INT_RANGE,
694 "display_surface_type",
697 (void *) MM_DISPLAY_SURFACE_NULL,
698 MM_ATTRS_VALID_TYPE_INT_RANGE,
699 MM_DISPLAY_SURFACE_X,
700 MM_DISPLAY_SURFACE_X_EXT
703 "display_evas_surface_sink",
704 MM_ATTRS_TYPE_STRING,
705 MM_ATTRS_FLAG_READABLE,
706 (void *) PLAYER_INI()->videosink_element_evas,
707 MM_ATTRS_VALID_TYPE_NONE,
712 "display_force_aspect_ration",
716 MM_ATTRS_VALID_TYPE_INT_RANGE,
721 "display_width", // dest width of fimcconvert ouput
725 MM_ATTRS_VALID_TYPE_INT_RANGE,
730 "display_height", // dest height of fimcconvert ouput
734 MM_ATTRS_VALID_TYPE_INT_RANGE,
739 "display_evas_do_scaling",
743 MM_ATTRS_VALID_TYPE_INT_RANGE,
752 MM_ATTRS_VALID_TYPE_INT_RANGE,
761 MM_ATTRS_VALID_TYPE_INT_RANGE,
769 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
770 MM_ATTRS_VALID_TYPE_INT_RANGE,
771 MM_SOUND_VOLUME_TYPE_SYSTEM,
772 MM_SOUND_VOLUME_TYPE_CALL
778 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
779 MM_ATTRS_VALID_TYPE_INT_RANGE,
780 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
781 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
784 "sound_stop_when_unplugged",
788 MM_ATTRS_VALID_TYPE_INT_RANGE,
793 "sound_application_pid",
797 MM_ATTRS_VALID_TYPE_INT_RANGE,
802 "sound_spk_out_only",
806 MM_ATTRS_VALID_TYPE_INT_RANGE,
814 (void *) 0, // 0: normal, 1: high 2: high with sound transition
815 MM_ATTRS_VALID_TYPE_INT_RANGE,
820 "audio_latency_mode",
823 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
824 MM_ATTRS_VALID_TYPE_INT_RANGE,
829 "pcm_extraction", // enable pcm extraction
833 MM_ATTRS_VALID_TYPE_INT_RANGE,
838 "pcm_extraction_samplerate", // set samplerate for pcm extraction
842 MM_ATTRS_VALID_TYPE_INT_RANGE,
847 "pcm_extraction_depth", // set depth for pcm extraction
851 MM_ATTRS_VALID_TYPE_INT_RANGE,
856 "pcm_extraction_channels", // set channels for pcm extraction
860 MM_ATTRS_VALID_TYPE_INT_RANGE,
865 "pcm_extraction_start_msec", // set start position to extract pcm
869 MM_ATTRS_VALID_TYPE_INT_RANGE,
874 "pcm_extraction_end_msec", // set end position to extract pcm
878 MM_ATTRS_VALID_TYPE_INT_RANGE,
883 "profile_smooth_repeat",
887 MM_ATTRS_VALID_TYPE_INT_RANGE,
892 "profile_progress_interval", // will be deprecated
896 MM_ATTRS_VALID_TYPE_INT_RANGE,
905 MM_ATTRS_VALID_TYPE_INT_RANGE,
914 MM_ATTRS_VALID_TYPE_INT_RANGE,
922 (void *) MM_PLAYER_PD_MODE_NONE,
923 MM_ATTRS_VALID_TYPE_INT_RANGE,
924 MM_PLAYER_PD_MODE_NONE,
925 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
928 "pd_location", // location of the file to write
929 MM_ATTRS_TYPE_STRING,
932 MM_ATTRS_VALID_TYPE_NONE,
938 num_of_attrs = ARRAY_SIZE(player_attrs);
940 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
944 debug_error("failed to alloc attrs constructor");
948 /* initialize values of attributes */
949 for ( idx = 0; idx < num_of_attrs; idx++ )
951 base[idx].name = player_attrs[idx].name;
952 base[idx].value_type = player_attrs[idx].value_type;
953 base[idx].flags = player_attrs[idx].flags;
954 base[idx].default_value = player_attrs[idx].default_value;
957 attrs = mmf_attrs_new_from_data(
965 MMPLAYER_FREEIF(base);
969 debug_error("failed to create player attrs");
973 /* set validity type and range */
974 for ( idx = 0; idx < num_of_attrs; idx++ )
976 switch ( player_attrs[idx].valid_type)
978 case MM_ATTRS_VALID_TYPE_INT_RANGE:
980 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
981 mmf_attrs_set_valid_range (attrs, idx,
982 player_attrs[idx].value_min,
983 player_attrs[idx].value_max,
984 player_attrs[idx].default_value);
988 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
989 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
990 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
996 /* set proxy and user agent */
997 system_ua = vconf_get_str(VCONFKEY_ADMIN_UAGENT);
998 system_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
1002 mm_attrs_set_string_by_name(attrs, "streaming_user_agent", system_ua);
1008 mm_attrs_set_string_by_name(attrs, "streaming_proxy", system_proxy);
1009 g_free(system_proxy);
1013 mmf_attrs_commit(attrs);
1021 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1025 mm_player_t *player = MM_PLAYER_CAST(handle);
1027 return_val_if_fail ( player, FALSE );
1031 mmf_attrs_free (player->attrs);