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 ========================================================================================== */
30 #include "mm_player_utils.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
34 /*===========================================================================================
36 | LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE |
38 ========================================================================================== */
40 /*-----------------------------------------------------------------------
41 | LOCAL FUNCTION PROTOTYPES: |
42 -----------------------------------------------------------------------*/
43 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
44 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
45 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
47 /*===========================================================================================
49 | FUNCTION DEFINITIONS |
51 ========================================================================================== */
53 static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
55 mmplayer_t *player = MM_PLAYER_CAST(handle);
56 mmplayer_gst_element_t *videobin = NULL;
59 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
61 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
62 LOGD("will be applied when videosink is ready");
66 if (!player->set_mode.video_export) {
67 LOGW("there is no callback for enabling");
71 videobin = player->pipeline->videobin;
73 LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
75 g_object_set(videobin[MMPLAYER_V_SINK].gst,
76 "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
81 static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
83 mmplayer_t *player = MM_PLAYER_CAST(handle);
84 mmplayer_gst_element_t *videobin = NULL;
87 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
89 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
90 LOGD("will be applied when videosink is ready");
94 videobin = player->pipeline->videobin;
96 if (value->value.i_val > 0) {
97 LOGD("[update plugin][videosink] disable last sample for gapless");
98 g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
104 static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
106 mmplayer_t *player = MM_PLAYER_CAST(handle);
107 mmplayer_pipeline_info_t *pipeline;
108 int pitch_control = 0;
111 MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
112 MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->mainbin, true);
114 pipeline = player->pipeline;
115 mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
117 if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
118 LOGW("audio pitch is disabled");
122 LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
123 g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
128 static int __mmplayer_get_array_count(MMHandleType handle, int type)
130 mmplayer_t *player = MM_PLAYER_CAST(handle);
135 if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
136 while (player->ini.audio_offload_media_format[i++][0])
138 } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
139 while (player->ini.media_stream_input_format[i++][0])
145 static media_format_mimetype_e __mmplayer_get_supported_format_mimetype(MMHandleType handle, int type, int i)
147 mmplayer_t *player = MM_PLAYER_CAST(handle);
148 media_format_mimetype_e format = MEDIA_FORMAT_MAX;
151 if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
152 name = player->ini.audio_offload_media_format[i];
153 } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
154 name = player->ini.media_stream_input_format[i];
156 LOGE("invalid ini type");
160 if (!strcmp(name, "MP3"))
161 format = MEDIA_FORMAT_MP3;
162 else if (!strcmp(name, "AAC"))
163 format = MEDIA_FORMAT_AAC;
164 else if (!strcmp(name, "H264_SP"))
165 format = MEDIA_FORMAT_H264_SP;
166 else if (!strcmp(name, "H264_MP"))
167 format = MEDIA_FORMAT_H264_MP;
168 else if (!strcmp(name, "H264_HP"))
169 format = MEDIA_FORMAT_H264_HP;
170 else if (!strcmp(name, "PCM"))
171 format = MEDIA_FORMAT_PCM;
172 else if (!strcmp(name, "PCM_S16LE"))
173 format = MEDIA_FORMAT_PCM_S16LE;
174 else if (!strcmp(name, "PCM_S24LE"))
175 format = MEDIA_FORMAT_PCM_S24LE;
176 else if (!strcmp(name, "PCM_S32LE"))
177 format = MEDIA_FORMAT_PCM_S32LE;
178 else if (!strcmp(name, "PCM_S16BE"))
179 format = MEDIA_FORMAT_PCM_S16BE;
180 else if (!strcmp(name, "PCM_S24BE"))
181 format = MEDIA_FORMAT_PCM_S24BE;
182 else if (!strcmp(name, "PCM_S32BE"))
183 format = MEDIA_FORMAT_PCM_S32BE;
184 else if (!strcmp(name, "PCM_F32LE"))
185 format = MEDIA_FORMAT_PCM_F32LE;
186 else if (!strcmp(name, "PCM_F32BE"))
187 format = MEDIA_FORMAT_PCM_F32BE;
188 else if (!strcmp(name, "PCM_S16LE"))
189 format = MEDIA_FORMAT_PCM_U16LE;
190 else if (!strcmp(name, "PCM_U24LE"))
191 format = MEDIA_FORMAT_PCM_U24LE;
192 else if (!strcmp(name, "PCM_U32LE"))
193 format = MEDIA_FORMAT_PCM_U32LE;
194 else if (!strcmp(name, "PCM_U16BE"))
195 format = MEDIA_FORMAT_PCM_U16BE;
196 else if (!strcmp(name, "PCM_U24BE"))
197 format = MEDIA_FORMAT_PCM_U24BE;
198 else if (!strcmp(name, "PCM_U32BE"))
199 format = MEDIA_FORMAT_PCM_U32BE;
201 LOGE("FIXME: need to modify function to support more format");
204 LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
209 static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
217 MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
219 count = __mmplayer_get_array_count(handle, type);
224 arr = (int *) g_malloc0(count * sizeof(int));
225 for (i = 0 ; i < count ; i++) {
226 fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
227 if (fmt != MEDIA_FORMAT_MAX)
228 arr[total_count++] = fmt;
231 if (total_count <= 0) {
236 LOGD("[%d type] num of supported codec %d", type, total_count);
242 static int __mmplayer_get_default_audio_codec_type(MMHandleType handle)
244 mmplayer_t *player = MM_PLAYER_CAST(handle);
246 if (!strcmp(player->ini.audiocodec_default_type, "hw"))
247 return MM_PLAYER_CODEC_TYPE_HW;
249 return MM_PLAYER_CODEC_TYPE_SW;
252 static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
254 mmplayer_t *player = MM_PLAYER_CAST(handle);
258 /* supported format of audio offload */
259 total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
260 if (format && total_count > 0) {
261 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
262 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
265 /* supported format of media stream input */
266 total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
267 if (format && total_count > 0) {
268 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
269 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
272 /* default audio codec type */
273 player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = __mmplayer_get_default_audio_codec_type(handle);
275 return MM_ERROR_NONE;
278 static int __mmplayer_release_ini_info(MMHandleType handle)
280 mmplayer_t *player = MM_PLAYER_CAST(handle);
285 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
287 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
288 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
290 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
292 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
293 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
296 return MM_ERROR_NONE;
299 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
301 switch (value->type) {
302 case MM_ATTRS_TYPE_INT:
303 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
305 case MM_ATTRS_TYPE_DOUBLE:
306 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
308 case MM_ATTRS_TYPE_STRING:
309 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
311 case MM_ATTRS_TYPE_DATA:
312 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
321 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
324 mmplayer_t *player = MM_PLAYER_CAST(commit_param);
326 MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
328 if (player->default_attrs[attr_idx].attr_commit) {
329 __mmplayer_print_attrs(attr_name, value, "Dynamic");
330 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
332 __mmplayer_print_attrs(attr_name, value, "Static");
339 int _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
341 int result = MM_ERROR_NONE;
342 MMHandleType attrs = NULL;
344 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
345 /* if it's not want to know it. */
346 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
347 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
349 attrs = MM_PLAYER_GET_ATTRS(handle);
351 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
353 if (result != MM_ERROR_NONE)
354 LOGE("failed to get %s attribute", attribute_name);
359 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
361 mmplayer_t *player = NULL;
364 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
365 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
367 player = MM_PLAYER_CAST(handle);
369 /* apply display attr value to player handle */
370 if (!g_strrstr(attribute_name, "display"))
371 return MM_ERROR_NONE;
373 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
374 LOGD("will be applied when videosink is ready");
375 return MM_ERROR_NONE;
378 if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
379 LOGW("not supported video param %s", attribute_name);
380 return MM_ERROR_NONE;
383 return MM_ERROR_NONE;
386 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
388 int result = MM_ERROR_NONE;
389 MMHandleType attrs = NULL;
391 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
392 /* if it's not want to know it. */
393 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
394 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
396 attrs = MM_PLAYER_GET_ATTRS(handle);
398 /* set attributes and commit them */
399 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
400 if (result != MM_ERROR_NONE) {
401 LOGE("failed to set %s attribute", attribute_name);
405 /* Note: 'attr_commit' function is called before committing the new value to attr struct.
406 so if there is a value to apply after committing, it should be added below function. */
407 result = __mmplayer_apply_attribute(handle, attribute_name);
408 if (result != MM_ERROR_NONE) {
409 LOGE("failed to apply attributes");
413 return MM_ERROR_NONE;
416 int _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, mmplayer_attrs_info_t *dst_info)
418 int result = MM_ERROR_NONE;
419 MMHandleType attrs = NULL;
420 MMAttrsInfo src_info = {0, };
422 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
423 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
424 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
426 attrs = MM_PLAYER_GET_ATTRS(handle);
428 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
430 if (result != MM_ERROR_NONE) {
431 LOGE("failed to get attribute info");
435 memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
437 dst_info->type = src_info.type;
438 dst_info->flag = src_info.flag;
439 dst_info->validity_type = src_info.validity_type;
441 switch (src_info.validity_type) {
442 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
443 dst_info->int_array.array = src_info.int_array.array;
444 dst_info->int_array.count = src_info.int_array.count;
445 dst_info->int_array.d_val = src_info.int_array.dval;
448 case MM_ATTRS_VALID_TYPE_INT_RANGE:
449 dst_info->int_range.min = src_info.int_range.min;
450 dst_info->int_range.max = src_info.int_range.max;
451 dst_info->int_range.d_val = src_info.int_range.dval;
454 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
455 dst_info->double_array.array = src_info.double_array.array;
456 dst_info->double_array.count = src_info.double_array.count;
457 dst_info->double_array.d_val = src_info.double_array.dval;
460 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
461 dst_info->double_range.min = src_info.double_range.min;
462 dst_info->double_range.max = src_info.double_range.max;
463 dst_info->double_range.d_val = src_info.double_range.dval;
473 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
475 mmplayer_t *player = MM_PLAYER_CAST(handle);
476 int result = MM_ERROR_NONE;
478 MMHandleType attrs = NULL;
479 int num_of_attrs = 0;
480 MMAttrsConstructInfo *base = NULL;
482 mmplayer_attrs_spec_t player_attrs[] = {
484 MMPLAYER_ATTRS_PROFILE_URI, /* ID */
485 (char *)"profile_uri", /* Name */
486 MM_ATTRS_TYPE_STRING, /* Value Type */
487 MM_ATTRS_FLAG_RW, /* Flag */
488 {(void *)NULL}, /* default value */
489 MM_ATTRS_VALID_TYPE_NONE, /* validity type */
490 {0}, /* validity min value */
491 {0}, /* validity max value */
492 NULL, /* Runtime setting function of the attribute */
495 MMPLAYER_ATTRS_PROFILE_USER_PARAM,
496 (char *)"profile_user_param",
500 MM_ATTRS_VALID_TYPE_NONE,
506 MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
507 (char *)"profile_play_count",
510 {(void *)1}, /* -1 : repeat continually */
511 MM_ATTRS_VALID_TYPE_INT_RANGE,
517 MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
518 (char *)"profile_prepare_async",
522 MM_ATTRS_VALID_TYPE_INT_RANGE,
528 MMPLAYER_ATTRS_STREAMING_USER_AGENT,
529 (char *)"streaming_user_agent",
530 MM_ATTRS_TYPE_STRING,
533 MM_ATTRS_VALID_TYPE_NONE,
539 MMPLAYER_ATTRS_STREAMING_COOKIE,
540 (char *)"streaming_cookie",
541 MM_ATTRS_TYPE_STRING,
544 MM_ATTRS_VALID_TYPE_NONE,
550 MMPLAYER_ATTRS_SUBTITLE_URI,
551 (char *)"subtitle_uri",
552 MM_ATTRS_TYPE_STRING,
555 MM_ATTRS_VALID_TYPE_NONE,
561 MMPLAYER_ATTRS_CONTENT_BITRATE,
562 (char *)"content_bitrate",
566 MM_ATTRS_VALID_TYPE_INT_RANGE,
568 {.int_max = MMPLAYER_MAX_INT},
572 MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
573 (char *)"content_max_bitrate",
577 MM_ATTRS_VALID_TYPE_INT_RANGE,
579 {.int_max = MMPLAYER_MAX_INT},
583 MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
584 (char *)"content_video_found",
588 MM_ATTRS_VALID_TYPE_INT_RANGE,
594 MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
595 (char *)"content_video_codec",
596 MM_ATTRS_TYPE_STRING,
599 MM_ATTRS_VALID_TYPE_NONE,
605 MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
606 (char *)"content_video_bitrate",
610 MM_ATTRS_VALID_TYPE_INT_RANGE,
612 {.int_max = MMPLAYER_MAX_INT},
616 MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
617 (char *)"content_video_fps",
621 MM_ATTRS_VALID_TYPE_INT_RANGE,
623 {.int_max = MMPLAYER_MAX_INT},
627 MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
628 (char *)"content_video_width",
632 MM_ATTRS_VALID_TYPE_INT_RANGE,
634 {.int_max = MMPLAYER_MAX_INT},
638 MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
639 (char *)"content_video_height",
643 MM_ATTRS_VALID_TYPE_INT_RANGE,
645 {.int_max = MMPLAYER_MAX_INT},
649 MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
650 (char *)"content_video_orientation", /* orientation of video content */
651 MM_ATTRS_TYPE_STRING,
654 MM_ATTRS_VALID_TYPE_NONE,
660 MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
661 (char *)"content_video_is_spherical",
665 MM_ATTRS_VALID_TYPE_INT_RANGE,
667 {.int_max = MMPLAYER_MAX_INT},
671 MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
672 (char *)"content_audio_codec",
673 MM_ATTRS_TYPE_STRING,
676 MM_ATTRS_VALID_TYPE_NONE,
682 MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
683 (char *)"content_audio_bitrate",
687 MM_ATTRS_VALID_TYPE_INT_RANGE,
689 {.int_max = MMPLAYER_MAX_INT},
693 MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
694 (char *)"content_audio_channels",
698 MM_ATTRS_VALID_TYPE_INT_RANGE,
700 {.int_max = MMPLAYER_MAX_INT},
704 MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
705 (char *)"content_audio_samplerate",
709 MM_ATTRS_VALID_TYPE_INT_RANGE,
711 {.int_max = MMPLAYER_MAX_INT},
715 MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
716 (char *)"content_audio_format",
717 MM_ATTRS_TYPE_STRING,
720 MM_ATTRS_VALID_TYPE_NONE,
726 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
727 (char *)"content_text_track_num",
731 MM_ATTRS_VALID_TYPE_INT_RANGE,
733 {.int_max = MMPLAYER_MAX_INT},
737 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
738 (char *)"current_text_track_index",
742 MM_ATTRS_VALID_TYPE_INT_RANGE,
744 {.int_max = MMPLAYER_MAX_INT},
748 MMPLAYER_ATTRS_TAG_ARTIST,
749 (char *)"tag_artist",
750 MM_ATTRS_TYPE_STRING,
753 MM_ATTRS_VALID_TYPE_NONE,
759 MMPLAYER_ATTRS_TAG_TITLE,
761 MM_ATTRS_TYPE_STRING,
764 MM_ATTRS_VALID_TYPE_NONE,
770 MMPLAYER_ATTRS_TAG_ALBUM,
772 MM_ATTRS_TYPE_STRING,
775 MM_ATTRS_VALID_TYPE_NONE,
781 MMPLAYER_ATTRS_TAG_GENRE,
783 MM_ATTRS_TYPE_STRING,
786 MM_ATTRS_VALID_TYPE_NONE,
792 MMPLAYER_ATTRS_TAG_AUTHOR,
793 (char *)"tag_author",
794 MM_ATTRS_TYPE_STRING,
797 MM_ATTRS_VALID_TYPE_NONE,
803 MMPLAYER_ATTRS_TAG_COPYRIGHT,
804 (char *)"tag_copyright",
805 MM_ATTRS_TYPE_STRING,
808 MM_ATTRS_VALID_TYPE_NONE,
814 MMPLAYER_ATTRS_TAG_DATE,
816 MM_ATTRS_TYPE_STRING,
819 MM_ATTRS_VALID_TYPE_NONE,
825 MMPLAYER_ATTRS_TAG_DESCRIPTION,
826 (char *)"tag_description",
827 MM_ATTRS_TYPE_STRING,
830 MM_ATTRS_VALID_TYPE_NONE,
836 MMPLAYER_ATTRS_TAG_TRACK_NUM,
837 (char *)"tag_track_num",
841 MM_ATTRS_VALID_TYPE_INT_RANGE,
843 {.int_max = MMPLAYER_MAX_INT},
847 MMPLAYER_ATTRS_TAG_ALBUM_COVER,
848 (char *)"tag_album_cover",
852 MM_ATTRS_VALID_TYPE_NONE,
858 MMPLAYER_ATTRS_DISPLAY_ROTATION,
859 (char *)"display_rotation",
862 {(void *)MM_DISPLAY_ROTATION_NONE},
863 MM_ATTRS_VALID_TYPE_INT_RANGE,
864 {.int_min = MM_DISPLAY_ROTATION_NONE},
865 {.int_max = MM_DISPLAY_ROTATION_270},
869 MMPLAYER_ATTRS_DISPLAY_VISIBLE,
870 (char *)"display_visible",
874 MM_ATTRS_VALID_TYPE_INT_RANGE,
880 MMPLAYER_ATTRS_DISPLAY_METHOD,
881 (char *)"display_method",
884 {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
885 MM_ATTRS_VALID_TYPE_INT_RANGE,
886 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
887 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
891 MMPLAYER_ATTRS_DISPLAY_OVERLAY,
892 (char *)"display_overlay",
896 MM_ATTRS_VALID_TYPE_INT_RANGE,
898 {.int_max = MMPLAYER_MAX_INT},
902 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
903 (char *)"display_win_roi_x",
907 MM_ATTRS_VALID_TYPE_INT_RANGE,
908 {.int_min = MMPLAYER_MIN_INT},
909 {.int_max = MMPLAYER_MAX_INT},
913 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
914 (char *)"display_win_roi_y",
918 MM_ATTRS_VALID_TYPE_INT_RANGE,
919 {.int_min = MMPLAYER_MIN_INT},
920 {.int_max = MMPLAYER_MAX_INT},
924 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
925 (char *)"display_win_roi_width",
929 MM_ATTRS_VALID_TYPE_INT_RANGE,
931 {.int_max = MMPLAYER_MAX_INT},
935 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
936 (char *)"display_win_roi_height",
940 MM_ATTRS_VALID_TYPE_INT_RANGE,
942 {.int_max = MMPLAYER_MAX_INT},
946 MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
947 (char *)"display_surface_type",
950 {(void *)MM_DISPLAY_SURFACE_NULL},
951 MM_ATTRS_VALID_TYPE_INT_RANGE,
952 {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
953 {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
957 MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
958 (char *)"sound_stream_type",
959 MM_ATTRS_TYPE_STRING,
962 MM_ATTRS_VALID_TYPE_NONE,
968 MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
969 (char *)"sound_stream_index",
973 MM_ATTRS_VALID_TYPE_INT_RANGE,
975 {.int_max = MMPLAYER_MAX_INT},
979 MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
980 (char *)"sound_latency_mode",
983 {(void *)1}, /* 0: low latency, 1: middle latency 2: high latency */
984 MM_ATTRS_VALID_TYPE_INT_RANGE,
990 MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
991 (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
995 MM_ATTRS_VALID_TYPE_INT_RANGE,
997 {.int_max = MMPLAYER_MAX_INT},
1001 MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
1002 (char *)"pcm_extraction_channels", /* set channels for pcm extraction */
1006 MM_ATTRS_VALID_TYPE_INT_RANGE,
1008 {.int_max = MMPLAYER_MAX_INT},
1012 MMPLAYER_ATTRS_ACCURATE_SEEK,
1013 (char *)"accurate_seek",
1017 MM_ATTRS_VALID_TYPE_INT_RANGE,
1023 MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1024 (char *)"pcm_extraction_format",
1025 MM_ATTRS_TYPE_STRING,
1028 MM_ATTRS_VALID_TYPE_NONE,
1034 MMPLAYER_ATTRS_DRC_MODE,
1039 MM_ATTRS_VALID_TYPE_INT_RANGE,
1045 MMPLAYER_ATTRS_GAPLESS_MODE,
1046 (char *)"gapless_mode",
1050 MM_ATTRS_VALID_TYPE_INT_RANGE,
1053 __mmplayer_commit_gapless_mode,
1056 MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1057 (char *)"enable_video_decoded_cb",
1061 MM_ATTRS_VALID_TYPE_INT_RANGE,
1064 __mmplayer_commit_enable_video_decoded_cb,
1067 MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1068 (char *)"video_codec_type",
1071 {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT},
1072 MM_ATTRS_VALID_TYPE_INT_RANGE,
1073 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1074 {.int_max = MM_PLAYER_CODEC_TYPE_DEFAULT},
1078 MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1079 (char *)"audio_codec_type",
1082 {(void *)MM_PLAYER_CODEC_TYPE_SW},
1083 MM_ATTRS_VALID_TYPE_INT_RANGE,
1084 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1085 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1089 MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1090 (char *)"video_buffer_total_size",
1093 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1094 MM_ATTRS_VALID_TYPE_INT_RANGE,
1095 {.int_min = MMPLAYER_MIN_INT},
1096 {.int_max = MMPLAYER_MAX_INT},
1100 MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1101 (char *)"video_buffer_extra_size",
1104 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1105 MM_ATTRS_VALID_TYPE_INT_RANGE,
1106 {.int_min = MMPLAYER_MIN_INT},
1107 {.int_max = MMPLAYER_MAX_INT},
1111 MMPLAYER_ATTRS_PREBUFFER_MS,
1112 (char *)"prebuffer_ms", /* user setting */
1115 {(void *) MIN_BUFFERING_TIME},
1116 MM_ATTRS_VALID_TYPE_INT_RANGE,
1117 {.int_min = MIN_BUFFERING_TIME},
1118 {.int_max = MMPLAYER_MAX_INT},
1122 MMPLAYER_ATTRS_REBUFFER_MS,
1123 (char *)"rebuffer_ms", /* user setting */
1126 {(void *) MIN_BUFFERING_TIME},
1127 MM_ATTRS_VALID_TYPE_INT_RANGE,
1128 {.int_min = MIN_BUFFERING_TIME},
1129 {.int_max = MMPLAYER_MAX_INT},
1133 MMPLAYER_ATTRS_PITCH_CONTROL,
1134 (char *)"pitch_control", /* MM_PLAYER_PITCH_CONTROL */
1138 MM_ATTRS_VALID_TYPE_INT_RANGE,
1144 MMPLAYER_ATTRS_PITCH_VALUE,
1145 (char *)"pitch_value", /* MM_PLAYER_PITCH_VALUE */
1146 MM_ATTRS_TYPE_DOUBLE,
1148 {.value_double = 1.0},
1149 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1150 {.double_min = 0.5},
1152 __mmplayer_commit_audio_pitch_value,
1155 MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1156 (char *)"audio_offload", /* MM_PLAYER_AUDIO_OFFLOAD */
1160 MM_ATTRS_VALID_TYPE_INT_RANGE,
1166 MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1167 (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1171 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1172 {.int_array = NULL},
1177 MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1178 (char *)"media_stream_input_format",
1182 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1183 {.int_array = NULL},
1189 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1191 num_of_attrs = ARRAY_SIZE(player_attrs);
1193 base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1195 LOGE("failed to alloc attrs constructor");
1199 /* initialize values of attributes */
1200 for (idx = 0; idx < num_of_attrs; idx++) {
1201 base[idx].name = player_attrs[idx].name;
1202 base[idx].value_type = player_attrs[idx].value_type;
1203 base[idx].flags = player_attrs[idx].flags;
1204 base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1207 result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1208 _mmplayer_commit_attribute, (void *)handle, &attrs);
1211 MMPLAYER_FREEIF(base);
1214 LOGE("failed to create player attrs");
1218 /* alloc default attribute info */
1219 player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1220 if (player->default_attrs == NULL) {
1221 LOGE("failed to alloc default attribute info");
1225 memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1227 __mmplayer_set_ini_to_valid_info(handle);
1229 /* set validity type and range */
1230 for (idx = 0; idx < num_of_attrs; idx++) {
1231 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1232 switch (player->default_attrs[idx].valid_type) {
1233 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1234 mm_attrs_set_valid_range(attrs, idx,
1235 player->default_attrs[idx].validity_value_1.int_min,
1236 player->default_attrs[idx].validity_value_2.int_max,
1237 player->default_attrs[idx].default_value.value_int);
1239 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1240 if (player->default_attrs[idx].validity_value_1.int_array &&
1241 player->default_attrs[idx].validity_value_2.count > 0)
1242 mm_attrs_set_valid_array(attrs, idx,
1243 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1244 player->default_attrs[idx].validity_value_2.count,
1245 player->default_attrs[idx].default_value.value_int);
1247 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1248 mm_attrs_set_valid_double_range(attrs, idx,
1249 player->default_attrs[idx].validity_value_1.double_min,
1250 player->default_attrs[idx].validity_value_2.double_max,
1251 player->default_attrs[idx].default_value.value_double);
1253 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1254 LOGW("FIXME: need to set range value if required.");
1255 case MM_ATTRS_VALID_TYPE_NONE:
1256 case MM_ATTRS_VALID_TYPE_INVALID:
1263 if (mm_attrs_commit_all(attrs)) {
1264 LOGE("failed to update attributes");
1268 __mmplayer_release_ini_info(handle);
1273 MMPLAYER_FREEIF(player->default_attrs);
1276 mm_attrs_free(attrs);
1281 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1283 mmplayer_t *player = MM_PLAYER_CAST(handle);
1285 MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1287 if (player->attrs) {
1288 mm_attrs_free(player->attrs);
1289 player->attrs = NULL;
1292 MMPLAYER_FREEIF(player->default_attrs);