OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_CDM_CONTEXT_H_ | 5 #ifndef MEDIA_BASE_CDM_CONTEXT_H_ |
6 #define MEDIA_BASE_CDM_CONTEXT_H_ | 6 #define MEDIA_BASE_CDM_CONTEXT_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 class Decryptor; | 14 class Decryptor; |
15 | 15 |
16 // An interface representing the context that a media pipeline needs from a | 16 // An interface representing the context that a media pipeline needs from a |
17 // content decryption module (CDM) to decrypt (and decode) encrypted buffers. | 17 // content decryption module (CDM) to decrypt (and decode) encrypted buffers. |
| 18 // Only used for implementing SetCdm(). |
18 class MEDIA_EXPORT CdmContext { | 19 class MEDIA_EXPORT CdmContext { |
19 public: | 20 public: |
20 // Indicates an invalid CDM ID. See GetCdmId() for details. | 21 // Indicates an invalid CDM ID. See GetCdmId() for details. |
21 static const int kInvalidCdmId = 0; | 22 static const int kInvalidCdmId = 0; |
22 | 23 |
23 virtual ~CdmContext(); | 24 virtual ~CdmContext(); |
24 | 25 |
25 // Gets the Decryptor object associated with the CDM. Returns NULL if the CDM | 26 // Gets the Decryptor object associated with the CDM. Returns nullptr if the |
26 // does not support a Decryptor. The returned object is only guaranteed to be | 27 // CDM does not support a Decryptor. Must not return nullptr if GetCdmId() |
27 // valid during the CDM's lifetime. | 28 // returns kInvalidCdmId. The returned object is only guaranteed to be valid |
| 29 // during the CDM's lifetime. |
28 virtual Decryptor* GetDecryptor() = 0; | 30 virtual Decryptor* GetDecryptor() = 0; |
29 | 31 |
30 // Returns an ID associated with the CDM, which can be used to locate the real | 32 // Returns an ID that identifies a CDM, or kInvalidCdmId. The interpretation |
31 // CDM instance. This is useful when the CDM is hosted remotely, e.g. in a | 33 // is implementation-specific; current implementations use the ID to locate a |
32 // different process. | 34 // remote CDM in a different process. The return value will not be |
33 // Returns kInvalidCdmId if the CDM cannot be used remotely. In this case, | 35 // kInvalidCdmId if GetDecryptor() returns nullptr. |
34 // GetDecryptor() should return a non-null Decryptor. | |
35 virtual int GetCdmId() const = 0; | 36 virtual int GetCdmId() const = 0; |
36 | 37 |
37 protected: | 38 protected: |
38 CdmContext(); | 39 CdmContext(); |
39 | 40 |
40 private: | 41 private: |
41 DISALLOW_COPY_AND_ASSIGN(CdmContext); | 42 DISALLOW_COPY_AND_ASSIGN(CdmContext); |
42 }; | 43 }; |
43 | 44 |
| 45 // An interface for looking up CdmContext objects by the CDM ID. |
| 46 class MEDIA_EXPORT CdmContextProvider { |
| 47 public: |
| 48 virtual ~CdmContextProvider(); |
| 49 |
| 50 // Returns the CdmContext corresponding to |cdm_id|. Returns nullptr if no |
| 51 // such CdmContext can be found. |
| 52 // Note: Calling GetCdmId() on the returned CdmContext returns kInvalidCdmId |
| 53 // (in all current cases) because the CDM will be local in the process where |
| 54 // GetCdmContext() is called. |
| 55 virtual CdmContext* GetCdmContext(int cdm_id) = 0; |
| 56 |
| 57 protected: |
| 58 CdmContextProvider(); |
| 59 |
| 60 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(CdmContextProvider); |
| 62 }; |
| 63 |
44 // Callback to notify that the CdmContext has been completely attached to | 64 // Callback to notify that the CdmContext has been completely attached to |
45 // the media pipeline. Parameter indicates whether the operation succeeded. | 65 // the media pipeline. Parameter indicates whether the operation succeeded. |
46 typedef base::Callback<void(bool)> CdmAttachedCB; | 66 typedef base::Callback<void(bool)> CdmAttachedCB; |
47 | 67 |
48 // A dummy implementation of CdmAttachedCB. | 68 // A dummy implementation of CdmAttachedCB. |
49 MEDIA_EXPORT void IgnoreCdmAttached(bool success); | 69 MEDIA_EXPORT void IgnoreCdmAttached(bool success); |
50 | 70 |
51 } // namespace media | 71 } // namespace media |
52 | 72 |
53 #endif // MEDIA_BASE_CDM_CONTEXT_H_ | 73 #endif // MEDIA_BASE_CDM_CONTEXT_H_ |
OLD | NEW |