} mmplayer_attrs_info_t;
/**
- * Volume type.
- *
- * @see mm_player_set_volume, mm_player_get_volume
- */
-typedef struct {
- float level[MM_VOLUME_CHANNEL_NUM]; /**< Relative volume factor for each channels */
-} mmplayer_volume_type_t;
-
-/**
* Video stream info in external demux case
*
**/
int mm_player_get_state(MMHandleType player, mmplayer_state_e *state);
/**
- * This function is to set relative volume of player. \n
- * So, It controls logical volume value. \n
- * But, if developer want to change system volume, mm sound api should be used.
- *
- * @param player [in] Handle of player
- * @param volume [in] Volume factor of each channel
- *
- * @return This function returns zero on success, or negative value with error code.
- * @see mmplayer_volume_type_t, mm_player_get_volume
- * @remark The range of factor range is from 0 to 1.0. (1.0 = 100%) And, default value is 1.0.
- * @par Example
- * @code
-mmplayer_volume_type_t volume;
-int i = 0;
-
-for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
- volume.level[i] = MM_VOLUME_LEVEL_MAX;
-
-if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
-{
- LOGE("failed to set volume\n");
-}
- * @endcode
+ * This function is to control logical volume.
*/
-int mm_player_set_volume(MMHandleType player, mmplayer_volume_type_t *volume);
+int mm_player_set_volume(MMHandleType player, float volume);
/**
* This function is to get current volume factor of player.
- *
- * @param player [in] Handle of player.
- * @param volume [out] Volume factor of each channel.
- *
- * @return This function returns zero on success, or negative value with error code.
- *
- * @see mmplayer_volume_type_t, mm_player_set_volume
- * @remark None
- * @par Example
- * @code
-mmplayer_volume_type_t volume;
-int i;
-
-if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE)
-{
- LOGW("failed to get volume\n");
-}
-
-for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
- LOGD("channel[%d] = %d \n", i, volume.level[i]);
- * @endcode
*/
-int mm_player_get_volume(MMHandleType player, mmplayer_volume_type_t *volume);
+int mm_player_get_volume(MMHandleType player, float *volume);
/**
* This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
* This function is to mute volume of player
*
* @param player [in] Handle of player
- * @param mute [in] Mute(1) or not mute(0)
+ * @param mute [in] mute value
*
* @return This function returns zero on success, or negative value with error code
* @see mm_player_get_mute
* @remark None
- * @par Example
- * @code
-if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE)
-{
- LOGW("failed to set mute\n");
-}
- * @endcode
*/
-int mm_player_set_mute(MMHandleType player, int mute);
+int mm_player_set_mute(MMHandleType player, bool mute);
/**
* This function is to get mute value of player
* @return This function returns zero on success, or negative value with error code
* @see mm_player_set_mute
* @remark None
- * @par Example
- * @code
-int mute;
-
-if (mm_player_get_mute(g_player, &mute) != MM_ERROR_NONE)
-{
- LOGW("failed to get mute\n");
-}
-
-LOGD("mute status:%d\n", mute);
- * @endcode
*/
-int mm_player_get_mute(MMHandleType player, int *mute);
+int mm_player_get_mute(MMHandleType player, bool *mute);
/**
* This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
if (player->build_audio_offload) { /* skip all the audio filters */
LOGD("create audio offload sink : %s", player->ini.audio_offload_sink_element);
+
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audio_offload_sink_element, "audiosink", element_bucket, player);
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE, NULL);
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE,
+ "volume", player->sound.volume, "mute", player->sound.mute, NULL);
+
__mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
goto DONE;
}
return MM_ERROR_NONE;
}
-
-int
-_mmplayer_set_volume(MMHandleType hplayer, mmplayer_volume_type_t volume)
+static int
+__mmplayer_gst_set_volume_property(mmplayer_t *player, const char *prop_name)
{
- mmplayer_t *player = (mmplayer_t *)hplayer;
GstElement *vol_element = NULL;
- int i = 0;
+ enum audio_element_id volume_elem_id = MMPLAYER_A_VOL;
MMPLAYER_FENTER();
-
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
- LOGD("volume [L]=%f:[R]=%f",
- volume.level[MM_VOLUME_CHANNEL_LEFT], volume.level[MM_VOLUME_CHANNEL_RIGHT]);
-
- /* invalid factor range or not */
- for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++) {
- if (volume.level[i] < MM_VOLUME_FACTOR_MIN || volume.level[i] > MM_VOLUME_FACTOR_MAX) {
- LOGE("Invalid factor!(valid factor:0~1.0)");
- return MM_ERROR_INVALID_ARGUMENT;
- }
- }
-
- /* not support to set other value into each channel */
- if ((volume.level[MM_VOLUME_CHANNEL_LEFT] != volume.level[MM_VOLUME_CHANNEL_RIGHT]))
- return MM_ERROR_INVALID_ARGUMENT;
-
- /* Save volume to handle. Currently the first array element will be saved. */
- player->sound.volume = volume.level[MM_VOLUME_CHANNEL_LEFT];
+ MMPLAYER_RETURN_VAL_IF_FAIL(prop_name, MM_ERROR_INVALID_ARGUMENT);
/* check pipeline handle */
if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("audiobin is not created yet");
- LOGD("but, current stored volume will be set when it's created.");
+ LOGD("'%s' will be applied when audiobin is created", prop_name);
- /* NOTE : stored volume will be used in create_audiobin
+ /* NOTE : stored value will be used in create_audiobin
* returning MM_ERROR_NONE here makes application to able to
- * set volume at anytime.
+ * set audio volume or mute at anytime.
*/
return MM_ERROR_NONE;
}
- /* setting volume to volume element */
- vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
+ if (player->build_audio_offload) {
+ LOGD("offload pipeline");
+ volume_elem_id = MMPLAYER_A_SINK;
+ }
+
+ vol_element = player->pipeline->audiobin[volume_elem_id].gst;
+ if (!vol_element) {
+ LOGE("failed to get vol element %d", volume_elem_id);
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
- if (vol_element) {
- LOGD("volume is set [%f]", player->sound.volume);
- g_object_set(vol_element, "volume", player->sound.volume, NULL);
+ LOGD("set '%s' property to element[%s]", prop_name, GST_ELEMENT_NAME(vol_element));
+
+ if (!g_object_class_find_property(G_OBJECT_GET_CLASS(vol_element), prop_name)) {
+ LOGE("there is no '%s' property", prop_name);
+ return MM_ERROR_PLAYER_INTERNAL;
}
- MMPLAYER_FLEAVE();
+ if (!strcmp(prop_name, "volume")) {
+ g_object_set(vol_element, "volume", player->sound.volume, NULL);
+ } else if (!strcmp(prop_name, "mute")) {
+ g_object_set(vol_element, "mute", player->sound.mute, NULL);
+ } else {
+ LOGE("invalid property %s", prop_name);
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
return MM_ERROR_NONE;
}
int
-_mmplayer_get_volume(MMHandleType hplayer, mmplayer_volume_type_t *volume)
+_mmplayer_set_volume(MMHandleType hplayer, float volume)
{
+ int ret = MM_ERROR_NONE;
mmplayer_t *player = (mmplayer_t *)hplayer;
- int i = 0;
MMPLAYER_FENTER();
-
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
- /* returning stored volume */
- for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
- volume->level[i] = player->sound.volume;
+ LOGD("volume = %f", volume);
- MMPLAYER_FLEAVE();
+ /* invalid factor range or not */
+ if (volume < MM_VOLUME_FACTOR_MIN || volume > MM_VOLUME_FACTOR_MAX) {
+ LOGE("Invalid volume value");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
- return MM_ERROR_NONE;
+ player->sound.volume = volume;
+
+ ret = __mmplayer_gst_set_volume_property(player, "volume");
+
+ MMPLAYER_FLEAVE();
+ return ret;
}
int
-_mmplayer_set_mute(MMHandleType hplayer, int mute)
+_mmplayer_get_volume(MMHandleType hplayer, float *volume)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
- GstElement *vol_element = NULL;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
- /* mute value shoud 0 or 1 */
- if (mute != 0 && mute != 1) {
- LOGE("bad mute value");
+ *volume = player->sound.volume;
- /* FIXIT : definitly, we need _BAD_PARAM error code */
- return MM_ERROR_INVALID_ARGUMENT;
- }
+ LOGD("current vol = %f", *volume);
- player->sound.mute = mute;
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_NONE;
+}
- /* just hold mute value if pipeline is not ready */
- if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("pipeline is not ready. holding mute value");
- return MM_ERROR_NONE;
- }
+int
+_mmplayer_set_mute(MMHandleType hplayer, bool mute)
+{
+ int ret = MM_ERROR_NONE;
+ mmplayer_t *player = (mmplayer_t *)hplayer;
- vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- /* NOTE : volume will only created when the bt is enabled */
- if (vol_element) {
- LOGD("mute : %d", mute);
- g_object_set(vol_element, "mute", mute, NULL);
- } else
- LOGD("volume elemnet is not created. using volume in audiosink");
+ LOGD("mute = %d", mute);
- MMPLAYER_FLEAVE();
+ player->sound.mute = mute;
- return MM_ERROR_NONE;
+ ret = __mmplayer_gst_set_volume_property(player, "mute");
+
+ MMPLAYER_FLEAVE();
+ return ret;
}
int
-_mmplayer_get_mute(MMHandleType hplayer, int *pmute)
+_mmplayer_get_mute(MMHandleType hplayer, bool *mute)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_RETURN_VAL_IF_FAIL(pmute, MM_ERROR_INVALID_ARGUMENT);
+ MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
- /* just hold mute value if pipeline is not ready */
- if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("pipeline is not ready. returning stored value");
- *pmute = player->sound.mute;
- return MM_ERROR_NONE;
- }
+ *mute = player->sound.mute;
- *pmute = player->sound.mute;
+ LOGD("current mute = %d", *mute);
MMPLAYER_FLEAVE();
mmplayer_t *player = (mmplayer_t *)hplayer;
gint64 pos_nsec = 0;
int ret = MM_ERROR_NONE;
- int mute = FALSE;
+ bool mute = false;
signed long long start = 0, stop = 0;
mmplayer_state_e current_state = MM_PLAYER_STATE_NONE;
MMPLAYER_FENTER();
/* The sound of video is not supported under 0.0 and over 2.0. */
if (rate >= TRICK_PLAY_MUTE_THRESHOLD_MAX || rate < TRICK_PLAY_MUTE_THRESHOLD_MIN) {
if (player->can_support_codec & FOUND_PLUGIN_VIDEO)
- mute = TRUE;
+ mute = true;
}
_mmplayer_set_mute(hplayer, mute);