• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #pragma once
17 
18 #include <utils/RefBase.h>
19 
20 #include "ClearKeyTypes.h"
21 
22 namespace clearkeydrm {
23 struct Buffer : public ::android::RefBase {
24     explicit Buffer(size_t capacity);
25 
baseBuffer26     uint8_t* base() { return reinterpret_cast<uint8_t*>(mData); }
dataBuffer27     uint8_t* data() { return reinterpret_cast<uint8_t*>(mData) + mRangeOffset; }
capacityBuffer28     size_t capacity() const { return mCapacity; }
sizeBuffer29     size_t size() const { return mRangeLength; }
offsetBuffer30     size_t offset() const { return mRangeOffset; }
31 
32   protected:
33     virtual ~Buffer();
34 
35   private:
36     void* mData;
37     size_t mCapacity;
38     size_t mRangeOffset;
39     size_t mRangeLength;
40 
41     bool mOwnsData;
42 
43     CLEARKEY_DISALLOW_COPY_AND_ASSIGN(Buffer);
44 };
45 
46 }  // namespace clearkeydrm
47