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->audiobin, 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_U16LE"))
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_set_ini_to_valid_info(MMHandleType handle)
244 mmplayer_t *player = MM_PLAYER_CAST(handle);
248 /* supported format of audio offload */
249 total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
250 if (format && total_count > 0) {
251 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
252 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
255 /* supported format of media stream input */
256 total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
257 if (format && total_count > 0) {
258 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
259 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
262 /* default codec type */
263 if (!strcmp(player->ini.audiocodec_default_type, "sw"))
264 player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
266 if (!strcmp(player->ini.videocodec_default_type, "sw"))
267 player->default_attrs[MMPLAYER_ATTRS_VIDEO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
269 return MM_ERROR_NONE;
272 static int __mmplayer_release_ini_info(MMHandleType handle)
274 mmplayer_t *player = MM_PLAYER_CAST(handle);
279 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
281 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
282 player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
284 mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
286 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
287 player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
290 return MM_ERROR_NONE;
293 static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
295 switch (value->type) {
296 case MM_ATTRS_TYPE_INT:
297 LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
299 case MM_ATTRS_TYPE_DOUBLE:
300 LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
302 case MM_ATTRS_TYPE_STRING:
303 LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
305 case MM_ATTRS_TYPE_DATA:
306 LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
315 bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
318 mmplayer_t *player = MM_PLAYER_CAST(commit_param);
320 MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
322 if (player->default_attrs[attr_idx].attr_commit) {
323 __mmplayer_print_attrs(attr_name, value, "Dynamic");
324 ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
326 __mmplayer_print_attrs(attr_name, value, "Static");
333 int _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
335 int result = MM_ERROR_NONE;
336 MMHandleType attrs = NULL;
338 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
339 /* if it's not want to know it. */
340 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
341 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
343 attrs = MM_PLAYER_GET_ATTRS(handle);
345 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
347 if (result != MM_ERROR_NONE)
348 LOGE("failed to get %s attribute", attribute_name);
353 int __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
355 mmplayer_t *player = NULL;
358 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
359 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
361 player = MM_PLAYER_CAST(handle);
363 /* apply display attr value to player handle */
364 if (!g_strrstr(attribute_name, "display"))
365 return MM_ERROR_NONE;
367 if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
368 LOGD("will be applied when videosink is ready");
369 return MM_ERROR_NONE;
372 if (_mmplayer_update_video_overlay_param(player, attribute_name) != MM_ERROR_NONE) {
373 LOGW("not supported video param %s", attribute_name);
374 return MM_ERROR_NONE;
377 return MM_ERROR_NONE;
380 int _mmplayer_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
382 int result = MM_ERROR_NONE;
383 MMHandleType attrs = NULL;
385 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
386 /* if it's not want to know it. */
387 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
388 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
390 attrs = MM_PLAYER_GET_ATTRS(handle);
392 /* set attributes and commit them */
393 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
394 if (result != MM_ERROR_NONE) {
395 LOGE("failed to set %s attribute", attribute_name);
399 /* Note: 'attr_commit' function is called before committing the new value to attr struct.
400 so if there is a value to apply after committing, it should be added below function. */
401 result = __mmplayer_apply_attribute(handle, attribute_name);
402 if (result != MM_ERROR_NONE) {
403 LOGE("failed to apply attributes");
407 return MM_ERROR_NONE;
410 int _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, mmplayer_attrs_info_t *dst_info)
412 int result = MM_ERROR_NONE;
413 MMHandleType attrs = NULL;
414 MMAttrsInfo src_info = {0, };
416 MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
417 MMPLAYER_RETURN_VAL_IF_FAIL(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
418 MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
420 attrs = MM_PLAYER_GET_ATTRS(handle);
422 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
424 if (result != MM_ERROR_NONE) {
425 LOGE("failed to get attribute info");
429 memset(dst_info, 0x00, sizeof(mmplayer_attrs_info_t));
431 dst_info->type = src_info.type;
432 dst_info->flag = src_info.flag;
433 dst_info->validity_type = src_info.validity_type;
435 switch (src_info.validity_type) {
436 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
437 dst_info->int_array.array = src_info.int_array.array;
438 dst_info->int_array.count = src_info.int_array.count;
439 dst_info->int_array.d_val = src_info.int_array.dval;
442 case MM_ATTRS_VALID_TYPE_INT_RANGE:
443 dst_info->int_range.min = src_info.int_range.min;
444 dst_info->int_range.max = src_info.int_range.max;
445 dst_info->int_range.d_val = src_info.int_range.dval;
448 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
449 dst_info->double_array.array = src_info.double_array.array;
450 dst_info->double_array.count = src_info.double_array.count;
451 dst_info->double_array.d_val = src_info.double_array.dval;
454 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
455 dst_info->double_range.min = src_info.double_range.min;
456 dst_info->double_range.max = src_info.double_range.max;
457 dst_info->double_range.d_val = src_info.double_range.dval;
467 MMHandleType _mmplayer_construct_attribute(MMHandleType handle)
469 mmplayer_t *player = MM_PLAYER_CAST(handle);
470 int result = MM_ERROR_NONE;
472 MMHandleType attrs = NULL;
473 int num_of_attrs = 0;
474 MMAttrsConstructInfo *base = NULL;
476 mmplayer_attrs_spec_t player_attrs[] = {
478 MMPLAYER_ATTRS_PROFILE_URI, /* ID */
479 (char *)"profile_uri", /* Name */
480 MM_ATTRS_TYPE_STRING, /* Value Type */
481 MM_ATTRS_FLAG_RW, /* Flag */
482 {(void *)NULL}, /* default value */
483 MM_ATTRS_VALID_TYPE_NONE, /* validity type */
484 {0}, /* validity min value */
485 {0}, /* validity max value */
486 NULL, /* Runtime setting function of the attribute */
489 MMPLAYER_ATTRS_PROFILE_USER_PARAM,
490 (char *)"profile_user_param",
494 MM_ATTRS_VALID_TYPE_NONE,
500 MMPLAYER_ATTRS_PROFILE_PLAY_COUNT,
501 (char *)"profile_play_count",
504 {(void *)1}, /* -1 : repeat continually */
505 MM_ATTRS_VALID_TYPE_INT_RANGE,
511 MMPLAYER_ATTRS_PROFILE_PREPARE_ASYNC,
512 (char *)"profile_prepare_async",
516 MM_ATTRS_VALID_TYPE_INT_RANGE,
522 MMPLAYER_ATTRS_STREAMING_USER_AGENT,
523 (char *)"streaming_user_agent",
524 MM_ATTRS_TYPE_STRING,
527 MM_ATTRS_VALID_TYPE_NONE,
533 MMPLAYER_ATTRS_STREAMING_COOKIE,
534 (char *)"streaming_cookie",
535 MM_ATTRS_TYPE_STRING,
538 MM_ATTRS_VALID_TYPE_NONE,
544 MMPLAYER_ATTRS_SUBTITLE_URI,
545 (char *)"subtitle_uri",
546 MM_ATTRS_TYPE_STRING,
549 MM_ATTRS_VALID_TYPE_NONE,
555 MMPLAYER_ATTRS_CONTENT_BITRATE,
556 (char *)"content_bitrate",
560 MM_ATTRS_VALID_TYPE_INT_RANGE,
562 {.int_max = MMPLAYER_MAX_INT},
566 MMPLAYER_ATTRS_CONTENT_MAX_BITRATE,
567 (char *)"content_max_bitrate",
571 MM_ATTRS_VALID_TYPE_INT_RANGE,
573 {.int_max = MMPLAYER_MAX_INT},
577 MMPLAYER_ATTRS_CONTENT_VIDEO_FOUND,
578 (char *)"content_video_found",
582 MM_ATTRS_VALID_TYPE_INT_RANGE,
588 MMPLAYER_ATTRS_CONTENT_VIDEO_CODEC,
589 (char *)"content_video_codec",
590 MM_ATTRS_TYPE_STRING,
593 MM_ATTRS_VALID_TYPE_NONE,
599 MMPLAYER_ATTRS_CONTENT_VIDEO_BITRATE,
600 (char *)"content_video_bitrate",
604 MM_ATTRS_VALID_TYPE_INT_RANGE,
606 {.int_max = MMPLAYER_MAX_INT},
610 MMPLAYER_ATTRS_CONTENT_VIDEO_FPS,
611 (char *)"content_video_fps",
615 MM_ATTRS_VALID_TYPE_INT_RANGE,
617 {.int_max = MMPLAYER_MAX_INT},
621 MMPLAYER_ATTRS_CONTENT_VIDEO_WIDTH,
622 (char *)"content_video_width",
626 MM_ATTRS_VALID_TYPE_INT_RANGE,
628 {.int_max = MMPLAYER_MAX_INT},
632 MMPLAYER_ATTRS_CONTENT_VIDEO_HEIGHT,
633 (char *)"content_video_height",
637 MM_ATTRS_VALID_TYPE_INT_RANGE,
639 {.int_max = MMPLAYER_MAX_INT},
643 MMPLAYER_ATTRS_CONTENT_VIDEO_ORIENTATION,
644 (char *)"content_video_orientation", /* orientation of video content */
645 MM_ATTRS_TYPE_STRING,
648 MM_ATTRS_VALID_TYPE_NONE,
654 MMPLAYER_ATTRS_CONTENT_VIDEO_IS_SPHERICAL,
655 (char *)"content_video_is_spherical",
659 MM_ATTRS_VALID_TYPE_INT_RANGE,
661 {.int_max = MMPLAYER_MAX_INT},
665 MMPLAYER_ATTRS_CONTENT_AUDIO_CODEC,
666 (char *)"content_audio_codec",
667 MM_ATTRS_TYPE_STRING,
670 MM_ATTRS_VALID_TYPE_NONE,
676 MMPLAYER_ATTRS_CONTENT_AUDIO_BITRATE,
677 (char *)"content_audio_bitrate",
681 MM_ATTRS_VALID_TYPE_INT_RANGE,
683 {.int_max = MMPLAYER_MAX_INT},
687 MMPLAYER_ATTRS_CONTENT_AUDIO_CHANNELS,
688 (char *)"content_audio_channels",
692 MM_ATTRS_VALID_TYPE_INT_RANGE,
694 {.int_max = MMPLAYER_MAX_INT},
698 MMPLAYER_ATTRS_CONTENT_AUDIO_SAMPLERATE,
699 (char *)"content_audio_samplerate",
703 MM_ATTRS_VALID_TYPE_INT_RANGE,
705 {.int_max = MMPLAYER_MAX_INT},
709 MMPLAYER_ATTRS_CONTENT_AUDIO_FORMAT,
710 (char *)"content_audio_format",
711 MM_ATTRS_TYPE_STRING,
714 MM_ATTRS_VALID_TYPE_NONE,
720 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_NUM,
721 (char *)"content_text_track_num",
725 MM_ATTRS_VALID_TYPE_INT_RANGE,
727 {.int_max = MMPLAYER_MAX_INT},
731 MMPLAYER_ATTRS_CONTENT_TEXT_TRACK_INDEX,
732 (char *)"current_text_track_index",
736 MM_ATTRS_VALID_TYPE_INT_RANGE,
738 {.int_max = MMPLAYER_MAX_INT},
742 MMPLAYER_ATTRS_TAG_ARTIST,
743 (char *)"tag_artist",
744 MM_ATTRS_TYPE_STRING,
747 MM_ATTRS_VALID_TYPE_NONE,
753 MMPLAYER_ATTRS_TAG_TITLE,
755 MM_ATTRS_TYPE_STRING,
758 MM_ATTRS_VALID_TYPE_NONE,
764 MMPLAYER_ATTRS_TAG_ALBUM,
766 MM_ATTRS_TYPE_STRING,
769 MM_ATTRS_VALID_TYPE_NONE,
775 MMPLAYER_ATTRS_TAG_GENRE,
777 MM_ATTRS_TYPE_STRING,
780 MM_ATTRS_VALID_TYPE_NONE,
786 MMPLAYER_ATTRS_TAG_AUTHOR,
787 (char *)"tag_author",
788 MM_ATTRS_TYPE_STRING,
791 MM_ATTRS_VALID_TYPE_NONE,
797 MMPLAYER_ATTRS_TAG_COPYRIGHT,
798 (char *)"tag_copyright",
799 MM_ATTRS_TYPE_STRING,
802 MM_ATTRS_VALID_TYPE_NONE,
808 MMPLAYER_ATTRS_TAG_DATE,
810 MM_ATTRS_TYPE_STRING,
813 MM_ATTRS_VALID_TYPE_NONE,
819 MMPLAYER_ATTRS_TAG_DESCRIPTION,
820 (char *)"tag_description",
821 MM_ATTRS_TYPE_STRING,
824 MM_ATTRS_VALID_TYPE_NONE,
830 MMPLAYER_ATTRS_TAG_TRACK_NUM,
831 (char *)"tag_track_num",
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
837 {.int_max = MMPLAYER_MAX_INT},
841 MMPLAYER_ATTRS_TAG_ALBUM_COVER,
842 (char *)"tag_album_cover",
846 MM_ATTRS_VALID_TYPE_NONE,
852 MMPLAYER_ATTRS_DISPLAY_ROTATION,
853 (char *)"display_rotation",
856 {(void *)MM_DISPLAY_ROTATION_NONE},
857 MM_ATTRS_VALID_TYPE_INT_RANGE,
858 {.int_min = MM_DISPLAY_ROTATION_NONE},
859 {.int_max = MM_DISPLAY_ROTATION_270},
863 MMPLAYER_ATTRS_DISPLAY_VISIBLE,
864 (char *)"display_visible",
868 MM_ATTRS_VALID_TYPE_INT_RANGE,
874 MMPLAYER_ATTRS_DISPLAY_METHOD,
875 (char *)"display_method",
878 {(void *)MM_DISPLAY_METHOD_LETTER_BOX},
879 MM_ATTRS_VALID_TYPE_INT_RANGE,
880 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
881 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
885 MMPLAYER_ATTRS_DISPLAY_OVERLAY,
886 (char *)"display_overlay",
890 MM_ATTRS_VALID_TYPE_INT_RANGE,
892 {.int_max = MMPLAYER_MAX_INT},
896 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_X,
897 (char *)"display_win_roi_x",
901 MM_ATTRS_VALID_TYPE_INT_RANGE,
902 {.int_min = MMPLAYER_MIN_INT},
903 {.int_max = MMPLAYER_MAX_INT},
907 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_Y,
908 (char *)"display_win_roi_y",
912 MM_ATTRS_VALID_TYPE_INT_RANGE,
913 {.int_min = MMPLAYER_MIN_INT},
914 {.int_max = MMPLAYER_MAX_INT},
918 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_WIDTH,
919 (char *)"display_win_roi_width",
923 MM_ATTRS_VALID_TYPE_INT_RANGE,
925 {.int_max = MMPLAYER_MAX_INT},
929 MMPLAYER_ATTRS_DISPLAY_WIN_ROI_HEIGHT,
930 (char *)"display_win_roi_height",
934 MM_ATTRS_VALID_TYPE_INT_RANGE,
936 {.int_max = MMPLAYER_MAX_INT},
940 MMPLAYER_ATTRS_DISPLAY_SURFACE_TYPE,
941 (char *)"display_surface_type",
944 {(void *)MM_DISPLAY_SURFACE_NULL},
945 MM_ATTRS_VALID_TYPE_INT_RANGE,
946 {.int_min = MM_DISPLAY_SURFACE_OVERLAY},
947 {.int_max = MM_DISPLAY_SURFACE_NUM - 1},
951 MMPLAYER_ATTRS_SOUND_STREAM_TYPE,
952 (char *)"sound_stream_type",
953 MM_ATTRS_TYPE_STRING,
956 MM_ATTRS_VALID_TYPE_NONE,
962 MMPLAYER_ATTRS_SOUND_STREAM_INDEX,
963 (char *)"sound_stream_index",
967 MM_ATTRS_VALID_TYPE_INT_RANGE,
969 {.int_max = MMPLAYER_MAX_INT},
973 MMPLAYER_ATTRS_SOUND_LATENCY_MODE,
974 (char *)"sound_latency_mode",
977 {(void *)1}, /* 0: low latency, 1: middle latency 2: high latency */
978 MM_ATTRS_VALID_TYPE_INT_RANGE,
984 MMPLAYER_ATTRS_PCM_EXTRACTION_SAMPLERATE,
985 (char *)"pcm_extraction_samplerate", /* set samplerate for pcm extraction */
989 MM_ATTRS_VALID_TYPE_INT_RANGE,
991 {.int_max = MMPLAYER_MAX_INT},
995 MMPLAYER_ATTRS_PCM_EXTRACTION_CHANNELS,
996 (char *)"pcm_extraction_channels", /* set channels for pcm extraction */
1000 MM_ATTRS_VALID_TYPE_INT_RANGE,
1002 {.int_max = MMPLAYER_MAX_INT},
1006 MMPLAYER_ATTRS_ACCURATE_SEEK,
1007 (char *)"accurate_seek",
1011 MM_ATTRS_VALID_TYPE_INT_RANGE,
1017 MMPLAYER_ATTRS_PCM_EXTRACTION_FORMAT,
1018 (char *)"pcm_extraction_format",
1019 MM_ATTRS_TYPE_STRING,
1022 MM_ATTRS_VALID_TYPE_NONE,
1028 MMPLAYER_ATTRS_DRC_MODE,
1033 MM_ATTRS_VALID_TYPE_INT_RANGE,
1039 MMPLAYER_ATTRS_GAPLESS_MODE,
1040 (char *)"gapless_mode",
1044 MM_ATTRS_VALID_TYPE_INT_RANGE,
1047 __mmplayer_commit_gapless_mode,
1050 MMPLAYER_ATTRS_ENABLE_VIDEO_DECODED_CB,
1051 (char *)"enable_video_decoded_cb",
1055 MM_ATTRS_VALID_TYPE_INT_RANGE,
1058 __mmplayer_commit_enable_video_decoded_cb,
1061 MMPLAYER_ATTRS_VIDEO_CODEC_TYPE,
1062 (char *)"video_codec_type",
1065 {(void *)MM_PLAYER_CODEC_TYPE_HW},
1066 MM_ATTRS_VALID_TYPE_INT_RANGE,
1067 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1068 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1072 MMPLAYER_ATTRS_AUDIO_CODEC_TYPE,
1073 (char *)"audio_codec_type",
1076 {(void *)MM_PLAYER_CODEC_TYPE_HW},
1077 MM_ATTRS_VALID_TYPE_INT_RANGE,
1078 {.int_min = MM_PLAYER_CODEC_TYPE_HW},
1079 {.int_max = MM_PLAYER_CODEC_TYPE_SW},
1083 MMPLAYER_ATTRS_VIDEO_BUFFER_TOTAL_SIZE,
1084 (char *)"video_buffer_total_size",
1087 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1088 MM_ATTRS_VALID_TYPE_INT_RANGE,
1089 {.int_min = MMPLAYER_MIN_INT},
1090 {.int_max = MMPLAYER_MAX_INT},
1094 MMPLAYER_ATTRS_VIDEO_BUFFER_EXTRA_SIZE,
1095 (char *)"video_buffer_extra_size",
1098 {(void *)DEFAULT_NUM_OF_V_OUT_BUFFER},
1099 MM_ATTRS_VALID_TYPE_INT_RANGE,
1100 {.int_min = MMPLAYER_MIN_INT},
1101 {.int_max = MMPLAYER_MAX_INT},
1105 MMPLAYER_ATTRS_PREBUFFER_MS,
1106 (char *)"prebuffer_ms", /* user setting */
1109 {(void *) MIN_BUFFERING_TIME},
1110 MM_ATTRS_VALID_TYPE_INT_RANGE,
1111 {.int_min = MIN_BUFFERING_TIME},
1112 {.int_max = MMPLAYER_MAX_INT},
1116 MMPLAYER_ATTRS_REBUFFER_MS,
1117 (char *)"rebuffer_ms", /* user setting */
1120 {(void *) MIN_BUFFERING_TIME},
1121 MM_ATTRS_VALID_TYPE_INT_RANGE,
1122 {.int_min = MIN_BUFFERING_TIME},
1123 {.int_max = MMPLAYER_MAX_INT},
1127 MMPLAYER_ATTRS_PITCH_CONTROL,
1128 (char *)"pitch_control", /* MM_PLAYER_PITCH_CONTROL */
1132 MM_ATTRS_VALID_TYPE_INT_RANGE,
1138 MMPLAYER_ATTRS_PITCH_VALUE,
1139 (char *)"pitch_value", /* MM_PLAYER_PITCH_VALUE */
1140 MM_ATTRS_TYPE_DOUBLE,
1142 {.value_double = 1.0},
1143 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1144 {.double_min = 0.5},
1146 __mmplayer_commit_audio_pitch_value,
1149 MMPLAYER_ATTRS_AUDIO_OFFLOAD,
1150 (char *)"audio_offload", /* MM_PLAYER_AUDIO_OFFLOAD */
1154 MM_ATTRS_VALID_TYPE_INT_RANGE,
1160 MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT,
1161 (char *)"audio_offload_format", /* MM_PLAYER_AUDIO_OFFLOAD_FORMAT, array of media_format_mimetype_e */
1165 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1166 {.int_array = NULL},
1171 MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT, /* MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT */
1172 (char *)"media_stream_input_format",
1176 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1177 {.int_array = NULL},
1183 MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
1185 num_of_attrs = ARRAY_SIZE(player_attrs);
1187 base = g_try_new(MMAttrsConstructInfo, num_of_attrs);
1189 LOGE("failed to alloc attrs constructor");
1193 /* alloc default attribute info */
1194 player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1195 if (player->default_attrs == NULL) {
1196 LOGE("failed to alloc default attribute info");
1200 memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs);
1201 __mmplayer_set_ini_to_valid_info(handle);
1203 /* initialize values of attributes */
1204 for (idx = 0; idx < num_of_attrs; idx++) {
1205 base[idx].name = player->default_attrs[idx].name;
1206 base[idx].value_type = player->default_attrs[idx].value_type;
1207 base[idx].flags = player->default_attrs[idx].flags;
1208 base[idx].default_value = player->default_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */
1211 result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs",
1212 _mmplayer_commit_attribute, (void *)handle, &attrs);
1215 MMPLAYER_FREEIF(base);
1217 if (result != MM_ERROR_NONE) {
1218 LOGE("failed to create player attrs");
1222 /* set validity type and range */
1223 for (idx = 0; idx < num_of_attrs; idx++) {
1224 mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type);
1225 switch (player->default_attrs[idx].valid_type) {
1226 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1227 mm_attrs_set_valid_range(attrs, idx,
1228 player->default_attrs[idx].validity_value_1.int_min,
1229 player->default_attrs[idx].validity_value_2.int_max,
1230 player->default_attrs[idx].default_value.value_int);
1232 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1233 if (player->default_attrs[idx].validity_value_1.int_array &&
1234 player->default_attrs[idx].validity_value_2.count > 0)
1235 mm_attrs_set_valid_array(attrs, idx,
1236 (const int *)(player->default_attrs[idx].validity_value_1.int_array),
1237 player->default_attrs[idx].validity_value_2.count,
1238 player->default_attrs[idx].default_value.value_int);
1240 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1241 mm_attrs_set_valid_double_range(attrs, idx,
1242 player->default_attrs[idx].validity_value_1.double_min,
1243 player->default_attrs[idx].validity_value_2.double_max,
1244 player->default_attrs[idx].default_value.value_double);
1246 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1247 LOGW("FIXME: need to set range value if required.");
1248 case MM_ATTRS_VALID_TYPE_NONE:
1249 case MM_ATTRS_VALID_TYPE_INVALID:
1256 if (mm_attrs_commit_all(attrs)) {
1257 LOGE("failed to update attributes");
1261 __mmplayer_release_ini_info(handle);
1266 MMPLAYER_FREEIF(base);
1267 MMPLAYER_FREEIF(player->default_attrs);
1270 mm_attrs_free(attrs);
1275 bool _mmplayer_deconstruct_attribute(MMHandleType handle)
1277 mmplayer_t *player = MM_PLAYER_CAST(handle);
1279 MMPLAYER_RETURN_VAL_IF_FAIL(player, false);
1281 if (player->attrs) {
1282 mm_attrs_free(player->attrs);
1283 player->attrs = NULL;
1286 MMPLAYER_FREEIF(player->default_attrs);