1 /*
2  * Copyright (c) 2022-2022 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_SHARE_ALLOCATOR_H
17 #define HISTREAMER_PLUGIN_COMMON_SHARE_ALLOCATOR_H
18 
19 #if !defined(OHOS_LITE) && defined(VIDEO_SUPPORT)
20 
21 #include "plugin/common/plugin_memory.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Plugin {
26 /**
27 * @brief Enumerate the shared memory types.
28 */
29 enum struct ShareMemType : uint8_t {
30     /** Readable and writable shared memory */
31     READ_WRITE_TYPE = 0x1,
32     /** Readable shared memory */
33     READ_ONLY_TYPE = 0x2,
34 };
35 
36 class ShareAllocator : public Allocator {
37 public:
38     explicit ShareAllocator(ShareMemType shareMemType = ShareMemType::READ_WRITE_TYPE);
39     ~ShareAllocator() override = default;
40 
41     void* Alloc(size_t size) override;
42     void Free(void* ptr) override; // NOLINT: void*
43 
44     ShareMemType GetShareMemType();
45 
46 private:
47     ShareMemType shareMemType_;
48 };
49 } // namespace Plugin
50 } // namespace Media
51 } // namespace OHOS
52 #endif
53 #endif // HISTREAMER_PLUGIN_COMMON_SHARE_ALLOCATOR_H
54