| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/media/session/media_session_delegate_android.h" | 5 #include "content/browser/media/session/media_session_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "jni/MediaSessionDelegate_jni.h" | 9 #include "jni/MediaSessionDelegate_jni.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 void MediaSessionDelegateAndroid::Initialize() { | 31 void MediaSessionDelegateAndroid::Initialize() { |
| 32 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
| 33 DCHECK(env); | 33 DCHECK(env); |
| 34 j_media_session_delegate_.Reset(Java_MediaSessionDelegate_create( | 34 j_media_session_delegate_.Reset(Java_MediaSessionDelegate_create( |
| 35 env, | 35 env, |
| 36 base::android::GetApplicationContext(), | 36 base::android::GetApplicationContext(), |
| 37 reinterpret_cast<intptr_t>(this))); | 37 reinterpret_cast<intptr_t>(this))); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool MediaSessionDelegateAndroid::RequestAudioFocus(MediaSession::Type type) { | 40 bool MediaSessionDelegateAndroid::RequestAudioFocus( |
| 41 AudioFocusManager::AudioFocusType audio_focus_type) { |
| 41 JNIEnv* env = base::android::AttachCurrentThread(); | 42 JNIEnv* env = base::android::AttachCurrentThread(); |
| 42 DCHECK(env); | 43 DCHECK(env); |
| 43 return Java_MediaSessionDelegate_requestAudioFocus( | 44 return Java_MediaSessionDelegate_requestAudioFocus( |
| 44 env, j_media_session_delegate_, type == MediaSession::Type::Transient); | 45 env, j_media_session_delegate_, |
| 46 audio_focus_type == |
| 47 AudioFocusManager::AudioFocusType::GainTransientMayDuck); |
| 45 } | 48 } |
| 46 | 49 |
| 47 void MediaSessionDelegateAndroid::AbandonAudioFocus() { | 50 void MediaSessionDelegateAndroid::AbandonAudioFocus() { |
| 48 JNIEnv* env = base::android::AttachCurrentThread(); | 51 JNIEnv* env = base::android::AttachCurrentThread(); |
| 49 DCHECK(env); | 52 DCHECK(env); |
| 50 Java_MediaSessionDelegate_abandonAudioFocus(env, j_media_session_delegate_); | 53 Java_MediaSessionDelegate_abandonAudioFocus(env, j_media_session_delegate_); |
| 51 } | 54 } |
| 52 | 55 |
| 53 void MediaSessionDelegateAndroid::OnSuspend( | 56 void MediaSessionDelegateAndroid::OnSuspend( |
| 54 JNIEnv*, const JavaParamRef<jobject>&, jboolean temporary) { | 57 JNIEnv*, const JavaParamRef<jobject>&, jboolean temporary) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // static | 89 // static |
| 87 std::unique_ptr<MediaSessionDelegate> MediaSessionDelegate::Create( | 90 std::unique_ptr<MediaSessionDelegate> MediaSessionDelegate::Create( |
| 88 MediaSession* media_session) { | 91 MediaSession* media_session) { |
| 89 MediaSessionDelegateAndroid* delegate = | 92 MediaSessionDelegateAndroid* delegate = |
| 90 new MediaSessionDelegateAndroid(media_session); | 93 new MediaSessionDelegateAndroid(media_session); |
| 91 delegate->Initialize(); | 94 delegate->Initialize(); |
| 92 return std::unique_ptr<MediaSessionDelegate>(delegate); | 95 return std::unique_ptr<MediaSessionDelegate>(delegate); |
| 93 } | 96 } |
| 94 | 97 |
| 95 } // namespace content | 98 } // namespace content |
| OLD | NEW |