Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/renderer/media/crypto/encrypted_media_support_impl.h

Issue 501473003: Move EME code out of WebMediaPlayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android build Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_SUPPORT_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_SUPPORT_IMPL_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "content/renderer/media/crypto/encrypted_media_support.h"
10 #include "content/renderer/media/crypto/proxy_decryptor.h"
11
12 namespace content {
13
14 class WebContentDecryptionModuleImpl;
15
16 class EncryptedMediaSupportImpl
17 : public EncryptedMediaSupport,
18 public base::SupportsWeakPtr<EncryptedMediaSupportImpl> {
19 public:
20 explicit EncryptedMediaSupportImpl(blink::WebMediaPlayerClient* client);
21 virtual ~EncryptedMediaSupportImpl();
22
23 // EncryptedMediaSupport implementation.
24 virtual blink::WebMediaPlayer::MediaKeyException generateKeyRequest(
25 blink::WebLocalFrame* frame,
26 const blink::WebString& key_system,
27 const unsigned char* init_data,
28 unsigned init_data_length) OVERRIDE;
29
30 virtual blink::WebMediaPlayer::MediaKeyException addKey(
31 const blink::WebString& key_system,
32 const unsigned char* key,
33 unsigned key_length,
34 const unsigned char* init_data,
35 unsigned init_data_length,
36 const blink::WebString& session_id) OVERRIDE;
37
38 virtual blink::WebMediaPlayer::MediaKeyException cancelKeyRequest(
39 const blink::WebString& key_system,
40 const blink::WebString& session_id) OVERRIDE;
41
42 virtual void setContentDecryptionModule(
43 blink::WebContentDecryptionModule* cdm) OVERRIDE;
44 virtual void setContentDecryptionModule(
45 blink::WebContentDecryptionModule* cdm,
46 blink::WebContentDecryptionModuleResult result) OVERRIDE;
47 virtual void setContentDecryptionModuleSync(
48 blink::WebContentDecryptionModule* cdm) OVERRIDE;
49
50 virtual media::SetDecryptorReadyCB CreateSetDecryptorReadyCB() OVERRIDE;
51 virtual media::Demuxer::NeedKeyCB CreateNeedKeyCB() OVERRIDE;
52
53 virtual void OnDecryptError() OVERRIDE;
54
55 private:
56 // Requests that this object notifies when a decryptor is ready through the
57 // |decryptor_ready_cb| provided.
58 // If |decryptor_ready_cb| is null, the existing callback will be fired with
59 // NULL immediately and reset.
60 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb);
61
62 blink::WebMediaPlayer::MediaKeyException GenerateKeyRequestInternal(
63 blink::WebLocalFrame* frame,
64 const std::string& key_system,
65 const unsigned char* init_data,
66 unsigned init_data_length);
67
68 blink::WebMediaPlayer::MediaKeyException AddKeyInternal(
69 const std::string& key_system,
70 const unsigned char* key,
71 unsigned key_length,
72 const unsigned char* init_data,
73 unsigned init_data_length,
74 const std::string& session_id);
75
76 blink::WebMediaPlayer::MediaKeyException CancelKeyRequestInternal(
77 const std::string& key_system,
78 const std::string& session_id);
79
80 void OnNeedKey(const std::string& type,
81 const std::vector<uint8>& init_data);
82
83 void OnKeyAdded(const std::string& session_id);
84 void OnKeyError(const std::string& session_id,
85 media::MediaKeys::KeyError error_code,
86 uint32 system_code);
87 void OnKeyMessage(const std::string& session_id,
88 const std::vector<uint8>& message,
89 const GURL& destination_url);
90
91 void ContentDecryptionModuleAttached(
92 blink::WebContentDecryptionModuleResult result,
93 bool success);
94
95 blink::WebMediaPlayerClient* client_;
96
97 // The currently selected key system. Empty string means that no key system
98 // has been selected.
99 std::string current_key_system_;
100
101 // Temporary for EME v0.1. In the future the init data type should be passed
102 // through GenerateKeyRequest() directly from WebKit.
103 std::string init_data_type_;
104
105 // Manages decryption keys and decrypts encrypted frames.
106 scoped_ptr<ProxyDecryptor> proxy_decryptor_;
107
108 // Non-owned pointer to the CDM. Updated via calls to
109 // setContentDecryptionModule().
110 WebContentDecryptionModuleImpl* web_cdm_;
111
112 media::DecryptorReadyCB decryptor_ready_cb_;
113
114 DISALLOW_COPY_AND_ASSIGN(EncryptedMediaSupportImpl);
115 };
116
117 }
118
119 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_ENCRYPTED_MEDIA_SUPPORT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698