Material PDF: Restore animated entry and exit of viewer toolbars
[chromium-blink-merge.git] / media / base / cdm_context.h
blob7d897608cc39946e513334ca6a0a55cc1ee19e5a
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_BASE_CDM_CONTEXT_H_
6 #define MEDIA_BASE_CDM_CONTEXT_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "media/base/media_export.h"
12 namespace media {
14 class Decryptor;
16 // An interface representing the context that a media pipeline needs from a
17 // content decryption module (CDM) to decrypt (and decode) encrypted buffers.
18 // Only used for implementing SetCdm().
19 class MEDIA_EXPORT CdmContext {
20 public:
21 // Indicates an invalid CDM ID. See GetCdmId() for details.
22 static const int kInvalidCdmId = 0;
24 virtual ~CdmContext();
26 // Gets the Decryptor object associated with the CDM. Returns nullptr if the
27 // CDM does not support a Decryptor. Must not return nullptr if GetCdmId()
28 // returns kInvalidCdmId. The returned object is only guaranteed to be valid
29 // during the CDM's lifetime.
30 virtual Decryptor* GetDecryptor() = 0;
32 // Returns an ID that identifies a CDM, or kInvalidCdmId. The interpretation
33 // is implementation-specific; current implementations use the ID to locate a
34 // remote CDM in a different process. The return value will not be
35 // kInvalidCdmId if GetDecryptor() returns nullptr.
36 virtual int GetCdmId() const = 0;
38 protected:
39 CdmContext();
41 private:
42 DISALLOW_COPY_AND_ASSIGN(CdmContext);
45 // An interface for looking up CdmContext objects by the CDM ID.
46 class MEDIA_EXPORT CdmContextProvider {
47 public:
48 virtual ~CdmContextProvider();
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;
57 protected:
58 CdmContextProvider();
60 private:
61 DISALLOW_COPY_AND_ASSIGN(CdmContextProvider);
64 // Callback to notify that the CdmContext has been completely attached to
65 // the media pipeline. Parameter indicates whether the operation succeeded.
66 typedef base::Callback<void(bool)> CdmAttachedCB;
68 // A dummy implementation of CdmAttachedCB.
69 MEDIA_EXPORT void IgnoreCdmAttached(bool success);
71 } // namespace media
73 #endif // MEDIA_BASE_CDM_CONTEXT_H_