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

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 23545029: EME: Handle NO_KEY and resume playback after key is added. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 7 years, 3 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/android/webmediaplayer_android.h" 5 #include "content/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include <limits>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
13 #include "cc/layers/video_layer.h" 15 #include "cc/layers/video_layer.h"
14 #include "content/renderer/media/android/proxy_media_keys.h" 16 #include "content/renderer/media/android/proxy_media_keys.h"
15 #include "content/renderer/media/android/renderer_media_player_manager.h" 17 #include "content/renderer/media/android/renderer_media_player_manager.h"
16 #include "content/renderer/media/android/webmediaplayer_proxy_android.h" 18 #include "content/renderer/media/android/webmediaplayer_proxy_android.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // TODO(xhwang): Report an error when there is encrypted stream but EME is 141 // TODO(xhwang): Report an error when there is encrypted stream but EME is
140 // not enabled. Currently the player just doesn't start and waits for ever. 142 // not enabled. Currently the player just doesn't start and waits for ever.
141 decryptor_.reset(new ProxyDecryptor( 143 decryptor_.reset(new ProxyDecryptor(
142 #if defined(ENABLE_PEPPER_CDMS) 144 #if defined(ENABLE_PEPPER_CDMS)
143 client, 145 client,
144 frame, 146 frame,
145 #else 147 #else
146 proxy_, 148 proxy_,
147 player_id_, // TODO(xhwang): Use media_keys_id when MediaKeys are 149 player_id_, // TODO(xhwang): Use media_keys_id when MediaKeys are
148 // separated from WebMediaPlayer. 150 // separated from WebMediaPlayer.
149 #endif // defined(ENABLE_PEPPER_CDMS) 151 #endif // defined(ENABLE_PEPPER_CDMS)
150 // |decryptor_| is owned, so Unretained() is safe here. 152 // |decryptor_| is owned, so Unretained() is safe here.
151 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)), 153 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)),
152 base::Bind(&WebMediaPlayerAndroid::OnKeyError, base::Unretained(this)), 154 base::Bind(&WebMediaPlayerAndroid::OnKeyError, base::Unretained(this)),
153 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, 155 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage,
154 base::Unretained(this)))); 156 base::Unretained(this))));
155 } 157 }
156 } 158 }
157 159
158 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { 160 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
159 SetVideoFrameProviderClient(NULL); 161 SetVideoFrameProviderClient(NULL);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // content contains video. Android does not provide any function to do 358 // content contains video. Android does not provide any function to do
357 // this. 359 // this.
358 // We don't know whether the current media content has video unless 360 // We don't know whether the current media content has video unless
359 // the player is prepared. If the player is not prepared, we fall back 361 // the player is prepared. If the player is not prepared, we fall back
360 // to the mime-type. There may be no mime-type on a redirect URL. 362 // to the mime-type. There may be no mime-type on a redirect URL.
361 // In that case, we conservatively assume it contains video so that 363 // In that case, we conservatively assume it contains video so that
362 // enterfullscreen call will not fail. 364 // enterfullscreen call will not fail.
363 if (!url_.has_path()) 365 if (!url_.has_path())
364 return false; 366 return false;
365 std::string mime; 367 std::string mime;
366 if(!net::GetMimeTypeFromFile(base::FilePath(url_.path()), &mime)) 368 if (!net::GetMimeTypeFromFile(base::FilePath(url_.path()), &mime))
367 return true; 369 return true;
368 return mime.find("audio/") == std::string::npos; 370 return mime.find("audio/") == std::string::npos;
369 } 371 }
370 372
371 bool WebMediaPlayerAndroid::hasAudio() const { 373 bool WebMediaPlayerAndroid::hasAudio() const {
372 // TODO(hclam): Query status of audio and return the actual value. 374 // TODO(hclam): Query status of audio and return the actual value.
373 return true; 375 return true;
374 } 376 }
375 377
376 bool WebMediaPlayerAndroid::paused() const { 378 bool WebMediaPlayerAndroid::paused() const {
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 if (current_key_system_.isEmpty() || key_system != current_key_system_) 1084 if (current_key_system_.isEmpty() || key_system != current_key_system_)
1083 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; 1085 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
1084 1086
1085 decryptor_->CancelKeyRequest(session_id.utf8()); 1087 decryptor_->CancelKeyRequest(session_id.utf8());
1086 return WebMediaPlayer::MediaKeyExceptionNoError; 1088 return WebMediaPlayer::MediaKeyExceptionNoError;
1087 } 1089 }
1088 1090
1089 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { 1091 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) {
1090 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); 1092 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1);
1091 1093
1094 #if defined(GOOGLE_TV)
1092 if (media_source_delegate_) 1095 if (media_source_delegate_)
1093 media_source_delegate_->NotifyKeyAdded(current_key_system_.utf8()); 1096 media_source_delegate_->NotifyKeyAdded(current_key_system_.utf8());
1097 #endif // defined(GOOGLE_TV)
1094 1098
1095 client_->keyAdded(current_key_system_, WebString::fromUTF8(session_id)); 1099 client_->keyAdded(current_key_system_, WebString::fromUTF8(session_id));
1096 } 1100 }
1097 1101
1098 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, 1102 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id,
1099 media::MediaKeys::KeyError error_code, 1103 media::MediaKeys::KeyError error_code,
1100 int system_code) { 1104 int system_code) {
1101 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", 1105 EmeUMAHistogramEnumeration(current_key_system_, "KeyError",
1102 error_code, media::MediaKeys::kMaxKeyError); 1106 error_code, media::MediaKeys::kMaxKeyError);
1103 1107
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1182
1179 void WebMediaPlayerAndroid::exitFullscreen() { 1183 void WebMediaPlayerAndroid::exitFullscreen() {
1180 proxy_->ExitFullscreen(player_id_); 1184 proxy_->ExitFullscreen(player_id_);
1181 } 1185 }
1182 1186
1183 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1187 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1184 return manager_->CanEnterFullscreen(frame_); 1188 return manager_->CanEnterFullscreen(frame_);
1185 } 1189 }
1186 1190
1187 } // namespace content 1191 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/media_source_delegate.cc ('k') | media/base/android/demuxer_stream_player_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698