| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/context_utils.h" | |
| 10 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 12 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 16 #include "jni/MediaPlayerBridge_jni.h" | 15 #include "jni/MediaPlayerBridge_jni.h" |
| 17 #include "media/base/android/media_common_android.h" | 16 #include "media/base/android/media_common_android.h" |
| 18 #include "media/base/android/media_player_manager.h" | 17 #include "media/base/android/media_player_manager.h" |
| 19 #include "media/base/android/media_resource_getter.h" | 18 #include "media/base/android/media_resource_getter.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (!Java_MediaPlayerBridge_setDataSourceFromFd(env, j_media_player_bridge_, | 170 if (!Java_MediaPlayerBridge_setDataSourceFromFd(env, j_media_player_bridge_, |
| 172 fd, offset, size)) { | 171 fd, offset, size)) { |
| 173 OnMediaError(MEDIA_ERROR_FORMAT); | 172 OnMediaError(MEDIA_ERROR_FORMAT); |
| 174 return; | 173 return; |
| 175 } | 174 } |
| 176 } else { | 175 } else { |
| 177 // Create a Java String for the URL. | 176 // Create a Java String for the URL. |
| 178 ScopedJavaLocalRef<jstring> j_url_string = | 177 ScopedJavaLocalRef<jstring> j_url_string = |
| 179 ConvertUTF8ToJavaString(env, url); | 178 ConvertUTF8ToJavaString(env, url); |
| 180 | 179 |
| 181 const JavaRef<jobject>& j_context = base::android::GetApplicationContext(); | |
| 182 | |
| 183 const std::string data_uri_prefix("data:"); | 180 const std::string data_uri_prefix("data:"); |
| 184 if (base::StartsWith(url, data_uri_prefix, base::CompareCase::SENSITIVE)) { | 181 if (base::StartsWith(url, data_uri_prefix, base::CompareCase::SENSITIVE)) { |
| 185 if (!Java_MediaPlayerBridge_setDataUriDataSource( | 182 if (!Java_MediaPlayerBridge_setDataUriDataSource( |
| 186 env, j_media_player_bridge_, j_context, j_url_string)) { | 183 env, j_media_player_bridge_, j_url_string)) { |
| 187 OnMediaError(MEDIA_ERROR_FORMAT); | 184 OnMediaError(MEDIA_ERROR_FORMAT); |
| 188 } | 185 } |
| 189 return; | 186 return; |
| 190 } | 187 } |
| 191 | 188 |
| 192 ScopedJavaLocalRef<jstring> j_cookies = ConvertUTF8ToJavaString( | 189 ScopedJavaLocalRef<jstring> j_cookies = ConvertUTF8ToJavaString( |
| 193 env, cookies_); | 190 env, cookies_); |
| 194 ScopedJavaLocalRef<jstring> j_user_agent = ConvertUTF8ToJavaString( | 191 ScopedJavaLocalRef<jstring> j_user_agent = ConvertUTF8ToJavaString( |
| 195 env, user_agent_); | 192 env, user_agent_); |
| 196 | 193 |
| 197 if (!Java_MediaPlayerBridge_setDataSource( | 194 if (!Java_MediaPlayerBridge_setDataSource(env, j_media_player_bridge_, |
| 198 env, j_media_player_bridge_, j_context, j_url_string, j_cookies, | 195 j_url_string, j_cookies, |
| 199 j_user_agent, hide_url_log_)) { | 196 j_user_agent, hide_url_log_)) { |
| 200 OnMediaError(MEDIA_ERROR_FORMAT); | 197 OnMediaError(MEDIA_ERROR_FORMAT); |
| 201 return; | 198 return; |
| 202 } | 199 } |
| 203 } | 200 } |
| 204 | 201 |
| 205 if (!Java_MediaPlayerBridge_prepareAsync(env, j_media_player_bridge_)) | 202 if (!Java_MediaPlayerBridge_prepareAsync(env, j_media_player_bridge_)) |
| 206 OnMediaError(MEDIA_ERROR_FORMAT); | 203 OnMediaError(MEDIA_ERROR_FORMAT); |
| 207 } | 204 } |
| 208 | 205 |
| 209 bool MediaPlayerBridge::InterceptMediaUrl(const std::string& url, | 206 bool MediaPlayerBridge::InterceptMediaUrl(const std::string& url, |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 592 |
| 596 GURL MediaPlayerBridge::GetUrl() { | 593 GURL MediaPlayerBridge::GetUrl() { |
| 597 return url_; | 594 return url_; |
| 598 } | 595 } |
| 599 | 596 |
| 600 GURL MediaPlayerBridge::GetFirstPartyForCookies() { | 597 GURL MediaPlayerBridge::GetFirstPartyForCookies() { |
| 601 return first_party_for_cookies_; | 598 return first_party_for_cookies_; |
| 602 } | 599 } |
| 603 | 600 |
| 604 } // namespace media | 601 } // namespace media |
| OLD | NEW |