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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1070853004: media: CdmFactory creates CDM (MediaKeys) asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ScopedVector Created 5 years, 8 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
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/cdm/default_cdm_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 client_(client), 130 client_(client),
131 delegate_(delegate), 131 delegate_(delegate),
132 defer_load_cb_(params.defer_load_cb()), 132 defer_load_cb_(params.defer_load_cb()),
133 context_3d_cb_(params.context_3d_cb()), 133 context_3d_cb_(params.context_3d_cb()),
134 supports_save_(true), 134 supports_save_(true),
135 chunk_demuxer_(NULL), 135 chunk_demuxer_(NULL),
136 compositor_task_runner_(params.compositor_task_runner()), 136 compositor_task_runner_(params.compositor_task_runner()),
137 compositor_(new VideoFrameCompositor( 137 compositor_(new VideoFrameCompositor(
138 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 138 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
139 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 139 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
140 encrypted_media_support_( 140 encrypted_media_support_(cdm_factory,
141 cdm_factory, 141 client,
142 client, 142 params.media_permission(),
143 params.media_permission(), 143 base::Bind(&WebMediaPlayerImpl::SetCdm,
144 base::Bind(&WebMediaPlayerImpl::SetCdm, AsWeakPtr())), 144 AsWeakPtr(),
145 base::Bind(&IgnoreCdmAttached))),
145 renderer_factory_(renderer_factory.Pass()) { 146 renderer_factory_(renderer_factory.Pass()) {
146 // Threaded compositing isn't enabled universally yet. 147 // Threaded compositing isn't enabled universally yet.
147 if (!compositor_task_runner_.get()) 148 if (!compositor_task_runner_.get())
148 compositor_task_runner_ = base::MessageLoopProxy::current(); 149 compositor_task_runner_ = base::MessageLoopProxy::current();
149 150
150 media_log_->AddEvent( 151 media_log_->AddEvent(
151 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 152 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
152 153
153 if (params.initial_cdm()) { 154 if (params.initial_cdm()) {
154 SetCdm( 155 SetCdm(base::Bind(&IgnoreCdmAttached),
155 ToWebContentDecryptionModuleImpl(params.initial_cdm())->GetCdmContext(), 156 ToWebContentDecryptionModuleImpl(params.initial_cdm())
156 base::Bind(&IgnoreCdmAttached)); 157 ->GetCdmContext());
157 } 158 }
158 159
159 // TODO(xhwang): When we use an external Renderer, many methods won't work, 160 // TODO(xhwang): When we use an external Renderer, many methods won't work,
160 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 161 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861
161 162
162 // Use the null sink if no sink was provided. 163 // Use the null sink if no sink was provided.
163 audio_source_provider_ = new WebAudioSourceProviderImpl( 164 audio_source_provider_ = new WebAudioSourceProviderImpl(
164 params.audio_renderer_sink().get() 165 params.audio_renderer_sink().get()
165 ? params.audio_renderer_sink() 166 ? params.audio_renderer_sink()
166 : new NullAudioSink(media_task_runner_)); 167 : new NullAudioSink(media_task_runner_));
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 DCHECK(main_task_runner_->BelongsToCurrentThread()); 654 DCHECK(main_task_runner_->BelongsToCurrentThread());
654 655
655 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 656 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324
656 if (!cdm) { 657 if (!cdm) {
657 result.completeWithError( 658 result.completeWithError(
658 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 659 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
659 "Null MediaKeys object is not supported."); 660 "Null MediaKeys object is not supported.");
660 return; 661 return;
661 } 662 }
662 663
663 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), 664 SetCdm(BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result),
664 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); 665 ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext());
665 } 666 }
666 667
667 void WebMediaPlayerImpl::OnEncryptedMediaInitData( 668 void WebMediaPlayerImpl::OnEncryptedMediaInitData(
668 EmeInitDataType init_data_type, 669 EmeInitDataType init_data_type,
669 const std::vector<uint8>& init_data) { 670 const std::vector<uint8>& init_data) {
670 DCHECK(init_data_type != EmeInitDataType::UNKNOWN); 671 DCHECK(init_data_type != EmeInitDataType::UNKNOWN);
671 672
672 // Do not fire "encrypted" event if encrypted media is not enabled. 673 // Do not fire "encrypted" event if encrypted media is not enabled.
673 // TODO(xhwang): Handle this in |client_|. 674 // TODO(xhwang): Handle this in |client_|.
674 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 675 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
(...skipping 13 matching lines...) Expand all
688 689
689 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 690 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
690 client_->didBlockPlaybackWaitingForKey(); 691 client_->didBlockPlaybackWaitingForKey();
691 692
692 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 693 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
693 // when a key has been successfully added (e.g. OnSessionKeysChange() with 694 // when a key has been successfully added (e.g. OnSessionKeysChange() with
694 // |has_additional_usable_key| = true). http://crbug.com/461903 695 // |has_additional_usable_key| = true). http://crbug.com/461903
695 client_->didResumePlaybackBlockedForKey(); 696 client_->didResumePlaybackBlockedForKey();
696 } 697 }
697 698
698 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, 699 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
699 const CdmAttachedCB& cdm_attached_cb) { 700 CdmContext* cdm_context) {
700 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 701 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
701 } 702 }
702 703
703 void WebMediaPlayerImpl::OnCdmAttached( 704 void WebMediaPlayerImpl::OnCdmAttached(
704 blink::WebContentDecryptionModuleResult result, 705 blink::WebContentDecryptionModuleResult result,
705 bool success) { 706 bool success) {
706 if (success) { 707 if (success) {
707 result.complete(); 708 result.complete();
708 return; 709 return;
709 } 710 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 1022
1022 // pause() may be called after playback has ended and the HTMLMediaElement 1023 // pause() may be called after playback has ended and the HTMLMediaElement
1023 // requires that currentTime() == duration() after ending. We want to ensure 1024 // requires that currentTime() == duration() after ending. We want to ensure
1024 // |paused_time_| matches currentTime() in this case or a future seek() may 1025 // |paused_time_| matches currentTime() in this case or a future seek() may
1025 // incorrectly discard what it thinks is a seek to the existing time. 1026 // incorrectly discard what it thinks is a seek to the existing time.
1026 paused_time_ = 1027 paused_time_ =
1027 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); 1028 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime();
1028 } 1029 }
1029 1030
1030 } // namespace media 1031 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/cdm/default_cdm_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698