diff options
-rw-r--r-- | packaging/libmm-player.spec | 2 | ||||
-rw-r--r-- | src/include/mm_player_sound_focus.h | 1 | ||||
-rw-r--r-- | src/mm_player_priv.c | 11 | ||||
-rw-r--r-- | src/mm_player_sound_focus.c | 27 |
4 files changed, 37 insertions, 4 deletions
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index ab49199..efd7c1d 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.27 +Version: 0.6.28 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player_sound_focus.h b/src/include/mm_player_sound_focus.h index ae5a1a8..a9bb690 100644 --- a/src/include/mm_player_sound_focus.h +++ b/src/include/mm_player_sound_focus.h @@ -59,6 +59,7 @@ gint _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus, mm_sound_focus_ch gint _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus); int _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus); int _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus); +bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus); #ifdef __cplusplus } diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index b2c6d2d..3755568 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -4532,13 +4532,14 @@ ERROR: void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType attrs) { - #define MAX_PROPS_LEN 64 + #define MAX_PROPS_LEN 128 gint latency_mode = 0; gchar *stream_type = NULL; gchar *latency = NULL; gint stream_id = 0; gchar stream_props[MAX_PROPS_LEN] = {0,}; GstStructure *props = NULL; + gint stream_focus_status = 0; /* set volume table * It should be set after player creation through attribute. @@ -4551,10 +4552,14 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att if (!stream_type) { LOGE("stream_type is null.\n"); } else { - snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d", stream_type, stream_id); + if (_mmplayer_is_using_internal_sound_focus(&player->sound_focus)) + stream_focus_status = 1; + + snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_status=%d", + stream_type, stream_id, stream_focus_status); props = gst_structure_from_string(stream_props, NULL); g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL); - LOGD("stream_id[%d], stream_type[%s], result[%s].\n", stream_id, stream_type, stream_props); + LOGI("stream_id[%d], stream_type[%s], stream_focus[%d], result[%s].\n", stream_id, stream_type, stream_focus_status, stream_props); } mm_attrs_get_int_by_name(attrs, "sound_latency_mode", &latency_mode); diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c index 5d4b727..73548eb 100644 --- a/src/mm_player_sound_focus.c +++ b/src/mm_player_sound_focus.c @@ -217,9 +217,11 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus, gint pid = -1; gint ret = MM_ERROR_NONE; const gchar *stream_type = NULL; + mm_player_t* player = MM_PLAYER_CAST(param); MMPLAYER_FENTER(); MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus); + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_INVALID_ARGUMENT); /* check if it's running on the media_server */ if (sound_focus->pid > 0) @@ -315,6 +317,12 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus, } LOGD("register device connected callback for the value is 0, sub_cb id %d\n", sound_focus->connected_id); } + + ret = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), (char *)NULL); + if (ret != MM_ERROR_NONE) { + LOGE("mm_player_set_attribute for sound_stream_type is failed\n"); + return ret; + } } ret = MM_ERROR_NONE; } else { @@ -367,3 +375,22 @@ _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus) return MM_ERROR_NONE; } +bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus) +{ + MMPLAYER_RETURN_VAL_IF_FAIL(sound_focus, false); + + /* Perhaps, already got release signal or application may use stream focus directly */ + if (sound_focus->focus_id == 0) + return false; + + if ((sound_focus->session_type == MM_SESSION_TYPE_MEDIA && sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) || + (sound_focus->session_type == MM_SESSION_TYPE_CALL) || + (sound_focus->session_type == MM_SESSION_TYPE_VIDEOCALL) || + (sound_focus->session_type == MM_SESSION_TYPE_VOIP) || + (sound_focus->session_type == MM_SESSION_TYPE_NOTIFY) || + (sound_focus->session_type == MM_SESSION_TYPE_ALARM) || + (sound_focus->session_type == MM_SESSION_TYPE_EMERGENCY)) + return true; + else + return false; +}
\ No newline at end of file |