| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright (c) 2012 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_DECRYPTOR_H_ | 
 |   6 #define MEDIA_BASE_DECRYPTOR_H_ | 
 |   7  | 
 |   8 #include <string> | 
 |   9  | 
 |  10 #include "base/basictypes.h" | 
 |  11 #include "base/memory/ref_counted.h" | 
 |  12 #include "media/base/media_export.h" | 
 |  13  | 
 |  14 namespace media { | 
 |  15  | 
 |  16 class DecoderBuffer; | 
 |  17  | 
 |  18 // Performs key operations and decrypts encrypted buffer. | 
 |  19 // All public methods other than Decrypt() will be called on the renderer | 
 |  20 // thread. Therefore, these calls should be fast and nonblocking, with key | 
 |  21 // events fired asynchronously. Decrypt() will be called on the (video/audio) | 
 |  22 // decoder thread synchronously. | 
 |  23 class MEDIA_EXPORT Decryptor { | 
 |  24  public: | 
 |  25   enum KeyError { | 
 |  26     kUnknownError = 1, | 
 |  27     kClientError, | 
 |  28     kServiceError, | 
 |  29     kOutputError, | 
 |  30     kHardwareChangeError, | 
 |  31     kDomainError | 
 |  32   }; | 
 |  33  | 
 |  34   Decryptor() {} | 
 |  35   virtual ~Decryptor() {} | 
 |  36  | 
 |  37   // Generates a key request for the |key_system| with |init_data| provided. | 
 |  38   virtual void GenerateKeyRequest(const std::string& key_system, | 
 |  39                                   const uint8* init_data, | 
 |  40                                   int init_data_length) = 0; | 
 |  41  | 
 |  42   // Adds a |key| to the |key_system|. The |key| is not limited to a decryption | 
 |  43   // key. It can be any data that the key system accepts, such as a license. | 
 |  44   // If multiple calls of this function set different keys for the same | 
 |  45   // key ID, the older key will be replaced by the newer key. | 
 |  46   virtual void AddKey(const std::string& key_system, | 
 |  47                       const uint8* key, | 
 |  48                       int key_length, | 
 |  49                       const uint8* init_data, | 
 |  50                       int init_data_length, | 
 |  51                       const std::string& session_id) = 0; | 
 |  52  | 
 |  53   // Cancels the key request specified by |session_id|. | 
 |  54   virtual void CancelKeyRequest(const std::string& key_system, | 
 |  55                                 const std::string& session_id) = 0; | 
 |  56  | 
 |  57   // Decrypts the |input| buffer, which should not be NULL. | 
 |  58   // Returns a DecoderBuffer with the decrypted data if decryption succeeded. | 
 |  59   // Returns NULL if decryption failed. | 
 |  60   virtual scoped_refptr<DecoderBuffer> Decrypt( | 
 |  61       const scoped_refptr<DecoderBuffer>& input) = 0; | 
 |  62  | 
 |  63  private: | 
 |  64   DISALLOW_COPY_AND_ASSIGN(Decryptor); | 
 |  65 }; | 
 |  66  | 
 |  67 }  // namespace media | 
 |  68  | 
 |  69 #endif  // MEDIA_BASE_DECRYPTOR_H_ | 
| OLD | NEW |