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

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

Issue 98823003: Supporting blob urls for html5 media (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/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_player_manager.h" 14 #include "media/base/android/media_player_manager.h"
15 #include "media/base/android/media_resource_getter.h" 15 #include "media/base/android/media_resource_getter.h"
16 16
17 using base::android::ConvertUTF8ToJavaString; 17 using base::android::ConvertUTF8ToJavaString;
18 using base::android::ScopedJavaLocalRef; 18 using base::android::ScopedJavaLocalRef;
19 19
20 // Time update happens every 250ms. 20 // Time update happens every 250ms.
21 static const int kTimeUpdateInterval = 250; 21 static const int kTimeUpdateInterval = 250;
22 22
23 // blob url scheme.
24 static const char kBlobScheme[] = "blob";
xhwang 2014/01/14 17:57:40 nit: "static" isn't necessary. Global const variab
qinmin 2014/01/14 21:48:33 Done.
25
23 namespace media { 26 namespace media {
24 27
25 MediaPlayerBridge::MediaPlayerBridge( 28 MediaPlayerBridge::MediaPlayerBridge(
26 int player_id, 29 int player_id,
27 const GURL& url, 30 const GURL& url,
28 const GURL& first_party_for_cookies, 31 const GURL& first_party_for_cookies,
29 bool hide_url_log, 32 bool hide_url_log,
30 MediaPlayerManager* manager) 33 MediaPlayerManager* manager)
31 : MediaPlayerAndroid(player_id, 34 : MediaPlayerAndroid(player_id,
32 manager), 35 manager),
(...skipping 15 matching lines...) Expand all
48 MediaPlayerBridge::~MediaPlayerBridge() { 51 MediaPlayerBridge::~MediaPlayerBridge() {
49 if (!j_media_player_bridge_.is_null()) { 52 if (!j_media_player_bridge_.is_null()) {
50 JNIEnv* env = base::android::AttachCurrentThread(); 53 JNIEnv* env = base::android::AttachCurrentThread();
51 CHECK(env); 54 CHECK(env);
52 Java_MediaPlayerBridge_destroy(env, j_media_player_bridge_.obj()); 55 Java_MediaPlayerBridge_destroy(env, j_media_player_bridge_.obj());
53 } 56 }
54 Release(); 57 Release();
55 } 58 }
56 59
57 void MediaPlayerBridge::Initialize() { 60 void MediaPlayerBridge::Initialize() {
61 cookies_.clear();
58 if (url_.SchemeIsFile()) { 62 if (url_.SchemeIsFile()) {
59 cookies_.clear();
60 ExtractMediaMetadata(url_.spec()); 63 ExtractMediaMetadata(url_.spec());
61 return; 64 return;
62 } 65 }
63 66
64 media::MediaResourceGetter* resource_getter = 67 media::MediaResourceGetter* resource_getter =
65 manager()->GetMediaResourceGetter(); 68 manager()->GetMediaResourceGetter();
66 if (url_.SchemeIsFileSystem()) { 69 if (url_.SchemeIsFileSystem() || url_.SchemeIs(kBlobScheme)) {
67 cookies_.clear(); 70 resource_getter->GetPlatformPathFromURL(url_, base::Bind(
68 resource_getter->GetPlatformPathFromFileSystemURL(url_, base::Bind(
69 &MediaPlayerBridge::ExtractMediaMetadata, weak_this_.GetWeakPtr())); 71 &MediaPlayerBridge::ExtractMediaMetadata, weak_this_.GetWeakPtr()));
70 return; 72 return;
71 } 73 }
72 74
73 resource_getter->GetCookies(url_, first_party_for_cookies_, base::Bind( 75 resource_getter->GetCookies(url_, first_party_for_cookies_, base::Bind(
74 &MediaPlayerBridge::OnCookiesRetrieved, weak_this_.GetWeakPtr())); 76 &MediaPlayerBridge::OnCookiesRetrieved, weak_this_.GetWeakPtr()));
75 } 77 }
76 78
77 void MediaPlayerBridge::CreateJavaMediaPlayerBridge() { 79 void MediaPlayerBridge::CreateJavaMediaPlayerBridge() {
78 JNIEnv* env = base::android::AttachCurrentThread(); 80 JNIEnv* env = base::android::AttachCurrentThread();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 JNIEnv* env = base::android::AttachCurrentThread(); 122 JNIEnv* env = base::android::AttachCurrentThread();
121 CHECK(env); 123 CHECK(env);
122 124
123 Java_MediaPlayerBridge_setSurface( 125 Java_MediaPlayerBridge_setSurface(
124 env, j_media_player_bridge_.obj(), surface.j_surface().obj()); 126 env, j_media_player_bridge_.obj(), surface.j_surface().obj());
125 } 127 }
126 128
127 void MediaPlayerBridge::Prepare() { 129 void MediaPlayerBridge::Prepare() {
128 DCHECK(j_media_player_bridge_.is_null()); 130 DCHECK(j_media_player_bridge_.is_null());
129 CreateJavaMediaPlayerBridge(); 131 CreateJavaMediaPlayerBridge();
130 if (url_.SchemeIsFileSystem()) { 132 if (url_.SchemeIsFileSystem() || url_.SchemeIs(kBlobScheme)) {
131 manager()->GetMediaResourceGetter()->GetPlatformPathFromFileSystemURL( 133 manager()->GetMediaResourceGetter()->GetPlatformPathFromURL(
132 url_, base::Bind(&MediaPlayerBridge::SetDataSource, 134 url_, base::Bind(&MediaPlayerBridge::SetDataSource,
133 weak_this_.GetWeakPtr())); 135 weak_this_.GetWeakPtr()));
134 } else { 136 return;
135 SetDataSource(url_.spec());
136 } 137 }
138
139 SetDataSource(url_.spec());
137 } 140 }
138 141
139 void MediaPlayerBridge::SetDataSource(const std::string& url) { 142 void MediaPlayerBridge::SetDataSource(const std::string& url) {
140 if (j_media_player_bridge_.is_null()) 143 if (j_media_player_bridge_.is_null())
141 return; 144 return;
142 145
143 JNIEnv* env = base::android::AttachCurrentThread(); 146 JNIEnv* env = base::android::AttachCurrentThread();
144 CHECK(env); 147 CHECK(env);
145 148
146 // Create a Java String for the URL. 149 // Create a Java String for the URL.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 452
450 GURL MediaPlayerBridge::GetUrl() { 453 GURL MediaPlayerBridge::GetUrl() {
451 return url_; 454 return url_;
452 } 455 }
453 456
454 GURL MediaPlayerBridge::GetFirstPartyForCookies() { 457 GURL MediaPlayerBridge::GetFirstPartyForCookies() {
455 return first_party_for_cookies_; 458 return first_party_for_cookies_;
456 } 459 }
457 460
458 } // namespace media 461 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698