[v0.6.28] Enhance session backward compatibility 14/112914/1 accepted/tizen/common/20170206.124401 submit/tizen/20170206.043356
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 3 Feb 2017 05:37:00 +0000 (14:37 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Fri, 3 Feb 2017 08:42:48 +0000 (00:42 -0800)
Stream type and stream focus status are applied to the audiosink in case of
session backward compatibility, so it brings proper audio routing path in pulseaudio.

Change-Id: I31c1c37ce65b9467ea298f12cd64f1f8de327d7d
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit b2149f09ed2de1ac0a9fdc91c50657bb3699de0c)

packaging/libmm-player.spec
src/include/mm_player_sound_focus.h
src/mm_player_priv.c
src/mm_player_sound_focus.c

index 9838dd4..2f674c3 100644 (file)
@@ -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
index ae5a1a8..a9bb690 100644 (file)
@@ -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
 }
index fc82243..f0f470a 100644 (file)
@@ -4534,13 +4534,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.
@@ -4553,10 +4554,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);
index 5d4b727..73548eb 100644 (file)
@@ -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