| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "media/filters/opus_audio_decoder.h" | 53 #include "media/filters/opus_audio_decoder.h" |
| 54 #include "media/filters/renderer_impl.h" | 54 #include "media/filters/renderer_impl.h" |
| 55 #include "media/filters/video_renderer_impl.h" | 55 #include "media/filters/video_renderer_impl.h" |
| 56 #include "media/filters/vpx_video_decoder.h" | 56 #include "media/filters/vpx_video_decoder.h" |
| 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
| 58 #include "third_party/WebKit/public/platform/WebRect.h" | 58 #include "third_party/WebKit/public/platform/WebRect.h" |
| 59 #include "third_party/WebKit/public/platform/WebSize.h" | 59 #include "third_party/WebKit/public/platform/WebSize.h" |
| 60 #include "third_party/WebKit/public/platform/WebString.h" | 60 #include "third_party/WebKit/public/platform/WebString.h" |
| 61 #include "third_party/WebKit/public/platform/WebURL.h" | 61 #include "third_party/WebKit/public/platform/WebURL.h" |
| 62 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 62 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 63 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 63 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 64 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 64 #include "third_party/WebKit/public/web/WebView.h" | 65 #include "third_party/WebKit/public/web/WebView.h" |
| 65 | 66 |
| 66 using blink::WebCanvas; | 67 using blink::WebCanvas; |
| 67 using blink::WebMediaPlayer; | 68 using blink::WebMediaPlayer; |
| 68 using blink::WebRect; | 69 using blink::WebRect; |
| 69 using blink::WebSize; | 70 using blink::WebSize; |
| 70 using blink::WebString; | 71 using blink::WebString; |
| 71 | 72 |
| 72 namespace { | 73 namespace { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 result.completeWithError( | 693 result.completeWithError( |
| 693 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 694 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| 694 "Null MediaKeys object is not supported."); | 695 "Null MediaKeys object is not supported."); |
| 695 return; | 696 return; |
| 696 } | 697 } |
| 697 | 698 |
| 698 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), | 699 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), |
| 699 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); | 700 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); |
| 700 } | 701 } |
| 701 | 702 |
| 703 void WebMediaPlayerImpl::OnNeedKey(const std::string& init_data_type, |
| 704 const std::vector<uint8>& init_data) { |
| 705 DCHECK(!init_data_type.empty()); |
| 706 |
| 707 // Do not fire NeedKey event if encrypted media is not enabled. |
| 708 // TODO(xhwang): Handle this in |client_|. |
| 709 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && |
| 710 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { |
| 711 return; |
| 712 } |
| 713 |
| 714 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); |
| 715 |
| 716 encrypted_media_support_.SetInitDataType(init_data_type); |
| 717 |
| 718 const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0]; |
| 719 client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr, |
| 720 base::saturated_cast<unsigned int>(init_data.size())); |
| 721 } |
| 722 |
| 702 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, | 723 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, |
| 703 const CdmAttachedCB& cdm_attached_cb) { | 724 const CdmAttachedCB& cdm_attached_cb) { |
| 704 pipeline_.SetCdm(cdm_context, cdm_attached_cb); | 725 pipeline_.SetCdm(cdm_context, cdm_attached_cb); |
| 705 } | 726 } |
| 706 | 727 |
| 707 void WebMediaPlayerImpl::OnCdmAttached( | 728 void WebMediaPlayerImpl::OnCdmAttached( |
| 708 blink::WebContentDecryptionModuleResult result, | 729 blink::WebContentDecryptionModuleResult result, |
| 709 bool success) { | 730 bool success) { |
| 710 if (success) { | 731 if (success) { |
| 711 result.complete(); | 732 result.complete(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 924 |
| 904 void WebMediaPlayerImpl::StartPipeline() { | 925 void WebMediaPlayerImpl::StartPipeline() { |
| 905 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 926 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 906 | 927 |
| 907 // Keep track if this is a MSE or non-MSE playback. | 928 // Keep track if this is a MSE or non-MSE playback. |
| 908 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", | 929 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", |
| 909 (load_type_ == LoadTypeMediaSource)); | 930 (load_type_ == LoadTypeMediaSource)); |
| 910 | 931 |
| 911 LogCB mse_log_cb; | 932 LogCB mse_log_cb; |
| 912 Demuxer::NeedKeyCB need_key_cb = | 933 Demuxer::NeedKeyCB need_key_cb = |
| 913 encrypted_media_support_.CreateNeedKeyCB(); | 934 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey); |
| 914 | 935 |
| 915 // Figure out which demuxer to use. | 936 // Figure out which demuxer to use. |
| 916 if (load_type_ != LoadTypeMediaSource) { | 937 if (load_type_ != LoadTypeMediaSource) { |
| 917 DCHECK(!chunk_demuxer_); | 938 DCHECK(!chunk_demuxer_); |
| 918 DCHECK(data_source_); | 939 DCHECK(data_source_); |
| 919 | 940 |
| 920 demuxer_.reset(new FFmpegDemuxer( | 941 demuxer_.reset(new FFmpegDemuxer( |
| 921 media_task_runner_, data_source_.get(), | 942 media_task_runner_, data_source_.get(), |
| 922 need_key_cb, | 943 need_key_cb, |
| 923 media_log_)); | 944 media_log_)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 compositor_task_runner_->PostTask(FROM_HERE, | 1072 compositor_task_runner_->PostTask(FROM_HERE, |
| 1052 base::Bind(&GetCurrentFrameAndSignal, | 1073 base::Bind(&GetCurrentFrameAndSignal, |
| 1053 base::Unretained(compositor_), | 1074 base::Unretained(compositor_), |
| 1054 &video_frame, | 1075 &video_frame, |
| 1055 &event)); | 1076 &event)); |
| 1056 event.Wait(); | 1077 event.Wait(); |
| 1057 return video_frame; | 1078 return video_frame; |
| 1058 } | 1079 } |
| 1059 | 1080 |
| 1060 } // namespace media | 1081 } // namespace media |
| OLD | NEW |