Chromium Code Reviews| Index: content/renderer/media/android/webmediaplayer_android.cc |
| diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc |
| index f5dd958ba5c10fd7a5cce1640997d7ee6dcfd3a0..5dbee6a068ff98428f16367bd521da6174ea0328 100644 |
| --- a/content/renderer/media/android/webmediaplayer_android.cc |
| +++ b/content/renderer/media/android/webmediaplayer_android.cc |
| @@ -40,6 +40,7 @@ |
| #include "media/base/video_frame.h" |
| #include "net/base/mime_util.h" |
| #include "third_party/WebKit/public/platform/Platform.h" |
| +#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
| #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" |
| #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
| #include "third_party/WebKit/public/platform/WebString.h" |
| @@ -96,6 +97,10 @@ class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
| blink::WebGraphicsContext3D* web_graphics_context_; |
| }; |
| +// Used for calls to decryptor_ready_cb_ where the result can be ignored. |
| +void DoNothing(bool) { |
| +} |
| + |
| } // namespace |
| namespace content { |
| @@ -1369,7 +1374,7 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal( |
| if (!decryptor_ready_cb_.is_null()) { |
| base::ResetAndReturn(&decryptor_ready_cb_) |
| - .Run(proxy_decryptor_->GetDecryptor()); |
| + .Run(proxy_decryptor_->GetDecryptor(), base::Bind(DoNothing)); |
| } |
| // Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do |
| @@ -1488,13 +1493,78 @@ void WebMediaPlayerAndroid::setContentDecryptionModule( |
| if (!web_cdm_) |
| return; |
| - if (!decryptor_ready_cb_.is_null()) |
| - base::ResetAndReturn(&decryptor_ready_cb_).Run(web_cdm_->GetDecryptor()); |
| + if (!decryptor_ready_cb_.is_null()) { |
| + base::ResetAndReturn(&decryptor_ready_cb_) |
| + .Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
| + } |
| + |
| + if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) |
| + player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| +} |
| + |
| +void WebMediaPlayerAndroid::setContentDecryptionModule( |
| + blink::WebContentDecryptionModule* cdm, |
| + blink::WebContentDecryptionModuleResult result) { |
| + DCHECK(main_thread_checker_.CalledOnValidThread()); |
| + |
| + // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
| + if (!cdm) { |
| + result.completeWithError( |
| + blink::WebContentDecryptionModuleExceptionNotSupportedError, |
| + 0, |
| + "Null MediaKeys object is not supported."); |
|
xhwang
2014/08/12 16:12:59
return here?
jrummell
2014/08/12 22:54:18
Done.
|
| + } |
| + |
| + web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
| + if (!web_cdm_) |
| + return; |
|
xhwang
2014/08/12 16:12:59
Now with the |result|, we need to make sure the |r
jrummell
2014/08/12 22:54:18
Done.
|
| + |
| + if (!decryptor_ready_cb_.is_null()) { |
| + base::ResetAndReturn(&decryptor_ready_cb_).Run( |
| + web_cdm_->GetDecryptor(), |
| + media::BindToCurrentLoop( |
| + base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, |
| + weak_factory_.GetWeakPtr(), |
| + result))); |
| + } else { |
| + // No pipeline/decoder connected, so resolve the promise. When something |
| + // is connected, setting the CDM will happen in SetDecryptorReadyCB(). |
| + ContentDecryptionModuleAttached(result, true); |
| + } |
| + |
| + if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) |
| + player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| +} |
| + |
| +void WebMediaPlayerAndroid::setContentDecryptionModuleSync( |
| + blink::WebContentDecryptionModule* cdm) { |
| + DCHECK(main_thread_checker_.CalledOnValidThread()); |
| + |
| + // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
| + if (!cdm) |
| + return; |
| + |
| + DCHECK(decryptor_ready_cb_.is_null()); |
| + web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
| if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) |
| player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| } |
| +void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( |
| + blink::WebContentDecryptionModuleResult result, |
| + bool success) { |
| + if (success) { |
| + result.complete(); |
| + return; |
| + } |
| + |
| + result.completeWithError( |
| + blink::WebContentDecryptionModuleExceptionNotSupportedError, |
| + 0, |
| + "Unable to set MediaKeys object"); |
| +} |
| + |
| void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { |
| EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); |
| @@ -1569,8 +1639,10 @@ void WebMediaPlayerAndroid::SetDecryptorReadyCB( |
| // Cancels the previous decryptor request. |
| if (decryptor_ready_cb.is_null()) { |
| - if (!decryptor_ready_cb_.is_null()) |
| - base::ResetAndReturn(&decryptor_ready_cb_).Run(NULL); |
| + if (!decryptor_ready_cb_.is_null()) { |
| + base::ResetAndReturn(&decryptor_ready_cb_) |
| + .Run(NULL, base::Bind(DoNothing)); |
| + } |
| return; |
| } |
| @@ -1585,12 +1657,13 @@ void WebMediaPlayerAndroid::SetDecryptorReadyCB( |
| DCHECK(!proxy_decryptor_ || !web_cdm_); |
| if (proxy_decryptor_) { |
| - decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor()); |
| + decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor(), |
| + base::Bind(DoNothing)); |
| return; |
| } |
| if (web_cdm_) { |
| - decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); |
| + decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
| return; |
| } |