Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / media / blink / encrypted_media_player_support.h
blobc261ec38c2cda7717327db9afa4e0b788173c3b3
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_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
6 #define MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "media/base/cdm_context.h"
15 #include "media/base/cdm_factory.h"
16 #include "media/base/demuxer.h"
17 #include "media/cdm/proxy_decryptor.h"
18 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
19 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
21 namespace blink {
22 class WebContentDecryptionModule;
23 class WebLocalFrame;
24 class WebMediaPlayerClient;
25 class WebString;
28 namespace media {
30 class WebContentDecryptionModuleImpl;
32 // Provides support to prefixed EME implementation.
33 // Do NOT add unprefixed EME functionality to this class!
34 // TODO(xhwang): When deprecating prefixed EME support, drop this whole file.
35 class EncryptedMediaPlayerSupport
36 : public base::SupportsWeakPtr<EncryptedMediaPlayerSupport> {
37 public:
38 typedef base::Callback<void(CdmContext*, const CdmAttachedCB&)>
39 SetCdmContextCB;
41 EncryptedMediaPlayerSupport(scoped_ptr<CdmFactory> cdm_factory,
42 blink::WebMediaPlayerClient* client,
43 const SetCdmContextCB& set_cdm_context_cb);
44 ~EncryptedMediaPlayerSupport();
46 blink::WebMediaPlayer::MediaKeyException GenerateKeyRequest(
47 blink::WebLocalFrame* frame,
48 const blink::WebString& key_system,
49 const unsigned char* init_data,
50 unsigned init_data_length);
52 blink::WebMediaPlayer::MediaKeyException AddKey(
53 const blink::WebString& key_system,
54 const unsigned char* key,
55 unsigned key_length,
56 const unsigned char* init_data,
57 unsigned init_data_length,
58 const blink::WebString& session_id);
60 blink::WebMediaPlayer::MediaKeyException CancelKeyRequest(
61 const blink::WebString& key_system,
62 const blink::WebString& session_id);
64 void SetInitDataType(const std::string& init_data_type);
66 void OnPipelineDecryptError();
68 private:
69 blink::WebMediaPlayer::MediaKeyException GenerateKeyRequestInternal(
70 blink::WebLocalFrame* frame,
71 const std::string& key_system,
72 const unsigned char* init_data,
73 unsigned init_data_length);
75 blink::WebMediaPlayer::MediaKeyException AddKeyInternal(
76 const std::string& key_system,
77 const unsigned char* key,
78 unsigned key_length,
79 const unsigned char* init_data,
80 unsigned init_data_length,
81 const std::string& session_id);
83 blink::WebMediaPlayer::MediaKeyException CancelKeyRequestInternal(
84 const std::string& key_system,
85 const std::string& session_id);
87 void OnKeyAdded(const std::string& session_id);
88 void OnKeyError(const std::string& session_id,
89 MediaKeys::KeyError error_code,
90 uint32 system_code);
91 void OnKeyMessage(const std::string& session_id,
92 const std::vector<uint8>& message,
93 const GURL& destination_url);
95 scoped_ptr<CdmFactory> cdm_factory_;
97 blink::WebMediaPlayerClient* client_;
99 // The currently selected key system. Empty string means that no key system
100 // has been selected.
101 std::string current_key_system_;
103 // We assume all streams are from the same container, thus have the same
104 // init data type.
105 std::string init_data_type_;
107 SetCdmContextCB set_cdm_context_cb_;
109 // Manages decryption keys and decrypts encrypted frames.
110 scoped_ptr<ProxyDecryptor> proxy_decryptor_;
112 DISALLOW_COPY_AND_ASSIGN(EncryptedMediaPlayerSupport);
115 } // namespace media
117 #endif // MEDIA_BLINK_ENCRYPTED_MEDIA_PLAYER_SUPPORT_H_