| 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 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ | 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
| 14 #include "media/base/cdm_context.h" |
| 14 #include "media/base/cdm_promise.h" | 15 #include "media/base/cdm_promise.h" |
| 15 #include "media/base/media_keys.h" | 16 #include "media/base/media_keys.h" |
| 16 | 17 |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 class RendererCdmManager; | 22 class RendererCdmManager; |
| 22 | 23 |
| 23 // A MediaKeys proxy that wraps the EME part of RendererCdmManager. | 24 // A MediaKeys proxy that wraps the EME part of RendererCdmManager. |
| 24 class ProxyMediaKeys : public media::MediaKeys { | 25 class ProxyMediaKeys : public media::MediaKeys, public media::CdmContext { |
| 25 public: | 26 public: |
| 26 static scoped_ptr<ProxyMediaKeys> Create( | 27 static scoped_ptr<ProxyMediaKeys> Create( |
| 27 const std::string& key_system, | 28 const std::string& key_system, |
| 28 const GURL& security_origin, | 29 const GURL& security_origin, |
| 29 RendererCdmManager* manager, | 30 RendererCdmManager* manager, |
| 30 const media::SessionMessageCB& session_message_cb, | 31 const media::SessionMessageCB& session_message_cb, |
| 31 const media::SessionReadyCB& session_ready_cb, | 32 const media::SessionReadyCB& session_ready_cb, |
| 32 const media::SessionClosedCB& session_closed_cb, | 33 const media::SessionClosedCB& session_closed_cb, |
| 33 const media::SessionErrorCB& session_error_cb, | 34 const media::SessionErrorCB& session_error_cb, |
| 34 const media::SessionKeysChangeCB& session_keys_change_cb, | 35 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 35 const media::SessionExpirationUpdateCB& session_expiration_update_cb); | 36 const media::SessionExpirationUpdateCB& session_expiration_update_cb); |
| 36 | 37 |
| 37 virtual ~ProxyMediaKeys(); | 38 ~ProxyMediaKeys() override; |
| 38 | 39 |
| 39 // MediaKeys implementation. | 40 // MediaKeys implementation. |
| 40 virtual void SetServerCertificate( | 41 void SetServerCertificate( |
| 41 const uint8* certificate_data, | 42 const uint8* certificate_data, |
| 42 int certificate_data_length, | 43 int certificate_data_length, |
| 43 scoped_ptr<media::SimpleCdmPromise> promise) override; | 44 scoped_ptr<media::SimpleCdmPromise> promise) override; |
| 44 virtual void CreateSession( | 45 void CreateSession(const std::string& init_data_type, |
| 45 const std::string& init_data_type, | 46 const uint8* init_data, |
| 46 const uint8* init_data, | 47 int init_data_length, |
| 47 int init_data_length, | 48 SessionType session_type, |
| 48 SessionType session_type, | 49 scoped_ptr<media::NewSessionCdmPromise> promise) override; |
| 49 scoped_ptr<media::NewSessionCdmPromise> promise) override; | 50 void LoadSession(const std::string& web_session_id, |
| 50 virtual void LoadSession( | 51 scoped_ptr<media::NewSessionCdmPromise> promise) override; |
| 51 const std::string& web_session_id, | 52 void UpdateSession(const std::string& web_session_id, |
| 52 scoped_ptr<media::NewSessionCdmPromise> promise) override; | 53 const uint8* response, |
| 53 virtual void UpdateSession( | 54 int response_length, |
| 54 const std::string& web_session_id, | 55 scoped_ptr<media::SimpleCdmPromise> promise) override; |
| 55 const uint8* response, | 56 void CloseSession(const std::string& web_session_id, |
| 56 int response_length, | 57 scoped_ptr<media::SimpleCdmPromise> promise) override; |
| 57 scoped_ptr<media::SimpleCdmPromise> promise) override; | 58 void RemoveSession(const std::string& web_session_id, |
| 58 virtual void CloseSession( | 59 scoped_ptr<media::SimpleCdmPromise> promise) override; |
| 59 const std::string& web_session_id, | 60 void GetUsableKeyIds(const std::string& web_session_id, |
| 60 scoped_ptr<media::SimpleCdmPromise> promise) override; | 61 scoped_ptr<media::KeyIdsPromise> promise) override; |
| 61 virtual void RemoveSession( | 62 media::CdmContext* GetCdmContext() override; |
| 62 const std::string& web_session_id, | 63 |
| 63 scoped_ptr<media::SimpleCdmPromise> promise) override; | 64 // media::CdmContext implementation. |
| 64 virtual void GetUsableKeyIds( | 65 media::Decryptor* GetDecryptor() override; |
| 65 const std::string& web_session_id, | 66 int GetCdmId() const override; |
| 66 scoped_ptr<media::KeyIdsPromise> promise) override; | |
| 67 virtual int GetCdmId() const override; | |
| 68 | 67 |
| 69 // Callbacks. | 68 // Callbacks. |
| 70 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); | 69 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| 71 void OnSessionMessage(uint32 session_id, | 70 void OnSessionMessage(uint32 session_id, |
| 72 const std::vector<uint8>& message, | 71 const std::vector<uint8>& message, |
| 73 const GURL& destination_url); | 72 const GURL& destination_url); |
| 74 void OnSessionReady(uint32 session_id); | 73 void OnSessionReady(uint32 session_id); |
| 75 void OnSessionClosed(uint32 session_id); | 74 void OnSessionClosed(uint32 session_id); |
| 76 void OnSessionError(uint32 session_id, | 75 void OnSessionError(uint32 session_id, |
| 77 media::MediaKeys::KeyError error_code, | 76 media::MediaKeys::KeyError error_code, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 128 |
| 130 // Keep track of outstanding promises. This map owns the promise object. | 129 // Keep track of outstanding promises. This map owns the promise object. |
| 131 PromiseMap session_id_to_promise_map_; | 130 PromiseMap session_id_to_promise_map_; |
| 132 | 131 |
| 133 DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys); | 132 DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys); |
| 134 }; | 133 }; |
| 135 | 134 |
| 136 } // namespace content | 135 } // namespace content |
| 137 | 136 |
| 138 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ | 137 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_MEDIA_KEYS_H_ |
| OLD | NEW |