1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AV_HARDWARE_ALLOCATOR_H 17 #define AV_HARDWARE_ALLOCATOR_H 18 19 #include "buffer/avallocator.h" 20 #include "common/status.h" 21 22 namespace OHOS { 23 namespace Media { 24 class AVHardwareAllocator : public AVAllocator { 25 public: 26 friend class AVAllocatorFactory; 27 ~AVHardwareAllocator() override; 28 29 void *Alloc(int32_t capacity) override; 30 bool Free(void *ptr) override; 31 MemoryType GetMemoryType() override; 32 33 MemoryFlag GetMemFlag(); 34 int32_t GetFileDescriptor(); 35 bool GetIsSecure(); 36 37 private: 38 AVHardwareAllocator(); 39 Status MapMemoryAddr(); 40 41 int32_t fd_; 42 int32_t capacity_; 43 uint8_t *allocBase_; 44 MemoryFlag memFlag_; 45 bool isAllocated_; 46 bool isSecure_; 47 }; 48 } // namespace Media 49 } // namespace OHOS 50 #endif // AV_HARDWARE_ALLOCATOR_H