| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ | |
| 6 #define MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | |
| 17 #include "media/base/cdm_context.h" | |
| 18 #include "media/base/cdm_factory.h" | |
| 19 #include "media/base/demuxer.h" | |
| 20 #include "media/base/eme_constants.h" | |
| 21 #include "media/cdm/proxy_decryptor.h" | |
| 22 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | |
| 23 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | |
| 24 | |
| 25 namespace blink { | |
| 26 class WebContentDecryptionModule; | |
| 27 class WebLocalFrame; | |
| 28 class WebMediaPlayerEncryptedMediaClient; | |
| 29 class WebString; | |
| 30 } | |
| 31 | |
| 32 namespace media { | |
| 33 | |
| 34 class MediaPermission; | |
| 35 class WebContentDecryptionModuleImpl; | |
| 36 | |
| 37 // Provides support to prefixed EME implementation. | |
| 38 // Do NOT add unprefixed EME functionality to this class! | |
| 39 // TODO(xhwang): When deprecating prefixed EME support, drop this whole file. | |
| 40 class EncryptedMediaPlayerSupport | |
| 41 : public base::SupportsWeakPtr<EncryptedMediaPlayerSupport> { | |
| 42 public: | |
| 43 using CdmContextReadyCB = ProxyDecryptor::CdmContextReadyCB; | |
| 44 | |
| 45 // |cdm_context_ready_cb| is called when the CDM instance creation completes. | |
| 46 EncryptedMediaPlayerSupport(CdmFactory* cdm_factory, | |
| 47 blink::WebMediaPlayerEncryptedMediaClient* client, | |
| 48 MediaPermission* media_permission, | |
| 49 const CdmContextReadyCB& cdm_context_ready_cb); | |
| 50 ~EncryptedMediaPlayerSupport(); | |
| 51 | |
| 52 blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest( | |
| 53 blink::WebLocalFrame* frame, | |
| 54 const blink::WebString& key_system, | |
| 55 const unsigned char* init_data, | |
| 56 unsigned init_data_length); | |
| 57 | |
| 58 blink::WebMediaPlayer::MediaKeyException AddKey( | |
| 59 const blink::WebString& key_system, | |
| 60 const unsigned char* key, | |
| 61 unsigned key_length, | |
| 62 const unsigned char* init_data, | |
| 63 unsigned init_data_length, | |
| 64 const blink::WebString& session_id); | |
| 65 | |
| 66 blink::WebMediaPlayer::MediaKeyException CancelKeyRequest( | |
| 67 const blink::WebString& key_system, | |
| 68 const blink::WebString& session_id); | |
| 69 | |
| 70 void SetInitDataType(EmeInitDataType init_data_type); | |
| 71 | |
| 72 private: | |
| 73 blink::WebMediaPlayer::MediaKeyException GenerateKeyRequestInternal( | |
| 74 blink::WebLocalFrame* frame, | |
| 75 const std::string& key_system, | |
| 76 const unsigned char* init_data, | |
| 77 unsigned init_data_length); | |
| 78 | |
| 79 blink::WebMediaPlayer::MediaKeyException AddKeyInternal( | |
| 80 const std::string& key_system, | |
| 81 const unsigned char* key, | |
| 82 unsigned key_length, | |
| 83 const unsigned char* init_data, | |
| 84 unsigned init_data_length, | |
| 85 const std::string& session_id); | |
| 86 | |
| 87 blink::WebMediaPlayer::MediaKeyException CancelKeyRequestInternal( | |
| 88 const std::string& key_system, | |
| 89 const std::string& session_id); | |
| 90 | |
| 91 void OnKeyAdded(const std::string& session_id); | |
| 92 void OnKeyError(const std::string& session_id, | |
| 93 MediaKeys::KeyError error_code, | |
| 94 uint32_t system_code); | |
| 95 void OnKeyMessage(const std::string& session_id, | |
| 96 const std::vector<uint8_t>& message, | |
| 97 const GURL& destination_url); | |
| 98 | |
| 99 CdmFactory* cdm_factory_; | |
| 100 | |
| 101 blink::WebMediaPlayerEncryptedMediaClient* client_; | |
| 102 | |
| 103 MediaPermission* media_permission_; | |
| 104 | |
| 105 // The currently selected key system. Empty string means that no key system | |
| 106 // has been selected. | |
| 107 std::string current_key_system_; | |
| 108 | |
| 109 // We assume all streams are from the same container, thus have the same | |
| 110 // init data type. | |
| 111 EmeInitDataType init_data_type_; | |
| 112 | |
| 113 CdmContextReadyCB cdm_context_ready_cb_; | |
| 114 | |
| 115 // Manages decryption keys and decrypts encrypted frames. | |
| 116 scoped_ptr<ProxyDecryptor> proxy_decryptor_; | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport); | |
| 119 }; | |
| 120 | |
| 121 } // namespace media | |
| 122 | |
| 123 #endif // MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_ | |
| OLD | NEW |