blob: 25bd34aa7ff4cefc9bbd85f5f2016a5307771c5b [file] [log] [blame]
Jeff Tinker8ab80a22012-11-29 07:37:08 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef DRM_ENGINE_API_H_
18#define DRM_ENGINE_API_H_
19
20#include <utils/Errors.h>
21#include <media/stagefright/foundation/ABase.h>
22
23
24namespace android {
25
26 class CryptoPlugin;
27 class DrmClientPlugin;
28
29 // DRMs are implemented in DrmEngine plugins, which are dynamically
30 // loadable shared libraries that implement the entry point
31 // createDrmPluginFactory. createDrmPluginFactory constructs and returns
32 // an instance of a DrmPluginFactory object. When a MediaCrypto or
33 // DrmClient object needs to be constructed, all available
34 // DrmEngines present in the plugins directory on the device are scanned
35 // for a matching DrmEngine that can support the crypto scheme. When a
36 // match is found, the DrmEngine’s createCryptoPlugin or
37 // createDrmClientPlugin methods are used to create CryptoPlugin or
38 // DrmClientPlugin instances to support that DRM scheme.
39
40 class DrmPluginFactory {
41 public:
42 DrmPluginFactory() {}
43 virtual ~DrmPluginFactory() {}
44
45 // DrmPluginFactory::isCryptoSchemeSupported can be called to determine
46 // if the plugin factory is able to construct plugins that support a
47 // given crypto scheme, which is specified by a UUID.
48 virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const = 0;
49
50 // Construct a CryptoPlugin for the crypto scheme specified by UUID.
51 // {data, size} provide scheme-specific initialization data.
52 virtual status_t createCryptoPlugin(
53 const uint8_t uuid[16], const void *data, size_t size,
54 CryptoPlugin **plugin) = 0;
55
56 // Construct a DrmClientPlugin for the crypto scheme specified by UUID.
57 // {data, size} provide scheme-specific initialization data.
58 virtual status_t createDrmClientPlugin(
59 const uint8_t uuid[16], const void *data, size_t size,
60 DrmClientPlugin **plugin) = 0;
61
62 private:
63 DISALLOW_EVIL_CONSTRUCTORS(DrmPluginFactory);
64 };
65
66} // namespace android
67
68 // Loadable DrmEngine shared libraries should define the entry point
69 // createDrmPluginFactory as shown below:
70 //
71 // extern "C" {
72 // extern android::DrmPluginFactory *createDrmPluginFactory();
73 // }
74
75#endif // DRM_ENGINE_API_H_