| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "jni/MediaPlayerBridge_jni.h" | 13 #include "jni/MediaPlayerBridge_jni.h" |
| 14 #include "media/base/android/media_common_android.h" | 14 #include "media/base/android/media_common_android.h" |
| 15 #include "media/base/android/media_player_manager.h" | 15 #include "media/base/android/media_player_manager.h" |
| 16 #include "media/base/android/media_resource_getter.h" | 16 #include "media/base/android/media_resource_getter.h" |
| 17 #include "media/base/android/media_url_interceptor.h" | 17 #include "media/base/android/media_url_interceptor.h" |
| 18 #include "media/base/buffers.h" |
| 18 | 19 |
| 19 using base::android::ConvertUTF8ToJavaString; | 20 using base::android::ConvertUTF8ToJavaString; |
| 20 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 | 24 |
| 24 MediaPlayerBridge::MediaPlayerBridge( | 25 MediaPlayerBridge::MediaPlayerBridge( |
| 25 int player_id, | 26 int player_id, |
| 26 const GURL& url, | 27 const GURL& url, |
| 27 const GURL& first_party_for_cookies, | 28 const GURL& first_party_for_cookies, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 JNIEnv* env = base::android::AttachCurrentThread(); | 362 JNIEnv* env = base::android::AttachCurrentThread(); |
| 362 return base::TimeDelta::FromMilliseconds( | 363 return base::TimeDelta::FromMilliseconds( |
| 363 Java_MediaPlayerBridge_getCurrentPosition( | 364 Java_MediaPlayerBridge_getCurrentPosition( |
| 364 env, j_media_player_bridge_.obj())); | 365 env, j_media_player_bridge_.obj())); |
| 365 } | 366 } |
| 366 | 367 |
| 367 base::TimeDelta MediaPlayerBridge::GetDuration() { | 368 base::TimeDelta MediaPlayerBridge::GetDuration() { |
| 368 if (!prepared_) | 369 if (!prepared_) |
| 369 return duration_; | 370 return duration_; |
| 370 JNIEnv* env = base::android::AttachCurrentThread(); | 371 JNIEnv* env = base::android::AttachCurrentThread(); |
| 371 return base::TimeDelta::FromMilliseconds( | 372 const int duration_ms = |
| 372 Java_MediaPlayerBridge_getDuration( | 373 Java_MediaPlayerBridge_getDuration(env, j_media_player_bridge_.obj()); |
| 373 env, j_media_player_bridge_.obj())); | 374 return duration_ms < 0 ? media::kInfiniteDuration() |
| 375 : base::TimeDelta::FromMilliseconds(duration_ms); |
| 374 } | 376 } |
| 375 | 377 |
| 376 void MediaPlayerBridge::Release() { | 378 void MediaPlayerBridge::Release() { |
| 377 if (j_media_player_bridge_.is_null()) | 379 if (j_media_player_bridge_.is_null()) |
| 378 return; | 380 return; |
| 379 | 381 |
| 380 time_update_timer_.Stop(); | 382 time_update_timer_.Stop(); |
| 381 if (prepared_) | 383 if (prepared_) |
| 382 pending_seek_ = GetCurrentTime(); | 384 pending_seek_ = GetCurrentTime(); |
| 383 prepared_ = false; | 385 prepared_ = false; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 546 |
| 545 GURL MediaPlayerBridge::GetFirstPartyForCookies() { | 547 GURL MediaPlayerBridge::GetFirstPartyForCookies() { |
| 546 return first_party_for_cookies_; | 548 return first_party_for_cookies_; |
| 547 } | 549 } |
| 548 | 550 |
| 549 bool MediaPlayerBridge::IsSurfaceInUse() const { | 551 bool MediaPlayerBridge::IsSurfaceInUse() const { |
| 550 return is_surface_in_use_; | 552 return is_surface_in_use_; |
| 551 } | 553 } |
| 552 | 554 |
| 553 } // namespace media | 555 } // namespace media |
| OLD | NEW |