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.
5 #ifndef MEDIA_BASE_BROWSER_CDM_H_
6 #define MEDIA_BASE_BROWSER_CDM_H_
8 #include "media/base/media_export.h"
9 #include "media/base/media_keys.h"
10 #include "media/base/player_tracker.h"
14 // Interface for browser side CDMs.
15 class MEDIA_EXPORT BrowserCdm
: public PlayerTracker
{
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
)>
23 typedef base::Callback
<void(uint32 session_id
,
24 const std::vector
<uint8
>& message
,
25 const GURL
& destination_url
)> SessionMessageCB
;
27 typedef base::Callback
<void(uint32 session_id
)> SessionReadyCB
;
29 typedef base::Callback
<void(uint32 session_id
)> SessionClosedCB
;
31 typedef base::Callback
<void(uint32 session_id
,
32 media::MediaKeys::KeyError error_code
,
33 uint32 system_code
)> SessionErrorCB
;
35 virtual ~BrowserCdm();
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;
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;
58 DISALLOW_COPY_AND_ASSIGN(BrowserCdm
);
63 #endif // MEDIA_BASE_BROWSER_CDM_H_