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 CONTENT_RENDERER_MEDIA_CRYPTO_RENDERER_CDM_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_RENDERER_CDM_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "content/common/media/cdm_messages_enums.h" |
| 14 #include "content/public/renderer/render_frame_observer.h" |
| 15 #include "media/base/media_keys.h" |
| 16 #include "url/gurl.h" |
| 17 |
| 18 namespace blink { |
| 19 class WebFrame; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class ProxyMediaKeys; |
| 25 |
| 26 // Class for managing all the CDM objects in the same RenderFrame. |
| 27 class RendererCdmManager : public RenderFrameObserver { |
| 28 public: |
| 29 static const int kInvalidCdmId = 0; |
| 30 |
| 31 // Constructs a RendererCdmManager object for the |render_frame|. |
| 32 explicit RendererCdmManager(RenderFrame* render_frame); |
| 33 virtual ~RendererCdmManager(); |
| 34 |
| 35 // RenderFrameObserver overrides. |
| 36 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 37 |
| 38 // Encrypted media related methods. |
| 39 void InitializeCdm(int cdm_id, |
| 40 ProxyMediaKeys* media_keys, |
| 41 const std::string& key_system, |
| 42 const GURL& security_origin); |
| 43 void CreateSession(int cdm_id, |
| 44 uint32 session_id, |
| 45 CdmHostMsg_CreateSession_ContentType conent_type, |
| 46 const std::vector<uint8>& init_data); |
| 47 void UpdateSession(int cdm_id, |
| 48 uint32 session_id, |
| 49 const std::vector<uint8>& response); |
| 50 void ReleaseSession(int cdm_id, uint32 session_id); |
| 51 void DestroyCdm(int cdm_id); |
| 52 |
| 53 private: |
| 54 // Registers a ProxyMediaKeys object. |
| 55 void RegisterMediaKeys(int cdm_id, ProxyMediaKeys* media_keys); |
| 56 |
| 57 // Gets the pointer to ProxyMediaKeys given the |cdm_id|. |
| 58 ProxyMediaKeys* GetMediaKeys(int cdm_id); |
| 59 |
| 60 // Message handlers. |
| 61 void OnSessionCreated(int cdm_id, |
| 62 uint32 session_id, |
| 63 const std::string& web_session_id); |
| 64 void OnSessionMessage(int cdm_id, |
| 65 uint32 session_id, |
| 66 const std::vector<uint8>& message, |
| 67 const GURL& destination_url); |
| 68 void OnSessionReady(int cdm_id, uint32 session_id); |
| 69 void OnSessionClosed(int cdm_id, uint32 session_id); |
| 70 void OnSessionError(int cdm_id, |
| 71 uint32 session_id, |
| 72 media::MediaKeys::KeyError error_code, |
| 73 uint32 system_code); |
| 74 |
| 75 // CDM ID to ProxyMediaKeys mapping. |
| 76 std::map<int, ProxyMediaKeys*> proxy_media_keys_map_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(RendererCdmManager); |
| 79 }; |
| 80 |
| 81 } // namespace content |
| 82 |
| 83 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_RENDERER_CDM_MANAGER_H_ |
OLD | NEW |