Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
qinmin
2015/09/15 21:10:45
s/2013/2015/
| |
| 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_BASE_ANDROID_MEDIA_DRM_PROXY_H_ | |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_PROXY_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "media/base/android/media_drm_bridge.h" | |
| 13 #include "media/base/browser_cdm.h" | |
| 14 | |
| 15 namespace media { | |
| 16 | |
| 17 // This class delegates MediaDrmBridge calls onto the Media thread | |
| 18 class MEDIA_EXPORT MediaDrmProxy : public BrowserCdm { | |
| 19 public: | |
| 20 ~MediaDrmProxy() override; | |
| 21 void DeleteOnCorrectThread() override; | |
| 22 | |
| 23 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL | |
| 24 // pointer otherwise. | |
| 25 // TODO(xhwang): Is it okay not to update session expiration info? | |
| 26 static scoped_ptr<MediaDrmProxy, BrowserCdmDeleter> Create( | |
| 27 const std::string& key_system, | |
| 28 MediaDrmBridge::SecurityLevel widevine_security_level, | |
| 29 const SessionMessageCB& session_message_cb, | |
| 30 const SessionClosedCB& session_closed_cb, | |
| 31 const LegacySessionErrorCB& legacy_session_error_cb, | |
| 32 const SessionKeysChangeCB& session_keys_change_cb, | |
| 33 const SessionExpirationUpdateCB& session_expiration_update_cb); | |
| 34 | |
| 35 // MediaKeys (via BrowserCdm) implementation. | |
| 36 | |
| 37 void SetServerCertificate( | |
| 38 const std::vector<uint8_t>& certificate, | |
| 39 scoped_ptr<media::SimpleCdmPromise> promise) override; | |
| 40 void CreateSessionAndGenerateRequest( | |
| 41 SessionType session_type, | |
| 42 media::EmeInitDataType init_data_type, | |
| 43 const std::vector<uint8_t>& init_data, | |
| 44 scoped_ptr<media::NewSessionCdmPromise> promise) override; | |
| 45 void LoadSession(SessionType session_type, | |
| 46 const std::string& session_id, | |
| 47 scoped_ptr<media::NewSessionCdmPromise> promise) override; | |
| 48 void UpdateSession(const std::string& session_id, | |
| 49 const std::vector<uint8_t>& response, | |
| 50 scoped_ptr<media::SimpleCdmPromise> promise) override; | |
| 51 void CloseSession(const std::string& session_id, | |
| 52 scoped_ptr<media::SimpleCdmPromise> promise) override; | |
| 53 void RemoveSession(const std::string& session_id, | |
| 54 scoped_ptr<media::SimpleCdmPromise> promise) override; | |
| 55 CdmContext* GetCdmContext() override; | |
| 56 | |
| 57 // PlayerTracker (via BrowserCdm) implementation. | |
| 58 | |
| 59 int RegisterPlayer(const base::Closure& new_key_cb, | |
| 60 const base::Closure& cdm_unset_cb) override; | |
| 61 void UnregisterPlayer(int registration_id) override; | |
| 62 | |
| 63 // Accessor for MediaDrmBridge | |
| 64 MediaDrmBridge* GetDrmBridge(); | |
| 65 | |
| 66 private: | |
| 67 MediaDrmProxy(const std::string& key_system, | |
| 68 MediaDrmBridge::SecurityLevel widevine_security_level, | |
| 69 const SessionMessageCB& session_message_cb, | |
| 70 const SessionClosedCB& session_closed_cb, | |
| 71 const LegacySessionErrorCB& legacy_session_error_cb, | |
| 72 const SessionKeysChangeCB& session_keys_change_cb, | |
| 73 const SessionExpirationUpdateCB& session_expiration_update_cb); | |
| 74 | |
| 75 // Helper method to create MediaDrmBridge on the Media thread. | |
| 76 void Initialize(); | |
| 77 | |
| 78 // Data. | |
| 79 | |
| 80 // Object for posting tasks on UI thread. | |
| 81 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | |
| 82 | |
| 83 // MediaDrmBridge that will be accessed on the Media thread. | |
| 84 scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> media_drm_bridge_; | |
| 85 | |
| 86 // The key system. | |
| 87 std::string key_system_; | |
| 88 | |
| 89 // Required security level. Only makes sense for Widevine system. | |
| 90 MediaDrmBridge::SecurityLevel widevine_security_level_; | |
| 91 | |
| 92 // Callbacks received as parameters, to be called on UI thread | |
| 93 SessionMessageCB session_message_cb_; | |
| 94 SessionClosedCB session_closed_cb_; | |
| 95 LegacySessionErrorCB legacy_session_error_cb_; | |
| 96 SessionKeysChangeCB session_keys_change_cb_; | |
| 97 SessionExpirationUpdateCB session_expiration_update_cb_; | |
| 98 | |
| 99 base::WeakPtr<MediaDrmProxy> media_weak_this_; | |
| 100 | |
| 101 // NOTE: Weak pointers must be invalidated before all other member variables. | |
| 102 base::WeakPtrFactory<MediaDrmProxy> media_weak_factory_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(MediaDrmProxy); | |
| 105 }; | |
| 106 | |
| 107 } // namespace media | |
| 108 | |
| 109 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_PROXY_H_ | |
| OLD | NEW |