• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
30 namespace clearkeydrm {
31 
32 class Session : public android::RefBase {
33 public:
Session(const android::Vector<uint8_t> & sessionId)34     explicit Session(const android::Vector<uint8_t>& sessionId)
35             : mSessionId(sessionId) {}
~Session()36     virtual ~Session() {}
37 
sessionId()38     const android::Vector<uint8_t>& sessionId() const { return mSessionId; }
39 
40     android::status_t getKeyRequest(
41             const android::Vector<uint8_t>& mimeType,
42             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 
53 private:
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_
65