1 /* 2 * Copyright 2017, 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 _ANDROID_MEDIA_DESCRAMBLER_H_ 18 #define _ANDROID_MEDIA_DESCRAMBLER_H_ 19 20 #include "jni.h" 21 22 #include <binder/Status.h> 23 #include <media/cas/DescramblerAPI.h> 24 #include <media/stagefright/foundation/ABase.h> 25 #include <utils/Mutex.h> 26 #include <utils/RefBase.h> 27 28 namespace android { 29 class IMemory; 30 class MemoryDealer; 31 namespace media { 32 class IDescrambler; 33 }; 34 using namespace media; 35 using binder::Status; 36 37 struct JDescrambler : public RefBase { 38 JDescrambler(JNIEnv *env, jobject descramberBinderObj); 39 40 Status descramble( 41 jbyte key, 42 size_t numSubSamples, 43 ssize_t totalLength, 44 DescramblerPlugin::SubSample *subSamples, 45 const void *srcPtr, 46 jint srcOffset, 47 void *dstPtr, 48 jint dstOffset, 49 ssize_t *result); 50 51 protected: 52 virtual ~JDescrambler(); 53 54 private: 55 sp<IDescrambler> mDescrambler; 56 sp<IMemory> mMem; 57 sp<MemoryDealer> mDealer; 58 Mutex mSharedMemLock; 59 60 void ensureBufferCapacity(size_t neededSize); 61 62 DISALLOW_EVIL_CONSTRUCTORS(JDescrambler); 63 }; 64 65 } // namespace android 66 67 #endif // _ANDROID_MEDIA_DESCRAMBLER_H_ 68