1 /* 2 * Copyright (c) 2021-2021 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 HISTREAMER_PLUGIN_COMMON_SURFACE_ALLOCATOR_H 17 #define HISTREAMER_PLUGIN_COMMON_SURFACE_ALLOCATOR_H 18 19 #if !defined(OHOS_LITE) && defined(VIDEO_SUPPORT) 20 21 #include "plugin_memory.h" 22 #include "refbase.h" 23 #include "surface/surface.h" 24 25 namespace OHOS { 26 namespace Media { 27 namespace Plugin { 28 class SurfaceAllocator : public Allocator { 29 public: 30 explicit SurfaceAllocator(sptr<Surface> surface = nullptr); 31 ~SurfaceAllocator() override = default; 32 33 sptr<SurfaceBuffer> AllocSurfaceBuffer(size_t size); 34 35 void* Alloc(size_t size) override; 36 void Free(void* ptr) override; // NOLINT: void* 37 38 void Config(int32_t width, int32_t height, uint64_t usage, int32_t format, int32_t strideAlign, int32_t timeout); 39 40 private: 41 sptr<Surface> surface_ {nullptr}; 42 BufferRequestConfig requestConfig_; 43 }; 44 } // namespace Plugin 45 } // namespace Media 46 } // namespace OHOS 47 48 #endif 49 #endif // HISTREAMER_PLUGIN_COMMON_SURFACE_BUFFER_H 50