+static bool __mmplayer_commit_enable_video_decoded_cb(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ mmplayer_gst_element_t *videobin = NULL;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
+
+ if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
+ LOGD("will be applied when videosink is ready");
+ return true;
+ }
+
+ if (!player->set_mode.video_export) {
+ LOGW("there is no callback for enabling");
+ return true;
+ }
+
+ videobin = player->pipeline->videobin;
+
+ LOGD("[update plugin][videosink] handoff %d", value->value.i_val);
+
+ g_object_set(videobin[MMPLAYER_V_SINK].gst,
+ "signal-handoffs", (value->value.i_val) ? TRUE : FALSE, NULL);
+
+ return true;
+}
+
+static bool __mmplayer_commit_gapless_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ mmplayer_gst_element_t *videobin = NULL;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
+
+ if (!_mmplayer_is_videosink_ready(player, MM_DISPLAY_SURFACE_NUM)) {
+ LOGD("will be applied when videosink is ready");
+ return true;
+ }
+
+ videobin = player->pipeline->videobin;
+
+ if (value->value.i_val > 0) {
+ LOGD("[update plugin][videosink] disable last sample for gapless");
+ g_object_set(videobin[MMPLAYER_V_SINK].gst, "enable-last-sample", FALSE, NULL);
+ }
+
+ return true;
+}
+
+static bool __mmplayer_commit_audio_pitch_value(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ mmplayer_pipeline_info_t *pipeline;
+ int pitch_control = 0;
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && value, false);
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline && player->pipeline->audiobin, true);
+
+ pipeline = player->pipeline;
+ mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_PITCH_CONTROL, &pitch_control);
+
+ if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) {
+ LOGW("audio pitch is disabled");
+ return true;
+ }
+
+ LOGD("[update plugin][pitch] value to %1.3f", value->value.d_val);
+ g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (value->value.d_val), NULL);
+
+ return true;
+}
+
+static int __mmplayer_get_array_count(MMHandleType handle, int type)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+
+ int count = 0;
+ int i = 0;
+
+ if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
+ while (player->ini.audio_offload_media_format[i++][0])
+ count++;
+ } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
+ while (player->ini.media_stream_input_format[i++][0])
+ count++;
+ }
+ return count;
+}
+
+static media_format_mimetype_e __mmplayer_get_supported_format_mimetype(MMHandleType handle, int type, int i)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ media_format_mimetype_e format = MEDIA_FORMAT_MAX;
+ char *name = NULL;
+
+ if (type == KEYWORD_A_OFFLOAD_MEDIA_FORMAT) {
+ name = player->ini.audio_offload_media_format[i];
+ } else if (type == KEYWORD_MEDIA_STREAM_IN_FORMAT) {
+ name = player->ini.media_stream_input_format[i];
+ } else {
+ LOGE("invalid ini type");
+ goto EXIT;
+ }
+
+ if (!strcmp(name, "MP3"))
+ format = MEDIA_FORMAT_MP3;
+ else if (!strcmp(name, "AAC"))
+ format = MEDIA_FORMAT_AAC;
+ else if (!strcmp(name, "H264_SP"))
+ format = MEDIA_FORMAT_H264_SP;
+ else if (!strcmp(name, "H264_MP"))
+ format = MEDIA_FORMAT_H264_MP;
+ else if (!strcmp(name, "H264_HP"))
+ format = MEDIA_FORMAT_H264_HP;
+ else if (!strcmp(name, "PCM"))
+ format = MEDIA_FORMAT_PCM;
+ else if (!strcmp(name, "PCM_S16LE"))
+ format = MEDIA_FORMAT_PCM_S16LE;
+ else if (!strcmp(name, "PCM_S24LE"))
+ format = MEDIA_FORMAT_PCM_S24LE;
+ else if (!strcmp(name, "PCM_S32LE"))
+ format = MEDIA_FORMAT_PCM_S32LE;
+ else if (!strcmp(name, "PCM_S16BE"))
+ format = MEDIA_FORMAT_PCM_S16BE;
+ else if (!strcmp(name, "PCM_S24BE"))
+ format = MEDIA_FORMAT_PCM_S24BE;
+ else if (!strcmp(name, "PCM_S32BE"))
+ format = MEDIA_FORMAT_PCM_S32BE;
+ else if (!strcmp(name, "PCM_F32LE"))
+ format = MEDIA_FORMAT_PCM_F32LE;
+ else if (!strcmp(name, "PCM_F32BE"))
+ format = MEDIA_FORMAT_PCM_F32BE;
+ else if (!strcmp(name, "PCM_U16LE"))
+ format = MEDIA_FORMAT_PCM_U16LE;
+ else if (!strcmp(name, "PCM_U24LE"))
+ format = MEDIA_FORMAT_PCM_U24LE;
+ else if (!strcmp(name, "PCM_U32LE"))
+ format = MEDIA_FORMAT_PCM_U32LE;
+ else if (!strcmp(name, "PCM_U16BE"))
+ format = MEDIA_FORMAT_PCM_U16BE;
+ else if (!strcmp(name, "PCM_U24BE"))
+ format = MEDIA_FORMAT_PCM_U24BE;
+ else if (!strcmp(name, "PCM_U32BE"))
+ format = MEDIA_FORMAT_PCM_U32BE;
+ else
+ LOGE("FIXME: need to modify function to support more format");
+
+EXIT:
+ LOGD("[%d type] supported format 0x%X(%s)", type, format, name);
+
+ return format;
+}
+
+static int __mmplayer_get_available_format(MMHandleType handle, int type, int **format)
+{
+ int *arr = NULL;
+ int total_count = 0;
+ int count = 0;
+ int i = 0;
+ int fmt = 0;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(handle, -1);
+
+ count = __mmplayer_get_array_count(handle, type);
+
+ if (count <= 0)
+ return -1;
+
+ arr = (int *) g_malloc0(count * sizeof(int));
+ for (i = 0 ; i < count ; i++) {
+ fmt = __mmplayer_get_supported_format_mimetype(handle, type, i);
+ if (fmt != MEDIA_FORMAT_MAX)
+ arr[total_count++] = fmt;
+ }
+
+ if (total_count <= 0) {
+ g_free(arr);
+ return -1;
+ }
+
+ LOGD("[%d type] num of supported codec %d", type, total_count);
+
+ *format = arr;
+ return total_count;
+}
+
+static int __mmplayer_set_ini_to_valid_info(MMHandleType handle)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ int *format = NULL;
+ int total_count = 0;
+
+ /* supported format of audio offload */
+ total_count = __mmplayer_get_available_format(handle, KEYWORD_A_OFFLOAD_MEDIA_FORMAT, &format);
+ if (format && total_count > 0) {
+ player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = format;
+ player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = total_count;
+ }
+
+ /* supported format of media stream input */
+ total_count = __mmplayer_get_available_format(handle, KEYWORD_MEDIA_STREAM_IN_FORMAT, &format);
+ if (format && total_count > 0) {
+ player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = format;
+ player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count;
+ }
+
+ /* default codec type */
+ if (!strcmp(player->ini.audiocodec_default_type, "sw"))
+ player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
+
+ if (!strcmp(player->ini.videocodec_default_type, "sw"))
+ player->default_attrs[MMPLAYER_ATTRS_VIDEO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW;
+
+ return MM_ERROR_NONE;
+}
+
+static int __mmplayer_release_ini_info(MMHandleType handle)
+{
+ mmplayer_t *player = MM_PLAYER_CAST(handle);
+ int *mem = NULL;
+
+ MMPLAYER_FENTER();
+
+ mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array);
+ g_free(mem);
+ player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_1.int_array = NULL;
+ player->default_attrs[MMPLAYER_ATTRS_AUDIO_OFFLOAD_FORMAT].validity_value_2.count = 0;
+
+ mem = (int *)(player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array);
+ g_free(mem);
+ player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_1.int_array = NULL;
+ player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = 0;
+
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_NONE;
+}
+
+static void __mmplayer_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
+{
+ switch (value->type) {
+ case MM_ATTRS_TYPE_INT:
+ LOGD("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
+ break;
+ case MM_ATTRS_TYPE_DOUBLE:
+ LOGD("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
+ break;
+ case MM_ATTRS_TYPE_STRING:
+ LOGD("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
+ break;
+ case MM_ATTRS_TYPE_DATA:
+ LOGD("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
+ break;
+ default:
+ break;
+ }
+
+ return;
+}
+
+bool _mmplayer_commit_attribute(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
+{
+ bool ret = false;
+ mmplayer_t *player = MM_PLAYER_CAST(commit_param);
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && (attr_idx >= 0) && attr_name && value, false);
+
+ if (player->default_attrs[attr_idx].attr_commit) {
+ __mmplayer_print_attrs(attr_name, value, "Dynamic");
+ ret = player->default_attrs[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
+ } else {
+ __mmplayer_print_attrs(attr_name, value, "Static");
+ ret = true;
+ }
+
+ return ret;
+}
+
+int _mmplayer_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)