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

Side by Side Diff: media/base/media_keys.h

Issue 15772012: Separate MediaKeys interface from Decryptor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 7 years, 6 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
« no previous file with comments | « media/base/decryptor.h ('k') | media/base/media_keys.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #ifndef MEDIA_BASE_MEDIA_KEYS_H_
6 #define MEDIA_BASE_MEDIA_KEYS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "media/base/media_export.h"
14
15 namespace media {
16
17 // Performs media key operations.
18 //
19 // All key operations are called on the renderer thread. Therefore, these calls
20 // should be fast and nonblocking; key events should be fired asynchronously.
21 class MEDIA_EXPORT MediaKeys {
22 public:
23 // Reported to UMA, so never reuse a value!
24 // Must be kept in sync with WebKit::WebMediaPlayerClient::MediaKeyErrorCode
25 // (enforced in webmediaplayer_impl.cc).
26 enum KeyError {
27 kUnknownError = 1,
28 kClientError,
29 kServiceError,
30 kOutputError,
31 kHardwareChangeError,
32 kDomainError,
33 kMaxKeyError // Must be last and greater than any legit value.
34 };
35
36 MediaKeys();
37 virtual ~MediaKeys();
38
39 // Generates a key request for the |key_system| with |type| and
40 // |init_data| provided.
41 // Returns true if generating key request succeeded, false otherwise.
42 // Note: AddKey() and CancelKeyRequest() should only be called after
43 // GenerateKeyRequest() returns true.
44 virtual bool GenerateKeyRequest(const std::string& key_system,
45 const std::string& type,
46 const uint8* init_data,
47 int init_data_length) = 0;
48
49 // Adds a |key| to the |key_system|. The |key| is not limited to a decryption
50 // key. It can be any data that the key system accepts, such as a license.
51 // If multiple calls of this function set different keys for the same
52 // key ID, the older key will be replaced by the newer key.
53 virtual void AddKey(const std::string& key_system,
54 const uint8* key, int key_length,
55 const uint8* init_data, int init_data_length,
56 const std::string& session_id) = 0;
57
58 // Cancels the key request specified by |session_id|.
59 virtual void CancelKeyRequest(const std::string& key_system,
60 const std::string& session_id) = 0;
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(MediaKeys);
64 };
65
66 // Key event callbacks. See the spec for details:
67 // http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted -media.html#event-summary
68 typedef base::Callback<void(const std::string& key_system,
69 const std::string& session_id)> KeyAddedCB;
70
71 typedef base::Callback<void(const std::string& key_system,
72 const std::string& session_id,
73 media::MediaKeys::KeyError error_code,
74 int system_code)> KeyErrorCB;
75
76 typedef base::Callback<void(const std::string& key_system,
77 const std::string& session_id,
78 const std::string& message,
79 const std::string& default_url)> KeyMessageCB;
80
81 typedef base::Callback<void(const std::string& key_system,
82 const std::string& session_id,
83 const std::string& type,
84 scoped_ptr<uint8[]> init_data,
85 int init_data_size)> NeedKeyCB;
86
87 } // namespace media
88
89 #endif // MEDIA_BASE_MEDIA_KEYS_H_
OLDNEW
« no previous file with comments | « media/base/decryptor.h ('k') | media/base/media_keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698