1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_
8 #include "base/basictypes.h"
9 #include "media/base/media_keys.h"
15 class RendererMediaPlayerManager;
17 // A MediaKeys proxy that wraps the EME part of RendererMediaPlayerManager.
18 // TODO(xhwang): Instead of accessing RendererMediaPlayerManager directly, let
19 // RendererMediaPlayerManager return a MediaKeys object that can be used by
20 // ProxyDecryptor directly. Then we can remove this class!
21 class ProxyMediaKeys : public media::MediaKeys {
23 ProxyMediaKeys(RendererMediaPlayerManager* proxy,
25 const media::KeyAddedCB& key_added_cb,
26 const media::KeyErrorCB& key_error_cb,
27 const media::KeyMessageCB& key_message_cb);
28 virtual ~ProxyMediaKeys();
30 void InitializeCDM(const std::string& key_system, const GURL& frame_url);
32 // MediaKeys implementation.
33 virtual bool GenerateKeyRequest(const std::string& type,
34 const uint8* init_data,
35 int init_data_length) OVERRIDE;
36 virtual void AddKey(const uint8* key, int key_length,
37 const uint8* init_data, int init_data_length,
38 const std::string& session_id) OVERRIDE;
39 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE;
42 void OnKeyAdded(const std::string& session_id);
43 void OnKeyError(const std::string& session_id,
44 media::MediaKeys::KeyError error_code,
46 void OnKeyMessage(const std::string& session_id,
47 const std::vector<uint8>& message,
48 const std::string& destination_url);
51 RendererMediaPlayerManager* manager_;
53 media::KeyAddedCB key_added_cb_;
54 media::KeyErrorCB key_error_cb_;
55 media::KeyMessageCB key_message_cb_;
57 DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys);
60 } // namespace content
62 #endif // CONTENT_RENDERER_MEDIA_ANDROID_PROXY_MEDIA_KEYS_H_