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) {
91 LOGE("failed to set %s attribute\n", attribute_name);
95 result = __mmplayer_apply_attribute(handle, attribute_name);
96 if (result != MM_ERROR_NONE) {
97 LOGE("failed to apply attributes\n");
105 _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *dst_info)
107 int result = MM_ERROR_NONE;
108 MMHandleType attrs = 0;
109 MMAttrsInfo src_info = {0, };
111 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
112 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
113 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
115 attrs = MM_PLAYER_GET_ATTRS(handle);
117 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
119 if (result != MM_ERROR_NONE) {
120 LOGE("failed to get attribute info\n");
124 memset(dst_info, 0x00, sizeof(MMPlayerAttrsInfo));
126 dst_info->type = src_info.type;
127 dst_info->flag = src_info.flag;
128 dst_info->validity_type = src_info.validity_type;
130 switch (src_info.validity_type) {
131 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
132 dst_info->int_array.array = src_info.int_array.array;
133 dst_info->int_array.count = src_info.int_array.count;
134 dst_info->int_array.d_val = src_info.int_array.dval;
137 case MM_ATTRS_VALID_TYPE_INT_RANGE:
138 dst_info->int_range.min = src_info.int_range.min;
139 dst_info->int_range.max = src_info.int_range.max;
140 dst_info->int_range.d_val = src_info.int_range.dval;
143 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
144 dst_info->double_array.array = src_info.double_array.array;
145 dst_info->double_array.count = src_info.double_array.count;
146 dst_info->double_array.d_val = src_info.double_array.dval;
149 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
150 dst_info->double_range.min = src_info.double_range.min;
151 dst_info->double_range.max = src_info.double_range.max;
152 dst_info->double_range.d_val = src_info.double_range.dval;
163 __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
165 mm_player_t* player = 0;
167 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
168 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
170 player = MM_PLAYER_CAST(handle);
171 MMPlayerGstPipelineInfo *pipeline = player->pipeline;
173 /* Currently, there are only display related implementation at below */
175 !pipeline->videobin ||
176 !pipeline->videobin[MMPLAYER_V_SINK].gst) {
178 * The attribute should be committed even though videobin is not created yet.
179 * So, true should be returned here.
180 * Otherwise, video can be diaplayed abnormal.
182 return MM_ERROR_NONE;
185 if (g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x")) {
186 char *param_name = NULL;
187 int str_len = strlen(attribute_name);
188 param_name = g_malloc0(str_len);
190 LOGE("failed to alloc param_name");
191 return MM_ERROR_PLAYER_INTERNAL;
193 strncpy(param_name, attribute_name, str_len);
194 LOGD(" param_name: %s", param_name);
195 if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
197 LOGE("failed to update video param");
198 return MM_ERROR_PLAYER_INTERNAL;
203 if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
206 mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
209 LOGD("disable last-sample at videosink");
210 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
214 if (g_strrstr(attribute_name, MM_PLAYER_ENABLE_VIDEO_DECODED_CB)) {
215 if (!player->set_mode.media_packet_video_stream) {
216 LOGE("there is no callback for media_packet");
217 return MM_ERROR_PLAYER_INTERNAL;
220 mm_attrs_get_int_by_name(player->attrs, "enable_video_decoded_cb", &enable);
221 g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "signal-handoffs", enable ? TRUE : FALSE, NULL);
224 return MM_ERROR_NONE;
228 _mmplayer_construct_attribute(MMHandleType handle)
231 MMHandleType attrs = 0;
232 int num_of_attrs = 0;
233 mmf_attrs_construct_info_t *base = NULL;
235 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
237 MMPlayerAttrsSpec player_attrs[] = {
239 "profile_uri", // name
240 MM_ATTRS_TYPE_STRING, // type
241 MM_ATTRS_FLAG_RW, // flag
242 (void *) NULL, // default value
243 MM_ATTRS_VALID_TYPE_NONE, // validity type
244 0, // validity min value
245 0 // validity max value
248 "profile_user_param",
252 MM_ATTRS_VALID_TYPE_NONE,
257 "profile_play_count",
260 (void *) 1, // -1 : repeat continually
261 MM_ATTRS_VALID_TYPE_INT_RANGE,
266 "profile_prepare_async",
270 MM_ATTRS_VALID_TYPE_INT_RANGE,
274 { /* update registry for downloadable codec */
275 "profile_update_registry",
279 MM_ATTRS_VALID_TYPE_INT_RANGE,
287 (void *) STREAMING_SERVICE_NONE,
288 MM_ATTRS_VALID_TYPE_INT_RANGE,
289 STREAMING_SERVICE_VOD,
290 STREAMING_SERVICE_NUM
293 "streaming_udp_timeout",
297 MM_ATTRS_VALID_TYPE_INT_RANGE,
302 "streaming_user_agent",
303 MM_ATTRS_TYPE_STRING,
306 MM_ATTRS_VALID_TYPE_NONE,
311 "streaming_wap_profile",
312 MM_ATTRS_TYPE_STRING,
315 MM_ATTRS_VALID_TYPE_NONE,
320 "streaming_network_bandwidth",
324 MM_ATTRS_VALID_TYPE_INT_RANGE,
330 MM_ATTRS_TYPE_STRING,
333 MM_ATTRS_VALID_TYPE_NONE,
339 MM_ATTRS_TYPE_STRING,
342 MM_ATTRS_VALID_TYPE_NONE,
350 (void *) -1, // DEFAULT_HTTP_TIMEOUT
351 MM_ATTRS_VALID_TYPE_INT_RANGE,
357 MM_ATTRS_TYPE_STRING,
360 MM_ATTRS_VALID_TYPE_NONE,
369 MM_ATTRS_VALID_TYPE_INT_RANGE,
378 MM_ATTRS_VALID_TYPE_INT_RANGE,
383 "content_max_bitrate",
387 MM_ATTRS_VALID_TYPE_INT_RANGE,
392 "content_video_found",
396 MM_ATTRS_VALID_TYPE_INT_RANGE,
401 "content_video_codec",
402 MM_ATTRS_TYPE_STRING,
405 MM_ATTRS_VALID_TYPE_NONE,
410 "content_video_bitrate",
414 MM_ATTRS_VALID_TYPE_INT_RANGE,
423 MM_ATTRS_VALID_TYPE_INT_RANGE,
428 "content_video_width",
432 MM_ATTRS_VALID_TYPE_INT_RANGE,
437 "content_video_height",
441 MM_ATTRS_VALID_TYPE_INT_RANGE,
446 "content_video_track_num",
450 MM_ATTRS_VALID_TYPE_INT_RANGE,
455 "content_audio_found",
459 MM_ATTRS_VALID_TYPE_INT_RANGE,
464 "content_audio_codec",
465 MM_ATTRS_TYPE_STRING,
468 MM_ATTRS_VALID_TYPE_NONE,
473 "content_audio_bitrate",
477 MM_ATTRS_VALID_TYPE_INT_RANGE,
482 "content_audio_channels",
486 MM_ATTRS_VALID_TYPE_INT_RANGE,
491 "content_audio_samplerate",
495 MM_ATTRS_VALID_TYPE_INT_RANGE,
500 "content_audio_track_num",
504 MM_ATTRS_VALID_TYPE_INT_RANGE,
509 "content_audio_format",
513 MM_ATTRS_VALID_TYPE_INT_RANGE,
518 "content_text_track_num",
522 MM_ATTRS_VALID_TYPE_INT_RANGE,
528 MM_ATTRS_TYPE_STRING,
531 MM_ATTRS_VALID_TYPE_NONE,
537 MM_ATTRS_TYPE_STRING,
540 MM_ATTRS_VALID_TYPE_NONE,
546 MM_ATTRS_TYPE_STRING,
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,
588 MM_ATTRS_TYPE_STRING,
591 MM_ATTRS_VALID_TYPE_NONE,
600 MM_ATTRS_VALID_TYPE_INT_RANGE,
609 MM_ATTRS_VALID_TYPE_NONE,
614 "display_src_crop_x",
618 MM_ATTRS_VALID_TYPE_INT_RANGE,
623 "display_src_crop_y",
627 MM_ATTRS_VALID_TYPE_INT_RANGE,
632 "display_src_crop_width",
636 MM_ATTRS_VALID_TYPE_INT_RANGE,
641 "display_src_crop_height",
645 MM_ATTRS_VALID_TYPE_INT_RANGE,
654 MM_ATTRS_VALID_TYPE_INT_RANGE,
663 MM_ATTRS_VALID_TYPE_INT_RANGE,
672 MM_ATTRS_VALID_TYPE_INT_RANGE,
677 "display_roi_height",
681 MM_ATTRS_VALID_TYPE_INT_RANGE,
689 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
690 MM_ATTRS_VALID_TYPE_INT_RANGE,
691 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
692 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX
698 (void *) MM_DISPLAY_ROTATION_NONE,
699 MM_ATTRS_VALID_TYPE_INT_RANGE,
700 MM_DISPLAY_ROTATION_NONE,
701 MM_DISPLAY_ROTATION_270
708 MM_ATTRS_VALID_TYPE_INT_RANGE,
716 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
717 MM_ATTRS_VALID_TYPE_INT_RANGE,
718 MM_DISPLAY_METHOD_LETTER_BOX,
719 MM_DISPLAY_METHOD_CUSTOM_ROI
726 MM_ATTRS_VALID_TYPE_NONE,
735 MM_ATTRS_VALID_TYPE_NONE,
740 "wl_window_render_x",
744 MM_ATTRS_VALID_TYPE_INT_RANGE,
749 "wl_window_render_y",
753 MM_ATTRS_VALID_TYPE_INT_RANGE,
758 "wl_window_render_width",
762 MM_ATTRS_VALID_TYPE_INT_RANGE,
767 "wl_window_render_height",
771 MM_ATTRS_VALID_TYPE_INT_RANGE,
780 MM_ATTRS_VALID_TYPE_INT_RANGE,
785 "display_overlay_user_data",
789 MM_ATTRS_VALID_TYPE_NONE,
794 "display_surface_type",
797 (void *) MM_DISPLAY_SURFACE_NULL,
798 MM_ATTRS_VALID_TYPE_INT_RANGE,
799 MM_DISPLAY_SURFACE_OVERLAY,
800 MM_DISPLAY_SURFACE_NUM - 1
803 "display_force_aspect_ration",
807 MM_ATTRS_VALID_TYPE_INT_RANGE,
812 "display_width", // dest width of fimcconvert ouput
816 MM_ATTRS_VALID_TYPE_INT_RANGE,
821 "display_height", // dest height of fimcconvert ouput
825 MM_ATTRS_VALID_TYPE_INT_RANGE,
830 "display_evas_do_scaling",
834 MM_ATTRS_VALID_TYPE_INT_RANGE,
843 MM_ATTRS_VALID_TYPE_INT_RANGE,
852 MM_ATTRS_VALID_TYPE_INT_RANGE,
860 (void *) MM_SOUND_VOLUME_TYPE_MEDIA,
861 MM_ATTRS_VALID_TYPE_INT_RANGE,
867 MM_ATTRS_TYPE_STRING,
870 MM_ATTRS_VALID_TYPE_NONE,
875 "sound_stream_index",
879 MM_ATTRS_VALID_TYPE_INT_RANGE,
887 (void *) MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
888 MM_ATTRS_VALID_TYPE_INT_RANGE,
889 MM_AUDIOROUTE_USE_EXTERNAL_SETTING,
890 MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY
893 "sound_stop_when_unplugged",
897 MM_ATTRS_VALID_TYPE_INT_RANGE,
902 "sound_application_pid",
906 MM_ATTRS_VALID_TYPE_INT_RANGE,
911 "sound_spk_out_only",
915 MM_ATTRS_VALID_TYPE_INT_RANGE,
923 (void *) 0, // 0: normal, 1: high 2: high with sound transition 3: mix with others regardless of priority
924 MM_ATTRS_VALID_TYPE_INT_RANGE,
929 "sound_close_resource",
933 MM_ATTRS_VALID_TYPE_INT_RANGE,
938 "sound_latency_mode",
941 (void *) 1, // 0: low latency, 1: middle latency 2: high latency
942 MM_ATTRS_VALID_TYPE_INT_RANGE,
947 "pcm_extraction", // enable pcm extraction
951 MM_ATTRS_VALID_TYPE_INT_RANGE,
956 "pcm_extraction_samplerate", // set samplerate for pcm extraction
959 (void *) 44100, // hz
960 MM_ATTRS_VALID_TYPE_INT_RANGE,
965 "pcm_extraction_depth", // set depth for pcm extraction
969 MM_ATTRS_VALID_TYPE_INT_RANGE,
974 "pcm_extraction_channels", // set channels for pcm extraction
978 MM_ATTRS_VALID_TYPE_INT_RANGE,
983 "pcm_extraction_start_msec", // set start position to extract pcm
987 MM_ATTRS_VALID_TYPE_INT_RANGE,
992 "pcm_extraction_end_msec", // set end position to extract pcm
996 MM_ATTRS_VALID_TYPE_INT_RANGE,
1001 "profile_smooth_repeat",
1005 MM_ATTRS_VALID_TYPE_INT_RANGE,
1010 "profile_progress_interval", // will be deprecated
1014 MM_ATTRS_VALID_TYPE_INT_RANGE,
1023 MM_ATTRS_VALID_TYPE_INT_RANGE,
1032 MM_ATTRS_VALID_TYPE_INT_RANGE,
1040 (void *) MM_PLAYER_PD_MODE_NONE,
1041 MM_ATTRS_VALID_TYPE_INT_RANGE,
1042 MM_PLAYER_PD_MODE_NONE,
1043 MM_PLAYER_PD_MODE_URI // not tested yet, because of no fixed scenario
1046 "pd_location", // location of the file to write
1047 MM_ATTRS_TYPE_STRING,
1050 MM_ATTRS_VALID_TYPE_NONE,
1059 MM_ATTRS_VALID_TYPE_INT_RANGE,
1064 "content_video_orientation", // orientation of video content
1065 MM_ATTRS_TYPE_STRING,
1068 MM_ATTRS_VALID_TYPE_NONE,
1074 MM_ATTRS_TYPE_STRING,
1077 MM_ATTRS_VALID_TYPE_NONE,
1086 MM_ATTRS_VALID_TYPE_INT_RANGE,
1095 MM_ATTRS_VALID_TYPE_INT_RANGE,
1100 "enable_video_decoded_cb",
1104 MM_ATTRS_VALID_TYPE_INT_RANGE,
1110 num_of_attrs = ARRAY_SIZE(player_attrs);
1112 base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
1115 LOGE("failed to alloc attrs constructor");
1119 /* initialize values of attributes */
1120 for (idx = 0; idx < num_of_attrs; idx++) {
1121 base[idx].name = player_attrs[idx].name;
1122 base[idx].value_type = player_attrs[idx].value_type;
1123 base[idx].flags = player_attrs[idx].flags;
1124 base[idx].default_value = player_attrs[idx].default_value;
1127 attrs = mmf_attrs_new_from_data(
1135 MMPLAYER_FREEIF(base);
1138 LOGE("failed to create player attrs");
1142 /* set validity type and range */
1143 for (idx = 0; idx < num_of_attrs; idx++) {
1144 switch (player_attrs[idx].valid_type) {
1145 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1147 mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1148 mmf_attrs_set_valid_range(attrs, idx,
1149 player_attrs[idx].value_min,
1150 player_attrs[idx].value_max,
1151 (int)(intptr_t)(player_attrs[idx].default_value));
1155 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1156 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1157 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1164 mmf_attrs_commit(attrs);
1170 _mmplayer_deconstruct_attribute(MMHandleType handle) // @
1172 mm_player_t *player = MM_PLAYER_CAST(handle);
1174 MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
1176 if (player->attrs) {
1177 mmf_attrs_free(player->attrs);