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

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

Issue 11313016: Add "type" in GenerateKeyRequest() and OnNeedKey(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments resolved Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // We do not support run-time switching between key systems for now. 792 // We do not support run-time switching between key systems for now.
793 if (current_key_system_.isEmpty()) 793 if (current_key_system_.isEmpty())
794 current_key_system_ = key_system; 794 current_key_system_ = key_system;
795 else if (key_system != current_key_system_) 795 else if (key_system != current_key_system_)
796 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; 796 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
797 797
798 DVLOG(1) << "generateKeyRequest: " << key_system.utf8().data() << ": " 798 DVLOG(1) << "generateKeyRequest: " << key_system.utf8().data() << ": "
799 << std::string(reinterpret_cast<const char*>(init_data), 799 << std::string(reinterpret_cast<const char*>(init_data),
800 static_cast<size_t>(init_data_length)); 800 static_cast<size_t>(init_data_length));
801 801
802 // TODO(xhwang): We assume all streams are from the same container (thus have
803 // the same "type") for now. In the future, the "type" should be passed down
804 // from the application.
802 if (!decryptor_.GenerateKeyRequest(key_system.utf8(), 805 if (!decryptor_.GenerateKeyRequest(key_system.utf8(),
806 init_data_type_,
803 init_data, init_data_length)) { 807 init_data, init_data_length)) {
804 current_key_system_.reset(); 808 current_key_system_.reset();
805 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; 809 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
806 } 810 }
807 811
808 return WebMediaPlayer::MediaKeyExceptionNoError; 812 return WebMediaPlayer::MediaKeyExceptionNoError;
809 } 813 }
810 814
811 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey( 815 WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey(
812 const WebString& key_system, 816 const WebString& key_system,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 kMediaEme + KeySystemNameForUMA(key_system) + ".KeyAdded", 1010 kMediaEme + KeySystemNameForUMA(key_system) + ".KeyAdded",
1007 1, 1000000, 50, 1011 1, 1000000, 50,
1008 base::Histogram::kUmaTargetedHistogramFlag)->Add(1); 1012 base::Histogram::kUmaTargetedHistogramFlag)->Add(1);
1009 1013
1010 GetClient()->keyAdded(WebString::fromUTF8(key_system), 1014 GetClient()->keyAdded(WebString::fromUTF8(key_system),
1011 WebString::fromUTF8(session_id)); 1015 WebString::fromUTF8(session_id));
1012 } 1016 }
1013 1017
1014 void WebMediaPlayerImpl::OnNeedKey(const std::string& key_system, 1018 void WebMediaPlayerImpl::OnNeedKey(const std::string& key_system,
1015 const std::string& session_id, 1019 const std::string& session_id,
1020 const std::string& type,
1016 scoped_array<uint8> init_data, 1021 scoped_array<uint8> init_data,
1017 int init_data_size) { 1022 int init_data_size) {
1018 DCHECK_EQ(main_loop_, MessageLoop::current()); 1023 DCHECK_EQ(main_loop_, MessageLoop::current());
1019 1024
1020 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); 1025 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1);
1021 1026
1027 DCHECK(init_data_type_.empty() || type == init_data_type_);
1028 if (init_data_type_.empty())
1029 init_data_type_ = type;
1030
1022 GetClient()->keyNeeded(WebString::fromUTF8(key_system), 1031 GetClient()->keyNeeded(WebString::fromUTF8(key_system),
1023 WebString::fromUTF8(session_id), 1032 WebString::fromUTF8(session_id),
1024 init_data.get(), 1033 init_data.get(),
1025 init_data_size); 1034 init_data_size);
1026 } 1035 }
1027 1036
1028 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ 1037 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
1029 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ 1038 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \
1030 static_cast<int>(media::Decryptor::k ## name), \ 1039 static_cast<int>(media::Decryptor::k ## name), \
1031 mismatching_enums) 1040 mismatching_enums)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 return audio_source_provider_; 1190 return audio_source_provider_;
1182 } 1191 }
1183 1192
1184 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1193 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1185 DCHECK_EQ(main_loop_, MessageLoop::current()); 1194 DCHECK_EQ(main_loop_, MessageLoop::current());
1186 incremented_externally_allocated_memory_ = true; 1195 incremented_externally_allocated_memory_ = true;
1187 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1196 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1188 } 1197 }
1189 1198
1190 } // namespace webkit_media 1199 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698