diff --git a/BUILD.gn b/BUILD.gn index 54981df1796612533627394498868328543e8fc2..f6c02def949b09f36479aed5c97de59097ad6a88 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -35,6 +35,8 @@ group("image_framework") { "frameworks/kits/js/common/ndk:image_ndk", "frameworks/kits/js/common/ndk:image_receiver_ndk", "frameworks/kits/js/common/pixelmap_ndk:pixelmap_ndk", + "frameworks/kits/native/common/ndk:image_receiver", + "frameworks/kits/native/common/ndk:ohimage", "interfaces/innerkits:image_native", "interfaces/kits/js/common:image", "interfaces/kits/js/common:image_napi", diff --git a/bundle.json b/bundle.json index 7f852102248b1ae1efdebae298e305e16b54b191..e1734784ec51dc69a090f57f866280f3d14a756a 100644 --- a/bundle.json +++ b/bundle.json @@ -171,6 +171,26 @@ "header_base": "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/egl_image/include" }, "name": "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/egl_image:egl_image" + }, + { + "header": { + "header_base": "//foundation/multimedia/image_framework/interfaces/kits/native/include/image/", + "header_files": [ + "image_common.h", + "image_native.h" + ] + }, + "name": "//foundation/multimedia/image_framework/frameworks/kits/native/common/ndk:ohimage" + }, + { + "header": { + "header_base": "//foundation/multimedia/image_framework/interfaces/kits/native/include/image/", + "header_files": [ + "image_common.h", + "image_receiver_native.h" + ] + }, + "name": "//foundation/multimedia/image_framework/frameworks/kits/native/common/ndk:image_receiver" } ], "test": [ diff --git a/frameworks/innerkitsimpl/receiver/include/image_receiver.h b/frameworks/innerkitsimpl/receiver/include/image_receiver.h index 8e38edeef084cc72284e324b7acd845b055a4c38..bc5771cdddf497f1fcb5f2765b3f3708a0207858 100644 --- a/frameworks/innerkitsimpl/receiver/include/image_receiver.h +++ b/frameworks/innerkitsimpl/receiver/include/image_receiver.h @@ -73,6 +73,10 @@ public: { surfaceBufferAvaliableListener_ = surfaceBufferAvaliableListener; } + void UnRegisterBufferAvaliableListener() + { + surfaceBufferAvaliableListener_.reset(); + } static sptr getSurfaceById(std::string id); void ReleaseReceiver(); diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index e9538caf77547231c6c66c19f3cf43e5f14d0b8d..955cb459755b31c4d6b9b0e648b0367cb652fe4e 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -1461,6 +1461,54 @@ ohos_unittest("exifmetadatatest") { ] } +ohos_unittest("image_native_test") { + module_out_path = module_output_path + + include_dirs = [ + "${image_subsystem}/frameworks/innerkitsimpl", + "${image_subsystem}/frameworks/kits/native/common/ndk/include", + "${image_subsystem}/frameworks/kits/js/common/include", + "${image_subsystem}/interfaces/kits/native/include/image", + "${image_subsystem}/../../../third_party/googletest/googletest/include", + ] + + sources = [ "${image_subsystem}/frameworks/innerkitsimpl/test/unittest/image_native_test.cpp" ] + + deps = [ + "${image_subsystem}/../../../third_party/googletest:gtest_main", + "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", + "${image_subsystem}/frameworks/kits/native/common/ndk:image_receiver", + "${image_subsystem}/frameworks/kits/native/common/ndk:ohimage", + "${image_subsystem}/interfaces/innerkits:image_native", + ] + resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml" + external_deps = [ "c_utils:utils" ] +} + +ohos_unittest("image_receiver_native_test") { + module_out_path = module_output_path + + include_dirs = [ + "${image_subsystem}/frameworks/innerkitsimpl", + "${image_subsystem}/frameworks/kits/native/common/ndk/include", + "${image_subsystem}/frameworks/kits/js/common/include", + "${image_subsystem}/interfaces/kits/native/include/image", + "${image_subsystem}/../../../third_party/googletest/googletest/include", + ] + + sources = [ "${image_subsystem}/frameworks/innerkitsimpl/test/unittest/image_receiver_native_test.cpp" ] + + deps = [ + "${image_subsystem}/../../../third_party/googletest:gtest_main", + "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", + "${image_subsystem}/frameworks/kits/native/common/ndk:image_receiver", + "${image_subsystem}/frameworks/kits/native/common/ndk:ohimage", + "${image_subsystem}/interfaces/innerkits:image_native", + ] + resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml" + external_deps = [ "c_utils:utils" ] +} + ################################################ group("unittest") { testonly = true @@ -1477,6 +1525,8 @@ group("unittest") { ":formatagentplugintest", ":gstpluginfwtest", ":heifyuvtest", + ":image_native_test", + ":image_receiver_native_test", ":imageaccessortest", ":imagecolorspacetest", ":imagepixelmapparceltest", diff --git a/frameworks/innerkitsimpl/test/unittest/image_native_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_native_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1eee52bbb6897e4dc94eeca6b3c0972ee911e2e3 --- /dev/null +++ b/frameworks/innerkitsimpl/test/unittest/image_native_test.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "common_utils.h" +#include "image_native.h" +#include "image_receiver_native.h" +#include "image_kits.h" +#include "image_receiver.h" + +using namespace testing::ext; +namespace OHOS { +namespace Media { + +class ImageNativeTest : public testing::Test { +public: + ImageNativeTest() {} + ~ImageNativeTest() {} +}; + +/** + * @tc.name: OH_ImageNative_ReleaseTest + * @tc.desc: OH_ImageNative_Release + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_ReleaseTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_ReleaseTest start"; + OH_ImageNative* pImg = nullptr; + Image_ErrorCode nRst = OH_ImageNative_Release(pImg); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_ReleaseTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetByteBufferTest + * @tc.desc: OH_ImageNative_GetByteBuffer + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetByteBufferTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetByteBufferTest start"; + OH_ImageNative* pImg = nullptr; + OH_NativeBuffer* pBuffer = nullptr; + Image_ErrorCode nRst = OH_ImageNative_GetByteBuffer(pImg, 0, &pBuffer); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetByteBufferTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetBufferSizeTest + * @tc.desc: OH_ImageNative_GetBufferSize + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetBufferSizeTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetBufferSizeTest start"; + OH_ImageNative* pImg = nullptr; + size_t nSize = 0; + Image_ErrorCode nRst = OH_ImageNative_GetBufferSize(pImg, 0, &nSize); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetBufferSizeTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetComponentTypesTest + * @tc.desc: OH_ImageNative_GetComponentTypes + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetComponentTypesTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetComponentTypesTest start"; + OH_ImageNative* pImg = nullptr; + uint32_t* pTypes = nullptr; + size_t nTypeSize = 0; + Image_ErrorCode nRst = OH_ImageNative_GetComponentTypes(pImg, &pTypes, &nTypeSize); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetComponentTypesTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetRowStrideTest + * @tc.desc: OH_ImageNative_GetRowStride + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetRowStrideTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetRowStrideTest start"; + OH_ImageNative* pImg = nullptr; + int32_t nRowStride = 0; + Image_ErrorCode nRst = OH_ImageNative_GetRowStride(pImg, 0, &nRowStride); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetRowStrideTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetPixelStrideTest + * @tc.desc: OH_ImageNative_GetPixelStride + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetPixelStrideTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetPixelStrideTest start"; + OH_ImageNative* pImg = nullptr; + int32_t nPixelStride = 0; + Image_ErrorCode nRst = OH_ImageNative_GetPixelStride(pImg, 0, &nPixelStride); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetPixelStrideTest end"; +} + +/** + * @tc.name: OH_ImageNative_GetImageSizeTest + * @tc.desc: OH_ImageNative_GetImageSize + * @tc.type: FUNC + */ +HWTEST_F(ImageNativeTest, OH_ImageNative_GetImageSizeTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetImageSizeTest start"; + OH_ImageNative* pImg = nullptr; + Image_Size szImg = { 0 }; + Image_ErrorCode nRst = OH_ImageNative_GetImageSize(pImg, &szImg); + ASSERT_EQ(nRst, IMAGE_BAD_PARAMETER); + GTEST_LOG_(INFO) << "ImageNativeTest: OH_ImageNative_GetImageSizeTest end"; +} + +} // namespace Media +} // namespace OHOS diff --git a/frameworks/innerkitsimpl/test/unittest/image_receiver_native_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_receiver_native_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..133454a785d7c4624b2e94408fdf36264848272b --- /dev/null +++ b/frameworks/innerkitsimpl/test/unittest/image_receiver_native_test.cpp @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "common_utils.h" +#include "image_native.h" +#include "image_receiver_native.h" +#include "image_kits.h" +#include "image_receiver.h" + +using namespace testing::ext; +namespace OHOS { +namespace Media { + +static constexpr int32_t IMAGE_TEST_WIDTH = 8192; +static constexpr int32_t IMAGE_TEST_HEIGHT = 8; +static constexpr int32_t IMAGE_TEST_CAPACITY = 8; + +class ImageReceiverNativeTest : public testing::Test { +public: + ImageReceiverNativeTest() {} + ~ImageReceiverNativeTest() {} + static OH_ImageReceiverNative* CreateReceiver(); +}; + +OH_ImageReceiverNative* ImageReceiverNativeTest::CreateReceiver() +{ + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + if (nRst != IMAGE_SUCCESS || options == nullptr) { + return nullptr; + } + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + + Image_Size size; + size.width = IMAGE_TEST_WIDTH; + size.height = IMAGE_TEST_HEIGHT; + nRst = OH_ImageReceiverOptions_SetSize(options, size); + if (nRst != IMAGE_SUCCESS) { + return nullptr; + } + + nRst = OH_ImageReceiverOptions_SetCapacity(options, IMAGE_TEST_CAPACITY); + if (nRst != IMAGE_SUCCESS) { + return nullptr; + } + + OH_ImageReceiverNative* pReceiver = nullptr; + nRst = OH_ImageReceiverNative_Create(options, &pReceiver); + if (nRst != IMAGE_SUCCESS || pReceiver == nullptr) { + return nullptr; + } + return pReceiver; +} + +/** + * @tc.name: OH_ImageReceiverOptions_CreateTest + * @tc.desc: OH_ImageReceiverOptions_Create + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_CreateTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_CreateTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_CreateTest end"; +} + +/** + * @tc.name: OH_ImageReceiverOptions_ReleaseTest + * @tc.desc: OH_ImageReceiverOptions_Release + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_ReleaseTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_ReleaseTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + nRst = OH_ImageReceiverOptions_Release(options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_ReleaseTest end"; +} + +/** + * @tc.name: OH_ImageReceiverOptions_SetSizeTest + * @tc.desc: OH_ImageReceiverOptions_SetSize + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_SetSizeTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_SetSizeTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + + Image_Size size; + size.width = IMAGE_TEST_WIDTH; + size.height = IMAGE_TEST_HEIGHT; + nRst = OH_ImageReceiverOptions_SetSize(options, size); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_SetSizeTest end"; +} + +/** + * @tc.name: OH_ImageReceiverOptions_GetSizeTest + * @tc.desc: OH_ImageReceiverOptions_GetSize + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_GetSizeTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_GetSizeTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + + Image_Size size; + size.width = IMAGE_TEST_WIDTH; + size.height = IMAGE_TEST_HEIGHT; + nRst = OH_ImageReceiverOptions_SetSize(options, size); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + + Image_Size size_get; + nRst = OH_ImageReceiverOptions_GetSize(options, &size_get); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_EQ(size_get.width, IMAGE_TEST_WIDTH); + ASSERT_EQ(size_get.height, IMAGE_TEST_HEIGHT); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_GetSizeTest end"; +} + +/** + * @tc.name: OH_ImageReceiverOptions_SetCapacityTest + * @tc.desc: OH_ImageReceiverOptions_SetCapacity + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_SetCapacityTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_SetCapacityTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + + nRst = OH_ImageReceiverOptions_SetCapacity(options, IMAGE_TEST_CAPACITY); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_SetCapacityTest end"; +} + +/** + * @tc.name: OH_ImageReceiverOptions_GetCapacityTest + * @tc.desc: OH_ImageReceiverOptions_GetCapacity + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverOptions_GetCapacityTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_GetCapacityTest start"; + OH_ImageReceiverOptions* options = nullptr; + Image_ErrorCode nRst = IMAGE_SUCCESS; + nRst = OH_ImageReceiverOptions_Create(&options); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_NE(options, nullptr); + std::shared_ptr ptrOptions(options, OH_ImageReceiverOptions_Release); + + nRst = OH_ImageReceiverOptions_SetCapacity(options, IMAGE_TEST_CAPACITY); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + + int32_t nCapacity = 0; + nRst = OH_ImageReceiverOptions_GetCapacity(options, &nCapacity); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + ASSERT_EQ(nCapacity, IMAGE_TEST_CAPACITY); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverOptions_GetCapacityTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_CreateTest + * @tc.desc: OH_ImageReceiverNative_Create + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_CreateTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_CreateTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_CreateTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_ReleaseTest + * @tc.desc: OH_ImageReceiverNative_Release + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_ReleaseTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReleaseTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + Image_ErrorCode nRst = OH_ImageReceiverNative_Release(pReceiver); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReleaseTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_GetReceivingSurfaceIdTest + * @tc.desc: OH_ImageReceiverNative_GetReceivingSurfaceId + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_GetReceivingSurfaceIdTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetReceivingSurfaceIdTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + uint64_t nSurfaceId = 0; + Image_ErrorCode nRst = OH_ImageReceiverNative_GetReceivingSurfaceId(pReceiver, &nSurfaceId); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetReceivingSurfaceIdTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_ReadLatestImageTest + * @tc.desc: OH_ImageReceiverNative_ReadLatestImage + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_ReadLatestImageTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReadLatestImageTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + OH_ImageNative* pImg = nullptr; + Image_ErrorCode nRst = OH_ImageReceiverNative_ReadLatestImage(pReceiver, &pImg); + ASSERT_EQ(nRst, IMAGE_UNKNOWN_ERROR); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReadLatestImageTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_ReadNextImageTest + * @tc.desc: OH_ImageReceiverNative_ReadNextImage + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_ReadNextImageTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReadNextImageTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + OH_ImageNative* pImg = nullptr; + Image_ErrorCode nRst = OH_ImageReceiverNative_ReadNextImage(pReceiver, &pImg); + ASSERT_EQ(nRst, IMAGE_UNKNOWN_ERROR); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_ReadNextImageTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_OnTest + * @tc.desc: OH_ImageReceiverNative_On + * @tc.type: FUNC + */ +static void OH_ImageReceiver_OnCallback(OH_ImageReceiverNative* receiver) {} + +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_OnTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_OnTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + Image_ErrorCode nRst = OH_ImageReceiverNative_On(pReceiver, OH_ImageReceiver_OnCallback); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_OnTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_OffTest + * @tc.desc: OH_ImageReceiverNative_Off + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_OffTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_OffTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + Image_ErrorCode nRst = OH_ImageReceiverNative_Off(pReceiver); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_OffTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_GetSizeTest + * @tc.desc: OH_ImageReceiverNative_GetSize + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_GetSizeTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetSizeTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + Image_Size size; + Image_ErrorCode nRst = OH_ImageReceiverNative_GetSize(pReceiver, &size); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetSizeTest end"; +} + +/** + * @tc.name: OH_ImageReceiverNative_GetCapacityTest + * @tc.desc: OH_ImageReceiverNative_GetCapacity + * @tc.type: FUNC + */ +HWTEST_F(ImageReceiverNativeTest, OH_ImageReceiverNative_GetCapacityTest, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetCapacityTest start"; + OH_ImageReceiverNative* pReceiver = ImageReceiverNativeTest::CreateReceiver(); + ASSERT_NE(pReceiver, nullptr); + std::shared_ptr ptrReceiver(pReceiver, OH_ImageReceiverNative_Release); + + int32_t nCapacity = 0; + Image_ErrorCode nRst = OH_ImageReceiverNative_GetCapacity(pReceiver, &nCapacity); + ASSERT_EQ(nRst, IMAGE_SUCCESS); + GTEST_LOG_(INFO) << "ImageReceiverNativeTest: OH_ImageReceiverNative_GetCapacityTest end"; +} + +} // namespace Media +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/kits/native/common/ndk/BUILD.gn b/frameworks/kits/native/common/ndk/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..de98ec8f64485542f81184cf19c9c8cd9a6bdc08 --- /dev/null +++ b/frameworks/kits/native/common/ndk/BUILD.gn @@ -0,0 +1,75 @@ +# Copyright (C) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/multimedia/image_framework/ide/image_decode_config.gni") + +config("native_public_config") { + include_dirs = [ + "include", + "${image_subsystem}/interfaces/kits/native/include/image", + "${image_subsystem}/frameworks/innerkitsimpl/receiver/include", + ] +} + +ohos_shared_library("ohimage") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + output_name = "image" + output_extension = "so" + + sources = [ "image_native.cpp" ] + public_configs = [ ":native_public_config" ] + deps = [ + "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", + "${image_subsystem}/interfaces/innerkits:image_native", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] + + innerapi_tags = [ "ndk" ] + subsystem_name = "multimedia" + part_name = "image_framework" +} + +ohos_shared_library("image_receiver") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + output_name = "image_receiver" + output_extension = "so" + + sources = [ "image_receiver_native.cpp" ] + public_configs = [ ":native_public_config" ] + deps = [ + "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", + "${image_subsystem}/interfaces/innerkits:image_native", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] + + innerapi_tags = [ "ndk" ] + subsystem_name = "multimedia" + part_name = "image_framework" +} diff --git a/frameworks/kits/native/common/ndk/image_native.cpp b/frameworks/kits/native/common/ndk/image_native.cpp new file mode 100644 index 0000000000000000000000000000000000000000..936ccedfa8609ec36ae9d22547fd984d5601525c --- /dev/null +++ b/frameworks/kits/native/common/ndk/image_native.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "common_utils.h" +#include "image_log.h" +#include "image_native.h" +#include "image_kits.h" + +#ifdef __cplusplus +extern "C" { +#endif + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative* image, Image_Size* size) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == size) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, size=0x%{public}p", image, size); + return IMAGE_BAD_PARAMETER; + } + int32_t width = 0; + int32_t height = 0; + Image_ErrorCode err = (Image_ErrorCode)image->imgNative->GetSize(width, height); + size->width = width; + size->height = height; + return err; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative* image, uint32_t** types, size_t* typeSize) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == typeSize) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, typeSize=0x%{public}p", image, typeSize); + return IMAGE_BAD_PARAMETER; + } + + image->imgNative->GetComponent(int32_t(OHOS::Media::ComponentType::JPEG)); + + auto& components = image->imgNative->GetComponents(); + *typeSize = components.size(); + if (nullptr == types) { + return IMAGE_SUCCESS; + } + + uint32_t* p = *types; + for (auto itor = components.begin(); itor != components.end(); ++itor) { + *p = itor->first; + p++; + } + + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative* image, uint32_t componentType, OH_NativeBuffer** nativeBuffer) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == nativeBuffer) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, nativeBuffer=0x%{public}p", image, nativeBuffer); + return IMAGE_BAD_PARAMETER; + } + + auto component = image->imgNative->GetComponent(componentType); + if (nullptr == component) { + return IMAGE_BAD_PARAMETER; + } + + auto buffer = image->imgNative->GetBuffer(); + if (buffer != nullptr) { + *nativeBuffer = buffer->SurfaceBufferToNativeBuffer(); + } + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative* image, uint32_t componentType, size_t* size) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == size) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, size=0x%{public}p", image, size); + return IMAGE_BAD_PARAMETER; + } + + auto component = image->imgNative->GetComponent(componentType); + if (nullptr == component) { + return IMAGE_BAD_PARAMETER; + } + + *size = component->size; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative* image, uint32_t componentType, int32_t* rowStride) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == rowStride) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, rowStride=0x%{public}p", image, rowStride); + return IMAGE_BAD_PARAMETER; + } + + auto component = image->imgNative->GetComponent(componentType); + if (nullptr == component) { + return IMAGE_BAD_PARAMETER; + } + + *rowStride = component->rowStride; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative* image, uint32_t componentType, int32_t* pixelStride) +{ + if (nullptr == image || nullptr == image->imgNative || nullptr == pixelStride) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p, pixelStride=0x%{public}p", image, pixelStride); + return IMAGE_BAD_PARAMETER; + } + + auto component = image->imgNative->GetComponent(componentType); + if (nullptr == component) { + return IMAGE_BAD_PARAMETER; + } + + *pixelStride = component->pixelStride; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageNative_Release(OH_ImageNative* image) +{ + if (nullptr == image) { + IMAGE_LOGE("Invalid parameter: image=0x%{public}p", image); + return IMAGE_BAD_PARAMETER; + } + if (nullptr != image->imgNative) { + delete image->imgNative; + } + IMAGE_LOGI("OH_ImageNative 0x%{public}p has been deleted.", image); + delete image; + return IMAGE_SUCCESS; +} + +#ifdef __cplusplus +}; +#endif diff --git a/frameworks/kits/native/common/ndk/image_receiver_native.cpp b/frameworks/kits/native/common/ndk/image_receiver_native.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ff8f94724e895467e84c180dfac2fefdb4a95a0 --- /dev/null +++ b/frameworks/kits/native/common/ndk/image_receiver_native.cpp @@ -0,0 +1,360 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "common_utils.h" +#include "image_log.h" +#include "image_receiver_native.h" +#include "image_kits.h" +#include "image_receiver.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct OH_ImageReceiverNative { + std::shared_ptr ptrImgRcv; +}; + +struct OH_ImageReceiverOptions { + /* Default width of the image received by the consumer, in pixels. */ + int32_t width = 0; + /* Default height of the image received by the consumer, in pixels. */ + int32_t height = 0; + /* Image format {@link OHOS_IMAGE_FORMAT_JPEG} created by using the receiver. */ + int32_t format = 0; + /* Maximum number of images that can be cached. */ + int32_t capacity = 0; +}; + +namespace OHOS { +namespace Media { + class ImageReceiverListener : public SurfaceBufferAvaliableListener { + public: + explicit ImageReceiverListener(OH_ImageReceiverNative* receiver) : receiver_(receiver), callback_(nullptr) {} + + ~ImageReceiverListener() override + { + callback_ = nullptr; + } + + void OnSurfaceBufferAvaliable() __attribute__((no_sanitize("cfi"))) override + { + if (nullptr != callback_) { + callback_(receiver_); + } + } + + OH_ImageReceiverNative* receiver_; + OH_ImageReceiver_OnCallback callback_; + }; +} // namespace Media +} // namespace OHOS + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_Create(OH_ImageReceiverOptions** options) +{ + if (nullptr == options) { + IMAGE_LOGE("Invalid parameter: options=null."); + return IMAGE_BAD_PARAMETER; + } + auto rst = new OH_ImageReceiverOptions; + if (nullptr == rst) { + IMAGE_LOGE("OH_ImageReceiverOptions create failed."); + return IMAGE_ALLOC_FAILED; + } + *options = rst; + IMAGE_LOGI("OH_ImageReceiverOptions 0x%{public}p has been created.", rst); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_GetSize(OH_ImageReceiverOptions* options, Image_Size* size) +{ + if (nullptr == options) { + IMAGE_LOGE("Invalid parameter: options=null."); + return IMAGE_BAD_PARAMETER; + } + size->width = options->width; + size->height = options->height; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_SetSize(OH_ImageReceiverOptions* options, Image_Size size) +{ + if (nullptr == options) { + IMAGE_LOGE("Invalid parameter: options=null."); + return IMAGE_BAD_PARAMETER; + } + options->width = size.width; + options->height = size.height; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_GetCapacity(OH_ImageReceiverOptions* options, int32_t* capacity) +{ + if (nullptr == options) { + IMAGE_LOGE("Invalid parameter: options=null."); + return IMAGE_BAD_PARAMETER; + } + *capacity = options->capacity; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_SetCapacity(OH_ImageReceiverOptions* options, int32_t capacity) +{ + if (nullptr == options) { + IMAGE_LOGE("Invalid parameter: options=null."); + return IMAGE_BAD_PARAMETER; + } + options->capacity = capacity; + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverOptions_Release(OH_ImageReceiverOptions* options) +{ + if (nullptr != options) { + IMAGE_LOGI("OH_ImageReceiverOptions 0x%{public}p has been deleted.", options); + delete options; + } + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_Create(OH_ImageReceiverOptions* options, OH_ImageReceiverNative** receiver) +{ + if (nullptr == options || nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: options=0x%{public}p, receiver=0x%{public}p", options, receiver); + return IMAGE_BAD_PARAMETER; + } + + auto rst = new OH_ImageReceiverNative; + if (nullptr == rst) { + IMAGE_LOGE("OH_ImageReceiverNative create failed."); + return IMAGE_ALLOC_FAILED; + } + + rst->ptrImgRcv = OHOS::Media::ImageReceiver::CreateImageReceiver( + options->width, options->height, options->format, options->capacity); + if (!(rst->ptrImgRcv)) { + delete rst; + IMAGE_LOGE("OH_ImageReceiverNative data create failed."); + return IMAGE_UNKNOWN_ERROR; + } + + *receiver = rst; + IMAGE_LOGI("OH_ImageReceiverNative 0x%{public}p has been created.", rst); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_GetReceivingSurfaceId(OH_ImageReceiverNative* receiver, uint64_t* surfaceId) +{ + if (nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: receiver=null."); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv || nullptr == receiver->ptrImgRcv->iraContext_) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + std::string strKey = receiver->ptrImgRcv->iraContext_->GetReceiverKey(); + if (strKey.empty() || nullptr == strKey.c_str()) { + IMAGE_LOGE("Bad data: key string empty."); + return IMAGE_UNKNOWN_ERROR; + } + + *surfaceId = std::stoull(strKey); + if (*surfaceId <= 0) { + IMAGE_LOGE("Bad data: key string empty."); + return IMAGE_UNKNOWN_ERROR; + } + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_ReadLatestImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image) +{ + if (nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: receiver=null."); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + auto bufferProcessor = receiver->ptrImgRcv->GetBufferProcessor(); + if (nullptr == bufferProcessor) { + IMAGE_LOGE("Bad data: buffer processor empty."); + return IMAGE_UNKNOWN_ERROR; + } + + auto surfaceBuffer = receiver->ptrImgRcv->ReadLastImage(); + if (nullptr == surfaceBuffer) { + IMAGE_LOGE("Bad data: surfacebuffer empty."); + return IMAGE_UNKNOWN_ERROR; + } + + auto rst = new OH_ImageNative; + if (nullptr == rst) { + IMAGE_LOGE("OH_ImageNative create failed."); + return IMAGE_ALLOC_FAILED; + } + + rst->imgNative = new OHOS::Media::NativeImage(surfaceBuffer, bufferProcessor); + if (!(rst->imgNative)) { + delete rst; + IMAGE_LOGE("OH_ImageNative data create failed."); + return IMAGE_UNKNOWN_ERROR; + } + + *image = rst; + IMAGE_LOGI("OH_ImageNative 0x%{public}p has been created.", rst); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_ReadNextImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image) +{ + if (nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: receiver=null."); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + auto bufferProcessor = receiver->ptrImgRcv->GetBufferProcessor(); + if (nullptr == bufferProcessor) { + IMAGE_LOGE("Bad data: buffer processor empty."); + return IMAGE_UNKNOWN_ERROR; + } + + auto surfaceBuffer = receiver->ptrImgRcv->ReadNextImage(); + if (nullptr == surfaceBuffer) { + IMAGE_LOGE("Bad data: surfacebuffer empty."); + return IMAGE_UNKNOWN_ERROR; + } + + auto rst = new OH_ImageNative; + if (nullptr == rst) { + IMAGE_LOGE("OH_ImageNative create failed."); + return IMAGE_ALLOC_FAILED; + } + + rst->imgNative = new OHOS::Media::NativeImage(surfaceBuffer, bufferProcessor); + if (!(rst->imgNative)) { + delete rst; + IMAGE_LOGE("OH_ImageNative data create failed."); + return IMAGE_UNKNOWN_ERROR; + } + + *image = rst; + IMAGE_LOGI("OH_ImageNative 0x%{public}p has been created.", rst); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_On(OH_ImageReceiverNative* receiver, OH_ImageReceiver_OnCallback callback) +{ + if (nullptr == receiver || nullptr == callback) { + IMAGE_LOGE("Invalid parameter: receiver=0x%{public}p, callback=0x%{public}p", receiver, callback); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + auto listener = std::make_shared(receiver); + listener->callback_ = callback; + receiver->ptrImgRcv->RegisterBufferAvaliableListener(listener); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_Off(OH_ImageReceiverNative* receiver) +{ + if (nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: receiver=null."); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + receiver->ptrImgRcv->UnRegisterBufferAvaliableListener(); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_GetSize(OH_ImageReceiverNative* receiver, Image_Size* size) +{ + if (nullptr == receiver || nullptr == size) { + IMAGE_LOGE("Invalid parameter: receiver=0x%{public}p, size=0x%{public}p", receiver, size); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv || nullptr == receiver->ptrImgRcv->iraContext_) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + size->width = receiver->ptrImgRcv->iraContext_->GetWidth(); + size->height = receiver->ptrImgRcv->iraContext_->GetHeight(); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_GetCapacity(OH_ImageReceiverNative* receiver, int32_t* capacity) +{ + if (nullptr == receiver || nullptr == capacity) { + IMAGE_LOGE("Invalid parameter: receiver=0x%{public}p, capacity=0x%{public}p", receiver, capacity); + return IMAGE_BAD_PARAMETER; + } + if (nullptr == receiver->ptrImgRcv || nullptr == receiver->ptrImgRcv->iraContext_) { + IMAGE_LOGE("Bad parameter: receiver data empty."); + return IMAGE_BAD_PARAMETER; + } + + *capacity = receiver->ptrImgRcv->iraContext_->GetCapicity(); + return IMAGE_SUCCESS; +} + +MIDK_EXPORT +Image_ErrorCode OH_ImageReceiverNative_Release(OH_ImageReceiverNative* receiver) +{ + if (nullptr == receiver) { + IMAGE_LOGE("Invalid parameter: receiver=null."); + return IMAGE_BAD_PARAMETER; + } + receiver->ptrImgRcv.reset(); + IMAGE_LOGI("OH_ImageReceiverNative 0x%{public}p has been deleted.", receiver); + delete receiver; + return IMAGE_SUCCESS; +} + +#ifdef __cplusplus +}; +#endif \ No newline at end of file diff --git a/frameworks/kits/native/common/ndk/include/image_kits.h b/frameworks/kits/native/common/ndk/include/image_kits.h new file mode 100644 index 0000000000000000000000000000000000000000..ebce3bc7b6ba503e1f25a35f277d4344daa5126c --- /dev/null +++ b/frameworks/kits/native/common/ndk/include/image_kits.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FRAMEWORKS_KITS_NATIVE_COMMON_INCLUDE_IMAGE2_KITS_H +#define FRAMEWORKS_KITS_NATIVE_COMMON_INCLUDE_IMAGE2_KITS_H + +#include "native_image.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct OH_ImageNative { + OHOS::Media::NativeImage* imgNative = nullptr; +}; + +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // FRAMEWORKS_KITS_NATIVE_COMMON_INCLUDE_IMAGE2_KITS_H \ No newline at end of file diff --git a/interfaces/innerkits/include/native_image.h b/interfaces/innerkits/include/native_image.h index ec47c506b0d7519227898d90c37a2a9946d56c64..5a47a577c4afa854681a5c61e17e96f6636f3def 100644 --- a/interfaces/innerkits/include/native_image.h +++ b/interfaces/innerkits/include/native_image.h @@ -48,6 +48,10 @@ public: int32_t GetFormat(int32_t &format); int32_t GetTimestamp(int64_t ×tamp); NativeComponent* GetComponent(int32_t type); + std::map>& GetComponents() + { + return components_; + } int32_t CombineYUVComponents(); sptr GetBuffer() { diff --git a/interfaces/kits/native/include/image/image_common.h b/interfaces/kits/native/include/image/image_common.h new file mode 100644 index 0000000000000000000000000000000000000000..36f35754dc8f10a316b8300877065ef6e736e493 --- /dev/null +++ b/interfaces/kits/native/include/image/image_common.h @@ -0,0 +1,1266 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup image + * @{ + * + * @brief Provides APIs for access to the image interface. + * + * @since 12 + */ + +/** + * @file image_common.h + * + * @brief Declares the common enums and structs used by the image interface. + * @library libimage.so + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_COMMON_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_COMMON_H_ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the image size. + * + * @since 12 + */ +struct Image_Size { + /** Image width, in pixels. */ + uint32_t width; + /** Image height, in pixels. */ + uint32_t height; +}; + +/** + * @brief Declaration the image size. + * + * @since 12 + */ +typedef struct Image_Size Image_Size; + +/** + * @brief Defines the region of the image source to decode. + * + * @since 12 + */ +struct Image_Region { + /** X coordinate of the start point, in pixels. */ + uint32_t x; + /** Y coordinate of the start point, in pixels. */ + uint32_t y; + /** Width of the region, in pixels. */ + uint32_t width; + /** Height of the region, in pixels. */ + uint32_t height; +}; + +/** + * @brief Declaration the image region. + * + * @since 12 + */ +typedef struct Image_Region Image_Region; + +/** + * @brief Defines the region of the image source to decode. + * + * @since 12 + */ +struct Image_String { + /** data for string type */ + char *data = nullptr; + /** data lenth for string type */ + size_t size = 0; +}; + +/** + * @brief Defines the property string (in key-value format) of the image source. + * + * @since 12 + */ +typedef struct Image_String Image_String; + +/** + * @brief Defines the image encode format. + * + * @since 12 + */ +typedef struct Image_String Image_MimeType; + +/** + * @brief Enumerates the return values that may be used by the interface. + * + * @since 12 + */ +typedef enum { + /** operation success */ + IMAGE_SUCCESS = 0, + /** invalid parameter */ + IMAGE_BAD_PARAMETER = 401, + /** unsupported mime type */ + IMAGE_UNSUPPORTED_MIME_TYPE = 7600101, + /** unknown mime type */ + IMAGE_UNKNOWN_MIME_TYPE = 7600102, + /** too large data or image */ + IMAGE_TOO_LARGE = 7600103, + /** unsupported operations */ + IMAGE_UNSUPPORTED_OPERATION = 7600201, + /** unsupported metadata */ + IMAGE_UNSUPPORTED_METADATA = 7600202, + /** unsupported conversion */ + IMAGE_UNSUPPORTED_CONVERSION = 7600203, + /** invalid region */ + IMAGE_INVALID_REGION = 7600204, + /** failed to allocate memory */ + IMAGE_ALLOC_FAILED = 7600301, + /** memory copy failed */ + IMAGE_COPY_FAILED = 7600302, + /** unknown error */ + IMAGE_UNKNOWN_ERROR = 7600901, + /** decode data source exception */ + IMAGE_BAD_SOURCE = 7700101, + /** decode failed */ + IMAGE_DECODE_FAILED = 7700301, + /** encode failed */ + IMAGE_ENCODE_FAILED = 7800301, +} Image_ErrorCode; + +/** + * @brief Defines the bmp mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_BMP = "image/bmp"; + +/** + * @brief Defines the jpeg mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_JPEG = "image/jpeg"; + +/** + * @brief Defines the heic mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_HEIC = "image/heic"; + +/** + * @brief Defines the png mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_PNG = "image/png"; + +/** + * @brief Defines the webp mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_WEBP = "image/webp"; + +/** + * @brief Defines the gif mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_GIF = "image/gif"; + +/** + * @brief Defines the x-icon mime type. + * + * @since 12 + */ +static const char* MIME_TYPE_ICON = "image/x-icon"; + +/** + * @brief Defines a pointer to bits per sample, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_BITS_PER_SAMPLE = "BitsPerSample"; + +/** + * @brief Defines a pointer to the orientation, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ORIENTATION = "Orientation"; + +/** + * @brief Defines a pointer to the image length, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_IMAGE_LENGTH = "ImageLength"; + +/** + * @brief Defines a pointer to the image width, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_IMAGE_WIDTH = "ImageWidth"; + +/** + * @brief Defines a pointer to the GPS latitude, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_LATITUDE = "GPSLatitude"; + +/** + * @brief Defines a pointer to the GPS longitude, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_LONGITUDE = "GPSLongitude"; + +/** + * @brief Defines a pointer to the GPS latitude reference information, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_LATITUDE_REF = "GPSLatitudeRef"; + +/** + * @brief Defines a pointer to the GPS longitude reference information, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_LONGITUDE_REF = "GPSLongitudeRef"; + +/** + * @brief Defines a pointer to the created date and time, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DATE_TIME_ORIGINAL = "DateTimeOriginal"; + +/** + * @brief Defines a pointer to the exposure time, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_EXPOSURE_TIME = "ExposureTime"; + +/** + * @brief Defines a pointer to the scene type, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SCENE_TYPE = "SceneType"; + +/** + * @brief Defines a pointer to the ISO speed ratings, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ISO_SPEED_RATINGS = "ISOSpeedRatings"; + +/** + * @brief Defines a pointer to the f-number of the image, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_F_NUMBER = "FNumber"; + +/** + * @brief Defines a pointer to the compressed bits per pixel, one of the image properties. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel"; + +/** + * @brief The scheme used for image compression. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COMPRESSION = "Compression"; + +/** + * @brief Pixel composition, such as RGB or YCbCr. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation"; + +/** + * @brief For each strip, the byte offset of that strip. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_STRIP_OFFSETS = "StripOffsets"; + +/** + * @brief The number of components per pixel. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SAMPLES_PER_PIXEL = "SamplesPerPixel"; + +/** + * @brief The number of rows per strip of image data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ROWS_PER_STRIP = "RowsPerStrip"; + +/** + * @brief The total number of bytes in each strip of image data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_STRIP_BYTE_COUNTS = "StripByteCounts"; + +/** + * @brief The image resolution in the width direction. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_X_RESOLUTION = "XResolution"; + +/** + * @brief The image resolution in the height direction. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_Y_RESOLUTION = "YResolution"; + +/** + * @brief Indicates whether pixel components are recorded in a chunky or planar format. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_PLANAR_CONFIGURATION = "PlanarConfiguration"; + +/** + * @brief The unit used to measure XResolution and YResolution. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_RESOLUTION_UNIT = "ResolutionUnit"; + +/** + * @brief The transfer function for the image, typically used for color correction. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_TRANSFER_FUNCTION = "TransferFunction"; + +/** + * @brief The name and version of the software used to generate the image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SOFTWARE = "Software"; + +/** + * @brief The name of the person who created the image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ARTIST = "Artist"; + +/** + * @brief The chromaticity of the white point of the image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_WHITE_POINT = "WhitePoint"; + +/** + * @brief The chromaticity of the primary colors of the image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_PRIMARY_CHROMATICITIES = "PrimaryChromaticities"; + +/** + * @brief The matrix coefficients for transformation from RGB to YCbCr image data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_YCBCR_COEFFICIENTS = "YCbCrCoefficients"; + +/** + * @brief The sampling ratio of chrominance components to the luminance component. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_YCBCR_SUB_SAMPLING = "YCbCrSubSampling"; + +/** + * @brief The position of chrominance components in relation to the luminance component. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_YCBCR_POSITIONING = "YCbCrPositioning"; + +/** + * @brief The reference black point value and reference white point value. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite"; + +/** + * @brief Copyright information for the image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COPYRIGHT = "Copyright"; + +/** + * @brief The offset to the start byte (SOI) of JPEG compressed thumbnail data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat"; + +/** + * @brief The number of bytes of JPEG compressed thumbnail data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength"; + +/** + * @brief The class of the program used by the camera to set exposure when the picture is taken. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_EXPOSURE_PROGRAM = "ExposureProgram"; + +/** + * @brief Indicates the spectral sensitivity of each channel of the camera used. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SPECTRAL_SENSITIVITY = "SpectralSensitivity"; + +/** + * @brief Indicates the Opto-Electric Conversion Function (OECF) specified in ISO 14524. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_OECF = "OECF"; + +/** + * @brief The version of the Exif standard supported. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_EXIF_VERSION = "ExifVersion"; + +/** + * @brief The date and time when the image was stored as digital data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DATE_TIME_DIGITIZED = "DateTimeDigitized"; + +/** + * @brief Information specific to compressed data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COMPONENTS_CONFIGURATION = "ComponentsConfiguration"; + +/** + * @brief The shutter speed, expressed as an APEX (Additive System of Photographic Exposure) value. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SHUTTER_SPEED_VALUE = "ShutterSpeedValue"; + +/** + * @brief The brightness value of the image, in APEX units. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_BRIGHTNESS_VALUE = "BrightnessValue"; + +/** + * @brief The smallest F number of lens. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_MAX_APERTURE_VALUE = "MaxApertureValue"; + +/** + * @brief The distance to the subject, measured in meters. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBJECT_DISTANCE = "SubjectDistance"; + +/** + * @brief This tag indicate the location and area of the main subject in the overall scene. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBJECT_AREA = "SubjectArea"; + +/** + * @brief A tag for manufacturers of Exif/DCF writers to record any desired infomation. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_MAKER_NOTE = "MakerNote"; + +/** + * @brief A tag for record fractions of seconds for the DateTime tag. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBSEC_TIME = "SubsecTime"; + +/** + * @brief A tag used to record fractions of seconds for the DateTimeOriginal tag. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBSEC_TIME_ORIGINAL = "SubsecTimeOriginal"; + +/** + * @brief A tag used to record fractions of seconds for the DateTimeDigitized tag. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBSEC_TIME_DIGITIZED = "SubsecTimeDigitized"; + +/** + * @brief This tag denotes the Flashpix format version supported by an FPXR file, enhancing device compatibility. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FLASHPIX_VERSION = "FlashpixVersion"; + +/** + * @brief The color space information tag, often recorded as the color space specifier. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COLOR_SPACE = "ColorSpace"; + +/** + * @brief The name of an audio file related to the image data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_RELATED_SOUND_FILE = "RelatedSoundFile"; + +/** + * @brief Strobe energy at image capture, in BCPS. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FLASH_ENERGY = "FlashEnergy"; + +/** + * @brief Camera or input device spatial frequency table. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse"; + +/** + * @brief Pixels per FocalPlaneResolutionUnit in the image width. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution"; + +/** + * @brief Pixels per FocalPlaneResolutionUnit in the image height. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution"; + +/** + * @brief Unit for measuring FocalPlaneXResolution and FocalPlaneYResolution. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit"; + +/** + * @brief Location of the main subject, relative to the left edge. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBJECT_LOCATION = "SubjectLocation"; + +/** + * @brief Selected exposure index at capture. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_EXPOSURE_INDEX = "ExposureIndex"; + +/** + * @brief Image sensor type on the camera. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SENSING_METHOD = "SensingMethod"; + +/** + * @brief Indicates the image source. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FILE_SOURCE = "FileSource"; + +/** + * @brief Color filter array (CFA) geometric pattern of the image sensor. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_CFA_PATTERN = "CFAPattern"; + +/** + * @brief Indicates special processing on image data. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_CUSTOM_RENDERED = "CustomRendered"; + +/** + * @brief Exposure mode set when the image was shot. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_EXPOSURE_MODE = "ExposureMode"; + +/** + * @brief Digital zoom ratio at the time of capture. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio"; + +/** + * @brief Type of scene captured. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SCENE_CAPTURE_TYPE = "SceneCaptureType"; + +/** + * @brief Degree of overall image gain adjustment. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GAIN_CONTROL = "GainControl"; + +/** + * @brief Direction of contrast processing applied by the camera. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_CONTRAST = "Contrast"; + +/** + * @brief Direction of saturation processing applied by the camera. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SATURATION = "Saturation"; + +/** + * @brief The direction of sharpness processing applied by the camera. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SHARPNESS = "Sharpness"; + +/** + * @brief Information on picture-taking conditions for a specific camera model. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription"; + +/** + * @brief Indicates the distance range to the subject. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange"; + +/** + * @brief An identifier uniquely assigned to each image. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_IMAGE_UNIQUE_ID = "ImageUniqueID"; + +/** + * @brief The version of the GPSInfoIFD. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_VERSION_ID = "GPSVersionID"; + +/** + * @brief Reference altitude used for GPS altitude. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_ALTITUDE_REF = "GPSAltitudeRef"; + +/** + * @brief The altitude based on the reference in GPSAltitudeRef. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_ALTITUDE = "GPSAltitude"; + +/** + * @brief The GPS satellites used for measurements. + * Used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_SATELLITES = "GPSSatellites"; + +/** + * @brief The status of the GPS receiver when the image is recorded. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_STATUS = "GPSStatus"; + +/** + * @brief The GPS measurement mode. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_MEASURE_MODE = "GPSMeasureMode"; + +/** + * @brief The GPS DOP (data degree of precision). + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DOP = "GPSDOP"; + +/** + * @brief The unit used to express the GPS receiver speed of movement. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_SPEED_REF = "GPSSpeedRef"; + +/** + * @brief The speed of GPS receiver movement. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_SPEED = "GPSSpeed"; + +/** + * @brief The reference for giving the direction of GPS receiver movement. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_TRACK_REF = "GPSTrackRef"; + +/** + * @brief The direction of GPS receiver movement. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_TRACK = "GPSTrack"; + +/** + * @brief The reference for the image's direction. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef"; + +/** + * @brief The direction of the image when captured. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_IMG_DIRECTION = "GPSImgDirection"; + +/** + * @brief Geodetic survey data used by the GPS receiver. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_MAP_DATUM = "GPSMapDatum"; + +/** + * @brief Indicates the latitude reference of the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef"; + +/** + * @brief The latitude of the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_LATITUDE = "GPSDestLatitude"; + +/** + * @brief Indicates the longitude reference of the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef"; + +/** + * @brief A character string recording the name of the method used for location finding. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_PROCESSING_METHOD = "GPSProcessingMethod"; + +/** + * @brief A character string recording the name of the GPS area. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_AREA_INFORMATION = "GPSAreaInformation"; + +/** + * @brief This field denotes if differential correction was applied to GPS data, crucial for precise location accuracy. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DIFFERENTIAL = "GPSDifferential"; + +/** + * @brief The serial number of the camera body. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_BODY_SERIAL_NUMBER = "BodySerialNumber"; + +/** + * @brief The name of the camera owner. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_CAMERA_OWNER_NAME = "CameraOwnerName"; + +/** + * @brief The name of the camera owner. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_COMPOSITE_IMAGE = "CompositeImage"; + +/** + * @brief The DNGVersion tag encodes the four-tier version number for DNG specification compliance. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DNG_VERSION = "DNGVersion"; + +/** + * @brief The longitude of the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_LONGITUDE = "GPSDestLongitude"; + +/** + * @brief The reference for the bearing to the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_BEARING_REF = "GPSDestBearingRef"; + +/** + * @brief The bearing to the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_BEARING = "GPSDestBearing"; + +/** + * @brief The measurement unit for the distance to the target point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef"; + +/** + * @brief The distance to the destination point. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_DEST_DISTANCE = "GPSDestDistance"; + +/** + * @brief DefaultCropSize specifies the final image size in raw coordinates, accounting for extra edge pixels. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_DEFAULT_CROP_SIZE = "DefaultCropSize"; + +/** + * @brief Indicates the value of coefficient gamma. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GAMMA = "Gamma"; + +/** + * @brief The tag indicate the ISO speed latitude yyy value of the camera or input device that is defined in ISO 12232. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ISO_SPEED_LATITUDEYYY = "ISOSpeedLatitudeyyy"; + +/** + * @brief The tag indicate the ISO speed latitude zzz value of the camera or input device that is defined in ISO 12232. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_ISO_SPEED_LATITUDEZZZ = "ISOSpeedLatitudezzz"; + +/** + * @brief The manufacturer of the lens. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_LENS_MAKE = "LensMake"; + +/** + * @brief The model name of the lens. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_LENS_MODEL = "LensModel"; + +/** + * @brief The serial number of the lens. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_LENS_SERIAL_NUMBER = "LensSerialNumber"; + +/** + * @brief Specifications of the lens used. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_LENS_SPECIFICATION = "LensSpecification"; + +/** + * @brief This tag provides a broad description of the data type in this subfile. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_NEW_SUBFILE_TYPE = "NewSubfileType"; + +/** + * @brief This tag records the UTC offset for the DateTime tag, ensuring accurate timestamps regardless of location. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_OFFSET_TIME = "OffsetTime"; + +/** + * @brief This tag logs the UTC offset when the image was digitized, aiding in accurate timestamp adjustment. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_OFFSET_TIME_DIGITIZED = "OffsetTimeDigitized"; + +/** + * @brief This tag records the UTC offset when the original image was created, crucial for time-sensitive applications. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_OFFSET_TIME_ORIGINAL = "OffsetTimeOriginal"; + +/** + * @brief Exposure times of source images for a composite image. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SOURCE_EXPOSURE_TIMES_OF_COMPOSITE_IMAGE = "SourceExposureTimesOfCompositeImage"; + +/** + * @brief The number of source images used for a composite image. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SOURCE_IMAGE_NUMBER_OF_COMPOSITE_IMAGE = "SourceImageNumberOfCompositeImage"; + +/** + * @brief This deprecated field signifies the type of data in this subfile. Use the NewSubfileType field instead. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SUBFILE_TYPE = "SubfileType"; + +/** + * @brief This tag indicates horizontal positioning errors in meters. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_GPS_H_POSITIONING_ERROR = "GPSHPositioningError"; + +/** + * @brief This tag indicates the sensitivity of the camera or input device when the image was shot. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_PHOTOGRAPHIC_SENSITIVITY = "PhotographicSensitivity"; + +/** + * @brief Burst Number + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_BURST_NUMBER = "HwMnoteBurstNumber"; + +/** + * @brief Face Conf + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_CONF = "HwMnoteFaceConf"; + +/** + * @brief Face Leye Center + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_LEYE_CENTER = "HwMnoteFaceLeyeCenter"; + +/** + * @brief Face Mouth Center + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_MOUTH_CENTER = "HwMnoteFaceMouthCenter"; + +/** + * @brief Face Pointer + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_POINTER = "HwMnoteFacePointer"; + +/** + * @brief Face Rect + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_RECT = "HwMnoteFaceRect"; + +/** + * @brief Face Reye Center + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_REYE_CENTER = "HwMnoteFaceReyeCenter"; + +/** + * @brief Face Smile Score + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_SMILE_SCORE = "HwMnoteFaceSmileScore"; + +/** + * @brief Face Version + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FACE_VERSION = "HwMnoteFaceVersion"; + +/** + * @brief Front Camera + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FRONT_CAMERA = "HwMnoteFrontCamera"; + +/** + * @brief Scene Pointer + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SCENE_POINTER = "HwMnoteScenePointer"; + +/** + * @brief Scene Version + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_SCENE_VERSION = "HwMnoteSceneVersion"; +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_IMAGE_COMMON_H_ \ No newline at end of file diff --git a/interfaces/kits/native/include/image/image_native.h b/interfaces/kits/native/include/image/image_native.h new file mode 100644 index 0000000000000000000000000000000000000000..5336d7b13a671d3bdbe2917e9b86d004383eef77 --- /dev/null +++ b/interfaces/kits/native/include/image/image_native.h @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup image + * @{ + * + * @brief Provides APIs for access to the image interface. + * + * @since 12 + */ + +/** + * @file image_native.h + * + * @brief Declares functions that access the image rectangle, size, format, and component data. + * + * @library libimage.so + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H + +#include "image_common.h" +#include "native_buffer.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines an OH_ImageNative object. + * + * @since 12 + */ +struct OH_ImageNative; + +/** + * @brief Defines the data type name of a native image. + * + * @since 12 + */ +typedef struct OH_ImageNative OH_ImageNative; + +/** + * @brief Obtains {@link Image_Size} of an {@link OH_ImageNative} object. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param size Indicates the pointer to the {@link Image_Size} object obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter. + * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size); + +/** + * @brief Get type arry from an {@link OH_ImageNative} object. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param types Indicates the pointer to an {@link OH_ImageNative} component arry obtained. + * @param typeSize Indicates the pointer to the {@link OH_ImageNative} component arry size obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image, + uint32_t **types, size_t *typeSize); + +/** + * @brief Get byte buffer from an {@link OH_ImageNative} object by the component type. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param componentType Indicates the type of component. + * @param nativeBuffer Indicates the pointer to the component buffer obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image, + uint32_t componentType, OH_NativeBuffer **nativeBuffer); + +/** + * @brief Get size of buffer from an {@link OH_ImageNative} object by the component type. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param componentType Indicates the type of component. + * @param size Indicates the pointer to the size of buffer obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image, + uint32_t componentType, size_t *size); + +/** + * @brief Get row stride from an {@link OH_ImageNative} object by the component type. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param componentType Indicates the type of component. + * @param rowStride Indicates the pointer to the row stride obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image, + uint32_t componentType, int32_t *rowStride); + +/** + * @brief Get pixel stride from an {@link OH_ImageNative} object by the component type. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @param componentType Indicates the type of component. + * @param pixelStride Indicates the pointer to the pixel stride obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image, + uint32_t componentType, int32_t *pixelStride); + +/** + * @brief Releases an {@link OH_ImageNative} object. + * It is used to release the object {@link OH_ImageNative}. + * + * @param image Indicates the pointer to an {@link OH_ImageNative} object. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image); + +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H diff --git a/interfaces/kits/native/include/image/image_receiver_native.h b/interfaces/kits/native/include/image/image_receiver_native.h new file mode 100644 index 0000000000000000000000000000000000000000..39d4f89a158b7910d95d472fb1f5255d384bb7b1 --- /dev/null +++ b/interfaces/kits/native/include/image/image_receiver_native.h @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup image + * @{ + * + * @brief Provides APIs for obtaining image data. + * + * @since 12 + */ + +/** + * @file image_receiver_native.h + * + * @brief Declares the APIs for obtaining image data. + * @library libimage_receiver.so + * @syscap SystemCapability.Multimedia.Image.ImageReceiver + * @since 12 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_NATIVE_H +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_NATIVE_H + +#include "image_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines an OH_ImageReceiverNative object. + * + * @since 12 + */ +struct OH_ImageReceiverNative; + +/** + * @brief Defines the data type name of a native image receiver. + * + * @since 12 + */ +typedef struct OH_ImageReceiverNative OH_ImageReceiverNative; + +/** + * @brief Defines an image receiver options object. + * + * @since 12 + */ +struct OH_ImageReceiverOptions; + +/** + * @brief Defines the data type name of a native image receiver info. + * + * @since 12 + */ +typedef struct OH_ImageReceiverOptions OH_ImageReceiverOptions; + +/** + * @brief Defines the callbacks for images. + * + * @since 12 + */ +typedef void (*OH_ImageReceiver_OnCallback)(OH_ImageReceiverNative *receiver); + +/** + * @brief Creates an OH_ImageReceiverOptions object at the application layer. + * + * @param options Indicates the pointer to the OH_ImageReceiverOptions object obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if alloc failed. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_Create(OH_ImageReceiverOptions **options); + +/** + * @brief Get size of an {@link OH_ImageReceiverOptions} object. + * + * @param options Indicates the pointer to an {@link OH_ImageReceiverOptions} object. + * @param size Indicates the value of the {@Link Image_Size} object will be obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_GetSize(OH_ImageReceiverOptions* options, Image_Size* size); + +/** + * @brief Set size of an {@link OH_ImageReceiverOptions} object. + * + * @param options Indicates the pointer to an {@link OH_ImageReceiverOptions} object. + * @param size Indicates the value of the {@link Image_Size} object will be seted. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_SetSize(OH_ImageReceiverOptions* options, Image_Size size); + +/** + * @brief Get capacity from an {@link OH_ImageReceiverOptions} object. + * + * @param options Indicates the pointer to an {@link OH_ImageReceiverOptions} object. + * @param capacity Indicates the pointer to capacity will be obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_GetCapacity(OH_ImageReceiverOptions* options, int32_t* capacity); + +/** + * @brief Set capacity of an {@link OH_ImageReceiverOptions} object. + * + * @param options Indicates the pointer to an {@link OH_ImageReceiverOptions} object. + * @param capacity Indicates the value of capacity will be seted. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_SetCapacity(OH_ImageReceiverOptions* options, int32_t capacity); + +/** + * @brief Releases an {@link OH_ImageReceiverOptions} object. + * It is used to release the object {@link OH_ImageReceiverOptions}. + * + * @param options Indicates the pointer to an {@link OH_ImageReceiverOptions} object. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverOptions + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverOptions_Release(OH_ImageReceiverOptions* options); + +/** + * @brief Creates an OH_ImageReceiverNative object at the application layer. + * + * @param options Indicates the options for setting the OH_ImageReceiverNative object. + * @param receiver Indicates the pointer to the OH_ImageReceiverNative object obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if alloc failed. + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_Create(OH_ImageReceiverOptions* options, OH_ImageReceiverNative** receiver); + +/** + * @brief Obtains the receiver ID through an {@link OH_ImageReceiverNative} object. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param surfaceId Indicates the pointer to the surfaceID will be obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error. + * @see OH_ImageReceiverNative + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_GetReceivingSurfaceId(OH_ImageReceiverNative* receiver, uint64_t* surfaceId); + +/** + * @brief Obtains the latest image through an {@link OH_ImageReceiverNative} object. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param image Indicates the pointer to an OH_ImageNative object at the application layer. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error. + * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if alloc failed. + * @see OH_ImageReceiverNative, OH_ImageNative + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_ReadLatestImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image); + +/** + * @brief Obtains the next image through an {@link OH_ImageReceiverNative} object. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param image Indicates the pointer to an OH_ImageNative object at the application layer. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error. + * returns {@link Image_ErrorCode} IMAGE_ALLOC_FAILED - if alloc failed. + * @see OH_ImageReceiverNative, OH_ImageNative + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_ReadNextImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image); + +/** + * @brief Registers an {@link OH_ImageReceiver_OnCallback} callback event. + * + * This callback event is triggered whenever a new image is received. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param callback Indicates the {@link OH_ImageReceiver_OnCallback} callback event to register. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverNative, OH_ImageReceiver_OnCallback + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_On(OH_ImageReceiverNative* receiver, OH_ImageReceiver_OnCallback callback); + +/** + * @brief Unregisters the {@link OH_ImageReceiver_OnCallback} callback event. + * + * Turn off the callback witch triggered by {@link OH_ImageReceiverNative_On}. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverNative, OH_ImageReceiverNative_On + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_Off(OH_ImageReceiverNative* receiver); + +/** + * @brief Obtains the size of the image receiver through an {@link OH_ImageReceiverNative} object. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param size Indicates the pointer to the {@link Image_Size} object will be obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverNative, Image_Size + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_GetSize(OH_ImageReceiverNative* receiver, Image_Size* size); + +/** + * @brief Obtains the capacity of the image receiver through an {@link OH_ImageReceiverNative} object. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @param capacity Indicates the pointer to the capacity will be obtained. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverNative + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_GetCapacity(OH_ImageReceiverNative* receiver, int32_t* capacity); + +/** + * @brief Releases an {@link OH_ImageReceiverNative} object. + * + * This API is not used to release an OH_ImageReceiverNative object at the application layer. + * + * @param receiver Indicates the pointer to an {@link OH_ImageReceiverNative} object. + * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful. + * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter. + * @see OH_ImageReceiverNative + * @since 12 + */ +Image_ErrorCode OH_ImageReceiverNative_Release(OH_ImageReceiverNative* receiver); + +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_NATIVE_H