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 "mm_player_utils.h"
32 #include "mm_player_priv.h"
33 #include "mm_player_attrs.h"
35 /*===========================================================================================
37 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
39 ========================================================================================== */
41 /*---------------------------------------------------------------------------
42 | LOCAL FUNCTION PROTOTYPES: |
43 ---------------------------------------------------------------------------*/
45 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name);
47 /*===========================================================================================
49 | FUNCTION DEFINITIONS |
51 ========================================================================================== */
54 _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
56 int result = MM_ERROR_NONE;
57 MMHandleType attrs = 0;
59 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
60 /* if it's not want to know it. */
61 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
62 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
64 attrs = MM_PLAYER_GET_ATTRS(handle);
66 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
68 if ( result != MM_ERROR_NONE)
69 LOGE("failed to get %s attribute\n", attribute_name);
75 _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
77 int result = MM_ERROR_NONE;
78 MMHandleType attrs = 0;
80 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
81 /* if it's not want to know it. */
82 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
83 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
85 attrs = MM_PLAYER_GET_ATTRS(handle);
87 /* set attributes and commit them */
88 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
90 if (result != MM_ERROR_NONE)
92 LOGE("failed to set %s attribute\n", attribute_name);
96 result = __mmplayer_apply_attribute(handle, attribute_name);
97 if (result != MM_ERROR_NONE)
99 LOGE("failed to apply attributes\n");
107 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
109 int result = MM_ERROR_NONE;
110 MMHandleType attrs = 0;
111 MMAttrsInfo src_info = {0, };
113 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
114 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
115 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
117 attrs = MM_PLAYER_GET_ATTRS(handle);
119 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
121 if ( result != MM_ERROR_NONE)
123 LOGE("failed to get attribute info\n");
127 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
129 dst_info->type = src_info.type;
130 dst_info->flag = src_info.flag;
131 dst_info->validity_type= src_info.validity_type;
133 switch(src_info.validity_type)
135 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
136 dst_info->int_array.array = src_info.int_array.array;
137 dst_info->int_array.count = src_info.int_array.count;
138 dst_info->int_array.d_val = src_info.int_array.dval;
141 case MM_ATTRS_VALID_TYPE_INT_RANGE:
142 dst_info->int_range.min = src_info.int_range.min;
143 dst_info->int_range.max = src_info.int_range.max;
144 dst_info->int_range.d_val = src_info.int_range.dval;
147 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
148 dst_info->double_array.array = src_info.double_array.array;
149 dst_info->double_array.count = src_info.double_array.count;
150 dst_info->double_array.d_val = src_info.double_array.dval;
153 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
154 dst_info->double_range.min = src_info.double_range.min;
155 dst_info->double_range.max = src_info.double_range.max;
156 dst_info->double_range.d_val = src_info.double_range.dval;
167 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
169 mm_player_t* player = 0;
171 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
172 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
174 player = MM_PLAYER_CAST(handle);
176 if ( g_strrstr(attribute_name, "display") )
178 int pipeline_type = 0;
179 MMPlayerGstPipelineInfo *pipeline = player->pipeline;
181 /* check videosink element is created */
183 return MM_ERROR_NONE;
184 mm_attrs_get_int_by_name(player->attrs, "pipeline_type", &pipeline_type);
185 if (pipeline_type == MM_PLAYER_PIPELINE_CLIENT) {
186 if(!pipeline->mainbin || !pipeline->mainbin[MMPLAYER_M_V_SINK].gst)
187 return MM_ERROR_NONE;
189 if(!pipeline->videobin || !pipeline->videobin[MMPLAYER_V_SINK].gst)
190 return MM_ERROR_NONE;
193 if ( MM_ERROR_NONE != _mmplayer_update_video_param( player ) )
195 LOGE("failed to update video param");
196 return MM_ERROR_PLAYER_INTERNAL;
200 return MM_ERROR_NONE;
204 _mmplayer_construct_attribute(MMHandleType handle)
206 mm_player_t *player = NULL;
208 MMHandleType attrs = 0;
209 int num_of_attrs = 0;
210 mmf_attrs_construct_info_t *base = NULL;
212 MMPLAYER_RETURN_VAL_IF_FAIL (handle, 0);
214 player = MM_PLAYER_CAST(handle);
216 MMPlayerAttrsSpec player_attrs[] =
219 "profile_uri", // name
220 MM_ATTRS_TYPE_STRING, // type
221 MM_ATTRS_FLAG_RW, // flag
222 (void *) NULL, // default value
223 MM_ATTRS_VALID_TYPE_NONE, // validity type
224 0, // validity min value
225 0 // validity max value
228 "profile_user_param",
232 MM_ATTRS_VALID_TYPE_NONE,
237 "profile_play_count",
240 (void *) 1, // -1 : repeat continually
241 MM_ATTRS_VALID_TYPE_INT_RANGE,
246 "profile_prepare_async",
250 MM_ATTRS_VALID_TYPE_INT_RANGE,
254 { /* update registry for downloadable codec */
255 "profile_update_registry",
259 MM_ATTRS_VALID_TYPE_INT_RANGE,
267 (void *) STREAMING_SERVICE_NONE,
268 MM_ATTRS_VALID_TYPE_INT_RANGE,
269 STREAMING_SERVICE_VOD,
270 STREAMING_SERVICE_NUM
273 "streaming_udp_timeout",
277 MM_ATTRS_VALID_TYPE_INT_RANGE,
282 "streaming_user_agent",
283 MM_ATTRS_TYPE_STRING,
286 MM_ATTRS_VALID_TYPE_NONE,
291 "streaming_wap_profile",
292 MM_ATTRS_TYPE_STRING,
295 MM_ATTRS_VALID_TYPE_NONE,
300 "streaming_network_bandwidth",
304 MM_ATTRS_VALID_TYPE_INT_RANGE,
310 MM_ATTRS_TYPE_STRING,
313 MM_ATTRS_VALID_TYPE_NONE,
319 MM_ATTRS_TYPE_STRING,
322 MM_ATTRS_VALID_TYPE_NONE,
330 (void *) -1, // DEFAULT_HTTP_TIMEOUT
331 MM_ATTRS_VALID_TYPE_INT_RANGE,
337 MM_ATTRS_TYPE_STRING,
340 MM_ATTRS_VALID_TYPE_NONE,
349 MM_ATTRS_VALID_TYPE_INT_RANGE,
358 MM_ATTRS_VALID_TYPE_INT_RANGE,
363 "content_max_bitrate",
367 MM_ATTRS_VALID_TYPE_INT_RANGE,
372 "content_video_found",
376 MM_ATTRS_VALID_TYPE_INT_RANGE,
381 "content_video_codec",
382 MM_ATTRS_TYPE_STRING,
385 MM_ATTRS_VALID_TYPE_NONE,
390 "content_video_bitrate",
394 MM_ATTRS_VALID_TYPE_INT_RANGE,
403 MM_ATTRS_VALID_TYPE_INT_RANGE,
408 "content_video_width",
412 MM_ATTRS_VALID_TYPE_INT_RANGE,
417 "content_video_height",
421 MM_ATTRS_VALID_TYPE_INT_RANGE,
426 "content_video_track_num",
430 MM_ATTRS_VALID_TYPE_INT_RANGE,
435 "content_audio_found",
439 MM_ATTRS_VALID_TYPE_INT_RANGE,
444 "content_audio_codec",
445 MM_ATTRS_TYPE_STRING,
448 MM_ATTRS_VALID_TYPE_NONE,
453 "content_audio_bitrate",
457 MM_ATTRS_VALID_TYPE_INT_RANGE,
462 "content_audio_channels",
466 MM_ATTRS_VALID_TYPE_INT_RANGE,
471 "content_audio_samplerate",
475 MM_ATTRS_VALID_TYPE_INT_RANGE,
480 "content_audio_track_num",
484 MM_ATTRS_VALID_TYPE_INT_RANGE,
489 "content_audio_format",
493 MM_ATTRS_VALID_TYPE_INT_RANGE,
498 "content_text_track_num",
502 MM_ATTRS_VALID_TYPE_INT_RANGE,
508 MM_ATTRS_TYPE_STRING,
511 MM_ATTRS_VALID_TYPE_NONE,
517 MM_ATTRS_TYPE_STRING,
520 MM_ATTRS_VALID_TYPE_NONE,
526 MM_ATTRS_TYPE_STRING,
532 MM_ATTRS_TYPE_STRING,
535 MM_ATTRS_VALID_TYPE_NONE,
541 MM_ATTRS_TYPE_STRING,
544 MM_ATTRS_VALID_TYPE_NONE,
550 MM_ATTRS_TYPE_STRING,
553 MM_ATTRS_VALID_TYPE_NONE,
559 MM_ATTRS_TYPE_STRING,
562 MM_ATTRS_VALID_TYPE_NONE,
568 MM_ATTRS_TYPE_STRING,
571 MM_ATTRS_VALID_TYPE_NONE,
580 MM_ATTRS_VALID_TYPE_INT_RANGE,
589 MM_ATTRS_VALID_TYPE_NONE,
594 "display_src_crop_x",
598 MM_ATTRS_VALID_TYPE_INT_RANGE,
603 "display_src_crop_y",
607 MM_ATTRS_VALID_TYPE_INT_RANGE,
612 "display_src_crop_width",
616 MM_ATTRS_VALID_TYPE_INT_RANGE,
621 "display_src_crop_height",
625 MM_ATTRS_VALID_TYPE_INT_RANGE,
634 MM_ATTRS_VALID_TYPE_INT_RANGE,
643 MM_ATTRS_VALID_TYPE_INT_RANGE,
652 MM_ATTRS_VALID_TYPE_INT_RANGE,
657 "display_roi_height",
661 MM_ATTRS_VALID_TYPE_INT_RANGE,
669 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
670 MM_ATTRS_VALID_TYPE_INT_RANGE,
671 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
672 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
678 (void *) MM_DISPLAY_ROTATION_NONE,
679 MM_ATTRS_VALID_TYPE_INT_RANGE,
680 MM_DISPLAY_ROTATION_NONE,
681 MM_DISPLAY_ROTATION_270
688 MM_ATTRS_VALID_TYPE_INT_RANGE,
696 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
697 MM_ATTRS_VALID_TYPE_INT_RANGE,
698 MM_DISPLAY_METHOD_LETTER_BOX,
699 MM_DISPLAY_METHOD_CUSTOM_ROI
706 MM_ATTRS_VALID_TYPE_NONE,
716 MM_ATTRS_VALID_TYPE_NONE,
721 "wl_window_render_x",
725 MM_ATTRS_VALID_TYPE_INT_RANGE,
730 "wl_window_render_y",
734 MM_ATTRS_VALID_TYPE_INT_RANGE,
739 "wl_window_render_width",
743 MM_ATTRS_VALID_TYPE_INT_RANGE,
748 "wl_window_render_height",
752 MM_ATTRS_VALID_TYPE_INT_RANGE,
761 MM_ATTRS_VALID_TYPE_INT_RANGE,
768 "display_overlay_user_data",
772 MM_ATTRS_VALID_TYPE_NONE,
777 "display_surface_type",
780 (void *) MM_DISPLAY_SURFACE_NULL,
781 MM_ATTRS_VALID_TYPE_INT_RANGE,
782 MM_DISPLAY_SURFACE_OVERLAY,
783 MM_DISPLAY_SURFACE_NUM - 1
786 "display_evas_surface_sink",
787 MM_ATTRS_TYPE_STRING,
788 MM_ATTRS_FLAG_READABLE,
789 (void *) player->ini.videosink_element_evas,
790 MM_ATTRS_VALID_TYPE_NONE,
795 "display_force_aspect_ration",
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
804 "display_width", // dest width of fimcconvert ouput
808 MM_ATTRS_VALID_TYPE_INT_RANGE,
813 "display_height", // dest height of fimcconvert ouput
817 MM_ATTRS_VALID_TYPE_INT_RANGE,
822 "display_evas_do_scaling",
826 MM_ATTRS_VALID_TYPE_INT_RANGE,
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
844 MM_ATTRS_VALID_TYPE_INT_RANGE,
852 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
853 MM_ATTRS_VALID_TYPE_INT_RANGE,
859 MM_ATTRS_TYPE_STRING,
862 MM_ATTRS_VALID_TYPE_NONE,
867 "sound_stream_index",
871 MM_ATTRS_VALID_TYPE_INT_RANGE,
879 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
880 MM_ATTRS_VALID_TYPE_INT_RANGE,
881 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
882 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
885 "sound_stop_when_unplugged",
889 MM_ATTRS_VALID_TYPE_INT_RANGE,
894 "sound_application_pid",
898 MM_ATTRS_VALID_TYPE_INT_RANGE,
903 "sound_spk_out_only",
907 MM_ATTRS_VALID_TYPE_INT_RANGE,
915 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
916 MM_ATTRS_VALID_TYPE_INT_RANGE,
921 "sound_close_resource",
925 MM_ATTRS_VALID_TYPE_INT_RANGE,
930 "sound_latency_mode",
933 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
934 MM_ATTRS_VALID_TYPE_INT_RANGE,
939 "pcm_extraction", // enable pcm extraction
943 MM_ATTRS_VALID_TYPE_INT_RANGE,
948 "pcm_extraction_samplerate", // set samplerate for pcm extraction
951 (void *) 44100, // hz
952 MM_ATTRS_VALID_TYPE_INT_RANGE,
957 "pcm_extraction_depth", // set depth for pcm extraction
961 MM_ATTRS_VALID_TYPE_INT_RANGE,
966 "pcm_extraction_channels", // set channels for pcm extraction
970 MM_ATTRS_VALID_TYPE_INT_RANGE,
975 "pcm_extraction_start_msec", // set start position to extract pcm
979 MM_ATTRS_VALID_TYPE_INT_RANGE,
984 "pcm_extraction_end_msec", // set end position to extract pcm
988 MM_ATTRS_VALID_TYPE_INT_RANGE,
993 "profile_smooth_repeat",
997 MM_ATTRS_VALID_TYPE_INT_RANGE,
1002 "profile_progress_interval", // will be deprecated
1006 MM_ATTRS_VALID_TYPE_INT_RANGE,
1015 MM_ATTRS_VALID_TYPE_INT_RANGE,
1024 MM_ATTRS_VALID_TYPE_INT_RANGE,
1032 (void *) MM_PLAYER_PD_MODE_NONE,
1033 MM_ATTRS_VALID_TYPE_INT_RANGE,
1034 MM_PLAYER_PD_MODE_NONE,
1035 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
1038 "pd_location", // location of the file to write
1039 MM_ATTRS_TYPE_STRING,
1042 MM_ATTRS_VALID_TYPE_NONE,
1051 MM_ATTRS_VALID_TYPE_INT_RANGE,
1056 "content_video_orientation", // orientation of video content
1057 MM_ATTRS_TYPE_STRING,
1060 MM_ATTRS_VALID_TYPE_NONE,
1066 MM_ATTRS_TYPE_STRING,
1069 MM_ATTRS_VALID_TYPE_NONE,
1074 "display_surface_client_type",
1077 (void *) MM_DISPLAY_SURFACE_NULL,
1078 MM_ATTRS_VALID_TYPE_INT_RANGE,
1079 MM_DISPLAY_SURFACE_OVERLAY,
1080 MM_DISPLAY_SURFACE_NUM - 1
1086 (void *) MM_PLAYER_PIPELINE_LEGACY,
1087 MM_ATTRS_VALID_TYPE_INT_RANGE,
1088 MM_PLAYER_PIPELINE_LEGACY,
1089 MM_PLAYER_PIPELINE_MAX - 1
1096 MM_ATTRS_VALID_TYPE_INT_RANGE,
1105 MM_ATTRS_VALID_TYPE_INT_RANGE,
1111 num_of_attrs = ARRAY_SIZE(player_attrs);
1113 base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1117 LOGE("failed to alloc attrs constructor");
1121 /* initialize values of attributes */
1122 for ( idx = 0; idx < num_of_attrs; idx++ )
1124 base[idx].name = player_attrs[idx].name;
1125 base[idx].value_type = player_attrs[idx].value_type;
1126 base[idx].flags = player_attrs[idx].flags;
1127 base[idx].default_value = player_attrs[idx].default_value;
1130 attrs = mmf_attrs_new_from_data(
1138 MMPLAYER_FREEIF(base);
1142 LOGE("failed to create player attrs");
1146 /* set validity type and range */
1147 for ( idx = 0; idx < num_of_attrs; idx++ )
1149 switch ( player_attrs[idx].valid_type)
1151 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1153 mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1154 mmf_attrs_set_valid_range (attrs, idx,
1155 player_attrs[idx].value_min,
1156 player_attrs[idx].value_max,
1157 (int)(intptr_t)(player_attrs[idx].default_value));
1161 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1162 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1163 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1170 mmf_attrs_commit(attrs);
1176 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1178 mm_player_t *player = MM_PLAYER_CAST(handle);
1180 MMPLAYER_RETURN_VAL_IF_FAIL ( player, FALSE );
1184 mmf_attrs_free (player->attrs);