Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: media/base/android/media_player_bridge.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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 "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/basictypes.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
13 #include "jni/MediaPlayerBridge_jni.h" 12 #include "jni/MediaPlayerBridge_jni.h"
14 #include "media/base/android/media_common_android.h" 13 #include "media/base/android/media_common_android.h"
15 #include "media/base/android/media_player_manager.h" 14 #include "media/base/android/media_player_manager.h"
16 #include "media/base/android/media_resource_getter.h" 15 #include "media/base/android/media_resource_getter.h"
17 #include "media/base/android/media_url_interceptor.h" 16 #include "media/base/android/media_url_interceptor.h"
18 #include "media/base/timestamp_constants.h" 17 #include "media/base/timestamp_constants.h"
19 18
20 using base::android::ConvertUTF8ToJavaString; 19 using base::android::ConvertUTF8ToJavaString;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 136 }
138 137
139 void MediaPlayerBridge::SetDataSource(const std::string& url) { 138 void MediaPlayerBridge::SetDataSource(const std::string& url) {
140 if (j_media_player_bridge_.is_null()) 139 if (j_media_player_bridge_.is_null())
141 return; 140 return;
142 141
143 JNIEnv* env = base::android::AttachCurrentThread(); 142 JNIEnv* env = base::android::AttachCurrentThread();
144 CHECK(env); 143 CHECK(env);
145 144
146 int fd; 145 int fd;
147 int64 offset; 146 int64_t offset;
148 int64 size; 147 int64_t size;
149 if (InterceptMediaUrl(url, &fd, &offset, &size)) { 148 if (InterceptMediaUrl(url, &fd, &offset, &size)) {
150 if (!Java_MediaPlayerBridge_setDataSourceFromFd( 149 if (!Java_MediaPlayerBridge_setDataSourceFromFd(
151 env, j_media_player_bridge_.obj(), fd, offset, size)) { 150 env, j_media_player_bridge_.obj(), fd, offset, size)) {
152 OnMediaError(MEDIA_ERROR_FORMAT); 151 OnMediaError(MEDIA_ERROR_FORMAT);
153 return; 152 return;
154 } 153 }
155 } else { 154 } else {
156 // Create a Java String for the URL. 155 // Create a Java String for the URL.
157 ScopedJavaLocalRef<jstring> j_url_string = 156 ScopedJavaLocalRef<jstring> j_url_string =
158 ConvertUTF8ToJavaString(env, url); 157 ConvertUTF8ToJavaString(env, url);
(...skipping 20 matching lines...) Expand all
179 j_cookies.obj(), j_user_agent.obj(), hide_url_log_)) { 178 j_cookies.obj(), j_user_agent.obj(), hide_url_log_)) {
180 OnMediaError(MEDIA_ERROR_FORMAT); 179 OnMediaError(MEDIA_ERROR_FORMAT);
181 return; 180 return;
182 } 181 }
183 } 182 }
184 183
185 if (!Java_MediaPlayerBridge_prepareAsync(env, j_media_player_bridge_.obj())) 184 if (!Java_MediaPlayerBridge_prepareAsync(env, j_media_player_bridge_.obj()))
186 OnMediaError(MEDIA_ERROR_FORMAT); 185 OnMediaError(MEDIA_ERROR_FORMAT);
187 } 186 }
188 187
189 bool MediaPlayerBridge::InterceptMediaUrl( 188 bool MediaPlayerBridge::InterceptMediaUrl(const std::string& url,
190 const std::string& url, int* fd, int64* offset, int64* size) { 189 int* fd,
190 int64_t* offset,
191 int64_t* size) {
191 // Sentinel value to check whether the output arguments have been set. 192 // Sentinel value to check whether the output arguments have been set.
192 const int kUnsetValue = -1; 193 const int kUnsetValue = -1;
193 194
194 *fd = kUnsetValue; 195 *fd = kUnsetValue;
195 *offset = kUnsetValue; 196 *offset = kUnsetValue;
196 *size = kUnsetValue; 197 *size = kUnsetValue;
197 media::MediaUrlInterceptor* url_interceptor = 198 media::MediaUrlInterceptor* url_interceptor =
198 manager()->GetMediaUrlInterceptor(); 199 manager()->GetMediaUrlInterceptor();
199 if (url_interceptor && url_interceptor->Intercept(url, fd, offset, size)) { 200 if (url_interceptor && url_interceptor->Intercept(url, fd, offset, size)) {
200 DCHECK_NE(kUnsetValue, *fd); 201 DCHECK_NE(kUnsetValue, *fd);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 240 }
240 241
241 void MediaPlayerBridge::ExtractMediaMetadata(const std::string& url) { 242 void MediaPlayerBridge::ExtractMediaMetadata(const std::string& url) {
242 if (url.empty()) { 243 if (url.empty()) {
243 OnMediaError(MEDIA_ERROR_FORMAT); 244 OnMediaError(MEDIA_ERROR_FORMAT);
244 on_decoder_resources_released_cb_.Run(player_id()); 245 on_decoder_resources_released_cb_.Run(player_id());
245 return; 246 return;
246 } 247 }
247 248
248 int fd; 249 int fd;
249 int64 offset; 250 int64_t offset;
250 int64 size; 251 int64_t size;
251 if (InterceptMediaUrl(url, &fd, &offset, &size)) { 252 if (InterceptMediaUrl(url, &fd, &offset, &size)) {
252 manager()->GetMediaResourceGetter()->ExtractMediaMetadata( 253 manager()->GetMediaResourceGetter()->ExtractMediaMetadata(
253 fd, offset, size, 254 fd, offset, size,
254 base::Bind(&MediaPlayerBridge::OnMediaMetadataExtracted, 255 base::Bind(&MediaPlayerBridge::OnMediaMetadataExtracted,
255 weak_factory_.GetWeakPtr())); 256 weak_factory_.GetWeakPtr()));
256 } else { 257 } else {
257 manager()->GetMediaResourceGetter()->ExtractMediaMetadata( 258 manager()->GetMediaResourceGetter()->ExtractMediaMetadata(
258 url, cookies_, user_agent_, 259 url, cookies_, user_agent_,
259 base::Bind(&MediaPlayerBridge::OnMediaMetadataExtracted, 260 base::Bind(&MediaPlayerBridge::OnMediaMetadataExtracted,
260 weak_factory_.GetWeakPtr())); 261 weak_factory_.GetWeakPtr()));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 535
535 GURL MediaPlayerBridge::GetUrl() { 536 GURL MediaPlayerBridge::GetUrl() {
536 return url_; 537 return url_;
537 } 538 }
538 539
539 GURL MediaPlayerBridge::GetFirstPartyForCookies() { 540 GURL MediaPlayerBridge::GetFirstPartyForCookies() {
540 return first_party_for_cookies_; 541 return first_party_for_cookies_;
541 } 542 }
542 543
543 } // namespace media 544 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698