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

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

Issue 1712903002: Remove prefixed EME. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix layout tests. Created 4 years, 10 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 "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #define BIND_TO_RENDER_LOOP1(function, arg1) \ 123 #define BIND_TO_RENDER_LOOP1(function, arg1) \
124 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 124 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
125 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) 125 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1)))
126 126
127 WebMediaPlayerImpl::WebMediaPlayerImpl( 127 WebMediaPlayerImpl::WebMediaPlayerImpl(
128 blink::WebLocalFrame* frame, 128 blink::WebLocalFrame* frame,
129 blink::WebMediaPlayerClient* client, 129 blink::WebMediaPlayerClient* client,
130 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, 130 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
131 base::WeakPtr<WebMediaPlayerDelegate> delegate, 131 base::WeakPtr<WebMediaPlayerDelegate> delegate,
132 scoped_ptr<RendererFactory> renderer_factory, 132 scoped_ptr<RendererFactory> renderer_factory,
133 CdmFactory* cdm_factory,
134 linked_ptr<UrlIndex> url_index, 133 linked_ptr<UrlIndex> url_index,
135 const WebMediaPlayerParams& params) 134 const WebMediaPlayerParams& params)
136 : frame_(frame), 135 : frame_(frame),
137 network_state_(WebMediaPlayer::NetworkStateEmpty), 136 network_state_(WebMediaPlayer::NetworkStateEmpty),
138 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 137 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
139 preload_(BufferedDataSource::AUTO), 138 preload_(BufferedDataSource::AUTO),
140 buffering_strategy_( 139 buffering_strategy_(
141 BufferedDataSourceInterface::BUFFERING_STRATEGY_NORMAL), 140 BufferedDataSourceInterface::BUFFERING_STRATEGY_NORMAL),
142 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 141 main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
143 media_task_runner_(params.media_task_runner()), 142 media_task_runner_(params.media_task_runner()),
(...skipping 30 matching lines...) Expand all
174 url_index_(url_index), 173 url_index_(url_index),
175 // Threaded compositing isn't enabled universally yet. 174 // Threaded compositing isn't enabled universally yet.
176 compositor_task_runner_( 175 compositor_task_runner_(
177 params.compositor_task_runner() 176 params.compositor_task_runner()
178 ? params.compositor_task_runner() 177 ? params.compositor_task_runner()
179 : base::MessageLoop::current()->task_runner()), 178 : base::MessageLoop::current()->task_runner()),
180 compositor_(new VideoFrameCompositor( 179 compositor_(new VideoFrameCompositor(
181 compositor_task_runner_, 180 compositor_task_runner_,
182 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 181 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
183 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 182 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
184 encrypted_media_support_(cdm_factory,
185 encrypted_client,
186 params.media_permission(),
187 base::Bind(&WebMediaPlayerImpl::SetCdm,
188 AsWeakPtr(),
189 base::Bind(&IgnoreCdmAttached))),
190 is_cdm_attached_(false), 183 is_cdm_attached_(false),
191 #if defined(OS_ANDROID) // WMPI_CAST 184 #if defined(OS_ANDROID) // WMPI_CAST
192 cast_impl_(this, client_, params.context_3d_cb()), 185 cast_impl_(this, client_, params.context_3d_cb()),
193 #endif 186 #endif
194 volume_(1.0), 187 volume_(1.0),
195 volume_multiplier_(1.0), 188 volume_multiplier_(1.0),
196 renderer_factory_(std::move(renderer_factory)), 189 renderer_factory_(std::move(renderer_factory)),
197 surface_manager_(params.surface_manager()) { 190 surface_manager_(params.surface_manager()) {
198 DCHECK(!adjust_allocated_memory_cb_.is_null()); 191 DCHECK(!adjust_allocated_memory_cb_.is_null());
199 DCHECK(renderer_factory_); 192 DCHECK(renderer_factory_);
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // GLES2Interface. 784 // GLES2Interface.
792 gpu::gles2::GLES2Interface* gl = 785 gpu::gles2::GLES2Interface* gl =
793 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) 786 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
794 ->GetGLInterface(); 787 ->GetGLInterface();
795 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( 788 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
796 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, 789 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha,
797 flip_y); 790 flip_y);
798 return true; 791 return true;
799 } 792 }
800 793
801 WebMediaPlayer::MediaKeyException
802 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system,
803 const unsigned char* init_data,
804 unsigned init_data_length) {
805 DCHECK(main_task_runner_->BelongsToCurrentThread());
806
807 return encrypted_media_support_.GenerateKeyRequest(
808 frame_, key_system, init_data, init_data_length);
809 }
810
811 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey(
812 const WebString& key_system,
813 const unsigned char* key,
814 unsigned key_length,
815 const unsigned char* init_data,
816 unsigned init_data_length,
817 const WebString& session_id) {
818 DCHECK(main_task_runner_->BelongsToCurrentThread());
819
820 return encrypted_media_support_.AddKey(
821 key_system, key, key_length, init_data, init_data_length, session_id);
822 }
823
824 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::cancelKeyRequest(
825 const WebString& key_system,
826 const WebString& session_id) {
827 DCHECK(main_task_runner_->BelongsToCurrentThread());
828
829 return encrypted_media_support_.CancelKeyRequest(key_system, session_id);
830 }
831
832 void WebMediaPlayerImpl::setContentDecryptionModule( 794 void WebMediaPlayerImpl::setContentDecryptionModule(
833 blink::WebContentDecryptionModule* cdm, 795 blink::WebContentDecryptionModule* cdm,
834 blink::WebContentDecryptionModuleResult result) { 796 blink::WebContentDecryptionModuleResult result) {
835 DCHECK(main_task_runner_->BelongsToCurrentThread()); 797 DCHECK(main_task_runner_->BelongsToCurrentThread());
836 798
837 // Once the CDM is set it can't be cleared as there may be frames being 799 // Once the CDM is set it can't be cleared as there may be frames being
838 // decrypted on other threads. So fail this request. 800 // decrypted on other threads. So fail this request.
839 // http://crbug.com/462365#c7. 801 // http://crbug.com/462365#c7.
840 if (!cdm) { 802 if (!cdm) {
841 result.completeWithError( 803 result.completeWithError(
(...skipping 18 matching lines...) Expand all
860 822
861 SetCdm(BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnCdmAttached), 823 SetCdm(BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnCdmAttached),
862 ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext()); 824 ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext());
863 } 825 }
864 826
865 void WebMediaPlayerImpl::OnEncryptedMediaInitData( 827 void WebMediaPlayerImpl::OnEncryptedMediaInitData(
866 EmeInitDataType init_data_type, 828 EmeInitDataType init_data_type,
867 const std::vector<uint8_t>& init_data) { 829 const std::vector<uint8_t>& init_data) {
868 DCHECK(init_data_type != EmeInitDataType::UNKNOWN); 830 DCHECK(init_data_type != EmeInitDataType::UNKNOWN);
869 831
870 // Do not fire "encrypted" event if encrypted media is not enabled. 832 // Do not fire the "encrypted" event if Encrypted Media is not enabled.
871 // TODO(xhwang): Handle this in |client_|. 833 // EME may not be enabled on Android Jelly Bean.
872 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 834 if (!blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
873 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
874 return; 835 return;
875 } 836 }
876 837
877 // TODO(xhwang): Update this UMA name. 838 // TODO(xhwang): Update this UMA name.
878 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 839 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
879 840
880 encrypted_media_support_.SetInitDataType(init_data_type);
881
882 encrypted_client_->encrypted( 841 encrypted_client_->encrypted(
883 ConvertToWebInitDataType(init_data_type), init_data.data(), 842 ConvertToWebInitDataType(init_data_type), init_data.data(),
884 base::saturated_cast<unsigned int>(init_data.size())); 843 base::saturated_cast<unsigned int>(init_data.size()));
885 } 844 }
886 845
887 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 846 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
888 encrypted_client_->didBlockPlaybackWaitingForKey(); 847 encrypted_client_->didBlockPlaybackWaitingForKey();
889 848
890 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 849 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
891 // when a key has been successfully added (e.g. OnSessionKeysChange() with 850 // when a key has been successfully added (e.g. OnSessionKeysChange() with
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1574 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1616 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1575 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1617 << ", Demuxer: " << demuxer_memory_usage; 1576 << ", Demuxer: " << demuxer_memory_usage;
1618 1577
1619 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1578 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1620 last_reported_memory_usage_ = current_memory_usage; 1579 last_reported_memory_usage_ = current_memory_usage;
1621 adjust_allocated_memory_cb_.Run(delta); 1580 adjust_allocated_memory_cb_.Run(delta);
1622 } 1581 }
1623 1582
1624 } // namespace media 1583 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698