| 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_player_manager.h" | 15 #include "media/base/android/media_player_manager.h" |
| 15 #include "media/base/android/media_resource_getter.h" | 16 #include "media/base/android/media_resource_getter.h" |
| 16 #include "media/base/android/media_url_interceptor.h" | 17 #include "media/base/android/media_url_interceptor.h" |
| 17 | 18 |
| 18 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
| 19 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
| 20 | 21 |
| 21 // Time update happens every 250ms. | |
| 22 const int kTimeUpdateInterval = 250; | |
| 23 | |
| 24 namespace media { | 22 namespace media { |
| 25 | 23 |
| 26 MediaPlayerBridge::MediaPlayerBridge( | 24 MediaPlayerBridge::MediaPlayerBridge( |
| 27 int player_id, | 25 int player_id, |
| 28 const GURL& url, | 26 const GURL& url, |
| 29 const GURL& first_party_for_cookies, | 27 const GURL& first_party_for_cookies, |
| 30 const std::string& user_agent, | 28 const std::string& user_agent, |
| 31 bool hide_url_log, | 29 bool hide_url_log, |
| 32 MediaPlayerManager* manager, | 30 MediaPlayerManager* manager, |
| 33 const RequestMediaResourcesCB& request_media_resources_cb, | 31 const RequestMediaResourcesCB& request_media_resources_cb, |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 500 } |
| 503 | 501 |
| 504 JNIEnv* env = base::android::AttachCurrentThread(); | 502 JNIEnv* env = base::android::AttachCurrentThread(); |
| 505 CHECK(env); | 503 CHECK(env); |
| 506 int time_msec = static_cast<int>(time.InMilliseconds()); | 504 int time_msec = static_cast<int>(time.InMilliseconds()); |
| 507 Java_MediaPlayerBridge_seekTo( | 505 Java_MediaPlayerBridge_seekTo( |
| 508 env, j_media_player_bridge_.obj(), time_msec); | 506 env, j_media_player_bridge_.obj(), time_msec); |
| 509 } | 507 } |
| 510 | 508 |
| 511 void MediaPlayerBridge::OnTimeUpdateTimerFired() { | 509 void MediaPlayerBridge::OnTimeUpdateTimerFired() { |
| 512 manager()->OnTimeUpdate(player_id(), GetCurrentTime()); | 510 manager()->OnTimeUpdate( |
| 511 player_id(), GetCurrentTime(), base::TimeTicks::Now()); |
| 513 } | 512 } |
| 514 | 513 |
| 515 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { | 514 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { |
| 516 bool ret = RegisterNativesImpl(env); | 515 bool ret = RegisterNativesImpl(env); |
| 517 DCHECK(g_MediaPlayerBridge_clazz); | 516 DCHECK(g_MediaPlayerBridge_clazz); |
| 518 return ret; | 517 return ret; |
| 519 } | 518 } |
| 520 | 519 |
| 521 bool MediaPlayerBridge::CanPause() { | 520 bool MediaPlayerBridge::CanPause() { |
| 522 return can_pause_; | 521 return can_pause_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 540 | 539 |
| 541 GURL MediaPlayerBridge::GetFirstPartyForCookies() { | 540 GURL MediaPlayerBridge::GetFirstPartyForCookies() { |
| 542 return first_party_for_cookies_; | 541 return first_party_for_cookies_; |
| 543 } | 542 } |
| 544 | 543 |
| 545 bool MediaPlayerBridge::IsSurfaceInUse() const { | 544 bool MediaPlayerBridge::IsSurfaceInUse() const { |
| 546 return is_surface_in_use_; | 545 return is_surface_in_use_; |
| 547 } | 546 } |
| 548 | 547 |
| 549 } // namespace media | 548 } // namespace media |
| OLD | NEW |