blob: 09335069df68de1eb6f4cf41e3c8b18feeadfbe6 [file] [log] [blame]
John "Juce" Bruce1fe11a52014-05-13 22:22:44 -07001/*
2 * Copyright (C) 2014 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 CLEARKEY_SESSION_H_
18#define CLEARKEY_SESSION_H_
19
20#include <media/stagefright/foundation/ABase.h>
21#include <utils/Errors.h>
22#include <utils/Mutex.h>
23#include <utils/RefBase.h>
24#include <utils/String8.h>
25#include <utils/Vector.h>
26
27#include "ClearKeyTypes.h"
28#include "Utils.h"
29
30namespace clearkeydrm {
31
32class Session : public android::RefBase {
33public:
34 explicit Session(const android::Vector<uint8_t>& sessionId)
35 : mSessionId(sessionId) {}
36 virtual ~Session() {}
37
38 const android::Vector<uint8_t>& sessionId() const { return mSessionId; }
39
40 android::status_t getKeyRequest(
Edwin Wong01a977a2016-08-11 14:06:34 -070041 const android::Vector<uint8_t>& mimeType,
John "Juce" Bruce1fe11a52014-05-13 22:22:44 -070042 const android::String8& initDataType,
43 android::Vector<uint8_t>* keyRequest) const;
44
45 android::status_t provideKeyResponse(
46 const android::Vector<uint8_t>& response);
47
48 android::status_t decrypt(
49 const KeyId keyId, const Iv iv, const void* source,
50 void* destination, const SubSample* subSamples,
51 size_t numSubSamples, size_t* bytesDecryptedOut);
52
53private:
54 DISALLOW_EVIL_CONSTRUCTORS(Session);
55
56 const android::Vector<uint8_t> mSessionId;
57
58 android::Mutex mMapLock;
59 KeyMap mKeyMap;
60};
61
62} // namespace clearkeydrm
63
64#endif // CLEARKEY_SESSION_H_