| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/base/android/media_player_bridge.h" | 5 #include "media/base/android/media_player_bridge.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 12 #include "jni/MediaPlayerBridge_jni.h" | 14 #include "jni/MediaPlayerBridge_jni.h" |
| 13 #include "media/base/android/media_common_android.h" | 15 #include "media/base/android/media_common_android.h" |
| 14 #include "media/base/android/media_player_manager.h" | 16 #include "media/base/android/media_player_manager.h" |
| 15 #include "media/base/android/media_resource_getter.h" | 17 #include "media/base/android/media_resource_getter.h" |
| 16 #include "media/base/android/media_url_interceptor.h" | 18 #include "media/base/android/media_url_interceptor.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 SetVolume(volume_); | 104 SetVolume(volume_); |
| 103 | 105 |
| 104 AttachListener(j_media_player_bridge_.obj()); | 106 AttachListener(j_media_player_bridge_.obj()); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void MediaPlayerBridge::SetDuration(base::TimeDelta duration) { | 109 void MediaPlayerBridge::SetDuration(base::TimeDelta duration) { |
| 108 duration_ = duration; | 110 duration_ = duration; |
| 109 } | 111 } |
| 110 | 112 |
| 111 void MediaPlayerBridge::SetVideoSurface(gfx::ScopedJavaSurface surface) { | 113 void MediaPlayerBridge::SetVideoSurface(gfx::ScopedJavaSurface surface) { |
| 112 surface_ = surface.Pass(); | 114 surface_ = std::move(surface); |
| 113 | 115 |
| 114 if (j_media_player_bridge_.is_null()) | 116 if (j_media_player_bridge_.is_null()) |
| 115 return; | 117 return; |
| 116 | 118 |
| 117 JNIEnv* env = base::android::AttachCurrentThread(); | 119 JNIEnv* env = base::android::AttachCurrentThread(); |
| 118 CHECK(env); | 120 CHECK(env); |
| 119 | 121 |
| 120 Java_MediaPlayerBridge_setSurface( | 122 Java_MediaPlayerBridge_setSurface( |
| 121 env, j_media_player_bridge_.obj(), surface_.j_surface().obj()); | 123 env, j_media_player_bridge_.obj(), surface_.j_surface().obj()); |
| 122 } | 124 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 412 |
| 411 // If media player was recovered from a saved state, consume all the pending | 413 // If media player was recovered from a saved state, consume all the pending |
| 412 // events. | 414 // events. |
| 413 if (should_seek_on_prepare_) { | 415 if (should_seek_on_prepare_) { |
| 414 PendingSeekInternal(pending_seek_); | 416 PendingSeekInternal(pending_seek_); |
| 415 pending_seek_ = base::TimeDelta::FromMilliseconds(0); | 417 pending_seek_ = base::TimeDelta::FromMilliseconds(0); |
| 416 should_seek_on_prepare_ = false; | 418 should_seek_on_prepare_ = false; |
| 417 } | 419 } |
| 418 | 420 |
| 419 if (!surface_.IsEmpty()) | 421 if (!surface_.IsEmpty()) |
| 420 SetVideoSurface(surface_.Pass()); | 422 SetVideoSurface(std::move(surface_)); |
| 421 | 423 |
| 422 if (pending_play_) { | 424 if (pending_play_) { |
| 423 StartInternal(); | 425 StartInternal(); |
| 424 pending_play_ = false; | 426 pending_play_ = false; |
| 425 } | 427 } |
| 426 | 428 |
| 427 UpdateAllowedOperations(); | 429 UpdateAllowedOperations(); |
| 428 manager()->OnMediaMetadataChanged( | 430 manager()->OnMediaMetadataChanged( |
| 429 player_id(), duration_, width_, height_, true); | 431 player_id(), duration_, width_, height_, true); |
| 430 } | 432 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 537 |
| 536 GURL MediaPlayerBridge::GetUrl() { | 538 GURL MediaPlayerBridge::GetUrl() { |
| 537 return url_; | 539 return url_; |
| 538 } | 540 } |
| 539 | 541 |
| 540 GURL MediaPlayerBridge::GetFirstPartyForCookies() { | 542 GURL MediaPlayerBridge::GetFirstPartyForCookies() { |
| 541 return first_party_for_cookies_; | 543 return first_party_for_cookies_; |
| 542 } | 544 } |
| 543 | 545 |
| 544 } // namespace media | 546 } // namespace media |
| OLD | NEW |