Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/media/crypto/encrypted_media_player_support_impl.h" | 5 #include "content/renderer/media/crypto/encrypted_media_player_support_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 const std::string& key_system, | 108 const std::string& key_system, |
| 109 WebMediaPlayer::MediaKeyException e) { | 109 WebMediaPlayer::MediaKeyException e) { |
| 110 MediaKeyException result_id = MediaKeyExceptionForUMA(e); | 110 MediaKeyException result_id = MediaKeyExceptionForUMA(e); |
| 111 DCHECK_NE(result_id, kUnknownResultId) << e; | 111 DCHECK_NE(result_id, kUnknownResultId) << e; |
| 112 EmeUMAHistogramEnumeration( | 112 EmeUMAHistogramEnumeration( |
| 113 key_system, method, result_id, kMaxMediaKeyException); | 113 key_system, method, result_id, kMaxMediaKeyException); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Guess the type of |init_data|. This is only used to handle some corner cases | 116 // Guess the type of |init_data|. This is only used to handle some corner cases |
| 117 // so we keep it as simple as possible without breaking major use cases. | 117 // so we keep it as simple as possible without breaking major use cases. |
| 118 static std::string GuessInitDataType(const unsigned char* init_data, | 118 static std::string GuessInitDataType(const unsigned char* init_data, |
|
ddorwin
2014/09/26 22:09:18
Fix WMPA too.
sandersd (OOO until July 31)
2014/09/26 22:49:56
Done.
| |
| 119 unsigned init_data_length) { | 119 unsigned init_data_length) { |
| 120 // Most WebM files use KeyId of 16 bytes. MP4 init data are always >16 bytes. | 120 // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. |
| 121 if (init_data_length == 16) | 121 if (init_data_length == 16) |
| 122 return "video/webm"; | 122 return "webm"; |
| 123 | 123 |
| 124 return "video/mp4"; | 124 return "cenc"; |
| 125 } | 125 } |
| 126 | 126 |
| 127 scoped_ptr<media::EncryptedMediaPlayerSupport> | 127 scoped_ptr<media::EncryptedMediaPlayerSupport> |
| 128 EncryptedMediaPlayerSupportImpl::Create(blink::WebMediaPlayerClient* client) { | 128 EncryptedMediaPlayerSupportImpl::Create(blink::WebMediaPlayerClient* client) { |
| 129 return scoped_ptr<EncryptedMediaPlayerSupport>( | 129 return scoped_ptr<EncryptedMediaPlayerSupport>( |
| 130 new EncryptedMediaPlayerSupportImpl(client)); | 130 new EncryptedMediaPlayerSupportImpl(client)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 EncryptedMediaPlayerSupportImpl::EncryptedMediaPlayerSupportImpl( | 133 EncryptedMediaPlayerSupportImpl::EncryptedMediaPlayerSupportImpl( |
| 134 blink::WebMediaPlayerClient* client) | 134 blink::WebMediaPlayerClient* client) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 199 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 200 } | 200 } |
| 201 | 201 |
| 202 std::string init_data_type = init_data_type_; | 202 std::string init_data_type = init_data_type_; |
| 203 if (init_data_type.empty()) | 203 if (init_data_type.empty()) |
| 204 init_data_type = GuessInitDataType(init_data, init_data_length); | 204 init_data_type = GuessInitDataType(init_data, init_data_length); |
| 205 | 205 |
| 206 // TODO(xhwang): We assume all streams are from the same container (thus have | 206 // TODO(xhwang): We assume all streams are from the same container (thus have |
| 207 // the same "type") for now. In the future, the "type" should be passed down | 207 // the same "type") for now. In the future, the "type" should be passed down |
| 208 // from the application. | 208 // from the application. |
| 209 if (!proxy_decryptor_->GenerateKeyRequest( | 209 if (!proxy_decryptor_->GenerateKeyRequest( |
|
ddorwin
2014/09/26 22:09:18
You need to fix this this function too - remove th
sandersd (OOO until July 31)
2014/09/26 22:49:56
Done.
| |
| 210 init_data_type, init_data, init_data_length)) { | 210 init_data_type, init_data, init_data_length)) { |
| 211 current_key_system_.clear(); | 211 current_key_system_.clear(); |
| 212 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 212 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 213 } | 213 } |
| 214 | 214 |
| 215 return WebMediaPlayer::MediaKeyExceptionNoError; | 215 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 216 } | 216 } |
| 217 | 217 |
| 218 WebMediaPlayer::MediaKeyException EncryptedMediaPlayerSupportImpl::AddKey( | 218 WebMediaPlayer::MediaKeyException EncryptedMediaPlayerSupportImpl::AddKey( |
| 219 const WebString& key_system, | 219 const WebString& key_system, |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 | 463 |
| 464 if (web_cdm_) { | 464 if (web_cdm_) { |
| 465 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); | 465 decryptor_ready_cb.Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
| 466 return; | 466 return; |
| 467 } | 467 } |
| 468 | 468 |
| 469 decryptor_ready_cb_ = decryptor_ready_cb; | 469 decryptor_ready_cb_ = decryptor_ready_cb; |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace content | 472 } // namespace content |
| OLD | NEW |