• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include <binder/IInterface.h>
18 #include <media/stagefright/foundation/ABase.h>
19 #include <media/hardware/CryptoAPI.h>
20 
21 #ifndef ANDROID_ICRYPTO_H_
22 
23 #define ANDROID_ICRYPTO_H_
24 
25 namespace android {
26 
27 struct AString;
28 class IMemory;
29 
30 struct ICrypto : public IInterface {
31     DECLARE_META_INTERFACE(Crypto);
32 
33     virtual status_t initCheck() const = 0;
34 
35     virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0;
36 
37     virtual status_t createPlugin(
38             const uint8_t uuid[16], const void *data, size_t size) = 0;
39 
40     virtual status_t destroyPlugin() = 0;
41 
42     virtual bool requiresSecureDecoderComponent(
43             const char *mime) const = 0;
44 
45     virtual void notifyResolution(uint32_t width, uint32_t height) = 0;
46 
47     virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId) = 0;
48 
49     virtual ssize_t decrypt(
50             bool secure,
51             const uint8_t key[16],
52             const uint8_t iv[16],
53             CryptoPlugin::Mode mode,
54             const sp<IMemory> &sharedBuffer, size_t offset,
55             const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
56             void *dstPtr,
57             AString *errorDetailMsg) = 0;
58 
59 private:
60     DISALLOW_EVIL_CONSTRUCTORS(ICrypto);
61 };
62 
63 struct BnCrypto : public BnInterface<ICrypto> {
64     virtual status_t onTransact(
65             uint32_t code, const Parcel &data, Parcel *reply,
66             uint32_t flags = 0);
67 private:
68     void readVector(const Parcel &data, Vector<uint8_t> &vector) const;
69     void writeVector(Parcel *reply, Vector<uint8_t> const &vector) const;
70 };
71 
72 }  // namespace android
73 
74 #endif // ANDROID_ICRYPTO_H_
75