Chromium Code Reviews| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 video_frame->UpdateReleaseSyncPoint(&client); | 651 video_frame->UpdateReleaseSyncPoint(&client); |
| 651 return true; | 652 return true; |
| 652 } | 653 } |
| 653 | 654 |
| 654 WebMediaPlayer::MediaKeyException | 655 WebMediaPlayer::MediaKeyException |
| 655 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, | 656 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
| 656 const unsigned char* init_data, | 657 const unsigned char* init_data, |
| 657 unsigned init_data_length) { | 658 unsigned init_data_length) { |
| 658 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 659 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 659 | 660 |
| 661 // TODO(xhwang): We assume all streams are from the same container (thus have | |
|
ddorwin
2014/12/02 20:49:49
Note: YouTube is currently violating this assumpti
xhwang
2014/12/02 21:57:47
Acknowledged.
| |
| 662 // the same "type") for now. In the future, the "type" should be passed down | |
|
ddorwin
2014/12/02 20:49:49
ditto
xhwang
2014/12/02 21:57:47
Done.
| |
| 663 // from the application. | |
| 660 return encrypted_media_support_.GenerateKeyRequest( | 664 return encrypted_media_support_.GenerateKeyRequest( |
| 661 frame_, key_system, init_data, init_data_length); | 665 frame_, key_system, init_data_type_, init_data, init_data_length); |
| 662 } | 666 } |
| 663 | 667 |
| 664 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey( | 668 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey( |
| 665 const WebString& key_system, | 669 const WebString& key_system, |
| 666 const unsigned char* key, | 670 const unsigned char* key, |
| 667 unsigned key_length, | 671 unsigned key_length, |
| 668 const unsigned char* init_data, | 672 const unsigned char* init_data, |
| 669 unsigned init_data_length, | 673 unsigned init_data_length, |
| 670 const WebString& session_id) { | 674 const WebString& session_id) { |
| 671 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 675 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 692 result.completeWithError( | 696 result.completeWithError( |
| 693 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 697 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| 694 "Null MediaKeys object is not supported."); | 698 "Null MediaKeys object is not supported."); |
| 695 return; | 699 return; |
| 696 } | 700 } |
| 697 | 701 |
| 698 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), | 702 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), |
| 699 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); | 703 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); |
| 700 } | 704 } |
| 701 | 705 |
| 706 void WebMediaPlayerImpl::OnNeedKey(const std::string& type, | |
|
ddorwin
2014/12/02 20:49:49
i_d_t
xhwang
2014/12/02 21:57:47
Done.
| |
| 707 const std::vector<uint8>& init_data) { | |
| 708 // Do not fire NeedKey event if encrypted media is not enabled. | |
|
ddorwin
2014/12/02 20:49:49
I know this was copied, but should client_ be hand
xhwang
2014/12/02 21:57:47
Added TODO.
| |
| 709 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && | |
| 710 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { | |
| 711 return; | |
| 712 } | |
| 713 | |
| 714 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); | |
| 715 | |
| 716 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | |
|
ddorwin
2014/12/02 20:49:49
Can type be empty? The demuxers that call this alw
ddorwin
2014/12/02 20:49:49
YouTube currently violates this without problems i
xhwang
2014/12/02 21:57:47
Good catch. Done.
xhwang
2014/12/02 21:57:47
Done.
| |
| 717 if (init_data_type_.empty()) | |
| 718 init_data_type_ = type; | |
| 719 | |
| 720 const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0]; | |
| 721 client_->encrypted(WebString::fromUTF8(type), init_data_ptr, | |
| 722 base::saturated_cast<unsigned int>(init_data.size())); | |
| 723 } | |
| 724 | |
| 702 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, | 725 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, |
| 703 const CdmAttachedCB& cdm_attached_cb) { | 726 const CdmAttachedCB& cdm_attached_cb) { |
| 704 pipeline_.SetCdm(cdm_context, cdm_attached_cb); | 727 pipeline_.SetCdm(cdm_context, cdm_attached_cb); |
| 705 } | 728 } |
| 706 | 729 |
| 707 void WebMediaPlayerImpl::OnCdmAttached( | 730 void WebMediaPlayerImpl::OnCdmAttached( |
| 708 blink::WebContentDecryptionModuleResult result, | 731 blink::WebContentDecryptionModuleResult result, |
| 709 bool success) { | 732 bool success) { |
| 710 if (success) { | 733 if (success) { |
| 711 result.complete(); | 734 result.complete(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 903 | 926 |
| 904 void WebMediaPlayerImpl::StartPipeline() { | 927 void WebMediaPlayerImpl::StartPipeline() { |
| 905 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 928 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 906 | 929 |
| 907 // Keep track if this is a MSE or non-MSE playback. | 930 // Keep track if this is a MSE or non-MSE playback. |
| 908 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", | 931 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", |
| 909 (load_type_ == LoadTypeMediaSource)); | 932 (load_type_ == LoadTypeMediaSource)); |
| 910 | 933 |
| 911 LogCB mse_log_cb; | 934 LogCB mse_log_cb; |
| 912 Demuxer::NeedKeyCB need_key_cb = | 935 Demuxer::NeedKeyCB need_key_cb = |
| 913 encrypted_media_support_.CreateNeedKeyCB(); | 936 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey); |
| 914 | 937 |
| 915 // Figure out which demuxer to use. | 938 // Figure out which demuxer to use. |
| 916 if (load_type_ != LoadTypeMediaSource) { | 939 if (load_type_ != LoadTypeMediaSource) { |
| 917 DCHECK(!chunk_demuxer_); | 940 DCHECK(!chunk_demuxer_); |
| 918 DCHECK(data_source_); | 941 DCHECK(data_source_); |
| 919 | 942 |
| 920 demuxer_.reset(new FFmpegDemuxer( | 943 demuxer_.reset(new FFmpegDemuxer( |
| 921 media_task_runner_, data_source_.get(), | 944 media_task_runner_, data_source_.get(), |
| 922 need_key_cb, | 945 need_key_cb, |
| 923 media_log_)); | 946 media_log_)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 compositor_task_runner_->PostTask(FROM_HERE, | 1074 compositor_task_runner_->PostTask(FROM_HERE, |
| 1052 base::Bind(&GetCurrentFrameAndSignal, | 1075 base::Bind(&GetCurrentFrameAndSignal, |
| 1053 base::Unretained(compositor_), | 1076 base::Unretained(compositor_), |
| 1054 &video_frame, | 1077 &video_frame, |
| 1055 &event)); | 1078 &event)); |
| 1056 event.Wait(); | 1079 event.Wait(); |
| 1057 return video_frame; | 1080 return video_frame; |
| 1058 } | 1081 } |
| 1059 | 1082 |
| 1060 } // namespace media | 1083 } // namespace media |
| OLD | NEW |