1 /* 2 * Copyright (C) 2018 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 BUFFER_H_ 18 #define BUFFER_H_ 19 20 #include <android/hardware/drm/1.0/types.h> 21 #include <utils/RefBase.h> 22 23 #include "ClearKeyTypes.h" 24 25 namespace android { 26 namespace hardware { 27 namespace drm { 28 namespace V1_2 { 29 namespace clearkey { 30 31 using ::android::sp; 32 33 struct Buffer : public RefBase { 34 explicit Buffer(size_t capacity); 35 baseBuffer36 uint8_t *base() { return reinterpret_cast<uint8_t *>(mData); } dataBuffer37 uint8_t *data() { return reinterpret_cast<uint8_t *>(mData) + mRangeOffset; } capacityBuffer38 size_t capacity() const { return mCapacity; } sizeBuffer39 size_t size() const { return mRangeLength; } offsetBuffer40 size_t offset() const { return mRangeOffset; } 41 42 protected: 43 virtual ~Buffer(); 44 45 private: 46 void *mData; 47 size_t mCapacity; 48 size_t mRangeOffset; 49 size_t mRangeLength; 50 51 bool mOwnsData; 52 53 CLEARKEY_DISALLOW_COPY_AND_ASSIGN(Buffer); 54 }; 55 56 } // namespace clearkey 57 } // namespace V1_2 58 } // namespace drm 59 } // namespace hardware 60 } // namespace android 61 62 #endif // BUFFER_H_ 63