From: Eunhye Choi Date: Mon, 11 Mar 2019 11:15:54 +0000 (+0900) Subject: [0.6.173] support audio pitch control X-Git-Tag: submit/tizen/20190319.063124^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F201228%2F8;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git [0.6.173] support audio pitch control - add pitch element in audiobin if user enable the pitch control via API Change-Id: I1f563ea00d2b036de00fa9702f55fbd0950df020 --- diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index e80c2cc..10a31fc 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.172 +Version: 0.6.173 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player.h b/src/include/mm_player.h index e16c579..7a97387 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -259,6 +259,17 @@ */ #define MM_PLAYER_AUDIO_OFFLOAD "audio_offload" +/** + * MM_PLAYER_PITCH_CONTROL (int) + */ +#define MM_PLAYER_PITCH_CONTROL "pitch_control" + +/** + * MM_PLAYER_PITCH_VALUE (double) + */ +#define MM_PLAYER_PITCH_VALUE "pitch_value" + + #define BUFFER_MAX_PLANE_NUM (4) typedef struct { diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 35d8f4c..beafbc0 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -208,6 +208,8 @@ enum AudioElementID { MMPLAYER_A_RESAMPLER, MMPLAYER_A_DEINTERLEAVE, MMPLAYER_A_RGVOL, + MMPLAYER_A_CONV_PITCH, + MMPLAYER_A_PITCH, MMPLAYER_A_NUM }; diff --git a/src/mm_player_attrs.c b/src/mm_player_attrs.c index e8a1fea..f1c1691 100644 --- a/src/mm_player_attrs.c +++ b/src/mm_player_attrs.c @@ -169,9 +169,27 @@ __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name) player = MM_PLAYER_CAST(handle); MMPlayerGstPipelineInfo *pipeline = player->pipeline; + /* before preparing, just keep the attr value */ + MMPLAYER_RETURN_VAL_IF_FAIL(pipeline && pipeline->mainbin, MM_ERROR_NONE); + + if (g_strrstr(attribute_name, MM_PLAYER_PITCH_VALUE)) { + int pitch_control = 0; + double pitch_value = 0; + + mm_attrs_multiple_get(player->attrs, NULL, + MM_PLAYER_PITCH_CONTROL, &pitch_control, + MM_PLAYER_PITCH_VALUE, &pitch_value, + NULL); + + if (!pitch_control || !pipeline->audiobin[MMPLAYER_A_PITCH].gst) + return MM_ERROR_PLAYER_NO_OP; + + LOGD("set pitch value to %1.3f", pitch_value); + g_object_set(pipeline->audiobin[MMPLAYER_A_PITCH].gst, "pitch", (gdouble)pitch_value, NULL); + } + /* Currently, there are only display related implementation at below */ - if (!pipeline || - !pipeline->videobin || + if (!pipeline->videobin || !pipeline->videobin[MMPLAYER_V_SINK].gst) { /* * The attribute should be committed even though videobin is not created yet. @@ -745,6 +763,24 @@ _mmplayer_construct_attribute(MMHandleType handle) FALSE, TRUE }, + { + "pitch_control", /* MM_PLAYER_PITCH_CONTROL */ + MM_ATTRS_TYPE_INT, + MM_ATTRS_FLAG_RW, + (void *)FALSE, + MM_ATTRS_VALID_TYPE_INT_RANGE, + FALSE, + TRUE + }, + { + "pitch_value", /* MM_PLAYER_PITCH_VALUE */ + MM_ATTRS_TYPE_DOUBLE, + MM_ATTRS_FLAG_RW, + (void *)1, + MM_ATTRS_VALID_TYPE_DOUBLE_RANGE, + 0.5, + 2 + }, }; num_of_attrs = ARRAY_SIZE(player_attrs); diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 72b4c9c..a4efccb 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -2576,6 +2576,8 @@ __mmplayer_gst_fill_audio_bucket(mm_player_t *player, GList **bucket) GList *element_bucket = NULL; GstCaps *acaps = NULL; GstPad *sink_pad = NULL; + int pitch_control = 0; + double pitch_value = 1.0; MMPLAYER_FENTER(); MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && @@ -2592,6 +2594,31 @@ __mmplayer_gst_fill_audio_bucket(mm_player_t *player, GList **bucket) goto DONE; } + /* pitch */ + mm_attrs_multiple_get(player->attrs, NULL, + MM_PLAYER_PITCH_CONTROL, &pitch_control, + MM_PLAYER_PITCH_VALUE, &pitch_value, + NULL); + + LOGD("pitch %d / %1.3f", pitch_control, pitch_value); + if (pitch_control && (player->videodec_linked == 0)) { + GstElementFactory *factory; + + factory = gst_element_factory_find("pitch"); + if (factory) { + gst_object_unref(factory); + + /* converter */ + MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV_PITCH, "audioconvert", "audio convert pitch", TRUE, player); + + /* pitch */ + MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_PITCH, "pitch", "audio pitch", TRUE, player); + g_object_set(G_OBJECT(audiobin[MMPLAYER_A_PITCH].gst), "pitch", (gdouble)pitch_value, NULL); + } else { + LOGW("there is no pitch element"); + } + } + /* converter */ MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CONV, "audioconvert", "audio converter", TRUE, player);