[v0.6.28] Enhance session backward compatibility
[platform/core/multimedia/libmm-player.git] / src / mm_player_sound_focus.c
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