• 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 
16 #ifndef IMAGE_RECEIVER_MODULE_TEST_H
17 #define IMAGE_RECEIVER_MODULE_TEST_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include "napi/native_api.h"
23 #include "camera_manager_ndk.h"
24 #include "multimedia/image_framework/image/image_receiver_native.h"
25 #include "multimedia/image_framework/image/image_common.h"
26 
27 class ImageReceiverModuleTest {
28 public:
29     ImageReceiverModuleTest();
30     ~ImageReceiverModuleTest();
31 
32     // Image Receiver
33     Image_ErrorCode CreateImageReceiver(uint32_t width, uint32_t height, uint32_t capicity);
34     Image_ErrorCode DestroyImageReceiver();
35 
36     Image_ErrorCode GetImageReceiverSurfaceId(uint64_t *surfaceId);
37     Image_ErrorCode GetImageReceiverLatestImage(OH_ImageNative **image);
38     Image_ErrorCode GetImageReceiverNextImage(OH_ImageNative **image);
39 
40     Image_ErrorCode RegisterImageReceiverListener(OH_ImageReceiver_OnCallback callback);
41     Image_ErrorCode UnregisterImageReceiverListener();
42 
43     Image_ErrorCode VerifyImageReceiver();
44 
45     // Image Native
46     Image_ErrorCode DumpImageInfo(OH_ImageNative *image);
47     Image_ErrorCode ReleaseImage(OH_ImageNative *image);
48 
49 private:
50     bool ReuseSameRecevier(uint32_t width, uint32_t height, uint32_t capicity);
51 
52     Image_ErrorCode VerifyImageReceiverOptions(OH_ImageReceiverOptions *options);
53 
54     Image_ErrorCode GetImageSize(OH_ImageNative *image, Image_Size *size);
55     Image_ErrorCode GetImageComponentTypes(OH_ImageNative *image, std::vector<uint32_t> *types);
56     Image_ErrorCode GetImageByteBuffer(OH_ImageNative *image, int32_t type, OH_NativeBuffer **nativeBuffer);
57     Image_ErrorCode GetImageBufferSize(OH_ImageNative *image, int32_t type, size_t *size);
58     Image_ErrorCode GetImageRowStride(OH_ImageNative *image, int32_t type, int32_t *rowStride);
59     Image_ErrorCode GetImagePixelStride(OH_ImageNative *image, int32_t type, int32_t *pixelStride);
60 
61 private:
62     OH_ImageReceiverNative *imageReceiver_ = nullptr;
63 
64     // Params
65     uint32_t width_;
66     uint32_t height_;
67     uint32_t capacity_;
68 };
69 
70 #endif // IMAGE_RECEIVER_MODULE_TEST_H
71