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

Side by Side Diff: content/renderer/media/webmediaplayer_impl.cc

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
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/webmediaplayer_impl.h" 5 #include "content/renderer/media/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "media/filters/chunk_demuxer.h" 54 #include "media/filters/chunk_demuxer.h"
55 #include "media/filters/ffmpeg_audio_decoder.h" 55 #include "media/filters/ffmpeg_audio_decoder.h"
56 #include "media/filters/ffmpeg_demuxer.h" 56 #include "media/filters/ffmpeg_demuxer.h"
57 #include "media/filters/ffmpeg_video_decoder.h" 57 #include "media/filters/ffmpeg_video_decoder.h"
58 #include "media/filters/gpu_video_accelerator_factories.h" 58 #include "media/filters/gpu_video_accelerator_factories.h"
59 #include "media/filters/gpu_video_decoder.h" 59 #include "media/filters/gpu_video_decoder.h"
60 #include "media/filters/opus_audio_decoder.h" 60 #include "media/filters/opus_audio_decoder.h"
61 #include "media/filters/video_renderer_impl.h" 61 #include "media/filters/video_renderer_impl.h"
62 #include "media/filters/vpx_video_decoder.h" 62 #include "media/filters/vpx_video_decoder.h"
63 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" 63 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
64 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
64 #include "third_party/WebKit/public/platform/WebMediaSource.h" 65 #include "third_party/WebKit/public/platform/WebMediaSource.h"
65 #include "third_party/WebKit/public/platform/WebRect.h" 66 #include "third_party/WebKit/public/platform/WebRect.h"
66 #include "third_party/WebKit/public/platform/WebSize.h" 67 #include "third_party/WebKit/public/platform/WebSize.h"
67 #include "third_party/WebKit/public/platform/WebString.h" 68 #include "third_party/WebKit/public/platform/WebString.h"
68 #include "third_party/WebKit/public/platform/WebURL.h" 69 #include "third_party/WebKit/public/platform/WebURL.h"
69 #include "third_party/WebKit/public/web/WebDocument.h" 70 #include "third_party/WebKit/public/web/WebDocument.h"
70 #include "third_party/WebKit/public/web/WebLocalFrame.h" 71 #include "third_party/WebKit/public/web/WebLocalFrame.h"
71 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 72 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
72 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 73 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
73 #include "third_party/WebKit/public/web/WebView.h" 74 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnKeyError), 777 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnKeyError),
777 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnKeyMessage))); 778 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnKeyMessage)));
778 } 779 }
779 780
780 GURL security_origin(frame_->document().securityOrigin().toString()); 781 GURL security_origin(frame_->document().securityOrigin().toString());
781 if (!proxy_decryptor_->InitializeCDM(key_system, security_origin)) 782 if (!proxy_decryptor_->InitializeCDM(key_system, security_origin))
782 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; 783 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
783 784
784 if (proxy_decryptor_ && !decryptor_ready_cb_.is_null()) { 785 if (proxy_decryptor_ && !decryptor_ready_cb_.is_null()) {
785 base::ResetAndReturn(&decryptor_ready_cb_) 786 base::ResetAndReturn(&decryptor_ready_cb_)
786 .Run(proxy_decryptor_->GetDecryptor()); 787 .Run(proxy_decryptor_->GetDecryptor(), base::Closure());
xhwang 2014/07/29 20:58:07 Here and below, use base::Bind(&base::DoNothing) i
jrummell 2014/07/30 00:15:13 Done.
787 } 788 }
788 789
789 current_key_system_ = key_system; 790 current_key_system_ = key_system;
790 } else if (key_system != current_key_system_) { 791 } else if (key_system != current_key_system_) {
791 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; 792 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
792 } 793 }
793 794
794 std::string init_data_type = init_data_type_; 795 std::string init_data_type = init_data_type_;
795 if (init_data_type.empty()) 796 if (init_data_type.empty())
796 init_data_type = GuessInitDataType(init_data, init_data_length); 797 init_data_type = GuessInitDataType(init_data, init_data_length);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 if (current_key_system_.empty() || key_system != current_key_system_) 882 if (current_key_system_.empty() || key_system != current_key_system_)
882 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; 883 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
883 884
884 proxy_decryptor_->CancelKeyRequest(session_id); 885 proxy_decryptor_->CancelKeyRequest(session_id);
885 return WebMediaPlayer::MediaKeyExceptionNoError; 886 return WebMediaPlayer::MediaKeyExceptionNoError;
886 } 887 }
887 888
888 void WebMediaPlayerImpl::setContentDecryptionModule( 889 void WebMediaPlayerImpl::setContentDecryptionModule(
889 blink::WebContentDecryptionModule* cdm) { 890 blink::WebContentDecryptionModule* cdm) {
890 DCHECK(main_loop_->BelongsToCurrentThread()); 891 DCHECK(main_loop_->BelongsToCurrentThread());
892 // TODO(jrummell): Remove this method once blink starts calling with 2
893 // parameters.
891 894
892 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 895 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324
893 if (!cdm) 896 if (!cdm)
894 return; 897 return;
895 898
896 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); 899 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm);
897 900
898 if (web_cdm_ && !decryptor_ready_cb_.is_null()) 901 if (web_cdm_ && !decryptor_ready_cb_.is_null())
899 base::ResetAndReturn(&decryptor_ready_cb_).Run(web_cdm_->GetDecryptor()); 902 base::ResetAndReturn(&decryptor_ready_cb_)
903 .Run(web_cdm_->GetDecryptor(), base::Closure());
904 }
905
906 void WebMediaPlayerImpl::setContentDecryptionModule(
907 blink::WebContentDecryptionModule* cdm,
908 blink::WebContentDecryptionModuleResult result) {
909 DCHECK(main_loop_->BelongsToCurrentThread());
910
911 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324
912 if (!cdm) {
913 result.completeWithError(
914 blink::WebContentDecryptionModuleExceptionNotSupportedError,
915 0,
916 "The existing MediaKeys object cannot be removed.");
xhwang 2014/07/29 20:58:07 We may not have a CDM set yet. So more accurately
jrummell 2014/07/30 00:15:13 Done.
917 return;
918 }
919
920 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm);
921
922 if (web_cdm_ && !decryptor_ready_cb_.is_null()) {
923 base::ResetAndReturn(&decryptor_ready_cb_)
924 .Run(web_cdm_->GetDecryptor(),
925 BIND_TO_RENDER_LOOP1(
926 &WebMediaPlayerImpl::ContentDecryptionModuleSet, result));
927 } else {
928 // No player, so setting CDM is complete.
xhwang 2014/07/29 20:58:07 This is more of a spec question, so +ddorwin for c
ddorwin 2014/07/30 22:41:34 As I noted in the next PS, I'm not sure this comme
929 ContentDecryptionModuleSet(result);
930 }
931 }
932
933 void WebMediaPlayerImpl::ContentDecryptionModuleSet(
934 blink::WebContentDecryptionModuleResult result) {
935 result.complete();
900 } 936 }
901 937
902 void WebMediaPlayerImpl::InvalidateOnMainThread() { 938 void WebMediaPlayerImpl::InvalidateOnMainThread() {
903 DCHECK(main_loop_->BelongsToCurrentThread()); 939 DCHECK(main_loop_->BelongsToCurrentThread());
904 TRACE_EVENT0("media", "WebMediaPlayerImpl::InvalidateOnMainThread"); 940 TRACE_EVENT0("media", "WebMediaPlayerImpl::InvalidateOnMainThread");
905 941
906 client_->repaint(); 942 client_->repaint();
907 } 943 }
908 944
909 void WebMediaPlayerImpl::OnPipelineSeeked(bool time_changed, 945 void WebMediaPlayerImpl::OnPipelineSeeked(bool time_changed,
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 frame)); 1344 frame));
1309 } 1345 }
1310 1346
1311 void WebMediaPlayerImpl::SetDecryptorReadyCB( 1347 void WebMediaPlayerImpl::SetDecryptorReadyCB(
1312 const media::DecryptorReadyCB& decryptor_ready_cb) { 1348 const media::DecryptorReadyCB& decryptor_ready_cb) {
1313 DCHECK(main_loop_->BelongsToCurrentThread()); 1349 DCHECK(main_loop_->BelongsToCurrentThread());
1314 1350
1315 // Cancels the previous decryptor request. 1351 // Cancels the previous decryptor request.
1316 if (decryptor_ready_cb.is_null()) { 1352 if (decryptor_ready_cb.is_null()) {
1317 if (!decryptor_ready_cb_.is_null()) 1353 if (!decryptor_ready_cb_.is_null())
1318 base::ResetAndReturn(&decryptor_ready_cb_).Run(NULL); 1354 base::ResetAndReturn(&decryptor_ready_cb_).Run(NULL, base::Closure());
1319 return; 1355 return;
1320 } 1356 }
1321 1357
1322 // TODO(xhwang): Support multiple decryptor notification request (e.g. from 1358 // TODO(xhwang): Support multiple decryptor notification request (e.g. from
1323 // video and audio). The current implementation is okay for the current 1359 // video and audio). The current implementation is okay for the current
1324 // media pipeline since we initialize audio and video decoders in sequence. 1360 // media pipeline since we initialize audio and video decoders in sequence.
1325 // But WebMediaPlayerImpl should not depend on media pipeline's implementation 1361 // But WebMediaPlayerImpl should not depend on media pipeline's implementation
1326 // detail. 1362 // detail.
1327 DCHECK(decryptor_ready_cb_.is_null()); 1363 DCHECK(decryptor_ready_cb_.is_null());
1328 1364
1329 // Mixed use of prefixed and unprefixed EME APIs is disallowed by Blink. 1365 // Mixed use of prefixed and unprefixed EME APIs is disallowed by Blink.
1330 DCHECK(!proxy_decryptor_ || !web_cdm_); 1366 DCHECK(!proxy_decryptor_ || !web_cdm_);
1331 1367
1332 if (proxy_decryptor_) { 1368 if (proxy_decryptor_) {
1333 decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor()); 1369 decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor(), base::Closure());
1334 return; 1370 return;
1335 } 1371 }
1336 1372
1337 if (web_cdm_) { 1373 if (web_cdm_) {
1338 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); 1374 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Closure());
1339 return; 1375 return;
1340 } 1376 }
1341 1377
1342 decryptor_ready_cb_ = decryptor_ready_cb; 1378 decryptor_ready_cb_ = decryptor_ready_cb;
1343 } 1379 }
1344 1380
1345 static void GetCurrentFrameAndSignal( 1381 static void GetCurrentFrameAndSignal(
1346 VideoFrameCompositor* compositor, 1382 VideoFrameCompositor* compositor,
1347 scoped_refptr<media::VideoFrame>* video_frame_out, 1383 scoped_refptr<media::VideoFrame>* video_frame_out,
1348 base::WaitableEvent* event) { 1384 base::WaitableEvent* event) {
(...skipping 15 matching lines...) Expand all
1364 compositor_task_runner_->PostTask(FROM_HERE, 1400 compositor_task_runner_->PostTask(FROM_HERE,
1365 base::Bind(&GetCurrentFrameAndSignal, 1401 base::Bind(&GetCurrentFrameAndSignal,
1366 base::Unretained(compositor_), 1402 base::Unretained(compositor_),
1367 &video_frame, 1403 &video_frame,
1368 &event)); 1404 &event));
1369 event.Wait(); 1405 event.Wait();
1370 return video_frame; 1406 return video_frame;
1371 } 1407 }
1372 1408
1373 } // namespace content 1409 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698