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

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

Issue 784493002: Encrypted Media: Rename NeedKey to EncryptedMediaInitData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 result.completeWithError( 693 result.completeWithError(
694 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 694 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
695 "Null MediaKeys object is not supported."); 695 "Null MediaKeys object is not supported.");
696 return; 696 return;
697 } 697 }
698 698
699 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), 699 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(),
700 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); 700 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result));
701 } 701 }
702 702
703 void WebMediaPlayerImpl::OnNeedKey(const std::string& init_data_type, 703 void WebMediaPlayerImpl::OnEncryptedMediaInitData(
704 const std::vector<uint8>& init_data) { 704 const std::string& init_data_type,
705 const std::vector<uint8>& init_data) {
705 DCHECK(!init_data_type.empty()); 706 DCHECK(!init_data_type.empty());
706 707
707 // Do not fire NeedKey event if encrypted media is not enabled. 708 // Do not fire "encrypted" event if encrypted media is not enabled.
708 // TODO(xhwang): Handle this in |client_|. 709 // TODO(xhwang): Handle this in |client_|.
709 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 710 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
710 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { 711 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
711 return; 712 return;
712 } 713 }
713 714
715 // TODO(xhwang): Update this UMA name.
ddorwin 2014/12/11 02:06:44 Maybe we should have two separate UMAs and depreca
714 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 716 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
715 717
716 encrypted_media_support_.SetInitDataType(init_data_type); 718 encrypted_media_support_.SetInitDataType(init_data_type);
717 719
718 const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0]; 720 const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0];
719 client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr, 721 client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr,
720 base::saturated_cast<unsigned int>(init_data.size())); 722 base::saturated_cast<unsigned int>(init_data.size()));
721 } 723 }
722 724
723 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, 725 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 925 }
924 926
925 void WebMediaPlayerImpl::StartPipeline() { 927 void WebMediaPlayerImpl::StartPipeline() {
926 DCHECK(main_task_runner_->BelongsToCurrentThread()); 928 DCHECK(main_task_runner_->BelongsToCurrentThread());
927 929
928 // Keep track if this is a MSE or non-MSE playback. 930 // Keep track if this is a MSE or non-MSE playback.
929 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", 931 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback",
930 (load_type_ == LoadTypeMediaSource)); 932 (load_type_ == LoadTypeMediaSource));
931 933
932 LogCB mse_log_cb; 934 LogCB mse_log_cb;
933 Demuxer::NeedKeyCB need_key_cb = 935 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
934 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey); 936 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
935 937
936 // Figure out which demuxer to use. 938 // Figure out which demuxer to use.
937 if (load_type_ != LoadTypeMediaSource) { 939 if (load_type_ != LoadTypeMediaSource) {
938 DCHECK(!chunk_demuxer_); 940 DCHECK(!chunk_demuxer_);
939 DCHECK(data_source_); 941 DCHECK(data_source_);
940 942
941 demuxer_.reset(new FFmpegDemuxer( 943 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
942 media_task_runner_, data_source_.get(), 944 encrypted_media_init_data_cb, media_log_));
943 need_key_cb,
944 media_log_));
945 } else { 945 } else {
946 DCHECK(!chunk_demuxer_); 946 DCHECK(!chunk_demuxer_);
947 DCHECK(!data_source_); 947 DCHECK(!data_source_);
948 948
949 mse_log_cb = base::Bind(&LogMediaSourceError, media_log_); 949 mse_log_cb = base::Bind(&LogMediaSourceError, media_log_);
950 950
951 chunk_demuxer_ = new ChunkDemuxer( 951 chunk_demuxer_ = new ChunkDemuxer(
952 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 952 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
953 need_key_cb, 953 encrypted_media_init_data_cb, mse_log_cb, media_log_, true);
954 mse_log_cb,
955 media_log_,
956 true);
957 demuxer_.reset(chunk_demuxer_); 954 demuxer_.reset(chunk_demuxer_);
958 } 955 }
959 956
960 // ... and we're ready to go! 957 // ... and we're ready to go!
961 seeking_ = true; 958 seeking_ = true;
962 959
963 if (!renderer_) 960 if (!renderer_)
964 renderer_ = CreateRenderer(); 961 renderer_ = CreateRenderer();
965 962
966 pipeline_.Start( 963 pipeline_.Start(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 compositor_task_runner_->PostTask(FROM_HERE, 1069 compositor_task_runner_->PostTask(FROM_HERE,
1073 base::Bind(&GetCurrentFrameAndSignal, 1070 base::Bind(&GetCurrentFrameAndSignal,
1074 base::Unretained(compositor_), 1071 base::Unretained(compositor_),
1075 &video_frame, 1072 &video_frame,
1076 &event)); 1073 &event));
1077 event.Wait(); 1074 event.Wait();
1078 return video_frame; 1075 return video_frame;
1079 } 1076 }
1080 1077
1081 } // namespace media 1078 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698