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_BASE_BROWSER_CDM_H_ 6 #define MEDIA_BASE_BROWSER_CDM_H_ 7 8 #include "media/base/media_export.h" 9 #include "media/base/media_keys.h" 10 #include "media/base/player_tracker.h" 11 12 namespace media { 13 14 // Interface for browser side CDMs. 15 class MEDIA_EXPORT BrowserCdm : public PlayerTracker { 16 public: 17 // TODO(jrummell): Update this to actually derive from MediaKeys 18 // (Use web_session_id rather than session_id). 19 typedef base::Callback< 20 void(uint32 session_id, const std::string& web_session_id)> 21 SessionCreatedCB; 22 23 typedef base::Callback<void(uint32 session_id, 24 const std::vector<uint8>& message, 25 const GURL& destination_url)> SessionMessageCB; 26 27 typedef base::Callback<void(uint32 session_id)> SessionReadyCB; 28 29 typedef base::Callback<void(uint32 session_id)> SessionClosedCB; 30 31 typedef base::Callback<void(uint32 session_id, 32 media::MediaKeys::KeyError error_code, 33 uint32 system_code)> SessionErrorCB; 34 35 virtual ~BrowserCdm(); 36 37 // MediaKeys-like implementation. 38 virtual bool CreateSession(uint32 session_id, 39 const std::string& content_type, 40 const uint8* init_data, 41 int init_data_length) = 0; 42 virtual void LoadSession(uint32 session_id, 43 const std::string& web_session_id) = 0; 44 virtual void UpdateSession(uint32 session_id, 45 const uint8* response, 46 int response_length) = 0; 47 virtual void ReleaseSession(uint32 session_id) = 0; 48 49 // PlayerTracker implementation. 50 virtual int RegisterPlayer(const base::Closure& new_key_cb, 51 const base::Closure& cdm_unset_cb) = 0; 52 virtual void UnregisterPlayer(int registration_id) = 0; 53 54 protected: 55 BrowserCdm(); 56 57 private: 58 DISALLOW_COPY_AND_ASSIGN(BrowserCdm); 59 }; 60 61 } // namespace media 62 63 #endif // MEDIA_BASE_BROWSER_CDM_H_ 64