• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef IMAGE_CREATOR_IMPL_H
16 #define IMAGE_CREATOR_IMPL_H
17 
18 #include "cj_ffi/cj_common_ffi.h"
19 #include "ffi_remote_data.h"
20 #include "image_creator.h"
21 #include "image_log.h"
22 
23 namespace OHOS {
24 namespace Media {
25 class ImageCreatorImpl : public OHOS::FFI::FFIData {
26     DECL_TYPE(ImageCreatorImpl, OHOS::FFI::FFIData)
27 public:
28     ImageCreatorImpl(int32_t width, int32_t height, int32_t format, int32_t capacity);
29     ~ImageCreatorImpl();
30     std::shared_ptr<ImageCreator> GetImageCreator();
31     void Release();
32     uint32_t CjOn(std::string name, std::function<void()> callBack);
33 #ifdef IMAGE_DEBUG_FLAG
34     bool isCallBackTest = false;
35 #endif
36 
37 private:
38     void release();
39     bool isRelease = false;
40     std::shared_ptr<ImageCreator> imageCreator_ = nullptr;
41 };
42 
43 class CJImageCreatorReleaseListener : public SurfaceBufferReleaseListener {
44 public:
~CJImageCreatorReleaseListener()45     ~CJImageCreatorReleaseListener() override
46     {
47         callBack = nullptr;
48     }
OnSurfaceBufferRelease()49     void OnSurfaceBufferRelease() override
50     {
51         if (callBack != nullptr) {
52             callBack();
53         }
54     }
55     std::string name;
56     std::function<void()> callBack = nullptr;
57 };
58 } // namespace Media
59 } // namespace OHOS
60 #endif // IMAGE_CREATOR_IMPL_H
61