diff --git a/LICENSE b/LICENSE index 4947287f7b5ccb5d1e8b7b2d3aa5d89f322c160d..4a459866a57c25462afad17f3fe0b50d440da080 100644 --- a/LICENSE +++ b/LICENSE @@ -1,177 +1,177 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/OAT.xml b/OAT.xml index 1725b56dec57579e9cff13c3f06110f14a0d1b05..c768660503ba92e3c60cfdd02b59a257157fddcf 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1,65 +1,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.en.md b/README.en.md index 4559b64dd9e98286c06e6e74a636117a0b45bfac..1898559507519e02817aae2e76494122f9cc5935 100644 --- a/README.en.md +++ b/README.en.md @@ -1,49 +1,49 @@ -Public Repository for API Declaration Files - -## Overview - -This repository is used to store .h declaration files of C APIs. The OpenHarmony C API is collection of system C interfaces that the operating system provided for applications using the C/C++ language library.It is the contract between the system and the applications; These interfaces need to be sufficiently stable. Interfaces are currently organized into various directories according to the function, and the directories organized as follows. - -## Directory Structure - - ─ai - | ├─neural_network_runtime - ├─arkui - | ├─ace_engine - ├─bundlemanager - | ├─bundle_framework - │ | ├─bundle - ├─commonlibrary - | ├─memory_utils - │ | ├─bundle - ├─distributeddatamgr - | ├─relational_store - ├─drivers - | ├─external_device_manager - ├─global - | ├─resource_management - ├─graphic - | ├─graphic_2d - ├─hiviewdfx - | ├─hiappevent - | ├─hilog - | ├─hitrace - ├─multimedia - | ├─audio_framework - | ├─av_codec - | ├─image_framework - | ├─player_framework - ├─resourceschedule - | ├─ffrt - ├─security - | ├─huks - ├─startup - | ├─init - ├─third_party - - -## Repositories Involved - -[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/) -[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): A guide that describes how to design and publish an interface. +Public Repository for API Declaration Files + +## Overview + +This repository is used to store .h declaration files of C APIs. The OpenHarmony C API is collection of system C interfaces that the operating system provided for applications using the C/C++ language library.It is the contract between the system and the applications; These interfaces need to be sufficiently stable. Interfaces are currently organized into various directories according to the function, and the directories organized as follows. + +## Directory Structure + + ─ai + | ├─neural_network_runtime + ├─arkui + | ├─ace_engine + ├─bundlemanager + | ├─bundle_framework + │ | ├─bundle + ├─commonlibrary + | ├─memory_utils + │ | ├─bundle + ├─distributeddatamgr + | ├─relational_store + ├─drivers + | ├─external_device_manager + ├─global + | ├─resource_management + ├─graphic + | ├─graphic_2d + ├─hiviewdfx + | ├─hiappevent + | ├─hilog + | ├─hitrace + ├─multimedia + | ├─audio_framework + | ├─av_codec + | ├─image_framework + | ├─player_framework + ├─resourceschedule + | ├─ffrt + ├─security + | ├─huks + ├─startup + | ├─init + ├─third_party + + +## Repositories Involved + +[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/) +[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): A guide that describes how to design and publish an interface. [C API构建指南](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/howto_add.md):A guide that describes how to add a build target for the C API in the build.gn \ No newline at end of file diff --git a/README.md b/README.md index 7939d274f6b0ff4ca15ddcb82129e4267eb95a19..ef0a7ff10def11916143bdf8a14fa3e21e1f7727 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,52 @@ -# API声明文件公共仓 - -## 简介 - -[C API](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/user_guide.md)公共仓,用来提交 C API 声明头文件。OpenHarmony C API接口是操作系统提供给应用使用C/C++语言生态库的系统C接口, -是系统与应用的C能力契约;这些接口需要保持足够的稳定性。C API接口当前按照功能组织放到各个领域目录下,具体目录如下。 - -## 目录 - -``` -|─ai -| ├─neural_network_runtime -├─arkui -| ├─ace_engine -├─bundlemanager -| ├─bundle_framework -│ | ├─bundle -├─commonlibrary -| ├─memory_utils -│ | ├─bundle -├─distributeddatamgr -| ├─relational_store -├─drivers -| ├─external_device_manager -├─global -| ├─resource_management -├─graphic -| ├─graphic_2d -├─hiviewdfx -| ├─hiappevent -| ├─hilog -| ├─hitrace -├─multimedia -| ├─audio_framework -| ├─av_codec -| ├─image_framework -| ├─player_framework -├─resourceschedule -| ├─ffrt -├─security -| ├─huks -├─startup -| ├─init -├─third_party - - -``` -## 相关仓 - -[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/) -[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): 描述了OpenHarmony C API的设计规范,指导开发者如何设计发布一个接口。 -[C API构建指南](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/howto_add.md):描述了如何在build.gn中添加C API的构建目标。 +# API声明文件公共仓 + +## 简介 + +[C API](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/user_guide.md)公共仓,用来提交 C API 声明头文件。OpenHarmony C API接口是操作系统提供给应用使用C/C++语言生态库的系统C接口, +是系统与应用的C能力契约;这些接口需要保持足够的稳定性。C API接口当前按照功能组织放到各个领域目录下,具体目录如下。 + +## 目录 + +``` +|─ai +| ├─neural_network_runtime +├─arkui +| ├─ace_engine +├─bundlemanager +| ├─bundle_framework +│ | ├─bundle +├─commonlibrary +| ├─memory_utils +│ | ├─bundle +├─distributeddatamgr +| ├─relational_store +├─drivers +| ├─external_device_manager +├─global +| ├─resource_management +├─graphic +| ├─graphic_2d +├─hiviewdfx +| ├─hiappevent +| ├─hilog +| ├─hitrace +├─multimedia +| ├─audio_framework +| ├─av_codec +| ├─image_framework +| ├─player_framework +├─resourceschedule +| ├─ffrt +├─security +| ├─huks +├─startup +| ├─init +├─third_party + + +``` +## 相关仓 + +[interface_sdk_c](https://gitee.com/openharmony-sig/interface_sdk_c/) +[C API编码规范](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/capi_naming.md): 描述了OpenHarmony C API的设计规范,指导开发者如何设计发布一个接口。 +[C API构建指南](https://gitee.com/openharmony-sig/interface_sdk_c/blob/master/docs/howto_add.md):描述了如何在build.gn中添加C API的构建目标。 diff --git a/ai/neural_network_runtime/BUILD.gn b/ai/neural_network_runtime/BUILD.gn index db9a140e4019dfb32452c3fc342692f682b24166..fc5c2e50bddd3cc07a7347999ae1adf1274e159e 100644 --- a/ai/neural_network_runtime/BUILD.gn +++ b/ai/neural_network_runtime/BUILD.gn @@ -1,34 +1,34 @@ -# Copyright (c) 2022 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") - -ohos_ndk_library("libneural_network_runtime_ndk") { - output_name = "neural_network_runtime.z" - output_extension = "so" - ndk_description_file = "libneural_network_runtime.ndk.json" - min_compact_version = "9" - system_capability = "SystemCapability.AI.NeuralNetworkRuntime" - system_capability_headers = [ - "neural_network_runtime.h", - "neural_network_runtime_type.h", - ] -} - -ohos_ndk_headers("libneural_network_runtime_header") { - dest_dir = "$ndk_headers_out_dir/neural_network_runtime" - sources = [ - "neural_network_runtime.h", - "neural_network_runtime_type.h", - ] +# Copyright (c) 2022 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") + +ohos_ndk_library("libneural_network_runtime_ndk") { + output_name = "neural_network_runtime.z" + output_extension = "so" + ndk_description_file = "libneural_network_runtime.ndk.json" + min_compact_version = "9" + system_capability = "SystemCapability.AI.NeuralNetworkRuntime" + system_capability_headers = [ + "neural_network_runtime.h", + "neural_network_runtime_type.h", + ] +} + +ohos_ndk_headers("libneural_network_runtime_header") { + dest_dir = "$ndk_headers_out_dir/neural_network_runtime" + sources = [ + "neural_network_runtime.h", + "neural_network_runtime_type.h", + ] } \ No newline at end of file diff --git a/ai/neural_network_runtime/libneural_network_runtime.ndk.json b/ai/neural_network_runtime/libneural_network_runtime.ndk.json index 0d58444cb13d1d058014fcf82380c03675ff81da..322a238db548a8289bb7fbe948883191370dc784 100644 --- a/ai/neural_network_runtime/libneural_network_runtime.ndk.json +++ b/ai/neural_network_runtime/libneural_network_runtime.ndk.json @@ -1,95 +1,95 @@ -[ - { - "name": "OH_NNModel_Construct" - }, - { - "name": "OH_NNModel_AddTensor" - }, - { - "name": "OH_NNModel_SetTensorData" - }, - { - "name": "OH_NNModel_AddOperation" - }, - { - "name": "OH_NNModel_SpecifyInputsAndOutputs" - }, - { - "name": "OH_NNModel_Finish" - }, - { - "name": "OH_NNModel_Destroy" - }, - { - "name": "OH_NNModel_GetAvailableOperations" - }, - { - "name": "OH_NNCompilation_Construct" - }, - { - "name": "OH_NNCompilation_SetDevice" - }, - { - "name": "OH_NNCompilation_SetCache" - }, - { - "name": "OH_NNCompilation_SetPerformanceMode" - }, - { - "name": "OH_NNCompilation_SetPriority" - }, - { - "name": "OH_NNCompilation_EnableFloat16" - }, - { - "name": "OH_NNCompilation_Build" - }, - { - "name": "OH_NNCompilation_Destroy" - }, - { - "name": "OH_NNExecutor_Construct" - }, - { - "name": "OH_NNExecutor_SetInput" - }, - { - "name": "OH_NNExecutor_SetOutput" - }, - { - "name": "OH_NNExecutor_GetOutputShape" - }, - { - "name": "OH_NNExecutor_Run" - }, - { - "name": "OH_NNExecutor_AllocateInputMemory" - }, - { - "name": "OH_NNExecutor_AllocateOutputMemory" - }, - { - "name": "OH_NNExecutor_DestroyInputMemory" - }, - { - "name": "OH_NNExecutor_DestroyOutputMemory" - }, - { - "name": "OH_NNExecutor_SetInputWithMemory" - }, - { - "name": "OH_NNExecutor_SetOutputWithMemory" - }, - { - "name": "OH_NNExecutor_Destroy" - }, - { - "name": "OH_NNDevice_GetAllDevicesID" - }, - { - "name": "OH_NNDevice_GetName" - }, - { - "name": "OH_NNDevice_GetType" - } +[ + { + "name": "OH_NNModel_Construct" + }, + { + "name": "OH_NNModel_AddTensor" + }, + { + "name": "OH_NNModel_SetTensorData" + }, + { + "name": "OH_NNModel_AddOperation" + }, + { + "name": "OH_NNModel_SpecifyInputsAndOutputs" + }, + { + "name": "OH_NNModel_Finish" + }, + { + "name": "OH_NNModel_Destroy" + }, + { + "name": "OH_NNModel_GetAvailableOperations" + }, + { + "name": "OH_NNCompilation_Construct" + }, + { + "name": "OH_NNCompilation_SetDevice" + }, + { + "name": "OH_NNCompilation_SetCache" + }, + { + "name": "OH_NNCompilation_SetPerformanceMode" + }, + { + "name": "OH_NNCompilation_SetPriority" + }, + { + "name": "OH_NNCompilation_EnableFloat16" + }, + { + "name": "OH_NNCompilation_Build" + }, + { + "name": "OH_NNCompilation_Destroy" + }, + { + "name": "OH_NNExecutor_Construct" + }, + { + "name": "OH_NNExecutor_SetInput" + }, + { + "name": "OH_NNExecutor_SetOutput" + }, + { + "name": "OH_NNExecutor_GetOutputShape" + }, + { + "name": "OH_NNExecutor_Run" + }, + { + "name": "OH_NNExecutor_AllocateInputMemory" + }, + { + "name": "OH_NNExecutor_AllocateOutputMemory" + }, + { + "name": "OH_NNExecutor_DestroyInputMemory" + }, + { + "name": "OH_NNExecutor_DestroyOutputMemory" + }, + { + "name": "OH_NNExecutor_SetInputWithMemory" + }, + { + "name": "OH_NNExecutor_SetOutputWithMemory" + }, + { + "name": "OH_NNExecutor_Destroy" + }, + { + "name": "OH_NNDevice_GetAllDevicesID" + }, + { + "name": "OH_NNDevice_GetName" + }, + { + "name": "OH_NNDevice_GetType" + } ] \ No newline at end of file diff --git a/ai/neural_network_runtime/neural_network_runtime.h b/ai/neural_network_runtime/neural_network_runtime.h index b5cc5e2fbe56aecd45b3f22abec414b80cd5bdd9..693b247817388814734afe50a91b1bcaff8849e7 100644 --- a/ai/neural_network_runtime/neural_network_runtime.h +++ b/ai/neural_network_runtime/neural_network_runtime.h @@ -1,690 +1,691 @@ -/* - * Copyright (c) 2022 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 NeuralNeworkRuntime - * @{ - * - * @brief Provides APIs of Neural Network Runtime for accelerating the model inference. - * - * @Syscap SystemCapability.Ai.NeuralNetworkRuntime - * @since 9 - * @version 1.0 - */ - -/** - * @file neural_network_runtime.h - * - * @brief Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime - * to construct and compile models and perform inference and computing on acceleration hardware. - * Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling. \n - * - * @since 9 - * @version 1.0 - */ - -#ifndef NEURAL_NETWORK_RUNTIME_H -#define NEURAL_NETWORK_RUNTIME_H - -#include "neural_network_runtime_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Creates a model instance of the {@link OH_NNModel} type and uses other APIs provided by OH_NNModel to construct the model instance. - * - * Before composition, call {@link OH_NNModel_Construct} to create a model instance. Based on the model topology, - * call the {@link OH_NNModel_AddTensor}, {@link OH_NNModel_AddOperation}, and {@link OH_NNModel_SetTensorData} methods - * to fill in the data and operator nodes of the model, and then call {@link OH_NNModel_SpecifyInputsAndOutputs} to specify the inputs and outputs of the model. - * After the model topology is constructed, call {@link OH_NNModel_Finish} to build the model. \n - * - * After a model instance is used, you need to destroy it by calling {@link OH_NNModel_Destroy} to avoid memory leak. \n - * - * @return Returns the pointer to a {@link OH_NNModel} instance. - * @since 9 - * @version 1.0 - */ -OH_NNModel *OH_NNModel_Construct(void); - -/** - * @brief Adds a tensor to a model instance. - * - * The data node and operator parameters in the Neural Network Runtime model are composed of tensors of the model. - * This method is used to add tensors to a model instance based on the tensor parameter. - * The sequence of adding tensors is specified by the index value recorded in the model. The {@link OH_NNModel_SetTensorData}, {@link OH_NNModel_AddOperation}, - * and {@link OH_NNModel_SpecifyInputsAndOutputs} methods specifies tensors based on the index value. \n - * - * Neural Network Runtime supports inputs and outputs of the dynamic shape. When adding a data node with a dynamic shape, - * you need to set the dimensions that support dynamic changes in tensor.dimensions to -1. - * For example, if tensor.dimensions of a four-dimensional tensor is set to [1, -1, 2, 2], the second dimension supports dynamic changes. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @param tensor Pointer to the {@link OH_NN_Tensor} tensor. The tensor specifies the attributes of the tensor added to the model instance. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_AddTensor(OH_NNModel *model, const OH_NN_Tensor *tensor); - -/** - * @brief Sets the tensor value. - * - * For tensors with constant values (such as model weights), you need to use this method in the composition phase. - * The index value of a tensor is determined by the sequence in which the tensor is added to the model. - * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @param index Index value of a tensor. - * @param dataBuffer Pointer to real data. - * @param length Length of the data buffer. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_SetTensorData(OH_NNModel *model, uint32_t index, const void *dataBuffer, size_t length); - -/** - * @brief Adds an operator to a model instance. - * - * This method is used to add an operator to a model instance. The operator type is specified by op, and - * the operator parameters, inputs, and outputs are specified by paramIndices, inputIndices, and outputIndices respectively. - * This method verifies the attributes of operator parameters and the number of input and output parameters. - * These attributes must be correctly set when {@link OH_NNModel_AddTensor} is called to add tensors. - * For details about the expected parameters, input attributes, and output attributes of each operator, see {@link OH_NN_OperationType}. \n - * - * paramIndices, inputIndices, and outputIndices store index values of tensors. - * Index values are determined by the sequence in which tensors are added to the model. - * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n - * - * If unnecessary parameters are added for adding an operator, this method returns {@link OH_NN_INVALID_PARAMETER}. - * If no operator parameter is set, the operator uses the default parameter value. - * For details about the default values, see {@link OH_NN_OperationType}. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @param op Specifies the type of an operator to be added. For details, see the enumerated values of {@link OH_NN_OperationType}. - * @param paramIndices Pointer to the OH_NN_UInt32Array instance, which is used to set operator parameters. - * @param inputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator input. - * @param outputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator output. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_AddOperation(OH_NNModel *model, - OH_NN_OperationType op, - const OH_NN_UInt32Array *paramIndices, - const OH_NN_UInt32Array *inputIndices, - const OH_NN_UInt32Array *outputIndices); - -/** - * @brief Specifies the inputs and outputs of a model. - * - * A tensor must be specified as the end-to-end inputs and outputs of a model instance. This type of tensor cannot be set - * using {@link OH_NNModel_SetTensorData}. The OH_NNExecutor method needs to be called in the execution phase to set the input and output data. \n - * - * The index value of a tensor is determined by the sequence in which the tensor is added to the model. - * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n - * - * Currently, the model inputs and outputs cannot be set asynchronously. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @param inputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator input. - * @param outputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator output. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_SpecifyInputsAndOutputs(OH_NNModel *model, - const OH_NN_UInt32Array *inputIndices, - const OH_NN_UInt32Array *outputIndices); - -/** - * @brief Completes model composition. - * - * After the model topology is set up, call this method to indicate that the composition is complete. After this method is called, - * additional composition operations cannot be performed. If {@link OH_NNModel_AddTensor}, {@link OH_NNModel_AddOperation}, - * {@link OH_NNModel_SetTensorData}, and {@link OH_NNModel_SpecifyInputsAndOutputs} are called, - * {@link OH_NN_OPERATION_FORBIDDEN} is returned. \n - * - * Before calling {@link OH_NNModel_GetAvailableOperations} and {@link OH_NNCompilation_Construct}, - * you must call this method to complete composition. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_Finish(OH_NNModel *model); - -/** - * @brief Releases a model instance. - * - * This method needs to be called to release the model instance created by calling {@link OH_NNModel_Construct}. Otherwise, memory leak will occur. \n - * - * If model or *model is a null pointer, this method only prints warning logs and does not execute the release logic. \n - * - * @param model Level-2 pointer to the {@link OH_NNModel} instance. After a model instance is destroyed, this method sets *model to a null pointer. - * @since 9 - * @version 1.0 - */ -void OH_NNModel_Destroy(OH_NNModel **model); - -/** - * @brief Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. - * - * Queries whether underlying device supports operators in a model instance. The device is specified by deviceID, - * and the result is represented by the array pointed by isSupported. If the ith operator is supported, - * the value of (*isSupported)[i] is true. Otherwise, the value is false. \n - * - * After this method is successfully executed, (*isSupported) points to the bool array that records the operator support status. - * The operator quantity for the array length is the same as that for the model instance. The memory corresponding to this array is - * managed by Neural Network Runtime and is automatically destroyed after the model instance is destroyed or this method is called again. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @param deviceID Device ID to be queried, which can be obtained by using {@link OH_NNDevice_GetAllDevicesID}. - * @param isSupported Pointer to the bool array. When this method is called, (*isSupported) must be a null pointer. - * Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. - * - * @param opCount Number of operators in a model instance, corresponding to the length of the (*isSupported) array. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNModel_GetAvailableOperations(OH_NNModel *model, - size_t deviceID, - const bool **isSupported, - uint32_t *opCount); - - -/** - * @brief Creates a compilation instance of the {@link OH_NNCompilation} type. - * - * After the OH_NNModel module completes model construction, APIs provided by the OH_NNCompilation module pass the model - * to underlying device for compilation. This method creates a {@link OH_NNCompilation} instance - * based on the passed {@link OH_NNModel} instance. The {@link OH_NNCompilation_SetDevice} method is called - * to set the device to compile on, and {@link OH_NNCompilation_Build} is then called to complete compilation.\n - * - * In addition to computing device selection, the OH_NNCompilation module supports features such as model caching, performance preference, - * priority setting, and float16 computing, which can be implemented by the following methods: - * - {@link OH_NNCompilation_SetCache} - * - {@link OH_NNCompilation_SetPerformanceMode} - * - {@link OH_NNCompilation_SetPriority} - * - {@link OH_NNCompilation_EnableFloat16} \n - * - * After {@link OH_NNCompilation} is created by calling this method, the {@link OH_NNModel} instance can be released. \n - * - * @param model Pointer to the {@link OH_NNModel} instance. - * @return Returns the pointer to a {@link OH_NNCompilation} instance. - * @since 9 - * @version 1.0 - */ -OH_NNCompilation *OH_NNCompilation_Construct(const OH_NNModel *model); - -/** - * @brief Specifies the device for model compilation and computing. - * - * In the compilation phase, you need to specify the device for model compilation and computing. Call {@link OH_NNDevice_GetAllDevicesID} - * to obtain available device IDs. Call {@link OH_NNDevice_GetType} and {@link OH_NNDevice_GetName} to obtain device information - * and pass target device IDs to this method for setting. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @param deviceID Device ID. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_SetDevice(OH_NNCompilation *compilation, size_t deviceID); - -/** - * @brief Set the cache directory and version of the compiled model. - * - * On the device that supports caching, a model can be saved as a cache file after being compiled at the device driver layer. - * The model can be directly read from the cache file in the next compilation, saving recompilation time. - * This method performs different operations based on the passed cache directory and version:\n - * - * - No file exists in the cache directory: - * Caches the compiled model to the directory and sets the cache version to version. \n - * - * - A complete cache file exists in the cache directory, and its version is version: - * Reads the cache file in the path and passes the data to the underlying device for conversion into executable model instances. \n - * - * - A complete cache file exists in the cache directory, and its version is earlier than version: - * When model compilation is complete on the underlying device, overwrites the cache file and changes the version number to version. \n - * - * - A complete cache file exists in the cache directory, and its version is later than version: - * Returns the {@link OH_NN_INVALID_PARAMETER} error code without reading the cache file. \n - * - * - The cache file in the cache directory is incomplete or you do not have the permission to access the cache file. - * Returns the {@link OH_NN_INVALID_FILE} error code. \n - * - * - The cache directory does not exist or you do not have the access permission. - * Returns the {@link OH_NN_INVALID_PATH} error code. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @param cachePath Directory for storing model cache files. This method creates directories for different devices in the cachePath directory. - * You are advised to use a separate cache directory for each model. - * @param version Cache version. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_SetCache(OH_NNCompilation *compilation, const char *cachePath, uint32_t version); - -/** - * @brief Sets the performance mode for model computing. - * - * Neural Network Runtime allows you to set the performance mode for model computing to meet the requirements of low power consumption - * and ultimate performance. If this method is not called to set the performance mode in the compilation phase, the compilation instance assigns - * the {@link OH_NN_PERFORMANCE_NONE} mode for the model by default. In this case, the device performs computing in the default performance mode. \n - * - * If this method is called on the device that does not support the setting of the performance mode, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @param performanceMode Performance mode. For details about the available performance modes, see {@link OH_NN_PerformanceMode}. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_SetPerformanceMode(OH_NNCompilation *compilation, - OH_NN_PerformanceMode performanceMode); - -/** - * @brief Sets the model computing priority. - * - * Neural Network Runtime allows you to set computing priorities for models. - * The priorities apply only to models created by the process with the same UID. - * The settings will not affect models created by processes with different UIDs on different devices. \n - * - * If this method is called on the device that does not support the priority setting, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @param priority Priority. For details about the optional priorities, see {@link OH_NN_Priority}. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_SetPriority(OH_NNCompilation *compilation, OH_NN_Priority priority); - -/** - * @brief Enables float16 for computing. - * - * Currently, Neural Network Runtime supports only float32 and int8. If this method is called on a device that supports float16, - * float16 will be used for computing the float32 model to reduce memory usage and execution time. \n - * - * If this method is called on the device that does not support float16, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @param enableFloat16 Indicates whether to enable float16. If this parameter is set to true, float16 inference is performed. - * If this parameter is set to false, float32 inference is performed. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, an error code is returned. - * For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_EnableFloat16(OH_NNCompilation *compilation, bool enableFloat16); - -/** - * @brief Compiles a model. - * - * After the compilation configuration is complete, call this method to return the compilation result. The compilation instance pushes the model and - * compilation options to the device for compilation. After this method is called, additional compilation operations cannot be performed. - * If the {@link OH_NNCompilation_SetDevice}, {@link OH_NNCompilation_SetCache}, {@link OH_NNCompilation_SetPerformanceMode}, - * {@link OH_NNCompilation_SetPriority}, and {@link OH_NNCompilation_EnableFloat16} methods are called, {@link OH_NN_OPERATION_FORBIDDEN} is returned. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNCompilation_Build(OH_NNCompilation *compilation); - -/** - * @brief Releases the Compilation object. - * - * This method needs to be called to release the compilation instance created by calling {@link OH_NNCompilation_Construct}. Otherwise, memory leak will occur. \n - * - * If compilation or *compilation is a null pointer, this method only prints warning logs and does not execute the release logic. \n - * - * @param compilation Level-2 pointer to the {@link OH_NNCompilation} instance. After a compilation instance is destroyed, - * this method sets *compilation to a null pointer. - * @since 9 - * @version 1.0 - */ -void OH_NNCompilation_Destroy(OH_NNCompilation **compilation); - - -/** - * @brief Creates an executor instance of the {@link OH_NNExecutor} type. - * - * This method constructs a model inference executor associated with the device based on the passed compiler. Use {@link OH_NNExecutor_SetInput} - * to set the model input data. After the input data is set, call {@link OH_NNExecutor_Run} to perform inference and then call - * {@link OH_NNExecutor_SetOutput} to obtain the computing result. \n - * - * After calling this method to create the {@link OH_NNExecutor} instance, you can release the {@link OH_NNCompilation} - * instance if you do not need to create any other executors. \n - * - * @param compilation Pointer to the {@link OH_NNCompilation} instance. - * @return Pointer to a {@link OH_NNExecutor} instance. - * @since 9 - * @version 1.0 - */ -OH_NNExecutor *OH_NNExecutor_Construct(OH_NNCompilation *compilation); - -/** - * @brief Sets the single input data for a model. - * - * This method copies the data whose length is specified by length (in bytes) in dataBuffer to the shared memory - * of the underlying device. inputIndex specifies the input to be set and tensor sets information such as the input shape, - * type, and quantization parameters. \n - * - * Neural Network Runtime supports models with dynamical shape input. For fixed shape input and dynamic shape input scenarios, - * this method uses different processing policies. - * - * - Fixed shape input: The attributes of tensor must be the same as those of the tensor added by calling - * {@link OH_NNModel_AddTensor} in the composition phase. - * - Dynamic shape input: In the composition phase, because the shape is not fixed, each value in tensor.dimensions must be greater than - * 0 in the method calls to determine the shape input in the calculation phase. When setting the shape, you can modify - * only the dimension whose value is -1. Assume that [-1, 224, 224, 3] is input as the the dimension of A in the composition phase. - * When this method is called, only the size of the first dimension can be modified, for example, to [3, 224, 224, 3]. - * If other dimensions are adjusted, {@link OH_NN_INVALID_PARAMETER} is returned. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * In input settings, the index value for the three inputs is {0, 1, 2}. \n - * - * @param tensor Sets the tensor corresponding to the input data. - * @param dataBuffer Pointer to the input data. - * @param length Length of the data buffer, in bytes. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_SetInput(OH_NNExecutor *executor, - uint32_t inputIndex, - const OH_NN_Tensor *tensor, - const void *dataBuffer, - size_t length); - -/** - * @brief Sets the buffer for a single output of a model. - * - * This method binds the buffer to which dataBuffer points to the output specified by outputIndex. - * The length of the buffer is specified by length. \n - * - * After {@link OH_NNExecutor_Run} is called to complete a single model inference, Neural Network Runtime compares - * the length of the buffer to which dataBuffer points with the length of the output data and returns different results - * based on the actual situation. \n - * - * - If the buffer length is greater than or equal to the data length, the inference result is copied to the buffer and - * {@link OH_NN_SUCCESS} is returned. You can read the inference result from dataBuffer. - * - If the buffer length is smaller than the data length, {@link OH_NNExecutor_Run} returns {@link OH_NN_INVALID_PARAMETER} - * and generates a log indicating that the buffer is too small. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} - * is called. In output buffer settings, the index value for the three outputs is {0, 1, 2}. - * @param dataBuffer Pointer to the output data. - * @param length Length of the data buffer, in bytes. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_SetOutput(OH_NNExecutor *executor, - uint32_t outputIndex, - void *dataBuffer, - size_t length); - -/** - * @brief Obtains the dimension information about the output tensor. - * - * After {@link OH_NNExecutor_Run} is called to complete a single inference, call this method to obtain the specified output dimension - * information and number of dimensions. It is commonly used in dynamic shape input and output scenarios. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * When {@link OH_NNExecutor_GetOutputShape} is called to obtain dimension information about the output tensor, - * outputIndices is {0, 1, 2}. - * - * @param shape Pointer to the int32_t array. The value of each element in the array is the length of the output tensor in each dimension. - * @param shapeLength Pointer to the uint32_t type. The number of output dimensions is returned. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_GetOutputShape(OH_NNExecutor *executor, - uint32_t outputIndex, - int32_t **shape, - uint32_t *shapeLength); - -/** - * @brief Performs inference. - * - * Performs end-to-end inference and computing of the model on the device associated with the executor. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_Run(OH_NNExecutor *executor); - -/** - * @brief Allocates shared memory to a single input on a device. - * - * Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and input index value, - * this method allocates shared memory whose size is specified by length on the device associated with a single input and returns the - * operation result through the {@link OH_NN_Memory} instance. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * In the memory input application, the index value for the three inputs is {0, 1, 2}. - * @param length Memory size to be applied for, in bytes. - * @return Pointer to a {@link OH_NN_Memory} instance. - * @since 9 - * @version 1.0 - */ -OH_NN_Memory *OH_NNExecutor_AllocateInputMemory(OH_NNExecutor *executor, uint32_t inputIndex, size_t length); - -/** - * @brief Allocates shared memory to a single output on a device. - * - * Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and - * output index value, this method allocates shared memory whose size is specified by length on the device associated with - * a single output and returns the operation result through the {@link OH_NN_Memory} instance. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * In output memory application, the index value for the three outputs is {0, 1, 2}. - * @param length Memory size to be applied for, in bytes. - * @return Pointer to a {@link OH_NN_Memory} instance. - * @since 9 - * @version 1.0 - */ -OH_NN_Memory *OH_NNExecutor_AllocateOutputMemory(OH_NNExecutor *executor, uint32_t outputIndex, size_t length); - -/** - * @brief Releases the input memory to which the {@link OH_NN_Memory} instance points. - * - * This method needs to be called to release the memory instance created by calling {@link OH_NNExecutor_AllocateInputMemory}. - * Otherwise, memory leak will occur. - * The mapping between inputIndex and memory must be the same as that in memory instance creation. \n - * - * If memory or *memory is a null pointer, this method only prints warning logs and does not execute the release logic. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * In memory input release, the index value for the three inputs is {0, 1, 2}. - * @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets *memory to a null pointer. - * @since 9 - * @version 1.0 - */ -void OH_NNExecutor_DestroyInputMemory(OH_NNExecutor *executor, uint32_t inputIndex, OH_NN_Memory **memory); - -/** - * @brief Releases the output memory to which the {@link OH_NN_Memory} instance points. - * - * This method needs to be called to release the memory instance created by calling {@link OH_NNExecutor_AllocateOutputMemory}. Otherwise, memory leak will occur. - * The mapping between outputIndex and memory must be the same as that in memory instance creation. \n - * - * If memory or *memory is a null pointer, this method only prints warning logs and does not execute the release logic. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * In output memory release, the index value for the three outputs is {0, 1, 2}. - * @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets *memory to a null pointer. - * @since 9 - * @version 1.0 - */ -void OH_NNExecutor_DestroyOutputMemory(OH_NNExecutor *executor, uint32_t outputIndex, OH_NN_Memory **memory); - -/** - * @brief Specifies the hardware shared memory pointed to by the {@link OH_NN_Memory} instance as the shared memory used by a single input. - * - * In scenarios where memory needs to be managed by yourself, this method binds the execution input to the {@link OH_NN_Memory} memory instance. - * During computing, the underlying device reads the input data from the shared memory pointed to by the memory instance. - * By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. \n - * - * @param executor Pointer to the {@link OH_NNExecutor} instance. - * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * When the input shared memory is specified, the index value for the three inputs is {0, 1, 2}. - * @param tensor Pointer to {@link OH_NN_Tensor}, used to set the tensor corresponding to a single input. - * @param memory Pointer to {@link OH_NN_Memory}. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_SetInputWithMemory(OH_NNExecutor *executor, - uint32_t inputIndex, - const OH_NN_Tensor *tensor, - const OH_NN_Memory *memory); - -/** - * @brief Specifies the hardware shared memory pointed to by the {@link OH_NN_Memory} instance as the shared memory used by a single output. - * - * In scenarios where memory needs to be managed by yourself, this method binds the execution output to the {@link OH_NN_Memory} memory instance. - * When computing is performed, the underlying hardware directly writes the computing result to the shared memory to which the memory instance points. - * By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. \n - * - * @param executor Executor. - * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. - * When output shared memory is specified, the index value for the three outputs is {0, 1, 2}. - * @param memory Pointer to {@link OH_NN_Memory}. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNExecutor_SetOutputWithMemory(OH_NNExecutor *executor, - uint32_t outputIndex, - const OH_NN_Memory *memory); - -/** - * @brief Destroys an executor instance to release the memory occupied by the executor. - * - * This method needs to be called to release the executor instance created by calling {@link OH_NNExecutor_Construct}. Otherwise, - * memory leak will occur. \n - * - * If executor or *executor is a null pointer, this method only prints warning logs and does not execute the release logic. \n - * - * @param executor Level-2 pointer to the {@link OH_NNExecutor} instance. - * @since 9 - * @version 1.0 - */ -void OH_NNExecutor_Destroy(OH_NNExecutor **executor); - - -/** - * @brief Obtains the ID of the device connected to Neural Network Runtime. - * - * Each device has a unique and fixed ID in Neural Network Runtime. This method returns device IDs on the current device through the uint32_t array. \n - * - * Device IDs are returned through the size_t array. Each element of the array is the ID of a single device. - * The array memory is managed by Neural Network Runtime. - * The data pointer is valid before this method is called next time. \n - * - * @param allDevicesID Pointer to the size_t array. The input *allDevicesID must be a null pointer. Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. - * @param deviceCount Pointer of the uint32_t type, which is used to return the length of (*allDevicesID). - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. - * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNDevice_GetAllDevicesID(const size_t **allDevicesID, uint32_t *deviceCount); - -/** - * @brief Obtains the name of the specified device. - * - * deviceID specifies the device whose name will be obtained. The device ID needs to be obtained by calling {@link OH_NNDevice_GetAllDevicesID}. \n - * - * @param deviceID Device ID. - * @param name Pointer to the char array. The passed (*char) must be a null pointer. Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. - * The value of (*name) is a C-style string ended with '\0'. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNDevice_GetName(size_t deviceID, const char **name); - -/** - * @brief Obtains the type information of the specified device. - * - * deviceID specifies the device whose type will be obtained. Currently, Neural Network Runtime supports the following device types: - * - OH_NN_CPU: CPU device. - * - OH_NN_GPU: GPU device. - * - OH_NN_ACCELERATOR: machine learning dedicated accelerator. - * - OH_NN_OTHERS: other hardware types. \n - * - * @param deviceID Device ID. - * @param deviceType Pointer to the {@link OH_NN_DeviceType} instance. The device type information is returned. - * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, - * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. - * @since 9 - * @version 1.0 - */ -OH_NN_ReturnCode OH_NNDevice_GetType(size_t deviceID, OH_NN_DeviceType *deviceType); - -#ifdef __cplusplus -} -#endif // __cplusplus - -/** @} */ -#endif // NEURAL_NETWORK_RUNTIME_H +/* + * Copyright (c) 2022 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 NeuralNeworkRuntime + * @{ + * + * @brief Provides APIs of Neural Network Runtime for accelerating the model inference. + * + * @Syscap SystemCapability.Ai.NeuralNetworkRuntime + * @since 9 + * @version 1.0 + */ + +/** + * @file neural_network_runtime.h + * + * @brief Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime + * to construct and compile models and perform inference and computing on acceleration hardware. + * Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling. \n + * + * @library libneural_network_runtime.so + * @since 9 + * @version 1.0 + */ + +#ifndef NEURAL_NETWORK_RUNTIME_H +#define NEURAL_NETWORK_RUNTIME_H + +#include "neural_network_runtime_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates a model instance of the {@link OH_NNModel} type and uses other APIs provided by OH_NNModel to construct the model instance. + * + * Before composition, call {@link OH_NNModel_Construct} to create a model instance. Based on the model topology, + * call the {@link OH_NNModel_AddTensor}, {@link OH_NNModel_AddOperation}, and {@link OH_NNModel_SetTensorData} methods + * to fill in the data and operator nodes of the model, and then call {@link OH_NNModel_SpecifyInputsAndOutputs} to specify the inputs and outputs of the model. + * After the model topology is constructed, call {@link OH_NNModel_Finish} to build the model. \n + * + * After a model instance is used, you need to destroy it by calling {@link OH_NNModel_Destroy} to avoid memory leak. \n + * + * @return Returns the pointer to a {@link OH_NNModel} instance. + * @since 9 + * @version 1.0 + */ +OH_NNModel *OH_NNModel_Construct(void); + +/** + * @brief Adds a tensor to a model instance. + * + * The data node and operator parameters in the Neural Network Runtime model are composed of tensors of the model. + * This method is used to add tensors to a model instance based on the tensor parameter. + * The sequence of adding tensors is specified by the index value recorded in the model. The {@link OH_NNModel_SetTensorData}, {@link OH_NNModel_AddOperation}, + * and {@link OH_NNModel_SpecifyInputsAndOutputs} methods specifies tensors based on the index value. \n + * + * Neural Network Runtime supports inputs and outputs of the dynamic shape. When adding a data node with a dynamic shape, + * you need to set the dimensions that support dynamic changes in tensor.dimensions to -1. + * For example, if tensor.dimensions of a four-dimensional tensor is set to [1, -1, 2, 2], the second dimension supports dynamic changes. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @param tensor Pointer to the {@link OH_NN_Tensor} tensor. The tensor specifies the attributes of the tensor added to the model instance. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_AddTensor(OH_NNModel *model, const OH_NN_Tensor *tensor); + +/** + * @brief Sets the tensor value. + * + * For tensors with constant values (such as model weights), you need to use this method in the composition phase. + * The index value of a tensor is determined by the sequence in which the tensor is added to the model. + * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @param index Index value of a tensor. + * @param dataBuffer Pointer to real data. + * @param length Length of the data buffer. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_SetTensorData(OH_NNModel *model, uint32_t index, const void *dataBuffer, size_t length); + +/** + * @brief Adds an operator to a model instance. + * + * This method is used to add an operator to a model instance. The operator type is specified by op, and + * the operator parameters, inputs, and outputs are specified by paramIndices, inputIndices, and outputIndices respectively. + * This method verifies the attributes of operator parameters and the number of input and output parameters. + * These attributes must be correctly set when {@link OH_NNModel_AddTensor} is called to add tensors. + * For details about the expected parameters, input attributes, and output attributes of each operator, see {@link OH_NN_OperationType}. \n + * + * paramIndices, inputIndices, and outputIndices store index values of tensors. + * Index values are determined by the sequence in which tensors are added to the model. + * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n + * + * If unnecessary parameters are added for adding an operator, this method returns {@link OH_NN_INVALID_PARAMETER}. + * If no operator parameter is set, the operator uses the default parameter value. + * For details about the default values, see {@link OH_NN_OperationType}. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @param op Specifies the type of an operator to be added. For details, see the enumerated values of {@link OH_NN_OperationType}. + * @param paramIndices Pointer to the OH_NN_UInt32Array instance, which is used to set operator parameters. + * @param inputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator input. + * @param outputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator output. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_AddOperation(OH_NNModel *model, + OH_NN_OperationType op, + const OH_NN_UInt32Array *paramIndices, + const OH_NN_UInt32Array *inputIndices, + const OH_NN_UInt32Array *outputIndices); + +/** + * @brief Specifies the inputs and outputs of a model. + * + * A tensor must be specified as the end-to-end inputs and outputs of a model instance. This type of tensor cannot be set + * using {@link OH_NNModel_SetTensorData}. The OH_NNExecutor method needs to be called in the execution phase to set the input and output data. \n + * + * The index value of a tensor is determined by the sequence in which the tensor is added to the model. + * For details about how to add a tensor, see {@link OH_NNModel_AddTensor}. \n + * + * Currently, the model inputs and outputs cannot be set asynchronously. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @param inputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator input. + * @param outputIndices Pointer to the OH_NN_UInt32Array instance, which is used to set the operator output. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_SpecifyInputsAndOutputs(OH_NNModel *model, + const OH_NN_UInt32Array *inputIndices, + const OH_NN_UInt32Array *outputIndices); + +/** + * @brief Completes model composition. + * + * After the model topology is set up, call this method to indicate that the composition is complete. After this method is called, + * additional composition operations cannot be performed. If {@link OH_NNModel_AddTensor}, {@link OH_NNModel_AddOperation}, + * {@link OH_NNModel_SetTensorData}, and {@link OH_NNModel_SpecifyInputsAndOutputs} are called, + * {@link OH_NN_OPERATION_FORBIDDEN} is returned. \n + * + * Before calling {@link OH_NNModel_GetAvailableOperations} and {@link OH_NNCompilation_Construct}, + * you must call this method to complete composition. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_Finish(OH_NNModel *model); + +/** + * @brief Releases a model instance. + * + * This method needs to be called to release the model instance created by calling {@link OH_NNModel_Construct}. Otherwise, memory leak will occur. \n + * + * If model or *model is a null pointer, this method only prints warning logs and does not execute the release logic. \n + * + * @param model Level-2 pointer to the {@link OH_NNModel} instance. After a model instance is destroyed, this method sets *model to a null pointer. + * @since 9 + * @version 1.0 + */ +void OH_NNModel_Destroy(OH_NNModel **model); + +/** + * @brief Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. + * + * Queries whether underlying device supports operators in a model instance. The device is specified by deviceID, + * and the result is represented by the array pointed by isSupported. If the ith operator is supported, + * the value of (*isSupported)[i] is true. Otherwise, the value is false. \n + * + * After this method is successfully executed, (*isSupported) points to the bool array that records the operator support status. + * The operator quantity for the array length is the same as that for the model instance. The memory corresponding to this array is + * managed by Neural Network Runtime and is automatically destroyed after the model instance is destroyed or this method is called again. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @param deviceID Device ID to be queried, which can be obtained by using {@link OH_NNDevice_GetAllDevicesID}. + * @param isSupported Pointer to the bool array. When this method is called, (*isSupported) must be a null pointer. + * Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. + * + * @param opCount Number of operators in a model instance, corresponding to the length of the (*isSupported) array. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNModel_GetAvailableOperations(OH_NNModel *model, + size_t deviceID, + const bool **isSupported, + uint32_t *opCount); + + +/** + * @brief Creates a compilation instance of the {@link OH_NNCompilation} type. + * + * After the OH_NNModel module completes model construction, APIs provided by the OH_NNCompilation module pass the model + * to underlying device for compilation. This method creates a {@link OH_NNCompilation} instance + * based on the passed {@link OH_NNModel} instance. The {@link OH_NNCompilation_SetDevice} method is called + * to set the device to compile on, and {@link OH_NNCompilation_Build} is then called to complete compilation.\n + * + * In addition to computing device selection, the OH_NNCompilation module supports features such as model caching, performance preference, + * priority setting, and float16 computing, which can be implemented by the following methods: + * - {@link OH_NNCompilation_SetCache} + * - {@link OH_NNCompilation_SetPerformanceMode} + * - {@link OH_NNCompilation_SetPriority} + * - {@link OH_NNCompilation_EnableFloat16} \n + * + * After {@link OH_NNCompilation} is created by calling this method, the {@link OH_NNModel} instance can be released. \n + * + * @param model Pointer to the {@link OH_NNModel} instance. + * @return Returns the pointer to a {@link OH_NNCompilation} instance. + * @since 9 + * @version 1.0 + */ +OH_NNCompilation *OH_NNCompilation_Construct(const OH_NNModel *model); + +/** + * @brief Specifies the device for model compilation and computing. + * + * In the compilation phase, you need to specify the device for model compilation and computing. Call {@link OH_NNDevice_GetAllDevicesID} + * to obtain available device IDs. Call {@link OH_NNDevice_GetType} and {@link OH_NNDevice_GetName} to obtain device information + * and pass target device IDs to this method for setting. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @param deviceID Device ID. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_SetDevice(OH_NNCompilation *compilation, size_t deviceID); + +/** + * @brief Set the cache directory and version of the compiled model. + * + * On the device that supports caching, a model can be saved as a cache file after being compiled at the device driver layer. + * The model can be directly read from the cache file in the next compilation, saving recompilation time. + * This method performs different operations based on the passed cache directory and version:\n + * + * - No file exists in the cache directory: + * Caches the compiled model to the directory and sets the cache version to version. \n + * + * - A complete cache file exists in the cache directory, and its version is version: + * Reads the cache file in the path and passes the data to the underlying device for conversion into executable model instances. \n + * + * - A complete cache file exists in the cache directory, and its version is earlier than version: + * When model compilation is complete on the underlying device, overwrites the cache file and changes the version number to version. \n + * + * - A complete cache file exists in the cache directory, and its version is later than version: + * Returns the {@link OH_NN_INVALID_PARAMETER} error code without reading the cache file. \n + * + * - The cache file in the cache directory is incomplete or you do not have the permission to access the cache file. + * Returns the {@link OH_NN_INVALID_FILE} error code. \n + * + * - The cache directory does not exist or you do not have the access permission. + * Returns the {@link OH_NN_INVALID_PATH} error code. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @param cachePath Directory for storing model cache files. This method creates directories for different devices in the cachePath directory. + * You are advised to use a separate cache directory for each model. + * @param version Cache version. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_SetCache(OH_NNCompilation *compilation, const char *cachePath, uint32_t version); + +/** + * @brief Sets the performance mode for model computing. + * + * Neural Network Runtime allows you to set the performance mode for model computing to meet the requirements of low power consumption + * and ultimate performance. If this method is not called to set the performance mode in the compilation phase, the compilation instance assigns + * the {@link OH_NN_PERFORMANCE_NONE} mode for the model by default. In this case, the device performs computing in the default performance mode. \n + * + * If this method is called on the device that does not support the setting of the performance mode, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @param performanceMode Performance mode. For details about the available performance modes, see {@link OH_NN_PerformanceMode}. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_SetPerformanceMode(OH_NNCompilation *compilation, + OH_NN_PerformanceMode performanceMode); + +/** + * @brief Sets the model computing priority. + * + * Neural Network Runtime allows you to set computing priorities for models. + * The priorities apply only to models created by the process with the same UID. + * The settings will not affect models created by processes with different UIDs on different devices. \n + * + * If this method is called on the device that does not support the priority setting, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @param priority Priority. For details about the optional priorities, see {@link OH_NN_Priority}. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_SetPriority(OH_NNCompilation *compilation, OH_NN_Priority priority); + +/** + * @brief Enables float16 for computing. + * + * Currently, Neural Network Runtime supports only float32 and int8. If this method is called on a device that supports float16, + * float16 will be used for computing the float32 model to reduce memory usage and execution time. \n + * + * If this method is called on the device that does not support float16, the {@link OH_NN_UNAVALIDABLE_DEVICE} error code is returned. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @param enableFloat16 Indicates whether to enable float16. If this parameter is set to true, float16 inference is performed. + * If this parameter is set to false, float32 inference is performed. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, an error code is returned. + * For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_EnableFloat16(OH_NNCompilation *compilation, bool enableFloat16); + +/** + * @brief Compiles a model. + * + * After the compilation configuration is complete, call this method to return the compilation result. The compilation instance pushes the model and + * compilation options to the device for compilation. After this method is called, additional compilation operations cannot be performed. + * If the {@link OH_NNCompilation_SetDevice}, {@link OH_NNCompilation_SetCache}, {@link OH_NNCompilation_SetPerformanceMode}, + * {@link OH_NNCompilation_SetPriority}, and {@link OH_NNCompilation_EnableFloat16} methods are called, {@link OH_NN_OPERATION_FORBIDDEN} is returned. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNCompilation_Build(OH_NNCompilation *compilation); + +/** + * @brief Releases the Compilation object. + * + * This method needs to be called to release the compilation instance created by calling {@link OH_NNCompilation_Construct}. Otherwise, memory leak will occur. \n + * + * If compilation or *compilation is a null pointer, this method only prints warning logs and does not execute the release logic. \n + * + * @param compilation Level-2 pointer to the {@link OH_NNCompilation} instance. After a compilation instance is destroyed, + * this method sets *compilation to a null pointer. + * @since 9 + * @version 1.0 + */ +void OH_NNCompilation_Destroy(OH_NNCompilation **compilation); + + +/** + * @brief Creates an executor instance of the {@link OH_NNExecutor} type. + * + * This method constructs a model inference executor associated with the device based on the passed compiler. Use {@link OH_NNExecutor_SetInput} + * to set the model input data. After the input data is set, call {@link OH_NNExecutor_Run} to perform inference and then call + * {@link OH_NNExecutor_SetOutput} to obtain the computing result. \n + * + * After calling this method to create the {@link OH_NNExecutor} instance, you can release the {@link OH_NNCompilation} + * instance if you do not need to create any other executors. \n + * + * @param compilation Pointer to the {@link OH_NNCompilation} instance. + * @return Pointer to a {@link OH_NNExecutor} instance. + * @since 9 + * @version 1.0 + */ +OH_NNExecutor *OH_NNExecutor_Construct(OH_NNCompilation *compilation); + +/** + * @brief Sets the single input data for a model. + * + * This method copies the data whose length is specified by length (in bytes) in dataBuffer to the shared memory + * of the underlying device. inputIndex specifies the input to be set and tensor sets information such as the input shape, + * type, and quantization parameters. \n + * + * Neural Network Runtime supports models with dynamical shape input. For fixed shape input and dynamic shape input scenarios, + * this method uses different processing policies. + * + * - Fixed shape input: The attributes of tensor must be the same as those of the tensor added by calling + * {@link OH_NNModel_AddTensor} in the composition phase. + * - Dynamic shape input: In the composition phase, because the shape is not fixed, each value in tensor.dimensions must be greater than + * 0 in the method calls to determine the shape input in the calculation phase. When setting the shape, you can modify + * only the dimension whose value is -1. Assume that [-1, 224, 224, 3] is input as the the dimension of A in the composition phase. + * When this method is called, only the size of the first dimension can be modified, for example, to [3, 224, 224, 3]. + * If other dimensions are adjusted, {@link OH_NN_INVALID_PARAMETER} is returned. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * In input settings, the index value for the three inputs is {0, 1, 2}. \n + * + * @param tensor Sets the tensor corresponding to the input data. + * @param dataBuffer Pointer to the input data. + * @param length Length of the data buffer, in bytes. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_SetInput(OH_NNExecutor *executor, + uint32_t inputIndex, + const OH_NN_Tensor *tensor, + const void *dataBuffer, + size_t length); + +/** + * @brief Sets the buffer for a single output of a model. + * + * This method binds the buffer to which dataBuffer points to the output specified by outputIndex. + * The length of the buffer is specified by length. \n + * + * After {@link OH_NNExecutor_Run} is called to complete a single model inference, Neural Network Runtime compares + * the length of the buffer to which dataBuffer points with the length of the output data and returns different results + * based on the actual situation. \n + * + * - If the buffer length is greater than or equal to the data length, the inference result is copied to the buffer and + * {@link OH_NN_SUCCESS} is returned. You can read the inference result from dataBuffer. + * - If the buffer length is smaller than the data length, {@link OH_NNExecutor_Run} returns {@link OH_NN_INVALID_PARAMETER} + * and generates a log indicating that the buffer is too small. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} + * is called. In output buffer settings, the index value for the three outputs is {0, 1, 2}. + * @param dataBuffer Pointer to the output data. + * @param length Length of the data buffer, in bytes. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_SetOutput(OH_NNExecutor *executor, + uint32_t outputIndex, + void *dataBuffer, + size_t length); + +/** + * @brief Obtains the dimension information about the output tensor. + * + * After {@link OH_NNExecutor_Run} is called to complete a single inference, call this method to obtain the specified output dimension + * information and number of dimensions. It is commonly used in dynamic shape input and output scenarios. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * When {@link OH_NNExecutor_GetOutputShape} is called to obtain dimension information about the output tensor, + * outputIndices is {0, 1, 2}. + * + * @param shape Pointer to the int32_t array. The value of each element in the array is the length of the output tensor in each dimension. + * @param shapeLength Pointer to the uint32_t type. The number of output dimensions is returned. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_GetOutputShape(OH_NNExecutor *executor, + uint32_t outputIndex, + int32_t **shape, + uint32_t *shapeLength); + +/** + * @brief Performs inference. + * + * Performs end-to-end inference and computing of the model on the device associated with the executor. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_Run(OH_NNExecutor *executor); + +/** + * @brief Allocates shared memory to a single input on a device. + * + * Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and input index value, + * this method allocates shared memory whose size is specified by length on the device associated with a single input and returns the + * operation result through the {@link OH_NN_Memory} instance. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * In the memory input application, the index value for the three inputs is {0, 1, 2}. + * @param length Memory size to be applied for, in bytes. + * @return Pointer to a {@link OH_NN_Memory} instance. + * @since 9 + * @version 1.0 + */ +OH_NN_Memory *OH_NNExecutor_AllocateInputMemory(OH_NNExecutor *executor, uint32_t inputIndex, size_t length); + +/** + * @brief Allocates shared memory to a single output on a device. + * + * Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and + * output index value, this method allocates shared memory whose size is specified by length on the device associated with + * a single output and returns the operation result through the {@link OH_NN_Memory} instance. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * In output memory application, the index value for the three outputs is {0, 1, 2}. + * @param length Memory size to be applied for, in bytes. + * @return Pointer to a {@link OH_NN_Memory} instance. + * @since 9 + * @version 1.0 + */ +OH_NN_Memory *OH_NNExecutor_AllocateOutputMemory(OH_NNExecutor *executor, uint32_t outputIndex, size_t length); + +/** + * @brief Releases the input memory to which the {@link OH_NN_Memory} instance points. + * + * This method needs to be called to release the memory instance created by calling {@link OH_NNExecutor_AllocateInputMemory}. + * Otherwise, memory leak will occur. + * The mapping between inputIndex and memory must be the same as that in memory instance creation. \n + * + * If memory or *memory is a null pointer, this method only prints warning logs and does not execute the release logic. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * In memory input release, the index value for the three inputs is {0, 1, 2}. + * @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets *memory to a null pointer. + * @since 9 + * @version 1.0 + */ +void OH_NNExecutor_DestroyInputMemory(OH_NNExecutor *executor, uint32_t inputIndex, OH_NN_Memory **memory); + +/** + * @brief Releases the output memory to which the {@link OH_NN_Memory} instance points. + * + * This method needs to be called to release the memory instance created by calling {@link OH_NNExecutor_AllocateOutputMemory}. Otherwise, memory leak will occur. + * The mapping between outputIndex and memory must be the same as that in memory instance creation. \n + * + * If memory or *memory is a null pointer, this method only prints warning logs and does not execute the release logic. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * In output memory release, the index value for the three outputs is {0, 1, 2}. + * @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets *memory to a null pointer. + * @since 9 + * @version 1.0 + */ +void OH_NNExecutor_DestroyOutputMemory(OH_NNExecutor *executor, uint32_t outputIndex, OH_NN_Memory **memory); + +/** + * @brief Specifies the hardware shared memory pointed to by the {@link OH_NN_Memory} instance as the shared memory used by a single input. + * + * In scenarios where memory needs to be managed by yourself, this method binds the execution input to the {@link OH_NN_Memory} memory instance. + * During computing, the underlying device reads the input data from the shared memory pointed to by the memory instance. + * By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. \n + * + * @param executor Pointer to the {@link OH_NNExecutor} instance. + * @param inputIndex Input index value, which is in the same sequence of the data input when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of inputIndices is {1, 5, 9} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * When the input shared memory is specified, the index value for the three inputs is {0, 1, 2}. + * @param tensor Pointer to {@link OH_NN_Tensor}, used to set the tensor corresponding to a single input. + * @param memory Pointer to {@link OH_NN_Memory}. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_SetInputWithMemory(OH_NNExecutor *executor, + uint32_t inputIndex, + const OH_NN_Tensor *tensor, + const OH_NN_Memory *memory); + +/** + * @brief Specifies the hardware shared memory pointed to by the {@link OH_NN_Memory} instance as the shared memory used by a single output. + * + * In scenarios where memory needs to be managed by yourself, this method binds the execution output to the {@link OH_NN_Memory} memory instance. + * When computing is performed, the underlying hardware directly writes the computing result to the shared memory to which the memory instance points. + * By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. \n + * + * @param executor Executor. + * @param outputIndex Output Index value, which is in the same sequence of the data output when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * Assume that the value of outputIndices is {4, 6, 8} when {@link OH_NNModel_SpecifyInputsAndOutputs} is called. + * When output shared memory is specified, the index value for the three outputs is {0, 1, 2}. + * @param memory Pointer to {@link OH_NN_Memory}. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNExecutor_SetOutputWithMemory(OH_NNExecutor *executor, + uint32_t outputIndex, + const OH_NN_Memory *memory); + +/** + * @brief Destroys an executor instance to release the memory occupied by the executor. + * + * This method needs to be called to release the executor instance created by calling {@link OH_NNExecutor_Construct}. Otherwise, + * memory leak will occur. \n + * + * If executor or *executor is a null pointer, this method only prints warning logs and does not execute the release logic. \n + * + * @param executor Level-2 pointer to the {@link OH_NNExecutor} instance. + * @since 9 + * @version 1.0 + */ +void OH_NNExecutor_Destroy(OH_NNExecutor **executor); + + +/** + * @brief Obtains the ID of the device connected to Neural Network Runtime. + * + * Each device has a unique and fixed ID in Neural Network Runtime. This method returns device IDs on the current device through the uint32_t array. \n + * + * Device IDs are returned through the size_t array. Each element of the array is the ID of a single device. + * The array memory is managed by Neural Network Runtime. + * The data pointer is valid before this method is called next time. \n + * + * @param allDevicesID Pointer to the size_t array. The input *allDevicesID must be a null pointer. Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. + * @param deviceCount Pointer of the uint32_t type, which is used to return the length of (*allDevicesID). + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. + * If the operation fails, an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNDevice_GetAllDevicesID(const size_t **allDevicesID, uint32_t *deviceCount); + +/** + * @brief Obtains the name of the specified device. + * + * deviceID specifies the device whose name will be obtained. The device ID needs to be obtained by calling {@link OH_NNDevice_GetAllDevicesID}. \n + * + * @param deviceID Device ID. + * @param name Pointer to the char array. The passed (*char) must be a null pointer. Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned. + * The value of (*name) is a C-style string ended with '\0'. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNDevice_GetName(size_t deviceID, const char **name); + +/** + * @brief Obtains the type information of the specified device. + * + * deviceID specifies the device whose type will be obtained. Currently, Neural Network Runtime supports the following device types: + * - OH_NN_CPU: CPU device. + * - OH_NN_GPU: GPU device. + * - OH_NN_ACCELERATOR: machine learning dedicated accelerator. + * - OH_NN_OTHERS: other hardware types. \n + * + * @param deviceID Device ID. + * @param deviceType Pointer to the {@link OH_NN_DeviceType} instance. The device type information is returned. + * @return Execution result of the function. If the operation is successful, OH_NN_SUCCESS is returned. If the operation fails, + * an error code is returned. For details about the error codes, see {@link OH_NN_ReturnCode}. + * @since 9 + * @version 1.0 + */ +OH_NN_ReturnCode OH_NNDevice_GetType(size_t deviceID, OH_NN_DeviceType *deviceType); + +#ifdef __cplusplus +} +#endif // __cplusplus + +/** @} */ +#endif // NEURAL_NETWORK_RUNTIME_H diff --git a/ai/neural_network_runtime/neural_network_runtime_type.h b/ai/neural_network_runtime/neural_network_runtime_type.h index 3bbbb4c528ffe81b10f8c8e73a8fd0c6980d2088..1b0701e147cfd35fd433ec77a3d5482e001937d1 100644 --- a/ai/neural_network_runtime/neural_network_runtime_type.h +++ b/ai/neural_network_runtime/neural_network_runtime_type.h @@ -1,1783 +1,1784 @@ -/* - * Copyright (c) 2022 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 NeuralNeworkRuntime - * @{ - * - * @brief Provides APIs for accelerating the Neural Network Runtime model inference. - * - * @Syscap SystemCapability.Ai.NeuralNetworkRuntime - * @since 9 - * @version 1.0 - */ - -/** - * @file neural_network_runtime_type.h - * - * @brief Defines the structure and enumeration for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ - -#ifndef NEURAL_NETWORK_RUNTIME_TYPE_H -#define NEURAL_NETWORK_RUNTIME_TYPE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines the handles of models for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NNModel OH_NNModel; - -/** - * @brief Defines the compiler handle for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NNCompilation OH_NNCompilation; - -/** - * @brief Defines the executor handle for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NNExecutor OH_NNExecutor; - -/** - * @brief Defines the hardware performance mode. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** No performance mode preference */ - OH_NN_PERFORMANCE_NONE = 0, - /** Low power consumption mode*/ - OH_NN_PERFORMANCE_LOW = 1, - /** Medium performance mode */ - OH_NN_PERFORMANCE_MEDIUM = 2, - /** High performance mode */ - OH_NN_PERFORMANCE_HIGH = 3, - /** Ultimate performance mode */ - OH_NN_PERFORMANCE_EXTREME = 4 -} OH_NN_PerformanceMode; - -/** - * @brief Defines the model inference task priority. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** No priority preference */ - OH_NN_PRIORITY_NONE = 0, - /** Low priority */ - OH_NN_PRIORITY_LOW = 1, - /** Medium priority */ - OH_NN_PRIORITY_MEDIUM = 2, - /** High priority */ - OH_NN_PRIORITY_HIGH = 3 -} OH_NN_Priority; - -/** - * @brief Defines error codes for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** The operation is successful. */ - OH_NN_SUCCESS = 0, - /** The operation failed. */ - OH_NN_FAILED = 1, - /** Invalid parameter. */ - OH_NN_INVALID_PARAMETER = 2, - /** Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure. */ - OH_NN_MEMORY_ERROR = 3, - /** Invalid operation. */ - OH_NN_OPERATION_FORBIDDEN = 4, - /** Null pointer exception */ - OH_NN_NULL_PTR = 5, - /** Invalid file. */ - OH_NN_INVALID_FILE = 6, - /** A hardware error occurs, for example, HDL service crash. */ - OH_NN_UNAVALIDABLE_DEVICE = 7, - /** Invalid path. */ - OH_NN_INVALID_PATH = 8 -} OH_NN_ReturnCode; - -/** - * @brief Defines activation function types in the fusion operator for Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef enum : int8_t { - /** The fusion activation function is not specified. */ - OH_NN_FUSED_NONE = 0, - /** Fusion relu activation function */ - OH_NN_FUSED_RELU = 1, - /** Fusion relu6 activation function */ - OH_NN_FUSED_RELU6 = 2 -} OH_NN_FuseType; - -/** - * @brief Defines the layout type of tensor data. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** The tensor does not have a specific layout type (such as scalar or vector). */ - OH_NN_FORMAT_NONE = 0, - /** The tensor arranges data in NCHW format.*/ - OH_NN_FORMAT_NCHW = 1, - /** The tensor arranges data in NHWC format.*/ - OH_NN_FORMAT_NHWC = 2 -} OH_NN_Format; - -/** - * @brief Defines device types supported by Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** Devices that are not CPU, GPU, or dedicated accelerator*/ - OH_NN_OTHERS = 0, - /** CPU device */ - OH_NN_CPU = 1, - /** GPU device */ - OH_NN_GPU = 2, - /** Dedicated hardware accelerator */ - OH_NN_ACCELERATOR = 3, -} OH_NN_DeviceType; - -/** - * @brief Defines tensor data types supported by Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** Unknown type */ - OH_NN_UNKNOWN = 0, - /** bool */ - OH_NN_BOOL = 1, - /** int8 */ - OH_NN_INT8 = 2, - /** int16 */ - OH_NN_INT16 = 3, - /** int32 */ - OH_NN_INT32 = 4, - /** int64 */ - OH_NN_INT64 = 5, - /** uint8 */ - OH_NN_UINT8 = 6, - /** uint16 */ - OH_NN_UINT16 = 7, - /** uint32 */ - OH_NN_UINT32 = 8, - /** uint64 */ - OH_NN_UINT64 = 9, - /** float16 */ - OH_NN_FLOAT16 = 10, - /** float32 */ - OH_NN_FLOAT32 = 11, - /** float64 */ - OH_NN_FLOAT64 = 12 -} OH_NN_DataType; - - -/** - * @brief Defines operator types supported by Neural Network Runtime. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** - * Returns the tensor of the sum of the elements corresponding to two input tensors. - * - * Inputs: - * - * * input1: first input tensor, of the Boolean or number type. - * * input2: second input tensor, whose data type must be the same as that of the first tensor. - * - * Parameters: - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: sum of input1 and input2. - * The data shape is the same as that of the input after broadcasting, - * and the data type is the same as that of the input with a higher precision. - */ - OH_NN_OPS_ADD = 1, - - /** - * Apply 2D average pooling to the input tensor, which now must be in NHWC format. The int8 quantization input is supported. - * - * If the input contains the padMode parameter: - * - * Inputs: - * - * * input: tensor. - * - * Parameters: - * - * * kernelSize indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. - * The first number indicates the kernel height, and the second number indicates the kernel width. - * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. - * The first number indicates the moving step in height, and the second number indicates the moving step in width. - * * padMode: padding mode, which is optional. The value is of the int type and can be 0 (same) or 1 (valid). - * The nearest neighbor value is used for padding. - * 0 (same): The height and width of the output are the same as those of the input. - * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. - * Otherwise, the last additional padding will be completed from the bottom and right. - * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. Excessive pixels will be discarded. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * If the input contains the padList parameter: - * - * Inputs: - * - * * input: tensor. - * - * Parameters: - * - * * kernelSize indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. - * The first number indicates the kernel height, and the second number indicates the kernel width. - * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. - * The first number indicates the moving step in height, and the second number indicates the moving step in width. - * * padList: padding around input. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: average pooling result of the input. - */ - OH_NN_OPS_AVG_POOL = 2, - - /** - * Batch normalization is performed on a tensor to scale and shift tensor elements, relieving potential covariate shift in a batch of data. - * - * Inputs: - * - * * input: n-dimensional tensor of shape [N, ..., C]. The nth dimension is the number of channels. - * * scale: 1D tensor of the scaling factor used to scale the first normalized tensor. - * * offset: 1D tensor used to move to the first normalized tensor. - * * mean: 1D tensor of the overall mean value. It is used only for inference. In case of training, this parameter must be left empty. - * * variance: 1D tensor used for the overall variance. It is used only for inference. In case of training, this parameter must be left empty. - * - * Parameters: - * - * * epsilon: fixed small additional value. - * - * Outputs: - * - * * output: n-dimensional output tensor whose shape and data type are the same as those of the input. - */ - OH_NN_OPS_BATCH_NORM = 3, - - /** - * Divides the batch dimension of a 4D tensor into small blocks by block_shape, and interleaves these blocks back into the spatial dimension. - * - * Parameters: - * - * * input: input tensor. The dimension will be divided into small blocks, and these blocks will be interleaved into the spatial dimension. - * - * Outputs: - * - * * blockSize: size of each block to be interleaved into the spatial dimension. The value is an array [height_block, width_block]. - * * crops: elements truncated from the spatial dimension of the output. The value is a 2D array [[crop0_start, crop0_end], - * [crop1_start, crop1_end]] with the shape of (2, 2). - * - * - * Outputs: - * - * * output. Assume that the shape of input is (n,h,w,c) and the shape of output is (n',h',w',c'): - * n' = n / (block_shape[0] * block_shape[1]) - * h' = h * block_shape[0] - crops[0][0] - crops[0][1] - * w' = w * block_shape[1] - crops[1][0] - crops[1][1] - * c'= c - */ - OH_NN_OPS_BATCH_TO_SPACE_ND = 4, - - /** - * Offsets the data in each dimension of the input tensor. - * - * Inputs: - * - * * input: input tensor, which can have two to five dimensions. - * * bias: offset of the number of input dimensions. - * - * Outputs: - * - * * output: sum of the input tensor and the bias in each dimension. - */ - OH_NN_OPS_BIAS_ADD = 5, - - /** - * Converts the data type in the input tensor. - * - * Inputs: - * - * * input: input tensor. - * * type: converted data type. - * - * Outputs: - * - * * output: converted tensor. - */ - OH_NN_OPS_CAST = 6, - - /** - * Connects tensors in a specified dimension. - * - * Inputs: - * - * * input: N input tensors. - * - * Parameters: - * - * * axis: dimension for connecting tensors. - * - * Outputs: - * - * * output: result of connecting N tensors along the axis. - */ - OH_NN_OPS_CONCAT = 7, - - /** - * 2D convolutional layer. - * - * If the input contains the padMode parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. - * The value of inChannel must be exactly divided by the value of group. - * - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * - * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). - * 0 (same): The height and width of the output are the same as those of the input. - * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. - * Otherwise, the last additional padding will be completed from the bottom and right. - * - * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. - * * group: number of groups in which the input is divided by in_channel. The value is of the int type. - * If group is 1, it is a conventional convolution. If group is greater than 1 and - * less than or equal to in_channel, it is a group convolution. - * * activationType is an integer constant which is contained in FuseType. The specified activation function is called before output. - * - * If the input contains the padList parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. - * The value of inChannel must be exactly divided by the value of group. - * - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * * padList: padding around input. It is an int array [top, bottom, left, right]. - * * group: number of groups in which the input is divided by in_channel. The value is of the int type. - * If group is 1, it is a conventional convolution. - * If group is in_channel, it is depthwiseConv2d. In this case, group==in_channel==out_channel. - * If group is greater than 1 and less than in_channel, it is a group convolution. In this case, out_channel==group. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: convolution computing result. - */ - OH_NN_OPS_CONV2D = 8, - - /** - * 2D convolution transposition. - * - * If the input contains the padMode parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. - * The value of inChannel must be exactly divided by the value of group. - * - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * - * Parameters: - * - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). - * 0 (same): The height and width of the output are the same as those of the input. - * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. - * Otherwise, the last additional padding will be completed from the bottom and right. - * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. - * * group: number of groups in which the input is divided by in_channel. The value is of the int type. - * If group is 1, it is a conventional convolution. If group is greater than 1 and - * less than or equal to in_channel, it is a group convolution. - * * outputPads: padding along the height and width of the output tensor. The value is an int or a tuple. - * It can be a single integer to specify the same value for all spatial dimensions. The amount of output - * padding along a dimension must be less than the stride along this dimension. - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * If the input contains the padList parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. - * The value of inChannel must be exactly divided by the value of group. - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * * padList: padding around input. It is an int array [top, bottom, left, right]. - * * group: number of groups in which the input is divided by in_channel. The value is of the int type. - * If group is 1, it is a conventional convolution. If group is greater than 1 - * and less than or equal to in_channel, it is a group convolution. - * * outputPads: padding along the height and width of the output tensor. The value is an int or a tuple. - * It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding - * along a dimension must be less than the stride along this dimension. - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: computing result after convolution and transposition. - */ - OH_NN_OPS_CONV2D_TRANSPOSE = 9, - - /** - * 2D depthwise separable convolution. - * - * If the input contains the padMode parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. - * outChannel is equal to channelMultiplier multiplied by inChannel. - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). - * 0 (same): The height and width of the output are the same as those of the input. - * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. - * Otherwise, the last additional padding will be completed from the bottom and right. - * - * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * If the input contains the padList parameter: - * - * Inputs: - * - * * input: input tensor. - * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. - * outChannel is equal to channelMultiplier multiplied by inChannel. - * * bias: bias of the convolution. It is an array with a length of [outChannel]. - * In quantization scenarios, the bias parameter does not require quantization parameters. - * The quantization version requires data input of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. - * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. - * The value must be greater than or equal to 1 and cannot exceed the height and width of input. - * * padList: padding around input. It is an int array [top, bottom, left, right]. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: convolution computing result. - */ - OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, - - /** - * Divides two input scalars or tensors. - * - * Inputs: - * - * * input1: first input, which is a number, a bool, or a tensor whose data type is number or Boolean. - * * input2: second input, which must meet the following requirements: - * If the first input is a tensor, the second input can be a real number, a Boolean value, or a tensor whose data type is real number or Boolean value. - * If the first input is a real number or Boolean value, the second input must be a tensor whose data type is real number or Boolean value. - * - * Parameters: - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: result of dividing input1 by input2. - */ - OH_NN_OPS_DIV = 11, - - /** - * Sets parameters to perform product (dot product), sum (addition and subtraction), or max (larger value) on the input. - * - * Inputs: - * - * * input1: first input tensor. - * * input2: second input tensor. - * - * Parameters: - * - * * mode: operation mode. The value is an enumerated value. - * - * Outputs: - * - * * output: computing result, which has the same data type and shape of output and input1. - */ - OH_NN_OPS_ELTWISE = 12, - - /** - * Adds an additional dimension to a tensor in the given dimension. - * - * Inputs: - * - * * input: input tensor. - * * axis: index of the dimension to be added. The value is of the int32_t type and must be a constant in the range [-dim-1, dim]. - * - * Outputs: - * - * * output: tensor after dimension expansion. - */ - OH_NN_OPS_EXPAND_DIMS = 13, - - /** - * Creates a tensor of the specified dimensions and fills it with a scalar. - * - * Inputs: - * - * * value: scalar used to fill the tensor. - * * shape: dimensions of the tensor to be created. - * - * Outputs: - * - * * output: generated tensor, which has the same data type as value. The tensor shape is specified by the shape parameter. - */ - OH_NN_OPS_FILL = 14, - - /** - * Full connection. The entire input is used as the feature map for feature extraction. - * - * Inputs: - * - * * input: full-connection input tensor. - * * weight: weight tensor for a full connection. - * * bias: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. - * If quantization is required, the data must be of the OH_NN_INT32 type. - * The actual quantization parameters are determined by input and weight. - * - * Parameters: - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: computed tensor. - * - * If the input contains the axis parameter: - * - * Inputs: - * - * * input: full-connection input tensor. - * * weight: weight tensor for a full connection. - * * bias: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. - * If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters - * are determined by input and weight. - * - * Parameters: - * - * * axis: axis in which the full connection is applied. The specified axis and its following axes are - * converted into a 1D tensor for applying the full connection. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: computed tensor. - */ - OH_NN_OPS_FULL_CONNECTION = 15, - - /** - * Returns the slice of the input tensor based on the specified index and axis. - * - * Inputs: - * - * * input: tensor to be sliced. - * * inputIndices: indices of the specified input on the axis. The value is an array of the int type - * and must be in the range [0,input.shape[axis]). - * * axis: axis on which input is sliced. The value is an array with one element of the int32_t type. - * - * Outputs: - * - * * output: sliced tensor. - */ - OH_NN_OPS_GATHER = 16, - - /** - * Calculate the Hswish activation value of the input. - * - * Inputs: - * - * * An n-dimensional input tensor. - * - * Outputs: - * - * * output: n-dimensional Hswish activation value. The data type is the same as that of shape and input. - */ - OH_NN_OPS_HSWISH = 17, - - /** - * For input1 and input2, calculate the result of input1[i]<=input2[i] for each pair of elements, - * where i is the index of each element in the input tensor. - * - * Inputs: - * - * * input1, which can be a real number, Boolean value, or tensor whose data type is real number or NN_BOOL. - * * input2, which can be a real number or a Boolean value if input1 is a tensor and must be a tensor - * with the data type of real number or NN_BOOL if input1 is not a tensor. - * - * Outputs: - * - * * A tensor of the data type NN_BOOL. When a quantization model is used, the quantization parameters of the output - * cannot be omitted. However, values of the quantization parameters do not affect the result. - */ - OH_NN_OPS_LESS_EQUAL = 18, - - /** - * Calculate the inner product of input1 and input2. - * - * Inputs: - * - * * input1: n-dimensional input tensor. - * * input2: n-dimensional input tensor. - * - * Parameters: - * - * * TransposeX: Boolean value indicating whether to transpose input1. - * * TransposeY: Boolean value indicating whether to transpose input2. - * - * Outputs: - * - * * output: inner product obtained after calculation. In case of type!=NN_UNKNOWN, the output data type is - * determined by type. In case of type==NN_UNKNOWN, the output data type depends on the data type - * converted during computing of inputX and inputY. - * - */ - OH_NN_OPS_MATMUL = 19, - - /** - * Calculates the maximum of input1 and input2 element-wise. The inputs of input1 and input2 - * comply with the implicit type conversion rules to make the data types consistent. * The inputs must be two tensors or one tensor and one scalar. - * When the inputs are two tensors, their data types cannot be both NN_BOOL. Their shapes can be broadcast to the same size. - * When the inputs are one tensor and one scalar, the scalar must be a constant. - * - * Inputs: - * - * * input1: n-dimensional input tensor of the real number or NN_BOOL type. - * * input2: n-dimensional input tensor of the real number or NN_BOOL type. - * - * Outputs: - * - * * output: n-dimensional output tensor. The shape and data type of - * output are the same as those of the two inputs with a higher precision. - */ - OH_NN_OPS_MAXIMUM = 20, - - /** - * Applies 2D maximum pooling to the input tensor. - * - * If the input contains the padMode parameter: - * - * Inputs: - * - * * input: tensor. - * - * Parameters: - * - * * kernelSize: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. - * The first number indicates the kernel height, and the second number indicates the kernel width. - * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. - * The first number indicates the moving step in height, and the second number indicates the moving step in width. - * * padMode: padding mode, which is optional. The value is of the int type and can be 0 (same) - * or 1 (valid). The nearest neighbor value is used for padding. - * 0 (same): The height and width of the output are the same as those of the input. - * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. - * Otherwise, the last additional padding will be completed from the bottom and right. - * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * If the input contains the padList parameter: - * - * Inputs: - * - * * input: tensor. - * - * Parameters: - * - * * kernelSize: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. - * The first number indicates the kernel height, and the second number indicates the kernel width. - * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. - * The first number indicates the moving step in height, and the second number indicates the moving step in width. - * * padList: padding around input. It is an int array [top, bottom, left, right], - * and the nearest neighbor values are used for padding. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: tensor obtained after maximum pooling is applied to the input. - */ - OH_NN_OPS_MAX_POOL = 21, - - /** - * Multiplies elements in the same positions of inputX and inputY to obtain the output. - * If inputX and inputY have different shapes, expand them to the same shape - * through broadcast and then perform multiplication. - * - * Inputs: - * - * * input1: n-dimensional tensor. - * * input2: n-dimensional tensor. - * - * Parameters: - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * Product of each element of input1 and input2. - */ - OH_NN_OPS_MUL = 22, - - /** - * Generates a one-hot tensor based on the positions specified by indices. The positions specified by indices - * are determined by on_value, and other positions are determined by off_value. - * - * Inputs: - * - * * indices: n-dimensional tensor. Each element in indices determines the position of - * on_value in each one-hot vector. - * * depth: integer scalar that determines the depth of the one-hot vector. The value of depth - * must be greater than 0. - * * on_value: scalar that specifies a valid value in the one-hot vector. - * * off_value: scalar that specifies the values of other posistions in the one-hot vector except the valid value. - * - * Parameters: - * - * * axis: integer scalar that specifies the dimension for inserting the one-hot. Assume that the shape - * of indices is [N, C], and the value of depth is D. - * When axis is 0, the shape of the output is [D, N, C]. - * When axis is -1, the shape of the output is [N, C, D]. - * When axis is 1, the shape of the output is [N, D, C]. - * - * Outputs: - * - * * output: (n+1)-dimensional tensor if indices is an n-dimensional tensor. - * The output shape is determined by indices and axis. - */ - OH_NN_OPS_ONE_HOT = 23, - - /** - * Pads inputX in the specified dimensions. - * - * Inputs: - * - * * inputX: n-dimensional tensor in [BatchSize, ...] format. - * * paddings: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. - * For example, paddings[i][0] indicates the number of paddings to be added preceding inputX in the ith dimension. - * paddings[i][1] indicates the number of paddings to be added following inputX in the ith dimension. - * - * Parameters: - * - * * padValues: value to be added to the pad operation. The value is a constant with the same data type as inputX. - * - * Outputs: - * - * * output: n-dimensional tensor after padding, with the same dimensions and data type as inputX. - * The shape is determined by inputX and paddings. - * output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1] - */ - OH_NN_OPS_PAD = 24, - - /** - * Calculates the y power of each element in input. The inputs must be two tensors or one tensor and one scalar. - * When the inputs are two tensors, their data types cannot be both NN_BOOL, and their shapes must be the same. - * When the inputs are one tensor and one scalar, the scalar must be a constant. - * - * Inputs: - * - * * input: real number, Boolean value, or tensor whose data type is real number or NN_BOOL. - * * y: real number, Boolean value, or tensor whose data type is real number or NN_BOOL. - * - * Outputs: - * - * * output: tensor, whose shape is determined by the shape of input and y after broadcasting. - */ - OH_NN_OPS_POW = 25, - - /** - * Scales a tensor. - * - * Inputs: - * - * * input: n-dimensional tensor. - * * scale: scaling tensor. - * * bias: bias tensor. - * - * Parameters: - * - * * axis: dimensions to be scaled. - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: scaled n-dimensional tensor, whose data type is the same as that of input and - * shape is determined by axis. - */ - OH_NN_OPS_SCALE = 26, - - /** - * Calculates the shape of the input tensor. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Outputs: - * - * * output: integer array representing the dimensions of the input tensor. - */ - OH_NN_OPS_SHAPE = 27, - - /** - * Applies the sigmoid operation to the input tensor. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Outputs: - * - * * output: result of the sigmoid operation. It is an n-dimensional tensor - * with the same data type and shape as input. - */ - OH_NN_OPS_SIGMOID = 28, - - /** - * Slices a tensor of the specified size from the input in each dimension. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * * begin: start of the slice, which is an array of integers greater than or equal to 0. - * * size: slice length, which is an array of integers greater than or equal to 0. - * Assume that a dimension is i and 1<=size[i]<=input.shape[i]-begin[i]. - * - * Outputs: - * - * * output: n-dimensional tensor obtained by slicing. - * The TensorType, shape, and size of the output are the same as those of the input. - */ - OH_NN_OPS_SLICE = 29, - - /** - * Applies the softmax operation to the input tensor. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * - * Parameters: - * - * * axis: dimension in which the softmax operation is performed. - * The value is of the int64 type. It is an integer in the range [-n, n). - * - * Outputs: - * - * * output: result of the softmax operation. It is an n-dimensional tensor with - * the same data type and shape as input. - */ - OH_NN_OPS_SOFTMAX = 30, - - /** - * Divides a 4D tensor into small blocks and combines these blocks in the original batch. - * The number of blocks is blockShape[0] multiplied by blockShape[1]. - * - * Inputs: - * - * * input: 4D tensor. - * - * Parameters: - * - * * blockShape: a pair of integers. Each of them is greater than or equal to 1. - * * paddings: a pair of arrays. Each of them consists of two integers. The four integers that form paddings - * must be greater than or equal to 0. paddings[0][0] and paddings[0][1] - * specify the number of paddings in the third dimension, and paddings[1][0] and paddings[1][1] - * specify the number of paddings in the fourth dimension. - * - * Outputs: - * - * * output: 4D tensor with the same data type as input. The shape is determined by input, - * blockShape, and paddings. Assume that the input shape is [n,c,h,w], then: - * output.shape[0] = n * blockShape[0] * blockShape[1] - * output.shape[1] = c - * output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] - * output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] - * (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]) is exactly divisible by - * (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]). - * - */ - OH_NN_OPS_SPACE_TO_BATCH_ND = 31, - - /** - * Splits the input into multiple tensors along the axis dimension. The number of tensors is specified by outputNum. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Parameters: - * - * * outputNum: number of output tensors. The data type is long. - * * size_splits: size of each tensor split from the input. The value is a 1D tensor of the int type. - * If size_splits is empty, the input will be evenly split into tensors of the same size. In this case, - * input.shape[axis] can be exactly divisible by outputNum. - * If size_splits is not empty, the sum of all its elements must be equal to input.shape[axis]. - * * axis: splitting dimension of the int type. - * - * Outputs: - * - * * outputs: array of n-dimensional tensors, with the same data type and dimensions. - * The data type of each tensor is the same as that of input. - */ - OH_NN_OPS_SPLIT = 32, - - /** - * Calculates the square root of a tensor. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Outputs: - * - * * output: square root of the input. It is an n-dimensional tensor with the same data type and shape as input. - */ - OH_NN_OPS_SQRT = 33, - - /** - * Calculates the square of the difference between two tensors. The SquaredDifference operator supports tensor and tensor subtraction. - * If two tensors have different TensorTypes, the Sub operator converts the low-precision tensor to a high-precision one. - * If two tensors have different shapes, the two tensors can be extended to tensors with the same shape through broadcast. - * - * Inputs: - * - * * input1: minuend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type. - * * input2: subtrahend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type. - * - * Outputs: - * - * * output: square of the difference between two inputs. The output shape is determined - * byinput1 and input2. If they have the same shape, the output tensor has the same shape as them. - * If they have different shapes, perform the broadcast operation on input1 and input2 and perform subtraction. - * TensorType of the output is the same as that of the input tensor with higher precision. - */ - OH_NN_OPS_SQUARED_DIFFERENCE = 34, - - /** - * Removes the dimension with a length of 1 from the specified axis. The int8 quantization input is supported. - * Assume that the input shape is [2, 1, 1, 2, 2] and axis is [0,1], the output shape is [2, 1, 2, 2], - * which means the dimension whose length is 0 between dimensions 0 and dimension 1 is removed. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Parameters: - * - * * axis: dimension to be removed. The value is of int64_t type and can be an integer in the range [-n, n) or an array. - * - * Outputs: - * - * * output: output tensor. - */ - OH_NN_OPS_SQUEEZE = 35, - - /** - * Stacks multiple tensors along the specified axis. If each tensor has n dimensions before stacking, - * the output tensor will have n+1 dimensions. - * - * Inputs: - * - * * input: input for stacking, which can contain multiple n-dimensional tensors. - * Each of them must have the same shape and type. - * - * Parameters: - * - * * axis: dimension for tensor stacking, which is an integer. The value range is [-(n+1),(n+1)), - * which means a negative number is allowed. - * - * Outputs: - * - * * output: stacking result of the input along the axis dimension. The value is an n+1-dimensional tensor - * and has the same TensorType as the input. - */ - OH_NN_OPS_STACK = 36, - - /** - * Slices a tensor with the specified stride. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * * begin: start of slicing, which is a 1D tensor. The length of begin is n. - * begin[i] specifies the start of slicing in the ith dimension. - * * end: end of slicing, which is a 1D tensor. The length of end is n. - * end[i] specifies the end of slicing in the ith dimension. - * * strides: slicing stride, which is a 1D tensor. The length of strides is n. - * strides[i] specifies the stride at which the tensor is sliced in the ith dimension. - * - * Parameters: - * - * * beginMask: an integer used to mask begin. beginMask is represented in binary code. - * In case of binary(beginMask)[i]==1, for the ith dimension, elements are sliced from the first element - * at strides[i] until the end[i]-1 element. - * - * * endMask: an integer used to mask end. endMask is represented in binary code. - * In case of binary(endMask)[i]==1, elements are sliced from the element at the begin[i] position - * in the ith dimension until the tensor boundary at strides[i]. - * - * * ellipsisMask: integer used to mask begin and end. ellipsisMask is represented in binary code. - * In case of binary(ellipsisMask)[i]==1, elements are sliced from the first element at strides[i] in the ith dimension - * until the tensor boundary. Only one bit of binary(ellipsisMask) can be a non-zero value. - * - * * newAxisMask: new dimension, which is an integer. newAxisMask is represented in binary code. - * In case of binary(newAxisMask)[i]==1, a new dimension whose length is 1 is inserted into the ith dimension. - * * shrinkAxisMask: shrinking dimension, which is an integer. * shrinkAxisMask is represented in binary code. - * In the case of binary(shrinkAxisMask)[i]==1, all elements in the ith dimension will be discarded, - * and the length of the ith dimension is shrunk to 1. - * - * Outputs: - * - * * A tensor, with the same data type as input. The number of dimensions of the output tensor is rank(input[0])+1. - */ - OH_NN_OPS_STRIDED_SLICE = 37, - - /** - * Calculates the difference between two tensors. - * - * Inputs: - * - * * input1: minuend, which is a tensor. - * * input2: subtrahend, which is a tensor. - * - * Parameters: - * - * * activationType is an integer constant which is contained in FuseType. - * The specified activation function is called before output. - * - * Outputs: - * - * * output: difference between the two tensors. The output shape is determined byinput1 and input2. - * If they have the same shape, the output tensor has the same shape as them. - * If they have different shapes, perform the broadcast operation on input1 and input2 and perform subtraction. - * TensorType of the output is the same as that of the input tensor with higher precision. - */ - OH_NN_OPS_SUB = 38, - - /** - * Computes hyperbolic tangent of the input tensor. - * - * Inputs: - * - * * input: n-dimensional tensor. - * - * Outputs: - * - * * output: hyperbolic tangent of the input. The TensorType and tensor shape are the same as those of the input. - */ - OH_NN_OPS_TANH = 39, - - /** - * Copies a tensor the specified times. - * - * Inputs: - * * input: n-dimensional tensor. - * * multiples: number of times that the input tensor is copied in each dimension. The value is a 1D tensor. - * The length m is not less than the number of dimensions, that is, n. - * - * Outputs: - * * An m-dimensional tensor whose TensorType is the same as that of the input. If input and - * multiples have the same length, input and output have the same number of dimensions. - * If the length of multiples is greater than n, 1 is used to fill the input dimension, - * and then the input is copied in each dimension the specified times to obtain the m-dimensional tensor. - */ - OH_NN_OPS_TILE = 40, - - /** - * Transposes data of input 0 based on permutation. - * - * Inputs: - * - * * input: n-dimensional tensor to be transposed. - * * permutation: The value is a 1D tensor whose length is the same as the number of dimensions of input 0. - * - * Outputs: - * - * * output: n-dimensional tensor. TensorType of output 0 is the same as that of input 0, - * and the output shape is determined by the shape and permutation of input 0. - */ - OH_NN_OPS_TRANSPOSE = 41, - - /** - * Calculates the average value in the specified dimension. If keepDims is set to false, the number of dimensions - * is reduced for the input; if keepDims is set to true, the number of dimensions is retained. - * - * Inputs: - * - * * input: n-dimensional input tensor, where n is less than 8. - * * axis: dimension used to calculate the average value. The value is a 1D tensor. The value range of each element in axis is [–n, n). - * - * Parameters: - * - * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. - * - * Outputs: - * - * * output: m-dimensional output tensor whose data type is the same as that of the input. If keepDims is - * false, m==n. If keepDims is true, minput: 4D input tensor. Each element in the input cannot be less than 0. The input layout must be [batchSize, height, width, channels]. - * - * Parameters: - * - * * newHeight: resized height of the 4D tensor. - * * newWidth: resized width of the 4D tensor. - * * preserveAspectRatio: indicates whether to maintain the height/width ratio of input after resizing. - * * coordinateTransformMode: coordinate transformation method used by the resize operation. The value is an int32 integer. - * Currently, the following methods are supported: - * * excludeOutside: an int64 floating point number. When its value is 1, the sampling weight of the part that - * exceeds the boundary of input is set to 0, and other weights are normalized. - * - * Outputs: - * - * * output: n-dimensional tensor, with the same shape and data type as input. - */ - OH_NN_OPS_RESIZE_BILINEAR = 43, - - /** - * Calculates the reciprocal of the square root of a tensor. - * - * Inputs: - * - * * input: n-dimensional tensor, where n is less than 8. Each element of the tensor cannot be less than 0. - * - * Outputs: - * - * * output: n-dimensional tensor, with the same shape and data type as input. - */ - OH_NN_OPS_RSQRT = 44, - - /** - * Reshapes a tensor. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * * InputShape: shape of the output tensor. The value is a 1D constant tensor. - * - * Outputs: - * - * * output: tensor whose data type is the same as that of input and shape is determined by InputShape. - */ - OH_NN_OPS_RESHAPE = 45, - - /** - * Calculates the PReLU activation value of input and weight. - * - * Inputs: - * - * * input: n-dimensional tensor. If n is greater than or equal to 2, inputX must be [BatchSize, ..., Channels]. - * The second dimension is the number of channels. - * * weight: 1D tensor. The length of weight must be 1 or equal to the number of channels. If the length of weight is 1, - * all channels share the same weight. - * If the length of weight is equal to the number of channels, each channel exclusively has a weight. - * If n is less than 2 for inputX, the weight length must be 1. - * - * Outputs: - * - * * output: PReLU activation value of x, with the same shape and data type as inputX. - */ - OH_NN_OPS_PRELU = 46, - - /** - * Calculates the Relu activation value of input. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * - * Outputs: - * - * * output: n-dimensional tensor, with the same data type and shape as the input tensor. - */ - OH_NN_OPS_RELU = 47, - - /** - * Calculates the Relu6 activation value of the input, that is, calculate min(max(x, 0), 6) for each element x in the input. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * - * Outputs: - * - * * output: n-dimensional Relu6 tensor, with the same data type and shape as the input tensor. - */ - OH_NN_OPS_RELU6 = 48, - - /** - * Applies layer normalization for a tensor from the specified axis. - * - * Inputs: - * - * * input: n-dimensional input tensor. - * * gamma: m-dimensional tensor. The dimensions of gamma must be the same as - * the shape of the part of the input tensor to normalize. - * * beta: m-dimensional tensor with the same shape as gamma. - * - * Parameters: - * - * * beginAxis is an NN_INT32 scalar that specifies the axis from which normalization starts. The value range is [1, rank(input)). - * * epsilon is a scalar of NN_FLOAT32. It is a tiny amount in the normalization formula. The common value is 1e-7. - * - * Outputs: - * - * * output: n-dimensional tensor, with the same data type and shape as the input tensor. - */ - OH_NN_OPS_LAYER_NORM = 49, - - /** - * Calculates the accumulated value for a tensor along the specified dimension. - * - * Inputs: - * - * * input: n-dimensional input tensor, where n is less than 8. - * * axis: dimension used to calculate the product. The value is a 1D tensor. The value range of each element in axis is [–n, n). - * - * Parameters: - * - * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. - * When its value is true, the number of output dimensions is the same as that of the input. - * When its value is false, the number of output dimensions is reduced. - * - * Outputs: - * - * * output: m-dimensional output tensor whose data type is the same as that of the input. - * If keepDims is false, m==n. If keepDims is true, mkeepDims is set to false, - * the number of dimensions is reduced for the input; if keepDims is set to true, the number of dimensions is retained. - * - * Inputs: - * - * * A n-dimensional input tensor, where n is less than 8. - * * A 1D tensor specifying the dimension used to operate the logical OR. The value range of each element in axis is [–n, n). - * - * Parameters: - * - * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. - * - * Outputs: - * * output: m-dimensional output tensor whose data type is the same as that of the input. - * If keepDims is false, m==n. If keepDims is true, minput: n-dimensional tensor. - * - * Parameters: - * - * * src_t: data type of the input. - * * dst_t: data type of the output. - * - * Outputs: - * - * * output: n-dimensional tensor. The data type is determined by input2. - * The output shape is the same as the input shape. - */ - OH_NN_OPS_QUANT_DTYPE_CAST = 52, - - /** - * Obtains the values and indices of the largest k entries in the last dimension. - * - * Inputs: - * - * * input: n-dimensional tensor. - * * input k: first k records of data and their indices. - * - * Parameters: - * - * * sorted: order of sorting. The value true means descending and false means ascending. - * - * Outputs: - * - * * output0: largest k elements in each slice of the last dimension. - * * output1: index of the value in the last dimension of the input. - */ - OH_NN_OPS_TOP_K = 53, - - /** - * Returns the index of the maximum tensor value across axes. - * - * Inputs: - * - * * input: n-dimensional tensor (N, ∗), where ∗ means any number of additional dimensions. - * - * Parameters: - * - * * axis: dimension for calculating the index of the maximum. - * * keep_dims: indicates whether to maintain the input tensor dimension. The value is a Boolean value. - * - * Outputs: - * * output: index of the maximum input tensor on the axis. The value is a tensor. - */ - OH_NN_OPS_ARG_MAX = 54, - - /** - * Adds a dimension based on the value of axis. - * - * Inputs: - * * input: n-dimensional tensor. - * - * Parameters: - * - * * axis: dimension to be added. The value of axis can be an integer or an array of integers. - * The value range of the integer is [-n, n). - * - * Outputs: - * * output: output tensor. - */ - OH_NN_OPS_UNSQUEEZE = 55, - - /** - * Gaussian error linear unit activation function. The int quantization input is not supported. output=0.5∗input∗(1+tanh(input/2)) - * - * Inputs: - * * An n-dimensional input tensor. - * - * Outputs: - * * output: n-dimensional tensor, with the same data type and shape as the input tensor. - */ - OH_NN_OPS_GELU = 56, -} OH_NN_OperationType; - -/** - * @brief Enumerates the tensor data types. - * - * Tensors are usually used to set the input, output, and operator parameters of a model. When a tensor is used - * as the input or output of a model (or operator), set the tensor type to {@link OH_NN_TENSOR}. - * When the tensor is used as an operator parameter, select an enumerated value other than {@link OH_NN_TENSOR} as the tensor type. - * Assume that the pad parameter of the {@link OH_NN_OPS_CONV2D} operator is being set. - * You need to set the type attribute of the {@link OH_NN_Tensor} instance to {@link OH_NN_CONV2D_PAD}. - * The settings of other operator parameters are similar. The enumerated values are named - * in the format OH_NN_{Operator name}_{Attribute name}. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** This enumerated value is used when the tensor is used as the input or output of a model (or operator). */ - OH_NN_TENSOR = 0, - - /** This enumerated value is used when the tensor is used as the activationType parameter of the Add operator. */ - OH_NN_ADD_ACTIVATIONTYPE = 1, - - /** This enumerated value is used when the tensor is used as the kernel_size parameter of the AvgPool operator. */ - OH_NN_AVG_POOL_KERNEL_SIZE = 2, - /** This enumerated value is used when the tensor is used as the stride parameter of the AvgPool operator. */ - OH_NN_AVG_POOL_STRIDE = 3, - /** This enumerated value is used when the tensor is used as the pad_mode parameter of the AvgPool operator. */ - OH_NN_AVG_POOL_PAD_MODE = 4, - /** This enumerated value is used when the tensor is used as the pad parameter of the AvgPool operator. */ - OH_NN_AVG_POOL_PAD = 5, - /** This enumerated value is used when the tensor is used as the activation_type parameter of the AvgPool operator. */ - OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, - - /** This enumerated value is used when the tensor is used as the eosilon parameter of the BatchNorm operator. */ - OH_NN_BATCH_NORM_EPSILON = 7, - - /** This enumerated value is used when the tensor is used as the blockSize parameter of the BatchToSpaceND operator. */ - OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, - /** This enumerated value is used when the tensor is used as the crops parameter of the BatchToSpaceND operator. */ - OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, - - /** This enumerated value is used when the tensor is used as the axis parameter of the Concat operator. */ - OH_NN_CONCAT_AXIS = 10, - - /** This enumerated value is used when the tensor is used as the strides parameter of the Conv2D operator. */ - OH_NN_CONV2D_STRIDES = 11, - /** This enumerated value is used when the tensor is used as the pad parameter of the Conv2D operator. */ - OH_NN_CONV2D_PAD = 12, - /** This enumerated value is used when the tensor is used as the dilation parameter of the Conv2D operator. */ - OH_NN_CONV2D_DILATION = 13, - /** This enumerated value is used when the tensor is used as the padMode parameter of the Conv2D operator. */ - OH_NN_CONV2D_PAD_MODE = 14, - /** This enumerated value is used when the tensor is used as the activationType parameter of the Conv2D operator. */ - OH_NN_CONV2D_ACTIVATION_TYPE = 15, - /** This enumerated value is used when the tensor is used as the group parameter of the Conv2D operator. */ - OH_NN_CONV2D_GROUP = 16, - - /** This enumerated value is used when the tensor is used as the strides parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, - /** This enumerated value is used when the tensor is used as the pad parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_PAD = 18, - /** This enumerated value is used when the tensor is used as the dilation parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_DILATION = 19, - /** This enumerated value is used when the tensor is used as the outputPaddings parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, - /** This enumerated value is used when the tensor is used as the padMode parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, - /** This enumerated value is used when the tensor is used as the activationType parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, - /** This enumerated value is used when the tensor is used as the group parameter of the Conv2DTranspose operator. */ - OH_NN_CONV2D_TRANSPOSE_GROUP = 23, - - /** This enumerated value is used when the tensor is used as the strides parameter of the DepthwiseConv2dNative operator. */ - OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, - /** This enumerated value is used when the tensor is used as the pad parameter of the DepthwiseConv2dNative operator. */ - OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, - /** This enumerated value is used when the tensor is used as the dilation parameter of the DepthwiseConv2dNative operator. */ - OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, - /** This enumerated value is used when the tensor is used as the padMode parameter of the DepthwiseConv2dNative operator. */ - OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27, - /** This enumerated value is used when the tensor is used as the activationType parameter of the DepthwiseConv2dNative operator. */ - OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, - - /** This enumerated value is used when the tensor is used as the activationType parameter of the Div operator. */ - OH_NN_DIV_ACTIVATIONTYPE = 29, - - /** This enumerated value is used when the tensor is used as the mode parameter of the Eltwise operator. */ - OH_NN_ELTWISE_MODE = 30, - - /** This enumerated value is used when the tensor is used as the axis parameter of the FullConnection operator. */ - OH_NN_FULL_CONNECTION_AXIS = 31, - /** This enumerated value is used when the tensor is used as the activationType parameter of the FullConnection operator. */ - OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, - - /** This enumerated value is used when the tensor is used as the transposeA parameter of the Matmul operator. */ - OH_NN_MATMUL_TRANSPOSE_A = 33, - /** This enumerated value is used when the tensor is used as the transposeB parameter of the Matmul operator. */ - OH_NN_MATMUL_TRANSPOSE_B = 34, - /** This enumerated value is used when the tensor is used as the activationType parameter of the Matmul operator. */ - OH_NN_MATMUL_ACTIVATION_TYPE = 35, - - /** This enumerated value is used when the tensor is used as the kernel_size parameter of the MaxPool operator. */ - OH_NN_MAX_POOL_KERNEL_SIZE = 36, - /** This enumerated value is used when the tensor is used as the stride parameter of the MaxPool operator. */ - OH_NN_MAX_POOL_STRIDE = 37, - /** This enumerated value is used when the tensor is used as the pad_mode parameter of the MaxPool operator. */ - OH_NN_MAX_POOL_PAD_MODE = 38, - /** This enumerated value is used when the tensor is used as the pad parameter of the MaxPool operator. */ - OH_NN_MAX_POOL_PAD = 39, - /** This enumerated value is used when the tensor is used as the activation_type parameter of the MaxPool operator. */ - OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, - - /** This enumerated value is used when the tensor is used as the activationType parameter of the Mul operator. */ - OH_NN_MUL_ACTIVATION_TYPE = 41, - - /** This enumerated value is used when the tensor is used as the axis parameter of the OneHot operator. */ - OH_NN_ONE_HOT_AXIS = 42, - - /** This enumerated value is used when the tensor is used as the constant_value parameter of the Pad operator. */ - OH_NN_PAD_CONSTANT_VALUE = 43, - - /** This enumerated value is used when the tensor is used as the activationType parameter of the Scale operator. */ - OH_NN_SCALE_ACTIVATIONTYPE = 44, - /** This enumerated value is used when the tensor is used as the axis parameter of the Scale operator. */ - OH_NN_SCALE_AXIS = 45, - - /** This enumerated value is used when the tensor is used as the axis parameter of the Softmax operator. */ - OH_NN_SOFTMAX_AXIS = 46, - - /** This enumerated value is used when the tensor is used as the BlockShape parameter of the SpaceToBatchND operator. */ - OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47, - /** This enumerated value is used when the tensor is used as the Paddings parameter of the SpaceToBatchND operator. */ - OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, - - /** This enumerated value is used when the tensor is used as the Axis parameter of the Split operator. */ - OH_NN_SPLIT_AXIS = 49, - /** This enumerated value is used when the tensor is used as the OutputNum parameter of the Split operator. */ - OH_NN_SPLIT_OUTPUT_NUM = 50, - /** This enumerated value is used when the tensor is used as the SizeSplits parameter of the Split operator. */ - OH_NN_SPLIT_SIZE_SPLITS = 51, - - /** This enumerated value is used when the tensor is used as the Axis parameter of the Squeeze operator. */ - OH_NN_SQUEEZE_AXIS = 52, - - /** This enumerated value is used when the tensor is used as the Axis parameter of the Stack operator. */ - OH_NN_STACK_AXIS = 53, - - /** This enumerated value is used when the tensor is used as the BeginMask parameter of the StridedSlice operator. */ - OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, - /** This enumerated value is used when the tensor is used as the EndMask parameter of the StridedSlice operator. */ - OH_NN_STRIDED_SLICE_END_MASK = 55, - /** This enumerated value is used when the tensor is used as the EllipsisMask parameter of the StridedSlice operator. */ - OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, - /** This enumerated value is used when the tensor is used as the NewAxisMask parameter of the StridedSlice operator. */ - OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, - /** This enumerated value is used when the tensor is used as the ShrinkAxisMask parameter of the StridedSlice operator. */ - OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, - - /** This enumerated value is used when the tensor is used as the ActivationType parameter of the Sub operator. */ - OH_NN_SUB_ACTIVATIONTYPE = 59, - - /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceMean operator. */ - OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, - - /** This enumerated value is used when the tensor is used as the new_height parameter of the ResizeBilinear operator. */ - OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, - /** This enumerated value is used when the tensor is used as the new_width parameter of the ResizeBilinear operator. */ - OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, - /** This enumerated value is used when the tensor is used as the preserve_aspect_ratio parameter of the ResizeBilinear operator. */ - OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63, - /** This enumerated value is used when the tensor is used as the coordinate_transform_mode parameter of the ResizeBilinear operator. */ - OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, - /** This enumerated value is used when the tensor is used as the exclude_outside parameter of the ResizeBilinear operator. */ - OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, - - /** This enumerated value is used when the tensor is used as the beginNormAxis parameter of the LayerNorm operator. */ - OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, - /** This enumerated value is used when the tensor is used as the epsilon parameter of the LayerNorm operator. */ - OH_NN_LAYER_NORM_EPSILON = 67, - /** This enumerated value is used when the tensor is used as the beginParamsAxis parameter of the LayerNorm operator. */ - OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, - /** This enumerated value is used when the tensor is used as the elementwiseAffine parameter of the LayerNorm operator. */ - OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, - - /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceProd operator. */ - OH_NN_REDUCE_PROD_KEEP_DIMS = 70, - - /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceAll operator. */ - OH_NN_REDUCE_ALL_KEEP_DIMS = 71, - - /** This enumerated value is used when the tensor is used as the src_t parameter of the QuantDTypeCast operator. */ - OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, - /** This enumerated value is used when the tensor is used as the dst_t parameter of the QuantDTypeCast operator. */ - OH_NN_QUANT_DTYPE_CAST_DST_T = 73, - - /** This enumerated value is used when the tensor is used as the Sorted parameter of the Topk operator. */ - OH_NN_TOP_K_SORTED = 74, - - /** This enumerated value is used when the tensor is used as the axis parameter of the ArgMax operator. */ - OH_NN_ARG_MAX_AXIS = 75, - /** This enumerated value is used when the tensor is used as the keepDims parameter of the ArgMax operator. */ - OH_NN_ARG_MAX_KEEPDIMS = 76, - - /** This enumerated value is used when the tensor is used as the Axis parameter of the Unsqueeze operator. */ - OH_NN_UNSQUEEZE_AXIS = 77, -} OH_NN_TensorType; - -/** - * @brief This structure is used to store a 32-bit unsigned integer array. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NN_UInt32Array { - /** Pointer to the unsigned integer array */ - uint32_t *data; - /** Array length */ - uint32_t size; -} OH_NN_UInt32Array; - -/** - * @brief Quantization information. - * - * In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula: - \f[ - q = clamp(round(\frac{r}{s}+z), q_{min}, q_{max}) - \f] - * s and z are quantization parameters, which are stored by scale and zeroPoint in {@link OH_NN_QuantParam}. - * r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and - * q_max is an upper bound of a quantization result. The calculation method is as follows: - * - \f[ - \text{clamp}(x,min,max) = - \begin{cases} - q_{min} = -(1 << (numBits - 1)) \\ - q_{max} = (1 << (numBits - 1)) \\ - \end{cases} - \f] - * The clamp function is defined as follows: - \f[ - \text{clamp}(x,min,max) = - \begin{cases} - \text{max} & \text{ if } x > \text{ max } \\ - \text{min} & \text{ if } x < \text{ min } \\ - x & \text{ otherwise } \\ - \end{cases} - \f] - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NN_QuantParam { - /** Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, - * quantCount is usually set to 1. That is, all channels of a tensor share a set of quantization parameters. - * In the per-channel quantization scenario, quantCount is usually the same as the number of tensor channels, - * and each channel uses its own quantization parameters. - */ - uint32_t quantCount; - /** Number of quantization bits */ - const uint32_t *numBits; - /** Pointer to the scale data in the quantization formula */ - const double *scale; - /** Pointer to the zero point data in the quantization formula */ - const int32_t *zeroPoint; -} OH_NN_QuantParam; - -/** - * @brief Defines the tensor structure. - * - * It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, - * you need to specify the data type, number of dimensions, dimension information, and quantization information. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NN_Tensor { - /** Data type of the specified tensor. The value must be an enumerated value of {@link OH_NN_DataType}. */ - OH_NN_DataType dataType; - /** Number of dimensions of the specified tensor */ - uint32_t dimensionCount; - /** Dimension information (shape) of the specified tensor*/ - const int32_t *dimensions; - /** Quantization information of the specified tensor. The data type must be {@link OH_NN_QuantParam}. */ - const OH_NN_QuantParam *quantParam; - /** Specifies the tensor type. The value of type is related to the tensor usage. - * When the tensor is used as the input or output of the model, set type to {@link OH_NN_TENSOR}. - * When a tensor is used as an operator parameter, select any enumerated value except {@link OH_NN_TENSOR} from {@link OH_NN_TensorType}. - */ - OH_NN_TensorType type; -} OH_NN_Tensor; - -/** - * @brief Defines the memory structure. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NN_Memory { - /** Pointer to the shared memory. The shared memory is usually allocated by the underlying hardware driver. */ - void * const data; - /** Records the length of the shared memory, in bytes. */ - const size_t length; -} OH_NN_Memory; - -#ifdef __cplusplus -} -#endif // __cplusplus - -/** @} */ -#endif // NEURAL_NETWORK_RUNTIME_TYPE_H +/* + * Copyright (c) 2022 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 NeuralNeworkRuntime + * @{ + * + * @brief Provides APIs for accelerating the Neural Network Runtime model inference. + * + * @Syscap SystemCapability.Ai.NeuralNetworkRuntime + * @since 9 + * @version 1.0 + */ + +/** + * @file neural_network_runtime_type.h + * + * @brief Defines the structure and enumeration for Neural Network Runtime. + * + * @library libneural_network_runtime.so + * @since 9 + * @version 1.0 + */ + +#ifndef NEURAL_NETWORK_RUNTIME_TYPE_H +#define NEURAL_NETWORK_RUNTIME_TYPE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the handles of models for Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NNModel OH_NNModel; + +/** + * @brief Defines the compiler handle for Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NNCompilation OH_NNCompilation; + +/** + * @brief Defines the executor handle for Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NNExecutor OH_NNExecutor; + +/** + * @brief Defines the hardware performance mode. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** No performance mode preference */ + OH_NN_PERFORMANCE_NONE = 0, + /** Low power consumption mode*/ + OH_NN_PERFORMANCE_LOW = 1, + /** Medium performance mode */ + OH_NN_PERFORMANCE_MEDIUM = 2, + /** High performance mode */ + OH_NN_PERFORMANCE_HIGH = 3, + /** Ultimate performance mode */ + OH_NN_PERFORMANCE_EXTREME = 4 +} OH_NN_PerformanceMode; + +/** + * @brief Defines the model inference task priority. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** No priority preference */ + OH_NN_PRIORITY_NONE = 0, + /** Low priority */ + OH_NN_PRIORITY_LOW = 1, + /** Medium priority */ + OH_NN_PRIORITY_MEDIUM = 2, + /** High priority */ + OH_NN_PRIORITY_HIGH = 3 +} OH_NN_Priority; + +/** + * @brief Defines error codes for Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** The operation is successful. */ + OH_NN_SUCCESS = 0, + /** The operation failed. */ + OH_NN_FAILED = 1, + /** Invalid parameter. */ + OH_NN_INVALID_PARAMETER = 2, + /** Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure. */ + OH_NN_MEMORY_ERROR = 3, + /** Invalid operation. */ + OH_NN_OPERATION_FORBIDDEN = 4, + /** Null pointer exception */ + OH_NN_NULL_PTR = 5, + /** Invalid file. */ + OH_NN_INVALID_FILE = 6, + /** A hardware error occurs, for example, HDL service crash. */ + OH_NN_UNAVALIDABLE_DEVICE = 7, + /** Invalid path. */ + OH_NN_INVALID_PATH = 8 +} OH_NN_ReturnCode; + +/** + * @brief Defines activation function types in the fusion operator for Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef enum : int8_t { + /** The fusion activation function is not specified. */ + OH_NN_FUSED_NONE = 0, + /** Fusion relu activation function */ + OH_NN_FUSED_RELU = 1, + /** Fusion relu6 activation function */ + OH_NN_FUSED_RELU6 = 2 +} OH_NN_FuseType; + +/** + * @brief Defines the layout type of tensor data. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** The tensor does not have a specific layout type (such as scalar or vector). */ + OH_NN_FORMAT_NONE = 0, + /** The tensor arranges data in NCHW format.*/ + OH_NN_FORMAT_NCHW = 1, + /** The tensor arranges data in NHWC format.*/ + OH_NN_FORMAT_NHWC = 2 +} OH_NN_Format; + +/** + * @brief Defines device types supported by Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** Devices that are not CPU, GPU, or dedicated accelerator*/ + OH_NN_OTHERS = 0, + /** CPU device */ + OH_NN_CPU = 1, + /** GPU device */ + OH_NN_GPU = 2, + /** Dedicated hardware accelerator */ + OH_NN_ACCELERATOR = 3, +} OH_NN_DeviceType; + +/** + * @brief Defines tensor data types supported by Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** Unknown type */ + OH_NN_UNKNOWN = 0, + /** bool */ + OH_NN_BOOL = 1, + /** int8 */ + OH_NN_INT8 = 2, + /** int16 */ + OH_NN_INT16 = 3, + /** int32 */ + OH_NN_INT32 = 4, + /** int64 */ + OH_NN_INT64 = 5, + /** uint8 */ + OH_NN_UINT8 = 6, + /** uint16 */ + OH_NN_UINT16 = 7, + /** uint32 */ + OH_NN_UINT32 = 8, + /** uint64 */ + OH_NN_UINT64 = 9, + /** float16 */ + OH_NN_FLOAT16 = 10, + /** float32 */ + OH_NN_FLOAT32 = 11, + /** float64 */ + OH_NN_FLOAT64 = 12 +} OH_NN_DataType; + + +/** + * @brief Defines operator types supported by Neural Network Runtime. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** + * Returns the tensor of the sum of the elements corresponding to two input tensors. + * + * Inputs: + * + * * input1: first input tensor, of the Boolean or number type. + * * input2: second input tensor, whose data type must be the same as that of the first tensor. + * + * Parameters: + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: sum of input1 and input2. + * The data shape is the same as that of the input after broadcasting, + * and the data type is the same as that of the input with a higher precision. + */ + OH_NN_OPS_ADD = 1, + + /** + * Apply 2D average pooling to the input tensor, which now must be in NHWC format. The int8 quantization input is supported. + * + * If the input contains the padMode parameter: + * + * Inputs: + * + * * input: tensor. + * + * Parameters: + * + * * kernelSize indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. + * The first number indicates the kernel height, and the second number indicates the kernel width. + * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. + * The first number indicates the moving step in height, and the second number indicates the moving step in width. + * * padMode: padding mode, which is optional. The value is of the int type and can be 0 (same) or 1 (valid). + * The nearest neighbor value is used for padding. + * 0 (same): The height and width of the output are the same as those of the input. + * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. + * Otherwise, the last additional padding will be completed from the bottom and right. + * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. Excessive pixels will be discarded. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * If the input contains the padList parameter: + * + * Inputs: + * + * * input: tensor. + * + * Parameters: + * + * * kernelSize indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. + * The first number indicates the kernel height, and the second number indicates the kernel width. + * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. + * The first number indicates the moving step in height, and the second number indicates the moving step in width. + * * padList: padding around input. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: average pooling result of the input. + */ + OH_NN_OPS_AVG_POOL = 2, + + /** + * Batch normalization is performed on a tensor to scale and shift tensor elements, relieving potential covariate shift in a batch of data. + * + * Inputs: + * + * * input: n-dimensional tensor of shape [N, ..., C]. The nth dimension is the number of channels. + * * scale: 1D tensor of the scaling factor used to scale the first normalized tensor. + * * offset: 1D tensor used to move to the first normalized tensor. + * * mean: 1D tensor of the overall mean value. It is used only for inference. In case of training, this parameter must be left empty. + * * variance: 1D tensor used for the overall variance. It is used only for inference. In case of training, this parameter must be left empty. + * + * Parameters: + * + * * epsilon: fixed small additional value. + * + * Outputs: + * + * * output: n-dimensional output tensor whose shape and data type are the same as those of the input. + */ + OH_NN_OPS_BATCH_NORM = 3, + + /** + * Divides the batch dimension of a 4D tensor into small blocks by block_shape, and interleaves these blocks back into the spatial dimension. + * + * Parameters: + * + * * input: input tensor. The dimension will be divided into small blocks, and these blocks will be interleaved into the spatial dimension. + * + * Outputs: + * + * * blockSize: size of each block to be interleaved into the spatial dimension. The value is an array [height_block, width_block]. + * * crops: elements truncated from the spatial dimension of the output. The value is a 2D array [[crop0_start, crop0_end], + * [crop1_start, crop1_end]] with the shape of (2, 2). + * + * + * Outputs: + * + * * output. Assume that the shape of input is (n,h,w,c) and the shape of output is (n',h',w',c'): + * n' = n / (block_shape[0] * block_shape[1]) + * h' = h * block_shape[0] - crops[0][0] - crops[0][1] + * w' = w * block_shape[1] - crops[1][0] - crops[1][1] + * c'= c + */ + OH_NN_OPS_BATCH_TO_SPACE_ND = 4, + + /** + * Offsets the data in each dimension of the input tensor. + * + * Inputs: + * + * * input: input tensor, which can have two to five dimensions. + * * bias: offset of the number of input dimensions. + * + * Outputs: + * + * * output: sum of the input tensor and the bias in each dimension. + */ + OH_NN_OPS_BIAS_ADD = 5, + + /** + * Converts the data type in the input tensor. + * + * Inputs: + * + * * input: input tensor. + * * type: converted data type. + * + * Outputs: + * + * * output: converted tensor. + */ + OH_NN_OPS_CAST = 6, + + /** + * Connects tensors in a specified dimension. + * + * Inputs: + * + * * input: N input tensors. + * + * Parameters: + * + * * axis: dimension for connecting tensors. + * + * Outputs: + * + * * output: result of connecting N tensors along the axis. + */ + OH_NN_OPS_CONCAT = 7, + + /** + * 2D convolutional layer. + * + * If the input contains the padMode parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. + * The value of inChannel must be exactly divided by the value of group. + * + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * + * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). + * 0 (same): The height and width of the output are the same as those of the input. + * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. + * Otherwise, the last additional padding will be completed from the bottom and right. + * + * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. + * * group: number of groups in which the input is divided by in_channel. The value is of the int type. + * If group is 1, it is a conventional convolution. If group is greater than 1 and + * less than or equal to in_channel, it is a group convolution. + * * activationType is an integer constant which is contained in FuseType. The specified activation function is called before output. + * + * If the input contains the padList parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. + * The value of inChannel must be exactly divided by the value of group. + * + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * * padList: padding around input. It is an int array [top, bottom, left, right]. + * * group: number of groups in which the input is divided by in_channel. The value is of the int type. + * If group is 1, it is a conventional convolution. + * If group is in_channel, it is depthwiseConv2d. In this case, group==in_channel==out_channel. + * If group is greater than 1 and less than in_channel, it is a group convolution. In this case, out_channel==group. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: convolution computing result. + */ + OH_NN_OPS_CONV2D = 8, + + /** + * 2D convolution transposition. + * + * If the input contains the padMode parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. + * The value of inChannel must be exactly divided by the value of group. + * + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * + * Parameters: + * + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). + * 0 (same): The height and width of the output are the same as those of the input. + * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. + * Otherwise, the last additional padding will be completed from the bottom and right. + * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. + * * group: number of groups in which the input is divided by in_channel. The value is of the int type. + * If group is 1, it is a conventional convolution. If group is greater than 1 and + * less than or equal to in_channel, it is a group convolution. + * * outputPads: padding along the height and width of the output tensor. The value is an int or a tuple. + * It can be a single integer to specify the same value for all spatial dimensions. The amount of output + * padding along a dimension must be less than the stride along this dimension. + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * If the input contains the padList parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. + * The value of inChannel must be exactly divided by the value of group. + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * * padList: padding around input. It is an int array [top, bottom, left, right]. + * * group: number of groups in which the input is divided by in_channel. The value is of the int type. + * If group is 1, it is a conventional convolution. If group is greater than 1 + * and less than or equal to in_channel, it is a group convolution. + * * outputPads: padding along the height and width of the output tensor. The value is an int or a tuple. + * It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding + * along a dimension must be less than the stride along this dimension. + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: computing result after convolution and transposition. + */ + OH_NN_OPS_CONV2D_TRANSPOSE = 9, + + /** + * 2D depthwise separable convolution. + * + * If the input contains the padMode parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. + * outChannel is equal to channelMultiplier multiplied by inChannel. + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * * padMode: padding mode of input. The value is of the int type and can be 0 (same) or 1 (valid). + * 0 (same): The height and width of the output are the same as those of the input. + * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. + * Otherwise, the last additional padding will be completed from the bottom and right. + * + * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * If the input contains the padList parameter: + * + * Inputs: + * + * * input: input tensor. + * * weight: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. + * outChannel is equal to channelMultiplier multiplied by inChannel. + * * bias: bias of the convolution. It is an array with a length of [outChannel]. + * In quantization scenarios, the bias parameter does not require quantization parameters. + * The quantization version requires data input of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * stride: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth]. + * * dilation: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. + * The value must be greater than or equal to 1 and cannot exceed the height and width of input. + * * padList: padding around input. It is an int array [top, bottom, left, right]. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: convolution computing result. + */ + OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, + + /** + * Divides two input scalars or tensors. + * + * Inputs: + * + * * input1: first input, which is a number, a bool, or a tensor whose data type is number or Boolean. + * * input2: second input, which must meet the following requirements: + * If the first input is a tensor, the second input can be a real number, a Boolean value, or a tensor whose data type is real number or Boolean value. + * If the first input is a real number or Boolean value, the second input must be a tensor whose data type is real number or Boolean value. + * + * Parameters: + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: result of dividing input1 by input2. + */ + OH_NN_OPS_DIV = 11, + + /** + * Sets parameters to perform product (dot product), sum (addition and subtraction), or max (larger value) on the input. + * + * Inputs: + * + * * input1: first input tensor. + * * input2: second input tensor. + * + * Parameters: + * + * * mode: operation mode. The value is an enumerated value. + * + * Outputs: + * + * * output: computing result, which has the same data type and shape of output and input1. + */ + OH_NN_OPS_ELTWISE = 12, + + /** + * Adds an additional dimension to a tensor in the given dimension. + * + * Inputs: + * + * * input: input tensor. + * * axis: index of the dimension to be added. The value is of the int32_t type and must be a constant in the range [-dim-1, dim]. + * + * Outputs: + * + * * output: tensor after dimension expansion. + */ + OH_NN_OPS_EXPAND_DIMS = 13, + + /** + * Creates a tensor of the specified dimensions and fills it with a scalar. + * + * Inputs: + * + * * value: scalar used to fill the tensor. + * * shape: dimensions of the tensor to be created. + * + * Outputs: + * + * * output: generated tensor, which has the same data type as value. The tensor shape is specified by the shape parameter. + */ + OH_NN_OPS_FILL = 14, + + /** + * Full connection. The entire input is used as the feature map for feature extraction. + * + * Inputs: + * + * * input: full-connection input tensor. + * * weight: weight tensor for a full connection. + * * bias: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. + * If quantization is required, the data must be of the OH_NN_INT32 type. + * The actual quantization parameters are determined by input and weight. + * + * Parameters: + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: computed tensor. + * + * If the input contains the axis parameter: + * + * Inputs: + * + * * input: full-connection input tensor. + * * weight: weight tensor for a full connection. + * * bias: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. + * If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters + * are determined by input and weight. + * + * Parameters: + * + * * axis: axis in which the full connection is applied. The specified axis and its following axes are + * converted into a 1D tensor for applying the full connection. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: computed tensor. + */ + OH_NN_OPS_FULL_CONNECTION = 15, + + /** + * Returns the slice of the input tensor based on the specified index and axis. + * + * Inputs: + * + * * input: tensor to be sliced. + * * inputIndices: indices of the specified input on the axis. The value is an array of the int type + * and must be in the range [0,input.shape[axis]). + * * axis: axis on which input is sliced. The value is an array with one element of the int32_t type. + * + * Outputs: + * + * * output: sliced tensor. + */ + OH_NN_OPS_GATHER = 16, + + /** + * Calculate the Hswish activation value of the input. + * + * Inputs: + * + * * An n-dimensional input tensor. + * + * Outputs: + * + * * output: n-dimensional Hswish activation value. The data type is the same as that of shape and input. + */ + OH_NN_OPS_HSWISH = 17, + + /** + * For input1 and input2, calculate the result of input1[i]<=input2[i] for each pair of elements, + * where i is the index of each element in the input tensor. + * + * Inputs: + * + * * input1, which can be a real number, Boolean value, or tensor whose data type is real number or NN_BOOL. + * * input2, which can be a real number or a Boolean value if input1 is a tensor and must be a tensor + * with the data type of real number or NN_BOOL if input1 is not a tensor. + * + * Outputs: + * + * * A tensor of the data type NN_BOOL. When a quantization model is used, the quantization parameters of the output + * cannot be omitted. However, values of the quantization parameters do not affect the result. + */ + OH_NN_OPS_LESS_EQUAL = 18, + + /** + * Calculate the inner product of input1 and input2. + * + * Inputs: + * + * * input1: n-dimensional input tensor. + * * input2: n-dimensional input tensor. + * + * Parameters: + * + * * TransposeX: Boolean value indicating whether to transpose input1. + * * TransposeY: Boolean value indicating whether to transpose input2. + * + * Outputs: + * + * * output: inner product obtained after calculation. In case of type!=NN_UNKNOWN, the output data type is + * determined by type. In case of type==NN_UNKNOWN, the output data type depends on the data type + * converted during computing of inputX and inputY. + * + */ + OH_NN_OPS_MATMUL = 19, + + /** + * Calculates the maximum of input1 and input2 element-wise. The inputs of input1 and input2 + * comply with the implicit type conversion rules to make the data types consistent. * The inputs must be two tensors or one tensor and one scalar. + * When the inputs are two tensors, their data types cannot be both NN_BOOL. Their shapes can be broadcast to the same size. + * When the inputs are one tensor and one scalar, the scalar must be a constant. + * + * Inputs: + * + * * input1: n-dimensional input tensor of the real number or NN_BOOL type. + * * input2: n-dimensional input tensor of the real number or NN_BOOL type. + * + * Outputs: + * + * * output: n-dimensional output tensor. The shape and data type of + * output are the same as those of the two inputs with a higher precision. + */ + OH_NN_OPS_MAXIMUM = 20, + + /** + * Applies 2D maximum pooling to the input tensor. + * + * If the input contains the padMode parameter: + * + * Inputs: + * + * * input: tensor. + * + * Parameters: + * + * * kernelSize: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. + * The first number indicates the kernel height, and the second number indicates the kernel width. + * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. + * The first number indicates the moving step in height, and the second number indicates the moving step in width. + * * padMode: padding mode, which is optional. The value is of the int type and can be 0 (same) + * or 1 (valid). The nearest neighbor value is used for padding. + * 0 (same): The height and width of the output are the same as those of the input. + * The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. + * Otherwise, the last additional padding will be completed from the bottom and right. + * 1 (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * If the input contains the padList parameter: + * + * Inputs: + * + * * input: tensor. + * + * Parameters: + * + * * kernelSize: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. + * The first number indicates the kernel height, and the second number indicates the kernel width. + * * strides indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. + * The first number indicates the moving step in height, and the second number indicates the moving step in width. + * * padList: padding around input. It is an int array [top, bottom, left, right], + * and the nearest neighbor values are used for padding. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: tensor obtained after maximum pooling is applied to the input. + */ + OH_NN_OPS_MAX_POOL = 21, + + /** + * Multiplies elements in the same positions of inputX and inputY to obtain the output. + * If inputX and inputY have different shapes, expand them to the same shape + * through broadcast and then perform multiplication. + * + * Inputs: + * + * * input1: n-dimensional tensor. + * * input2: n-dimensional tensor. + * + * Parameters: + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * Product of each element of input1 and input2. + */ + OH_NN_OPS_MUL = 22, + + /** + * Generates a one-hot tensor based on the positions specified by indices. The positions specified by indices + * are determined by on_value, and other positions are determined by off_value. + * + * Inputs: + * + * * indices: n-dimensional tensor. Each element in indices determines the position of + * on_value in each one-hot vector. + * * depth: integer scalar that determines the depth of the one-hot vector. The value of depth + * must be greater than 0. + * * on_value: scalar that specifies a valid value in the one-hot vector. + * * off_value: scalar that specifies the values of other posistions in the one-hot vector except the valid value. + * + * Parameters: + * + * * axis: integer scalar that specifies the dimension for inserting the one-hot. Assume that the shape + * of indices is [N, C], and the value of depth is D. + * When axis is 0, the shape of the output is [D, N, C]. + * When axis is -1, the shape of the output is [N, C, D]. + * When axis is 1, the shape of the output is [N, D, C]. + * + * Outputs: + * + * * output: (n+1)-dimensional tensor if indices is an n-dimensional tensor. + * The output shape is determined by indices and axis. + */ + OH_NN_OPS_ONE_HOT = 23, + + /** + * Pads inputX in the specified dimensions. + * + * Inputs: + * + * * inputX: n-dimensional tensor in [BatchSize, ...] format. + * * paddings: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. + * For example, paddings[i][0] indicates the number of paddings to be added preceding inputX in the ith dimension. + * paddings[i][1] indicates the number of paddings to be added following inputX in the ith dimension. + * + * Parameters: + * + * * padValues: value to be added to the pad operation. The value is a constant with the same data type as inputX. + * + * Outputs: + * + * * output: n-dimensional tensor after padding, with the same dimensions and data type as inputX. + * The shape is determined by inputX and paddings. + * output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1] + */ + OH_NN_OPS_PAD = 24, + + /** + * Calculates the y power of each element in input. The inputs must be two tensors or one tensor and one scalar. + * When the inputs are two tensors, their data types cannot be both NN_BOOL, and their shapes must be the same. + * When the inputs are one tensor and one scalar, the scalar must be a constant. + * + * Inputs: + * + * * input: real number, Boolean value, or tensor whose data type is real number or NN_BOOL. + * * y: real number, Boolean value, or tensor whose data type is real number or NN_BOOL. + * + * Outputs: + * + * * output: tensor, whose shape is determined by the shape of input and y after broadcasting. + */ + OH_NN_OPS_POW = 25, + + /** + * Scales a tensor. + * + * Inputs: + * + * * input: n-dimensional tensor. + * * scale: scaling tensor. + * * bias: bias tensor. + * + * Parameters: + * + * * axis: dimensions to be scaled. + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: scaled n-dimensional tensor, whose data type is the same as that of input and + * shape is determined by axis. + */ + OH_NN_OPS_SCALE = 26, + + /** + * Calculates the shape of the input tensor. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Outputs: + * + * * output: integer array representing the dimensions of the input tensor. + */ + OH_NN_OPS_SHAPE = 27, + + /** + * Applies the sigmoid operation to the input tensor. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Outputs: + * + * * output: result of the sigmoid operation. It is an n-dimensional tensor + * with the same data type and shape as input. + */ + OH_NN_OPS_SIGMOID = 28, + + /** + * Slices a tensor of the specified size from the input in each dimension. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * * begin: start of the slice, which is an array of integers greater than or equal to 0. + * * size: slice length, which is an array of integers greater than or equal to 0. + * Assume that a dimension is i and 1<=size[i]<=input.shape[i]-begin[i]. + * + * Outputs: + * + * * output: n-dimensional tensor obtained by slicing. + * The TensorType, shape, and size of the output are the same as those of the input. + */ + OH_NN_OPS_SLICE = 29, + + /** + * Applies the softmax operation to the input tensor. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * + * Parameters: + * + * * axis: dimension in which the softmax operation is performed. + * The value is of the int64 type. It is an integer in the range [-n, n). + * + * Outputs: + * + * * output: result of the softmax operation. It is an n-dimensional tensor with + * the same data type and shape as input. + */ + OH_NN_OPS_SOFTMAX = 30, + + /** + * Divides a 4D tensor into small blocks and combines these blocks in the original batch. + * The number of blocks is blockShape[0] multiplied by blockShape[1]. + * + * Inputs: + * + * * input: 4D tensor. + * + * Parameters: + * + * * blockShape: a pair of integers. Each of them is greater than or equal to 1. + * * paddings: a pair of arrays. Each of them consists of two integers. The four integers that form paddings + * must be greater than or equal to 0. paddings[0][0] and paddings[0][1] + * specify the number of paddings in the third dimension, and paddings[1][0] and paddings[1][1] + * specify the number of paddings in the fourth dimension. + * + * Outputs: + * + * * output: 4D tensor with the same data type as input. The shape is determined by input, + * blockShape, and paddings. Assume that the input shape is [n,c,h,w], then: + * output.shape[0] = n * blockShape[0] * blockShape[1] + * output.shape[1] = c + * output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] + * output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] + * (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]) is exactly divisible by + * (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]). + * + */ + OH_NN_OPS_SPACE_TO_BATCH_ND = 31, + + /** + * Splits the input into multiple tensors along the axis dimension. The number of tensors is specified by outputNum. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Parameters: + * + * * outputNum: number of output tensors. The data type is long. + * * size_splits: size of each tensor split from the input. The value is a 1D tensor of the int type. + * If size_splits is empty, the input will be evenly split into tensors of the same size. In this case, + * input.shape[axis] can be exactly divisible by outputNum. + * If size_splits is not empty, the sum of all its elements must be equal to input.shape[axis]. + * * axis: splitting dimension of the int type. + * + * Outputs: + * + * * outputs: array of n-dimensional tensors, with the same data type and dimensions. + * The data type of each tensor is the same as that of input. + */ + OH_NN_OPS_SPLIT = 32, + + /** + * Calculates the square root of a tensor. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Outputs: + * + * * output: square root of the input. It is an n-dimensional tensor with the same data type and shape as input. + */ + OH_NN_OPS_SQRT = 33, + + /** + * Calculates the square of the difference between two tensors. The SquaredDifference operator supports tensor and tensor subtraction. + * If two tensors have different TensorTypes, the Sub operator converts the low-precision tensor to a high-precision one. + * If two tensors have different shapes, the two tensors can be extended to tensors with the same shape through broadcast. + * + * Inputs: + * + * * input1: minuend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type. + * * input2: subtrahend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type. + * + * Outputs: + * + * * output: square of the difference between two inputs. The output shape is determined + * byinput1 and input2. If they have the same shape, the output tensor has the same shape as them. + * If they have different shapes, perform the broadcast operation on input1 and input2 and perform subtraction. + * TensorType of the output is the same as that of the input tensor with higher precision. + */ + OH_NN_OPS_SQUARED_DIFFERENCE = 34, + + /** + * Removes the dimension with a length of 1 from the specified axis. The int8 quantization input is supported. + * Assume that the input shape is [2, 1, 1, 2, 2] and axis is [0,1], the output shape is [2, 1, 2, 2], + * which means the dimension whose length is 0 between dimensions 0 and dimension 1 is removed. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Parameters: + * + * * axis: dimension to be removed. The value is of int64_t type and can be an integer in the range [-n, n) or an array. + * + * Outputs: + * + * * output: output tensor. + */ + OH_NN_OPS_SQUEEZE = 35, + + /** + * Stacks multiple tensors along the specified axis. If each tensor has n dimensions before stacking, + * the output tensor will have n+1 dimensions. + * + * Inputs: + * + * * input: input for stacking, which can contain multiple n-dimensional tensors. + * Each of them must have the same shape and type. + * + * Parameters: + * + * * axis: dimension for tensor stacking, which is an integer. The value range is [-(n+1),(n+1)), + * which means a negative number is allowed. + * + * Outputs: + * + * * output: stacking result of the input along the axis dimension. The value is an n+1-dimensional tensor + * and has the same TensorType as the input. + */ + OH_NN_OPS_STACK = 36, + + /** + * Slices a tensor with the specified stride. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * * begin: start of slicing, which is a 1D tensor. The length of begin is n. + * begin[i] specifies the start of slicing in the ith dimension. + * * end: end of slicing, which is a 1D tensor. The length of end is n. + * end[i] specifies the end of slicing in the ith dimension. + * * strides: slicing stride, which is a 1D tensor. The length of strides is n. + * strides[i] specifies the stride at which the tensor is sliced in the ith dimension. + * + * Parameters: + * + * * beginMask: an integer used to mask begin. beginMask is represented in binary code. + * In case of binary(beginMask)[i]==1, for the ith dimension, elements are sliced from the first element + * at strides[i] until the end[i]-1 element. + * + * * endMask: an integer used to mask end. endMask is represented in binary code. + * In case of binary(endMask)[i]==1, elements are sliced from the element at the begin[i] position + * in the ith dimension until the tensor boundary at strides[i]. + * + * * ellipsisMask: integer used to mask begin and end. ellipsisMask is represented in binary code. + * In case of binary(ellipsisMask)[i]==1, elements are sliced from the first element at strides[i] in the ith dimension + * until the tensor boundary. Only one bit of binary(ellipsisMask) can be a non-zero value. + * + * * newAxisMask: new dimension, which is an integer. newAxisMask is represented in binary code. + * In case of binary(newAxisMask)[i]==1, a new dimension whose length is 1 is inserted into the ith dimension. + * * shrinkAxisMask: shrinking dimension, which is an integer. * shrinkAxisMask is represented in binary code. + * In the case of binary(shrinkAxisMask)[i]==1, all elements in the ith dimension will be discarded, + * and the length of the ith dimension is shrunk to 1. + * + * Outputs: + * + * * A tensor, with the same data type as input. The number of dimensions of the output tensor is rank(input[0])+1. + */ + OH_NN_OPS_STRIDED_SLICE = 37, + + /** + * Calculates the difference between two tensors. + * + * Inputs: + * + * * input1: minuend, which is a tensor. + * * input2: subtrahend, which is a tensor. + * + * Parameters: + * + * * activationType is an integer constant which is contained in FuseType. + * The specified activation function is called before output. + * + * Outputs: + * + * * output: difference between the two tensors. The output shape is determined byinput1 and input2. + * If they have the same shape, the output tensor has the same shape as them. + * If they have different shapes, perform the broadcast operation on input1 and input2 and perform subtraction. + * TensorType of the output is the same as that of the input tensor with higher precision. + */ + OH_NN_OPS_SUB = 38, + + /** + * Computes hyperbolic tangent of the input tensor. + * + * Inputs: + * + * * input: n-dimensional tensor. + * + * Outputs: + * + * * output: hyperbolic tangent of the input. The TensorType and tensor shape are the same as those of the input. + */ + OH_NN_OPS_TANH = 39, + + /** + * Copies a tensor the specified times. + * + * Inputs: + * * input: n-dimensional tensor. + * * multiples: number of times that the input tensor is copied in each dimension. The value is a 1D tensor. + * The length m is not less than the number of dimensions, that is, n. + * + * Outputs: + * * An m-dimensional tensor whose TensorType is the same as that of the input. If input and + * multiples have the same length, input and output have the same number of dimensions. + * If the length of multiples is greater than n, 1 is used to fill the input dimension, + * and then the input is copied in each dimension the specified times to obtain the m-dimensional tensor. + */ + OH_NN_OPS_TILE = 40, + + /** + * Transposes data of input 0 based on permutation. + * + * Inputs: + * + * * input: n-dimensional tensor to be transposed. + * * permutation: The value is a 1D tensor whose length is the same as the number of dimensions of input 0. + * + * Outputs: + * + * * output: n-dimensional tensor. TensorType of output 0 is the same as that of input 0, + * and the output shape is determined by the shape and permutation of input 0. + */ + OH_NN_OPS_TRANSPOSE = 41, + + /** + * Calculates the average value in the specified dimension. If keepDims is set to false, the number of dimensions + * is reduced for the input; if keepDims is set to true, the number of dimensions is retained. + * + * Inputs: + * + * * input: n-dimensional input tensor, where n is less than 8. + * * axis: dimension used to calculate the average value. The value is a 1D tensor. The value range of each element in axis is [–n, n). + * + * Parameters: + * + * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. + * + * Outputs: + * + * * output: m-dimensional output tensor whose data type is the same as that of the input. If keepDims is + * false, m==n. If keepDims is true, minput: 4D input tensor. Each element in the input cannot be less than 0. The input layout must be [batchSize, height, width, channels]. + * + * Parameters: + * + * * newHeight: resized height of the 4D tensor. + * * newWidth: resized width of the 4D tensor. + * * preserveAspectRatio: indicates whether to maintain the height/width ratio of input after resizing. + * * coordinateTransformMode: coordinate transformation method used by the resize operation. The value is an int32 integer. + * Currently, the following methods are supported: + * * excludeOutside: an int64 floating point number. When its value is 1, the sampling weight of the part that + * exceeds the boundary of input is set to 0, and other weights are normalized. + * + * Outputs: + * + * * output: n-dimensional tensor, with the same shape and data type as input. + */ + OH_NN_OPS_RESIZE_BILINEAR = 43, + + /** + * Calculates the reciprocal of the square root of a tensor. + * + * Inputs: + * + * * input: n-dimensional tensor, where n is less than 8. Each element of the tensor cannot be less than 0. + * + * Outputs: + * + * * output: n-dimensional tensor, with the same shape and data type as input. + */ + OH_NN_OPS_RSQRT = 44, + + /** + * Reshapes a tensor. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * * InputShape: shape of the output tensor. The value is a 1D constant tensor. + * + * Outputs: + * + * * output: tensor whose data type is the same as that of input and shape is determined by InputShape. + */ + OH_NN_OPS_RESHAPE = 45, + + /** + * Calculates the PReLU activation value of input and weight. + * + * Inputs: + * + * * input: n-dimensional tensor. If n is greater than or equal to 2, inputX must be [BatchSize, ..., Channels]. + * The second dimension is the number of channels. + * * weight: 1D tensor. The length of weight must be 1 or equal to the number of channels. If the length of weight is 1, + * all channels share the same weight. + * If the length of weight is equal to the number of channels, each channel exclusively has a weight. + * If n is less than 2 for inputX, the weight length must be 1. + * + * Outputs: + * + * * output: PReLU activation value of x, with the same shape and data type as inputX. + */ + OH_NN_OPS_PRELU = 46, + + /** + * Calculates the Relu activation value of input. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * + * Outputs: + * + * * output: n-dimensional tensor, with the same data type and shape as the input tensor. + */ + OH_NN_OPS_RELU = 47, + + /** + * Calculates the Relu6 activation value of the input, that is, calculate min(max(x, 0), 6) for each element x in the input. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * + * Outputs: + * + * * output: n-dimensional Relu6 tensor, with the same data type and shape as the input tensor. + */ + OH_NN_OPS_RELU6 = 48, + + /** + * Applies layer normalization for a tensor from the specified axis. + * + * Inputs: + * + * * input: n-dimensional input tensor. + * * gamma: m-dimensional tensor. The dimensions of gamma must be the same as + * the shape of the part of the input tensor to normalize. + * * beta: m-dimensional tensor with the same shape as gamma. + * + * Parameters: + * + * * beginAxis is an NN_INT32 scalar that specifies the axis from which normalization starts. The value range is [1, rank(input)). + * * epsilon is a scalar of NN_FLOAT32. It is a tiny amount in the normalization formula. The common value is 1e-7. + * + * Outputs: + * + * * output: n-dimensional tensor, with the same data type and shape as the input tensor. + */ + OH_NN_OPS_LAYER_NORM = 49, + + /** + * Calculates the accumulated value for a tensor along the specified dimension. + * + * Inputs: + * + * * input: n-dimensional input tensor, where n is less than 8. + * * axis: dimension used to calculate the product. The value is a 1D tensor. The value range of each element in axis is [–n, n). + * + * Parameters: + * + * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. + * When its value is true, the number of output dimensions is the same as that of the input. + * When its value is false, the number of output dimensions is reduced. + * + * Outputs: + * + * * output: m-dimensional output tensor whose data type is the same as that of the input. + * If keepDims is false, m==n. If keepDims is true, mkeepDims is set to false, + * the number of dimensions is reduced for the input; if keepDims is set to true, the number of dimensions is retained. + * + * Inputs: + * + * * A n-dimensional input tensor, where n is less than 8. + * * A 1D tensor specifying the dimension used to operate the logical OR. The value range of each element in axis is [–n, n). + * + * Parameters: + * + * * keepDims: indicates whether to retain the dimension. The value is a Boolean value. + * + * Outputs: + * * output: m-dimensional output tensor whose data type is the same as that of the input. + * If keepDims is false, m==n. If keepDims is true, minput: n-dimensional tensor. + * + * Parameters: + * + * * src_t: data type of the input. + * * dst_t: data type of the output. + * + * Outputs: + * + * * output: n-dimensional tensor. The data type is determined by input2. + * The output shape is the same as the input shape. + */ + OH_NN_OPS_QUANT_DTYPE_CAST = 52, + + /** + * Obtains the values and indices of the largest k entries in the last dimension. + * + * Inputs: + * + * * input: n-dimensional tensor. + * * input k: first k records of data and their indices. + * + * Parameters: + * + * * sorted: order of sorting. The value true means descending and false means ascending. + * + * Outputs: + * + * * output0: largest k elements in each slice of the last dimension. + * * output1: index of the value in the last dimension of the input. + */ + OH_NN_OPS_TOP_K = 53, + + /** + * Returns the index of the maximum tensor value across axes. + * + * Inputs: + * + * * input: n-dimensional tensor (N, ∗), where ∗ means any number of additional dimensions. + * + * Parameters: + * + * * axis: dimension for calculating the index of the maximum. + * * keep_dims: indicates whether to maintain the input tensor dimension. The value is a Boolean value. + * + * Outputs: + * * output: index of the maximum input tensor on the axis. The value is a tensor. + */ + OH_NN_OPS_ARG_MAX = 54, + + /** + * Adds a dimension based on the value of axis. + * + * Inputs: + * * input: n-dimensional tensor. + * + * Parameters: + * + * * axis: dimension to be added. The value of axis can be an integer or an array of integers. + * The value range of the integer is [-n, n). + * + * Outputs: + * * output: output tensor. + */ + OH_NN_OPS_UNSQUEEZE = 55, + + /** + * Gaussian error linear unit activation function. The int quantization input is not supported. output=0.5∗input∗(1+tanh(input/2)) + * + * Inputs: + * * An n-dimensional input tensor. + * + * Outputs: + * * output: n-dimensional tensor, with the same data type and shape as the input tensor. + */ + OH_NN_OPS_GELU = 56, +} OH_NN_OperationType; + +/** + * @brief Enumerates the tensor data types. + * + * Tensors are usually used to set the input, output, and operator parameters of a model. When a tensor is used + * as the input or output of a model (or operator), set the tensor type to {@link OH_NN_TENSOR}. + * When the tensor is used as an operator parameter, select an enumerated value other than {@link OH_NN_TENSOR} as the tensor type. + * Assume that the pad parameter of the {@link OH_NN_OPS_CONV2D} operator is being set. + * You need to set the type attribute of the {@link OH_NN_Tensor} instance to {@link OH_NN_CONV2D_PAD}. + * The settings of other operator parameters are similar. The enumerated values are named + * in the format OH_NN_{Operator name}_{Attribute name}. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** This enumerated value is used when the tensor is used as the input or output of a model (or operator). */ + OH_NN_TENSOR = 0, + + /** This enumerated value is used when the tensor is used as the activationType parameter of the Add operator. */ + OH_NN_ADD_ACTIVATIONTYPE = 1, + + /** This enumerated value is used when the tensor is used as the kernel_size parameter of the AvgPool operator. */ + OH_NN_AVG_POOL_KERNEL_SIZE = 2, + /** This enumerated value is used when the tensor is used as the stride parameter of the AvgPool operator. */ + OH_NN_AVG_POOL_STRIDE = 3, + /** This enumerated value is used when the tensor is used as the pad_mode parameter of the AvgPool operator. */ + OH_NN_AVG_POOL_PAD_MODE = 4, + /** This enumerated value is used when the tensor is used as the pad parameter of the AvgPool operator. */ + OH_NN_AVG_POOL_PAD = 5, + /** This enumerated value is used when the tensor is used as the activation_type parameter of the AvgPool operator. */ + OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, + + /** This enumerated value is used when the tensor is used as the eosilon parameter of the BatchNorm operator. */ + OH_NN_BATCH_NORM_EPSILON = 7, + + /** This enumerated value is used when the tensor is used as the blockSize parameter of the BatchToSpaceND operator. */ + OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, + /** This enumerated value is used when the tensor is used as the crops parameter of the BatchToSpaceND operator. */ + OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, + + /** This enumerated value is used when the tensor is used as the axis parameter of the Concat operator. */ + OH_NN_CONCAT_AXIS = 10, + + /** This enumerated value is used when the tensor is used as the strides parameter of the Conv2D operator. */ + OH_NN_CONV2D_STRIDES = 11, + /** This enumerated value is used when the tensor is used as the pad parameter of the Conv2D operator. */ + OH_NN_CONV2D_PAD = 12, + /** This enumerated value is used when the tensor is used as the dilation parameter of the Conv2D operator. */ + OH_NN_CONV2D_DILATION = 13, + /** This enumerated value is used when the tensor is used as the padMode parameter of the Conv2D operator. */ + OH_NN_CONV2D_PAD_MODE = 14, + /** This enumerated value is used when the tensor is used as the activationType parameter of the Conv2D operator. */ + OH_NN_CONV2D_ACTIVATION_TYPE = 15, + /** This enumerated value is used when the tensor is used as the group parameter of the Conv2D operator. */ + OH_NN_CONV2D_GROUP = 16, + + /** This enumerated value is used when the tensor is used as the strides parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, + /** This enumerated value is used when the tensor is used as the pad parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_PAD = 18, + /** This enumerated value is used when the tensor is used as the dilation parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_DILATION = 19, + /** This enumerated value is used when the tensor is used as the outputPaddings parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, + /** This enumerated value is used when the tensor is used as the padMode parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, + /** This enumerated value is used when the tensor is used as the activationType parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, + /** This enumerated value is used when the tensor is used as the group parameter of the Conv2DTranspose operator. */ + OH_NN_CONV2D_TRANSPOSE_GROUP = 23, + + /** This enumerated value is used when the tensor is used as the strides parameter of the DepthwiseConv2dNative operator. */ + OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, + /** This enumerated value is used when the tensor is used as the pad parameter of the DepthwiseConv2dNative operator. */ + OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, + /** This enumerated value is used when the tensor is used as the dilation parameter of the DepthwiseConv2dNative operator. */ + OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, + /** This enumerated value is used when the tensor is used as the padMode parameter of the DepthwiseConv2dNative operator. */ + OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27, + /** This enumerated value is used when the tensor is used as the activationType parameter of the DepthwiseConv2dNative operator. */ + OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, + + /** This enumerated value is used when the tensor is used as the activationType parameter of the Div operator. */ + OH_NN_DIV_ACTIVATIONTYPE = 29, + + /** This enumerated value is used when the tensor is used as the mode parameter of the Eltwise operator. */ + OH_NN_ELTWISE_MODE = 30, + + /** This enumerated value is used when the tensor is used as the axis parameter of the FullConnection operator. */ + OH_NN_FULL_CONNECTION_AXIS = 31, + /** This enumerated value is used when the tensor is used as the activationType parameter of the FullConnection operator. */ + OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, + + /** This enumerated value is used when the tensor is used as the transposeA parameter of the Matmul operator. */ + OH_NN_MATMUL_TRANSPOSE_A = 33, + /** This enumerated value is used when the tensor is used as the transposeB parameter of the Matmul operator. */ + OH_NN_MATMUL_TRANSPOSE_B = 34, + /** This enumerated value is used when the tensor is used as the activationType parameter of the Matmul operator. */ + OH_NN_MATMUL_ACTIVATION_TYPE = 35, + + /** This enumerated value is used when the tensor is used as the kernel_size parameter of the MaxPool operator. */ + OH_NN_MAX_POOL_KERNEL_SIZE = 36, + /** This enumerated value is used when the tensor is used as the stride parameter of the MaxPool operator. */ + OH_NN_MAX_POOL_STRIDE = 37, + /** This enumerated value is used when the tensor is used as the pad_mode parameter of the MaxPool operator. */ + OH_NN_MAX_POOL_PAD_MODE = 38, + /** This enumerated value is used when the tensor is used as the pad parameter of the MaxPool operator. */ + OH_NN_MAX_POOL_PAD = 39, + /** This enumerated value is used when the tensor is used as the activation_type parameter of the MaxPool operator. */ + OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, + + /** This enumerated value is used when the tensor is used as the activationType parameter of the Mul operator. */ + OH_NN_MUL_ACTIVATION_TYPE = 41, + + /** This enumerated value is used when the tensor is used as the axis parameter of the OneHot operator. */ + OH_NN_ONE_HOT_AXIS = 42, + + /** This enumerated value is used when the tensor is used as the constant_value parameter of the Pad operator. */ + OH_NN_PAD_CONSTANT_VALUE = 43, + + /** This enumerated value is used when the tensor is used as the activationType parameter of the Scale operator. */ + OH_NN_SCALE_ACTIVATIONTYPE = 44, + /** This enumerated value is used when the tensor is used as the axis parameter of the Scale operator. */ + OH_NN_SCALE_AXIS = 45, + + /** This enumerated value is used when the tensor is used as the axis parameter of the Softmax operator. */ + OH_NN_SOFTMAX_AXIS = 46, + + /** This enumerated value is used when the tensor is used as the BlockShape parameter of the SpaceToBatchND operator. */ + OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47, + /** This enumerated value is used when the tensor is used as the Paddings parameter of the SpaceToBatchND operator. */ + OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, + + /** This enumerated value is used when the tensor is used as the Axis parameter of the Split operator. */ + OH_NN_SPLIT_AXIS = 49, + /** This enumerated value is used when the tensor is used as the OutputNum parameter of the Split operator. */ + OH_NN_SPLIT_OUTPUT_NUM = 50, + /** This enumerated value is used when the tensor is used as the SizeSplits parameter of the Split operator. */ + OH_NN_SPLIT_SIZE_SPLITS = 51, + + /** This enumerated value is used when the tensor is used as the Axis parameter of the Squeeze operator. */ + OH_NN_SQUEEZE_AXIS = 52, + + /** This enumerated value is used when the tensor is used as the Axis parameter of the Stack operator. */ + OH_NN_STACK_AXIS = 53, + + /** This enumerated value is used when the tensor is used as the BeginMask parameter of the StridedSlice operator. */ + OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, + /** This enumerated value is used when the tensor is used as the EndMask parameter of the StridedSlice operator. */ + OH_NN_STRIDED_SLICE_END_MASK = 55, + /** This enumerated value is used when the tensor is used as the EllipsisMask parameter of the StridedSlice operator. */ + OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, + /** This enumerated value is used when the tensor is used as the NewAxisMask parameter of the StridedSlice operator. */ + OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, + /** This enumerated value is used when the tensor is used as the ShrinkAxisMask parameter of the StridedSlice operator. */ + OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, + + /** This enumerated value is used when the tensor is used as the ActivationType parameter of the Sub operator. */ + OH_NN_SUB_ACTIVATIONTYPE = 59, + + /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceMean operator. */ + OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, + + /** This enumerated value is used when the tensor is used as the new_height parameter of the ResizeBilinear operator. */ + OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, + /** This enumerated value is used when the tensor is used as the new_width parameter of the ResizeBilinear operator. */ + OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, + /** This enumerated value is used when the tensor is used as the preserve_aspect_ratio parameter of the ResizeBilinear operator. */ + OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63, + /** This enumerated value is used when the tensor is used as the coordinate_transform_mode parameter of the ResizeBilinear operator. */ + OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, + /** This enumerated value is used when the tensor is used as the exclude_outside parameter of the ResizeBilinear operator. */ + OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, + + /** This enumerated value is used when the tensor is used as the beginNormAxis parameter of the LayerNorm operator. */ + OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, + /** This enumerated value is used when the tensor is used as the epsilon parameter of the LayerNorm operator. */ + OH_NN_LAYER_NORM_EPSILON = 67, + /** This enumerated value is used when the tensor is used as the beginParamsAxis parameter of the LayerNorm operator. */ + OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, + /** This enumerated value is used when the tensor is used as the elementwiseAffine parameter of the LayerNorm operator. */ + OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, + + /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceProd operator. */ + OH_NN_REDUCE_PROD_KEEP_DIMS = 70, + + /** This enumerated value is used when the tensor is used as the keep_dims parameter of the ReduceAll operator. */ + OH_NN_REDUCE_ALL_KEEP_DIMS = 71, + + /** This enumerated value is used when the tensor is used as the src_t parameter of the QuantDTypeCast operator. */ + OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, + /** This enumerated value is used when the tensor is used as the dst_t parameter of the QuantDTypeCast operator. */ + OH_NN_QUANT_DTYPE_CAST_DST_T = 73, + + /** This enumerated value is used when the tensor is used as the Sorted parameter of the Topk operator. */ + OH_NN_TOP_K_SORTED = 74, + + /** This enumerated value is used when the tensor is used as the axis parameter of the ArgMax operator. */ + OH_NN_ARG_MAX_AXIS = 75, + /** This enumerated value is used when the tensor is used as the keepDims parameter of the ArgMax operator. */ + OH_NN_ARG_MAX_KEEPDIMS = 76, + + /** This enumerated value is used when the tensor is used as the Axis parameter of the Unsqueeze operator. */ + OH_NN_UNSQUEEZE_AXIS = 77, +} OH_NN_TensorType; + +/** + * @brief This structure is used to store a 32-bit unsigned integer array. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NN_UInt32Array { + /** Pointer to the unsigned integer array */ + uint32_t *data; + /** Array length */ + uint32_t size; +} OH_NN_UInt32Array; + +/** + * @brief Quantization information. + * + * In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula: + \f[ + q = clamp(round(\frac{r}{s}+z), q_{min}, q_{max}) + \f] + * s and z are quantization parameters, which are stored by scale and zeroPoint in {@link OH_NN_QuantParam}. + * r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and + * q_max is an upper bound of a quantization result. The calculation method is as follows: + * + \f[ + \text{clamp}(x,min,max) = + \begin{cases} + q_{min} = -(1 << (numBits - 1)) \\ + q_{max} = (1 << (numBits - 1)) \\ + \end{cases} + \f] + * The clamp function is defined as follows: + \f[ + \text{clamp}(x,min,max) = + \begin{cases} + \text{max} & \text{ if } x > \text{ max } \\ + \text{min} & \text{ if } x < \text{ min } \\ + x & \text{ otherwise } \\ + \end{cases} + \f] + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NN_QuantParam { + /** Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, + * quantCount is usually set to 1. That is, all channels of a tensor share a set of quantization parameters. + * In the per-channel quantization scenario, quantCount is usually the same as the number of tensor channels, + * and each channel uses its own quantization parameters. + */ + uint32_t quantCount; + /** Number of quantization bits */ + const uint32_t *numBits; + /** Pointer to the scale data in the quantization formula */ + const double *scale; + /** Pointer to the zero point data in the quantization formula */ + const int32_t *zeroPoint; +} OH_NN_QuantParam; + +/** + * @brief Defines the tensor structure. + * + * It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, + * you need to specify the data type, number of dimensions, dimension information, and quantization information. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NN_Tensor { + /** Data type of the specified tensor. The value must be an enumerated value of {@link OH_NN_DataType}. */ + OH_NN_DataType dataType; + /** Number of dimensions of the specified tensor */ + uint32_t dimensionCount; + /** Dimension information (shape) of the specified tensor*/ + const int32_t *dimensions; + /** Quantization information of the specified tensor. The data type must be {@link OH_NN_QuantParam}. */ + const OH_NN_QuantParam *quantParam; + /** Specifies the tensor type. The value of type is related to the tensor usage. + * When the tensor is used as the input or output of the model, set type to {@link OH_NN_TENSOR}. + * When a tensor is used as an operator parameter, select any enumerated value except {@link OH_NN_TENSOR} from {@link OH_NN_TensorType}. + */ + OH_NN_TensorType type; +} OH_NN_Tensor; + +/** + * @brief Defines the memory structure. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NN_Memory { + /** Pointer to the shared memory. The shared memory is usually allocated by the underlying hardware driver. */ + void * const data; + /** Records the length of the shared memory, in bytes. */ + const size_t length; +} OH_NN_Memory; + +#ifdef __cplusplus +} +#endif // __cplusplus + +/** @} */ +#endif // NEURAL_NETWORK_RUNTIME_TYPE_H diff --git a/arkui/ace_engine/native/BUILD.gn b/arkui/ace_engine/native/BUILD.gn index 5f3fa447bde1741372975640d9a3640856f6487d..67f64f7b4fff512171f1c0228a5bf3761e84c4b2 100644 --- a/arkui/ace_engine/native/BUILD.gn +++ b/arkui/ace_engine/native/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (c) 2021-2022 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/arkui/ace_engine/ace_config.gni") - -if (!is_cross_platform_build) { - ohos_ndk_headers("ace_header") { - dest_dir = "$ndk_headers_out_dir/ace/xcomponent/" - sources = [ - "native_interface_xcomponent.h", - "native_xcomponent_key_event.h", - ] - } - - ohos_ndk_library("libace_ndk") { - ndk_description_file = "./libace.ndk.json" - min_compact_version = "7" - output_name = "ace_ndk" - } -} +# Copyright (c) 2021-2022 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/arkui/ace_engine/ace_config.gni") + +if (!is_cross_platform_build) { + ohos_ndk_headers("ace_header") { + dest_dir = "$ndk_headers_out_dir/ace/xcomponent/" + sources = [ + "native_interface_xcomponent.h", + "native_xcomponent_key_event.h", + ] + } + + ohos_ndk_library("libace_ndk") { + ndk_description_file = "./libace.ndk.json" + min_compact_version = "7" + output_name = "ace_ndk" + } +} diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index bcc196abdbfd6fe9b0d5f58c9c01e04d13ac4b67..a5642feefe00b4ca52284d779ec3eaa1697f7f83 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -1,82 +1,82 @@ -[ - { - "first_introduced": "8", - "name": "OH_NativeXComponent_GetXComponentId" - }, - { - "first_introduced": "8", - "name": "OH_NativeXComponent_GetXComponentSize" - }, - { - "first_introduced": "8", - "name": "OH_NativeXComponent_RegisterCallback" - }, - { - "first_introduced": "8", - "name": "OH_NativeXComponent_GetTouchEvent" - }, - { - "first_introduced": "8", - "name": "OH_NativeXComponent_GetXComponentOffset" - }, - { - "first_introduced": "9", - "name": "OH_NativeXComponent_GetMouseEvent" - }, - { - "first_introduced": "9", - "name": "OH_NativeXComponent_RegisterMouseEventCallback" - }, - { - "first_introduced": "9", - "name": "OH_NativeXComponent_GetTouchPointToolType" - }, - { - "first_introduced": "9", - "name": "OH_NativeXComponent_GetTouchPointTiltX" - }, - { - "first_introduced": "9", - "name": "OH_NativeXComponent_GetTouchPointTiltY" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_RegisterFocusEventCallback" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_RegisterKeyEventCallback" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_RegisterBlurEventCallback" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEvent" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEventAction" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEventCode" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEventSourceType" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEventDeviceId" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetKeyEventTimestamp" - }, - { - "first_introduced": "10", - "name": "OH_NativeXComponent_GetHistoricalPoints" - } +[ + { + "first_introduced": "8", + "name": "OH_NativeXComponent_GetXComponentId" + }, + { + "first_introduced": "8", + "name": "OH_NativeXComponent_GetXComponentSize" + }, + { + "first_introduced": "8", + "name": "OH_NativeXComponent_RegisterCallback" + }, + { + "first_introduced": "8", + "name": "OH_NativeXComponent_GetTouchEvent" + }, + { + "first_introduced": "8", + "name": "OH_NativeXComponent_GetXComponentOffset" + }, + { + "first_introduced": "9", + "name": "OH_NativeXComponent_GetMouseEvent" + }, + { + "first_introduced": "9", + "name": "OH_NativeXComponent_RegisterMouseEventCallback" + }, + { + "first_introduced": "9", + "name": "OH_NativeXComponent_GetTouchPointToolType" + }, + { + "first_introduced": "9", + "name": "OH_NativeXComponent_GetTouchPointTiltX" + }, + { + "first_introduced": "9", + "name": "OH_NativeXComponent_GetTouchPointTiltY" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_RegisterFocusEventCallback" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_RegisterKeyEventCallback" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_RegisterBlurEventCallback" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEvent" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEventAction" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEventCode" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEventSourceType" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEventDeviceId" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetKeyEventTimestamp" + }, + { + "first_introduced": "10", + "name": "OH_NativeXComponent_GetHistoricalPoints" + } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_interface_xcomponent.h b/arkui/ace_engine/native/native_interface_xcomponent.h index fbc9a7f7181f25cc549945e47d48421b7b1fd150..88ac6f6f032fb9d9cc06ed80cac09f21a3e960c2 100644 --- a/arkui/ace_engine/native/native_interface_xcomponent.h +++ b/arkui/ace_engine/native/native_interface_xcomponent.h @@ -1,579 +1,579 @@ -/* - * Copyright (c) 2021-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 OH_NativeXComponent Native XComponent - * @{ - * - * @brief Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES\n - * and media data input and displayed on the ArkUI XComponent. - * - * @since 8 - * @version 1.0 - */ - -/** - * @file native_interface_xcomponent.h - * - * @brief Declares APIs for accessing a Native XComponent. - * - * @since 8 - * @version 1.0 - */ - -#ifndef _NATIVE_INTERFACE_XCOMPONENT_H_ -#define _NATIVE_INTERFACE_XCOMPONENT_H_ - -#include -#include -#include - -#include "native_xcomponent_key_event.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") - -const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128; -const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; - -/** - * @brief Enumerates the API access states. - * - * @since 8 - * @version 1.0 - */ -enum { - /** Successful. */ - OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, - /** Failed. */ - OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, - /** Invalid parameters. */ - OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2, -}; - -typedef enum { - /** Trigger a touch event when a finger is pressed. */ - OH_NATIVEXCOMPONENT_DOWN = 0, - /** Trigger a touch event when a finger is lifted. */ - OH_NATIVEXCOMPONENT_UP, - /** Trigger a touch event when a finger moves on the screen in pressed state. */ - OH_NATIVEXCOMPONENT_MOVE, - /** Trigger an event when a touch event is canceled. */ - OH_NATIVEXCOMPONENT_CANCEL, - /** Invalid touch type. */ - OH_NATIVEXCOMPONENT_UNKNOWN, -} OH_NativeXComponent_TouchEventType; - -/** - * @brief Represents the touch point tool type. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** Indicates invalid tool type. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, - /** Indicates a finger. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, - /** Indicates a stylus. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, - /** Indicates a eraser. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER, - /** Indicates a brush. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, - /** Indicates a pencil. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, - /** Indicates a brush. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, - /** Indicates a mouse. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE, - /** Indicates a lens. */ - OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS, -} OH_NativeXComponent_TouchPointToolType; - -/** - * @brief Represents the touch event source type. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - /** Indicates an unknown input source type. */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, - /** Indicates that the input source generates a mouse multi-touch event. */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, - /** Indicates that the input source generates a touchscreen multi-touch event. */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, - /** Indicates that the input source generates a touchpad multi-touch event. */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD, - /** Indicates that the input source generates a joystick multi-touch event. */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, - /** - * @brief Indicates that the input source generates a keyboard event. - * - * @since 10 - * @version 1.0 - */ - OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD, -} OH_NativeXComponent_EventSourceType; - -/** - * @brief Represents the mouse event action. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, - OH_NATIVEXCOMPONENT_MOUSE_PRESS, - OH_NATIVEXCOMPONENT_MOUSE_RELEASE, - OH_NATIVEXCOMPONENT_MOUSE_MOVE, -} OH_NativeXComponent_MouseEventAction; - -/** - * @brief Represents the mouse event button. - * - * @since 9 - * @version 1.0 - */ -typedef enum { - OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, - OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, - OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, - OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04, - OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, - OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10, -} OH_NativeXComponent_MouseEventButton; - -/** - * @brief Represents the source tool type of TouchEvent - * - * @since 10 - * @version 1.0 - */ -typedef enum { - OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0, - OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER = 1, - OH_NATIVEXCOMPONENT_SOURCETOOL_PEN = 2, - OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER = 3, - OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH = 4, - OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL = 5, - OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH = 6, - OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE = 7, - OH_NATIVEXCOMPONENT_SOURCETOOL_LENS = 8, - OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD = 9, -} OH_NativeXComponent_TouchEvent_SourceTool; - -typedef struct { - /** Unique identifier of a finger. */ - int32_t id; - /** X coordinate of the touch point relative to the left edge of the screen. */ - float screenX; - /** Y coordinate of the touch point relative to the upper edge of the screen. */ - float screenY; - /** X coordinate of the touch point relative to the left edge of the element to touch. */ - float x; - /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ - float y; - /** Touch type of the touch event. */ - OH_NativeXComponent_TouchEventType type; - /** Contact area between the finger pad and the screen. */ - double size; - /** Pressure of the current touch event. */ - float force; - /** Timestamp of the current touch event. */ - int64_t timeStamp; - /** The angle betweenprojection on plane-X-Y and axis-Z of the current touch event. */ - float titlX; - /** The angle betweenprojection on plane-Y-Z and axis-Z of the current touch event. */ - float titlY; - /** The sourceTool of the current touch event. */ - OH_NativeXComponent_TouchEvent_SourceTool sourceTool; -} OH_NativeXComponent_HistoricalPoint; - -typedef struct { - /** Unique identifier of a finger. */ - int32_t id; - /** X coordinate of the touch point relative to the left edge of the screen. */ - float screenX; - /** Y coordinate of the touch point relative to the upper edge of the screen. */ - float screenY; - /** X coordinate of the touch point relative to the left edge of the element to touch. */ - float x; - /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ - float y; - /** Touch type of the touch event. */ - OH_NativeXComponent_TouchEventType type; - /** Contact area between the finger pad and the screen. */ - double size; - /** Pressure of the current touch event. */ - float force; - /** Timestamp of the current touch event. */ - int64_t timeStamp; - /** Whether the current point is pressed. */ - bool isPressed; -} OH_NativeXComponent_TouchPoint; - -// Represents the touch point information. -typedef struct { - /** Unique identifier of a finger. */ - int32_t id; - /** X coordinate of the touch point relative to the left edge of the screen. */ - float screenX; - /** Y coordinate of the touch point relative to the upper edge of the screen. */ - float screenY; - /** X coordinate of the touch point relative to the left edge of the element to touch. */ - float x; - /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ - float y; - /** Touch type of the touch event. */ - OH_NativeXComponent_TouchEventType type; - /** Contact area between the finger pad and the screen. */ - double size; - /** Pressure of the current touch event. */ - float force; - /** ID of the device where the current touch event is generated. */ - int64_t deviceId; - /** Timestamp of the current touch event. */ - int64_t timeStamp; - /** Array of the current touch points. */ - OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; - /** Number of current touch points. */ - uint32_t numPoints; -} OH_NativeXComponent_TouchEvent; - -/** - * @brief Represents the mouse event information. - * - * @since 9 - * @version 1.0 - */ -typedef struct { - /** X coordinate of the mouse point relative to the left edge of the element to mouse. */ - float x; - /** Y coordinate of the mouse point relative to the upper edge of the element to mouse. */ - float y; - /** X coordinate of the mouse point relative to the left edge of the screen. */ - float screenX; - /** Y coordinate of the mouse point relative to the upper edge of the screen. */ - float screenY; - /** Timestamp of the current mouse event. */ - int64_t timestamp; - /** Mouse event action. */ - OH_NativeXComponent_MouseEventAction action; - /** Mouse event button. */ - OH_NativeXComponent_MouseEventButton button; -} OH_NativeXComponent_MouseEvent; - -/** - * @brief Provides an encapsulated OH_NativeXComponent instance. - * - * @since 8 - * @version 1.0 - */ -typedef struct OH_NativeXComponent OH_NativeXComponent; - -/** - * @brief Registers the surface lifecycle and touch event callbacks. - * - * @since 8 - * @version 1.0 - */ -typedef struct OH_NativeXComponent_Callback { - /** Called when the surface is created. */ - void (*OnSurfaceCreated)(OH_NativeXComponent* component, void* window); - /** Called when the surface is changed. */ - void (*OnSurfaceChanged)(OH_NativeXComponent* component, void* window); - /** Called when the surface is destroyed. */ - void (*OnSurfaceDestroyed)(OH_NativeXComponent* component, void* window); - /** Called when a touch event is triggered. */ - void (*DispatchTouchEvent)(OH_NativeXComponent* component, void* window); -} OH_NativeXComponent_Callback; - -/** - * @brief Registers the mouse event callbacks. - * - * @since 9 - * @version 1.0 - */ -typedef struct OH_NativeXComponent_MouseEvent_Callback { - /** Called when a mouse event is triggered. */ - void (*DispatchMouseEvent)(OH_NativeXComponent* component, void* window); - /** Called when a hover event is triggered. */ - void (*DispatchHoverEvent)(OH_NativeXComponent* component, bool isHover); -} OH_NativeXComponent_MouseEvent_Callback; - -struct OH_NativeXComponent_KeyEvent; -/** - * @brief Provides an encapsulated OH_NativeXComponent_KeyEvent instance. - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_NativeXComponent_KeyEvent OH_NativeXComponent_KeyEvent; - -/** - * @brief Obtains the ID of the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param id Indicates the char buffer to keep the ID of this OH_NativeXComponent instance.\n - * Notice that a null-terminator will be appended to the char buffer, so the size of the\n - * char buffer should be at least as large as the size of the real id length plus 1.\n - * It is recommended that the size of the char buffer be [OH_XCOMPONENT_ID_LEN_MAX + 1]. - * @param size Indicates the pointer to the length of id, which you can set and receive. - * @return Returns the status code of the execution. - * @since 8 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size); - -/** - * @brief Obtains the size of the surface held by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param window Indicates the native window handler. - * @param width Indicates the pointer to the width of the current surface. - * @param height Indicates the pointer to the height of the current surface. - * @return Returns the status code of the execution. - * @since 8 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetXComponentSize( - OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height); - -/** - * @brief Obtains the offset of the surface held by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param window Indicates the native window handler. - * @param x Indicates the pointer to the x coordinate of the current surface. - * @param y Indicates the pointer to the y coordinate of the current surface. - * @return Returns the status code of the execution. - * @since 8 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetXComponentOffset( - OH_NativeXComponent* component, const void* window, double* x, double* y); - -/** - * @brief Obtains the touch event dispatched by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param window Indicates the native window handler. - * @param touchEvent Indicates the pointer to the current touch event. - * @return Returns the status code of the execution. - * @since 8 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetTouchEvent( - OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent); - -/** - * @brief Obtains the touch pointer tool type by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param pointIndex Indicates the pointer index in the touchPoints. - * @param toolType Indicates the tool Type of the pointer. - * @return Returns the status code of the execution. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetTouchPointToolType( - OH_NativeXComponent* component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType* toolType); - -/** - * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param pointIndex Indicates the pointer index in the touchPoints. - * @param tiltX Indicates the x tilt of the pointer. - * @return Returns the status code of the execution. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX); - -/** - * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param pointIndex Indicates the pointer index in the touchPoints. - * @param tiltY Indicates the y tilt of the pointer. - * @return Returns the status code of the execution. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY); - -/** - * @brief Obtains the touch event dispatched by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param window Indicates the native window handler. - * @param historicalPoints Indicates the pointer to the current historicalPoints. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window, - int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints); - -/** - * @brief Obtains the mouse event dispatched by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param window Indicates the native window handler. - * @param mouseEvent Indicates the pointer to the current mouse event. - * @return Returns the status code of the execution. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetMouseEvent( - OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent); - -/** - * @brief Registers a callback for this OH_NativeXComponent instance. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param callback Indicates the pointer to a surface lifecycle and touch event callback. - * @return Returns the status code of the execution. - * @since 8 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback); - -/** - * @brief Registers a callback for this OH_NativeXComponent instance. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param callback Indicates the pointer to a mouse event callback. - * @return Returns the status code of the execution. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterMouseEventCallback( - OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback); - -/** - * @brief Registers a callback for this OH_NativeXComponent instance. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param callback Indicates the pointer to a focus event callback. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterFocusEventCallback( - OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); - -/** - * @brief Registers a callback for this OH_NativeXComponent instance. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param callback Indicates the pointer to a key event callback. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterKeyEventCallback( - OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); - -/** - * @brief Registers a callback for this OH_NativeXComponent instance. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param callback Indicates the pointer to a blur event callback. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_RegisterBlurEventCallback( - OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); - -/** - * @brief Obtains the key event dispatched by the ArkUI XComponent. - * - * @param component Indicates the pointer to this OH_NativeXComponent instance. - * @param keyEvent Indicates the pointer to pointer of OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent); - -/** - * @brief Obtains the action of the key event. - * - * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. - * @param action Indicates the action of the OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEventAction( - OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action); - -/** - * @brief Obtains the keyCode of the key event. - * - * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. - * @param code Indicates the keyCode of the OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code); - -/** - * @brief Obtains the sourceType of the key event. - * - * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. - * @param sourceType Indicates the sourceType of the OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEventSourceType( - OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType); - -/** - * @brief Obtains the deviceId of the key event. - * - * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. - * @param deviceId Indicates the deviceId of the OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId); - -/** - * @brief Obtains the timestamp of the key event. - * - * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. - * @param timestamp Indicates the timestamp of the OH_NativeXComponent_KeyEvent instance. - * @return Returns the status code of the execution. - * @since 10 - * @version 1.0 - */ -int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp); - -#ifdef __cplusplus -}; -#endif -#endif // _NATIVE_INTERFACE_XCOMPONENT_H_ +/* + * Copyright (c) 2021-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 OH_NativeXComponent Native XComponent + * @{ + * + * @brief Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES\n + * and media data input and displayed on the ArkUI XComponent. + * + * @since 8 + * @version 1.0 + */ + +/** + * @file native_interface_xcomponent.h + * + * @brief Declares APIs for accessing a Native XComponent. + * + * @since 8 + * @version 1.0 + */ + +#ifndef _NATIVE_INTERFACE_XCOMPONENT_H_ +#define _NATIVE_INTERFACE_XCOMPONENT_H_ + +#include +#include +#include + +#include "native_xcomponent_key_event.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") + +const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128; +const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; + +/** + * @brief Enumerates the API access states. + * + * @since 8 + * @version 1.0 + */ +enum { + /** Successful. */ + OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, + /** Failed. */ + OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, + /** Invalid parameters. */ + OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2, +}; + +typedef enum { + /** Trigger a touch event when a finger is pressed. */ + OH_NATIVEXCOMPONENT_DOWN = 0, + /** Trigger a touch event when a finger is lifted. */ + OH_NATIVEXCOMPONENT_UP, + /** Trigger a touch event when a finger moves on the screen in pressed state. */ + OH_NATIVEXCOMPONENT_MOVE, + /** Trigger an event when a touch event is canceled. */ + OH_NATIVEXCOMPONENT_CANCEL, + /** Invalid touch type. */ + OH_NATIVEXCOMPONENT_UNKNOWN, +} OH_NativeXComponent_TouchEventType; + +/** + * @brief Represents the touch point tool type. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** Indicates invalid tool type. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, + /** Indicates a finger. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, + /** Indicates a stylus. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, + /** Indicates a eraser. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER, + /** Indicates a brush. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, + /** Indicates a pencil. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, + /** Indicates a brush. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, + /** Indicates a mouse. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE, + /** Indicates a lens. */ + OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS, +} OH_NativeXComponent_TouchPointToolType; + +/** + * @brief Represents the touch event source type. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + /** Indicates an unknown input source type. */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, + /** Indicates that the input source generates a mouse multi-touch event. */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, + /** Indicates that the input source generates a touchscreen multi-touch event. */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, + /** Indicates that the input source generates a touchpad multi-touch event. */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD, + /** Indicates that the input source generates a joystick multi-touch event. */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, + /** + * @brief Indicates that the input source generates a keyboard event. + * + * @since 10 + * @version 1.0 + */ + OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD, +} OH_NativeXComponent_EventSourceType; + +/** + * @brief Represents the mouse event action. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, + OH_NATIVEXCOMPONENT_MOUSE_PRESS, + OH_NATIVEXCOMPONENT_MOUSE_RELEASE, + OH_NATIVEXCOMPONENT_MOUSE_MOVE, +} OH_NativeXComponent_MouseEventAction; + +/** + * @brief Represents the mouse event button. + * + * @since 9 + * @version 1.0 + */ +typedef enum { + OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, + OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, + OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, + OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04, + OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, + OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10, +} OH_NativeXComponent_MouseEventButton; + +/** + * @brief Represents the source tool type of TouchEvent + * + * @since 10 + * @version 1.0 + */ +typedef enum { + OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0, + OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER = 1, + OH_NATIVEXCOMPONENT_SOURCETOOL_PEN = 2, + OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER = 3, + OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH = 4, + OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL = 5, + OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH = 6, + OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE = 7, + OH_NATIVEXCOMPONENT_SOURCETOOL_LENS = 8, + OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD = 9, +} OH_NativeXComponent_TouchEvent_SourceTool; + +typedef struct { + /** Unique identifier of a finger. */ + int32_t id; + /** X coordinate of the touch point relative to the left edge of the screen. */ + float screenX; + /** Y coordinate of the touch point relative to the upper edge of the screen. */ + float screenY; + /** X coordinate of the touch point relative to the left edge of the element to touch. */ + float x; + /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ + float y; + /** Touch type of the touch event. */ + OH_NativeXComponent_TouchEventType type; + /** Contact area between the finger pad and the screen. */ + double size; + /** Pressure of the current touch event. */ + float force; + /** Timestamp of the current touch event. */ + int64_t timeStamp; + /** The angle betweenprojection on plane-X-Y and axis-Z of the current touch event. */ + float titlX; + /** The angle betweenprojection on plane-Y-Z and axis-Z of the current touch event. */ + float titlY; + /** The sourceTool of the current touch event. */ + OH_NativeXComponent_TouchEvent_SourceTool sourceTool; +} OH_NativeXComponent_HistoricalPoint; + +typedef struct { + /** Unique identifier of a finger. */ + int32_t id; + /** X coordinate of the touch point relative to the left edge of the screen. */ + float screenX; + /** Y coordinate of the touch point relative to the upper edge of the screen. */ + float screenY; + /** X coordinate of the touch point relative to the left edge of the element to touch. */ + float x; + /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ + float y; + /** Touch type of the touch event. */ + OH_NativeXComponent_TouchEventType type; + /** Contact area between the finger pad and the screen. */ + double size; + /** Pressure of the current touch event. */ + float force; + /** Timestamp of the current touch event. */ + int64_t timeStamp; + /** Whether the current point is pressed. */ + bool isPressed; +} OH_NativeXComponent_TouchPoint; + +// Represents the touch point information. +typedef struct { + /** Unique identifier of a finger. */ + int32_t id; + /** X coordinate of the touch point relative to the left edge of the screen. */ + float screenX; + /** Y coordinate of the touch point relative to the upper edge of the screen. */ + float screenY; + /** X coordinate of the touch point relative to the left edge of the element to touch. */ + float x; + /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ + float y; + /** Touch type of the touch event. */ + OH_NativeXComponent_TouchEventType type; + /** Contact area between the finger pad and the screen. */ + double size; + /** Pressure of the current touch event. */ + float force; + /** ID of the device where the current touch event is generated. */ + int64_t deviceId; + /** Timestamp of the current touch event. */ + int64_t timeStamp; + /** Array of the current touch points. */ + OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; + /** Number of current touch points. */ + uint32_t numPoints; +} OH_NativeXComponent_TouchEvent; + +/** + * @brief Represents the mouse event information. + * + * @since 9 + * @version 1.0 + */ +typedef struct { + /** X coordinate of the mouse point relative to the left edge of the element to mouse. */ + float x; + /** Y coordinate of the mouse point relative to the upper edge of the element to mouse. */ + float y; + /** X coordinate of the mouse point relative to the left edge of the screen. */ + float screenX; + /** Y coordinate of the mouse point relative to the upper edge of the screen. */ + float screenY; + /** Timestamp of the current mouse event. */ + int64_t timestamp; + /** Mouse event action. */ + OH_NativeXComponent_MouseEventAction action; + /** Mouse event button. */ + OH_NativeXComponent_MouseEventButton button; +} OH_NativeXComponent_MouseEvent; + +/** + * @brief Provides an encapsulated OH_NativeXComponent instance. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_NativeXComponent OH_NativeXComponent; + +/** + * @brief Registers the surface lifecycle and touch event callbacks. + * + * @since 8 + * @version 1.0 + */ +typedef struct OH_NativeXComponent_Callback { + /** Called when the surface is created. */ + void (*OnSurfaceCreated)(OH_NativeXComponent* component, void* window); + /** Called when the surface is changed. */ + void (*OnSurfaceChanged)(OH_NativeXComponent* component, void* window); + /** Called when the surface is destroyed. */ + void (*OnSurfaceDestroyed)(OH_NativeXComponent* component, void* window); + /** Called when a touch event is triggered. */ + void (*DispatchTouchEvent)(OH_NativeXComponent* component, void* window); +} OH_NativeXComponent_Callback; + +/** + * @brief Registers the mouse event callbacks. + * + * @since 9 + * @version 1.0 + */ +typedef struct OH_NativeXComponent_MouseEvent_Callback { + /** Called when a mouse event is triggered. */ + void (*DispatchMouseEvent)(OH_NativeXComponent* component, void* window); + /** Called when a hover event is triggered. */ + void (*DispatchHoverEvent)(OH_NativeXComponent* component, bool isHover); +} OH_NativeXComponent_MouseEvent_Callback; + +struct OH_NativeXComponent_KeyEvent; +/** + * @brief Provides an encapsulated OH_NativeXComponent_KeyEvent instance. + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_NativeXComponent_KeyEvent OH_NativeXComponent_KeyEvent; + +/** + * @brief Obtains the ID of the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param id Indicates the char buffer to keep the ID of this OH_NativeXComponent instance.\n + * Notice that a null-terminator will be appended to the char buffer, so the size of the\n + * char buffer should be at least as large as the size of the real id length plus 1.\n + * It is recommended that the size of the char buffer be [OH_XCOMPONENT_ID_LEN_MAX + 1]. + * @param size Indicates the pointer to the length of id, which you can set and receive. + * @return Returns the status code of the execution. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size); + +/** + * @brief Obtains the size of the surface held by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param window Indicates the native window handler. + * @param width Indicates the pointer to the width of the current surface. + * @param height Indicates the pointer to the height of the current surface. + * @return Returns the status code of the execution. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetXComponentSize( + OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height); + +/** + * @brief Obtains the offset of the surface held by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param window Indicates the native window handler. + * @param x Indicates the pointer to the x coordinate of the current surface. + * @param y Indicates the pointer to the y coordinate of the current surface. + * @return Returns the status code of the execution. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetXComponentOffset( + OH_NativeXComponent* component, const void* window, double* x, double* y); + +/** + * @brief Obtains the touch event dispatched by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param window Indicates the native window handler. + * @param touchEvent Indicates the pointer to the current touch event. + * @return Returns the status code of the execution. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetTouchEvent( + OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent); + +/** + * @brief Obtains the touch pointer tool type by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param pointIndex Indicates the pointer index in the touchPoints. + * @param toolType Indicates the tool Type of the pointer. + * @return Returns the status code of the execution. + * @since 9 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetTouchPointToolType( + OH_NativeXComponent* component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType* toolType); + +/** + * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param pointIndex Indicates the pointer index in the touchPoints. + * @param tiltX Indicates the x tilt of the pointer. + * @return Returns the status code of the execution. + * @since 9 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX); + +/** + * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param pointIndex Indicates the pointer index in the touchPoints. + * @param tiltY Indicates the y tilt of the pointer. + * @return Returns the status code of the execution. + * @since 9 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY); + +/** + * @brief Obtains the touch event dispatched by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param window Indicates the native window handler. + * @param historicalPoints Indicates the pointer to the current historicalPoints. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window, + int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints); + +/** + * @brief Obtains the mouse event dispatched by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param window Indicates the native window handler. + * @param mouseEvent Indicates the pointer to the current mouse event. + * @return Returns the status code of the execution. + * @since 9 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetMouseEvent( + OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a surface lifecycle and touch event callback. + * @return Returns the status code of the execution. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a mouse event callback. + * @return Returns the status code of the execution. + * @since 9 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterMouseEventCallback( + OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a focus event callback. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterFocusEventCallback( + OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a key event callback. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterKeyEventCallback( + OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); + +/** + * @brief Registers a callback for this OH_NativeXComponent instance. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param callback Indicates the pointer to a blur event callback. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_RegisterBlurEventCallback( + OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); + +/** + * @brief Obtains the key event dispatched by the ArkUI XComponent. + * + * @param component Indicates the pointer to this OH_NativeXComponent instance. + * @param keyEvent Indicates the pointer to pointer of OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent); + +/** + * @brief Obtains the action of the key event. + * + * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. + * @param action Indicates the action of the OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEventAction( + OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action); + +/** + * @brief Obtains the keyCode of the key event. + * + * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. + * @param code Indicates the keyCode of the OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code); + +/** + * @brief Obtains the sourceType of the key event. + * + * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. + * @param sourceType Indicates the sourceType of the OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEventSourceType( + OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType); + +/** + * @brief Obtains the deviceId of the key event. + * + * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. + * @param deviceId Indicates the deviceId of the OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId); + +/** + * @brief Obtains the timestamp of the key event. + * + * @param keyEvent Indicates the pointer to this OH_NativeXComponent_KeyEvent instance. + * @param timestamp Indicates the timestamp of the OH_NativeXComponent_KeyEvent instance. + * @return Returns the status code of the execution. + * @since 10 + * @version 1.0 + */ +int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp); + +#ifdef __cplusplus +}; +#endif +#endif // _NATIVE_INTERFACE_XCOMPONENT_H_ diff --git a/arkui/ace_engine/native/native_xcomponent_key_event.h b/arkui/ace_engine/native/native_xcomponent_key_event.h index 5445692b062463188a7cc1e287881200aff978f9..56a6df083cd3a87cf0de113c7c4934596b383676 100644 --- a/arkui/ace_engine/native/native_xcomponent_key_event.h +++ b/arkui/ace_engine/native/native_xcomponent_key_event.h @@ -1,391 +1,391 @@ -/* - * Copyright (c) 2021-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 OH_NativeXComponent Native XComponent - * @{ - */ - -/** - * @file native_xcomponent_key_event.h - * - * @brief Declares enums for key event of Native XComponent. - * - * @since 10 - * @version 1.0 - */ - -#ifndef _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ -#define _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Represents the key event code. - * - * @since 10 - * @version 1.0 - */ -typedef enum { - KEY_UNKNOWN = -1, - KEY_FN = 0, - KEY_HOME = 1, - KEY_BACK = 2, - KEY_MEDIA_PLAY_PAUSE = 10, - KEY_MEDIA_STOP = 11, - KEY_MEDIA_NEXT = 12, - KEY_MEDIA_PREVIOUS = 13, - KEY_MEDIA_REWIND = 14, - KEY_MEDIA_FAST_FORWARD = 15, - KEY_VOLUME_UP = 16, - KEY_VOLUME_DOWN = 17, - KEY_POWER = 18, - KEY_CAMERA = 19, - KEY_VOLUME_MUTE = 22, - KEY_MUTE = 23, - KEY_BRIGHTNESS_UP = 40, - KEY_BRIGHTNESS_DOWN = 41, - KEY_0 = 2000, - KEY_1 = 2001, - KEY_2 = 2002, - KEY_3 = 2003, - KEY_4 = 2004, - KEY_5 = 2005, - KEY_6 = 2006, - KEY_7 = 2007, - KEY_8 = 2008, - KEY_9 = 2009, - KEY_STAR = 2010, - KEY_POUND = 2011, - KEY_DPAD_UP = 2012, - KEY_DPAD_DOWN = 2013, - KEY_DPAD_LEFT = 2014, - KEY_DPAD_RIGHT = 2015, - KEY_DPAD_CENTER = 2016, - KEY_A = 2017, - KEY_B = 2018, - KEY_C = 2019, - KEY_D = 2020, - KEY_E = 2021, - KEY_F = 2022, - KEY_G = 2023, - KEY_H = 2024, - KEY_I = 2025, - KEY_J = 2026, - KEY_K = 2027, - KEY_L = 2028, - KEY_M = 2029, - KEY_N = 2030, - KEY_O = 2031, - KEY_P = 2032, - KEY_Q = 2033, - KEY_R = 2034, - KEY_S = 2035, - KEY_T = 2036, - KEY_U = 2037, - KEY_V = 2038, - KEY_W = 2039, - KEY_X = 2040, - KEY_Y = 2041, - KEY_Z = 2042, - KEY_COMMA = 2043, - KEY_PERIOD = 2044, - KEY_ALT_LEFT = 2045, - KEY_ALT_RIGHT = 2046, - KEY_SHIFT_LEFT = 2047, - KEY_SHIFT_RIGHT = 2048, - KEY_TAB = 2049, - KEY_SPACE = 2050, - KEY_SYM = 2051, - KEY_EXPLORER = 2052, - KEY_ENVELOPE = 2053, - KEY_ENTER = 2054, - KEY_DEL = 2055, - KEY_GRAVE = 2056, - KEY_MINUS = 2057, - KEY_EQUALS = 2058, - KEY_LEFT_BRACKET = 2059, - KEY_RIGHT_BRACKET = 2060, - KEY_BACKSLASH = 2061, - KEY_SEMICOLON = 2062, - KEY_APOSTROPHE = 2063, - KEY_SLASH = 2064, - KEY_AT = 2065, - KEY_PLUS = 2066, - KEY_MENU = 2067, - KEY_PAGE_UP = 2068, - KEY_PAGE_DOWN = 2069, - KEY_ESCAPE = 2070, - KEY_FORWARD_DEL = 2071, - KEY_CTRL_LEFT = 2072, - KEY_CTRL_RIGHT = 2073, - KEY_CAPS_LOCK = 2074, - KEY_SCROLL_LOCK = 2075, - KEY_META_LEFT = 2076, - KEY_META_RIGHT = 2077, - KEY_FUNCTION = 2078, - KEY_SYSRQ = 2079, - KEY_BREAK = 2080, - KEY_MOVE_HOME = 2081, - KEY_MOVE_END = 2082, - KEY_INSERT = 2083, - KEY_FORWARD = 2084, - KEY_MEDIA_PLAY = 2085, - KEY_MEDIA_PAUSE = 2086, - KEY_MEDIA_CLOSE = 2087, - KEY_MEDIA_EJECT = 2088, - KEY_MEDIA_RECORD = 2089, - KEY_F1 = 2090, - KEY_F2 = 2091, - KEY_F3 = 2092, - KEY_F4 = 2093, - KEY_F5 = 2094, - KEY_F6 = 2095, - KEY_F7 = 2096, - KEY_F8 = 2097, - KEY_F9 = 2098, - KEY_F10 = 2099, - KEY_F11 = 2100, - KEY_F12 = 2101, - KEY_NUM_LOCK = 2102, - KEY_NUMPAD_0 = 2103, - KEY_NUMPAD_1 = 2104, - KEY_NUMPAD_2 = 2105, - KEY_NUMPAD_3 = 2106, - KEY_NUMPAD_4 = 2107, - KEY_NUMPAD_5 = 2108, - KEY_NUMPAD_6 = 2109, - KEY_NUMPAD_7 = 2110, - KEY_NUMPAD_8 = 2111, - KEY_NUMPAD_9 = 2112, - KEY_NUMPAD_DIVIDE = 2113, - KEY_NUMPAD_MULTIPLY = 2114, - KEY_NUMPAD_SUBTRACT = 2115, - KEY_NUMPAD_ADD = 2116, - KEY_NUMPAD_DOT = 2117, - KEY_NUMPAD_COMMA = 2118, - KEY_NUMPAD_ENTER = 2119, - KEY_NUMPAD_EQUALS = 2120, - KEY_NUMPAD_LEFT_PAREN = 2121, - KEY_NUMPAD_RIGHT_PAREN = 2122, - KEY_VIRTUAL_MULTITASK = 2210, - KEY_SLEEP = 2600, - KEY_ZENKAKU_HANKAKU = 2601, - KEY_102ND = 2602, - KEY_RO = 2603, - KEY_KATAKANA = 2604, - KEY_HIRAGANA = 2605, - KEY_HENKAN = 2606, - KEY_KATAKANA_HIRAGANA = 2607, - KEY_MUHENKAN = 2608, - KEY_LINEFEED = 2609, - KEY_MACRO = 2610, - KEY_NUMPAD_PLUSMINUS = 2611, - KEY_SCALE = 2612, - KEY_HANGUEL = 2613, - KEY_HANJA = 2614, - KEY_YEN = 2615, - KEY_STOP = 2616, - KEY_AGAIN = 2617, - KEY_PROPS = 2618, - KEY_UNDO = 2619, - KEY_COPY = 2620, - KEY_OPEN = 2621, - KEY_PASTE = 2622, - KEY_FIND = 2623, - KEY_CUT = 2624, - KEY_HELP = 2625, - KEY_CALC = 2626, - KEY_FILE = 2627, - KEY_BOOKMARKS = 2628, - KEY_NEXT = 2629, - KEY_PLAYPAUSE = 2630, - KEY_PREVIOUS = 2631, - KEY_STOPCD = 2632, - KEY_CONFIG = 2634, - KEY_REFRESH = 2635, - KEY_EXIT = 2636, - KEY_EDIT = 2637, - KEY_SCROLLUP = 2638, - KEY_SCROLLDOWN = 2639, - KEY_NEW = 2640, - KEY_REDO = 2641, - KEY_CLOSE = 2642, - KEY_PLAY = 2643, - KEY_BASSBOOST = 2644, - KEY_PRINT = 2645, - KEY_CHAT = 2646, - KEY_FINANCE = 2647, - KEY_CANCEL = 2648, - KEY_KBDILLUM_TOGGLE = 2649, - KEY_KBDILLUM_DOWN = 2650, - KEY_KBDILLUM_UP = 2651, - KEY_SEND = 2652, - KEY_REPLY = 2653, - KEY_FORWARDMAIL = 2654, - KEY_SAVE = 2655, - KEY_DOCUMENTS = 2656, - KEY_VIDEO_NEXT = 2657, - KEY_VIDEO_PREV = 2658, - KEY_BRIGHTNESS_CYCLE = 2659, - KEY_BRIGHTNESS_ZERO = 2660, - KEY_DISPLAY_OFF = 2661, - KEY_BTN_MISC = 2662, - KEY_GOTO = 2663, - KEY_INFO = 2664, - KEY_PROGRAM = 2665, - KEY_PVR = 2666, - KEY_SUBTITLE = 2667, - KEY_FULL_SCREEN = 2668, - KEY_KEYBOARD = 2669, - KEY_ASPECT_RATIO = 2670, - KEY_PC = 2671, - KEY_TV = 2672, - KEY_TV2 = 2673, - KEY_VCR = 2674, - KEY_VCR2 = 2675, - KEY_SAT = 2676, - KEY_CD = 2677, - KEY_TAPE = 2678, - KEY_TUNER = 2679, - KEY_PLAYER = 2680, - KEY_DVD = 2681, - KEY_AUDIO = 2682, - KEY_VIDEO = 2683, - KEY_MEMO = 2684, - KEY_CALENDAR = 2685, - KEY_RED = 2686, - KEY_GREEN = 2687, - KEY_YELLOW = 2688, - KEY_BLUE = 2689, - KEY_CHANNELUP = 2690, - KEY_CHANNELDOWN = 2691, - KEY_LAST = 2692, - KEY_RESTART = 2693, - KEY_SLOW = 2694, - KEY_SHUFFLE = 2695, - KEY_VIDEOPHONE = 2696, - KEY_GAMES = 2697, - KEY_ZOOMIN = 2698, - KEY_ZOOMOUT = 2699, - KEY_ZOOMRESET = 2700, - KEY_WORDPROCESSOR = 2701, - KEY_EDITOR = 2702, - KEY_SPREADSHEET = 2703, - KEY_GRAPHICSEDITOR = 2704, - KEY_PRESENTATION = 2705, - KEY_DATABASE = 2706, - KEY_NEWS = 2707, - KEY_VOICEMAIL = 2708, - KEY_ADDRESSBOOK = 2709, - KEY_MESSENGER = 2710, - KEY_BRIGHTNESS_TOGGLE = 2711, - KEY_SPELLCHECK = 2712, - KEY_COFFEE = 2713, - KEY_MEDIA_REPEAT = 2714, - KEY_IMAGES = 2715, - KEY_BUTTONCONFIG = 2716, - KEY_TASKMANAGER = 2717, - KEY_JOURNAL = 2718, - KEY_CONTROLPANEL = 2719, - KEY_APPSELECT = 2720, - KEY_SCREENSAVER = 2721, - KEY_ASSISTANT = 2722, - KEY_KBD_LAYOUT_NEXT = 2723, - KEY_BRIGHTNESS_MIN = 2724, - KEY_BRIGHTNESS_MAX = 2725, - KEY_KBDINPUTASSIST_PREV = 2726, - KEY_KBDINPUTASSIST_NEXT = 2727, - KEY_KBDINPUTASSIST_PREVGROUP = 2728, - KEY_KBDINPUTASSIST_NEXTGROUP = 2729, - KEY_KBDINPUTASSIST_ACCEPT = 2730, - KEY_KBDINPUTASSIST_CANCEL = 2731, - KEY_FRONT = 2800, - KEY_SETUP = 2801, - KEY_WAKEUP = 2802, - KEY_SENDFILE = 2803, - KEY_DELETEFILE = 2804, - KEY_XFER = 2805, - KEY_PROG1 = 2806, - KEY_PROG2 = 2807, - KEY_MSDOS = 2808, - KEY_SCREENLOCK = 2809, - KEY_DIRECTION_ROTATE_DISPLAY = 2810, - KEY_CYCLEWINDOWS = 2811, - KEY_COMPUTER = 2812, - KEY_EJECTCLOSECD = 2813, - KEY_ISO = 2814, - KEY_MOVE = 2815, - KEY_F13 = 2816, - KEY_F14 = 2817, - KEY_F15 = 2818, - KEY_F16 = 2819, - KEY_F17 = 2820, - KEY_F18 = 2821, - KEY_F19 = 2822, - KEY_F20 = 2823, - KEY_F21 = 2824, - KEY_F22 = 2825, - KEY_F23 = 2826, - KEY_F24 = 2827, - KEY_PROG3 = 2828, - KEY_PROG4 = 2829, - KEY_DASHBOARD = 2830, - KEY_SUSPEND = 2831, - KEY_HP = 2832, - KEY_SOUND = 2833, - KEY_QUESTION = 2834, - KEY_CONNECT = 2836, - KEY_SPORT = 2837, - KEY_SHOP = 2838, - KEY_ALTERASE = 2839, - KEY_SWITCHVIDEOMODE = 2841, - KEY_BATTERY = 2842, - KEY_BLUETOOTH = 2843, - KEY_WLAN = 2844, - KEY_UWB = 2845, - KEY_WWAN_WIMAX = 2846, - KEY_RFKILL = 2847, - KEY_CHANNEL = 3001, - KEY_BTN_0 = 3100, - KEY_BTN_1 = 3101, - KEY_BTN_2 = 3102, - KEY_BTN_3 = 3103, - KEY_BTN_4 = 3104, - KEY_BTN_5 = 3105, - KEY_BTN_6 = 3106, - KEY_BTN_7 = 3107, - KEY_BTN_8 = 3108, - KEY_BTN_9 = 3109, -} OH_NativeXComponent_KeyCode; - -/** - * @brief Represents the key event action. - * - * @since 10 - * @version 1.0 - */ -typedef enum { - OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN = -1, - OH_NATIVEXCOMPONENT_KEY_ACTION_DOWN = 0, - OH_NATIVEXCOMPONENT_KEY_ACTION_UP, -} OH_NativeXComponent_KeyAction; - -#ifdef __cplusplus -}; -#endif -#endif // _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ +/* + * Copyright (c) 2021-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 OH_NativeXComponent Native XComponent + * @{ + */ + +/** + * @file native_xcomponent_key_event.h + * + * @brief Declares enums for key event of Native XComponent. + * + * @since 10 + * @version 1.0 + */ + +#ifndef _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ +#define _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Represents the key event code. + * + * @since 10 + * @version 1.0 + */ +typedef enum { + KEY_UNKNOWN = -1, + KEY_FN = 0, + KEY_HOME = 1, + KEY_BACK = 2, + KEY_MEDIA_PLAY_PAUSE = 10, + KEY_MEDIA_STOP = 11, + KEY_MEDIA_NEXT = 12, + KEY_MEDIA_PREVIOUS = 13, + KEY_MEDIA_REWIND = 14, + KEY_MEDIA_FAST_FORWARD = 15, + KEY_VOLUME_UP = 16, + KEY_VOLUME_DOWN = 17, + KEY_POWER = 18, + KEY_CAMERA = 19, + KEY_VOLUME_MUTE = 22, + KEY_MUTE = 23, + KEY_BRIGHTNESS_UP = 40, + KEY_BRIGHTNESS_DOWN = 41, + KEY_0 = 2000, + KEY_1 = 2001, + KEY_2 = 2002, + KEY_3 = 2003, + KEY_4 = 2004, + KEY_5 = 2005, + KEY_6 = 2006, + KEY_7 = 2007, + KEY_8 = 2008, + KEY_9 = 2009, + KEY_STAR = 2010, + KEY_POUND = 2011, + KEY_DPAD_UP = 2012, + KEY_DPAD_DOWN = 2013, + KEY_DPAD_LEFT = 2014, + KEY_DPAD_RIGHT = 2015, + KEY_DPAD_CENTER = 2016, + KEY_A = 2017, + KEY_B = 2018, + KEY_C = 2019, + KEY_D = 2020, + KEY_E = 2021, + KEY_F = 2022, + KEY_G = 2023, + KEY_H = 2024, + KEY_I = 2025, + KEY_J = 2026, + KEY_K = 2027, + KEY_L = 2028, + KEY_M = 2029, + KEY_N = 2030, + KEY_O = 2031, + KEY_P = 2032, + KEY_Q = 2033, + KEY_R = 2034, + KEY_S = 2035, + KEY_T = 2036, + KEY_U = 2037, + KEY_V = 2038, + KEY_W = 2039, + KEY_X = 2040, + KEY_Y = 2041, + KEY_Z = 2042, + KEY_COMMA = 2043, + KEY_PERIOD = 2044, + KEY_ALT_LEFT = 2045, + KEY_ALT_RIGHT = 2046, + KEY_SHIFT_LEFT = 2047, + KEY_SHIFT_RIGHT = 2048, + KEY_TAB = 2049, + KEY_SPACE = 2050, + KEY_SYM = 2051, + KEY_EXPLORER = 2052, + KEY_ENVELOPE = 2053, + KEY_ENTER = 2054, + KEY_DEL = 2055, + KEY_GRAVE = 2056, + KEY_MINUS = 2057, + KEY_EQUALS = 2058, + KEY_LEFT_BRACKET = 2059, + KEY_RIGHT_BRACKET = 2060, + KEY_BACKSLASH = 2061, + KEY_SEMICOLON = 2062, + KEY_APOSTROPHE = 2063, + KEY_SLASH = 2064, + KEY_AT = 2065, + KEY_PLUS = 2066, + KEY_MENU = 2067, + KEY_PAGE_UP = 2068, + KEY_PAGE_DOWN = 2069, + KEY_ESCAPE = 2070, + KEY_FORWARD_DEL = 2071, + KEY_CTRL_LEFT = 2072, + KEY_CTRL_RIGHT = 2073, + KEY_CAPS_LOCK = 2074, + KEY_SCROLL_LOCK = 2075, + KEY_META_LEFT = 2076, + KEY_META_RIGHT = 2077, + KEY_FUNCTION = 2078, + KEY_SYSRQ = 2079, + KEY_BREAK = 2080, + KEY_MOVE_HOME = 2081, + KEY_MOVE_END = 2082, + KEY_INSERT = 2083, + KEY_FORWARD = 2084, + KEY_MEDIA_PLAY = 2085, + KEY_MEDIA_PAUSE = 2086, + KEY_MEDIA_CLOSE = 2087, + KEY_MEDIA_EJECT = 2088, + KEY_MEDIA_RECORD = 2089, + KEY_F1 = 2090, + KEY_F2 = 2091, + KEY_F3 = 2092, + KEY_F4 = 2093, + KEY_F5 = 2094, + KEY_F6 = 2095, + KEY_F7 = 2096, + KEY_F8 = 2097, + KEY_F9 = 2098, + KEY_F10 = 2099, + KEY_F11 = 2100, + KEY_F12 = 2101, + KEY_NUM_LOCK = 2102, + KEY_NUMPAD_0 = 2103, + KEY_NUMPAD_1 = 2104, + KEY_NUMPAD_2 = 2105, + KEY_NUMPAD_3 = 2106, + KEY_NUMPAD_4 = 2107, + KEY_NUMPAD_5 = 2108, + KEY_NUMPAD_6 = 2109, + KEY_NUMPAD_7 = 2110, + KEY_NUMPAD_8 = 2111, + KEY_NUMPAD_9 = 2112, + KEY_NUMPAD_DIVIDE = 2113, + KEY_NUMPAD_MULTIPLY = 2114, + KEY_NUMPAD_SUBTRACT = 2115, + KEY_NUMPAD_ADD = 2116, + KEY_NUMPAD_DOT = 2117, + KEY_NUMPAD_COMMA = 2118, + KEY_NUMPAD_ENTER = 2119, + KEY_NUMPAD_EQUALS = 2120, + KEY_NUMPAD_LEFT_PAREN = 2121, + KEY_NUMPAD_RIGHT_PAREN = 2122, + KEY_VIRTUAL_MULTITASK = 2210, + KEY_SLEEP = 2600, + KEY_ZENKAKU_HANKAKU = 2601, + KEY_102ND = 2602, + KEY_RO = 2603, + KEY_KATAKANA = 2604, + KEY_HIRAGANA = 2605, + KEY_HENKAN = 2606, + KEY_KATAKANA_HIRAGANA = 2607, + KEY_MUHENKAN = 2608, + KEY_LINEFEED = 2609, + KEY_MACRO = 2610, + KEY_NUMPAD_PLUSMINUS = 2611, + KEY_SCALE = 2612, + KEY_HANGUEL = 2613, + KEY_HANJA = 2614, + KEY_YEN = 2615, + KEY_STOP = 2616, + KEY_AGAIN = 2617, + KEY_PROPS = 2618, + KEY_UNDO = 2619, + KEY_COPY = 2620, + KEY_OPEN = 2621, + KEY_PASTE = 2622, + KEY_FIND = 2623, + KEY_CUT = 2624, + KEY_HELP = 2625, + KEY_CALC = 2626, + KEY_FILE = 2627, + KEY_BOOKMARKS = 2628, + KEY_NEXT = 2629, + KEY_PLAYPAUSE = 2630, + KEY_PREVIOUS = 2631, + KEY_STOPCD = 2632, + KEY_CONFIG = 2634, + KEY_REFRESH = 2635, + KEY_EXIT = 2636, + KEY_EDIT = 2637, + KEY_SCROLLUP = 2638, + KEY_SCROLLDOWN = 2639, + KEY_NEW = 2640, + KEY_REDO = 2641, + KEY_CLOSE = 2642, + KEY_PLAY = 2643, + KEY_BASSBOOST = 2644, + KEY_PRINT = 2645, + KEY_CHAT = 2646, + KEY_FINANCE = 2647, + KEY_CANCEL = 2648, + KEY_KBDILLUM_TOGGLE = 2649, + KEY_KBDILLUM_DOWN = 2650, + KEY_KBDILLUM_UP = 2651, + KEY_SEND = 2652, + KEY_REPLY = 2653, + KEY_FORWARDMAIL = 2654, + KEY_SAVE = 2655, + KEY_DOCUMENTS = 2656, + KEY_VIDEO_NEXT = 2657, + KEY_VIDEO_PREV = 2658, + KEY_BRIGHTNESS_CYCLE = 2659, + KEY_BRIGHTNESS_ZERO = 2660, + KEY_DISPLAY_OFF = 2661, + KEY_BTN_MISC = 2662, + KEY_GOTO = 2663, + KEY_INFO = 2664, + KEY_PROGRAM = 2665, + KEY_PVR = 2666, + KEY_SUBTITLE = 2667, + KEY_FULL_SCREEN = 2668, + KEY_KEYBOARD = 2669, + KEY_ASPECT_RATIO = 2670, + KEY_PC = 2671, + KEY_TV = 2672, + KEY_TV2 = 2673, + KEY_VCR = 2674, + KEY_VCR2 = 2675, + KEY_SAT = 2676, + KEY_CD = 2677, + KEY_TAPE = 2678, + KEY_TUNER = 2679, + KEY_PLAYER = 2680, + KEY_DVD = 2681, + KEY_AUDIO = 2682, + KEY_VIDEO = 2683, + KEY_MEMO = 2684, + KEY_CALENDAR = 2685, + KEY_RED = 2686, + KEY_GREEN = 2687, + KEY_YELLOW = 2688, + KEY_BLUE = 2689, + KEY_CHANNELUP = 2690, + KEY_CHANNELDOWN = 2691, + KEY_LAST = 2692, + KEY_RESTART = 2693, + KEY_SLOW = 2694, + KEY_SHUFFLE = 2695, + KEY_VIDEOPHONE = 2696, + KEY_GAMES = 2697, + KEY_ZOOMIN = 2698, + KEY_ZOOMOUT = 2699, + KEY_ZOOMRESET = 2700, + KEY_WORDPROCESSOR = 2701, + KEY_EDITOR = 2702, + KEY_SPREADSHEET = 2703, + KEY_GRAPHICSEDITOR = 2704, + KEY_PRESENTATION = 2705, + KEY_DATABASE = 2706, + KEY_NEWS = 2707, + KEY_VOICEMAIL = 2708, + KEY_ADDRESSBOOK = 2709, + KEY_MESSENGER = 2710, + KEY_BRIGHTNESS_TOGGLE = 2711, + KEY_SPELLCHECK = 2712, + KEY_COFFEE = 2713, + KEY_MEDIA_REPEAT = 2714, + KEY_IMAGES = 2715, + KEY_BUTTONCONFIG = 2716, + KEY_TASKMANAGER = 2717, + KEY_JOURNAL = 2718, + KEY_CONTROLPANEL = 2719, + KEY_APPSELECT = 2720, + KEY_SCREENSAVER = 2721, + KEY_ASSISTANT = 2722, + KEY_KBD_LAYOUT_NEXT = 2723, + KEY_BRIGHTNESS_MIN = 2724, + KEY_BRIGHTNESS_MAX = 2725, + KEY_KBDINPUTASSIST_PREV = 2726, + KEY_KBDINPUTASSIST_NEXT = 2727, + KEY_KBDINPUTASSIST_PREVGROUP = 2728, + KEY_KBDINPUTASSIST_NEXTGROUP = 2729, + KEY_KBDINPUTASSIST_ACCEPT = 2730, + KEY_KBDINPUTASSIST_CANCEL = 2731, + KEY_FRONT = 2800, + KEY_SETUP = 2801, + KEY_WAKEUP = 2802, + KEY_SENDFILE = 2803, + KEY_DELETEFILE = 2804, + KEY_XFER = 2805, + KEY_PROG1 = 2806, + KEY_PROG2 = 2807, + KEY_MSDOS = 2808, + KEY_SCREENLOCK = 2809, + KEY_DIRECTION_ROTATE_DISPLAY = 2810, + KEY_CYCLEWINDOWS = 2811, + KEY_COMPUTER = 2812, + KEY_EJECTCLOSECD = 2813, + KEY_ISO = 2814, + KEY_MOVE = 2815, + KEY_F13 = 2816, + KEY_F14 = 2817, + KEY_F15 = 2818, + KEY_F16 = 2819, + KEY_F17 = 2820, + KEY_F18 = 2821, + KEY_F19 = 2822, + KEY_F20 = 2823, + KEY_F21 = 2824, + KEY_F22 = 2825, + KEY_F23 = 2826, + KEY_F24 = 2827, + KEY_PROG3 = 2828, + KEY_PROG4 = 2829, + KEY_DASHBOARD = 2830, + KEY_SUSPEND = 2831, + KEY_HP = 2832, + KEY_SOUND = 2833, + KEY_QUESTION = 2834, + KEY_CONNECT = 2836, + KEY_SPORT = 2837, + KEY_SHOP = 2838, + KEY_ALTERASE = 2839, + KEY_SWITCHVIDEOMODE = 2841, + KEY_BATTERY = 2842, + KEY_BLUETOOTH = 2843, + KEY_WLAN = 2844, + KEY_UWB = 2845, + KEY_WWAN_WIMAX = 2846, + KEY_RFKILL = 2847, + KEY_CHANNEL = 3001, + KEY_BTN_0 = 3100, + KEY_BTN_1 = 3101, + KEY_BTN_2 = 3102, + KEY_BTN_3 = 3103, + KEY_BTN_4 = 3104, + KEY_BTN_5 = 3105, + KEY_BTN_6 = 3106, + KEY_BTN_7 = 3107, + KEY_BTN_8 = 3108, + KEY_BTN_9 = 3109, +} OH_NativeXComponent_KeyCode; + +/** + * @brief Represents the key event action. + * + * @since 10 + * @version 1.0 + */ +typedef enum { + OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN = -1, + OH_NATIVEXCOMPONENT_KEY_ACTION_DOWN = 0, + OH_NATIVEXCOMPONENT_KEY_ACTION_UP, +} OH_NativeXComponent_KeyAction; + +#ifdef __cplusplus +}; +#endif +#endif // _NATIVE_INTERFACE_XCOMPONENT_KEY_EVENT_H_ diff --git a/arkui/napi/BUILD.gn b/arkui/napi/BUILD.gn index eea7bc4512e1bcc3fb6dfc06bac9da94e855a452..eab7fbcd0f9a47d55209c76c503e930a14b36b8d 100644 --- a/arkui/napi/BUILD.gn +++ b/arkui/napi/BUILD.gn @@ -1,30 +1,30 @@ -# Copyright (c) 2021 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") - - -ohos_ndk_library("libnapi_ndk") { - ndk_description_file = "./libnapi.ndk.json" - min_compact_version = "1" - output_name = "ace_napi" -} - -ohos_ndk_headers("napi_header") { - dest_dir = "$ndk_headers_out_dir/napi" - sources = [ - "./common.h", - "./native_api.h", - ] +# Copyright (c) 2021 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") + + +ohos_ndk_library("libnapi_ndk") { + ndk_description_file = "./libnapi.ndk.json" + min_compact_version = "1" + output_name = "ace_napi" +} + +ohos_ndk_headers("napi_header") { + dest_dir = "$ndk_headers_out_dir/napi" + sources = [ + "./common.h", + "./native_api.h", + ] } \ No newline at end of file diff --git a/arkui/napi/common.h b/arkui/napi/common.h index 8b7df91a66735ca3d7554c5927e9f7aa87aa99d3..28828d24b7fb2004758852a27c40719637e8dfc9 100644 --- a/arkui/napi/common.h +++ b/arkui/napi/common.h @@ -1,26 +1,26 @@ -/* - * 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. - */ - -#ifndef FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_COMMON_H -#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_COMMON_H - -typedef enum { - napi_qos_background = 0, - napi_qos_utility = 1, - napi_qos_default = 2, - napi_qos_user_initiated = 3, -} napi_qos_t; - +/* + * 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. + */ + +#ifndef FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_COMMON_H +#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_COMMON_H + +typedef enum { + napi_qos_background = 0, + napi_qos_utility = 1, + napi_qos_default = 2, + napi_qos_user_initiated = 3, +} napi_qos_t; + #endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */ \ No newline at end of file diff --git a/arkui/napi/libnapi.ndk.json b/arkui/napi/libnapi.ndk.json index dbc43ff837916e50824704cfb9697ce65e90e077..2ab595d53ed4b431680e3971f08f3a096c1217ba 100644 --- a/arkui/napi/libnapi.ndk.json +++ b/arkui/napi/libnapi.ndk.json @@ -1,135 +1,135 @@ -[ - {"name": "napi_module_register"}, - {"name": "napi_get_last_error_info"}, - {"name": "napi_throw"}, - {"name": "napi_throw_error"}, - {"name": "napi_throw_type_error"}, - {"name": "napi_throw_range_error"}, - {"name": "napi_is_error"}, - {"name": "napi_create_error"}, - {"name": "napi_create_type_error"}, - {"name": "napi_create_range_error"}, - {"name": "napi_get_and_clear_last_exception"}, - {"name": "napi_is_exception_pending"}, - {"name": "napi_fatal_error"}, - {"name": "napi_open_handle_scope"}, - {"name": "napi_close_handle_scope"}, - {"name": "napi_open_escapable_handle_scope"}, - {"name": "napi_close_escapable_handle_scope"}, - {"name": "napi_escape_handle"}, - {"name": "napi_create_reference"}, - {"name": "napi_delete_reference"}, - {"name": "napi_reference_ref"}, - {"name": "napi_reference_unref"}, - {"name": "napi_get_reference_value"}, - {"name": "napi_create_array"}, - {"name": "napi_create_array_with_length"}, - {"name": "napi_create_arraybuffer"}, - {"name": "napi_create_external"}, - {"name": "napi_create_external_arraybuffer"}, - {"name": "napi_create_object"}, - {"name": "napi_create_symbol"}, - {"name": "napi_create_typedarray"}, - {"name": "napi_create_dataview"}, - {"name": "napi_create_int32"}, - {"name": "napi_create_uint32"}, - {"name": "napi_create_int64"}, - {"name": "napi_create_double"}, - {"name": "napi_create_string_latin1"}, - {"name": "napi_create_string_utf8"}, - {"name": "napi_create_string_utf16"}, - {"name": "napi_get_array_length"}, - {"name": "napi_get_arraybuffer_info"}, - {"name": "napi_get_prototype"}, - {"name": "napi_get_typedarray_info"}, - {"name": "napi_get_dataview_info"}, - {"name": "napi_get_value_bool"}, - {"name": "napi_get_value_double"}, - {"name": "napi_get_value_external"}, - {"name": "napi_get_value_int32"}, - {"name": "napi_get_value_int64"}, - {"name": "napi_get_value_string_latin1"}, - {"name": "napi_get_value_string_utf8"}, - {"name": "napi_get_value_string_utf16"}, - {"name": "napi_get_value_uint32"}, - {"name": "napi_get_boolean"}, - {"name": "napi_get_global"}, - {"name": "napi_get_null"}, - {"name": "napi_get_undefined"}, - {"name": "napi_coerce_to_bool"}, - {"name": "napi_coerce_to_number"}, - {"name": "napi_coerce_to_object"}, - {"name": "napi_coerce_to_string"}, - {"name": "napi_typeof"}, - {"name": "napi_instanceof"}, - {"name": "napi_is_array"}, - {"name": "napi_is_arraybuffer"}, - {"name": "napi_is_typedarray"}, - {"name": "napi_is_dataview"}, - {"name": "napi_is_date"}, - {"name": "napi_strict_equals"}, - {"name": "napi_get_property_names"}, - {"name": "napi_get_all_property_names"}, - {"name": "napi_set_property"}, - {"name": "napi_get_property"}, - {"name": "napi_has_property"}, - {"name": "napi_check_object_type_tag"}, - {"name": "napi_type_tag_object"}, - {"name": "napi_delete_property"}, - {"name": "napi_has_own_property"}, - {"name": "napi_set_named_property"}, - {"name": "napi_get_named_property"}, - {"name": "napi_has_named_property"}, - {"name": "napi_set_element"}, - {"name": "napi_get_element"}, - {"name": "napi_has_element"}, - {"name": "napi_delete_element"}, - {"name": "napi_define_properties"}, - {"name": "napi_call_function"}, - {"name": "napi_create_function"}, - {"name": "napi_get_cb_info"}, - {"name": "napi_get_new_target"}, - {"name": "napi_new_instance"}, - {"name": "napi_define_class"}, - {"name": "napi_wrap"}, - {"name": "napi_unwrap"}, - {"name": "napi_remove_wrap"}, - {"name": "napi_create_async_work"}, - {"name": "napi_delete_async_work"}, - {"name": "napi_queue_async_work"}, - {"name": "napi_cancel_async_work"}, - {"name": "napi_get_node_version"}, - {"name": "napi_get_version"}, - {"name": "napi_create_promise"}, - {"name": "napi_resolve_deferred"}, - {"name": "napi_reject_deferred"}, - {"name": "napi_is_promise"}, - {"name": "napi_run_script"}, - {"name": "napi_get_uv_event_loop"}, - {"name": "napi_run_script_path"}, - {"name": "napi_create_threadsafe_function"}, - {"name": "napi_get_threadsafe_function_context"}, - {"name": "napi_call_threadsafe_function"}, - {"name": "napi_acquire_threadsafe_function"}, - {"name": "napi_release_threadsafe_function"}, - {"name": "napi_unref_threadsafe_function"}, - {"name": "napi_ref_threadsafe_function"}, - {"name": "napi_create_date"}, - {"name": "napi_get_date_value"}, - {"name": "napi_create_bigint_int64"}, - {"name": "napi_create_bigint_uint64"}, - {"name": "napi_create_bigint_words"}, - {"name": "napi_get_value_bigint_int64"}, - {"name": "napi_get_value_bigint_uint64"}, - {"name": "napi_get_value_bigint_words"}, - {"name": "napi_object_freeze"}, - {"name": "napi_object_seal"}, - {"name": "napi_detach_arraybuffer"}, - {"name": "napi_is_detached_arraybuffer"}, - {"name": "napi_is_buffer"}, - {"name": "napi_create_buffer"}, - {"name": "napi_create_buffer_copy"}, - {"name": "napi_create_external_buffer"}, - {"name": "napi_get_buffer_info"}, - {"name": "napi_queue_async_work_with_qos"} +[ + {"name": "napi_module_register"}, + {"name": "napi_get_last_error_info"}, + {"name": "napi_throw"}, + {"name": "napi_throw_error"}, + {"name": "napi_throw_type_error"}, + {"name": "napi_throw_range_error"}, + {"name": "napi_is_error"}, + {"name": "napi_create_error"}, + {"name": "napi_create_type_error"}, + {"name": "napi_create_range_error"}, + {"name": "napi_get_and_clear_last_exception"}, + {"name": "napi_is_exception_pending"}, + {"name": "napi_fatal_error"}, + {"name": "napi_open_handle_scope"}, + {"name": "napi_close_handle_scope"}, + {"name": "napi_open_escapable_handle_scope"}, + {"name": "napi_close_escapable_handle_scope"}, + {"name": "napi_escape_handle"}, + {"name": "napi_create_reference"}, + {"name": "napi_delete_reference"}, + {"name": "napi_reference_ref"}, + {"name": "napi_reference_unref"}, + {"name": "napi_get_reference_value"}, + {"name": "napi_create_array"}, + {"name": "napi_create_array_with_length"}, + {"name": "napi_create_arraybuffer"}, + {"name": "napi_create_external"}, + {"name": "napi_create_external_arraybuffer"}, + {"name": "napi_create_object"}, + {"name": "napi_create_symbol"}, + {"name": "napi_create_typedarray"}, + {"name": "napi_create_dataview"}, + {"name": "napi_create_int32"}, + {"name": "napi_create_uint32"}, + {"name": "napi_create_int64"}, + {"name": "napi_create_double"}, + {"name": "napi_create_string_latin1"}, + {"name": "napi_create_string_utf8"}, + {"name": "napi_create_string_utf16"}, + {"name": "napi_get_array_length"}, + {"name": "napi_get_arraybuffer_info"}, + {"name": "napi_get_prototype"}, + {"name": "napi_get_typedarray_info"}, + {"name": "napi_get_dataview_info"}, + {"name": "napi_get_value_bool"}, + {"name": "napi_get_value_double"}, + {"name": "napi_get_value_external"}, + {"name": "napi_get_value_int32"}, + {"name": "napi_get_value_int64"}, + {"name": "napi_get_value_string_latin1"}, + {"name": "napi_get_value_string_utf8"}, + {"name": "napi_get_value_string_utf16"}, + {"name": "napi_get_value_uint32"}, + {"name": "napi_get_boolean"}, + {"name": "napi_get_global"}, + {"name": "napi_get_null"}, + {"name": "napi_get_undefined"}, + {"name": "napi_coerce_to_bool"}, + {"name": "napi_coerce_to_number"}, + {"name": "napi_coerce_to_object"}, + {"name": "napi_coerce_to_string"}, + {"name": "napi_typeof"}, + {"name": "napi_instanceof"}, + {"name": "napi_is_array"}, + {"name": "napi_is_arraybuffer"}, + {"name": "napi_is_typedarray"}, + {"name": "napi_is_dataview"}, + {"name": "napi_is_date"}, + {"name": "napi_strict_equals"}, + {"name": "napi_get_property_names"}, + {"name": "napi_get_all_property_names"}, + {"name": "napi_set_property"}, + {"name": "napi_get_property"}, + {"name": "napi_has_property"}, + {"name": "napi_check_object_type_tag"}, + {"name": "napi_type_tag_object"}, + {"name": "napi_delete_property"}, + {"name": "napi_has_own_property"}, + {"name": "napi_set_named_property"}, + {"name": "napi_get_named_property"}, + {"name": "napi_has_named_property"}, + {"name": "napi_set_element"}, + {"name": "napi_get_element"}, + {"name": "napi_has_element"}, + {"name": "napi_delete_element"}, + {"name": "napi_define_properties"}, + {"name": "napi_call_function"}, + {"name": "napi_create_function"}, + {"name": "napi_get_cb_info"}, + {"name": "napi_get_new_target"}, + {"name": "napi_new_instance"}, + {"name": "napi_define_class"}, + {"name": "napi_wrap"}, + {"name": "napi_unwrap"}, + {"name": "napi_remove_wrap"}, + {"name": "napi_create_async_work"}, + {"name": "napi_delete_async_work"}, + {"name": "napi_queue_async_work"}, + {"name": "napi_cancel_async_work"}, + {"name": "napi_get_node_version"}, + {"name": "napi_get_version"}, + {"name": "napi_create_promise"}, + {"name": "napi_resolve_deferred"}, + {"name": "napi_reject_deferred"}, + {"name": "napi_is_promise"}, + {"name": "napi_run_script"}, + {"name": "napi_get_uv_event_loop"}, + {"name": "napi_run_script_path"}, + {"name": "napi_create_threadsafe_function"}, + {"name": "napi_get_threadsafe_function_context"}, + {"name": "napi_call_threadsafe_function"}, + {"name": "napi_acquire_threadsafe_function"}, + {"name": "napi_release_threadsafe_function"}, + {"name": "napi_unref_threadsafe_function"}, + {"name": "napi_ref_threadsafe_function"}, + {"name": "napi_create_date"}, + {"name": "napi_get_date_value"}, + {"name": "napi_create_bigint_int64"}, + {"name": "napi_create_bigint_uint64"}, + {"name": "napi_create_bigint_words"}, + {"name": "napi_get_value_bigint_int64"}, + {"name": "napi_get_value_bigint_uint64"}, + {"name": "napi_get_value_bigint_words"}, + {"name": "napi_object_freeze"}, + {"name": "napi_object_seal"}, + {"name": "napi_detach_arraybuffer"}, + {"name": "napi_is_detached_arraybuffer"}, + {"name": "napi_is_buffer"}, + {"name": "napi_create_buffer"}, + {"name": "napi_create_buffer_copy"}, + {"name": "napi_create_external_buffer"}, + {"name": "napi_get_buffer_info"}, + {"name": "napi_queue_async_work_with_qos"} ] \ No newline at end of file diff --git a/arkui/napi/native_api.h b/arkui/napi/native_api.h index b4f5d1c6b1cb08cf3d596f030c318cade4b4ec8b..aa0d5a7b4ee40eb5c144b0bea2909b263e5d73df 100644 --- a/arkui/napi/native_api.h +++ b/arkui/napi/native_api.h @@ -1,130 +1,130 @@ -/* - * Copyright (c) 2021 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 FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H -#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H - -#ifndef NAPI_VERSION -#define NAPI_VERSION 8 -#endif - -#ifndef NAPI_EXPERIMENTAL -#define NAPI_EXPERIMENTAL -#endif - -#include "common.h" -#include "node_api.h" - -#ifdef NAPI_TEST -#ifdef _WIN32 -#define NAPI_INNER_EXTERN __declspec(dllexport) -#else -#define NAPI_INNER_EXTERN __attribute__((visibility("default"))) -#endif -#else -#ifdef _WIN32 -#define NAPI_INNER_EXTERN __declspec(deprecated) -#else -#define NAPI_INNER_EXTERN __attribute__((__deprecated__)) -#endif -#endif - -NAPI_INNER_EXTERN napi_status napi_set_instance_data(napi_env env, - void* data, - napi_finalize finalize_cb, - void* finalize_hint); - -NAPI_INNER_EXTERN napi_status napi_get_instance_data(napi_env env, - void** data); - -NAPI_INNER_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err); - -NAPI_INNER_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, - void (*fun)(void* arg), - void* arg); - -NAPI_INNER_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, - void (*fun)(void* arg), - void* arg); - -NAPI_INNER_EXTERN napi_status napi_add_async_cleanup_hook( - napi_env env, - napi_async_cleanup_hook hook, - void* arg, - napi_async_cleanup_hook_handle* remove_handle); - -NAPI_INNER_EXTERN napi_status napi_remove_async_cleanup_hook( - napi_async_cleanup_hook_handle remove_handle); - -NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env, - const char16_t* str, - size_t length, - napi_value* result); - -NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env, - napi_value value, - char16_t* buf, - size_t bufsize, - size_t* result); - -NAPI_EXTERN napi_status napi_type_tag_object(napi_env env, - napi_value value, - const napi_type_tag* type_tag); - -NAPI_EXTERN napi_status napi_check_object_type_tag(napi_env env, - napi_value value, - const napi_type_tag* type_tag, - bool* result); - -NAPI_INNER_EXTERN napi_status napi_add_finalizer(napi_env env, - napi_value js_object, - void* native_object, - napi_finalize finalize_cb, - void* finalize_hint, - napi_ref* result); - -NAPI_INNER_EXTERN napi_status napi_async_init(napi_env env, - napi_value async_resource, - napi_value async_resource_name, - napi_async_context* result); - -NAPI_INNER_EXTERN napi_status napi_async_destroy(napi_env env, - napi_async_context async_context); - -NAPI_INNER_EXTERN napi_status napi_open_callback_scope(napi_env env, - napi_value resource_object, - napi_async_context context, - napi_callback_scope* result); - -NAPI_INNER_EXTERN napi_status napi_close_callback_scope(napi_env env, - napi_callback_scope scope); - -NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env, - int64_t change_in_bytes, - int64_t* adjusted_value); - -NAPI_INNER_EXTERN napi_status node_api_get_module_file_name(napi_env env, const char** result); - -#ifdef __cplusplus -extern "C" { -#endif - -NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result); -NAPI_EXTERN napi_status napi_queue_async_work_with_qos(napi_env env, napi_async_work work, napi_qos_t qos); - -#ifdef __cplusplus -} -#endif -#endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */ +/* + * Copyright (c) 2021 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 FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H +#define FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H + +#ifndef NAPI_VERSION +#define NAPI_VERSION 8 +#endif + +#ifndef NAPI_EXPERIMENTAL +#define NAPI_EXPERIMENTAL +#endif + +#include "common.h" +#include "node_api.h" + +#ifdef NAPI_TEST +#ifdef _WIN32 +#define NAPI_INNER_EXTERN __declspec(dllexport) +#else +#define NAPI_INNER_EXTERN __attribute__((visibility("default"))) +#endif +#else +#ifdef _WIN32 +#define NAPI_INNER_EXTERN __declspec(deprecated) +#else +#define NAPI_INNER_EXTERN __attribute__((__deprecated__)) +#endif +#endif + +NAPI_INNER_EXTERN napi_status napi_set_instance_data(napi_env env, + void* data, + napi_finalize finalize_cb, + void* finalize_hint); + +NAPI_INNER_EXTERN napi_status napi_get_instance_data(napi_env env, + void** data); + +NAPI_INNER_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err); + +NAPI_INNER_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); + +NAPI_INNER_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); + +NAPI_INNER_EXTERN napi_status napi_add_async_cleanup_hook( + napi_env env, + napi_async_cleanup_hook hook, + void* arg, + napi_async_cleanup_hook_handle* remove_handle); + +NAPI_INNER_EXTERN napi_status napi_remove_async_cleanup_hook( + napi_async_cleanup_hook_handle remove_handle); + +NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env, + const char16_t* str, + size_t length, + napi_value* result); + +NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env, + napi_value value, + char16_t* buf, + size_t bufsize, + size_t* result); + +NAPI_EXTERN napi_status napi_type_tag_object(napi_env env, + napi_value value, + const napi_type_tag* type_tag); + +NAPI_EXTERN napi_status napi_check_object_type_tag(napi_env env, + napi_value value, + const napi_type_tag* type_tag, + bool* result); + +NAPI_INNER_EXTERN napi_status napi_add_finalizer(napi_env env, + napi_value js_object, + void* native_object, + napi_finalize finalize_cb, + void* finalize_hint, + napi_ref* result); + +NAPI_INNER_EXTERN napi_status napi_async_init(napi_env env, + napi_value async_resource, + napi_value async_resource_name, + napi_async_context* result); + +NAPI_INNER_EXTERN napi_status napi_async_destroy(napi_env env, + napi_async_context async_context); + +NAPI_INNER_EXTERN napi_status napi_open_callback_scope(napi_env env, + napi_value resource_object, + napi_async_context context, + napi_callback_scope* result); + +NAPI_INNER_EXTERN napi_status napi_close_callback_scope(napi_env env, + napi_callback_scope scope); + +NAPI_INNER_EXTERN napi_status napi_adjust_external_memory(napi_env env, + int64_t change_in_bytes, + int64_t* adjusted_value); + +NAPI_INNER_EXTERN napi_status node_api_get_module_file_name(napi_env env, const char** result); + +#ifdef __cplusplus +extern "C" { +#endif + +NAPI_EXTERN napi_status napi_run_script_path(napi_env env, const char* path, napi_value* result); +NAPI_EXTERN napi_status napi_queue_async_work_with_qos(napi_env env, napi_async_work work, napi_qos_t qos); + +#ifdef __cplusplus +} +#endif +#endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */ diff --git a/bundlemanager/bundle_framework/bundle/BUILD.gn b/bundlemanager/bundle_framework/bundle/BUILD.gn index 1a834d911ed312dc20a1d64444a5df74e364ac92..dbbd3ab184621708a5e12ba1b20c6672cc2cdc2b 100644 --- a/bundlemanager/bundle_framework/bundle/BUILD.gn +++ b/bundlemanager/bundle_framework/bundle/BUILD.gn @@ -1,28 +1,28 @@ -# Copyright (c) 2022 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") - -config("bundle_ndk_config") { - include_dirs = [ "include" ] -} -ohos_ndk_headers("bundle_header") { - dest_dir = "$ndk_headers_out_dir/bundle/" - sources = [ "./include/native_interface_bundle.h" ] -} - -ohos_ndk_library("libbundle_ndk") { - ndk_description_file = "./libbundle.ndk.json" - min_compact_version = "9" - output_name = "bundle_ndk" +# Copyright (c) 2022 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") + +config("bundle_ndk_config") { + include_dirs = [ "include" ] +} +ohos_ndk_headers("bundle_header") { + dest_dir = "$ndk_headers_out_dir/bundle/" + sources = [ "./include/native_interface_bundle.h" ] +} + +ohos_ndk_library("libbundle_ndk") { + ndk_description_file = "./libbundle.ndk.json" + min_compact_version = "9" + output_name = "bundle_ndk" } \ No newline at end of file diff --git a/bundlemanager/bundle_framework/bundle/include/bundle_mgr_proxy_native.h b/bundlemanager/bundle_framework/bundle/include/bundle_mgr_proxy_native.h index 6cf1c4470816553f9a9ab3905560d93c90a78cb9..6ea7d227f34c900c29b9984654d2268666395b12 100644 --- a/bundlemanager/bundle_framework/bundle/include/bundle_mgr_proxy_native.h +++ b/bundlemanager/bundle_framework/bundle/include/bundle_mgr_proxy_native.h @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H -#define FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H - -#include - -#include "application_info.h" -#include "bundle_info.h" -#include "iremote_broker.h" -#include "iremote_object.h" - -namespace OHOS { -namespace AppExecFwk { -class BundleMgrProxyNative { -public: - BundleMgrProxyNative() = default; - virtual ~BundleMgrProxyNative() = default; - - /** - * @brief Obtains the BundleInfo based on calling uid. - * @param bundleName Indicates the application bundle name to be queried. - * @param flags Indicates the information contained in the BundleInfo object to be returned. - * @param bundleInfo Indicates the obtained BundleInfo object. - * @param userId Indicates the user ID. - * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. - */ - bool GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo); - - enum { - GET_BUNDLE_INFO_FOR_SELF_NATIVE = 98 - }; -private: - sptr GetBmsProxy(); - template - bool GetParcelableInfo(uint32_t code, MessageParcel &data, T &parcelableInfo); - bool SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply); -}; -} // namespace AppExecFwk -} // namespace OHOS +/* + * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H +#define FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H + +#include + +#include "application_info.h" +#include "bundle_info.h" +#include "iremote_broker.h" +#include "iremote_object.h" + +namespace OHOS { +namespace AppExecFwk { +class BundleMgrProxyNative { +public: + BundleMgrProxyNative() = default; + virtual ~BundleMgrProxyNative() = default; + + /** + * @brief Obtains the BundleInfo based on calling uid. + * @param bundleName Indicates the application bundle name to be queried. + * @param flags Indicates the information contained in the BundleInfo object to be returned. + * @param bundleInfo Indicates the obtained BundleInfo object. + * @param userId Indicates the user ID. + * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise. + */ + bool GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo); + + enum { + GET_BUNDLE_INFO_FOR_SELF_NATIVE = 98 + }; +private: + sptr GetBmsProxy(); + template + bool GetParcelableInfo(uint32_t code, MessageParcel &data, T &parcelableInfo); + bool SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply); +}; +} // namespace AppExecFwk +} // namespace OHOS #endif // FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H \ No newline at end of file diff --git a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h index d318f867090aeffc30cd952bb8e75ab3d62e514d..66f43205959b116b60bc15d1384a5dbacb315399 100644 --- a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h +++ b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2022 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 Native_Bundle - * @{ - * - * @brief Describes the Native Bundle. - * - * @since 9 - * @version 1.0 - */ - -/** - * @file native_interface_bundle.h - * - * @brief Declares the Bundle-specific function, including function for obtaining application info. - * - * @since 9 - * @version 1.0 - */ -#ifndef FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H -#define FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H - -#ifdef __cplusplus -extern "C" { -#endif -struct OH_NativeBundle_ApplicationInfo { - char* bundleName; - - char* fingerprint; -}; - -/** - * @brief Obtains the application info based on the The current bundle. - * - * @return Returns the application info. - * @since 9 - * @version 1.0 - */ -OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo(); - -#ifdef __cplusplus -}; -#endif -#endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H +/* + * Copyright (c) 2022 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 Native_Bundle + * @{ + * + * @brief Describes the Native Bundle. + * + * @since 9 + * @version 1.0 + */ + +/** + * @file native_interface_bundle.h + * + * @brief Declares the Bundle-specific function, including function for obtaining application info. + * + * @since 9 + * @version 1.0 + */ +#ifndef FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H +#define FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H + +#ifdef __cplusplus +extern "C" { +#endif +struct OH_NativeBundle_ApplicationInfo { + char* bundleName; + + char* fingerprint; +}; + +/** + * @brief Obtains the application info based on the The current bundle. + * + * @return Returns the application info. + * @since 9 + * @version 1.0 + */ +OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo(); + +#ifdef __cplusplus +}; +#endif +#endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H diff --git a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json index c40f8ee411641f2fba9244dcfea736bef87d0daf..ad0f30af1d1ec40872b46e25ea196ec4211a151f 100644 --- a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json +++ b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json @@ -1,6 +1,6 @@ -[ - { - "first_introduced": "9", - "name": "OH_NativeBundle_GetCurrentApplicationInfo" - } -] +[ + { + "first_introduced": "9", + "name": "OH_NativeBundle_GetCurrentApplicationInfo" + } +] diff --git a/commonlibrary/memory_utils/libpurgeablemem/BUILD.gn b/commonlibrary/memory_utils/libpurgeablemem/BUILD.gn index 6ffd6731c1ec8012832cebebbb184c44e61d3f77..6a28652436cae8f27ab92bc91a8585b28fde0df2 100644 --- a/commonlibrary/memory_utils/libpurgeablemem/BUILD.gn +++ b/commonlibrary/memory_utils/libpurgeablemem/BUILD.gn @@ -1,27 +1,27 @@ -# 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. - -import("//build/ohos.gni") - -ohos_ndk_headers("purgeable_memory_header") { - dest_dir = "$ndk_headers_out_dir/purgeable_memory" - sources = [ "./purgeable_memory.h" ] -} - -ohos_ndk_library("libpurgeable_memory_ndk") { - output_name = "purgeable_memory_ndk" - output_extension = "z.so" - ndk_description_file = "./libpurgeable_memory.ndk.json" - system_capability = "SystemCapability.CommonLibrary.Memory.PurgeableMemory" - system_capability = "purgeable_memory/purgeable_memory.h" -} +# 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. + +import("//build/ohos.gni") + +ohos_ndk_headers("purgeable_memory_header") { + dest_dir = "$ndk_headers_out_dir/purgeable_memory" + sources = [ "./purgeable_memory.h" ] +} + +ohos_ndk_library("libpurgeable_memory_ndk") { + output_name = "purgeable_memory_ndk" + output_extension = "z.so" + ndk_description_file = "./libpurgeable_memory.ndk.json" + system_capability = "SystemCapability.CommonLibrary.Memory.PurgeableMemory" + system_capability = "purgeable_memory/purgeable_memory.h" +} diff --git a/commonlibrary/memory_utils/libpurgeablemem/libpurgeable_memory.ndk.json b/commonlibrary/memory_utils/libpurgeablemem/libpurgeable_memory.ndk.json index 02b15f0172891e9779c9a7db92cb4e1f5242addb..21cf38b96ea22d690ebf60a9adf8769b15b50fe8 100644 --- a/commonlibrary/memory_utils/libpurgeablemem/libpurgeable_memory.ndk.json +++ b/commonlibrary/memory_utils/libpurgeablemem/libpurgeable_memory.ndk.json @@ -1,11 +1,11 @@ -[ - { "name": "OH_PurgeableMemory_Create" }, - { "name": "OH_PurgeableMemory_Destroy" }, - { "name": "OH_PurgeableMemory_BeginRead" }, - { "name": "OH_PurgeableMemory_EndRead" }, - { "name": "OH_PurgeableMemory_BeginWrite" }, - { "name": "OH_PurgeableMemory_EndWrite" }, - { "name": "OH_PurgeableMemory_GetContent" }, - { "name": "OH_PurgeableMemory_ContentSize" }, - { "name": "OH_PurgeableMemory_AppendModify" } +[ + { "name": "OH_PurgeableMemory_Create" }, + { "name": "OH_PurgeableMemory_Destroy" }, + { "name": "OH_PurgeableMemory_BeginRead" }, + { "name": "OH_PurgeableMemory_EndRead" }, + { "name": "OH_PurgeableMemory_BeginWrite" }, + { "name": "OH_PurgeableMemory_EndWrite" }, + { "name": "OH_PurgeableMemory_GetContent" }, + { "name": "OH_PurgeableMemory_ContentSize" }, + { "name": "OH_PurgeableMemory_AppendModify" } ] \ No newline at end of file diff --git a/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h b/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h index a228044348e33e324aa8c5df8dbb9378534face3..5ef3a71de5c666718072e2cc355479fca7acfc7c 100644 --- a/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h +++ b/commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h @@ -1,206 +1,206 @@ -/* - * 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 memory - * - * @brief provides memory management capabilities - * - * provides features include operations such as memory alloction, memory free, and so on - * - * @since 10 - * @version 1.0 - */ - -/** - * @file purgeable_memory.h - * - * @brief provides memory management capabilities of purgeable memory. - * - * provides features include create, begin read ,end read, begin write, end write, rebuild, and so on. - * when using, it is necessary to link libpurgeable_memory_ndk.z.so - * - * @since 10 - * @version 1.0 - */ - -#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEMORY_H -#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEMORY_H - -#include /* bool */ -#include /* size_t */ - -#ifdef __cplusplus -extern "C" { -#endif /* End of #ifdef __cplusplus */ - -/* - * @brief Purgeable mem struct - * - * @since 10 - * @version 1.0 - */ -typedef struct PurgMem OH_PurgeableMemory; - -/* - * @brief: function pointer, it points to a function which is used to build content of a PurgMem obj. - * - * - * @param void *: data ptr, points to start address of a PurgMem obj's content. - * @param size_t: data size of the content. - * @param void *: other private parameters. - * @return: build content result, true means success, while false is fail. - * - * @since 10 - * @version 1.0 - */ -typedef bool (*OH_PurgeableMemory_ModifyFunc)(void *, size_t, void *); - -/* - * @brief: create a PurgMem obj. - * - * - * @param size: data size of a PurgMem obj's content. - * @param func: function pointer, it is used to recover data when the PurgMem obj's content is purged. - * @param funcPara: parameters used by @func. - * @return: a PurgMem obj. - * - * @since 10 - * @version 1.0 - */ -OH_PurgeableMemory *OH_PurgeableMemory_Create( - size_t size, OH_PurgeableMemory_ModifyFunc func, void *funcPara); - -/* - * @brief: destroy a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj to be destroyed. - * @return: true is success, while false is fail. return true if @purgObj is NULL. - * If return true, @purgObj will be set to NULL to avoid Use-After-Free. - * - * @since 10 - * @version 1.0 - */ -bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory *purgObj); - -/* - * @brief: begin read a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * @return: return true if @purgObj's content is present. - * If content is purged(no present), system will recover its data, - * return false if content is purged and recovered failed. - * While return true if content recover success. - * OS cannot reclaim the memory of @purgObj's content when this - * function return true, until PurgMemEndRead() is called. - * - * @since 10 - * @version 1.0 - */ -bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory *purgObj); - -/* - * @brief: end read a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * OS may reclaim the memory of @purgObj's content - * at a later time when this function returns. - * - * @since 10 - * @version 1.0 - */ -void OH_PurgeableMemory_EndRead(OH_PurgeableMemory *purgObj); - -/* - * @brief: begin write a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * @return: return true if @purgObj's content is present. - * if content is purged(no present), system will recover its data, - * return false if content is purged and recovered failed. - * While return true if content is successfully recovered. - * OS cannot reclaim the memory of @purgObj's content when this - * function return true, until PurgMemEndWrite() is called. - * - * @since 10 - * @version 1.0 - */ -bool OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory *purgObj); - -/* - * @brief: end write a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * OS may reclaim the memory of @purgObj's content - * at a later time when this function returns. - * - * @since 10 - * @version 1.0 - */ -void OH_PurgeableMemory_EndWrite(OH_PurgeableMemory *purgObj); - -/* - * @brief: get content ptr of a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * @return: return start address of a PurgMem obj's content. - * Return NULL if @purgObj is NULL. - * This function should be protect by PurgMemBeginRead()/PurgMemEndRead() - * or PurgMemBeginWrite()/PurgMemEndWrite() - * - * @since 10 - * @version 1.0 - */ -void *OH_PurgeableMemory_GetContent(OH_PurgeableMemory *purgObj); - -/* - * @brief: get content size of a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * @return: return content size of @purgObj. - * Return 0 if @purgObj is NULL. - * - * @since 10 - * @version 1.0 - */ -size_t OH_PurgeableMemory_ContentSize(OH_PurgeableMemory *purgObj); - -/* - * @brief: append a modify to a PurgMem obj. - * - * - * @param purgObj: a PurgMem obj. - * @param size: data size of a PurgMem obj's content. - * @param func: function pointer, it will modify content of @PurgMem. - * @param funcPara: parameters used by @func. - * @return: append result, true is success, while false is fail. - * - * @since 10 - * @version 1.0 - */ -bool OH_PurgeableMemory_AppendModify(OH_PurgeableMemory *purgObj, - OH_PurgeableMemory_ModifyFunc func, void *funcPara); - -#ifdef __cplusplus -} -#endif /* End of #ifdef __cplusplus */ +/* + * 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 memory + * + * @brief provides memory management capabilities + * + * provides features include operations such as memory alloction, memory free, and so on + * + * @since 10 + * @version 1.0 + */ + +/** + * @file purgeable_memory.h + * + * @brief provides memory management capabilities of purgeable memory. + * + * provides features include create, begin read ,end read, begin write, end write, rebuild, and so on. + * when using, it is necessary to link libpurgeable_memory_ndk.z.so + * + * @since 10 + * @version 1.0 + */ + +#ifndef OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEMORY_H +#define OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEMORY_H + +#include /* bool */ +#include /* size_t */ + +#ifdef __cplusplus +extern "C" { +#endif /* End of #ifdef __cplusplus */ + +/* + * @brief Purgeable mem struct + * + * @since 10 + * @version 1.0 + */ +typedef struct PurgMem OH_PurgeableMemory; + +/* + * @brief: function pointer, it points to a function which is used to build content of a PurgMem obj. + * + * + * @param void *: data ptr, points to start address of a PurgMem obj's content. + * @param size_t: data size of the content. + * @param void *: other private parameters. + * @return: build content result, true means success, while false is fail. + * + * @since 10 + * @version 1.0 + */ +typedef bool (*OH_PurgeableMemory_ModifyFunc)(void *, size_t, void *); + +/* + * @brief: create a PurgMem obj. + * + * + * @param size: data size of a PurgMem obj's content. + * @param func: function pointer, it is used to recover data when the PurgMem obj's content is purged. + * @param funcPara: parameters used by @func. + * @return: a PurgMem obj. + * + * @since 10 + * @version 1.0 + */ +OH_PurgeableMemory *OH_PurgeableMemory_Create( + size_t size, OH_PurgeableMemory_ModifyFunc func, void *funcPara); + +/* + * @brief: destroy a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj to be destroyed. + * @return: true is success, while false is fail. return true if @purgObj is NULL. + * If return true, @purgObj will be set to NULL to avoid Use-After-Free. + * + * @since 10 + * @version 1.0 + */ +bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory *purgObj); + +/* + * @brief: begin read a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * @return: return true if @purgObj's content is present. + * If content is purged(no present), system will recover its data, + * return false if content is purged and recovered failed. + * While return true if content recover success. + * OS cannot reclaim the memory of @purgObj's content when this + * function return true, until PurgMemEndRead() is called. + * + * @since 10 + * @version 1.0 + */ +bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory *purgObj); + +/* + * @brief: end read a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * OS may reclaim the memory of @purgObj's content + * at a later time when this function returns. + * + * @since 10 + * @version 1.0 + */ +void OH_PurgeableMemory_EndRead(OH_PurgeableMemory *purgObj); + +/* + * @brief: begin write a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * @return: return true if @purgObj's content is present. + * if content is purged(no present), system will recover its data, + * return false if content is purged and recovered failed. + * While return true if content is successfully recovered. + * OS cannot reclaim the memory of @purgObj's content when this + * function return true, until PurgMemEndWrite() is called. + * + * @since 10 + * @version 1.0 + */ +bool OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory *purgObj); + +/* + * @brief: end write a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * OS may reclaim the memory of @purgObj's content + * at a later time when this function returns. + * + * @since 10 + * @version 1.0 + */ +void OH_PurgeableMemory_EndWrite(OH_PurgeableMemory *purgObj); + +/* + * @brief: get content ptr of a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * @return: return start address of a PurgMem obj's content. + * Return NULL if @purgObj is NULL. + * This function should be protect by PurgMemBeginRead()/PurgMemEndRead() + * or PurgMemBeginWrite()/PurgMemEndWrite() + * + * @since 10 + * @version 1.0 + */ +void *OH_PurgeableMemory_GetContent(OH_PurgeableMemory *purgObj); + +/* + * @brief: get content size of a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * @return: return content size of @purgObj. + * Return 0 if @purgObj is NULL. + * + * @since 10 + * @version 1.0 + */ +size_t OH_PurgeableMemory_ContentSize(OH_PurgeableMemory *purgObj); + +/* + * @brief: append a modify to a PurgMem obj. + * + * + * @param purgObj: a PurgMem obj. + * @param size: data size of a PurgMem obj's content. + * @param func: function pointer, it will modify content of @PurgMem. + * @param funcPara: parameters used by @func. + * @return: append result, true is success, while false is fail. + * + * @since 10 + * @version 1.0 + */ +bool OH_PurgeableMemory_AppendModify(OH_PurgeableMemory *purgObj, + OH_PurgeableMemory_ModifyFunc func, void *funcPara); + +#ifdef __cplusplus +} +#endif /* End of #ifdef __cplusplus */ #endif /* OHOS_UTILS_MEMORY_LIBPURGEABLEMEM_C_INCLUDE_PURGEABLE_MEMORY_H */ \ No newline at end of file diff --git a/distributeddatamgr/relational_store/BUILD.gn b/distributeddatamgr/relational_store/BUILD.gn index 01334de44290803b45dd45de94b0f63764523f0e..5a103e34c3c66bfe5256710baff20c921c14ff93 100644 --- a/distributeddatamgr/relational_store/BUILD.gn +++ b/distributeddatamgr/relational_store/BUILD.gn @@ -1,43 +1,43 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_rdb_ndk_header") { - dest_dir = "$ndk_headers_out_dir/database/rdb/" - sources = [ - "./include/oh_cursor.h", - "./include/oh_predicates.h", - "./include/oh_value_object.h", - "./include/oh_values_bucket.h", - "./include/relational_store.h", - "./include/relational_store_error_code.h", - ] -} - -ohos_ndk_library("libnative_rdb_ndk") { - output_name = "native_rdb_ndk" - system_capability = - "SystemCapability.DistributedDataManager.RelationalStore.Core" - ndk_description_file = "./libnative_rdb.ndk.json" - min_compact_version = "10" - system_capability_headers = [ - "$ndk_headers_out_dir/database/rdb/oh_cursor.h", - "$ndk_headers_out_dir/database/rdb/oh_predicates.h", - "$ndk_headers_out_dir/database/rdb/oh_value_object.h", - "$ndk_headers_out_dir/database/rdb/oh_values_bucket.h", - "$ndk_headers_out_dir/database/rdb/relational_store.h", - "$ndk_headers_out_dir/database/rdb/relational_store_error_code.h", - ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_rdb_ndk_header") { + dest_dir = "$ndk_headers_out_dir/database/rdb/" + sources = [ + "./include/oh_cursor.h", + "./include/oh_predicates.h", + "./include/oh_value_object.h", + "./include/oh_values_bucket.h", + "./include/relational_store.h", + "./include/relational_store_error_code.h", + ] +} + +ohos_ndk_library("libnative_rdb_ndk") { + output_name = "native_rdb_ndk" + system_capability = + "SystemCapability.DistributedDataManager.RelationalStore.Core" + ndk_description_file = "./libnative_rdb.ndk.json" + min_compact_version = "10" + system_capability_headers = [ + "$ndk_headers_out_dir/database/rdb/oh_cursor.h", + "$ndk_headers_out_dir/database/rdb/oh_predicates.h", + "$ndk_headers_out_dir/database/rdb/oh_value_object.h", + "$ndk_headers_out_dir/database/rdb/oh_values_bucket.h", + "$ndk_headers_out_dir/database/rdb/relational_store.h", + "$ndk_headers_out_dir/database/rdb/relational_store_error_code.h", + ] +} diff --git a/distributeddatamgr/relational_store/include/oh_cursor.h b/distributeddatamgr/relational_store/include/oh_cursor.h index 165da158ee6c968130b3883150ac7f72b2200b0d..e96754901d03a60a587e9809093e5153dfc7120c 100644 --- a/distributeddatamgr/relational_store/include/oh_cursor.h +++ b/distributeddatamgr/relational_store/include/oh_cursor.h @@ -1,254 +1,254 @@ -/* - * 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. - */ - -#ifndef OH_CURSOR_H -#define OH_CURSOR_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - -/** - * @file oh_cursor.h - * - * @brief Provides functions and enumerations related to the resultSet. - * - * @since 10 - */ - -#include -#include -#include -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Indicates the column type. - * - * @since 10 - */ -typedef enum OH_ColumnType { - /** - * Indicates the column type is NULL. - */ - TYPE_NULL = 0, - /** - * Indicates the column type is INT64. - */ - TYPE_INT64, - /** - * Indicates the column type is REAL. - */ - TYPE_REAL, - /** - * Indicates the column type is TEXT. - */ - TYPE_TEXT, - /** - * Indicates the column type is BLOB. - */ - TYPE_BLOB, -} OH_ColumnType; - -/** - * @brief Define the OH_Cursor structure type. - * - * Provides methods for accessing a database result set generated by query the database. - * - * @since 10 - */ -typedef struct OH_Cursor { - /** - * The id used to uniquely identify the OH_Cursor struct. - */ - int64_t id; - /** - * @brief Function pointer. Obtains the total number of columns. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param count This parameter is the output parameter, and the number of columns is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getColumnCount)(OH_Cursor *cursor, int *count); - - /** - * @brief Function pointer. Obtains data type of the given column's value. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based index of the target column. - * @param columnType This parameter is the output parameter, and the column value type is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor, OH_ColumnType. - * @since 10 - */ - int (*getColumnType)(OH_Cursor *cursor, int32_t columnIndex, OH_ColumnType *columnType); - - /** - * @brief Function pointer. Obtains the zero-based index for the given column name. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param name Indicates the name of the column. - * @param columnIndex This parameter is the output parameter, - * and the column index for the given column is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getColumnIndex)(OH_Cursor *cursor, const char *name, int *columnIndex); - - /** - * @brief Function pointer. Obtains the column name at the given column index. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param name This parameter is the output parameter, - * and the column name for the given index is written to this variable. - * @param length Indicates the length of the name. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getColumnName)(OH_Cursor *cursor, int32_t columnIndex, char *name, int length); - - /** - * @brief Function pointer. Obtains the numbers of rows in the result set. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param count This parameter is the output parameter, - * and the numbers of rows in the result set is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getRowCount)(OH_Cursor *cursor, int *count); - - /** - * @brief Function pointer. Move the cursor to the next row. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*goToNextRow)(OH_Cursor *cursor); - - /** - * @brief Function pointer. Obtains the size of blob or text. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param size This parameter is the output parameter, - * and the value size of the requested column is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getSize)(OH_Cursor *cursor, int32_t columnIndex, size_t *size); - - /** - * @brief Function pointer. Obtains the value of the requested column as a string. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param value This parameter is the output parameter, - * and the value of the requested column as a char * is written to this variable. - * @param length Indicates the length of the value, it can be obtained through the OH_Cursor_GetSize function. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getText)(OH_Cursor *cursor, int32_t columnIndex, char *value, int length); - - /** - * @brief Function pointer. Obtains the value of the requested column as a int64_t. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param value This parameter is the output parameter, - * and the value of the requested column as a int64_t is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getInt64)(OH_Cursor *cursor, int32_t columnIndex, int64_t *value); - - /** - * @brief Function pointer. Obtains the value of the requested column as a double. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param value This parameter is the output parameter, - * and the value of the requested column as a double is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getReal)(OH_Cursor *cursor, int32_t columnIndex, double *value); - - /** - * @brief Function pointer. Obtains the value of the requested column as a byte array. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param value This parameter is the output parameter, - * and the value of the requested column as a byte array is written to this variable. - * @param length Indicates the length of the value, it can be obtained through the OH_Cursor_GetSize function. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*getBlob)(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length); - - /** - * @brief Function pointer. Obtains Whether the value of the requested column is null. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @param columnIndex Indicates the zero-based column index. - * @param isNull This parameter is the output parameter, - * and the value whether the column value is null is written to this variable. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*isNull)(OH_Cursor *cursor, int32_t columnIndex, bool *isNull); - - /** - * @brief Function pointer. Destroy the result set, releasing all of its resources and making it completely invalid. - * - * @param cursor Represents a pointer to an {@link OH_Cursor} instance. - * @return Returns the status code of the execution. - * @see OH_Cursor. - * @since 10 - */ - int (*destroy)(OH_Cursor *cursor); -} OH_Cursor; - -#ifdef __cplusplus -}; -#endif - -#endif // OH_CURSOR_H +/* + * 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. + */ + +#ifndef OH_CURSOR_H +#define OH_CURSOR_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_cursor.h + * + * @brief Provides functions and enumerations related to the resultSet. + * + * @since 10 + */ + +#include +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Indicates the column type. + * + * @since 10 + */ +typedef enum OH_ColumnType { + /** + * Indicates the column type is NULL. + */ + TYPE_NULL = 0, + /** + * Indicates the column type is INT64. + */ + TYPE_INT64, + /** + * Indicates the column type is REAL. + */ + TYPE_REAL, + /** + * Indicates the column type is TEXT. + */ + TYPE_TEXT, + /** + * Indicates the column type is BLOB. + */ + TYPE_BLOB, +} OH_ColumnType; + +/** + * @brief Define the OH_Cursor structure type. + * + * Provides methods for accessing a database result set generated by query the database. + * + * @since 10 + */ +typedef struct OH_Cursor { + /** + * The id used to uniquely identify the OH_Cursor struct. + */ + int64_t id; + /** + * @brief Function pointer. Obtains the total number of columns. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param count This parameter is the output parameter, and the number of columns is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnCount)(OH_Cursor *cursor, int *count); + + /** + * @brief Function pointer. Obtains data type of the given column's value. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based index of the target column. + * @param columnType This parameter is the output parameter, and the column value type is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor, OH_ColumnType. + * @since 10 + */ + int (*getColumnType)(OH_Cursor *cursor, int32_t columnIndex, OH_ColumnType *columnType); + + /** + * @brief Function pointer. Obtains the zero-based index for the given column name. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param name Indicates the name of the column. + * @param columnIndex This parameter is the output parameter, + * and the column index for the given column is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnIndex)(OH_Cursor *cursor, const char *name, int *columnIndex); + + /** + * @brief Function pointer. Obtains the column name at the given column index. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param name This parameter is the output parameter, + * and the column name for the given index is written to this variable. + * @param length Indicates the length of the name. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnName)(OH_Cursor *cursor, int32_t columnIndex, char *name, int length); + + /** + * @brief Function pointer. Obtains the numbers of rows in the result set. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param count This parameter is the output parameter, + * and the numbers of rows in the result set is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getRowCount)(OH_Cursor *cursor, int *count); + + /** + * @brief Function pointer. Move the cursor to the next row. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*goToNextRow)(OH_Cursor *cursor); + + /** + * @brief Function pointer. Obtains the size of blob or text. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param size This parameter is the output parameter, + * and the value size of the requested column is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getSize)(OH_Cursor *cursor, int32_t columnIndex, size_t *size); + + /** + * @brief Function pointer. Obtains the value of the requested column as a string. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as a char * is written to this variable. + * @param length Indicates the length of the value, it can be obtained through the OH_Cursor_GetSize function. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getText)(OH_Cursor *cursor, int32_t columnIndex, char *value, int length); + + /** + * @brief Function pointer. Obtains the value of the requested column as a int64_t. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as a int64_t is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getInt64)(OH_Cursor *cursor, int32_t columnIndex, int64_t *value); + + /** + * @brief Function pointer. Obtains the value of the requested column as a double. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as a double is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getReal)(OH_Cursor *cursor, int32_t columnIndex, double *value); + + /** + * @brief Function pointer. Obtains the value of the requested column as a byte array. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as a byte array is written to this variable. + * @param length Indicates the length of the value, it can be obtained through the OH_Cursor_GetSize function. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*getBlob)(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length); + + /** + * @brief Function pointer. Obtains Whether the value of the requested column is null. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param isNull This parameter is the output parameter, + * and the value whether the column value is null is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*isNull)(OH_Cursor *cursor, int32_t columnIndex, bool *isNull); + + /** + * @brief Function pointer. Destroy the result set, releasing all of its resources and making it completely invalid. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 10 + */ + int (*destroy)(OH_Cursor *cursor); +} OH_Cursor; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_CURSOR_H diff --git a/distributeddatamgr/relational_store/include/oh_predicates.h b/distributeddatamgr/relational_store/include/oh_predicates.h index 28808e30ba072bae4ffa1ff8521c7abea8da7bdb..2cd84410f593391b9ec0f8e2d457f61e4e986561 100644 --- a/distributeddatamgr/relational_store/include/oh_predicates.h +++ b/distributeddatamgr/relational_store/include/oh_predicates.h @@ -1,403 +1,403 @@ -/* - * 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. - */ - -#ifndef OH_PREDICATES_H -#define OH_PREDICATES_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - -/** - * @file oh_predicates.h - * - * @brief Declared predicate related functions and enumerations. - * - * @since 10 - */ - -#include -#include -#include "oh_value_object.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Result set sort type. - * - * @since 10 - */ -typedef enum OH_OrderType { - /** - * Ascend order. - */ - ASC = 0, - /** - * Descend order. - */ - DESC = 1, -} OH_OrderType; - -/** - * @brief Define the OH_Predicates structure type. - * - * @since 10 - */ -typedef struct OH_Predicates { - /** - * The id used to uniquely identify the OH_Predicates struct. - */ - int64_t id; - - /** - * @brief Function pointer. Restricts the value of the field to be equal to the specified value to the predicates. - * - * This method is similar to = of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*equalTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be not equal to the specified value to the predicates. - * - * This method is similar to != of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*notEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. Add left parenthesis to predicate. - * - * This method is similar to ( of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*beginWrap)(OH_Predicates *predicates); - - /** - * @brief Function pointer. Add right parenthesis to predicate. - * - * This method is similar to ) of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*endWrap)(OH_Predicates *predicates); - - /** - * @brief Function pointer. Adds an or condition to the predicates. - * - * This method is similar to OR of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*orOperate)(OH_Predicates *predicates); - - /** - * @brief Function pointer. Adds an and condition to the predicates. - * - * This method is similar to AND of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*andOperate)(OH_Predicates *predicates); - - /** - * @brief Function pointer. Restricts the value of the field which is null to the predicates. - * - * This method is similar to IS NULL of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*isNull)(OH_Predicates *predicates, const char *field); - - /** - * @brief Function pointer. Restricts the value of the field which is not null to the predicates. - * - * This method is similar to IS NOT NULL of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*isNotNull)(OH_Predicates *predicates, const char *field); - - /** - * @brief Function pointer. Restricts the value of the field to be like the specified value to the predicates. - * - * This method is similar to LIKE of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*like)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. Restricts the value of the field to be between the specified value to the predicates. - * - * This method is similar to BETWEEN of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*between)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be not between the specified value to the predicates. - * - * This method is similar to NOT BETWEEN of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*notBetween)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be greater than the specified value to the predicates. - * - * This method is similar to > of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*greaterThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be less than the specified value to the predicates. - * - * This method is similar to < of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*lessThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be greater than or equal to the specified value to the predicates. - * - * This method is similar to >= of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*greaterThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Restricts the value of the field to be less than or equal to the specified value to the predicates. - * - * This method is similar to <= of the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*lessThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. Restricts the ascending or descending order of the return list. - * When there are several orders, the one close to the head has the highest priority. - * - * This method is similar ORDER BY the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param type Indicates the sort {@link OH_OrderType} type. - * @return Returns the self. - * @see OH_Predicates, OH_OrderType. - * @since 10 - */ - OH_Predicates *(*orderBy)(OH_Predicates *predicates, const char *field, OH_OrderType type); - - /** - * @brief Function pointer. Configure predicates to filter duplicate records and retain only one of them. - * - * This method is similar DISTINCT the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*distinct)(OH_Predicates *predicates); - - /** - * @brief Function pointer. Predicate for setting the maximum number of data records. - * - * This method is similar LIMIT the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param value Indicates the maximum number of records. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*limit)(OH_Predicates *predicates, unsigned int value); - - /** - * @brief Function pointer. Configure the predicate to specify the starting position of the returned result. - * - * This method is similar OFFSET the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param rowOffset Indicates the number of rows to offset from the beginning. The value is a positive integer. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*offset)(OH_Predicates *predicates, unsigned int rowOffset); - - /** - * @brief Function pointer. Configure predicates to group query results by specified columns. - * - * This method is similar GROUP BY the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param fields Indicates the column names that the grouping depends on. - * @param length Indicates the length of fields. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*groupBy)(OH_Predicates *predicates, char const *const *fields, int length); - - /** - * @brief Function pointer. - * Configure the predicate to match the specified field and the value within the given array range. - * - * This method is similar IN the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*in)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. - * Configure the predicate to match the specified field and the value not within the given array range. - * - * This method is similar NOT IN the SQL statement. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @param field Indicates the column name in the database table. - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the self. - * @see OH_Predicates, OH_VObject. - * @since 10 - */ - OH_Predicates *(*notIn)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); - - /** - * @brief Function pointer. Initialize OH_Predicates object. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the self. - * @see OH_Predicates. - * @since 10 - */ - OH_Predicates *(*clear)(OH_Predicates *predicates); - - /** - * @brief Destroy the {@link OH_Predicates} object and reclaim the memory occupied by the object. - * - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * @return Returns the status code of the execution.. - * @see OH_Predicates. - * @since 10 - */ - int (*destroy)(OH_Predicates *predicates); -} OH_Predicates; - -#ifdef __cplusplus -}; -#endif - -#endif // OH_PREDICATES_H +/* + * 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. + */ + +#ifndef OH_PREDICATES_H +#define OH_PREDICATES_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_predicates.h + * + * @brief Declared predicate related functions and enumerations. + * + * @since 10 + */ + +#include +#include +#include "oh_value_object.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Result set sort type. + * + * @since 10 + */ +typedef enum OH_OrderType { + /** + * Ascend order. + */ + ASC = 0, + /** + * Descend order. + */ + DESC = 1, +} OH_OrderType; + +/** + * @brief Define the OH_Predicates structure type. + * + * @since 10 + */ +typedef struct OH_Predicates { + /** + * The id used to uniquely identify the OH_Predicates struct. + */ + int64_t id; + + /** + * @brief Function pointer. Restricts the value of the field to be equal to the specified value to the predicates. + * + * This method is similar to = of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*equalTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be not equal to the specified value to the predicates. + * + * This method is similar to != of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*notEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. Add left parenthesis to predicate. + * + * This method is similar to ( of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*beginWrap)(OH_Predicates *predicates); + + /** + * @brief Function pointer. Add right parenthesis to predicate. + * + * This method is similar to ) of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*endWrap)(OH_Predicates *predicates); + + /** + * @brief Function pointer. Adds an or condition to the predicates. + * + * This method is similar to OR of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*orOperate)(OH_Predicates *predicates); + + /** + * @brief Function pointer. Adds an and condition to the predicates. + * + * This method is similar to AND of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*andOperate)(OH_Predicates *predicates); + + /** + * @brief Function pointer. Restricts the value of the field which is null to the predicates. + * + * This method is similar to IS NULL of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*isNull)(OH_Predicates *predicates, const char *field); + + /** + * @brief Function pointer. Restricts the value of the field which is not null to the predicates. + * + * This method is similar to IS NOT NULL of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*isNotNull)(OH_Predicates *predicates, const char *field); + + /** + * @brief Function pointer. Restricts the value of the field to be like the specified value to the predicates. + * + * This method is similar to LIKE of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*like)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. Restricts the value of the field to be between the specified value to the predicates. + * + * This method is similar to BETWEEN of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*between)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be not between the specified value to the predicates. + * + * This method is similar to NOT BETWEEN of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*notBetween)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be greater than the specified value to the predicates. + * + * This method is similar to > of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*greaterThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be less than the specified value to the predicates. + * + * This method is similar to < of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*lessThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be greater than or equal to the specified value to the predicates. + * + * This method is similar to >= of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*greaterThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Restricts the value of the field to be less than or equal to the specified value to the predicates. + * + * This method is similar to <= of the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*lessThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. Restricts the ascending or descending order of the return list. + * When there are several orders, the one close to the head has the highest priority. + * + * This method is similar ORDER BY the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param type Indicates the sort {@link OH_OrderType} type. + * @return Returns the self. + * @see OH_Predicates, OH_OrderType. + * @since 10 + */ + OH_Predicates *(*orderBy)(OH_Predicates *predicates, const char *field, OH_OrderType type); + + /** + * @brief Function pointer. Configure predicates to filter duplicate records and retain only one of them. + * + * This method is similar DISTINCT the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*distinct)(OH_Predicates *predicates); + + /** + * @brief Function pointer. Predicate for setting the maximum number of data records. + * + * This method is similar LIMIT the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param value Indicates the maximum number of records. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*limit)(OH_Predicates *predicates, unsigned int value); + + /** + * @brief Function pointer. Configure the predicate to specify the starting position of the returned result. + * + * This method is similar OFFSET the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param rowOffset Indicates the number of rows to offset from the beginning. The value is a positive integer. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*offset)(OH_Predicates *predicates, unsigned int rowOffset); + + /** + * @brief Function pointer. Configure predicates to group query results by specified columns. + * + * This method is similar GROUP BY the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param fields Indicates the column names that the grouping depends on. + * @param length Indicates the length of fields. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*groupBy)(OH_Predicates *predicates, char const *const *fields, int length); + + /** + * @brief Function pointer. + * Configure the predicate to match the specified field and the value within the given array range. + * + * This method is similar IN the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*in)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. + * Configure the predicate to match the specified field and the value not within the given array range. + * + * This method is similar NOT IN the SQL statement. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @param field Indicates the column name in the database table. + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the self. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*notIn)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Function pointer. Initialize OH_Predicates object. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the self. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*clear)(OH_Predicates *predicates); + + /** + * @brief Destroy the {@link OH_Predicates} object and reclaim the memory occupied by the object. + * + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * @return Returns the status code of the execution.. + * @see OH_Predicates. + * @since 10 + */ + int (*destroy)(OH_Predicates *predicates); +} OH_Predicates; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_PREDICATES_H diff --git a/distributeddatamgr/relational_store/include/oh_value_object.h b/distributeddatamgr/relational_store/include/oh_value_object.h index f8ddd1a6691917c54514a505cca3a43543df5dad..35e7f63ca8e4b15e962d4a0aa73bbf107d7c6ab5 100644 --- a/distributeddatamgr/relational_store/include/oh_value_object.h +++ b/distributeddatamgr/relational_store/include/oh_value_object.h @@ -1,120 +1,120 @@ -/* -* 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. -*/ - -#ifndef OH_VALUE_OBJECT_H -#define OH_VALUE_OBJECT_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - -/** - * @file oh_value_object.h - * - * @brief Provides numeric type conversion functions. - * - * @since 10 - */ - -#include -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Define the OH_VObject structure type. - * - * @since 10 - */ -typedef struct OH_VObject { - /** - * The id used to uniquely identify the OH_VObject struct. - */ - int64_t id; - - /** - * @brief Convert the int64 input parameter to a value of type {@link OH_VObject}. - * - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @param value Represents a pointer to an int64_t input parameter or the array of type int64_t. - * @param count If value is a pointer to a single numerical value, count = 1; - * if value is a pointer to an array, count is the size of the array. - * @return Returns the status code of the execution. - * @see OH_VObject. - * @since 10 - */ - int (*putInt64)(OH_VObject *valueObject, int64_t *value, uint32_t count); - - /** - * @brief Convert the double input parameter to a value of type {@link OH_VObject}. - * - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @param value Represents a pointer to an double input parameter or the array of type double. - * @param count If value is a pointer to a single numerical value, count = 1; - * if value is a pointer to an array, count is the size of the array. - * @return Returns the status code of the execution. - * @see OH_VObject. - * @since 10 - */ - int (*putDouble)(OH_VObject *valueObject, double *value, uint32_t count); - - /** - * @brief Convert the char input parameter to a value of type {@link OH_VObject}. - * - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @param value Indicates the const char * input parameter. - * @return Returns the status code of the execution. - * @see OH_VObject. - * @since 10 - */ - int (*putText)(OH_VObject *valueObject, const char *value); - - /** - * @brief Convert the char * array input parameter to a value of type {@link OH_VObject}. - * - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @param value Indicates the const char * array input parameter. - * @param count Indicates the size of the value. - * @return Returns the status code of the execution. - * @see OH_VObject. - * @since 10 - */ - int (*putTexts)(OH_VObject *valueObject, const char **value, uint32_t count); - - /** - * @brief Destroy the {@link OH_VObject} object and reclaim the memory occupied by the object. - * - * @param valueObject Represents a pointer to an {@link OH_VObject} instance. - * @return Returns the status code of the execution. - * @see OH_VObject. - * @since 10 - */ - int (*destroy)(OH_VObject *valueObject); -} OH_VObject; - -#ifdef __cplusplus -}; -#endif - -#endif // OH_VALUE_OBJECT_H +/* +* 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. +*/ + +#ifndef OH_VALUE_OBJECT_H +#define OH_VALUE_OBJECT_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_value_object.h + * + * @brief Provides numeric type conversion functions. + * + * @since 10 + */ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the OH_VObject structure type. + * + * @since 10 + */ +typedef struct OH_VObject { + /** + * The id used to uniquely identify the OH_VObject struct. + */ + int64_t id; + + /** + * @brief Convert the int64 input parameter to a value of type {@link OH_VObject}. + * + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @param value Represents a pointer to an int64_t input parameter or the array of type int64_t. + * @param count If value is a pointer to a single numerical value, count = 1; + * if value is a pointer to an array, count is the size of the array. + * @return Returns the status code of the execution. + * @see OH_VObject. + * @since 10 + */ + int (*putInt64)(OH_VObject *valueObject, int64_t *value, uint32_t count); + + /** + * @brief Convert the double input parameter to a value of type {@link OH_VObject}. + * + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @param value Represents a pointer to an double input parameter or the array of type double. + * @param count If value is a pointer to a single numerical value, count = 1; + * if value is a pointer to an array, count is the size of the array. + * @return Returns the status code of the execution. + * @see OH_VObject. + * @since 10 + */ + int (*putDouble)(OH_VObject *valueObject, double *value, uint32_t count); + + /** + * @brief Convert the char input parameter to a value of type {@link OH_VObject}. + * + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @param value Indicates the const char * input parameter. + * @return Returns the status code of the execution. + * @see OH_VObject. + * @since 10 + */ + int (*putText)(OH_VObject *valueObject, const char *value); + + /** + * @brief Convert the char * array input parameter to a value of type {@link OH_VObject}. + * + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @param value Indicates the const char * array input parameter. + * @param count Indicates the size of the value. + * @return Returns the status code of the execution. + * @see OH_VObject. + * @since 10 + */ + int (*putTexts)(OH_VObject *valueObject, const char **value, uint32_t count); + + /** + * @brief Destroy the {@link OH_VObject} object and reclaim the memory occupied by the object. + * + * @param valueObject Represents a pointer to an {@link OH_VObject} instance. + * @return Returns the status code of the execution. + * @see OH_VObject. + * @since 10 + */ + int (*destroy)(OH_VObject *valueObject); +} OH_VObject; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_VALUE_OBJECT_H diff --git a/distributeddatamgr/relational_store/include/oh_values_bucket.h b/distributeddatamgr/relational_store/include/oh_values_bucket.h index e966956b68a49fc04e7adda371c2c57cd10ef29c..1c809820163a3eaa201dc8251f3816206faf02e2 100644 --- a/distributeddatamgr/relational_store/include/oh_values_bucket.h +++ b/distributeddatamgr/relational_store/include/oh_values_bucket.h @@ -1,146 +1,146 @@ -/* - * 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. - */ - -#ifndef OH_VALUES_BUCKET_H -#define OH_VALUES_BUCKET_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - -/** - * @file oh_values_bucket.h - * - * @brief Define the type of stored key value pairs. - * - * @since 10 - */ - -#include -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Define the OH_VBucket structure type. - * - * @since 10 - */ -typedef struct OH_VBucket { - /** - * The id used to uniquely identify the OH_VBucket struct. - */ - int64_t id; - - /** - * Indicates the capability of OH_VBucket. - */ - uint16_t capability; - - /** - * @brief Put the const char * value to this {@link OH_VBucket} object for the given column name. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @param field Indicates the name of the column. - * @param value Indicates the const char * value. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*putText)(OH_VBucket *bucket, const char *field, const char *value); - - /** - * @brief Put the int64 value to this {@link OH_VBucket} object for the given column name. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @param field Indicates the name of the column. - * @param value Indicates the int64 value. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*putInt64)(OH_VBucket *bucket, const char *field, int64_t value); - - /** - * @brief Put the double value to this {@link OH_VBucket} object for the given column name. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @param field Indicates the name of the column. - * @param value Indicates the double value. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*putReal)(OH_VBucket *bucket, const char *field, double value); - - /** - * @brief Put the const uint8_t * value to this {@link OH_VBucket} object for the given column name. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @param field Indicates the name of the column. - * @param value Indicates the const uint8_t * value. - * @param size Indicates the size of value. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*putBlob)(OH_VBucket *bucket, const char *field, const uint8_t *value, uint32_t size); - - /** - * @brief Put NULL to this {@link OH_VBucket} object for the given column name. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @param field Indicates the name of the column. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*putNull)(OH_VBucket *bucket, const char *field); - - /** - * @brief Clear the {@link OH_VBucket} object's values. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*clear)(OH_VBucket *bucket); - - /** - * @brief Destroy the {@link OH_VBucket} object and reclaim the memory occupied by the object. - * - * @param bucket Represents a pointer to an {@link OH_VBucket} instance. - * @return Returns the status code of the execution. - * @see OH_VBucket. - * @since 10 - */ - int (*destroy)(OH_VBucket *bucket); -} OH_VBucket; - -#ifdef __cplusplus -}; -#endif - -#endif // OH_VALUES_BUCKET_H +/* + * 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. + */ + +#ifndef OH_VALUES_BUCKET_H +#define OH_VALUES_BUCKET_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_values_bucket.h + * + * @brief Define the type of stored key value pairs. + * + * @since 10 + */ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the OH_VBucket structure type. + * + * @since 10 + */ +typedef struct OH_VBucket { + /** + * The id used to uniquely identify the OH_VBucket struct. + */ + int64_t id; + + /** + * Indicates the capability of OH_VBucket. + */ + uint16_t capability; + + /** + * @brief Put the const char * value to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the const char * value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*putText)(OH_VBucket *bucket, const char *field, const char *value); + + /** + * @brief Put the int64 value to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the int64 value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*putInt64)(OH_VBucket *bucket, const char *field, int64_t value); + + /** + * @brief Put the double value to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the double value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*putReal)(OH_VBucket *bucket, const char *field, double value); + + /** + * @brief Put the const uint8_t * value to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the const uint8_t * value. + * @param size Indicates the size of value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*putBlob)(OH_VBucket *bucket, const char *field, const uint8_t *value, uint32_t size); + + /** + * @brief Put NULL to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*putNull)(OH_VBucket *bucket, const char *field); + + /** + * @brief Clear the {@link OH_VBucket} object's values. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*clear)(OH_VBucket *bucket); + + /** + * @brief Destroy the {@link OH_VBucket} object and reclaim the memory occupied by the object. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 10 + */ + int (*destroy)(OH_VBucket *bucket); +} OH_VBucket; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_VALUES_BUCKET_H diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 7b009ec34bb0f750e0d0d61a99ab534409a7f982..f8898c79e74f0c77ce0d1d835be8b85dbaf4dd4e 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -1,350 +1,350 @@ -/* - * 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. - */ - -#ifndef RELATIONAL_STORE_H -#define RELATIONAL_STORE_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - -/** - * @file relational_store.h - * - * @brief Provides database related functions and enumerations. - * - * @since 10 - */ - -#include "oh_cursor.h" -#include "oh_predicates.h" -#include "oh_value_object.h" -#include "oh_values_bucket.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Describe the security level of the database. - * - * @since 10 - */ -typedef enum OH_Rdb_SecurityLevel { - /** - * @brief Low-level security. Data leaks have a minor impact. - */ - S1 = 1, - /** - * @brief Medium-level security. Data leaks have a major impact. - */ - S2, - /** - * @brief High-level security. Data leaks have a severe impact. - */ - S3, - /** - * @brief Critical-level security. Data leaks have a critical impact. - */ - S4 -} OH_Rdb_SecurityLevel; - -/** - * @brief Manages relational database configurations. - * - * @since 10 - */ -#pragma pack(1) -typedef struct { - /** - * Indicates the size of the {@link OH_Rdb_Config}. It is mandatory. - */ - int selfSize; - /** - * Indicates the directory of the database. - */ - const char *dataBaseDir; - /** - * Indicates the name of the database. - */ - const char *storeName; - /** - * Indicates the bundle name of the application. - */ - const char *bundleName; - /** - * Indicates the module name of the application. - */ - const char *moduleName; - /** - * Indicates whether the database is encrypted. - */ - bool isEncrypt; - /** - * Indicates the security level {@link OH_Rdb_SecurityLevel} of the database. - */ - int securityLevel; -} OH_Rdb_Config; -#pragma pack() - -/** - * @brief Define OH_Rdb_Store type. - * - * @since 10 - */ -typedef struct { - /** - * The id used to uniquely identify the OH_Rdb_Store struct. - */ - int64_t id; -} OH_Rdb_Store; - -/** - * @brief Creates an {@link OH_VObject} instance. - * - * @return If the creation is successful, a pointer to the instance of the @link OH_VObject} structure is returned, - * otherwise NULL is returned. - * @see OH_VObject. - * @since 10 - */ -OH_VObject *OH_Rdb_CreateValueObject(); - -/** - * @brief Creates an {@link OH_VBucket} object. - * - * @return If the creation is successful, a pointer to the instance of the @link OH_VBucket} structure is returned, - * otherwise NULL is returned. - * @see OH_VBucket. - * @since 10 - */ -OH_VBucket *OH_Rdb_CreateValuesBucket(); - -/** - * @brief Creates an {@link OH_Predicates} instance. - * - * @param table Indicates the table name. - * @return If the creation is successful, a pointer to the instance of the @link OH_Predicates} structure is returned, - * otherwise NULL is returned. - * @see OH_Predicates. - * @since 10 - */ -OH_Predicates *OH_Rdb_CreatePredicates(const char *table); - -/** - * @brief Obtains an RDB store. - * - * You can set parameters of the RDB store as required. In general, - * this method is recommended to obtain a rdb store. - * - * @param config Represents a pointer to an {@link OH_Rdb_Config} instance. - * Indicates the configuration of the database related to this RDB store. - * @param errCode This parameter is the output parameter, - * and the execution status of a function is written to this variable. - * @return If the creation is successful, a pointer to the instance of the @link OH_Rdb_Store} structure is returned, - * otherwise NULL is returned. - * @see OH_Rdb_Config, OH_Rdb_Store. - * @since 10 - */ -OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode); - -/** - * @brief Close the {@link OH_Rdb_Store} object and reclaim the memory occupied by the object. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @return Returns the status code of the execution. Successful execution returns RDB_OK, - * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. - * @see OH_Rdb_Store, OH_Rdb_ErrCode. - * @since 10 - */ -int OH_Rdb_CloseStore(OH_Rdb_Store *store); - -/** - * @brief Deletes the database with a specified path. - * - * @param config Represents a pointer to an {@link OH_Rdb_Config} instance. - * Indicates the configuration of the database related to this RDB store. - * @return Returns the status code of the execution. Successful execution returns RDB_OK, - * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. - * @see OH_Rdb_ErrCode. - * @since 10 - */ -int OH_Rdb_DeleteStore(const OH_Rdb_Config *config); - -/** - * @brief Inserts a row of data into the target table. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param table Indicates the target table. - * @param valuesBucket Indicates the row of data {@link OH_VBucket} to be inserted into the table. - * @return Returns the rowId if success, returns a specific error code. - * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. - * @see OH_Rdb_Store, OH_VBucket, OH_Rdb_ErrCode. - * @since 10 - */ -int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket); - -/** - * @brief Updates data in the database based on specified conditions. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param valuesBucket Indicates the row of data {@link OH__VBucket} to be updated in the database - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * Indicates the specified update condition. - * @return Returns the number of rows changed if success, otherwise, returns a specific error code. - * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. - * @see OH_Rdb_Store, OH_Bucket, OH_Predicates, OH_Rdb_ErrCode. - * @since 10 - */ -int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates); - -/** - * @brief Deletes data from the database based on specified conditions. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * Indicates the specified delete condition. - * @return Returns the number of rows changed if success, otherwise, returns a specific error code. - * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. - * @see OH_Rdb_Store, OH_Predicates, OH_Rdb_ErrCode. - * @since 10 - */ -int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates); - -/** - * @brief Queries data in the database based on specified conditions. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param predicates Represents a pointer to an {@link OH_Predicates} instance. - * Indicates the specified query condition. - * @param columnNames Indicates the columns to query. If the value is empty array, the query applies to all columns. - * @param length Indicates the length of columnNames. - * @return If the query is successful, a pointer to the instance of the @link OH_Cursor} structure is returned, - * otherwise NULL is returned. - * @see OH_Rdb_Store, OH_Predicates, OH_Cursor. - * @since 10 - */ -OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length); - -/** - * @brief Executes an SQL statement. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param sql Indicates the SQL statement to execute. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql); - -/** - * @brief Queries data in the database based on an SQL statement. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param sql Indicates the SQL statement to execute. - * @return If the query is successful, a pointer to the instance of the @link OH_Cursor} structure is returned, - * otherwise NULL is returned. - * @see OH_Rdb_Store. - * @since 10 - */ -OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql); - -/** - * @brief Begins a transaction in EXCLUSIVE mode. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_BeginTransaction(OH_Rdb_Store *store); - -/** - * @brief Rolls back a transaction in EXCLUSIVE mode. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_RollBack(OH_Rdb_Store *store); - -/** - * @brief Commits a transaction in EXCLUSIVE mode. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_Commit(OH_Rdb_Store *store); - -/** - * @brief Backs up a database on specified path. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param databasePath Indicates the database file path. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath); - -/** - * @brief Restores a database from a specified database file. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param databasePath Indicates the database file path. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath); - -/** - * @brief Gets the version of a database. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param version Indicates the version number. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version); - -/** - * @brief Sets the version of a database. - * - * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. - * @param version Indicates the version number. - * @return Returns the status code of the execution. - * @see OH_Rdb_Store. - * @since 10 - */ -int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version); - -#ifdef __cplusplus -}; -#endif - -#endif // RELATIONAL_STORE_H +/* + * 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. + */ + +#ifndef RELATIONAL_STORE_H +#define RELATIONAL_STORE_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file relational_store.h + * + * @brief Provides database related functions and enumerations. + * + * @since 10 + */ + +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_value_object.h" +#include "oh_values_bucket.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Describe the security level of the database. + * + * @since 10 + */ +typedef enum OH_Rdb_SecurityLevel { + /** + * @brief Low-level security. Data leaks have a minor impact. + */ + S1 = 1, + /** + * @brief Medium-level security. Data leaks have a major impact. + */ + S2, + /** + * @brief High-level security. Data leaks have a severe impact. + */ + S3, + /** + * @brief Critical-level security. Data leaks have a critical impact. + */ + S4 +} OH_Rdb_SecurityLevel; + +/** + * @brief Manages relational database configurations. + * + * @since 10 + */ +#pragma pack(1) +typedef struct { + /** + * Indicates the size of the {@link OH_Rdb_Config}. It is mandatory. + */ + int selfSize; + /** + * Indicates the directory of the database. + */ + const char *dataBaseDir; + /** + * Indicates the name of the database. + */ + const char *storeName; + /** + * Indicates the bundle name of the application. + */ + const char *bundleName; + /** + * Indicates the module name of the application. + */ + const char *moduleName; + /** + * Indicates whether the database is encrypted. + */ + bool isEncrypt; + /** + * Indicates the security level {@link OH_Rdb_SecurityLevel} of the database. + */ + int securityLevel; +} OH_Rdb_Config; +#pragma pack() + +/** + * @brief Define OH_Rdb_Store type. + * + * @since 10 + */ +typedef struct { + /** + * The id used to uniquely identify the OH_Rdb_Store struct. + */ + int64_t id; +} OH_Rdb_Store; + +/** + * @brief Creates an {@link OH_VObject} instance. + * + * @return If the creation is successful, a pointer to the instance of the @link OH_VObject} structure is returned, + * otherwise NULL is returned. + * @see OH_VObject. + * @since 10 + */ +OH_VObject *OH_Rdb_CreateValueObject(); + +/** + * @brief Creates an {@link OH_VBucket} object. + * + * @return If the creation is successful, a pointer to the instance of the @link OH_VBucket} structure is returned, + * otherwise NULL is returned. + * @see OH_VBucket. + * @since 10 + */ +OH_VBucket *OH_Rdb_CreateValuesBucket(); + +/** + * @brief Creates an {@link OH_Predicates} instance. + * + * @param table Indicates the table name. + * @return If the creation is successful, a pointer to the instance of the @link OH_Predicates} structure is returned, + * otherwise NULL is returned. + * @see OH_Predicates. + * @since 10 + */ +OH_Predicates *OH_Rdb_CreatePredicates(const char *table); + +/** + * @brief Obtains an RDB store. + * + * You can set parameters of the RDB store as required. In general, + * this method is recommended to obtain a rdb store. + * + * @param config Represents a pointer to an {@link OH_Rdb_Config} instance. + * Indicates the configuration of the database related to this RDB store. + * @param errCode This parameter is the output parameter, + * and the execution status of a function is written to this variable. + * @return If the creation is successful, a pointer to the instance of the @link OH_Rdb_Store} structure is returned, + * otherwise NULL is returned. + * @see OH_Rdb_Config, OH_Rdb_Store. + * @since 10 + */ +OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode); + +/** + * @brief Close the {@link OH_Rdb_Store} object and reclaim the memory occupied by the object. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store, OH_Rdb_ErrCode. + * @since 10 + */ +int OH_Rdb_CloseStore(OH_Rdb_Store *store); + +/** + * @brief Deletes the database with a specified path. + * + * @param config Represents a pointer to an {@link OH_Rdb_Config} instance. + * Indicates the configuration of the database related to this RDB store. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_ErrCode. + * @since 10 + */ +int OH_Rdb_DeleteStore(const OH_Rdb_Config *config); + +/** + * @brief Inserts a row of data into the target table. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param table Indicates the target table. + * @param valuesBucket Indicates the row of data {@link OH_VBucket} to be inserted into the table. + * @return Returns the rowId if success, returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store, OH_VBucket, OH_Rdb_ErrCode. + * @since 10 + */ +int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket); + +/** + * @brief Updates data in the database based on specified conditions. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param valuesBucket Indicates the row of data {@link OH__VBucket} to be updated in the database + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * Indicates the specified update condition. + * @return Returns the number of rows changed if success, otherwise, returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store, OH_Bucket, OH_Predicates, OH_Rdb_ErrCode. + * @since 10 + */ +int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates); + +/** + * @brief Deletes data from the database based on specified conditions. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * Indicates the specified delete condition. + * @return Returns the number of rows changed if success, otherwise, returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store, OH_Predicates, OH_Rdb_ErrCode. + * @since 10 + */ +int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates); + +/** + * @brief Queries data in the database based on specified conditions. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param predicates Represents a pointer to an {@link OH_Predicates} instance. + * Indicates the specified query condition. + * @param columnNames Indicates the columns to query. If the value is empty array, the query applies to all columns. + * @param length Indicates the length of columnNames. + * @return If the query is successful, a pointer to the instance of the @link OH_Cursor} structure is returned, + * otherwise NULL is returned. + * @see OH_Rdb_Store, OH_Predicates, OH_Cursor. + * @since 10 + */ +OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length); + +/** + * @brief Executes an SQL statement. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param sql Indicates the SQL statement to execute. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql); + +/** + * @brief Queries data in the database based on an SQL statement. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param sql Indicates the SQL statement to execute. + * @return If the query is successful, a pointer to the instance of the @link OH_Cursor} structure is returned, + * otherwise NULL is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql); + +/** + * @brief Begins a transaction in EXCLUSIVE mode. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_BeginTransaction(OH_Rdb_Store *store); + +/** + * @brief Rolls back a transaction in EXCLUSIVE mode. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_RollBack(OH_Rdb_Store *store); + +/** + * @brief Commits a transaction in EXCLUSIVE mode. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Commit(OH_Rdb_Store *store); + +/** + * @brief Backs up a database on specified path. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param databasePath Indicates the database file path. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath); + +/** + * @brief Restores a database from a specified database file. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param databasePath Indicates the database file path. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath); + +/** + * @brief Gets the version of a database. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param version Indicates the version number. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version); + +/** + * @brief Sets the version of a database. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param version Indicates the version number. + * @return Returns the status code of the execution. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version); + +#ifdef __cplusplus +}; +#endif + +#endif // RELATIONAL_STORE_H diff --git a/distributeddatamgr/relational_store/include/relational_store_error_code.h b/distributeddatamgr/relational_store/include/relational_store_error_code.h index 6efa0ee28ba89eb3ff30936133eecb2a91578f2e..7f34beee7619fb4e18d7ccd07a4cd679186f46e6 100644 --- a/distributeddatamgr/relational_store/include/relational_store_error_code.h +++ b/distributeddatamgr/relational_store/include/relational_store_error_code.h @@ -1,316 +1,316 @@ -/* - * 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. - */ - -#ifndef RELATIONAL_STORE_ERRNO_CODE_H -#define RELATIONAL_STORE_ERRNO_CODE_H - -/** - * @addtogroup RDB - * @{ - * - * @brief The relational database (RDB) store manages data based on relational models. - * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. - * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations - * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. - * - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @since 10 - */ - - -/** - * @file relational_store_error_code.h - * - * @brief Declaration error code information. - * - * @since 10 - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Indicates the error code information. - * - * @since 10 - */ -typedef enum OH_Rdb_ErrCode { - /** - * Indicates that the function execution exception. - */ - RDB_ERR = -1, - - /** - * The error code in the correct case. - */ - RDB_OK = 0, - - /** - * @brief The base code of the exception error code. - */ - E_BASE = 14800000, - - /** - * @brief The error when the capability not supported. - */ - RDB_E_NOT_SUPPORTED = 801, - - /** - * @brief The error code for common exceptions. - */ - RDB_E_ERROR = E_BASE, - - /** - * @brief The error code for common invalid args. - */ - RDB_E_INVALID_ARGS = (E_BASE + 1), - - /** - * @brief The error code for upgrade the read-only store. - */ - RDB_E_CANNOT_UPDATE_READONLY = (E_BASE + 2), - - /** - * @brief The error code when deleting a file fails. - */ - RDB_E_REMOVE_FILE = (E_BASE + 3), - - /** - * @brief The error code for a table name is empty. - */ - RDB_E_EMPTY_TABLE_NAME = (E_BASE + 5), - - /** - * @brief The error code for a values bucket is empty. - */ - RDB_E_EMPTY_VALUES_BUCKET = (E_BASE + 6), - - /** - * @brief The error code when the sql is not select. - */ - RDB_E_EXECUTE_IN_STEP_QUERY = (E_BASE + 7), - - /** - * @brief The error code for the column index is invalid. - */ - RDB_E_INVALID_COLUMN_INDEX = (E_BASE + 8), - - /** - * @brief The error code for the column type is invalid. - */ - RDB_E_INVALID_COLUMN_TYPE = (E_BASE + 9), - - /** - * @brief The error code for a file name is empty. - */ - RDB_E_EMPTY_FILE_NAME = (E_BASE + 10), - - /** - * @brief The error for the current file path is invalid. - */ - RDB_E_INVALID_FILE_PATH = (E_BASE + 11), - - /** - * @brief The error code when using transactions. - */ - RDB_E_TRANSACTION_IN_EXECUTE = (E_BASE + 12), - - /** - * @brief The error code for the current status is invalid. - */ - RDB_E_INVALID_STATEMENT = (E_BASE + 13), - - /** - * @brief The error code when execute write operation in read connection. - */ - RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION = (E_BASE + 14), - - /** - * @brief The error code for execute begin transaction operation in read connection. - */ - RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION = (E_BASE + 15), - - /** - * @brief The error code for there are no transactions in this connection. - */ - RDB_E_NO_TRANSACTION_IN_SESSION = (E_BASE + 16), - - /** - * @brief The error code when begin more step query in one session. - */ - RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION = (E_BASE + 17), - - /** - * @brief The error code when the current statement doesn't contains one row result data. - */ - RDB_E_NO_ROW_IN_QUERY = (E_BASE + 18), - - /** - * @brief The error code for the bind arguments count is invalid. - */ - RDB_E_INVALID_BIND_ARGS_COUNT = (E_BASE + 19), - - /** - * @brief The error code for the object type is invalid. - */ - RDB_E_INVALID_OBJECT_TYPE = (E_BASE + 20), - - /** - * @brief The error code for the conflict flag is invalid. - */ - RDB_E_INVALID_CONFLICT_FLAG = (E_BASE + 21), - - /** - * @brief The error code for having clause not in group. - */ - RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY = (E_BASE + 22), - - /** - * @brief The error code for not supported by step result set. - */ - RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET = (E_BASE + 23), - - /** - * @brief The error code for step result current tid not equal to object's tid. - */ - RDB_E_STEP_RESULT_SET_CROSS_THREADS = (E_BASE + 24), - - /** - * @brief The error code when the result query was not executed. - */ - RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED = (E_BASE + 25), - - /** - * @brief The error code for the result set cursor is after the last row. - */ - RDB_E_STEP_RESULT_IS_AFTER_LAST = (E_BASE + 26), - - /** - * @brief The error code for the result set query exceeded. - */ - RDB_E_STEP_RESULT_QUERY_EXCEEDED = (E_BASE + 27), - - /** - * @brief The error code for the statement not prepared. - */ - RDB_E_STATEMENT_NOT_PREPARED = (E_BASE + 28), - - /** - * @brief The error code for the result set is incorrect. - */ - RDB_E_EXECUTE_RESULT_INCORRECT = (E_BASE + 29), - - /** - * @brief The error code when the result set is closed. - */ - RDB_E_STEP_RESULT_CLOSED = (E_BASE + 30), - - /** - * @brief The error code when input relative path. - */ - RDB_E_RELATIVE_PATH = (E_BASE + 31), - - /** - * @brief The error code for the new encrypt key is empty. - */ - RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32), - - /** - * @brief The error code for change unencrypted to encrypted. - */ - RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33), - - /** - * @brief The error code for change encrypt in busy. - */ - RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY = (E_BASE + 34), - - /** - * @brief The error code when the statement not initialized. - */ - RDB_E_STEP_STATEMENT_NOT_INIT = (E_BASE + 35), - - /** - * @brief The error code for the attach is not supported in WAL journal mode. - */ - RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE = (E_BASE + 36), - - /** - * @brief The error code when create folder failed. - */ - RDB_E_CREATE_FOLDER_FAIL = (E_BASE + 37), - - /** - * @brief The error for SQL builder normalize failed. - */ - RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL = (E_BASE + 38), - - /** - * @brief The error for store session not give connection temporarily. - */ - RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY = (E_BASE + 39), - - /** - * @brief The error for store session not current transaction. - */ - RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION = (E_BASE + 40), - - /** - * @brief The error for not supported the current operation. - */ - RDB_E_NOT_SUPPORT = (E_BASE + 41), - - /** - * @brief The error for the current parcel is invalid. - */ - RDB_E_INVALID_PARCEL = (E_BASE + 42), - - /** - * @brief The error code when using sqlite3_step function failed. - */ - RDB_E_QUERY_IN_EXECUTE = (E_BASE + 43), - - /** - * @brief The error for set persist WAL. - */ - RDB_E_SET_PERSIST_WAL = (E_BASE + 44), - - /** - * @brief The error when the database does not exist. - */ - RDB_E_DB_NOT_EXIST = (E_BASE + 45), - - /** - * @brief The error when the read connection count is overload. - */ - RDB_E_ARGS_READ_CON_OVERLOAD = (E_BASE + 46), - - /** - * @brief The error when the wal file size over default limit. - */ - RDB_E_WAL_SIZE_OVER_LIMIT = (E_BASE + 47), - - /** - * @brief The error when the connection count is used up. - */ - RDB_E_CON_OVER_LIMIT = (E_BASE + 48) -} OH_Rdb_ErrCode; - -#ifdef __cplusplus -}; -#endif - +/* + * 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. + */ + +#ifndef RELATIONAL_STORE_ERRNO_CODE_H +#define RELATIONAL_STORE_ERRNO_CODE_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + + +/** + * @file relational_store_error_code.h + * + * @brief Declaration error code information. + * + * @since 10 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Indicates the error code information. + * + * @since 10 + */ +typedef enum OH_Rdb_ErrCode { + /** + * Indicates that the function execution exception. + */ + RDB_ERR = -1, + + /** + * The error code in the correct case. + */ + RDB_OK = 0, + + /** + * @brief The base code of the exception error code. + */ + E_BASE = 14800000, + + /** + * @brief The error when the capability not supported. + */ + RDB_E_NOT_SUPPORTED = 801, + + /** + * @brief The error code for common exceptions. + */ + RDB_E_ERROR = E_BASE, + + /** + * @brief The error code for common invalid args. + */ + RDB_E_INVALID_ARGS = (E_BASE + 1), + + /** + * @brief The error code for upgrade the read-only store. + */ + RDB_E_CANNOT_UPDATE_READONLY = (E_BASE + 2), + + /** + * @brief The error code when deleting a file fails. + */ + RDB_E_REMOVE_FILE = (E_BASE + 3), + + /** + * @brief The error code for a table name is empty. + */ + RDB_E_EMPTY_TABLE_NAME = (E_BASE + 5), + + /** + * @brief The error code for a values bucket is empty. + */ + RDB_E_EMPTY_VALUES_BUCKET = (E_BASE + 6), + + /** + * @brief The error code when the sql is not select. + */ + RDB_E_EXECUTE_IN_STEP_QUERY = (E_BASE + 7), + + /** + * @brief The error code for the column index is invalid. + */ + RDB_E_INVALID_COLUMN_INDEX = (E_BASE + 8), + + /** + * @brief The error code for the column type is invalid. + */ + RDB_E_INVALID_COLUMN_TYPE = (E_BASE + 9), + + /** + * @brief The error code for a file name is empty. + */ + RDB_E_EMPTY_FILE_NAME = (E_BASE + 10), + + /** + * @brief The error for the current file path is invalid. + */ + RDB_E_INVALID_FILE_PATH = (E_BASE + 11), + + /** + * @brief The error code when using transactions. + */ + RDB_E_TRANSACTION_IN_EXECUTE = (E_BASE + 12), + + /** + * @brief The error code for the current status is invalid. + */ + RDB_E_INVALID_STATEMENT = (E_BASE + 13), + + /** + * @brief The error code when execute write operation in read connection. + */ + RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION = (E_BASE + 14), + + /** + * @brief The error code for execute begin transaction operation in read connection. + */ + RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION = (E_BASE + 15), + + /** + * @brief The error code for there are no transactions in this connection. + */ + RDB_E_NO_TRANSACTION_IN_SESSION = (E_BASE + 16), + + /** + * @brief The error code when begin more step query in one session. + */ + RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION = (E_BASE + 17), + + /** + * @brief The error code when the current statement doesn't contains one row result data. + */ + RDB_E_NO_ROW_IN_QUERY = (E_BASE + 18), + + /** + * @brief The error code for the bind arguments count is invalid. + */ + RDB_E_INVALID_BIND_ARGS_COUNT = (E_BASE + 19), + + /** + * @brief The error code for the object type is invalid. + */ + RDB_E_INVALID_OBJECT_TYPE = (E_BASE + 20), + + /** + * @brief The error code for the conflict flag is invalid. + */ + RDB_E_INVALID_CONFLICT_FLAG = (E_BASE + 21), + + /** + * @brief The error code for having clause not in group. + */ + RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY = (E_BASE + 22), + + /** + * @brief The error code for not supported by step result set. + */ + RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET = (E_BASE + 23), + + /** + * @brief The error code for step result current tid not equal to object's tid. + */ + RDB_E_STEP_RESULT_SET_CROSS_THREADS = (E_BASE + 24), + + /** + * @brief The error code when the result query was not executed. + */ + RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED = (E_BASE + 25), + + /** + * @brief The error code for the result set cursor is after the last row. + */ + RDB_E_STEP_RESULT_IS_AFTER_LAST = (E_BASE + 26), + + /** + * @brief The error code for the result set query exceeded. + */ + RDB_E_STEP_RESULT_QUERY_EXCEEDED = (E_BASE + 27), + + /** + * @brief The error code for the statement not prepared. + */ + RDB_E_STATEMENT_NOT_PREPARED = (E_BASE + 28), + + /** + * @brief The error code for the result set is incorrect. + */ + RDB_E_EXECUTE_RESULT_INCORRECT = (E_BASE + 29), + + /** + * @brief The error code when the result set is closed. + */ + RDB_E_STEP_RESULT_CLOSED = (E_BASE + 30), + + /** + * @brief The error code when input relative path. + */ + RDB_E_RELATIVE_PATH = (E_BASE + 31), + + /** + * @brief The error code for the new encrypt key is empty. + */ + RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32), + + /** + * @brief The error code for change unencrypted to encrypted. + */ + RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33), + + /** + * @brief The error code for change encrypt in busy. + */ + RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY = (E_BASE + 34), + + /** + * @brief The error code when the statement not initialized. + */ + RDB_E_STEP_STATEMENT_NOT_INIT = (E_BASE + 35), + + /** + * @brief The error code for the attach is not supported in WAL journal mode. + */ + RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE = (E_BASE + 36), + + /** + * @brief The error code when create folder failed. + */ + RDB_E_CREATE_FOLDER_FAIL = (E_BASE + 37), + + /** + * @brief The error for SQL builder normalize failed. + */ + RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL = (E_BASE + 38), + + /** + * @brief The error for store session not give connection temporarily. + */ + RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY = (E_BASE + 39), + + /** + * @brief The error for store session not current transaction. + */ + RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION = (E_BASE + 40), + + /** + * @brief The error for not supported the current operation. + */ + RDB_E_NOT_SUPPORT = (E_BASE + 41), + + /** + * @brief The error for the current parcel is invalid. + */ + RDB_E_INVALID_PARCEL = (E_BASE + 42), + + /** + * @brief The error code when using sqlite3_step function failed. + */ + RDB_E_QUERY_IN_EXECUTE = (E_BASE + 43), + + /** + * @brief The error for set persist WAL. + */ + RDB_E_SET_PERSIST_WAL = (E_BASE + 44), + + /** + * @brief The error when the database does not exist. + */ + RDB_E_DB_NOT_EXIST = (E_BASE + 45), + + /** + * @brief The error when the read connection count is overload. + */ + RDB_E_ARGS_READ_CON_OVERLOAD = (E_BASE + 46), + + /** + * @brief The error when the wal file size over default limit. + */ + RDB_E_WAL_SIZE_OVER_LIMIT = (E_BASE + 47), + + /** + * @brief The error when the connection count is used up. + */ + RDB_E_CON_OVER_LIMIT = (E_BASE + 48) +} OH_Rdb_ErrCode; + +#ifdef __cplusplus +}; +#endif + #endif // RELATIONAL_STORE_ERRNO_CODE_H \ No newline at end of file diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index 84901bb5404a0d1dd5886ce860473a2756d7e697..3d882809d5fd3fc3bdd946fe7e35818b5cd10767 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -1,21 +1,21 @@ -[ - {"name":"OH_Rdb_CreatePredicates" }, - {"name":"OH_Rdb_CreateValueObject" }, - {"name":"OH_Rdb_CreateValuesBucket" }, - {"name":"OH_Rdb_GetOrOpen" }, - {"name":"OH_Rdb_CloseStore" }, - {"name":"OH_Rdb_DeleteStore" }, - {"name":"OH_Rdb_Insert" }, - {"name":"OH_Rdb_Update" }, - {"name":"OH_Rdb_Delete" }, - {"name":"OH_Rdb_Query" }, - {"name":"OH_Rdb_Execute" }, - {"name":"OH_Rdb_ExecuteQuery" }, - {"name":"OH_Rdb_BeginTransaction" }, - {"name":"OH_Rdb_RollBack" }, - {"name":"OH_Rdb_Commit" }, - {"name":"OH_Rdb_Backup" }, - {"name":"OH_Rdb_Restore"}, - {"name":"OH_Rdb_GetVersion"}, - {"name":"OH_Rdb_SetVersion"} +[ + {"name":"OH_Rdb_CreatePredicates" }, + {"name":"OH_Rdb_CreateValueObject" }, + {"name":"OH_Rdb_CreateValuesBucket" }, + {"name":"OH_Rdb_GetOrOpen" }, + {"name":"OH_Rdb_CloseStore" }, + {"name":"OH_Rdb_DeleteStore" }, + {"name":"OH_Rdb_Insert" }, + {"name":"OH_Rdb_Update" }, + {"name":"OH_Rdb_Delete" }, + {"name":"OH_Rdb_Query" }, + {"name":"OH_Rdb_Execute" }, + {"name":"OH_Rdb_ExecuteQuery" }, + {"name":"OH_Rdb_BeginTransaction" }, + {"name":"OH_Rdb_RollBack" }, + {"name":"OH_Rdb_Commit" }, + {"name":"OH_Rdb_Backup" }, + {"name":"OH_Rdb_Restore"}, + {"name":"OH_Rdb_GetVersion"}, + {"name":"OH_Rdb_SetVersion"} ] \ No newline at end of file diff --git a/docs/capi_naming.md b/docs/capi_naming.md index a83790ec0e8fc1541629deca10f1c59d20e9c6bb..258776a69e2c9cf686fc285aaccc43b5fd8b95f0 100644 --- a/docs/capi_naming.md +++ b/docs/capi_naming.md @@ -1,83 +1,83 @@ -# C API接口编码规范 - -## 1 简介 -### 1.1 目的 -OpenHarmony提供了一些C语言系统接口供三方应用开发者使用,为了规范SDK C API的接口,对外提供一个统一接口风格,防止出现不必要的符号冲突,特此制定了此规范。 - -此规范对接口的命名规则,接口头文件,stub库在SDK包中的目录结构进行约束。2章节介绍了OpenHarmony的接口命名规范。 - -### 1.2 术语定义 -* __规则__:必须遵守的设计规则。 -* __建议__:必须加以考虑的约定,规则。 -* __说明__:对规则进行必须要的解释。 -* __示例__:对规则的举例说明。 -* __例外__:对规则的举例说明。 - -### 1.3 约定 -* 此规范描述的路径都是指SDK包中相对于Native包中的目录,不是指代码仓中的原始路径。 -* 全文xxx表示接口功能模块名,类比于C++中的类名;aaa,bbb表示普通的函数名,文件名。 - - -## 2 C API接口命名规则 -在C API中出现的接口,分为两类: -1. 业界标准接口或者是生态约定俗成的接口(如libc,opengles) -2. OpenHarmony自研接口 - -### 2.1 业界标准接口命名规则 -#### 2.1.1 【规则】已有业界标准的C API接口命名规则按照业界标准来命名。 - -__举例__: -1. libc/libc++采用的是unix_like的命名规则; -2. opengl接口规范采用<库前缀><根命令><可选参数个数><可选参数类型>格式; - -__说明__:针对第三方标准中,根据平台要求扩展的接口,也按照此三方库的推荐命名方式。 - -### 2.2 自研接口命名规则 -#### 2.2.1 【规则】C API接口函数标识符命名规则,采用OH_<模块前缀>_<方法名>的方式,命名需要精准,模块前缀采用大驼峰,方法名采用大驼峰规则。 - -__说明__:采用C语言接口,符号是全局课件,容易与别的模块符号产生符号冲突,采用模块前缀进行作用域区分。 - -#### 2.2.2 【规则】模块前缀需要精准,描述接口具体功能,模块名字需要接口领域SIG组审议通过。 -__说明__:模块前缀相当于C++中的类名,不要采用一些通用的名词,或者是范围过大的名字; -__举例__:OH_AI_xxx,AI这个一般指的是一个行业,一类技术的名词;这类名词座位模块名字不合适。 - -#### 2.2.3 【建议】接口文件中其他类型命名规范,基础类型建议都进行typedef进行定义。 -|类别|命名风格|形式| -|----|----|----| -|【建议】结构体类型,枚举类型,联合体,typedef类型|带模块前缀的大驼峰|采用Xxx_AaaBbb| -|局部变量,函数参数,宏参数,结构体字段,联合体成员|小驼峰|aaaBbb| -|全局变量|带‘g_’前缀的小驼峰|g_Xxx_aaaBbb| -|宏(不包括函数式宏),枚举值,goto标签|全大写,下划线分割|XXX_BBB| -|函数宏|带模块前缀的大驼峰|OH_Xxx_AaaBbb| -|常量(在函数外部定义由const修饰的基本数据类型,枚举类型,字符串类型)|全大写下划线分割,或带'g_'前缀的小驼峰|XXX_BBB, g_Xxx_aaaBbb| - -### 2.3 头文件命名规则 - -#### 2.3.1 【规则】头文件文件名采用unix_like的命名规则,名词与名词间用"_"隔离。 -__举例__:采用xxx_aaa.h xxx_aaa_bbb.h,或者xxx/aaa.h xxx/aaa_bbb.h。 -__说明__:如果此头文件在sysroot的include目录下的路径中已经包含xxx模块名,头文件的文件名就不需要带xxx前缀。 - - -#### 2.3.2 【规则】自研接口头文件放置在sysroot/usr/include规则,在此目录下创建子系统目录(名字上APP SIG评审),放置到此子目录下。 -__说明__:子系统下的目录组织形式可以采用模块名目录加头文件的形式,或者采用模块名_文件名.h方式;不建议新建太深的目录结构,开发者代码在引用头文件的时候,需要引用长串路径,不友好。 -``` -|--include -| |--领域组名(需要上API SIG评审) -| | |--xxx -| | | |-- aaa.h -| | | |-- bbb.h -| | | -| | |--xxx_ccc.h -| | |--xxx_common.h - -``` - -#### 2.3.3 【规则】三方库头文件按照生态的习惯放置,可以不遵守2.3.2规则。 - -### 2.4 库文件命名规则 -#### 2.4.1 【建议】库文件放置在sysroot/usr/lib根目录,不用建子目录;文件名采用unix_like的命名规则,不用z.so结尾。 -__说明__:是否需要给C API接口独立创建一个so库,这个没有强制要求;如果C API接口是重新封装,建议独立一个库,因为C API接口实现库在镜像中必须放置到/system/{lib|lib64}/ndk目录,方便接口管控。 -__说明__:命名采用libxxx.so的命名方式,库名字最好与模块名字相同,如果包含多个模块,建议采用业界常用的名字;如果名字是常用单词,建议前面加oh前缀,如libohxxx.so,避免名字冲突。 - - -#### 2.4.2 【规则】三方库的名字按照生态约定的名字命名。 +# C API接口编码规范 + +## 1 简介 +### 1.1 目的 +OpenHarmony提供了一些C语言系统接口供三方应用开发者使用,为了规范SDK C API的接口,对外提供一个统一接口风格,防止出现不必要的符号冲突,特此制定了此规范。 + +此规范对接口的命名规则,接口头文件,stub库在SDK包中的目录结构进行约束。2章节介绍了OpenHarmony的接口命名规范。 + +### 1.2 术语定义 +* __规则__:必须遵守的设计规则。 +* __建议__:必须加以考虑的约定,规则。 +* __说明__:对规则进行必须要的解释。 +* __示例__:对规则的举例说明。 +* __例外__:对规则的举例说明。 + +### 1.3 约定 +* 此规范描述的路径都是指SDK包中相对于Native包中的目录,不是指代码仓中的原始路径。 +* 全文xxx表示接口功能模块名,类比于C++中的类名;aaa,bbb表示普通的函数名,文件名。 + + +## 2 C API接口命名规则 +在C API中出现的接口,分为两类: +1. 业界标准接口或者是生态约定俗成的接口(如libc,opengles) +2. OpenHarmony自研接口 + +### 2.1 业界标准接口命名规则 +#### 2.1.1 【规则】已有业界标准的C API接口命名规则按照业界标准来命名。 + +__举例__: +1. libc/libc++采用的是unix_like的命名规则; +2. opengl接口规范采用<库前缀><根命令><可选参数个数><可选参数类型>格式; + +__说明__:针对第三方标准中,根据平台要求扩展的接口,也按照此三方库的推荐命名方式。 + +### 2.2 自研接口命名规则 +#### 2.2.1 【规则】C API接口函数标识符命名规则,采用OH_<模块前缀>_<方法名>的方式,命名需要精准,模块前缀采用大驼峰,方法名采用大驼峰规则。 + +__说明__:采用C语言接口,符号是全局课件,容易与别的模块符号产生符号冲突,采用模块前缀进行作用域区分。 + +#### 2.2.2 【规则】模块前缀需要精准,描述接口具体功能,模块名字需要接口领域SIG组审议通过。 +__说明__:模块前缀相当于C++中的类名,不要采用一些通用的名词,或者是范围过大的名字; +__举例__:OH_AI_xxx,AI这个一般指的是一个行业,一类技术的名词;这类名词座位模块名字不合适。 + +#### 2.2.3 【建议】接口文件中其他类型命名规范,基础类型建议都进行typedef进行定义。 +|类别|命名风格|形式| +|----|----|----| +|【建议】结构体类型,枚举类型,联合体,typedef类型|带模块前缀的大驼峰|采用Xxx_AaaBbb| +|局部变量,函数参数,宏参数,结构体字段,联合体成员|小驼峰|aaaBbb| +|全局变量|带‘g_’前缀的小驼峰|g_Xxx_aaaBbb| +|宏(不包括函数式宏),枚举值,goto标签|全大写,下划线分割|XXX_BBB| +|函数宏|带模块前缀的大驼峰|OH_Xxx_AaaBbb| +|常量(在函数外部定义由const修饰的基本数据类型,枚举类型,字符串类型)|全大写下划线分割,或带'g_'前缀的小驼峰|XXX_BBB, g_Xxx_aaaBbb| + +### 2.3 头文件命名规则 + +#### 2.3.1 【规则】头文件文件名采用unix_like的命名规则,名词与名词间用"_"隔离。 +__举例__:采用xxx_aaa.h xxx_aaa_bbb.h,或者xxx/aaa.h xxx/aaa_bbb.h。 +__说明__:如果此头文件在sysroot的include目录下的路径中已经包含xxx模块名,头文件的文件名就不需要带xxx前缀。 + + +#### 2.3.2 【规则】自研接口头文件放置在sysroot/usr/include规则,在此目录下创建子系统目录(名字上APP SIG评审),放置到此子目录下。 +__说明__:子系统下的目录组织形式可以采用模块名目录加头文件的形式,或者采用模块名_文件名.h方式;不建议新建太深的目录结构,开发者代码在引用头文件的时候,需要引用长串路径,不友好。 +``` +|--include +| |--领域组名(需要上API SIG评审) +| | |--xxx +| | | |-- aaa.h +| | | |-- bbb.h +| | | +| | |--xxx_ccc.h +| | |--xxx_common.h + +``` + +#### 2.3.3 【规则】三方库头文件按照生态的习惯放置,可以不遵守2.3.2规则。 + +### 2.4 库文件命名规则 +#### 2.4.1 【建议】库文件放置在sysroot/usr/lib根目录,不用建子目录;文件名采用unix_like的命名规则,不用z.so结尾。 +__说明__:是否需要给C API接口独立创建一个so库,这个没有强制要求;如果C API接口是重新封装,建议独立一个库,因为C API接口实现库在镜像中必须放置到/system/{lib|lib64}/ndk目录,方便接口管控。 +__说明__:命名采用libxxx.so的命名方式,库名字最好与模块名字相同,如果包含多个模块,建议采用业界常用的名字;如果名字是常用单词,建议前面加oh前缀,如libohxxx.so,避免名字冲突。 + + +#### 2.4.2 【规则】三方库的名字按照生态约定的名字命名。 diff --git a/docs/howto_add.md b/docs/howto_add.md index 2a17b395fb2f572b1ccf07b391b804bb8025ced8..eeee178e844bcee88034448956cf2832b83d1239 100644 --- a/docs/howto_add.md +++ b/docs/howto_add.md @@ -1,120 +1,120 @@ -# C API构建添加指南 -## 范围 -本文旨在说明跟C API相关的如下问题: -* 编译方法 -* 编译结果 -* 编译GN模板 -* 文档 - -## 需要了解的基础知识: - -GN语法,https://zhuanlan.zhihu.com/p/136954435 - -对json描述文件有一定了解 - -## 编译方法 - 使能ndk编译,默认编译linux/windows版本 -``` -./build.sh --product-name ohos-sdk -``` -更加详细的SDK编译指导,请参考[如何编译full-SDK](http://https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-compile-guide.md)。 - -## 编译结果 - -### 存放位置 -跟os相关的内容(比如工具链,cmake等)会被拷贝到 root_out_dir/sdk-native/os-specific/目录下,其他内容放在root_out_dir/sdk-native/os-irrelevant目录下。归档的C API zip包放在root_out_dir/packages/ohos-sdk-native/[darwin|windows|linux]目录下,命名为native-[darwin|windows|linux]-x64-[x.x.x].zip。 - -### 压缩包目录结构 -``` -|--build -|--build-tools -|--docs -|--llvm -|--sysroot -|--nativeapi_syscap_config.json -|--NOTICE.txt -|--oh-uni-package.json -``` -* build目录:存放cmake的配置文件 -* build-tools目录:存放cmake等工具 -* docs目录:存放sysroot对应的文档 -* llvm目录:存放不同操作系统下的交叉工具链 -* sysroot目录:存放头文件和库 -* nativeapi_syscap_config.json: 存放头文件与syscap的映射关系 -* NOTICE.txt:存放licence声明 - -## 编译模板说明 -如前文所示,OpenHarmony native包由三部分组成;对应地,编译系统提供了一些GN模板,模板定义位于//build/ohos/ndk/ndk.gni。 -* ohos_ndk_library : 对应包里的库文件。 -* ohos_ndk_headers : 对应包里的头文件。 -* ohos_ndk_toolchains :对应包里的工具链。 - -ohos_ndk_headers和ohos_ndk_toolchains目标本质上只做copy - -### ohos_ndk_library(目标名) -输入参数: -output_name: 最终输出的库的名字;选填,默认为目标名。 - -NOTE:库名字按照《C API接口编码规范》 - -下面的例子中,ndk_library的目标名为"libsensor",但是输出的so名字为libsensor.z.so -``` -ohos_ndk_library("libsensor_ndk") { - ndk_description_file = "./libsensor.ndk.json" - min_compact_version = "10" - output_name = "sensor" # 编译系统会自动将名字变成libsensor,如果不设置,就采用libsensor_ndk.so - output_extension = "so" # 设置动态库的后缀名,默认为z.so - system_capability = "SystemCapability.Xxx.Aaa" # 设置这个库关联的SysCap,当前一个库只支持一个SysCap - system_capability_headers = [ # 与这个SysCap相关联的头文件 - "Xxx/Aaa.h", - "Xxx/Bbb.h" - ] -} -``` - **min_compact_version** : 相当于Android的API level,当前library从哪个版本开始支持?如果没有设置,默认设置为从当前版本开始支持。 - -为什么需要变量min_compact_version? -一般地,操作系统的后期版本会提供比前期版本更多的库,比如某个提供23个NDK库,但是前一个版本仅提供13个NDK库。所以需要提供一个变量来告知编译系统当前库是从哪个版本开始支持的。 - - **ndk_description_file** : 当前library的符号描述文件json格式. 这个文件类似于镜像中的version script文件格式。Harmonyos上采用json格式。为统一起见,ndk_description_file的命名统一为libxxx.ndk.json。Json文件可以通过添加key来提供更丰富的属性,为未来的扩展留下空间。 - -json描述文件的例子如下: -``` -# NOTE:json文件本身不支持注释,这里作者便宜行事。读者使用的时候,请自行删除注释 -[ - { - "first_introduced": "2", # 描述当前接口引入的版本号 - "name": "GetSensorNdkVersion" # 当前接口的名字 - }, - { - "name": "GetSensorNdkObject", - "type": "variable" # 描述当前符号是变量,而不是函数 - } -] -``` - -### ohos_ndk_headers(目标名) -输入参数: - **sources** :想拷贝的文件或目录列表 - **dest_dir** :目标目录,默认值为$ndk_headers_out_dir,$ndk_headers_out_dir为$root_out_dir/sdk-native/sysroot/usr/include。 - -例子:例子中的sensor_ndk_interface.h将会被拷贝到$ndk_headers_out_dir/sensor目录下 -``` -ohos_ndk_headers("sensor_header") { -dest_dir = "$ndk_headers_out_dir/sensor" -sources = [ - "./include/sensor_ndk_interface.h", -] -} -``` - -### ohos_ndk_toolchains - -这个模板只针对mac/win/linux平台的几个工具链,一般开发同学使用不到。 -输入参数含义同ohos_ndk_headers。ohos_ndk_toolchains目标的默认dest_dir为$root_out_dir/sdk-native/sysroot/usr/lib - - -## 文档 -C API的文档生成在docs目录,需要安装doxygen工具,在ubuntu上使用`sudo apt-get install doxygen`即可安装。如果编译机上没有安装doxygen,文档将无法生成。 - - +# C API构建添加指南 +## 范围 +本文旨在说明跟C API相关的如下问题: +* 编译方法 +* 编译结果 +* 编译GN模板 +* 文档 + +## 需要了解的基础知识: + +GN语法,https://zhuanlan.zhihu.com/p/136954435 + +对json描述文件有一定了解 + +## 编译方法 + 使能ndk编译,默认编译linux/windows版本 +``` +./build.sh --product-name ohos-sdk +``` +更加详细的SDK编译指导,请参考[如何编译full-SDK](http://https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-compile-guide.md)。 + +## 编译结果 + +### 存放位置 +跟os相关的内容(比如工具链,cmake等)会被拷贝到 root_out_dir/sdk-native/os-specific/目录下,其他内容放在root_out_dir/sdk-native/os-irrelevant目录下。归档的C API zip包放在root_out_dir/packages/ohos-sdk-native/[darwin|windows|linux]目录下,命名为native-[darwin|windows|linux]-x64-[x.x.x].zip。 + +### 压缩包目录结构 +``` +|--build +|--build-tools +|--docs +|--llvm +|--sysroot +|--nativeapi_syscap_config.json +|--NOTICE.txt +|--oh-uni-package.json +``` +* build目录:存放cmake的配置文件 +* build-tools目录:存放cmake等工具 +* docs目录:存放sysroot对应的文档 +* llvm目录:存放不同操作系统下的交叉工具链 +* sysroot目录:存放头文件和库 +* nativeapi_syscap_config.json: 存放头文件与syscap的映射关系 +* NOTICE.txt:存放licence声明 + +## 编译模板说明 +如前文所示,OpenHarmony native包由三部分组成;对应地,编译系统提供了一些GN模板,模板定义位于//build/ohos/ndk/ndk.gni。 +* ohos_ndk_library : 对应包里的库文件。 +* ohos_ndk_headers : 对应包里的头文件。 +* ohos_ndk_toolchains :对应包里的工具链。 + +ohos_ndk_headers和ohos_ndk_toolchains目标本质上只做copy + +### ohos_ndk_library(目标名) +输入参数: +output_name: 最终输出的库的名字;选填,默认为目标名。 + +NOTE:库名字按照《C API接口编码规范》 + +下面的例子中,ndk_library的目标名为"libsensor",但是输出的so名字为libsensor.z.so +``` +ohos_ndk_library("libsensor_ndk") { + ndk_description_file = "./libsensor.ndk.json" + min_compact_version = "10" + output_name = "sensor" # 编译系统会自动将名字变成libsensor,如果不设置,就采用libsensor_ndk.so + output_extension = "so" # 设置动态库的后缀名,默认为z.so + system_capability = "SystemCapability.Xxx.Aaa" # 设置这个库关联的SysCap,当前一个库只支持一个SysCap + system_capability_headers = [ # 与这个SysCap相关联的头文件 + "Xxx/Aaa.h", + "Xxx/Bbb.h" + ] +} +``` + **min_compact_version** : 相当于Android的API level,当前library从哪个版本开始支持?如果没有设置,默认设置为从当前版本开始支持。 + +为什么需要变量min_compact_version? +一般地,操作系统的后期版本会提供比前期版本更多的库,比如某个提供23个NDK库,但是前一个版本仅提供13个NDK库。所以需要提供一个变量来告知编译系统当前库是从哪个版本开始支持的。 + + **ndk_description_file** : 当前library的符号描述文件json格式. 这个文件类似于镜像中的version script文件格式。Harmonyos上采用json格式。为统一起见,ndk_description_file的命名统一为libxxx.ndk.json。Json文件可以通过添加key来提供更丰富的属性,为未来的扩展留下空间。 + +json描述文件的例子如下: +``` +# NOTE:json文件本身不支持注释,这里作者便宜行事。读者使用的时候,请自行删除注释 +[ + { + "first_introduced": "2", # 描述当前接口引入的版本号 + "name": "GetSensorNdkVersion" # 当前接口的名字 + }, + { + "name": "GetSensorNdkObject", + "type": "variable" # 描述当前符号是变量,而不是函数 + } +] +``` + +### ohos_ndk_headers(目标名) +输入参数: + **sources** :想拷贝的文件或目录列表 + **dest_dir** :目标目录,默认值为$ndk_headers_out_dir,$ndk_headers_out_dir为$root_out_dir/sdk-native/sysroot/usr/include。 + +例子:例子中的sensor_ndk_interface.h将会被拷贝到$ndk_headers_out_dir/sensor目录下 +``` +ohos_ndk_headers("sensor_header") { +dest_dir = "$ndk_headers_out_dir/sensor" +sources = [ + "./include/sensor_ndk_interface.h", +] +} +``` + +### ohos_ndk_toolchains + +这个模板只针对mac/win/linux平台的几个工具链,一般开发同学使用不到。 +输入参数含义同ohos_ndk_headers。ohos_ndk_toolchains目标的默认dest_dir为$root_out_dir/sdk-native/sysroot/usr/lib + + +## 文档 +C API的文档生成在docs目录,需要安装doxygen工具,在ubuntu上使用`sudo apt-get install doxygen`即可安装。如果编译机上没有安装doxygen,文档将无法生成。 + + diff --git a/docs/user_guide.md b/docs/user_guide.md index d89b6ba9e60d8b3b5f707b1436fe9a78ab2e01de..9c8c77fcfe925eb141c56770bf27458b2c61ed3f 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -1,84 +1,84 @@ -# C API用户指导 - -## 基础知识 -了解C API基础知识,请参考《[Native API入门](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/native-api-intro.md)》。 - - -## 接口开放策略 - -### 不开放原则 - -1. 应用生态提供的核心特性只开放ArkTS API,不开发C API。 -2. 不开发ArkUI的C API。 -3. 不开发硬件底层接口(HDI)C API。 -4. 不开放命令行接口C API。 -### 开放原则 -5. 高性能、密集计算业务场景主动开放C API,例如:需要高性能的IO、CPU密集计算等场景;音视频编解码、图形计算等场景。 -6. 应用生态业务依赖的场景,主动开放高阶C API。例如:对标竞品,媒体高阶C API。 -7. 应用生态框架以来的场景,按需开放C API。例如:按需开放Unity/electron/CFE框架中依赖的C API。 -8. 行业约定或者标准要求的场景按需开放C API。此类C API独立发布,不放入OpenHarmony C API中。例如:金融或者安全行业高密加密算法等,按需独立发布。 - -### 前向兼容性原则 -9. C API的前向兼容性原则与ArkTS API策略保持一致。CI流程中会使用自动化工具进行看护。 - - -## C API接口设计规范 -本规范是在《[OpenHarmony API治理章程](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-governance.md)》《[OpenHarmony API社区规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md)》的基础上,对C API设计进行的一些补充。在C API接口设计上同时满足此三份规范。 - -### 设计规则 -* 【规则】C API相关的接口文件,包含接口列表文件ndk.json,头文件,编译构建脚本三部分;这些内容必须放置在interface_sdk_c仓中,不能对外产生依赖。三方库接口暴露规则同自研仓,接口是处理过的接口文件,不是三方库原生文件。 -* 【规则】接口命名必须符合《[C API接口编码规范](./capi_naming.md)》。 -* 【规则】需要发布的接口需要明确在ndk.json文件中声明列出,不允许直接发布镜像中的动态库,都采用stub动态库的方式发布。 - * json文件是一个符号描述数组,举例如下: - ``` - [ - { - "name": "__progname", - "type": "variable" - }, - { - "name": "pthread_cond_clockwait" - } - ] - ``` - name表示符号的名字,type表示符号类型,不写type,默认认为是函数;varible表示这个符号是变量。 -* 【规则】C API中头文件中不允许包含不发布的接口声明,类型定义;三方库的接口文件,可 -以备案保留。 -* 【规则】接口必须是C语言接口,不允许出现C++元素,保证引用方是C代码也能使用;提供头文件中的接口需要用C declare声明。 - - * C declare声明 - ``` - #ifdef __cplusplus - extern "C" { - #endif - ... - #ifdef __cplusplus - } - #endif - ``` - * __反例__ - struct/enum声明的类型,如果没有声明typedef类型,在使用时必须加上struct、enum关键字。 - - * __例外__ 直接提供实现库,嵌入到应用包中的接口可以使用C++元素。 - -* 【规则】包含C API的实现动态库放到/system/{lib}/ndk目录下。 -* 【规则】每个接口都需要与syscap相关联;一个头文件中的接口只能属于一个syscap,不能包含多个syscap能力;多个文件可以关联相同的syscap。 -* 【规则】自研接口按照如下文档注释写作规范进行注释,三方库接口有修改的,注释规则按照注释规范进行注释。 -* 【规则】对外提供的接口,采用对外封闭,依赖倒置原则;结构体的具体实现不对外暴露,方便后续扩展修改 - -> 此条是《[OpenHarmony API社区规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md)》规则16:注意封装:不暴露实现细节的C API补充解释。 - -### 兼容性规则 -* 【规则】不允许进行接口原型变更,可以通过新增接口,废弃老接口的方式进行。 -* 【规则】接口语义不允许变更,语义通过xts用例保持兼容性。接口涉及的结构体,枚举值变更也会影响语义,建议在设计的时候保留一些字段供扩展使用。 -* 【规则】结构体成员,枚举值可以标明废弃,不建议删除。 - -## 文档注释写作规范 -本章在OpenHarmony API社区规范[API设计概述](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md#api设计概述)基础上,对C API的注释流程做了补充。 - -自研接口注释书写规范步骤: -1. 每个头文件都需要书写注释。 -2. 注释书写参考 [Native接口注释规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/template/native-template.md),注释命令必须按照@开头。 -3. 提交注释头文件到 https://gitee.com/openharmony-sig/interface_native_header/tree/master/zh-cn/native_sdk 这个仓。 -4. 等待资料审核,合入;同时翻译一份英文注释头文件到en目录。 -5. 下载这个头文件,覆盖到对应头文件。 +# C API用户指导 + +## 基础知识 +了解C API基础知识,请参考《[Native API入门](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/native-api-intro.md)》。 + + +## 接口开放策略 + +### 不开放原则 + +1. 应用生态提供的核心特性只开放ArkTS API,不开发C API。 +2. 不开发ArkUI的C API。 +3. 不开发硬件底层接口(HDI)C API。 +4. 不开放命令行接口C API。 +### 开放原则 +5. 高性能、密集计算业务场景主动开放C API,例如:需要高性能的IO、CPU密集计算等场景;音视频编解码、图形计算等场景。 +6. 应用生态业务依赖的场景,主动开放高阶C API。例如:对标竞品,媒体高阶C API。 +7. 应用生态框架以来的场景,按需开放C API。例如:按需开放Unity/electron/CFE框架中依赖的C API。 +8. 行业约定或者标准要求的场景按需开放C API。此类C API独立发布,不放入OpenHarmony C API中。例如:金融或者安全行业高密加密算法等,按需独立发布。 + +### 前向兼容性原则 +9. C API的前向兼容性原则与ArkTS API策略保持一致。CI流程中会使用自动化工具进行看护。 + + +## C API接口设计规范 +本规范是在《[OpenHarmony API治理章程](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-governance.md)》《[OpenHarmony API社区规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md)》的基础上,对C API设计进行的一些补充。在C API接口设计上同时满足此三份规范。 + +### 设计规则 +* 【规则】C API相关的接口文件,包含接口列表文件ndk.json,头文件,编译构建脚本三部分;这些内容必须放置在interface_sdk_c仓中,不能对外产生依赖。三方库接口暴露规则同自研仓,接口是处理过的接口文件,不是三方库原生文件。 +* 【规则】接口命名必须符合《[C API接口编码规范](./capi_naming.md)》。 +* 【规则】需要发布的接口需要明确在ndk.json文件中声明列出,不允许直接发布镜像中的动态库,都采用stub动态库的方式发布。 + * json文件是一个符号描述数组,举例如下: + ``` + [ + { + "name": "__progname", + "type": "variable" + }, + { + "name": "pthread_cond_clockwait" + } + ] + ``` + name表示符号的名字,type表示符号类型,不写type,默认认为是函数;varible表示这个符号是变量。 +* 【规则】C API中头文件中不允许包含不发布的接口声明,类型定义;三方库的接口文件,可 +以备案保留。 +* 【规则】接口必须是C语言接口,不允许出现C++元素,保证引用方是C代码也能使用;提供头文件中的接口需要用C declare声明。 + + * C declare声明 + ``` + #ifdef __cplusplus + extern "C" { + #endif + ... + #ifdef __cplusplus + } + #endif + ``` + * __反例__ + struct/enum声明的类型,如果没有声明typedef类型,在使用时必须加上struct、enum关键字。 + + * __例外__ 直接提供实现库,嵌入到应用包中的接口可以使用C++元素。 + +* 【规则】包含C API的实现动态库放到/system/{lib}/ndk目录下。 +* 【规则】每个接口都需要与syscap相关联;一个头文件中的接口只能属于一个syscap,不能包含多个syscap能力;多个文件可以关联相同的syscap。 +* 【规则】自研接口按照如下文档注释写作规范进行注释,三方库接口有修改的,注释规则按照注释规范进行注释。 +* 【规则】对外提供的接口,采用对外封闭,依赖倒置原则;结构体的具体实现不对外暴露,方便后续扩展修改 + +> 此条是《[OpenHarmony API社区规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md)》规则16:注意封装:不暴露实现细节的C API补充解释。 + +### 兼容性规则 +* 【规则】不允许进行接口原型变更,可以通过新增接口,废弃老接口的方式进行。 +* 【规则】接口语义不允许变更,语义通过xts用例保持兼容性。接口涉及的结构体,枚举值变更也会影响语义,建议在设计的时候保留一些字段供扩展使用。 +* 【规则】结构体成员,枚举值可以标明废弃,不建议删除。 + +## 文档注释写作规范 +本章在OpenHarmony API社区规范[API设计概述](https://gitee.com/openharmony/docs/blob/master/zh-cn/design/OpenHarmony-API-quality.md#api设计概述)基础上,对C API的注释流程做了补充。 + +自研接口注释书写规范步骤: +1. 每个头文件都需要书写注释。 +2. 注释书写参考 [Native接口注释规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/template/native-template.md),注释命令必须按照@开头。 +3. 提交注释头文件到 https://gitee.com/openharmony-sig/interface_native_header/tree/master/zh-cn/native_sdk 这个仓。 +4. 等待资料审核,合入;同时翻译一份英文注释头文件到en目录。 +5. 下载这个头文件,覆盖到对应头文件。 diff --git a/drivers/external_device_manager/usb/BUILD.gn b/drivers/external_device_manager/usb/BUILD.gn index 36f24db18b6c23f77e402e9aa1869ef846057c82..6c2541edbb25f938499c3eef8c56597b4f3f1a0c 100644 --- a/drivers/external_device_manager/usb/BUILD.gn +++ b/drivers/external_device_manager/usb/BUILD.gn @@ -1,33 +1,33 @@ -# 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. - -import("//build/ohos.gni") - -ohos_ndk_headers("usb_header") { - dest_dir = "$ndk_headers_out_dir/usb/" - sources = [ - "usb_ddk_api.h", - "usb_ddk_types.h", - ] -} - -ohos_ndk_library("libusb_ndk") { - ndk_description_file = "./libusb.ndk.json" - min_compact_version = "9" - output_name = "usb_ndk" - system_capability = "SystemCapability.Driver.USB.Extension" - system_capability_headers = [ - "usb/usb_ddk_api.h", - "usb/usb_ddk_types.h", - ] -} +# 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. + +import("//build/ohos.gni") + +ohos_ndk_headers("usb_header") { + dest_dir = "$ndk_headers_out_dir/usb/" + sources = [ + "usb_ddk_api.h", + "usb_ddk_types.h", + ] +} + +ohos_ndk_library("libusb_ndk") { + ndk_description_file = "./libusb.ndk.json" + min_compact_version = "9" + output_name = "usb_ndk" + system_capability = "SystemCapability.Driver.USB.Extension" + system_capability_headers = [ + "usb/usb_ddk_api.h", + "usb/usb_ddk_types.h", + ] +} diff --git a/drivers/external_device_manager/usb/libusb.ndk.json b/drivers/external_device_manager/usb/libusb.ndk.json index 4cc70335ebfd13b107221726951e4b6fa9a33e06..24e375cdba79ada20db25bc7e91b0152ddafa988 100644 --- a/drivers/external_device_manager/usb/libusb.ndk.json +++ b/drivers/external_device_manager/usb/libusb.ndk.json @@ -1,44 +1,44 @@ -[ - { - "name": "OH_Usb_Init" - }, - { - "name": "OH_Usb_Release" - }, - { - "name": "OH_Usb_GetDeviceDescriptor" - }, - { - "name": "OH_Usb_GetConfigDescriptor" - }, - { - "name": "OH_Usb_FreeConfigDescriptor" - }, - { - "name": "OH_Usb_ClaimInterface" - }, - { - "name": "OH_Usb_ReleaseInterface" - }, - { - "name": "OH_Usb_SelectInterfaceSetting" - }, - { - "name": "OH_Usb_GetCurrentInterfaceSetting" - }, - { - "name": "OH_Usb_SendControlReadRequest" - }, - { - "name": "OH_Usb_SendControlWriteRequest" - }, - { - "name": "OH_Usb_SendPipeRequest" - }, - { - "name": "OH_Usb_CreateDeviceMemMap" - }, - { - "name": "OH_Usb_DestroyDeviceMemMap" - } +[ + { + "name": "OH_Usb_Init" + }, + { + "name": "OH_Usb_Release" + }, + { + "name": "OH_Usb_GetDeviceDescriptor" + }, + { + "name": "OH_Usb_GetConfigDescriptor" + }, + { + "name": "OH_Usb_FreeConfigDescriptor" + }, + { + "name": "OH_Usb_ClaimInterface" + }, + { + "name": "OH_Usb_ReleaseInterface" + }, + { + "name": "OH_Usb_SelectInterfaceSetting" + }, + { + "name": "OH_Usb_GetCurrentInterfaceSetting" + }, + { + "name": "OH_Usb_SendControlReadRequest" + }, + { + "name": "OH_Usb_SendControlWriteRequest" + }, + { + "name": "OH_Usb_SendPipeRequest" + }, + { + "name": "OH_Usb_CreateDeviceMemMap" + }, + { + "name": "OH_Usb_DestroyDeviceMemMap" + } ] \ No newline at end of file diff --git a/drivers/external_device_manager/usb/usb_ddk_api.h b/drivers/external_device_manager/usb/usb_ddk_api.h index e7b08a575f39523ba39cef466e9fd38f7e8463b4..8bd2a10b7b966a27d4860104fdb9dd970c1e0fc2 100644 --- a/drivers/external_device_manager/usb/usb_ddk_api.h +++ b/drivers/external_device_manager/usb/usb_ddk_api.h @@ -1,215 +1,229 @@ -/* - * 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. - */ -#ifndef USB_DDK_API_H -#define USB_DDK_API_H - -/** - * @addtogroup UsbDdk - * @{ - * - * @brief Provides USB DDK APIs to open and close USB interfaces, perform non-isochronous and isochronous\n - * data transfer over USB pipes, and implement control transfer and interrupt transfer, etc. - * - * @syscap SystemCapability.Driver.USB.Extension - * @since 10 - * @version 1.0 - */ - -/** - * @file usb_ddk_api.h - * - * @brief Declares the USB DDK APIs used by the USB host to access USB devices. - * - * @since 10 - * @version 1.0 - */ - -#include - -#include "usb_ddk_types.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief Initializes the DDK. - * - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_Init(void); - -/** - * @brief Releases the DDK. - * - * @since 10 - * @version 1.0 - */ -void OH_Usb_Release(void); - -/** - * @brief Obtains the USB device descriptor. - * - * @param deviceId ID of the device whose descriptor is to be obtained. - * @param desc Standard device descriptor defined in the USB protocol. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_GetDeviceDescriptor(uint64_t deviceId, struct UsbDeviceDescriptor *desc); - -/** - * @brief Obtains the configuration descriptor. To avoid memory leakage, use OH_Usb_FreeConfigDescriptor\n - * to release a descriptor after use. - * - * @param deviceId ID of the device whose configuration descriptor is to be obtained. - * @param configIndex Configuration index, which corresponds to bConfigurationValue in the USB protocol. - * @param config Configuration descriptor, which includes the standard configuration descriptor defined in the\n - * USB protocol and the associated interface descriptor and endpoint descriptor. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_GetConfigDescriptor( - uint64_t deviceId, uint8_t configIndex, struct UsbDdkConfigDescriptor ** const config); - -/** - * @brief Releases the configuration descriptor. To avoid memory leakage, use OH_Usb_FreeConfigDescriptor\n - * to release a descriptor after use. - * - * @param config Configuration descriptor obtained by calling OH_Usb_GetConfigDescriptor. - * @since 10 - * @version 1.0 - */ -void OH_Usb_FreeConfigDescriptor(struct UsbDdkConfigDescriptor * const config); - -/** - * @brief Claims a USB interface. - * - * @param deviceId ID of the device to be operated. - * @param interfaceIndex Interface index, which corresponds to bInterfaceNumber in the USB protocol. - * @param interfaceHandle Interface operation handle. After the interface is claimed successfully, a value will be\n - * assigned to this parameter. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_t *interfaceHandle); - -/** - * @brief Releases a USB interface. - * - * @param interfaceHandle Interface operation handle. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_ReleaseInterface(uint64_t interfaceHandle); - -/** - * @brief Activates the alternate setting of the USB interface. - * - * @param interfaceHandle Interface operation handle. - * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n - * in the USB protocol. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_SelectInterfaceSetting(uint64_t interfaceHandle, uint8_t settingIndex); - -/** - * @brief Obtains the activated alternate setting of the USB interface. - * - * @param interfaceHandle Interface operation handle. - * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n - * in the USB protocol. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_GetCurrentInterfaceSetting(uint64_t interfaceHandle, uint8_t *settingIndex); - -/** - * @brief Sends a control read transfer request. This API works in a synchronous manner. - * - * @param interfaceHandle Interface operation handle. - * @param setup Request data, which corresponds to Setup Data in the USB protocol. - * @param timeout Timeout duration, in milliseconds. - * @param data Data to be transferred. - * @param dataLen Data length. The return value indicates the length of the actually read data. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_SendControlReadRequest(uint64_t interfaceHandle, const struct UsbControlRequestSetup *setup, - uint32_t timeout, uint8_t *data, uint32_t *dataLen); - -/** - * @brief Sends a control write transfer request. This API works in a synchronous manner. - * - * @param interfaceHandle Interface operation handle. - * @param setup Request data, which corresponds to Setup Data in the USB protocol. - * @param timeout Timeout duration, in milliseconds. - * @param data Data to be transferred. - * @param dataLen Data length. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_SendControlWriteRequest(uint64_t interfaceHandle, const struct UsbControlRequestSetup *setup, - uint32_t timeout, const uint8_t *data, uint32_t dataLen); - -/** - * @brief Sends a pipe request. This API works in a synchronous manner. This API applies to interrupt transfer\n - * and bulk transfer. - * - * @param pipe Pipe used to transfer data. - * @param devMmap Device memory map, which can be obtained by calling OH_Usb_CreateDeviceMemMap. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_SendPipeRequest(const struct UsbRequestPipe *pipe, UsbDeviceMemMap *devMmap); - -/** - * @brief Creates a buffer. To avoid resource leakage, destroy a buffer by calling\n - * OH_Usb_DestroyDeviceMemMap after use. - * - * @param deviceId ID of the device for which the buffer is to be created. - * @param size Buffer size. - * @param devMmap Data memory map, through which the created buffer is returned to the caller. - * @return 0 if the operation is successful; a negative value otherwise. - * @since 10 - * @version 1.0 - */ -int32_t OH_Usb_CreateDeviceMemMap(uint64_t deviceId, size_t size, UsbDeviceMemMap **devMmap); - -/** - * @brief Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use. - * - * @param devMmap Device memory map created by calling OH_Usb_CreateDeviceMemMap. - * @since 10 - * @version 1.0 - */ -void OH_Usb_DestroyDeviceMemMap(UsbDeviceMemMap *devMmap); -/** @} */ -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +/* + * 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. + */ +#ifndef USB_DDK_API_H +#define USB_DDK_API_H + +/** + * @addtogroup UsbDdk + * @{ + * + * @brief Provides USB DDK APIs to open and close USB interfaces, perform non-isochronous and isochronous\n + * data transfer over USB pipes, and implement control transfer and interrupt transfer, etc. + * + * @syscap SystemCapability.Driver.USB.Extension + * @since 10 + * @version 1.0 + */ + +/** + * @file usb_ddk_api.h + * + * @brief Declares the USB DDK APIs used by the USB host to access USB devices. + * + * @since 10 + * @version 1.0 + */ + +#include + +#include "usb_ddk_types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Initializes the DDK. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_Init(void); + +/** + * @brief Releases the DDK. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @since 10 + * @version 1.0 + */ +void OH_Usb_Release(void); + +/** + * @brief Obtains the USB device descriptor. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param deviceId ID of the device whose descriptor is to be obtained. + * @param desc Standard device descriptor defined in the USB protocol. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_GetDeviceDescriptor(uint64_t deviceId, struct UsbDeviceDescriptor *desc); + +/** + * @brief Obtains the configuration descriptor. To avoid memory leakage, use OH_Usb_FreeConfigDescriptor\n + * to release a descriptor after use. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param deviceId ID of the device whose configuration descriptor is to be obtained. + * @param configIndex Configuration index, which corresponds to bConfigurationValue in the USB protocol. + * @param config Configuration descriptor, which includes the standard configuration descriptor defined in the\n + * USB protocol and the associated interface descriptor and endpoint descriptor. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_GetConfigDescriptor( + uint64_t deviceId, uint8_t configIndex, struct UsbDdkConfigDescriptor ** const config); + +/** + * @brief Releases the configuration descriptor. To avoid memory leakage, use OH_Usb_FreeConfigDescriptor\n + * to release a descriptor after use. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param config Configuration descriptor obtained by calling OH_Usb_GetConfigDescriptor. + * @since 10 + * @version 1.0 + */ +void OH_Usb_FreeConfigDescriptor(struct UsbDdkConfigDescriptor * const config); + +/** + * @brief Claims a USB interface. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param deviceId ID of the device to be operated. + * @param interfaceIndex Interface index, which corresponds to bInterfaceNumber in the USB protocol. + * @param interfaceHandle Interface operation handle. After the interface is claimed successfully, a value will be\n + * assigned to this parameter. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_t *interfaceHandle); + +/** + * @brief Releases a USB interface. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param interfaceHandle Interface operation handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_ReleaseInterface(uint64_t interfaceHandle); + +/** + * @brief Activates the alternate setting of the USB interface. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param interfaceHandle Interface operation handle. + * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n + * in the USB protocol. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_SelectInterfaceSetting(uint64_t interfaceHandle, uint8_t settingIndex); + +/** + * @brief Obtains the activated alternate setting of the USB interface. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param interfaceHandle Interface operation handle. + * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n + * in the USB protocol. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_GetCurrentInterfaceSetting(uint64_t interfaceHandle, uint8_t *settingIndex); + +/** + * @brief Sends a control read transfer request. This API works in a synchronous manner. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param interfaceHandle Interface operation handle. + * @param setup Request data, which corresponds to Setup Data in the USB protocol. + * @param timeout Timeout duration, in milliseconds. + * @param data Data to be transferred. + * @param dataLen Data length. The return value indicates the length of the actually read data. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_SendControlReadRequest(uint64_t interfaceHandle, const struct UsbControlRequestSetup *setup, + uint32_t timeout, uint8_t *data, uint32_t *dataLen); + +/** + * @brief Sends a control write transfer request. This API works in a synchronous manner. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param interfaceHandle Interface operation handle. + * @param setup Request data, which corresponds to Setup Data in the USB protocol. + * @param timeout Timeout duration, in milliseconds. + * @param data Data to be transferred. + * @param dataLen Data length. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_SendControlWriteRequest(uint64_t interfaceHandle, const struct UsbControlRequestSetup *setup, + uint32_t timeout, const uint8_t *data, uint32_t dataLen); + +/** + * @brief Sends a pipe request. This API works in a synchronous manner. This API applies to interrupt transfer\n + * and bulk transfer. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param pipe Pipe used to transfer data. + * @param devMmap Device memory map, which can be obtained by calling OH_Usb_CreateDeviceMemMap. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_SendPipeRequest(const struct UsbRequestPipe *pipe, UsbDeviceMemMap *devMmap); + +/** + * @brief Creates a buffer. To avoid resource leakage, destroy a buffer by calling\n + * OH_Usb_DestroyDeviceMemMap after use. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param deviceId ID of the device for which the buffer is to be created. + * @param size Buffer size. + * @param devMmap Data memory map, through which the created buffer is returned to the caller. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 10 + * @version 1.0 + */ +int32_t OH_Usb_CreateDeviceMemMap(uint64_t deviceId, size_t size, UsbDeviceMemMap **devMmap); + +/** + * @brief Destroys a buffer. To avoid resource leakage, destroy a buffer in time after use. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param devMmap Device memory map created by calling OH_Usb_CreateDeviceMemMap. + * @since 10 + * @version 1.0 + */ +void OH_Usb_DestroyDeviceMemMap(UsbDeviceMemMap *devMmap); +/** @} */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif // USB_DDK_API_H \ No newline at end of file diff --git a/drivers/external_device_manager/usb/usb_ddk_types.h b/drivers/external_device_manager/usb/usb_ddk_types.h index db511e0641fb2780ec44faa03311a78cd0da4d60..a675d929e50da3cd26b103407a611a339bdb69fc 100644 --- a/drivers/external_device_manager/usb/usb_ddk_types.h +++ b/drivers/external_device_manager/usb/usb_ddk_types.h @@ -1,316 +1,316 @@ -/* - * 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. - */ - -#ifndef USB_DDK_TYPES_H -#define USB_DDK_TYPES_H -/** - * @addtogroup UsbDdk - * @{ - * - * @brief Provides USB DDK types and declares the macros, enumerated variables, and\n - * data structures required by the USB DDK APIs. - * - * @syscap SystemCapability.Driver.USB.Extension - * @since 10 - * @version 1.0 - */ - -/** - * @file usb_ddk_types.h - * - * @brief Provides the enumerated variables, structures, and macros used in USB DDK APIs. - * - * @since 10 - * @version 1.0 - */ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ -/** - * @brief Setup data for control transfer. It corresponds to Setup Data in the USB protocol. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbControlRequestSetup { - /** Request type. */ - uint8_t bmRequestType; - /** Request command. */ - uint8_t bRequest; - /** Its meaning varies according to the request. */ - uint16_t wValue; - /** It is usually used to transfer the index or offset.\n - * Its meaning varies according to the request. - */ - uint16_t wIndex; - /** Data length. If data is transferred,\n - * this field indicates the number of transferred bytes. - */ - uint16_t wLength; -} __attribute__((aligned(8))) UsbControlRequestSetup; - -/** - * @brief Standard device descriptor, corresponding to Standard Device Descriptor in the USB protocol. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDeviceDescriptor { - /** Size of the descriptor, in bytes. */ - uint8_t bLength; - /** Descriptor type. */ - uint8_t bDescriptorType; - /** USB protocol release number. */ - uint16_t bcdUSB; - /** Device class code allocated by the USB-IF. */ - uint8_t bDeviceClass; - /** Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass. */ - uint8_t bDeviceSubClass; - /** Protocol code allocated by USB-IF. The value is limited by that of bDeviceClass and bDeviceSubClass. */ - uint8_t bDeviceProtocol; - /** Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid. */ - uint8_t bMaxPacketSize0; - /** Vendor ID allocated by USB-IF. */ - uint16_t idVendor; - /** Product ID allocated by the vendor. */ - uint16_t idProduct; - /** Device release number. */ - uint16_t bcdDevice; - /** Index of the string descriptor that describes the vendor. */ - uint8_t iManufacturer; - /** Index of the string descriptor that describes the product. */ - uint8_t iProduct; - /** Index of the string descriptor that describes the device SN. */ - uint8_t iSerialNumber; - /** Configuration quantity. */ - uint8_t bNumConfigurations; -} __attribute__((aligned(8))) UsbDeviceDescriptor; - -/** - * @brief Standard configuration descriptor, corresponding to Standard Configuration Descriptor\n - * in the USB protocol. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbConfigDescriptor { - /** Size of the descriptor, in bytes. */ - uint8_t bLength; - /** Descriptor type. */ - uint8_t bDescriptorType; - /** Total length of the configuration descriptor, including the configuration, interface, endpoint,\n - * and class- or vendor-specific descriptors. - */ - uint16_t wTotalLength; - /** Number of interfaces supported by the configuration. */ - uint8_t bNumInterfaces; - /** Configuration index, which is used to select the configuration. */ - uint8_t bConfigurationValue; - /** Index of the string descriptor that describes the configuration. */ - uint8_t iConfiguration; - /** Configuration attributes, including the power mode and remote wakeup. */ - uint8_t bmAttributes; - /** Maximum power consumption of the bus-powered USB device, in 2 mA. */ - uint8_t bMaxPower; -} __attribute__((packed)) UsbConfigDescriptor; - -/** - * @brief Standard interface descriptor, corresponding to Standard Interface Descriptor - * in the USB protocol. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbInterfaceDescriptor { - /** Size of the descriptor, in bytes. */ - uint8_t bLength; - /** Descriptor type. */ - uint8_t bDescriptorType; - /** Interface number. */ - uint8_t bInterfaceNumber; - /** Value used to select the alternate setting of the interface. */ - uint8_t bAlternateSetting; - /** Number of endpoints (excluding endpoint 0) used by the interface. */ - uint8_t bNumEndpoints; - /** Interface class code allocated by the USB-IF. */ - uint8_t bInterfaceClass; - /** Interface subclass code allocated by USB-IF. The value is limited by that of bInterfaceClass. */ - uint8_t bInterfaceSubClass; - /** Protocol code allocated by USB-IF. The value is limited by that of bInterfaceClass and bInterfaceSubClass. */ - uint8_t bInterfaceProtocol; - /** Index of the string descriptor that describes the interface. */ - uint8_t iInterface; -} __attribute__((packed)) UsbInterfaceDescriptor; - -/** - * @brief Standard endpoint descriptor, corresponding to Standard Endpoint Descriptor in the USB protocol. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbEndpointDescriptor { - /** Size of the descriptor, in bytes. */ - uint8_t bLength; - /** Descriptor type. */ - uint8_t bDescriptorType; - /** Endpoint address, including the endpoint number and endpoint direction. */ - uint8_t bEndpointAddress; - /** Endpoint attributes, including the transfer type, synchronization type, and usage type. */ - uint8_t bmAttributes; - /** Maximum packet size supported by an endpoint. */ - uint16_t wMaxPacketSize; - /** Interval for polling endpoints for data transfer. */ - uint8_t bInterval; - /** Refresh rate for audio devices. */ - uint8_t bRefresh; - /** Endpoint synchronization address for audio devices. */ - uint8_t bSynchAddress; -} __attribute__((packed)) UsbEndpointDescriptor; - -/** - * @brief Endpoint descriptor. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDdkEndpointDescriptor { - /** Standard endpoint descriptor. */ - struct UsbEndpointDescriptor endpointDescriptor; - /** Unresolved descriptor, including class- or vendor-specific descriptors. */ - const uint8_t *extra; - /** Length of the unresolved descriptor. */ - uint32_t extraLength; -} UsbDdkEndpointDescriptor; - -/** - * @brief Interface descriptor. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDdkInterfaceDescriptor { - /** Standard interface descriptor. */ - struct UsbInterfaceDescriptor interfaceDescriptor; - /** Endpoint descriptor contained in the interface. */ - struct UsbDdkEndpointDescriptor *endPoint; - /** Unresolved descriptor, including class- or vendor-specific descriptors. */ - const uint8_t *extra; - /** Length of the unresolved descriptor. */ - uint32_t extraLength; -} UsbDdkInterfaceDescriptor; - -/** - * @brief USB interface. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDdkInterface { - /** Number of alternate settings of the interface. */ - uint8_t numAltsetting; - /** Alternate setting of the interface. */ - struct UsbDdkInterfaceDescriptor *altsetting; -} UsbDdkInterface; - -/** - * @brief Configuration descriptor. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDdkConfigDescriptor { - /** Standard configuration descriptor. */ - struct UsbConfigDescriptor configDescriptor; - /** Interfaces contained in the configuration. */ - struct UsbDdkInterface *interface; - /** Unresolved descriptor, including class- or vendor-specific descriptors. */ - const uint8_t *extra; - /** Length of the unresolved descriptor. */ - uint32_t extraLength; -} UsbDdkConfigDescriptor; - -/** - * @brief Request pipe. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbRequestPipe { - /** Interface operation handle. */ - uint64_t interfaceHandle; - /** Timeout duration, in milliseconds. */ - uint32_t timeout; - /** Endpoint address. */ - uint8_t endpoint; -} __attribute__((aligned(8))) UsbRequestPipe; - -/** - * @brief Device memory map created by calling OH_Usb_CreateDeviceMemMap.\n - * A buffer using the device memory map can provide better performance. - * - * @since 10 - * @version 1.0 - */ -typedef struct UsbDeviceMemMap { - /** Buffer address. */ - uint8_t * const address; - /** Buffer size. */ - const size_t size; - /** Offset of the used buffer. The default value is 0, indicating that there is no offset\n - * and the buffer starts from the specified address. - */ - uint32_t offset; - /** Length of the used buffer. By default, the value is equal to the size, indicating that\n - * the entire buffer is used. - */ - uint32_t bufferLength; - /** Length of the transferred data. */ - uint32_t transferedLength; -} UsbDeviceMemMap; - -/** - * @brief Defines error codes for USB DDK. - * - * @since 10 - * @version 1.0 - */ -typedef enum { - /** The operation is successful. */ - USB_DDK_SUCCESS = 0, - /** The operation failed. */ - USB_DDK_FAILED = -1, - /** Invalid parameter. */ - USB_DDK_INVALID_PARAMETER = -2, - /** Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure. - */ - USB_DDK_MEMORY_ERROR = -3, - /** Invalid operation. */ - USB_DDK_INVALID_OPERATION = -4, - /** Null pointer exception */ - USB_DDK_NULL_PTR = -5, - /** Device busy. */ - USB_DDK_DEVICE_BUSY = -6, - /** Transmission timeout. */ - USB_DDK_TIMEOUT = -7 -} UsbDdkErrCode; -#ifdef __cplusplus -} -/** @} */ -#endif /* __cplusplus */ +/* + * 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. + */ + +#ifndef USB_DDK_TYPES_H +#define USB_DDK_TYPES_H +/** + * @addtogroup UsbDdk + * @{ + * + * @brief Provides USB DDK types and declares the macros, enumerated variables, and\n + * data structures required by the USB DDK APIs. + * + * @syscap SystemCapability.Driver.USB.Extension + * @since 10 + * @version 1.0 + */ + +/** + * @file usb_ddk_types.h + * + * @brief Provides the enumerated variables, structures, and macros used in USB DDK APIs. + * + * @since 10 + * @version 1.0 + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/** + * @brief Setup data for control transfer. It corresponds to Setup Data in the USB protocol. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbControlRequestSetup { + /** Request type. */ + uint8_t bmRequestType; + /** Request command. */ + uint8_t bRequest; + /** Its meaning varies according to the request. */ + uint16_t wValue; + /** It is usually used to transfer the index or offset.\n + * Its meaning varies according to the request. + */ + uint16_t wIndex; + /** Data length. If data is transferred,\n + * this field indicates the number of transferred bytes. + */ + uint16_t wLength; +} __attribute__((aligned(8))) UsbControlRequestSetup; + +/** + * @brief Standard device descriptor, corresponding to Standard Device Descriptor in the USB protocol. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDeviceDescriptor { + /** Size of the descriptor, in bytes. */ + uint8_t bLength; + /** Descriptor type. */ + uint8_t bDescriptorType; + /** USB protocol release number. */ + uint16_t bcdUSB; + /** Device class code allocated by the USB-IF. */ + uint8_t bDeviceClass; + /** Device subclass code allocated by USB-IF. The value is limited by that of bDeviceClass. */ + uint8_t bDeviceSubClass; + /** Protocol code allocated by USB-IF. The value is limited by that of bDeviceClass and bDeviceSubClass. */ + uint8_t bDeviceProtocol; + /** Maximum packet size of endpoint 0. Only values 8, 16, 32, and 64 are valid. */ + uint8_t bMaxPacketSize0; + /** Vendor ID allocated by USB-IF. */ + uint16_t idVendor; + /** Product ID allocated by the vendor. */ + uint16_t idProduct; + /** Device release number. */ + uint16_t bcdDevice; + /** Index of the string descriptor that describes the vendor. */ + uint8_t iManufacturer; + /** Index of the string descriptor that describes the product. */ + uint8_t iProduct; + /** Index of the string descriptor that describes the device SN. */ + uint8_t iSerialNumber; + /** Configuration quantity. */ + uint8_t bNumConfigurations; +} __attribute__((aligned(8))) UsbDeviceDescriptor; + +/** + * @brief Standard configuration descriptor, corresponding to Standard Configuration Descriptor\n + * in the USB protocol. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbConfigDescriptor { + /** Size of the descriptor, in bytes. */ + uint8_t bLength; + /** Descriptor type. */ + uint8_t bDescriptorType; + /** Total length of the configuration descriptor, including the configuration, interface, endpoint,\n + * and class- or vendor-specific descriptors. + */ + uint16_t wTotalLength; + /** Number of interfaces supported by the configuration. */ + uint8_t bNumInterfaces; + /** Configuration index, which is used to select the configuration. */ + uint8_t bConfigurationValue; + /** Index of the string descriptor that describes the configuration. */ + uint8_t iConfiguration; + /** Configuration attributes, including the power mode and remote wakeup. */ + uint8_t bmAttributes; + /** Maximum power consumption of the bus-powered USB device, in 2 mA. */ + uint8_t bMaxPower; +} __attribute__((packed)) UsbConfigDescriptor; + +/** + * @brief Standard interface descriptor, corresponding to Standard Interface Descriptor + * in the USB protocol. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbInterfaceDescriptor { + /** Size of the descriptor, in bytes. */ + uint8_t bLength; + /** Descriptor type. */ + uint8_t bDescriptorType; + /** Interface number. */ + uint8_t bInterfaceNumber; + /** Value used to select the alternate setting of the interface. */ + uint8_t bAlternateSetting; + /** Number of endpoints (excluding endpoint 0) used by the interface. */ + uint8_t bNumEndpoints; + /** Interface class code allocated by the USB-IF. */ + uint8_t bInterfaceClass; + /** Interface subclass code allocated by USB-IF. The value is limited by that of bInterfaceClass. */ + uint8_t bInterfaceSubClass; + /** Protocol code allocated by USB-IF. The value is limited by that of bInterfaceClass and bInterfaceSubClass. */ + uint8_t bInterfaceProtocol; + /** Index of the string descriptor that describes the interface. */ + uint8_t iInterface; +} __attribute__((packed)) UsbInterfaceDescriptor; + +/** + * @brief Standard endpoint descriptor, corresponding to Standard Endpoint Descriptor in the USB protocol. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbEndpointDescriptor { + /** Size of the descriptor, in bytes. */ + uint8_t bLength; + /** Descriptor type. */ + uint8_t bDescriptorType; + /** Endpoint address, including the endpoint number and endpoint direction. */ + uint8_t bEndpointAddress; + /** Endpoint attributes, including the transfer type, synchronization type, and usage type. */ + uint8_t bmAttributes; + /** Maximum packet size supported by an endpoint. */ + uint16_t wMaxPacketSize; + /** Interval for polling endpoints for data transfer. */ + uint8_t bInterval; + /** Refresh rate for audio devices. */ + uint8_t bRefresh; + /** Endpoint synchronization address for audio devices. */ + uint8_t bSynchAddress; +} __attribute__((packed)) UsbEndpointDescriptor; + +/** + * @brief Endpoint descriptor. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDdkEndpointDescriptor { + /** Standard endpoint descriptor. */ + struct UsbEndpointDescriptor endpointDescriptor; + /** Unresolved descriptor, including class- or vendor-specific descriptors. */ + const uint8_t *extra; + /** Length of the unresolved descriptor. */ + uint32_t extraLength; +} UsbDdkEndpointDescriptor; + +/** + * @brief Interface descriptor. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDdkInterfaceDescriptor { + /** Standard interface descriptor. */ + struct UsbInterfaceDescriptor interfaceDescriptor; + /** Endpoint descriptor contained in the interface. */ + struct UsbDdkEndpointDescriptor *endPoint; + /** Unresolved descriptor, including class- or vendor-specific descriptors. */ + const uint8_t *extra; + /** Length of the unresolved descriptor. */ + uint32_t extraLength; +} UsbDdkInterfaceDescriptor; + +/** + * @brief USB interface. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDdkInterface { + /** Number of alternate settings of the interface. */ + uint8_t numAltsetting; + /** Alternate setting of the interface. */ + struct UsbDdkInterfaceDescriptor *altsetting; +} UsbDdkInterface; + +/** + * @brief Configuration descriptor. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDdkConfigDescriptor { + /** Standard configuration descriptor. */ + struct UsbConfigDescriptor configDescriptor; + /** Interfaces contained in the configuration. */ + struct UsbDdkInterface *interface; + /** Unresolved descriptor, including class- or vendor-specific descriptors. */ + const uint8_t *extra; + /** Length of the unresolved descriptor. */ + uint32_t extraLength; +} UsbDdkConfigDescriptor; + +/** + * @brief Request pipe. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbRequestPipe { + /** Interface operation handle. */ + uint64_t interfaceHandle; + /** Timeout duration, in milliseconds. */ + uint32_t timeout; + /** Endpoint address. */ + uint8_t endpoint; +} __attribute__((aligned(8))) UsbRequestPipe; + +/** + * @brief Device memory map created by calling OH_Usb_CreateDeviceMemMap.\n + * A buffer using the device memory map can provide better performance. + * + * @since 10 + * @version 1.0 + */ +typedef struct UsbDeviceMemMap { + /** Buffer address. */ + uint8_t * const address; + /** Buffer size. */ + const size_t size; + /** Offset of the used buffer. The default value is 0, indicating that there is no offset\n + * and the buffer starts from the specified address. + */ + uint32_t offset; + /** Length of the used buffer. By default, the value is equal to the size, indicating that\n + * the entire buffer is used. + */ + uint32_t bufferLength; + /** Length of the transferred data. */ + uint32_t transferedLength; +} UsbDeviceMemMap; + +/** + * @brief Defines error codes for USB DDK. + * + * @since 10 + * @version 1.0 + */ +typedef enum { + /** The operation is successful. */ + USB_DDK_SUCCESS = 0, + /** The operation failed. */ + USB_DDK_FAILED = -1, + /** Invalid parameter. */ + USB_DDK_INVALID_PARAMETER = -2, + /** Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure. + */ + USB_DDK_MEMORY_ERROR = -3, + /** Invalid operation. */ + USB_DDK_INVALID_OPERATION = -4, + /** Null pointer exception */ + USB_DDK_NULL_PTR = -5, + /** Device busy. */ + USB_DDK_DEVICE_BUSY = -6, + /** Transmission timeout. */ + USB_DDK_TIMEOUT = -7 +} UsbDdkErrCode; +#ifdef __cplusplus +} +/** @} */ +#endif /* __cplusplus */ #endif // USB_DDK_TYPES_H \ No newline at end of file diff --git a/global/resource_management/BUILD.gn b/global/resource_management/BUILD.gn index d5c9057ab122f1b8cc518c93dd92d85d06be1241..efb898e41f1f2ccde32a878c9b898a846b32c2e8 100644 --- a/global/resource_management/BUILD.gn +++ b/global/resource_management/BUILD.gn @@ -1,29 +1,29 @@ -# Copyright (c) 2022 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") - -ohos_ndk_library("librawfile_ndk") { - ndk_description_file = "./librawfile.ndk.json" - min_compact_version = "1" - output_name = "rawfile" -} - -ohos_ndk_headers("rawfile_header") { - dest_dir = "$ndk_headers_out_dir/rawfile" - sources = [ - "./include/raw_dir.h", - "./include/raw_file.h", - "./include/raw_file_manager.h", - ] -} +# Copyright (c) 2022 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") + +ohos_ndk_library("librawfile_ndk") { + ndk_description_file = "./librawfile.ndk.json" + min_compact_version = "1" + output_name = "rawfile" +} + +ohos_ndk_headers("rawfile_header") { + dest_dir = "$ndk_headers_out_dir/rawfile" + sources = [ + "./include/raw_dir.h", + "./include/raw_file.h", + "./include/raw_file_manager.h", + ] +} diff --git a/global/resource_management/include/raw_dir.h b/global/resource_management/include/raw_dir.h index 76a618ecce38f1c55ee518d7ac1d556e3dc7abaa..7d1742562cd9a05aea7b4bddf357fe6ac5e6d09f 100644 --- a/global/resource_management/include/raw_dir.h +++ b/global/resource_management/include/raw_dir.h @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2022 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 rawfile - * @{ - * - * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. - * - * You can use the resource manager to traverse, open, seek, read, and close raw files. - * - * @since 8 - * @version 1.0 - */ - -/** - * @file raw_dir.h - * - * @brief Declares native functions related to raw file directories. - * - * For example, you can use the functions to traverse and close a raw file directory, and reset its index. - * - * @since 8 - * @version 1.0 - */ -#ifndef GLOBAL_RAW_DIR_H -#define GLOBAL_RAW_DIR_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct RawDir; - -/** - * @brief Provides access to a raw file directory. - * - * - * - * @since 8 - * @version 1.0 - */ -typedef struct RawDir RawDir; - -/** - * @brief Obtains the name of the file according to the index. - * - * You can use this method to traverse a raw file directory. - * - * @param rawDir Indicates the pointer to {@link RawDir}. - * @param index Indicates the file index in {@link RawDir}. - * @return Returns the name of the file according to the index, - * which can be passed to {@link OH_ResourceManager_OpenRawFile} as an input parameter; - * returns NULL if all files are returned. - * @see OH_ResourceManager_OpenRawFile - * @since 8 - * @version 1.0 - */ -const char *OH_ResourceManager_GetRawFileName(RawDir *rawDir, int index); - -/** - * @brief get the count of the raw files in {@link RawDir}. - * - * You can use this method to get the valid index of {@link OH_ResourceManager_GetRawFileName}. - * - * @param rawDir Indicates the pointer to {@link RawDir}. - * @see OH_ResourceManager_GetRawFileName - * @since 8 - * @version 1.0 - */ -int OH_ResourceManager_GetRawFileCount(RawDir *rawDir); - -/** - * @brief Closes an opened {@link RawDir} and releases all associated resources. - * - * - * - * @param rawDir Indicates the pointer to {@link RawDir}. - * @see OH_ResourceManager_OpenRawDir - * @since 8 - * @version 1.0 - */ -void OH_ResourceManager_CloseRawDir(RawDir *rawDir); - -#ifdef __cplusplus -}; -#endif - -/** @} */ -#endif // GLOBAL_RAW_DIR_H +/* + * Copyright (c) 2022 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 rawfile + * @{ + * + * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. + * + * You can use the resource manager to traverse, open, seek, read, and close raw files. + * + * @since 8 + * @version 1.0 + */ + +/** + * @file raw_dir.h + * + * @brief Declares native functions related to raw file directories. + * + * For example, you can use the functions to traverse and close a raw file directory, and reset its index. + * + * @since 8 + * @version 1.0 + */ +#ifndef GLOBAL_RAW_DIR_H +#define GLOBAL_RAW_DIR_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct RawDir; + +/** + * @brief Provides access to a raw file directory. + * + * + * + * @since 8 + * @version 1.0 + */ +typedef struct RawDir RawDir; + +/** + * @brief Obtains the name of the file according to the index. + * + * You can use this method to traverse a raw file directory. + * + * @param rawDir Indicates the pointer to {@link RawDir}. + * @param index Indicates the file index in {@link RawDir}. + * @return Returns the name of the file according to the index, + * which can be passed to {@link OH_ResourceManager_OpenRawFile} as an input parameter; + * returns NULL if all files are returned. + * @see OH_ResourceManager_OpenRawFile + * @since 8 + * @version 1.0 + */ +const char *OH_ResourceManager_GetRawFileName(RawDir *rawDir, int index); + +/** + * @brief get the count of the raw files in {@link RawDir}. + * + * You can use this method to get the valid index of {@link OH_ResourceManager_GetRawFileName}. + * + * @param rawDir Indicates the pointer to {@link RawDir}. + * @see OH_ResourceManager_GetRawFileName + * @since 8 + * @version 1.0 + */ +int OH_ResourceManager_GetRawFileCount(RawDir *rawDir); + +/** + * @brief Closes an opened {@link RawDir} and releases all associated resources. + * + * + * + * @param rawDir Indicates the pointer to {@link RawDir}. + * @see OH_ResourceManager_OpenRawDir + * @since 8 + * @version 1.0 + */ +void OH_ResourceManager_CloseRawDir(RawDir *rawDir); + +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif // GLOBAL_RAW_DIR_H diff --git a/global/resource_management/include/raw_file.h b/global/resource_management/include/raw_file.h index 3b58a7fb07535459a6a6c86389258a552006c1ec..b85ee895775481232a61aad859982308f7926962 100644 --- a/global/resource_management/include/raw_file.h +++ b/global/resource_management/include/raw_file.h @@ -1,173 +1,173 @@ -/* - * Copyright (c) 2022 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 rawfile - * @{ - * - * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. - * - * You can use the resource manager to traverse, open, seek, read, and close raw files. - * - * @since 8 - * @version 1.0 - */ - -/** - * @file raw_file.h - * - * @brief Declares native functions related to raw file. - * - * For example, you can use the functions to search for, read, and close raw files. - * - * @since 8 - * @version 1.0 - */ -#ifndef GLOBAL_RAW_FILE_H -#define GLOBAL_RAW_FILE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct RawFile; - -/** - * @brief Provides access to a raw file. - * - * - * - * @since 8 - * @version 1.0 - */ -typedef struct RawFile RawFile; - -/** - * @brief Represent the raw file descriptor's info. - * - * The RawFileDescriptor is an output parameter in the {@link OH_ResourceManager_GetRawFileDescriptor}, - * and describes the raw file's file descriptor, start position and the length in the HAP. - * - * @since 8 - * @version 1.0 - */ -typedef struct { - /** the raw file fd */ - int fd; - - /** the offset from where the raw file starts in the HAP */ - long start; - - /** the length of the raw file in the HAP. */ - long length; -} RawFileDescriptor; - -/** - * @brief Reads a raw file. - * - * This function attempts to read data of length bytes from the current offset. - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @param buf Indicates the pointer to the buffer for receiving the data read. - * @param length Indicates the number of bytes to read. - * @return Returns the number of bytes read if any; returns 0 if the number reaches the end of file (EOF). - * @since 8 - * @version 1.0 - */ -int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length); - -/** - * @brief Uses the 32-bit data type to seek a data read/write position based on the specified offset within a raw file. - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @param offset Indicates the specified offset. - * @param whence Indicates the new read/write position, which can be one of the following values: \n - * 0: The new read/write position is set to offset. \n - * 1: The read/write position is set to the current position plus offset. \n - * 2: The read/write position is set to the end of file (EOF) plus offset. - * @return Returns the new read/write position if the operation is successful; returns (long) -1 if an error - * occurs. - * @since 8 - * @version 1.0 - */ -int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence); - -/** - * @brief Obtains the raw file length represented by an int32_t. - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @return Returns the total length of the raw file. - * @since 8 - * @version 1.0 - */ -long OH_ResourceManager_GetRawFileSize(RawFile *rawFile); - -/** - * @brief Closes an opened {@link RawFile} and releases all associated resources. - * - * - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @see OH_ResourceManager_OpenRawFile - * @since 8 - * @version 1.0 - */ -void OH_ResourceManager_CloseRawFile(RawFile *rawFile); - -/** - * @brief Obtains the current offset of a raw file, represented by an int32_t. - * - * The current offset of a raw file. - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @return Returns the current offset of a raw file. - * @since 8 - * @version 1.0 - */ -long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile); - -/** - * @brief Opens the file descriptor of a raw file based on the int32_t offset and file length. - * - * The opened raw file descriptor is used to read the raw file. - * - * @param rawFile Indicates the pointer to {@link RawFile}. - * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP. - * @return Returns true: open the raw file descriptor successfully, false: the raw file is not allowed to access. - * @since 8 - * @version 1.0 - */ -bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor); - -/** - * @brief Closes the file descriptor of a raw file. - * - * The opened raw file descriptor must be released after used to avoid the file descriptor leak. - * - * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP. - * @return Returns true: closes the raw file descriptor successfully, false: closes the raw file descriptor failed. - * @since 8 - * @version 1.0 - */ -bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor); - -#ifdef __cplusplus -}; -#endif - -/** @} */ -#endif // GLOBAL_RAW_FILE_H +/* + * Copyright (c) 2022 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 rawfile + * @{ + * + * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. + * + * You can use the resource manager to traverse, open, seek, read, and close raw files. + * + * @since 8 + * @version 1.0 + */ + +/** + * @file raw_file.h + * + * @brief Declares native functions related to raw file. + * + * For example, you can use the functions to search for, read, and close raw files. + * + * @since 8 + * @version 1.0 + */ +#ifndef GLOBAL_RAW_FILE_H +#define GLOBAL_RAW_FILE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct RawFile; + +/** + * @brief Provides access to a raw file. + * + * + * + * @since 8 + * @version 1.0 + */ +typedef struct RawFile RawFile; + +/** + * @brief Represent the raw file descriptor's info. + * + * The RawFileDescriptor is an output parameter in the {@link OH_ResourceManager_GetRawFileDescriptor}, + * and describes the raw file's file descriptor, start position and the length in the HAP. + * + * @since 8 + * @version 1.0 + */ +typedef struct { + /** the raw file fd */ + int fd; + + /** the offset from where the raw file starts in the HAP */ + long start; + + /** the length of the raw file in the HAP. */ + long length; +} RawFileDescriptor; + +/** + * @brief Reads a raw file. + * + * This function attempts to read data of length bytes from the current offset. + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @param buf Indicates the pointer to the buffer for receiving the data read. + * @param length Indicates the number of bytes to read. + * @return Returns the number of bytes read if any; returns 0 if the number reaches the end of file (EOF). + * @since 8 + * @version 1.0 + */ +int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length); + +/** + * @brief Uses the 32-bit data type to seek a data read/write position based on the specified offset within a raw file. + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @param offset Indicates the specified offset. + * @param whence Indicates the new read/write position, which can be one of the following values: \n + * 0: The new read/write position is set to offset. \n + * 1: The read/write position is set to the current position plus offset. \n + * 2: The read/write position is set to the end of file (EOF) plus offset. + * @return Returns the new read/write position if the operation is successful; returns (long) -1 if an error + * occurs. + * @since 8 + * @version 1.0 + */ +int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence); + +/** + * @brief Obtains the raw file length represented by an int32_t. + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @return Returns the total length of the raw file. + * @since 8 + * @version 1.0 + */ +long OH_ResourceManager_GetRawFileSize(RawFile *rawFile); + +/** + * @brief Closes an opened {@link RawFile} and releases all associated resources. + * + * + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @see OH_ResourceManager_OpenRawFile + * @since 8 + * @version 1.0 + */ +void OH_ResourceManager_CloseRawFile(RawFile *rawFile); + +/** + * @brief Obtains the current offset of a raw file, represented by an int32_t. + * + * The current offset of a raw file. + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @return Returns the current offset of a raw file. + * @since 8 + * @version 1.0 + */ +long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile); + +/** + * @brief Opens the file descriptor of a raw file based on the int32_t offset and file length. + * + * The opened raw file descriptor is used to read the raw file. + * + * @param rawFile Indicates the pointer to {@link RawFile}. + * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP. + * @return Returns true: open the raw file descriptor successfully, false: the raw file is not allowed to access. + * @since 8 + * @version 1.0 + */ +bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor); + +/** + * @brief Closes the file descriptor of a raw file. + * + * The opened raw file descriptor must be released after used to avoid the file descriptor leak. + * + * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP. + * @return Returns true: closes the raw file descriptor successfully, false: closes the raw file descriptor failed. + * @since 8 + * @version 1.0 + */ +bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor); + +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif // GLOBAL_RAW_FILE_H diff --git a/global/resource_management/include/raw_file_manager.h b/global/resource_management/include/raw_file_manager.h index f76a9c8cf1b45ab0abfe30f5949a2a0ec14ed120..2daca96dbe9ddbfe179c28e415b6f39f225aef58 100644 --- a/global/resource_management/include/raw_file_manager.h +++ b/global/resource_management/include/raw_file_manager.h @@ -1,126 +1,126 @@ -/* - * Copyright (c) 2022 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 rawfile - * @{ - * - * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. - * - * You can use the resource manager to traverse, open, seek, read, and close raw files. - * - * @since 8 - * @version 1.0 - */ - -/** - * @file raw_file_manager.h - * - * @brief Declares native functions for the resource manager. - * - * You can use the resource manager to open raw files for subsequent operations, such as seeking and reading. - * - * @since 8 - * @version 1.0 - */ -#ifndef GLOBAL_NATIVE_RESOURCE_MANAGER_H -#define GLOBAL_NATIVE_RESOURCE_MANAGER_H - -#include "napi/native_api.h" -#include "raw_dir.h" -#include "raw_file.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct NativeResourceManager; - -/** - * @brief Presents the resource manager. - * - * This class encapsulates the native implementation of the JavaScript resource manager. The pointer to a - * ResourceManager object can be obtained by calling {@link OH_ResourceManager_InitNativeResourceManager}. - * - * @since 8 - * @version 1.0 - */ -typedef struct NativeResourceManager NativeResourceManager; - -/** - * @brief Obtains the native resource manager based on the JavaScipt resource manager. - * - * You need to obtain the resource manager to process raw files as required. - * - * @param env Indicates the pointer to the JavaScipt Native Interface (napi) environment. - * @param jsResMgr Indicates the JavaScipt resource manager. - * @return Returns the pointer to {@link NativeResourceManager}. - * @since 8 - * @version 1.0 - */ -NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr); - -/** - * @brief Releases the native resource manager. - * - * - * - * @param resMgr Indicates the pointer to {@link RawDir}. - * @since 8 - * @version 1.0 - */ -void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr); - -/** - * @brief Opens a raw file directory. - * - * After it is opened, you can traverse its raw files. - * - * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling - * {@link OH_ResourceManager_InitNativeResourceManager}. - * @param dirName Indicates the name of the raw file directory to open. You can pass an empty string to open the - * top-level raw file directory. - * @return Returns the pointer to {@link RawDir}. After you finish using the pointer, call - * {@link OH_ResourceManager_CloseRawDir} to release it. - * @see OH_ResourceManager_InitNativeResourceManager - * @see OH_ResourceManager_CloseRawDir - * @since 8 - * @version 1.0 - */ -RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName); - -/** - * @brief Opens a raw file. - * - * After it is opened, you can read its data. - * - * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling - * {@link OH_ResourceManager_InitNativeResourceManager}. - * @param fileName Indicates the file path relative to the top-level raw file directory. - * @return Returns the pointer to {@link RawFile}. After you finish using the pointer, call - * {@link OH_ResourceManager_CloseRawFile} to release it. - * @see OH_ResourceManager_InitNativeResourceManager - * @see OH_ResourceManager_CloseRawFile - * @since 8 - * @version 1.0 - */ -RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName); - -#ifdef __cplusplus -}; -#endif - -/** @} */ -#endif // GLOBAL_NATIVE_RESOURCE_MANAGER_H +/* + * Copyright (c) 2022 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 rawfile + * @{ + * + * @brief Provides native functions for the resource manager to operate raw file directories and their raw files. + * + * You can use the resource manager to traverse, open, seek, read, and close raw files. + * + * @since 8 + * @version 1.0 + */ + +/** + * @file raw_file_manager.h + * + * @brief Declares native functions for the resource manager. + * + * You can use the resource manager to open raw files for subsequent operations, such as seeking and reading. + * + * @since 8 + * @version 1.0 + */ +#ifndef GLOBAL_NATIVE_RESOURCE_MANAGER_H +#define GLOBAL_NATIVE_RESOURCE_MANAGER_H + +#include "napi/native_api.h" +#include "raw_dir.h" +#include "raw_file.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct NativeResourceManager; + +/** + * @brief Presents the resource manager. + * + * This class encapsulates the native implementation of the JavaScript resource manager. The pointer to a + * ResourceManager object can be obtained by calling {@link OH_ResourceManager_InitNativeResourceManager}. + * + * @since 8 + * @version 1.0 + */ +typedef struct NativeResourceManager NativeResourceManager; + +/** + * @brief Obtains the native resource manager based on the JavaScipt resource manager. + * + * You need to obtain the resource manager to process raw files as required. + * + * @param env Indicates the pointer to the JavaScipt Native Interface (napi) environment. + * @param jsResMgr Indicates the JavaScipt resource manager. + * @return Returns the pointer to {@link NativeResourceManager}. + * @since 8 + * @version 1.0 + */ +NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr); + +/** + * @brief Releases the native resource manager. + * + * + * + * @param resMgr Indicates the pointer to {@link RawDir}. + * @since 8 + * @version 1.0 + */ +void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr); + +/** + * @brief Opens a raw file directory. + * + * After it is opened, you can traverse its raw files. + * + * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling + * {@link OH_ResourceManager_InitNativeResourceManager}. + * @param dirName Indicates the name of the raw file directory to open. You can pass an empty string to open the + * top-level raw file directory. + * @return Returns the pointer to {@link RawDir}. After you finish using the pointer, call + * {@link OH_ResourceManager_CloseRawDir} to release it. + * @see OH_ResourceManager_InitNativeResourceManager + * @see OH_ResourceManager_CloseRawDir + * @since 8 + * @version 1.0 + */ +RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName); + +/** + * @brief Opens a raw file. + * + * After it is opened, you can read its data. + * + * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling + * {@link OH_ResourceManager_InitNativeResourceManager}. + * @param fileName Indicates the file path relative to the top-level raw file directory. + * @return Returns the pointer to {@link RawFile}. After you finish using the pointer, call + * {@link OH_ResourceManager_CloseRawFile} to release it. + * @see OH_ResourceManager_InitNativeResourceManager + * @see OH_ResourceManager_CloseRawFile + * @since 8 + * @version 1.0 + */ +RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName); + +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif // GLOBAL_NATIVE_RESOURCE_MANAGER_H diff --git a/global/resource_management/librawfile.ndk.json b/global/resource_management/librawfile.ndk.json index 411dbc53df47a8de233c51037951b54999958a94..dcbfa113895a8a4f0e330c8c176d40212d89aa47 100644 --- a/global/resource_management/librawfile.ndk.json +++ b/global/resource_management/librawfile.ndk.json @@ -1,44 +1,44 @@ -[ - { - "name": "OH_ResourceManager_InitNativeResourceManager" - }, - { - "name": "OH_ResourceManager_ReleaseNativeResourceManager" - }, - { - "name": "OH_ResourceManager_OpenRawDir" - }, - { - "name": "OH_ResourceManager_OpenRawFile" - }, - { - "name": "OH_ResourceManager_GetRawFileName" - }, - { - "name": "OH_ResourceManager_GetRawFileCount" - }, - { - "name": "OH_ResourceManager_CloseRawDir" - }, - { - "name": "OH_ResourceManager_ReadRawFile" - }, - { - "name": "OH_ResourceManager_SeekRawFile" - }, - { - "name": "OH_ResourceManager_GetRawFileSize" - }, - { - "name": "OH_ResourceManager_CloseRawFile" - }, - { - "name": "OH_ResourceManager_GetRawFileOffset" - }, - { - "name": "OH_ResourceManager_GetRawFileDescriptor" - }, - { - "name": "OH_ResourceManager_ReleaseRawFileDescriptor" - } +[ + { + "name": "OH_ResourceManager_InitNativeResourceManager" + }, + { + "name": "OH_ResourceManager_ReleaseNativeResourceManager" + }, + { + "name": "OH_ResourceManager_OpenRawDir" + }, + { + "name": "OH_ResourceManager_OpenRawFile" + }, + { + "name": "OH_ResourceManager_GetRawFileName" + }, + { + "name": "OH_ResourceManager_GetRawFileCount" + }, + { + "name": "OH_ResourceManager_CloseRawDir" + }, + { + "name": "OH_ResourceManager_ReadRawFile" + }, + { + "name": "OH_ResourceManager_SeekRawFile" + }, + { + "name": "OH_ResourceManager_GetRawFileSize" + }, + { + "name": "OH_ResourceManager_CloseRawFile" + }, + { + "name": "OH_ResourceManager_GetRawFileOffset" + }, + { + "name": "OH_ResourceManager_GetRawFileDescriptor" + }, + { + "name": "OH_ResourceManager_ReleaseRawFileDescriptor" + } ] \ No newline at end of file diff --git a/graphic/graphic_2d/EGL/BUILD.gn b/graphic/graphic_2d/EGL/BUILD.gn index 6bb373b0071397f7b42d31f321c00da24d87a820..7b08b3bf7d130c30bb47393f0e49fd4e74d26543 100644 --- a/graphic/graphic_2d/EGL/BUILD.gn +++ b/graphic/graphic_2d/EGL/BUILD.gn @@ -1,36 +1,36 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("EGL_header") { - dest_dir = "$ndk_headers_out_dir/EGL" - sources = [ - "//interface/sdk_c/third_party/egl/EGL/egl.h", - "//interface/sdk_c/third_party/egl/EGL/eglext.h", - "//interface/sdk_c/third_party/egl/EGL/eglplatform.h", - ] -} - -ohos_ndk_library("libEGL_ndk") { - output_name = "EGL" - output_extension = "so" - ndk_description_file = "./libEGL.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.EGL" - system_capability_headers = [ - "EGL/egl.h", - "EGL/eglext.h", - "EGL/eglplatform.h", - ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("EGL_header") { + dest_dir = "$ndk_headers_out_dir/EGL" + sources = [ + "//interface/sdk_c/third_party/egl/EGL/egl.h", + "//interface/sdk_c/third_party/egl/EGL/eglext.h", + "//interface/sdk_c/third_party/egl/EGL/eglplatform.h", + ] +} + +ohos_ndk_library("libEGL_ndk") { + output_name = "EGL" + output_extension = "so" + ndk_description_file = "./libEGL.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.EGL" + system_capability_headers = [ + "EGL/egl.h", + "EGL/eglext.h", + "EGL/eglplatform.h", + ] +} diff --git a/graphic/graphic_2d/EGL/libEGL.ndk.json b/graphic/graphic_2d/EGL/libEGL.ndk.json index 5054487784bcdc3ed09f8f0438f8922d8815ffe5..64c18931d312cd28ec80a195e2a7e3a5ce45a342 100644 --- a/graphic/graphic_2d/EGL/libEGL.ndk.json +++ b/graphic/graphic_2d/EGL/libEGL.ndk.json @@ -1,46 +1,46 @@ -[ - { "name": "eglChooseConfig" }, - { "name": "eglCopyBuffers" }, - { "name": "eglCreateContext" }, - { "name": "eglCreatePbufferSurface" }, - { "name": "eglCreatePixmapSurface" }, - { "name": "eglCreateWindowSurface" }, - { "name": "eglDestroyContext" }, - { "name": "eglDestroySurface" }, - { "name": "eglGetConfigAttrib" }, - { "name": "eglGetConfigs" }, - { "name": "eglGetCurrentDisplay" }, - { "name": "eglGetCurrentSurface" }, - { "name": "eglGetDisplay" }, - { "name": "eglGetError" }, - { "name": "eglGetProcAddress" }, - { "name": "eglInitialize" }, - { "name": "eglMakeCurrent" }, - { "name": "eglQueryContext" }, - { "name": "eglQueryString" }, - { "name": "eglQuerySurface" }, - { "name": "eglSwapBuffers" }, - { "name": "eglTerminate" }, - { "name": "eglWaitGL" }, - { "name": "eglWaitNative" }, - { "name": "eglBindTexImage" }, - { "name": "eglReleaseTexImage" }, - { "name": "eglSurfaceAttrib" }, - { "name": "eglSwapInterval" }, - { "name": "eglBindAPI" }, - { "name": "eglQueryAPI" }, - { "name": "eglCreatePbufferFromClientBuffer" }, - { "name": "eglReleaseThread" }, - { "name": "eglWaitClient" }, - { "name": "eglGetCurrentContext" }, - { "name": "eglCreateSync" }, - { "name": "eglDestroySync" }, - { "name": "eglClientWaitSync" }, - { "name": "eglGetSyncAttrib" }, - { "name": "eglCreateImage" }, - { "name": "eglDestroyImage" }, - { "name": "eglGetPlatformDisplay" }, - { "name": "eglCreatePlatformWindowSurface" }, - { "name": "eglCreatePlatformPixmapSurface" }, - { "name": "eglWaitSync" } -] +[ + { "name": "eglChooseConfig" }, + { "name": "eglCopyBuffers" }, + { "name": "eglCreateContext" }, + { "name": "eglCreatePbufferSurface" }, + { "name": "eglCreatePixmapSurface" }, + { "name": "eglCreateWindowSurface" }, + { "name": "eglDestroyContext" }, + { "name": "eglDestroySurface" }, + { "name": "eglGetConfigAttrib" }, + { "name": "eglGetConfigs" }, + { "name": "eglGetCurrentDisplay" }, + { "name": "eglGetCurrentSurface" }, + { "name": "eglGetDisplay" }, + { "name": "eglGetError" }, + { "name": "eglGetProcAddress" }, + { "name": "eglInitialize" }, + { "name": "eglMakeCurrent" }, + { "name": "eglQueryContext" }, + { "name": "eglQueryString" }, + { "name": "eglQuerySurface" }, + { "name": "eglSwapBuffers" }, + { "name": "eglTerminate" }, + { "name": "eglWaitGL" }, + { "name": "eglWaitNative" }, + { "name": "eglBindTexImage" }, + { "name": "eglReleaseTexImage" }, + { "name": "eglSurfaceAttrib" }, + { "name": "eglSwapInterval" }, + { "name": "eglBindAPI" }, + { "name": "eglQueryAPI" }, + { "name": "eglCreatePbufferFromClientBuffer" }, + { "name": "eglReleaseThread" }, + { "name": "eglWaitClient" }, + { "name": "eglGetCurrentContext" }, + { "name": "eglCreateSync" }, + { "name": "eglDestroySync" }, + { "name": "eglClientWaitSync" }, + { "name": "eglGetSyncAttrib" }, + { "name": "eglCreateImage" }, + { "name": "eglDestroyImage" }, + { "name": "eglGetPlatformDisplay" }, + { "name": "eglCreatePlatformWindowSurface" }, + { "name": "eglCreatePlatformPixmapSurface" }, + { "name": "eglWaitSync" } +] diff --git a/graphic/graphic_2d/GLES3/BUILD.gn b/graphic/graphic_2d/GLES3/BUILD.gn index bdc9a5349310a6218e560cc043a5b1f5b2a02693..f09312e57ef4f5d23de3c37cc060f6386b1a78af 100644 --- a/graphic/graphic_2d/GLES3/BUILD.gn +++ b/graphic/graphic_2d/GLES3/BUILD.gn @@ -1,38 +1,38 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("GLES3_header") { - dest_dir = "$ndk_headers_out_dir/GLES3" - sources = [ - "//interface/sdk_c/third_party/openGLES/GLES3/gl3.h", - "//interface/sdk_c/third_party/openGLES/GLES3/gl31.h", - "//interface/sdk_c/third_party/openGLES/GLES3/gl32.h", - "//interface/sdk_c/third_party/openGLES/GLES3/gl3platform.h", - ] -} - -ohos_ndk_library("libGLESv3_ndk") { - output_name = "GLESv3" - output_extension = "so" - ndk_description_file = "./libGLESv3.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.GLES3" - system_capability_headers = [ - "GLES3/gl3.h", - "GLES3/gl31.h", - "GLES3/gl32.h", - "GLES3/gl3platform.h", - ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("GLES3_header") { + dest_dir = "$ndk_headers_out_dir/GLES3" + sources = [ + "//interface/sdk_c/third_party/openGLES/GLES3/gl3.h", + "//interface/sdk_c/third_party/openGLES/GLES3/gl31.h", + "//interface/sdk_c/third_party/openGLES/GLES3/gl32.h", + "//interface/sdk_c/third_party/openGLES/GLES3/gl3platform.h", + ] +} + +ohos_ndk_library("libGLESv3_ndk") { + output_name = "GLESv3" + output_extension = "so" + ndk_description_file = "./libGLESv3.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.GLES3" + system_capability_headers = [ + "GLES3/gl3.h", + "GLES3/gl31.h", + "GLES3/gl32.h", + "GLES3/gl3platform.h", + ] +} diff --git a/graphic/graphic_2d/GLES3/libGLESv3.ndk.json b/graphic/graphic_2d/GLES3/libGLESv3.ndk.json index ee6870afe58a3086048176619427170428086ac3..6c6f0fb63a43e330b5b261518cb1d61d9a6c4bcc 100644 --- a/graphic/graphic_2d/GLES3/libGLESv3.ndk.json +++ b/graphic/graphic_2d/GLES3/libGLESv3.ndk.json @@ -1,360 +1,360 @@ -[ - { "name": "glActiveShaderProgram" }, - { "name": "glActiveTexture" }, - { "name": "glAttachShader" }, - { "name": "glBeginQuery" }, - { "name": "glBeginTransformFeedback" }, - { "name": "glBindAttribLocation" }, - { "name": "glBindBuffer" }, - { "name": "glBindBufferBase" }, - { "name": "glBindBufferRange" }, - { "name": "glBindFramebuffer" }, - { "name": "glBindImageTexture" }, - { "name": "glBindProgramPipeline" }, - { "name": "glBindRenderbuffer" }, - { "name": "glBindSampler" }, - { "name": "glBindTexture" }, - { "name": "glBindTransformFeedback" }, - { "name": "glBindVertexArray" }, - { "name": "glBindVertexBuffer" }, - { "name": "glBlendBarrier" }, - { "name": "glBlendColor" }, - { "name": "glBlendEquation" }, - { "name": "glBlendEquationi" }, - { "name": "glBlendEquationSeparate" }, - { "name": "glBlendEquationSeparatei" }, - { "name": "glBlendFunc" }, - { "name": "glBlendFunci" }, - { "name": "glBlendFuncSeparate" }, - { "name": "glBlendFuncSeparatei" }, - { "name": "glBlitFramebuffer" }, - { "name": "glBufferData" }, - { "name": "glBufferSubData" }, - { "name": "glCheckFramebufferStatus" }, - { "name": "glClear" }, - { "name": "glClearBufferfi" }, - { "name": "glClearBufferfv" }, - { "name": "glClearBufferiv" }, - { "name": "glClearBufferuiv" }, - { "name": "glClearColor" }, - { "name": "glClearDepthf" }, - { "name": "glClearStencil" }, - { "name": "glClientWaitSync" }, - { "name": "glColorMask" }, - { "name": "glColorMaski" }, - { "name": "glCompileShader" }, - { "name": "glCompressedTexImage2D" }, - { "name": "glCompressedTexImage3D" }, - { "name": "glCompressedTexSubImage2D" }, - { "name": "glCompressedTexSubImage3D" }, - { "name": "glCopyBufferSubData" }, - { "name": "glCopyImageSubData" }, - { "name": "glCopyTexImage2D" }, - { "name": "glCopyTexSubImage2D" }, - { "name": "glCopyTexSubImage3D" }, - { "name": "glCreateProgram" }, - { "name": "glCreateShader" }, - { "name": "glCreateShaderProgramv" }, - { "name": "glCullFace" }, - { "name": "glDebugMessageCallback" }, - { "name": "glDebugMessageControl" }, - { "name": "glDebugMessageInsert" }, - { "name": "glDeleteBuffers" }, - { "name": "glDeleteFramebuffers" }, - { "name": "glDeleteProgram" }, - { "name": "glDeleteProgramPipelines" }, - { "name": "glDeleteQueries" }, - { "name": "glDeleteRenderbuffers" }, - { "name": "glDeleteSamplers" }, - { "name": "glDeleteShader" }, - { "name": "glDeleteSync" }, - { "name": "glDeleteTextures" }, - { "name": "glDeleteTransformFeedbacks" }, - { "name": "glDeleteVertexArrays" }, - { "name": "glDepthFunc" }, - { "name": "glDepthMask" }, - { "name": "glDepthRangef" }, - { "name": "glDetachShader" }, - { "name": "glDisable" }, - { "name": "glDisablei" }, - { "name": "glDisableVertexAttribArray" }, - { "name": "glDispatchCompute" }, - { "name": "glDispatchComputeIndirect" }, - { "name": "glDrawArrays" }, - { "name": "glDrawArraysIndirect" }, - { "name": "glDrawArraysInstanced" }, - { "name": "glDrawBuffers" }, - { "name": "glDrawElements" }, - { "name": "glDrawElementsBaseVertex" }, - { "name": "glDrawElementsIndirect" }, - { "name": "glDrawElementsInstanced" }, - { "name": "glDrawElementsInstancedBaseVertex" }, - { "name": "glDrawRangeElements" }, - { "name": "glDrawRangeElementsBaseVertex" }, - { "name": "glEnable" }, - { "name": "glEnablei" }, - { "name": "glEnableVertexAttribArray" }, - { "name": "glEndQuery" }, - { "name": "glEndTransformFeedback" }, - { "name": "glFenceSync" }, - { "name": "glFinish" }, - { "name": "glFlush" }, - { "name": "glFlushMappedBufferRange" }, - { "name": "glFramebufferParameteri" }, - { "name": "glFramebufferRenderbuffer" }, - { "name": "glFramebufferTexture" }, - { "name": "glFramebufferTexture2D" }, - { "name": "glFramebufferTextureLayer" }, - { "name": "glFrontFace" }, - { "name": "glGenBuffers" }, - { "name": "glGenerateMipmap" }, - { "name": "glGenFramebuffers" }, - { "name": "glGenProgramPipelines" }, - { "name": "glGenQueries" }, - { "name": "glGenRenderbuffers" }, - { "name": "glGenSamplers" }, - { "name": "glGenTextures" }, - { "name": "glGenTransformFeedbacks" }, - { "name": "glGenVertexArrays" }, - { "name": "glGetActiveAttrib" }, - { "name": "glGetActiveUniform" }, - { "name": "glGetActiveUniformBlockiv" }, - { "name": "glGetActiveUniformBlockName" }, - { "name": "glGetActiveUniformsiv" }, - { "name": "glGetAttachedShaders" }, - { "name": "glGetAttribLocation" }, - { "name": "glGetBooleani_v" }, - { "name": "glGetBooleanv" }, - { "name": "glGetBufferParameteri64v" }, - { "name": "glGetBufferParameteriv" }, - { "name": "glGetBufferPointerv" }, - { "name": "glGetDebugMessageLog" }, - { "name": "glGetError" }, - { "name": "glGetFloatv" }, - { "name": "glGetFragDataLocation" }, - { "name": "glGetFramebufferAttachmentParameteriv" }, - { "name": "glGetFramebufferParameteriv" }, - { "name": "glGetGraphicsResetStatus" }, - { "name": "glGetInteger64i_v" }, - { "name": "glGetInteger64v" }, - { "name": "glGetIntegeri_v" }, - { "name": "glGetIntegerv" }, - { "name": "glGetInternalformativ" }, - { "name": "glGetMultisamplefv" }, - { "name": "glGetnUniformfv" }, - { "name": "glGetnUniformiv" }, - { "name": "glGetnUniformuiv" }, - { "name": "glGetObjectLabel" }, - { "name": "glGetObjectPtrLabel" }, - { "name": "glGetPointerv" }, - { "name": "glGetProgramBinary" }, - { "name": "glGetProgramInfoLog" }, - { "name": "glGetProgramInterfaceiv" }, - { "name": "glGetProgramiv" }, - { "name": "glGetProgramPipelineInfoLog" }, - { "name": "glGetProgramPipelineiv" }, - { "name": "glGetProgramResourceIndex" }, - { "name": "glGetProgramResourceiv" }, - { "name": "glGetProgramResourceLocation" }, - { "name": "glGetProgramResourceName" }, - { "name": "glGetQueryiv" }, - { "name": "glGetQueryObjectuiv" }, - { "name": "glGetRenderbufferParameteriv" }, - { "name": "glGetSamplerParameterfv" }, - { "name": "glGetSamplerParameterIiv" }, - { "name": "glGetSamplerParameterIuiv" }, - { "name": "glGetSamplerParameteriv" }, - { "name": "glGetShaderInfoLog" }, - { "name": "glGetShaderiv" }, - { "name": "glGetShaderPrecisionFormat" }, - { "name": "glGetShaderSource" }, - { "name": "glGetString" }, - { "name": "glGetStringi" }, - { "name": "glGetSynciv" }, - { "name": "glGetTexLevelParameterfv" }, - { "name": "glGetTexLevelParameteriv" }, - { "name": "glGetTexParameterfv" }, - { "name": "glGetTexParameterIiv" }, - { "name": "glGetTexParameterIuiv" }, - { "name": "glGetTexParameteriv" }, - { "name": "glGetTransformFeedbackVarying" }, - { "name": "glGetUniformBlockIndex" }, - { "name": "glGetUniformfv" }, - { "name": "glGetUniformIndices" }, - { "name": "glGetUniformiv" }, - { "name": "glGetUniformLocation" }, - { "name": "glGetUniformuiv" }, - { "name": "glGetVertexAttribfv" }, - { "name": "glGetVertexAttribIiv" }, - { "name": "glGetVertexAttribIuiv" }, - { "name": "glGetVertexAttribiv" }, - { "name": "glGetVertexAttribPointerv" }, - { "name": "glHint" }, - { "name": "glInvalidateFramebuffer" }, - { "name": "glInvalidateSubFramebuffer" }, - { "name": "glIsBuffer" }, - { "name": "glIsEnabled" }, - { "name": "glIsEnabledi" }, - { "name": "glIsFramebuffer" }, - { "name": "glIsProgram" }, - { "name": "glIsProgramPipeline" }, - { "name": "glIsQuery" }, - { "name": "glIsRenderbuffer" }, - { "name": "glIsSampler" }, - { "name": "glIsShader" }, - { "name": "glIsSync" }, - { "name": "glIsTexture" }, - { "name": "glIsTransformFeedback" }, - { "name": "glIsVertexArray" }, - { "name": "glLineWidth" }, - { "name": "glLinkProgram" }, - { "name": "glMapBufferRange" }, - { "name": "glMemoryBarrier" }, - { "name": "glMemoryBarrierByRegion" }, - { "name": "glMinSampleShading" }, - { "name": "glObjectLabel" }, - { "name": "glObjectPtrLabel" }, - { "name": "glPatchParameteri" }, - { "name": "glPauseTransformFeedback" }, - { "name": "glPixelStorei" }, - { "name": "glPolygonOffset" }, - { "name": "glPopDebugGroup" }, - { "name": "glPrimitiveBoundingBox" }, - { "name": "glProgramBinary" }, - { "name": "glProgramParameteri" }, - { "name": "glProgramUniform1f" }, - { "name": "glProgramUniform1fv" }, - { "name": "glProgramUniform1i" }, - { "name": "glProgramUniform1iv" }, - { "name": "glProgramUniform1ui" }, - { "name": "glProgramUniform1uiv" }, - { "name": "glProgramUniform2f" }, - { "name": "glProgramUniform2fv" }, - { "name": "glProgramUniform2i" }, - { "name": "glProgramUniform2iv" }, - { "name": "glProgramUniform2ui" }, - { "name": "glProgramUniform2uiv" }, - { "name": "glProgramUniform3f" }, - { "name": "glProgramUniform3fv" }, - { "name": "glProgramUniform3i" }, - { "name": "glProgramUniform3iv" }, - { "name": "glProgramUniform3ui" }, - { "name": "glProgramUniform3uiv" }, - { "name": "glProgramUniform4f" }, - { "name": "glProgramUniform4fv" }, - { "name": "glProgramUniform4i" }, - { "name": "glProgramUniform4iv" }, - { "name": "glProgramUniform4ui" }, - { "name": "glProgramUniform4uiv" }, - { "name": "glProgramUniformMatrix2fv" }, - { "name": "glProgramUniformMatrix2x3fv" }, - { "name": "glProgramUniformMatrix2x4fv" }, - { "name": "glProgramUniformMatrix3fv" }, - { "name": "glProgramUniformMatrix3x2fv" }, - { "name": "glProgramUniformMatrix3x4fv" }, - { "name": "glProgramUniformMatrix4fv" }, - { "name": "glProgramUniformMatrix4x2fv" }, - { "name": "glProgramUniformMatrix4x3fv" }, - { "name": "glPushDebugGroup" }, - { "name": "glReadBuffer" }, - { "name": "glReadnPixels" }, - { "name": "glReadPixels" }, - { "name": "glReleaseShaderCompiler" }, - { "name": "glRenderbufferStorage" }, - { "name": "glRenderbufferStorageMultisample" }, - { "name": "glResumeTransformFeedback" }, - { "name": "glSampleCoverage" }, - { "name": "glSampleMaski" }, - { "name": "glSamplerParameterf" }, - { "name": "glSamplerParameterfv" }, - { "name": "glSamplerParameteri" }, - { "name": "glSamplerParameterIiv" }, - { "name": "glSamplerParameterIuiv" }, - { "name": "glSamplerParameteriv" }, - { "name": "glScissor" }, - { "name": "glShaderBinary" }, - { "name": "glShaderSource" }, - { "name": "glStencilFunc" }, - { "name": "glStencilFuncSeparate" }, - { "name": "glStencilMask" }, - { "name": "glStencilMaskSeparate" }, - { "name": "glStencilOp" }, - { "name": "glStencilOpSeparate" }, - { "name": "glTexBuffer" }, - { "name": "glTexBufferRange" }, - { "name": "glTexImage2D" }, - { "name": "glTexImage3D" }, - { "name": "glTexParameterf" }, - { "name": "glTexParameterfv" }, - { "name": "glTexParameteri" }, - { "name": "glTexParameterIiv" }, - { "name": "glTexParameterIuiv" }, - { "name": "glTexParameteriv" }, - { "name": "glTexStorage2D" }, - { "name": "glTexStorage2DMultisample" }, - { "name": "glTexStorage3D" }, - { "name": "glTexStorage3DMultisample" }, - { "name": "glTexSubImage2D" }, - { "name": "glTexSubImage3D" }, - { "name": "glTransformFeedbackVaryings" }, - { "name": "glUniform1f" }, - { "name": "glUniform1fv" }, - { "name": "glUniform1i" }, - { "name": "glUniform1iv" }, - { "name": "glUniform1ui" }, - { "name": "glUniform1uiv" }, - { "name": "glUniform2f" }, - { "name": "glUniform2fv" }, - { "name": "glUniform2i" }, - { "name": "glUniform2iv" }, - { "name": "glUniform2ui" }, - { "name": "glUniform2uiv" }, - { "name": "glUniform3f" }, - { "name": "glUniform3fv" }, - { "name": "glUniform3i" }, - { "name": "glUniform3iv" }, - { "name": "glUniform3ui" }, - { "name": "glUniform3uiv" }, - { "name": "glUniform4f" }, - { "name": "glUniform4fv" }, - { "name": "glUniform4i" }, - { "name": "glUniform4iv" }, - { "name": "glUniform4ui" }, - { "name": "glUniform4uiv" }, - { "name": "glUniformBlockBinding" }, - { "name": "glUniformMatrix2fv" }, - { "name": "glUniformMatrix2x3fv" }, - { "name": "glUniformMatrix2x4fv" }, - { "name": "glUniformMatrix3fv" }, - { "name": "glUniformMatrix3x2fv" }, - { "name": "glUniformMatrix3x4fv" }, - { "name": "glUniformMatrix4fv" }, - { "name": "glUniformMatrix4x2fv" }, - { "name": "glUniformMatrix4x3fv" }, - { "name": "glUnmapBuffer" }, - { "name": "glUseProgram" }, - { "name": "glUseProgramStages" }, - { "name": "glValidateProgram" }, - { "name": "glValidateProgramPipeline" }, - { "name": "glVertexAttrib1f" }, - { "name": "glVertexAttrib1fv" }, - { "name": "glVertexAttrib2f" }, - { "name": "glVertexAttrib2fv" }, - { "name": "glVertexAttrib3f" }, - { "name": "glVertexAttrib3fv" }, - { "name": "glVertexAttrib4f" }, - { "name": "glVertexAttrib4fv" }, - { "name": "glVertexAttribBinding" }, - { "name": "glVertexAttribDivisor" }, - { "name": "glVertexAttribFormat" }, - { "name": "glVertexAttribI4i" }, - { "name": "glVertexAttribI4iv" }, - { "name": "glVertexAttribI4ui" }, - { "name": "glVertexAttribI4uiv" }, - { "name": "glVertexAttribIFormat" }, - { "name": "glVertexAttribIPointer" }, - { "name": "glVertexAttribPointer" }, - { "name": "glVertexBindingDivisor" }, - { "name": "glViewport" }, - { "name": "glWaitSync" } +[ + { "name": "glActiveShaderProgram" }, + { "name": "glActiveTexture" }, + { "name": "glAttachShader" }, + { "name": "glBeginQuery" }, + { "name": "glBeginTransformFeedback" }, + { "name": "glBindAttribLocation" }, + { "name": "glBindBuffer" }, + { "name": "glBindBufferBase" }, + { "name": "glBindBufferRange" }, + { "name": "glBindFramebuffer" }, + { "name": "glBindImageTexture" }, + { "name": "glBindProgramPipeline" }, + { "name": "glBindRenderbuffer" }, + { "name": "glBindSampler" }, + { "name": "glBindTexture" }, + { "name": "glBindTransformFeedback" }, + { "name": "glBindVertexArray" }, + { "name": "glBindVertexBuffer" }, + { "name": "glBlendBarrier" }, + { "name": "glBlendColor" }, + { "name": "glBlendEquation" }, + { "name": "glBlendEquationi" }, + { "name": "glBlendEquationSeparate" }, + { "name": "glBlendEquationSeparatei" }, + { "name": "glBlendFunc" }, + { "name": "glBlendFunci" }, + { "name": "glBlendFuncSeparate" }, + { "name": "glBlendFuncSeparatei" }, + { "name": "glBlitFramebuffer" }, + { "name": "glBufferData" }, + { "name": "glBufferSubData" }, + { "name": "glCheckFramebufferStatus" }, + { "name": "glClear" }, + { "name": "glClearBufferfi" }, + { "name": "glClearBufferfv" }, + { "name": "glClearBufferiv" }, + { "name": "glClearBufferuiv" }, + { "name": "glClearColor" }, + { "name": "glClearDepthf" }, + { "name": "glClearStencil" }, + { "name": "glClientWaitSync" }, + { "name": "glColorMask" }, + { "name": "glColorMaski" }, + { "name": "glCompileShader" }, + { "name": "glCompressedTexImage2D" }, + { "name": "glCompressedTexImage3D" }, + { "name": "glCompressedTexSubImage2D" }, + { "name": "glCompressedTexSubImage3D" }, + { "name": "glCopyBufferSubData" }, + { "name": "glCopyImageSubData" }, + { "name": "glCopyTexImage2D" }, + { "name": "glCopyTexSubImage2D" }, + { "name": "glCopyTexSubImage3D" }, + { "name": "glCreateProgram" }, + { "name": "glCreateShader" }, + { "name": "glCreateShaderProgramv" }, + { "name": "glCullFace" }, + { "name": "glDebugMessageCallback" }, + { "name": "glDebugMessageControl" }, + { "name": "glDebugMessageInsert" }, + { "name": "glDeleteBuffers" }, + { "name": "glDeleteFramebuffers" }, + { "name": "glDeleteProgram" }, + { "name": "glDeleteProgramPipelines" }, + { "name": "glDeleteQueries" }, + { "name": "glDeleteRenderbuffers" }, + { "name": "glDeleteSamplers" }, + { "name": "glDeleteShader" }, + { "name": "glDeleteSync" }, + { "name": "glDeleteTextures" }, + { "name": "glDeleteTransformFeedbacks" }, + { "name": "glDeleteVertexArrays" }, + { "name": "glDepthFunc" }, + { "name": "glDepthMask" }, + { "name": "glDepthRangef" }, + { "name": "glDetachShader" }, + { "name": "glDisable" }, + { "name": "glDisablei" }, + { "name": "glDisableVertexAttribArray" }, + { "name": "glDispatchCompute" }, + { "name": "glDispatchComputeIndirect" }, + { "name": "glDrawArrays" }, + { "name": "glDrawArraysIndirect" }, + { "name": "glDrawArraysInstanced" }, + { "name": "glDrawBuffers" }, + { "name": "glDrawElements" }, + { "name": "glDrawElementsBaseVertex" }, + { "name": "glDrawElementsIndirect" }, + { "name": "glDrawElementsInstanced" }, + { "name": "glDrawElementsInstancedBaseVertex" }, + { "name": "glDrawRangeElements" }, + { "name": "glDrawRangeElementsBaseVertex" }, + { "name": "glEnable" }, + { "name": "glEnablei" }, + { "name": "glEnableVertexAttribArray" }, + { "name": "glEndQuery" }, + { "name": "glEndTransformFeedback" }, + { "name": "glFenceSync" }, + { "name": "glFinish" }, + { "name": "glFlush" }, + { "name": "glFlushMappedBufferRange" }, + { "name": "glFramebufferParameteri" }, + { "name": "glFramebufferRenderbuffer" }, + { "name": "glFramebufferTexture" }, + { "name": "glFramebufferTexture2D" }, + { "name": "glFramebufferTextureLayer" }, + { "name": "glFrontFace" }, + { "name": "glGenBuffers" }, + { "name": "glGenerateMipmap" }, + { "name": "glGenFramebuffers" }, + { "name": "glGenProgramPipelines" }, + { "name": "glGenQueries" }, + { "name": "glGenRenderbuffers" }, + { "name": "glGenSamplers" }, + { "name": "glGenTextures" }, + { "name": "glGenTransformFeedbacks" }, + { "name": "glGenVertexArrays" }, + { "name": "glGetActiveAttrib" }, + { "name": "glGetActiveUniform" }, + { "name": "glGetActiveUniformBlockiv" }, + { "name": "glGetActiveUniformBlockName" }, + { "name": "glGetActiveUniformsiv" }, + { "name": "glGetAttachedShaders" }, + { "name": "glGetAttribLocation" }, + { "name": "glGetBooleani_v" }, + { "name": "glGetBooleanv" }, + { "name": "glGetBufferParameteri64v" }, + { "name": "glGetBufferParameteriv" }, + { "name": "glGetBufferPointerv" }, + { "name": "glGetDebugMessageLog" }, + { "name": "glGetError" }, + { "name": "glGetFloatv" }, + { "name": "glGetFragDataLocation" }, + { "name": "glGetFramebufferAttachmentParameteriv" }, + { "name": "glGetFramebufferParameteriv" }, + { "name": "glGetGraphicsResetStatus" }, + { "name": "glGetInteger64i_v" }, + { "name": "glGetInteger64v" }, + { "name": "glGetIntegeri_v" }, + { "name": "glGetIntegerv" }, + { "name": "glGetInternalformativ" }, + { "name": "glGetMultisamplefv" }, + { "name": "glGetnUniformfv" }, + { "name": "glGetnUniformiv" }, + { "name": "glGetnUniformuiv" }, + { "name": "glGetObjectLabel" }, + { "name": "glGetObjectPtrLabel" }, + { "name": "glGetPointerv" }, + { "name": "glGetProgramBinary" }, + { "name": "glGetProgramInfoLog" }, + { "name": "glGetProgramInterfaceiv" }, + { "name": "glGetProgramiv" }, + { "name": "glGetProgramPipelineInfoLog" }, + { "name": "glGetProgramPipelineiv" }, + { "name": "glGetProgramResourceIndex" }, + { "name": "glGetProgramResourceiv" }, + { "name": "glGetProgramResourceLocation" }, + { "name": "glGetProgramResourceName" }, + { "name": "glGetQueryiv" }, + { "name": "glGetQueryObjectuiv" }, + { "name": "glGetRenderbufferParameteriv" }, + { "name": "glGetSamplerParameterfv" }, + { "name": "glGetSamplerParameterIiv" }, + { "name": "glGetSamplerParameterIuiv" }, + { "name": "glGetSamplerParameteriv" }, + { "name": "glGetShaderInfoLog" }, + { "name": "glGetShaderiv" }, + { "name": "glGetShaderPrecisionFormat" }, + { "name": "glGetShaderSource" }, + { "name": "glGetString" }, + { "name": "glGetStringi" }, + { "name": "glGetSynciv" }, + { "name": "glGetTexLevelParameterfv" }, + { "name": "glGetTexLevelParameteriv" }, + { "name": "glGetTexParameterfv" }, + { "name": "glGetTexParameterIiv" }, + { "name": "glGetTexParameterIuiv" }, + { "name": "glGetTexParameteriv" }, + { "name": "glGetTransformFeedbackVarying" }, + { "name": "glGetUniformBlockIndex" }, + { "name": "glGetUniformfv" }, + { "name": "glGetUniformIndices" }, + { "name": "glGetUniformiv" }, + { "name": "glGetUniformLocation" }, + { "name": "glGetUniformuiv" }, + { "name": "glGetVertexAttribfv" }, + { "name": "glGetVertexAttribIiv" }, + { "name": "glGetVertexAttribIuiv" }, + { "name": "glGetVertexAttribiv" }, + { "name": "glGetVertexAttribPointerv" }, + { "name": "glHint" }, + { "name": "glInvalidateFramebuffer" }, + { "name": "glInvalidateSubFramebuffer" }, + { "name": "glIsBuffer" }, + { "name": "glIsEnabled" }, + { "name": "glIsEnabledi" }, + { "name": "glIsFramebuffer" }, + { "name": "glIsProgram" }, + { "name": "glIsProgramPipeline" }, + { "name": "glIsQuery" }, + { "name": "glIsRenderbuffer" }, + { "name": "glIsSampler" }, + { "name": "glIsShader" }, + { "name": "glIsSync" }, + { "name": "glIsTexture" }, + { "name": "glIsTransformFeedback" }, + { "name": "glIsVertexArray" }, + { "name": "glLineWidth" }, + { "name": "glLinkProgram" }, + { "name": "glMapBufferRange" }, + { "name": "glMemoryBarrier" }, + { "name": "glMemoryBarrierByRegion" }, + { "name": "glMinSampleShading" }, + { "name": "glObjectLabel" }, + { "name": "glObjectPtrLabel" }, + { "name": "glPatchParameteri" }, + { "name": "glPauseTransformFeedback" }, + { "name": "glPixelStorei" }, + { "name": "glPolygonOffset" }, + { "name": "glPopDebugGroup" }, + { "name": "glPrimitiveBoundingBox" }, + { "name": "glProgramBinary" }, + { "name": "glProgramParameteri" }, + { "name": "glProgramUniform1f" }, + { "name": "glProgramUniform1fv" }, + { "name": "glProgramUniform1i" }, + { "name": "glProgramUniform1iv" }, + { "name": "glProgramUniform1ui" }, + { "name": "glProgramUniform1uiv" }, + { "name": "glProgramUniform2f" }, + { "name": "glProgramUniform2fv" }, + { "name": "glProgramUniform2i" }, + { "name": "glProgramUniform2iv" }, + { "name": "glProgramUniform2ui" }, + { "name": "glProgramUniform2uiv" }, + { "name": "glProgramUniform3f" }, + { "name": "glProgramUniform3fv" }, + { "name": "glProgramUniform3i" }, + { "name": "glProgramUniform3iv" }, + { "name": "glProgramUniform3ui" }, + { "name": "glProgramUniform3uiv" }, + { "name": "glProgramUniform4f" }, + { "name": "glProgramUniform4fv" }, + { "name": "glProgramUniform4i" }, + { "name": "glProgramUniform4iv" }, + { "name": "glProgramUniform4ui" }, + { "name": "glProgramUniform4uiv" }, + { "name": "glProgramUniformMatrix2fv" }, + { "name": "glProgramUniformMatrix2x3fv" }, + { "name": "glProgramUniformMatrix2x4fv" }, + { "name": "glProgramUniformMatrix3fv" }, + { "name": "glProgramUniformMatrix3x2fv" }, + { "name": "glProgramUniformMatrix3x4fv" }, + { "name": "glProgramUniformMatrix4fv" }, + { "name": "glProgramUniformMatrix4x2fv" }, + { "name": "glProgramUniformMatrix4x3fv" }, + { "name": "glPushDebugGroup" }, + { "name": "glReadBuffer" }, + { "name": "glReadnPixels" }, + { "name": "glReadPixels" }, + { "name": "glReleaseShaderCompiler" }, + { "name": "glRenderbufferStorage" }, + { "name": "glRenderbufferStorageMultisample" }, + { "name": "glResumeTransformFeedback" }, + { "name": "glSampleCoverage" }, + { "name": "glSampleMaski" }, + { "name": "glSamplerParameterf" }, + { "name": "glSamplerParameterfv" }, + { "name": "glSamplerParameteri" }, + { "name": "glSamplerParameterIiv" }, + { "name": "glSamplerParameterIuiv" }, + { "name": "glSamplerParameteriv" }, + { "name": "glScissor" }, + { "name": "glShaderBinary" }, + { "name": "glShaderSource" }, + { "name": "glStencilFunc" }, + { "name": "glStencilFuncSeparate" }, + { "name": "glStencilMask" }, + { "name": "glStencilMaskSeparate" }, + { "name": "glStencilOp" }, + { "name": "glStencilOpSeparate" }, + { "name": "glTexBuffer" }, + { "name": "glTexBufferRange" }, + { "name": "glTexImage2D" }, + { "name": "glTexImage3D" }, + { "name": "glTexParameterf" }, + { "name": "glTexParameterfv" }, + { "name": "glTexParameteri" }, + { "name": "glTexParameterIiv" }, + { "name": "glTexParameterIuiv" }, + { "name": "glTexParameteriv" }, + { "name": "glTexStorage2D" }, + { "name": "glTexStorage2DMultisample" }, + { "name": "glTexStorage3D" }, + { "name": "glTexStorage3DMultisample" }, + { "name": "glTexSubImage2D" }, + { "name": "glTexSubImage3D" }, + { "name": "glTransformFeedbackVaryings" }, + { "name": "glUniform1f" }, + { "name": "glUniform1fv" }, + { "name": "glUniform1i" }, + { "name": "glUniform1iv" }, + { "name": "glUniform1ui" }, + { "name": "glUniform1uiv" }, + { "name": "glUniform2f" }, + { "name": "glUniform2fv" }, + { "name": "glUniform2i" }, + { "name": "glUniform2iv" }, + { "name": "glUniform2ui" }, + { "name": "glUniform2uiv" }, + { "name": "glUniform3f" }, + { "name": "glUniform3fv" }, + { "name": "glUniform3i" }, + { "name": "glUniform3iv" }, + { "name": "glUniform3ui" }, + { "name": "glUniform3uiv" }, + { "name": "glUniform4f" }, + { "name": "glUniform4fv" }, + { "name": "glUniform4i" }, + { "name": "glUniform4iv" }, + { "name": "glUniform4ui" }, + { "name": "glUniform4uiv" }, + { "name": "glUniformBlockBinding" }, + { "name": "glUniformMatrix2fv" }, + { "name": "glUniformMatrix2x3fv" }, + { "name": "glUniformMatrix2x4fv" }, + { "name": "glUniformMatrix3fv" }, + { "name": "glUniformMatrix3x2fv" }, + { "name": "glUniformMatrix3x4fv" }, + { "name": "glUniformMatrix4fv" }, + { "name": "glUniformMatrix4x2fv" }, + { "name": "glUniformMatrix4x3fv" }, + { "name": "glUnmapBuffer" }, + { "name": "glUseProgram" }, + { "name": "glUseProgramStages" }, + { "name": "glValidateProgram" }, + { "name": "glValidateProgramPipeline" }, + { "name": "glVertexAttrib1f" }, + { "name": "glVertexAttrib1fv" }, + { "name": "glVertexAttrib2f" }, + { "name": "glVertexAttrib2fv" }, + { "name": "glVertexAttrib3f" }, + { "name": "glVertexAttrib3fv" }, + { "name": "glVertexAttrib4f" }, + { "name": "glVertexAttrib4fv" }, + { "name": "glVertexAttribBinding" }, + { "name": "glVertexAttribDivisor" }, + { "name": "glVertexAttribFormat" }, + { "name": "glVertexAttribI4i" }, + { "name": "glVertexAttribI4iv" }, + { "name": "glVertexAttribI4ui" }, + { "name": "glVertexAttribI4uiv" }, + { "name": "glVertexAttribIFormat" }, + { "name": "glVertexAttribIPointer" }, + { "name": "glVertexAttribPointer" }, + { "name": "glVertexBindingDivisor" }, + { "name": "glViewport" }, + { "name": "glWaitSync" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/KHR/BUILD.gn b/graphic/graphic_2d/KHR/BUILD.gn index 07b3eb22e286e77ce37bb5192df97ce44fcffa3c..9d80fa5adc45886adbc816c6587ca6487215e72c 100644 --- a/graphic/graphic_2d/KHR/BUILD.gn +++ b/graphic/graphic_2d/KHR/BUILD.gn @@ -1,20 +1,20 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("KHR_header") { - dest_dir = "$ndk_headers_out_dir/KHR" - sources = [ "//interface/sdk_c/third_party/egl/KHR/khrplatform.h" ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("KHR_header") { + dest_dir = "$ndk_headers_out_dir/KHR" + sources = [ "//interface/sdk_c/third_party/egl/KHR/khrplatform.h" ] +} diff --git a/graphic/graphic_2d/native_buffer/BUILD.gn b/graphic/graphic_2d/native_buffer/BUILD.gn index e7066d1cd2b9d7d6eaf5c549263fa45981c628f6..ec03f99868e62d7389747de11ef0a3a0581b6d6d 100644 --- a/graphic/graphic_2d/native_buffer/BUILD.gn +++ b/graphic/graphic_2d/native_buffer/BUILD.gn @@ -1,28 +1,28 @@ -# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_buffer_header") { - dest_dir = "$ndk_headers_out_dir/native_buffer" - sources = [ "//interface/sdk_c/graphic/graphic_2d/native_buffer/native_buffer.h" ] -} - -ohos_ndk_library("libnative_buffer_ndk") { - output_name = "native_buffer" - output_extension = "so" - ndk_description_file = "./libnative_buffer.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.NativeBuffer" - system_capability_headers = [ "native_buffer/native_buffer.h" ] -} +# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_buffer_header") { + dest_dir = "$ndk_headers_out_dir/native_buffer" + sources = [ "//interface/sdk_c/graphic/graphic_2d/native_buffer/native_buffer.h" ] +} + +ohos_ndk_library("libnative_buffer_ndk") { + output_name = "native_buffer" + output_extension = "so" + ndk_description_file = "./libnative_buffer.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeBuffer" + system_capability_headers = [ "native_buffer/native_buffer.h" ] +} diff --git a/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json b/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json index 722ba7b087bf15793ad22df9dddd015ad13289bd..50755907913e3b32553614fb08d3763a844024ba 100644 --- a/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json +++ b/graphic/graphic_2d/native_buffer/libnative_buffer.ndk.json @@ -1,9 +1,9 @@ -[ - { "name": "OH_NativeBuffer_Alloc" }, - { "name": "OH_NativeBuffer_Reference" }, - { "name": "OH_NativeBuffer_Unreference" }, - { "name": "OH_NativeBuffer_GetConfig" }, - { "name": "OH_NativeBuffer_Map" }, - { "name": "OH_NativeBuffer_Unmap" }, - { "name": "OH_NativeBuffer_GetSeqNum" } +[ + { "name": "OH_NativeBuffer_Alloc" }, + { "name": "OH_NativeBuffer_Reference" }, + { "name": "OH_NativeBuffer_Unreference" }, + { "name": "OH_NativeBuffer_GetConfig" }, + { "name": "OH_NativeBuffer_Map" }, + { "name": "OH_NativeBuffer_Unmap" }, + { "name": "OH_NativeBuffer_GetSeqNum" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_buffer/native_buffer.h b/graphic/graphic_2d/native_buffer/native_buffer.h index bb1cb0ddf298629de0de17b2f3f5c7a985b15f83..0099131f645a9479a037e28e42bcbe6c89133430 100644 --- a/graphic/graphic_2d/native_buffer/native_buffer.h +++ b/graphic/graphic_2d/native_buffer/native_buffer.h @@ -32,6 +32,7 @@ * * @brief Defines the functions for obtaining and using a native buffer. * + * @library libnative_buffer.so * @since 9 * @version 1.0 */ @@ -45,6 +46,48 @@ extern "C" { struct OH_NativeBuffer; typedef struct OH_NativeBuffer OH_NativeBuffer; +/** + * @brief Indicates the usage of a native buffer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @since 10 + * @version 1.0 + */ +enum OH_NativeBuffer_Usage { + NATIVEBUFFER_USAGE_CPU_READ = (1ULL << 0), /// < CPU read buffer */ + NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL << 1), /// < CPU write memory */ + NATIVEBUFFER_USAGE_MEM_DMA = (1ULL << 3), /// < Direct memory access (DMA) buffer */ +}; + +/** + * @brief Indicates the format of a native buffer. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer + * @since 10 + * @version 1.0 + */ +enum OH_NativeBuffer_Format { + NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3, /// < RGB565 format */ + NATIVEBUFFER_PIXEL_FMT_RGBA_5658, /// < RGBA5658 format */ + NATIVEBUFFER_PIXEL_FMT_RGBX_4444, /// < RGBX4444 format */ + NATIVEBUFFER_PIXEL_FMT_RGBA_4444, /// < RGBA4444 format */ + NATIVEBUFFER_PIXEL_FMT_RGB_444, /// < RGB444 format */ + NATIVEBUFFER_PIXEL_FMT_RGBX_5551, /// < RGBX5551 format */ + NATIVEBUFFER_PIXEL_FMT_RGBA_5551, /// < RGBA5551 format */ + NATIVEBUFFER_PIXEL_FMT_RGB_555, /// < RGB555 format */ + NATIVEBUFFER_PIXEL_FMT_RGBX_8888, /// < RGBX8888 format */ + NATIVEBUFFER_PIXEL_FMT_RGBA_8888, /// < RGBA8888 format */ + NATIVEBUFFER_PIXEL_FMT_RGB_888, /// < RGB888 format */ + NATIVEBUFFER_PIXEL_FMT_BGR_565, /// < BGR565 format */ + NATIVEBUFFER_PIXEL_FMT_BGRX_4444, /// < BGRX4444 format */ + NATIVEBUFFER_PIXEL_FMT_BGRA_4444, /// < BGRA4444 format */ + NATIVEBUFFER_PIXEL_FMT_BGRX_5551, /// < BGRX5551 format */ + NATIVEBUFFER_PIXEL_FMT_BGRA_5551, /// < BGRA5551 format */ + NATIVEBUFFER_PIXEL_FMT_BGRX_8888, /// < BGRX8888 format */ + NATIVEBUFFER_PIXEL_FMT_BGRA_8888, /// < BGRA8888 format */ + NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF /// < Invalid pixel format */ +}; + /** * @brief OH_NativeBuffer config. \n * Used to allocating new OH_NativeBuffer andquery parameters if existing ones. @@ -58,6 +101,7 @@ typedef struct { int32_t height; ///< Height in pixels int32_t format; ///< One of PixelFormat int32_t usage; ///< Combination of buffer usage + int32_t stride; ///< the stride of memory } OH_NativeBuffer_Config; /** diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 499a374c24d51cc02d688deceb9547af85cc701c..a681f6396f934e9c91d3add47e96bd3b2c81da23 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -1,50 +1,50 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_drawing_header") { - dest_dir = "$ndk_headers_out_dir/native_drawing" - sources = [ - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_bitmap.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_brush.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_canvas.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_color.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_collection.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_typography.h", - "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_types.h", - ] -} - -ohos_ndk_library("libnative_drawing_ndk") { - output_name = "native_drawing" - output_extension = "so" - ndk_description_file = "./libnative_drawing.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.NativeDrawing" - system_capability_headers = [ - "native_drawing/drawing_bitmap.h", - "native_drawing/drawing_brush.h", - "native_drawing/drawing_canvas.h", - "native_drawing/drawing_color.h", - "native_drawing/drawing_font_collection.h", - "native_drawing/drawing_path.h", - "native_drawing/drawing_pen.h", - "native_drawing/drawing_text_declaration.h", - "native_drawing/drawing_text_typography.h", - "native_drawing/drawing_types.h", - ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_drawing_header") { + dest_dir = "$ndk_headers_out_dir/native_drawing" + sources = [ + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_bitmap.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_brush.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_canvas.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_color.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_collection.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_typography.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_types.h", + ] +} + +ohos_ndk_library("libnative_drawing_ndk") { + output_name = "native_drawing" + output_extension = "so" + ndk_description_file = "./libnative_drawing.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeDrawing" + system_capability_headers = [ + "native_drawing/drawing_bitmap.h", + "native_drawing/drawing_brush.h", + "native_drawing/drawing_canvas.h", + "native_drawing/drawing_color.h", + "native_drawing/drawing_font_collection.h", + "native_drawing/drawing_path.h", + "native_drawing/drawing_pen.h", + "native_drawing/drawing_text_declaration.h", + "native_drawing/drawing_text_typography.h", + "native_drawing/drawing_types.h", + ] +} diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 44c3452f8b5f4a8c66cb058dfbce1e6790cba9c0..ba16a3a6c58d2fb94b87f3e005f10d13fa253308 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1,85 +1,85 @@ -[ - { "name": "OH_Drawing_BitmapCreate" }, - { "name": "OH_Drawing_BitmapDestroy" }, - { "name": "OH_Drawing_BitmapBuild" }, - { "name": "OH_Drawing_BitmapGetWidth" }, - { "name": "OH_Drawing_BitmapGetHeight" }, - { "name": "OH_Drawing_BitmapGetPixels" }, - { "name": "OH_Drawing_BrushCreate" }, - { "name": "OH_Drawing_BrushDestroy" }, - { "name": "OH_Drawing_BrushIsAntiAlias" }, - { "name": "OH_Drawing_BrushSetAntiAlias" }, - { "name": "OH_Drawing_BrushGetColor" }, - { "name": "OH_Drawing_BrushSetColor" }, - { "name": "OH_Drawing_CanvasCreate" }, - { "name": "OH_Drawing_CanvasDestroy" }, - { "name": "OH_Drawing_CanvasBind" }, - { "name": "OH_Drawing_CanvasAttachPen" }, - { "name": "OH_Drawing_CanvasDetachPen" }, - { "name": "OH_Drawing_CanvasAttachBrush" }, - { "name": "OH_Drawing_CanvasDetachBrush" }, - { "name": "OH_Drawing_CanvasSave" }, - { "name": "OH_Drawing_CanvasRestore" }, - { "name": "OH_Drawing_CanvasDrawLine" }, - { "name": "OH_Drawing_CanvasDrawPath" }, - { "name": "OH_Drawing_CanvasClear" }, - { "name": "OH_Drawing_PathCreate" }, - { "name": "OH_Drawing_PathDestroy" }, - { "name": "OH_Drawing_PathMoveTo" }, - { "name": "OH_Drawing_PathLineTo" }, - { "name": "OH_Drawing_PathArcTo" }, - { "name": "OH_Drawing_PathQuadTo" }, - { "name": "OH_Drawing_PathCubicTo" }, - { "name": "OH_Drawing_PathClose" }, - { "name": "OH_Drawing_PathReset" }, - { "name": "OH_Drawing_PenCreate" }, - { "name": "OH_Drawing_PenDestroy" }, - { "name": "OH_Drawing_PenIsAntiAlias" }, - { "name": "OH_Drawing_PenSetAntiAlias" }, - { "name": "OH_Drawing_PenGetColor" }, - { "name": "OH_Drawing_PenSetColor" }, - { "name": "OH_Drawing_PenGetWidth" }, - { "name": "OH_Drawing_PenSetWidth" }, - { "name": "OH_Drawing_PenGetMiterLimit" }, - { "name": "OH_Drawing_PenSetMiterLimit" }, - { "name": "OH_Drawing_PenGetCap" }, - { "name": "OH_Drawing_PenSetCap" }, - { "name": "OH_Drawing_PenGetJoin" }, - { "name": "OH_Drawing_PenSetJoin" }, - { "name": "OH_Drawing_ColorSetArgb" }, - { "name": "OH_Drawing_CreateFontCollection" }, - { "name": "OH_Drawing_DestroyFontCollection" }, - { "name": "OH_Drawing_CreateTypographyStyle" }, - { "name": "OH_Drawing_DestroyTypographyStyle" }, - { "name": "OH_Drawing_SetTypographyTextDirection" }, - { "name": "OH_Drawing_SetTypographyTextAlign" }, - { "name": "OH_Drawing_SetTypographyTextMaxLines" }, - { "name": "OH_Drawing_CreateTextStyle" }, - { "name": "OH_Drawing_DestroyTextStyle" }, - { "name": "OH_Drawing_SetTextStyleColor" }, - { "name": "OH_Drawing_SetTextStyleFontSize" }, - { "name": "OH_Drawing_SetTextStyleFontWeight" }, - { "name": "OH_Drawing_SetTextStyleBaseLine" }, - { "name": "OH_Drawing_SetTextStyleDecoration" }, - { "name": "OH_Drawing_SetTextStyleDecorationColor" }, - { "name": "OH_Drawing_SetTextStyleFontHeight" }, - { "name": "OH_Drawing_SetTextStyleFontFamilies" }, - { "name": "OH_Drawing_SetTextStyleFontStyle" }, - { "name": "OH_Drawing_SetTextStyleLocale" }, - { "name": "OH_Drawing_CreateTypographyHandler" }, - { "name": "OH_Drawing_DestroyTypographyHandler" }, - { "name": "OH_Drawing_TypographyHandlerPushTextStyle" }, - { "name": "OH_Drawing_TypographyHandlerAddText" }, - { "name": "OH_Drawing_TypographyHandlerPopTextStyle" }, - { "name": "OH_Drawing_CreateTypography" }, - { "name": "OH_Drawing_DestroyTypography" }, - { "name": "OH_Drawing_TypographyLayout" }, - { "name": "OH_Drawing_TypographyPaint" }, - { "name": "OH_Drawing_TypographyGetMaxWidth" }, - { "name": "OH_Drawing_TypographyGetHeight" }, - { "name": "OH_Drawing_TypographyGetLongestLine" }, - { "name": "OH_Drawing_TypographyGetMinIntrinsicWidth" }, - { "name": "OH_Drawing_TypographyGetMaxIntrinsicWidth" }, - { "name": "OH_Drawing_TypographyGetAlphabeticBaseline" }, - { "name": "OH_Drawing_TypographyGetIdeographicBaseline" } +[ + { "name": "OH_Drawing_BitmapCreate" }, + { "name": "OH_Drawing_BitmapDestroy" }, + { "name": "OH_Drawing_BitmapBuild" }, + { "name": "OH_Drawing_BitmapGetWidth" }, + { "name": "OH_Drawing_BitmapGetHeight" }, + { "name": "OH_Drawing_BitmapGetPixels" }, + { "name": "OH_Drawing_BrushCreate" }, + { "name": "OH_Drawing_BrushDestroy" }, + { "name": "OH_Drawing_BrushIsAntiAlias" }, + { "name": "OH_Drawing_BrushSetAntiAlias" }, + { "name": "OH_Drawing_BrushGetColor" }, + { "name": "OH_Drawing_BrushSetColor" }, + { "name": "OH_Drawing_CanvasCreate" }, + { "name": "OH_Drawing_CanvasDestroy" }, + { "name": "OH_Drawing_CanvasBind" }, + { "name": "OH_Drawing_CanvasAttachPen" }, + { "name": "OH_Drawing_CanvasDetachPen" }, + { "name": "OH_Drawing_CanvasAttachBrush" }, + { "name": "OH_Drawing_CanvasDetachBrush" }, + { "name": "OH_Drawing_CanvasSave" }, + { "name": "OH_Drawing_CanvasRestore" }, + { "name": "OH_Drawing_CanvasDrawLine" }, + { "name": "OH_Drawing_CanvasDrawPath" }, + { "name": "OH_Drawing_CanvasClear" }, + { "name": "OH_Drawing_PathCreate" }, + { "name": "OH_Drawing_PathDestroy" }, + { "name": "OH_Drawing_PathMoveTo" }, + { "name": "OH_Drawing_PathLineTo" }, + { "name": "OH_Drawing_PathArcTo" }, + { "name": "OH_Drawing_PathQuadTo" }, + { "name": "OH_Drawing_PathCubicTo" }, + { "name": "OH_Drawing_PathClose" }, + { "name": "OH_Drawing_PathReset" }, + { "name": "OH_Drawing_PenCreate" }, + { "name": "OH_Drawing_PenDestroy" }, + { "name": "OH_Drawing_PenIsAntiAlias" }, + { "name": "OH_Drawing_PenSetAntiAlias" }, + { "name": "OH_Drawing_PenGetColor" }, + { "name": "OH_Drawing_PenSetColor" }, + { "name": "OH_Drawing_PenGetWidth" }, + { "name": "OH_Drawing_PenSetWidth" }, + { "name": "OH_Drawing_PenGetMiterLimit" }, + { "name": "OH_Drawing_PenSetMiterLimit" }, + { "name": "OH_Drawing_PenGetCap" }, + { "name": "OH_Drawing_PenSetCap" }, + { "name": "OH_Drawing_PenGetJoin" }, + { "name": "OH_Drawing_PenSetJoin" }, + { "name": "OH_Drawing_ColorSetArgb" }, + { "name": "OH_Drawing_CreateFontCollection" }, + { "name": "OH_Drawing_DestroyFontCollection" }, + { "name": "OH_Drawing_CreateTypographyStyle" }, + { "name": "OH_Drawing_DestroyTypographyStyle" }, + { "name": "OH_Drawing_SetTypographyTextDirection" }, + { "name": "OH_Drawing_SetTypographyTextAlign" }, + { "name": "OH_Drawing_SetTypographyTextMaxLines" }, + { "name": "OH_Drawing_CreateTextStyle" }, + { "name": "OH_Drawing_DestroyTextStyle" }, + { "name": "OH_Drawing_SetTextStyleColor" }, + { "name": "OH_Drawing_SetTextStyleFontSize" }, + { "name": "OH_Drawing_SetTextStyleFontWeight" }, + { "name": "OH_Drawing_SetTextStyleBaseLine" }, + { "name": "OH_Drawing_SetTextStyleDecoration" }, + { "name": "OH_Drawing_SetTextStyleDecorationColor" }, + { "name": "OH_Drawing_SetTextStyleFontHeight" }, + { "name": "OH_Drawing_SetTextStyleFontFamilies" }, + { "name": "OH_Drawing_SetTextStyleFontStyle" }, + { "name": "OH_Drawing_SetTextStyleLocale" }, + { "name": "OH_Drawing_CreateTypographyHandler" }, + { "name": "OH_Drawing_DestroyTypographyHandler" }, + { "name": "OH_Drawing_TypographyHandlerPushTextStyle" }, + { "name": "OH_Drawing_TypographyHandlerAddText" }, + { "name": "OH_Drawing_TypographyHandlerPopTextStyle" }, + { "name": "OH_Drawing_CreateTypography" }, + { "name": "OH_Drawing_DestroyTypography" }, + { "name": "OH_Drawing_TypographyLayout" }, + { "name": "OH_Drawing_TypographyPaint" }, + { "name": "OH_Drawing_TypographyGetMaxWidth" }, + { "name": "OH_Drawing_TypographyGetHeight" }, + { "name": "OH_Drawing_TypographyGetLongestLine" }, + { "name": "OH_Drawing_TypographyGetMinIntrinsicWidth" }, + { "name": "OH_Drawing_TypographyGetMaxIntrinsicWidth" }, + { "name": "OH_Drawing_TypographyGetAlphabeticBaseline" }, + { "name": "OH_Drawing_TypographyGetIdeographicBaseline" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_image/BUILD.gn b/graphic/graphic_2d/native_image/BUILD.gn index d4bc4f895c60a4e383139a23bddaf4a1429edff4..9ff61c8c36d501d28447ec1c791c71cce46016ac 100644 --- a/graphic/graphic_2d/native_image/BUILD.gn +++ b/graphic/graphic_2d/native_image/BUILD.gn @@ -1,28 +1,28 @@ -# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_image_header") { - dest_dir = "$ndk_headers_out_dir/native_image" - sources = [ "//interface/sdk_c/graphic/graphic_2d/native_image/native_image.h" ] -} - -ohos_ndk_library("libnative_image_ndk") { - output_name = "native_image" - output_extension = "so" - ndk_description_file = "./libnative_image.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.NativeImage" - system_capability_headers = [ "native_image/native_image.h" ] -} +# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_image_header") { + dest_dir = "$ndk_headers_out_dir/native_image" + sources = [ "//interface/sdk_c/graphic/graphic_2d/native_image/native_image.h" ] +} + +ohos_ndk_library("libnative_image_ndk") { + output_name = "native_image" + output_extension = "so" + ndk_description_file = "./libnative_image.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeImage" + system_capability_headers = [ "native_image/native_image.h" ] +} diff --git a/graphic/graphic_2d/native_image/libnative_image.ndk.json b/graphic/graphic_2d/native_image/libnative_image.ndk.json index 537d83d3e5ae6942a7818b0f5a252a574840c45d..3b69c79cbf21d576ab7e929cfe0b17c5216dea3d 100644 --- a/graphic/graphic_2d/native_image/libnative_image.ndk.json +++ b/graphic/graphic_2d/native_image/libnative_image.ndk.json @@ -1,10 +1,10 @@ -[ - { "name": "OH_NativeImage_Create" }, - { "name": "OH_NativeImage_AcquireNativeWindow" }, - { "name": "OH_NativeImage_AttachContext" }, - { "name": "OH_NativeImage_DetachContext" }, - { "name": "OH_NativeImage_UpdateSurfaceImage" }, - { "name": "OH_NativeImage_GetTimestamp" }, - { "name": "OH_NativeImage_GetTransformMatrix" }, - { "name": "OH_NativeImage_Destroy" } +[ + { "name": "OH_NativeImage_Create" }, + { "name": "OH_NativeImage_AcquireNativeWindow" }, + { "name": "OH_NativeImage_AttachContext" }, + { "name": "OH_NativeImage_DetachContext" }, + { "name": "OH_NativeImage_UpdateSurfaceImage" }, + { "name": "OH_NativeImage_GetTimestamp" }, + { "name": "OH_NativeImage_GetTransformMatrix" }, + { "name": "OH_NativeImage_Destroy" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_image/native_image.h b/graphic/graphic_2d/native_image/native_image.h index 6a12316d14c934e54343b83fde6fa2ceb4d08ed2..ada8357cb904d7520411aacdf6374414f0517912 100644 --- a/graphic/graphic_2d/native_image/native_image.h +++ b/graphic/graphic_2d/native_image/native_image.h @@ -32,6 +32,7 @@ * * @brief Defines the functions for obtaining and using a native image. * + * @library libnative_image.so * @since 9 * @version 1.0 */ diff --git a/graphic/graphic_2d/native_vsync/BUILD.gn b/graphic/graphic_2d/native_vsync/BUILD.gn index a7b9b402e50f6866b1fd5c0f80391db08a256ec2..68db17ec413b6c2b96b94ea6cc1e38a2539200b8 100644 --- a/graphic/graphic_2d/native_vsync/BUILD.gn +++ b/graphic/graphic_2d/native_vsync/BUILD.gn @@ -1,28 +1,28 @@ -# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_vsync_header") { - dest_dir = "$ndk_headers_out_dir/native_vsync" - sources = [ "//interface/sdk_c/graphic/graphic_2d/native_vsync/native_vsync.h" ] -} - -ohos_ndk_library("libnative_vsync_ndk") { - output_name = "native_vsync" - output_extension = "so" - ndk_description_file = "./libnative_vsync.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.NativeVSync" - system_capability_headers = [ "native_vsync/native_vsync.h" ] -} +# Copyright (c) 2022 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_vsync_header") { + dest_dir = "$ndk_headers_out_dir/native_vsync" + sources = [ "//interface/sdk_c/graphic/graphic_2d/native_vsync/native_vsync.h" ] +} + +ohos_ndk_library("libnative_vsync_ndk") { + output_name = "native_vsync" + output_extension = "so" + ndk_description_file = "./libnative_vsync.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeVSync" + system_capability_headers = [ "native_vsync/native_vsync.h" ] +} diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index e2c78daa58a279be992ec614bae0a8f928b2ba28..56b420eb6dec86522f2d5729c271fc7c7e2188a7 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -1,5 +1,6 @@ -[ - { "name": "OH_NativeVSync_Create" }, - { "name": "OH_NativeVSync_Destroy" }, - { "name": "OH_NativeVSync_RequestFrame" } +[ + { "name": "OH_NativeVSync_Create" }, + { "name": "OH_NativeVSync_Destroy" }, + { "name": "OH_NativeVSync_RequestFrame" }, + { "name": "OH_NativeVSync_GetPeriod" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index fb2d0c0c481e72cbaeb09bc581524177b0e283aa..2372eb1394d128c3b5faa6d41aece0967ea3928c 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -32,6 +32,7 @@ * * @brief Defines the functions for obtaining and using a native vsync. * + * @library libnative_vsync.so * @since 9 * @version 1.0 */ @@ -80,6 +81,18 @@ void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); * @version 1.0 */ int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); + +/** + * @brief Get vsync period. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param period Indicates the vsync period. + * @return Returns int32_t, return value == 0, success, otherwise, failed. + * @since 10 + * @version 1.0 + */ +int OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_window/BUILD.gn b/graphic/graphic_2d/native_window/BUILD.gn index d6f1baafb6cbc9b8863153c83a3b8f2b4e985c03..82d1346a1abe9e7a4d85207ea1def5157af9897a 100644 --- a/graphic/graphic_2d/native_window/BUILD.gn +++ b/graphic/graphic_2d/native_window/BUILD.gn @@ -1,34 +1,34 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("native_window_header") { - dest_dir = "$ndk_headers_out_dir/native_window" - sources = [ - "//interface/sdk_c/graphic/graphic_2d/native_window/buffer_handle.h", - "//interface/sdk_c/graphic/graphic_2d/native_window/external_window.h", - ] -} - -ohos_ndk_library("libnative_window_ndk") { - output_name = "native_window" - output_extension = "so" - ndk_description_file = "./libnative_window.ndk.json" - system_capability = "SystemCapability.Graphic.Graphic2D.NativeWindow" - system_capability_headers = [ - "native_window/buffer_handle.h", - "native_window/external_window.h", - ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("native_window_header") { + dest_dir = "$ndk_headers_out_dir/native_window" + sources = [ + "//interface/sdk_c/graphic/graphic_2d/native_window/buffer_handle.h", + "//interface/sdk_c/graphic/graphic_2d/native_window/external_window.h", + ] +} + +ohos_ndk_library("libnative_window_ndk") { + output_name = "native_window" + output_extension = "so" + ndk_description_file = "./libnative_window.ndk.json" + system_capability = "SystemCapability.Graphic.Graphic2D.NativeWindow" + system_capability_headers = [ + "native_window/buffer_handle.h", + "native_window/external_window.h", + ] +} diff --git a/graphic/graphic_2d/native_window/external_window.h b/graphic/graphic_2d/native_window/external_window.h index 81255842603524ce4c56c7dd9ab26cb13f5e9800..02dbbef3e38a959cb4c353b8eecbbeabda9e378b 100644 --- a/graphic/graphic_2d/native_window/external_window.h +++ b/graphic/graphic_2d/native_window/external_window.h @@ -32,6 +32,7 @@ * * @brief Defines the functions for obtaining and using a native window. * + * @library libnative_window.so * @since 8 * @version 1.0 */ diff --git a/graphic/graphic_2d/native_window/libnative_window.ndk.json b/graphic/graphic_2d/native_window/libnative_window.ndk.json index 95e138ee2dd64151981ce0003a07f29f6fab3ce4..0c76f51cab226efb66cedfa593ea5b8fd1250350 100644 --- a/graphic/graphic_2d/native_window/libnative_window.ndk.json +++ b/graphic/graphic_2d/native_window/libnative_window.ndk.json @@ -1,18 +1,18 @@ -[ - { "name": "OH_NativeWindow_CreateNativeWindow" }, - { "name": "OH_NativeWindow_DestroyNativeWindow" }, - { "name": "OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer" }, - { "name": "OH_NativeWindow_DestroyNativeWindowBuffer" }, - { "name": "OH_NativeWindow_NativeWindowRequestBuffer" }, - { "name": "OH_NativeWindow_NativeWindowFlushBuffer" }, - { "name": "OH_NativeWindow_NativeWindowAbortBuffer" }, - { "name": "OH_NativeWindow_NativeWindowHandleOpt" }, - { "name": "OH_NativeWindow_GetBufferHandleFromNative" }, - { "name": "OH_NativeWindow_NativeObjectReference" }, - { "name": "OH_NativeWindow_NativeObjectUnreference" }, - { "name": "OH_NativeWindow_GetNativeObjectMagic" }, - { "name": "OH_NativeWindow_NativeWindowSetScalingMode" }, - { "name": "OH_NativeWindow_NativeWindowSetMetaData" }, - { "name": "OH_NativeWindow_NativeWindowSetMetaDataSet" }, - { "name": "OH_NativeWindow_NativeWindowSetTunnelHandle" } +[ + { "name": "OH_NativeWindow_CreateNativeWindow" }, + { "name": "OH_NativeWindow_DestroyNativeWindow" }, + { "name": "OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer" }, + { "name": "OH_NativeWindow_DestroyNativeWindowBuffer" }, + { "name": "OH_NativeWindow_NativeWindowRequestBuffer" }, + { "name": "OH_NativeWindow_NativeWindowFlushBuffer" }, + { "name": "OH_NativeWindow_NativeWindowAbortBuffer" }, + { "name": "OH_NativeWindow_NativeWindowHandleOpt" }, + { "name": "OH_NativeWindow_GetBufferHandleFromNative" }, + { "name": "OH_NativeWindow_NativeObjectReference" }, + { "name": "OH_NativeWindow_NativeObjectUnreference" }, + { "name": "OH_NativeWindow_GetNativeObjectMagic" }, + { "name": "OH_NativeWindow_NativeWindowSetScalingMode" }, + { "name": "OH_NativeWindow_NativeWindowSetMetaData" }, + { "name": "OH_NativeWindow_NativeWindowSetMetaDataSet" }, + { "name": "OH_NativeWindow_NativeWindowSetTunnelHandle" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/vulkan/BUILD.gn b/graphic/graphic_2d/vulkan/BUILD.gn index b9d2d371dd8fc3238347d31aa5e542a2d36ae78d..6b634fe2dfdacb50328229a20499abbb958a5afd 100644 --- a/graphic/graphic_2d/vulkan/BUILD.gn +++ b/graphic/graphic_2d/vulkan/BUILD.gn @@ -1,38 +1,38 @@ -# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("vulkan_header") { - dest_dir = "$ndk_headers_out_dir/vulkan" - sources = [ - "//interface/sdk_c/third_party/vulkan-headers/vulkan/vk_platform.h", - "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan.h", - "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan_core.h", - "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan_ohos.h", - ] -} - -ohos_ndk_library("libvulkan_ndk") { - output_name = "vulkan" - output_extension = "so" - ndk_description_file = "./libvulkan.ndk.json" - system_capability = "SystemCapability.Graphic.Vulkan" - system_capability_headers = [ - "vulkan/vk_platform.h", - "vulkan/vulkan.h", - "vulkan/vulkan_core.h", - "vulkan/vulkan_ohos.h", - ] -} +# Copyright (c) 2021 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("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("vulkan_header") { + dest_dir = "$ndk_headers_out_dir/vulkan" + sources = [ + "//interface/sdk_c/third_party/vulkan-headers/vulkan/vk_platform.h", + "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan.h", + "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan_core.h", + "//interface/sdk_c/third_party/vulkan-headers/vulkan/vulkan_ohos.h", + ] +} + +ohos_ndk_library("libvulkan_ndk") { + output_name = "vulkan" + output_extension = "so" + ndk_description_file = "./libvulkan.ndk.json" + system_capability = "SystemCapability.Graphic.Vulkan" + system_capability_headers = [ + "vulkan/vk_platform.h", + "vulkan/vulkan.h", + "vulkan/vulkan_core.h", + "vulkan/vulkan_ohos.h", + ] +} diff --git a/graphic/graphic_2d/vulkan/libvulkan.ndk.json b/graphic/graphic_2d/vulkan/libvulkan.ndk.json index 46896ac1f18e801f8739abf492697c2bf305885c..a01abada31cf2c868766885f57069139918fdd88 100644 --- a/graphic/graphic_2d/vulkan/libvulkan.ndk.json +++ b/graphic/graphic_2d/vulkan/libvulkan.ndk.json @@ -1,248 +1,248 @@ -[ - { "name": "vkAcquireNextImage2KHR" }, - { "name": "vkAcquireNextImageKHR" }, - { "name": "vkAllocateCommandBuffers" }, - { "name": "vkAllocateDescriptorSets" }, - { "name": "vkAllocateMemory" }, - { "name": "vkBeginCommandBuffer" }, - { "name": "vkBindBufferMemory" }, - { "name": "vkBindBufferMemory2" }, - { "name": "vkBindImageMemory" }, - { "name": "vkBindImageMemory2" }, - { "name": "vkCmdBeginQuery" }, - { "name": "vkCmdBeginRendering" }, - { "name": "vkCmdBeginRenderPass" }, - { "name": "vkCmdBeginRenderPass2" }, - { "name": "vkCmdBindDescriptorSets" }, - { "name": "vkCmdBindIndexBuffer" }, - { "name": "vkCmdBindPipeline" }, - { "name": "vkCmdBindVertexBuffers" }, - { "name": "vkCmdBindVertexBuffers2" }, - { "name": "vkCmdBlitImage" }, - { "name": "vkCmdBlitImage2" }, - { "name": "vkCmdClearAttachments" }, - { "name": "vkCmdClearColorImage" }, - { "name": "vkCmdClearDepthStencilImage" }, - { "name": "vkCmdCopyBuffer" }, - { "name": "vkCmdCopyBuffer2" }, - { "name": "vkCmdCopyBufferToImage" }, - { "name": "vkCmdCopyBufferToImage2" }, - { "name": "vkCmdCopyImage" }, - { "name": "vkCmdCopyImage2" }, - { "name": "vkCmdCopyImageToBuffer" }, - { "name": "vkCmdCopyImageToBuffer2" }, - { "name": "vkCmdCopyQueryPoolResults" }, - { "name": "vkCmdDispatch" }, - { "name": "vkCmdDispatchBase" }, - { "name": "vkCmdDispatchIndirect" }, - { "name": "vkCmdDraw" }, - { "name": "vkCmdDrawIndexed" }, - { "name": "vkCmdDrawIndexedIndirect" }, - { "name": "vkCmdDrawIndexedIndirectCount" }, - { "name": "vkCmdDrawIndirect" }, - { "name": "vkCmdDrawIndirectCount" }, - { "name": "vkCmdEndQuery" }, - { "name": "vkCmdEndRendering" }, - { "name": "vkCmdEndRenderPass" }, - { "name": "vkCmdEndRenderPass2" }, - { "name": "vkCmdExecuteCommands" }, - { "name": "vkCmdFillBuffer" }, - { "name": "vkCmdNextSubpass" }, - { "name": "vkCmdNextSubpass2" }, - { "name": "vkCmdPipelineBarrier" }, - { "name": "vkCmdPipelineBarrier2" }, - { "name": "vkCmdPushConstants" }, - { "name": "vkCmdResetEvent" }, - { "name": "vkCmdResetEvent2" }, - { "name": "vkCmdResetQueryPool" }, - { "name": "vkCmdResolveImage" }, - { "name": "vkCmdResolveImage2" }, - { "name": "vkCmdSetBlendConstants" }, - { "name": "vkCmdSetCullMode" }, - { "name": "vkCmdSetDepthBias" }, - { "name": "vkCmdSetDepthBiasEnable" }, - { "name": "vkCmdSetDepthBounds" }, - { "name": "vkCmdSetDepthBoundsTestEnable" }, - { "name": "vkCmdSetDepthCompareOp" }, - { "name": "vkCmdSetDepthTestEnable" }, - { "name": "vkCmdSetDepthWriteEnable" }, - { "name": "vkCmdSetDeviceMask" }, - { "name": "vkCmdSetEvent" }, - { "name": "vkCmdSetEvent2" }, - { "name": "vkCmdSetFrontFace" }, - { "name": "vkCmdSetLineWidth" }, - { "name": "vkCmdSetPrimitiveRestartEnable" }, - { "name": "vkCmdSetPrimitiveTopology" }, - { "name": "vkCmdSetRasterizerDiscardEnable" }, - { "name": "vkCmdSetScissor" }, - { "name": "vkCmdSetScissorWithCount" }, - { "name": "vkCmdSetStencilCompareMask" }, - { "name": "vkCmdSetStencilOp" }, - { "name": "vkCmdSetStencilReference" }, - { "name": "vkCmdSetStencilTestEnable" }, - { "name": "vkCmdSetStencilWriteMask" }, - { "name": "vkCmdSetViewport" }, - { "name": "vkCmdSetViewportWithCount" }, - { "name": "vkCmdUpdateBuffer" }, - { "name": "vkCmdWaitEvents" }, - { "name": "vkCmdWaitEvents2" }, - { "name": "vkCmdWriteTimestamp" }, - { "name": "vkCmdWriteTimestamp2" }, - { "name": "vkCreateBuffer" }, - { "name": "vkCreateBufferView" }, - { "name": "vkCreateCommandPool" }, - { "name": "vkCreateComputePipelines" }, - { "name": "vkCreateDescriptorPool" }, - { "name": "vkCreateDescriptorSetLayout" }, - { "name": "vkCreateDescriptorUpdateTemplate" }, - { "name": "vkCreateDevice" }, - { "name": "vkCreateDisplayModeKHR" }, - { "name": "vkCreateDisplayPlaneSurfaceKHR" }, - { "name": "vkCreateEvent" }, - { "name": "vkCreateFence" }, - { "name": "vkCreateFramebuffer" }, - { "name": "vkCreateGraphicsPipelines" }, - { "name": "vkCreateImage" }, - { "name": "vkCreateImageView" }, - { "name": "vkCreateInstance" }, - { "name": "vkCreatePipelineCache" }, - { "name": "vkCreatePipelineLayout" }, - { "name": "vkCreatePrivateDataSlot" }, - { "name": "vkCreateQueryPool" }, - { "name": "vkCreateRenderPass" }, - { "name": "vkCreateRenderPass2" }, - { "name": "vkCreateSampler" }, - { "name": "vkCreateSamplerYcbcrConversion" }, - { "name": "vkCreateSemaphore" }, - { "name": "vkCreateShaderModule" }, - { "name": "vkCreateSharedSwapchainsKHR" }, - { "name": "vkCreateSwapchainKHR" }, - { "name": "vkDestroyBuffer" }, - { "name": "vkDestroyBufferView" }, - { "name": "vkDestroyCommandPool" }, - { "name": "vkDestroyDescriptorPool" }, - { "name": "vkDestroyDescriptorSetLayout" }, - { "name": "vkDestroyDescriptorUpdateTemplate" }, - { "name": "vkDestroyDevice" }, - { "name": "vkDestroyEvent" }, - { "name": "vkDestroyFence" }, - { "name": "vkDestroyFramebuffer" }, - { "name": "vkDestroyImage" }, - { "name": "vkDestroyImageView" }, - { "name": "vkDestroyInstance" }, - { "name": "vkDestroyPipeline" }, - { "name": "vkDestroyPipelineCache" }, - { "name": "vkDestroyPipelineLayout" }, - { "name": "vkDestroyPrivateDataSlot" }, - { "name": "vkDestroyQueryPool" }, - { "name": "vkDestroyRenderPass" }, - { "name": "vkDestroySampler" }, - { "name": "vkDestroySamplerYcbcrConversion" }, - { "name": "vkDestroySemaphore" }, - { "name": "vkDestroyShaderModule" }, - { "name": "vkDestroySurfaceKHR" }, - { "name": "vkDestroySwapchainKHR" }, - { "name": "vkDeviceWaitIdle" }, - { "name": "vkEndCommandBuffer" }, - { "name": "vkEnumerateDeviceExtensionProperties" }, - { "name": "vkEnumerateDeviceLayerProperties" }, - { "name": "vkEnumerateInstanceExtensionProperties" }, - { "name": "vkEnumerateInstanceLayerProperties" }, - { "name": "vkEnumerateInstanceVersion" }, - { "name": "vkEnumeratePhysicalDeviceGroups" }, - { "name": "vkEnumeratePhysicalDevices" }, - { "name": "vkFlushMappedMemoryRanges" }, - { "name": "vkFreeCommandBuffers" }, - { "name": "vkFreeDescriptorSets" }, - { "name": "vkFreeMemory" }, - { "name": "vkGetBufferDeviceAddress" }, - { "name": "vkGetBufferMemoryRequirements" }, - { "name": "vkGetBufferMemoryRequirements2" }, - { "name": "vkGetBufferOpaqueCaptureAddress" }, - { "name": "vkGetDescriptorSetLayoutSupport" }, - { "name": "vkGetDeviceBufferMemoryRequirements" }, - { "name": "vkGetDeviceGroupPeerMemoryFeatures" }, - { "name": "vkGetDeviceGroupPresentCapabilitiesKHR" }, - { "name": "vkGetDeviceGroupSurfacePresentModesKHR" }, - { "name": "vkGetDeviceImageMemoryRequirements" }, - { "name": "vkGetDeviceImageSparseMemoryRequirements" }, - { "name": "vkGetDeviceMemoryCommitment" }, - { "name": "vkGetDeviceMemoryOpaqueCaptureAddress" }, - { "name": "vkGetDeviceProcAddr" }, - { "name": "vkGetDeviceQueue" }, - { "name": "vkGetDeviceQueue2" }, - { "name": "vkGetDisplayModeProperties2KHR" }, - { "name": "vkGetDisplayModePropertiesKHR" }, - { "name": "vkGetDisplayPlaneCapabilities2KHR" }, - { "name": "vkGetDisplayPlaneCapabilitiesKHR" }, - { "name": "vkGetDisplayPlaneSupportedDisplaysKHR" }, - { "name": "vkGetEventStatus" }, - { "name": "vkGetFenceStatus" }, - { "name": "vkGetImageMemoryRequirements" }, - { "name": "vkGetImageMemoryRequirements2" }, - { "name": "vkGetImageSparseMemoryRequirements" }, - { "name": "vkGetImageSparseMemoryRequirements2" }, - { "name": "vkGetImageSubresourceLayout" }, - { "name": "vkGetInstanceProcAddr" }, - { "name": "vkGetPhysicalDeviceDisplayPlaneProperties2KHR" }, - { "name": "vkGetPhysicalDeviceDisplayPlanePropertiesKHR" }, - { "name": "vkGetPhysicalDeviceDisplayProperties2KHR" }, - { "name": "vkGetPhysicalDeviceDisplayPropertiesKHR" }, - { "name": "vkGetPhysicalDeviceExternalBufferProperties" }, - { "name": "vkGetPhysicalDeviceExternalFenceProperties" }, - { "name": "vkGetPhysicalDeviceExternalSemaphoreProperties" }, - { "name": "vkGetPhysicalDeviceFeatures" }, - { "name": "vkGetPhysicalDeviceFeatures2" }, - { "name": "vkGetPhysicalDeviceFormatProperties" }, - { "name": "vkGetPhysicalDeviceFormatProperties2" }, - { "name": "vkGetPhysicalDeviceImageFormatProperties" }, - { "name": "vkGetPhysicalDeviceImageFormatProperties2" }, - { "name": "vkGetPhysicalDeviceMemoryProperties" }, - { "name": "vkGetPhysicalDeviceMemoryProperties2" }, - { "name": "vkGetPhysicalDevicePresentRectanglesKHR" }, - { "name": "vkGetPhysicalDeviceProperties" }, - { "name": "vkGetPhysicalDeviceProperties2" }, - { "name": "vkGetPhysicalDeviceQueueFamilyProperties" }, - { "name": "vkGetPhysicalDeviceQueueFamilyProperties2" }, - { "name": "vkGetPhysicalDeviceSparseImageFormatProperties" }, - { "name": "vkGetPhysicalDeviceSparseImageFormatProperties2" }, - { "name": "vkGetPhysicalDeviceSurfaceCapabilities2KHR" }, - { "name": "vkGetPhysicalDeviceSurfaceCapabilitiesKHR" }, - { "name": "vkGetPhysicalDeviceSurfaceFormats2KHR" }, - { "name": "vkGetPhysicalDeviceSurfaceFormatsKHR" }, - { "name": "vkGetPhysicalDeviceSurfacePresentModesKHR" }, - { "name": "vkGetPhysicalDeviceSurfaceSupportKHR" }, - { "name": "vkGetPhysicalDeviceToolProperties" }, - { "name": "vkGetPipelineCacheData" }, - { "name": "vkGetPrivateData" }, - { "name": "vkGetQueryPoolResults" }, - { "name": "vkGetRenderAreaGranularity" }, - { "name": "vkGetSemaphoreCounterValue" }, - { "name": "vkGetSwapchainImagesKHR" }, - { "name": "vkInvalidateMappedMemoryRanges" }, - { "name": "vkMapMemory" }, - { "name": "vkMergePipelineCaches" }, - { "name": "vkQueueBindSparse" }, - { "name": "vkQueuePresentKHR" }, - { "name": "vkQueueSubmit" }, - { "name": "vkQueueSubmit2" }, - { "name": "vkQueueWaitIdle" }, - { "name": "vkResetCommandBuffer" }, - { "name": "vkResetCommandPool" }, - { "name": "vkResetDescriptorPool" }, - { "name": "vkResetEvent" }, - { "name": "vkResetFences" }, - { "name": "vkResetQueryPool" }, - { "name": "vkSetEvent" }, - { "name": "vkSetPrivateData" }, - { "name": "vkSignalSemaphore" }, - { "name": "vkTrimCommandPool" }, - { "name": "vkUnmapMemory" }, - { "name": "vkUpdateDescriptorSets" }, - { "name": "vkUpdateDescriptorSetWithTemplate" }, - { "name": "vkWaitForFences" }, - { "name": "vkWaitSemaphores" }, - { "name": "vkCreateSurfaceOHOS" }, - { "name": "vkGetNativeBufferPropertiesOHOS" }, - { "name": "vkGetMemoryNativeBufferOHOS" } +[ + { "name": "vkAcquireNextImage2KHR" }, + { "name": "vkAcquireNextImageKHR" }, + { "name": "vkAllocateCommandBuffers" }, + { "name": "vkAllocateDescriptorSets" }, + { "name": "vkAllocateMemory" }, + { "name": "vkBeginCommandBuffer" }, + { "name": "vkBindBufferMemory" }, + { "name": "vkBindBufferMemory2" }, + { "name": "vkBindImageMemory" }, + { "name": "vkBindImageMemory2" }, + { "name": "vkCmdBeginQuery" }, + { "name": "vkCmdBeginRendering" }, + { "name": "vkCmdBeginRenderPass" }, + { "name": "vkCmdBeginRenderPass2" }, + { "name": "vkCmdBindDescriptorSets" }, + { "name": "vkCmdBindIndexBuffer" }, + { "name": "vkCmdBindPipeline" }, + { "name": "vkCmdBindVertexBuffers" }, + { "name": "vkCmdBindVertexBuffers2" }, + { "name": "vkCmdBlitImage" }, + { "name": "vkCmdBlitImage2" }, + { "name": "vkCmdClearAttachments" }, + { "name": "vkCmdClearColorImage" }, + { "name": "vkCmdClearDepthStencilImage" }, + { "name": "vkCmdCopyBuffer" }, + { "name": "vkCmdCopyBuffer2" }, + { "name": "vkCmdCopyBufferToImage" }, + { "name": "vkCmdCopyBufferToImage2" }, + { "name": "vkCmdCopyImage" }, + { "name": "vkCmdCopyImage2" }, + { "name": "vkCmdCopyImageToBuffer" }, + { "name": "vkCmdCopyImageToBuffer2" }, + { "name": "vkCmdCopyQueryPoolResults" }, + { "name": "vkCmdDispatch" }, + { "name": "vkCmdDispatchBase" }, + { "name": "vkCmdDispatchIndirect" }, + { "name": "vkCmdDraw" }, + { "name": "vkCmdDrawIndexed" }, + { "name": "vkCmdDrawIndexedIndirect" }, + { "name": "vkCmdDrawIndexedIndirectCount" }, + { "name": "vkCmdDrawIndirect" }, + { "name": "vkCmdDrawIndirectCount" }, + { "name": "vkCmdEndQuery" }, + { "name": "vkCmdEndRendering" }, + { "name": "vkCmdEndRenderPass" }, + { "name": "vkCmdEndRenderPass2" }, + { "name": "vkCmdExecuteCommands" }, + { "name": "vkCmdFillBuffer" }, + { "name": "vkCmdNextSubpass" }, + { "name": "vkCmdNextSubpass2" }, + { "name": "vkCmdPipelineBarrier" }, + { "name": "vkCmdPipelineBarrier2" }, + { "name": "vkCmdPushConstants" }, + { "name": "vkCmdResetEvent" }, + { "name": "vkCmdResetEvent2" }, + { "name": "vkCmdResetQueryPool" }, + { "name": "vkCmdResolveImage" }, + { "name": "vkCmdResolveImage2" }, + { "name": "vkCmdSetBlendConstants" }, + { "name": "vkCmdSetCullMode" }, + { "name": "vkCmdSetDepthBias" }, + { "name": "vkCmdSetDepthBiasEnable" }, + { "name": "vkCmdSetDepthBounds" }, + { "name": "vkCmdSetDepthBoundsTestEnable" }, + { "name": "vkCmdSetDepthCompareOp" }, + { "name": "vkCmdSetDepthTestEnable" }, + { "name": "vkCmdSetDepthWriteEnable" }, + { "name": "vkCmdSetDeviceMask" }, + { "name": "vkCmdSetEvent" }, + { "name": "vkCmdSetEvent2" }, + { "name": "vkCmdSetFrontFace" }, + { "name": "vkCmdSetLineWidth" }, + { "name": "vkCmdSetPrimitiveRestartEnable" }, + { "name": "vkCmdSetPrimitiveTopology" }, + { "name": "vkCmdSetRasterizerDiscardEnable" }, + { "name": "vkCmdSetScissor" }, + { "name": "vkCmdSetScissorWithCount" }, + { "name": "vkCmdSetStencilCompareMask" }, + { "name": "vkCmdSetStencilOp" }, + { "name": "vkCmdSetStencilReference" }, + { "name": "vkCmdSetStencilTestEnable" }, + { "name": "vkCmdSetStencilWriteMask" }, + { "name": "vkCmdSetViewport" }, + { "name": "vkCmdSetViewportWithCount" }, + { "name": "vkCmdUpdateBuffer" }, + { "name": "vkCmdWaitEvents" }, + { "name": "vkCmdWaitEvents2" }, + { "name": "vkCmdWriteTimestamp" }, + { "name": "vkCmdWriteTimestamp2" }, + { "name": "vkCreateBuffer" }, + { "name": "vkCreateBufferView" }, + { "name": "vkCreateCommandPool" }, + { "name": "vkCreateComputePipelines" }, + { "name": "vkCreateDescriptorPool" }, + { "name": "vkCreateDescriptorSetLayout" }, + { "name": "vkCreateDescriptorUpdateTemplate" }, + { "name": "vkCreateDevice" }, + { "name": "vkCreateDisplayModeKHR" }, + { "name": "vkCreateDisplayPlaneSurfaceKHR" }, + { "name": "vkCreateEvent" }, + { "name": "vkCreateFence" }, + { "name": "vkCreateFramebuffer" }, + { "name": "vkCreateGraphicsPipelines" }, + { "name": "vkCreateImage" }, + { "name": "vkCreateImageView" }, + { "name": "vkCreateInstance" }, + { "name": "vkCreatePipelineCache" }, + { "name": "vkCreatePipelineLayout" }, + { "name": "vkCreatePrivateDataSlot" }, + { "name": "vkCreateQueryPool" }, + { "name": "vkCreateRenderPass" }, + { "name": "vkCreateRenderPass2" }, + { "name": "vkCreateSampler" }, + { "name": "vkCreateSamplerYcbcrConversion" }, + { "name": "vkCreateSemaphore" }, + { "name": "vkCreateShaderModule" }, + { "name": "vkCreateSharedSwapchainsKHR" }, + { "name": "vkCreateSwapchainKHR" }, + { "name": "vkDestroyBuffer" }, + { "name": "vkDestroyBufferView" }, + { "name": "vkDestroyCommandPool" }, + { "name": "vkDestroyDescriptorPool" }, + { "name": "vkDestroyDescriptorSetLayout" }, + { "name": "vkDestroyDescriptorUpdateTemplate" }, + { "name": "vkDestroyDevice" }, + { "name": "vkDestroyEvent" }, + { "name": "vkDestroyFence" }, + { "name": "vkDestroyFramebuffer" }, + { "name": "vkDestroyImage" }, + { "name": "vkDestroyImageView" }, + { "name": "vkDestroyInstance" }, + { "name": "vkDestroyPipeline" }, + { "name": "vkDestroyPipelineCache" }, + { "name": "vkDestroyPipelineLayout" }, + { "name": "vkDestroyPrivateDataSlot" }, + { "name": "vkDestroyQueryPool" }, + { "name": "vkDestroyRenderPass" }, + { "name": "vkDestroySampler" }, + { "name": "vkDestroySamplerYcbcrConversion" }, + { "name": "vkDestroySemaphore" }, + { "name": "vkDestroyShaderModule" }, + { "name": "vkDestroySurfaceKHR" }, + { "name": "vkDestroySwapchainKHR" }, + { "name": "vkDeviceWaitIdle" }, + { "name": "vkEndCommandBuffer" }, + { "name": "vkEnumerateDeviceExtensionProperties" }, + { "name": "vkEnumerateDeviceLayerProperties" }, + { "name": "vkEnumerateInstanceExtensionProperties" }, + { "name": "vkEnumerateInstanceLayerProperties" }, + { "name": "vkEnumerateInstanceVersion" }, + { "name": "vkEnumeratePhysicalDeviceGroups" }, + { "name": "vkEnumeratePhysicalDevices" }, + { "name": "vkFlushMappedMemoryRanges" }, + { "name": "vkFreeCommandBuffers" }, + { "name": "vkFreeDescriptorSets" }, + { "name": "vkFreeMemory" }, + { "name": "vkGetBufferDeviceAddress" }, + { "name": "vkGetBufferMemoryRequirements" }, + { "name": "vkGetBufferMemoryRequirements2" }, + { "name": "vkGetBufferOpaqueCaptureAddress" }, + { "name": "vkGetDescriptorSetLayoutSupport" }, + { "name": "vkGetDeviceBufferMemoryRequirements" }, + { "name": "vkGetDeviceGroupPeerMemoryFeatures" }, + { "name": "vkGetDeviceGroupPresentCapabilitiesKHR" }, + { "name": "vkGetDeviceGroupSurfacePresentModesKHR" }, + { "name": "vkGetDeviceImageMemoryRequirements" }, + { "name": "vkGetDeviceImageSparseMemoryRequirements" }, + { "name": "vkGetDeviceMemoryCommitment" }, + { "name": "vkGetDeviceMemoryOpaqueCaptureAddress" }, + { "name": "vkGetDeviceProcAddr" }, + { "name": "vkGetDeviceQueue" }, + { "name": "vkGetDeviceQueue2" }, + { "name": "vkGetDisplayModeProperties2KHR" }, + { "name": "vkGetDisplayModePropertiesKHR" }, + { "name": "vkGetDisplayPlaneCapabilities2KHR" }, + { "name": "vkGetDisplayPlaneCapabilitiesKHR" }, + { "name": "vkGetDisplayPlaneSupportedDisplaysKHR" }, + { "name": "vkGetEventStatus" }, + { "name": "vkGetFenceStatus" }, + { "name": "vkGetImageMemoryRequirements" }, + { "name": "vkGetImageMemoryRequirements2" }, + { "name": "vkGetImageSparseMemoryRequirements" }, + { "name": "vkGetImageSparseMemoryRequirements2" }, + { "name": "vkGetImageSubresourceLayout" }, + { "name": "vkGetInstanceProcAddr" }, + { "name": "vkGetPhysicalDeviceDisplayPlaneProperties2KHR" }, + { "name": "vkGetPhysicalDeviceDisplayPlanePropertiesKHR" }, + { "name": "vkGetPhysicalDeviceDisplayProperties2KHR" }, + { "name": "vkGetPhysicalDeviceDisplayPropertiesKHR" }, + { "name": "vkGetPhysicalDeviceExternalBufferProperties" }, + { "name": "vkGetPhysicalDeviceExternalFenceProperties" }, + { "name": "vkGetPhysicalDeviceExternalSemaphoreProperties" }, + { "name": "vkGetPhysicalDeviceFeatures" }, + { "name": "vkGetPhysicalDeviceFeatures2" }, + { "name": "vkGetPhysicalDeviceFormatProperties" }, + { "name": "vkGetPhysicalDeviceFormatProperties2" }, + { "name": "vkGetPhysicalDeviceImageFormatProperties" }, + { "name": "vkGetPhysicalDeviceImageFormatProperties2" }, + { "name": "vkGetPhysicalDeviceMemoryProperties" }, + { "name": "vkGetPhysicalDeviceMemoryProperties2" }, + { "name": "vkGetPhysicalDevicePresentRectanglesKHR" }, + { "name": "vkGetPhysicalDeviceProperties" }, + { "name": "vkGetPhysicalDeviceProperties2" }, + { "name": "vkGetPhysicalDeviceQueueFamilyProperties" }, + { "name": "vkGetPhysicalDeviceQueueFamilyProperties2" }, + { "name": "vkGetPhysicalDeviceSparseImageFormatProperties" }, + { "name": "vkGetPhysicalDeviceSparseImageFormatProperties2" }, + { "name": "vkGetPhysicalDeviceSurfaceCapabilities2KHR" }, + { "name": "vkGetPhysicalDeviceSurfaceCapabilitiesKHR" }, + { "name": "vkGetPhysicalDeviceSurfaceFormats2KHR" }, + { "name": "vkGetPhysicalDeviceSurfaceFormatsKHR" }, + { "name": "vkGetPhysicalDeviceSurfacePresentModesKHR" }, + { "name": "vkGetPhysicalDeviceSurfaceSupportKHR" }, + { "name": "vkGetPhysicalDeviceToolProperties" }, + { "name": "vkGetPipelineCacheData" }, + { "name": "vkGetPrivateData" }, + { "name": "vkGetQueryPoolResults" }, + { "name": "vkGetRenderAreaGranularity" }, + { "name": "vkGetSemaphoreCounterValue" }, + { "name": "vkGetSwapchainImagesKHR" }, + { "name": "vkInvalidateMappedMemoryRanges" }, + { "name": "vkMapMemory" }, + { "name": "vkMergePipelineCaches" }, + { "name": "vkQueueBindSparse" }, + { "name": "vkQueuePresentKHR" }, + { "name": "vkQueueSubmit" }, + { "name": "vkQueueSubmit2" }, + { "name": "vkQueueWaitIdle" }, + { "name": "vkResetCommandBuffer" }, + { "name": "vkResetCommandPool" }, + { "name": "vkResetDescriptorPool" }, + { "name": "vkResetEvent" }, + { "name": "vkResetFences" }, + { "name": "vkResetQueryPool" }, + { "name": "vkSetEvent" }, + { "name": "vkSetPrivateData" }, + { "name": "vkSignalSemaphore" }, + { "name": "vkTrimCommandPool" }, + { "name": "vkUnmapMemory" }, + { "name": "vkUpdateDescriptorSets" }, + { "name": "vkUpdateDescriptorSetWithTemplate" }, + { "name": "vkWaitForFences" }, + { "name": "vkWaitSemaphores" }, + { "name": "vkCreateSurfaceOHOS" }, + { "name": "vkGetNativeBufferPropertiesOHOS" }, + { "name": "vkGetMemoryNativeBufferOHOS" } ] \ No newline at end of file diff --git a/hiviewdfx/hiappevent/BUILD.gn b/hiviewdfx/hiappevent/BUILD.gn index 9a0c41b0c7f44e1835d9a8d8f3ba241db39e7d75..0e76e00de4d0eb4a3ea5e07fe19be9c2e1e9786c 100644 --- a/hiviewdfx/hiappevent/BUILD.gn +++ b/hiviewdfx/hiappevent/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (c) 2021-2022 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") - -ohos_ndk_library("libhiappevent_ndk") { - output_name = "hiappevent_ndk" - ndk_description_file = "./libhiappevent.ndk.json" - min_compact_version = "1" - system_capability = "SystemCapability.HiviewDFX.HiAppEvent" -} - -ohos_ndk_headers("libhiappevent_header") { - dest_dir = "$ndk_headers_out_dir/hiappevent" - sources = [ - "./include/hiappevent/hiappevent.h", - "./include/hiappevent/hiappevent_cfg.h", - "./include/hiappevent/hiappevent_event.h", - "./include/hiappevent/hiappevent_param.h", - ] -} +# Copyright (c) 2021-2022 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") + +ohos_ndk_library("libhiappevent_ndk") { + output_name = "hiappevent_ndk" + ndk_description_file = "./libhiappevent.ndk.json" + min_compact_version = "1" + system_capability = "SystemCapability.HiviewDFX.HiAppEvent" +} + +ohos_ndk_headers("libhiappevent_header") { + dest_dir = "$ndk_headers_out_dir/hiappevent" + sources = [ + "./include/hiappevent/hiappevent.h", + "./include/hiappevent/hiappevent_cfg.h", + "./include/hiappevent/hiappevent_event.h", + "./include/hiappevent/hiappevent_param.h", + ] +} diff --git a/hiviewdfx/hiappevent/include/hiappevent/hiappevent.h b/hiviewdfx/hiappevent/include/hiappevent/hiappevent.h index 2b3d36311742c7e5a5259c8fafa757b3a074c675..f6b683229308c95a0bf1e0709d8424594785a803 100644 --- a/hiviewdfx/hiappevent/include/hiappevent/hiappevent.h +++ b/hiviewdfx/hiappevent/include/hiappevent/hiappevent.h @@ -1,374 +1,374 @@ -/* - * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_H -#define HIVIEWDFX_HIAPPEVENT_H -/** - * @addtogroup HiAppEvent - * @{ - * - * @brief Provides application event logging functions. - * - * Provides the event logging function for applications to log the fault, statistical, security, and user behavior - * events reported during running. Based on event information, you will be able to analyze the running status of - * applications. - * - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * - * @since 8 - * @version 1.0 - */ - -/** - * @file hiappevent.h - * - * @brief Defines the application event logging functions of the HiAppEvent module. - * - * Before performing application event logging, you must construct a ParamList object to store the input - * event parameters and specify the event domain, event name, and event type. - * - *

Event domain: a string used to identify the domain of event logging. - *

Event name: a string used to identify the event name of event logging. - *

Event type: FAULT, STATISTIC, SECURITY, BEHAVIOR. - *

ParamList: a linked list used to store event parameters, each of which is comprised of the parameter name and - * parameter value. - * - * Sample code: - * 00 Including the header file: - *

- *     #include "hiappevent/hiappevent.h"
- * 
- * 01 create a ParamList pointer. - *
- *     ParamList list = OH_HiAppEvent_CreateParamList();
- * 
- * 02 add params to the ParamList. - *
- *     bool boolean = true;
- *     OH_HiAppEvent_AddBoolParam(list, "bool_key", boolean);
- *     int32_t nums[] = {1, 2, 3};
- *     OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nums, sizeof(nums) / sizeof(nums[0]));
- * 
- * 03 performing event logging. - *
- *     int res = OH_HiAppEvent_Write("test_domain", "test_event", BEHAVIOR, list);
- * 
- * 04 destroy the ParamList pointer. - *
- *     OH_HiAppEvent_DestroyParamList(list);
- * 
- * - * @since 8 - * @version 1.0 - */ - -#include -#include - -#include "hiappevent_cfg.h" -#include "hiappevent_event.h" -#include "hiappevent_param.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Event types. - * - * You are advised to select event types based on their respective usage scenarios. - * - * @since 8 - * @version 1.0 - */ -enum EventType { - /* Fault event type */ - FAULT = 1, - - /* Statistic event type */ - STATISTIC = 2, - - /* Security event type */ - SECURITY = 3, - - /* Behavior event type */ - BEHAVIOR = 4 -}; - -/** - * @brief Event param list node. - * - * @since 8 - * @version 1.0 - */ -typedef struct ParamListNode* ParamList; - -/** - * @brief Create a pointer to the ParamList. - * - * @return Pointer to the ParamList. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_CreateParamList(void); - -/** - * @brief Destroy a pointer to the ParamList. - * - * @param list Event param list. - * @since 8 - * @version 1.0 - */ -void OH_HiAppEvent_DestroyParamList(ParamList list); - -/** - * @brief Add bool param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param boolean The bool value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddBoolParam(ParamList list, const char* name, bool boolean); - -/** - * @brief Add bool array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param booleans The bool array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddBoolArrayParam(ParamList list, const char* name, const bool* booleans, int arrSize); - -/** - * @brief Add int8_t param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The int8_t value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt8Param(ParamList list, const char* name, int8_t num); - -/** - * @brief Add int8_t array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The int8_t array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt8ArrayParam(ParamList list, const char* name, const int8_t* nums, int arrSize); - -/** - * @brief Add int16_t param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The int16_t value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt16Param(ParamList list, const char* name, int16_t num); - -/** - * @brief Add int16_t array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The int16_t array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt16ArrayParam(ParamList list, const char* name, const int16_t* nums, int arrSize); - -/** - * @brief Add int32_t param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The int32_t value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt32Param(ParamList list, const char* name, int32_t num); - -/** - * @brief Add int32_t array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The int32_t array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt32ArrayParam(ParamList list, const char* name, const int32_t* nums, int arrSize); - -/** - * @brief Add int64_t param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The int64_t value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt64Param(ParamList list, const char* name, int64_t num); - -/** - * @brief Add int64_t array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The int64_t array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddInt64ArrayParam(ParamList list, const char* name, const int64_t* nums, int arrSize); - -/** - * @brief Add float param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The float value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddFloatParam(ParamList list, const char* name, float num); - -/** - * @brief Add float array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The float array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddFloatArrayParam(ParamList list, const char* name, const float* nums, int arrSize); - -/** - * @brief Add double param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param num The double value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddDoubleParam(ParamList list, const char* name, double num); - -/** - * @brief Add double array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param nums The double array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddDoubleArrayParam(ParamList list, const char* name, const double* nums, int arrSize); - -/** - * @brief Add string param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param str The string value of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddStringParam(ParamList list, const char* name, const char* str); - -/** - * @brief Add string array param to the ParamList. - * - * @param list The ParamList of params to be added. - * @param name The name of the param to be added. - * @param strs The string array value of the param to be added. - * @param arrSize The array size of the param to be added. - * @return ParamList after the param is added. - * @since 8 - * @version 1.0 - */ -ParamList OH_HiAppEvent_AddStringArrayParam(ParamList list, const char* name, const char * const *strs, int arrSize); - -/** - * @brief Implements logging of application events whose parameters are of the list type. - * - * Before logging an application event, this API will first verify parameters of this event. - * If the verification is successful, the API will write the event to the event file. - * - * @param domain Indicates the event domain. You can customize the event domain as needed. - * @param name Indicates the event name. You can customize the event name as needed. - * @param type Indicates the event type, which is defined in {@link EventType}. - * @param list Indicates a linked list of event parameters, each of which is comprised of the parameter name and - * parameter value. - * @return Returns {@code 0} if the event parameter verification is successful, and the event will be written to - * the event file; returns a positive integer if invalid parameters are present in the event, and - * the event will be written to the event file after the invalid parameters are ignored; returns a - * negative integer if the event parameter verification fails, and the event will not be written to the event file. - * @since 8 - * @version 1.0 - */ -int OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType type, const ParamList list); - -/** - * @brief Implements the configuration function of application events logging. - * - * Application event logging configuration interface, which is used to configure event logging switch, - * event file directory storage quota size and other functions. - * - * @param name Configuration item name. - * @param value Configuration item value. - * @return Configuration result. - * @since 8 - * @version 1.0 - */ -bool OH_HiAppEvent_Configure(const char* name, const char* value); - -#ifdef __cplusplus -} -#endif -/** @} */ +/* + * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_H +#define HIVIEWDFX_HIAPPEVENT_H +/** + * @addtogroup HiAppEvent + * @{ + * + * @brief Provides application event logging functions. + * + * Provides the event logging function for applications to log the fault, statistical, security, and user behavior + * events reported during running. Based on event information, you will be able to analyze the running status of + * applications. + * + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * + * @since 8 + * @version 1.0 + */ + +/** + * @file hiappevent.h + * + * @brief Defines the application event logging functions of the HiAppEvent module. + * + * Before performing application event logging, you must construct a ParamList object to store the input + * event parameters and specify the event domain, event name, and event type. + * + *

Event domain: a string used to identify the domain of event logging. + *

Event name: a string used to identify the event name of event logging. + *

Event type: FAULT, STATISTIC, SECURITY, BEHAVIOR. + *

ParamList: a linked list used to store event parameters, each of which is comprised of the parameter name and + * parameter value. + * + * Sample code: + * 00 Including the header file: + *

+ *     #include "hiappevent/hiappevent.h"
+ * 
+ * 01 create a ParamList pointer. + *
+ *     ParamList list = OH_HiAppEvent_CreateParamList();
+ * 
+ * 02 add params to the ParamList. + *
+ *     bool boolean = true;
+ *     OH_HiAppEvent_AddBoolParam(list, "bool_key", boolean);
+ *     int32_t nums[] = {1, 2, 3};
+ *     OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nums, sizeof(nums) / sizeof(nums[0]));
+ * 
+ * 03 performing event logging. + *
+ *     int res = OH_HiAppEvent_Write("test_domain", "test_event", BEHAVIOR, list);
+ * 
+ * 04 destroy the ParamList pointer. + *
+ *     OH_HiAppEvent_DestroyParamList(list);
+ * 
+ * + * @since 8 + * @version 1.0 + */ + +#include +#include + +#include "hiappevent_cfg.h" +#include "hiappevent_event.h" +#include "hiappevent_param.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Event types. + * + * You are advised to select event types based on their respective usage scenarios. + * + * @since 8 + * @version 1.0 + */ +enum EventType { + /* Fault event type */ + FAULT = 1, + + /* Statistic event type */ + STATISTIC = 2, + + /* Security event type */ + SECURITY = 3, + + /* Behavior event type */ + BEHAVIOR = 4 +}; + +/** + * @brief Event param list node. + * + * @since 8 + * @version 1.0 + */ +typedef struct ParamListNode* ParamList; + +/** + * @brief Create a pointer to the ParamList. + * + * @return Pointer to the ParamList. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_CreateParamList(void); + +/** + * @brief Destroy a pointer to the ParamList. + * + * @param list Event param list. + * @since 8 + * @version 1.0 + */ +void OH_HiAppEvent_DestroyParamList(ParamList list); + +/** + * @brief Add bool param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param boolean The bool value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddBoolParam(ParamList list, const char* name, bool boolean); + +/** + * @brief Add bool array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param booleans The bool array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddBoolArrayParam(ParamList list, const char* name, const bool* booleans, int arrSize); + +/** + * @brief Add int8_t param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The int8_t value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt8Param(ParamList list, const char* name, int8_t num); + +/** + * @brief Add int8_t array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The int8_t array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt8ArrayParam(ParamList list, const char* name, const int8_t* nums, int arrSize); + +/** + * @brief Add int16_t param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The int16_t value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt16Param(ParamList list, const char* name, int16_t num); + +/** + * @brief Add int16_t array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The int16_t array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt16ArrayParam(ParamList list, const char* name, const int16_t* nums, int arrSize); + +/** + * @brief Add int32_t param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The int32_t value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt32Param(ParamList list, const char* name, int32_t num); + +/** + * @brief Add int32_t array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The int32_t array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt32ArrayParam(ParamList list, const char* name, const int32_t* nums, int arrSize); + +/** + * @brief Add int64_t param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The int64_t value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt64Param(ParamList list, const char* name, int64_t num); + +/** + * @brief Add int64_t array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The int64_t array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddInt64ArrayParam(ParamList list, const char* name, const int64_t* nums, int arrSize); + +/** + * @brief Add float param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The float value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddFloatParam(ParamList list, const char* name, float num); + +/** + * @brief Add float array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The float array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddFloatArrayParam(ParamList list, const char* name, const float* nums, int arrSize); + +/** + * @brief Add double param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param num The double value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddDoubleParam(ParamList list, const char* name, double num); + +/** + * @brief Add double array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param nums The double array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddDoubleArrayParam(ParamList list, const char* name, const double* nums, int arrSize); + +/** + * @brief Add string param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param str The string value of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddStringParam(ParamList list, const char* name, const char* str); + +/** + * @brief Add string array param to the ParamList. + * + * @param list The ParamList of params to be added. + * @param name The name of the param to be added. + * @param strs The string array value of the param to be added. + * @param arrSize The array size of the param to be added. + * @return ParamList after the param is added. + * @since 8 + * @version 1.0 + */ +ParamList OH_HiAppEvent_AddStringArrayParam(ParamList list, const char* name, const char * const *strs, int arrSize); + +/** + * @brief Implements logging of application events whose parameters are of the list type. + * + * Before logging an application event, this API will first verify parameters of this event. + * If the verification is successful, the API will write the event to the event file. + * + * @param domain Indicates the event domain. You can customize the event domain as needed. + * @param name Indicates the event name. You can customize the event name as needed. + * @param type Indicates the event type, which is defined in {@link EventType}. + * @param list Indicates a linked list of event parameters, each of which is comprised of the parameter name and + * parameter value. + * @return Returns {@code 0} if the event parameter verification is successful, and the event will be written to + * the event file; returns a positive integer if invalid parameters are present in the event, and + * the event will be written to the event file after the invalid parameters are ignored; returns a + * negative integer if the event parameter verification fails, and the event will not be written to the event file. + * @since 8 + * @version 1.0 + */ +int OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType type, const ParamList list); + +/** + * @brief Implements the configuration function of application events logging. + * + * Application event logging configuration interface, which is used to configure event logging switch, + * event file directory storage quota size and other functions. + * + * @param name Configuration item name. + * @param value Configuration item value. + * @return Configuration result. + * @since 8 + * @version 1.0 + */ +bool OH_HiAppEvent_Configure(const char* name, const char* value); + +#ifdef __cplusplus +} +#endif +/** @} */ #endif // HIVIEWDFX_HIAPPEVENT_H \ No newline at end of file diff --git a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h index e2a6fbeaf844c79bf108fe6d3ef91af93429175f..dc12144606e496606651449c65c43d6a398874fb 100644 --- a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h +++ b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_CONFIG_H -#define HIVIEWDFX_HIAPPEVENT_CONFIG_H - -/** - * @addtogroup HiAppEvent - * @{ - * - * @brief Provides application event logging functions. - * - * Provides the event logging function for applications to log the fault, statistical, security, and user behavior - * events reported during running. Based on event information, you will be able to analyze the running status of - * applications. - * - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * - * @since 8 - * @version 1.0 - */ - -/** - * @file hiappevent_cfg.h - * - * @brief Defines the names of all the configuration items of the event logging configuration function. - * - * If you want to configure the event logging function, you can directly use the configuration item constants. - * - * Sample code: - *
- *     bool res = OH_HiAppEvent_Configure(MAX_STORAGE, "100M");
- * 
- * - * @since 8 - * @version 1.0 - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Event logging switch. - * - * @since 8 - * @version 1.0 - */ -#define DISABLE "disable" - -/** - * @brief Event file directory storage quota size. - * - * @since 8 - * @version 1.0 - */ -#define MAX_STORAGE "max_storage" - -#ifdef __cplusplus -} -#endif -/** @} */ +/* + * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_CONFIG_H +#define HIVIEWDFX_HIAPPEVENT_CONFIG_H + +/** + * @addtogroup HiAppEvent + * @{ + * + * @brief Provides application event logging functions. + * + * Provides the event logging function for applications to log the fault, statistical, security, and user behavior + * events reported during running. Based on event information, you will be able to analyze the running status of + * applications. + * + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * + * @since 8 + * @version 1.0 + */ + +/** + * @file hiappevent_cfg.h + * + * @brief Defines the names of all the configuration items of the event logging configuration function. + * + * If you want to configure the event logging function, you can directly use the configuration item constants. + * + * Sample code: + *
+ *     bool res = OH_HiAppEvent_Configure(MAX_STORAGE, "100M");
+ * 
+ * + * @since 8 + * @version 1.0 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Event logging switch. + * + * @since 8 + * @version 1.0 + */ +#define DISABLE "disable" + +/** + * @brief Event file directory storage quota size. + * + * @since 8 + * @version 1.0 + */ +#define MAX_STORAGE "max_storage" + +#ifdef __cplusplus +} +#endif +/** @} */ #endif // HIVIEWDFX_HIAPPEVENT_CONFIG_H \ No newline at end of file diff --git a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h index 66aa52061fc8c8fc056437a41b1c22dc9ccf30b1..f7b44c748e7455c84afc7c71bdd049c40984a683 100644 --- a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h +++ b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_EVENT_H -#define HIVIEWDFX_HIAPPEVENT_EVENT_H - -/** - * @addtogroup HiAppEvent - * @{ - * - * @brief Provides application event logging functions. - * - * Provides the event logging function for applications to log the fault, statistical, security, and user behavior - * events reported during running. Based on event information, you will be able to analyze the running status of - * applications. - * - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * - * @since 8 - * @version 1.0 - */ - -/** - * @file hiappevent_event.h - * - * @brief Defines the event names of all predefined events. - * - * In addition to custom events associated with specific apps, you can also use predefined events for logging. - * - * Sample code: - *
- *     ParamList list = OH_HiAppEvent_CreateParamList();
- *     OH_HiAppEvent_AddInt32Param(list, PARAM_USER_ID, 123);
- *     int res = OH_HiAppEvent_Write("user_domain", EVENT_USER_LOGIN, BEHAVIOR, list);
- *     OH_HiAppEvent_DestroyParamList(list);
- * 
- * - * @since 8 - * @version 1.0 - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief user login event. - * - * @since 8 - * @version 1.0 - */ -#define EVENT_USER_LOGIN "hiappevent.user_login" - -/** - * @brief user logout event. - * - * @since 8 - * @version 1.0 - */ -#define EVENT_USER_LOGOUT "hiappevent.user_logout" - -/** - * @brief distributed service event. - * - * @since 8 - * @version 1.0 - */ -#define EVENT_DISTRIBUTED_SERVICE_START "hiappevent.distributed_service_start" - -#ifdef __cplusplus -} -#endif -/** @} */ +/* + * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_EVENT_H +#define HIVIEWDFX_HIAPPEVENT_EVENT_H + +/** + * @addtogroup HiAppEvent + * @{ + * + * @brief Provides application event logging functions. + * + * Provides the event logging function for applications to log the fault, statistical, security, and user behavior + * events reported during running. Based on event information, you will be able to analyze the running status of + * applications. + * + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * + * @since 8 + * @version 1.0 + */ + +/** + * @file hiappevent_event.h + * + * @brief Defines the event names of all predefined events. + * + * In addition to custom events associated with specific apps, you can also use predefined events for logging. + * + * Sample code: + *
+ *     ParamList list = OH_HiAppEvent_CreateParamList();
+ *     OH_HiAppEvent_AddInt32Param(list, PARAM_USER_ID, 123);
+ *     int res = OH_HiAppEvent_Write("user_domain", EVENT_USER_LOGIN, BEHAVIOR, list);
+ *     OH_HiAppEvent_DestroyParamList(list);
+ * 
+ * + * @since 8 + * @version 1.0 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief user login event. + * + * @since 8 + * @version 1.0 + */ +#define EVENT_USER_LOGIN "hiappevent.user_login" + +/** + * @brief user logout event. + * + * @since 8 + * @version 1.0 + */ +#define EVENT_USER_LOGOUT "hiappevent.user_logout" + +/** + * @brief distributed service event. + * + * @since 8 + * @version 1.0 + */ +#define EVENT_DISTRIBUTED_SERVICE_START "hiappevent.distributed_service_start" + +#ifdef __cplusplus +} +#endif +/** @} */ #endif // HIVIEWDFX_HIAPPEVENT_EVENT_H \ No newline at end of file diff --git a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h index f47972e8dd625dcc8144157d0c6283982a679135..687f4a2171f18525f76c286becba0b2d18e61e79 100644 --- a/hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h +++ b/hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_PARAM_H -#define HIVIEWDFX_HIAPPEVENT_PARAM_H - -/** - * @addtogroup HiAppEvent - * @{ - * - * @brief Provides application event logging functions. - * - * Provides the event logging function for applications to log the fault, statistical, security, and user behavior - * events reported during running. Based on event information, you will be able to analyze the running status of - * applications. - * - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * - * @since 8 - * @version 1.0 - */ - -/** - * @file hiappevent_param.h - * - * @brief Defines the param names of all predefined events. - * - * In addition to custom events associated with specific apps, you can also use predefined events for logging. - * - * Sample code: - *
- *     ParamList list = OH_HiAppEvent_CreateParamList();
- *     OH_HiAppEvent_AddInt32Param(list, PARAM_USER_ID, 123);
- *     int res = OH_HiAppEvent_Write("user_domain", EVENT_USER_LOGIN, BEHAVIOR, list);
- *     OH_HiAppEvent_DestroyParamList(list);
- * 
- * - * @since 8 - * @version 1.0 - */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Preset param name, user id param. - * - * @since 8 - * @version 1.0 - */ -#define PARAM_USER_ID "user_id" - -/** - * @brief Preset param name, distributed service name param. - * - * @since 8 - * @version 1.0 - */ -#define PARAM_DISTRIBUTED_SERVICE_NAME "ds_name" - -/** - * @brief Preset param name, distributed service instance id param. - * - * @since 8 - * @version 1.0 - */ -#define PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID "ds_instance_id" - -#ifdef __cplusplus -} -#endif -/** @} */ +/* + * Copyright (c) 2021 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 HIVIEWDFX_HIAPPEVENT_PARAM_H +#define HIVIEWDFX_HIAPPEVENT_PARAM_H + +/** + * @addtogroup HiAppEvent + * @{ + * + * @brief Provides application event logging functions. + * + * Provides the event logging function for applications to log the fault, statistical, security, and user behavior + * events reported during running. Based on event information, you will be able to analyze the running status of + * applications. + * + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * + * @since 8 + * @version 1.0 + */ + +/** + * @file hiappevent_param.h + * + * @brief Defines the param names of all predefined events. + * + * In addition to custom events associated with specific apps, you can also use predefined events for logging. + * + * Sample code: + *
+ *     ParamList list = OH_HiAppEvent_CreateParamList();
+ *     OH_HiAppEvent_AddInt32Param(list, PARAM_USER_ID, 123);
+ *     int res = OH_HiAppEvent_Write("user_domain", EVENT_USER_LOGIN, BEHAVIOR, list);
+ *     OH_HiAppEvent_DestroyParamList(list);
+ * 
+ * + * @since 8 + * @version 1.0 + */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Preset param name, user id param. + * + * @since 8 + * @version 1.0 + */ +#define PARAM_USER_ID "user_id" + +/** + * @brief Preset param name, distributed service name param. + * + * @since 8 + * @version 1.0 + */ +#define PARAM_DISTRIBUTED_SERVICE_NAME "ds_name" + +/** + * @brief Preset param name, distributed service instance id param. + * + * @since 8 + * @version 1.0 + */ +#define PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID "ds_instance_id" + +#ifdef __cplusplus +} +#endif +/** @} */ #endif // HIVIEWDFX_HIAPPEVENT_PARAM_H \ No newline at end of file diff --git a/hiviewdfx/hiappevent/libhiappevent.ndk.json b/hiviewdfx/hiappevent/libhiappevent.ndk.json index 44d3c6a7430f1a696efb93ecd57b8c4c5da501ee..7bc0de87ecb7c7f1d43d3c028ccd69cbee5e152e 100644 --- a/hiviewdfx/hiappevent/libhiappevent.ndk.json +++ b/hiviewdfx/hiappevent/libhiappevent.ndk.json @@ -1,62 +1,62 @@ -[ - { - "name": "OH_HiAppEvent_Write" - }, - { - "name": "OH_HiAppEvent_Configure" - }, - { - "name": "OH_HiAppEvent_AddBoolParam" - }, - { - "name": "OH_HiAppEvent_AddBoolArrayParam" - }, - { - "name": "OH_HiAppEvent_AddInt8Param" - }, - { - "name": "OH_HiAppEvent_AddInt8ArrayParam" - }, - { - "name": "OH_HiAppEvent_AddInt16Param" - }, - { - "name": "OH_HiAppEvent_AddInt16ArrayParam" - }, - { - "name": "OH_HiAppEvent_AddInt32Param" - }, - { - "name": "OH_HiAppEvent_AddInt32ArrayParam" - }, - { - "name": "OH_HiAppEvent_AddInt64Param" - }, - { - "name": "OH_HiAppEvent_AddInt64ArrayParam" - }, - { - "name": "OH_HiAppEvent_AddFloatParam" - }, - { - "name": "OH_HiAppEvent_AddFloatArrayParam" - }, - { - "name": "OH_HiAppEvent_AddDoubleParam" - }, - { - "name": "OH_HiAppEvent_AddDoubleArrayParam" - }, - { - "name": "OH_HiAppEvent_AddStringParam" - }, - { - "name": "OH_HiAppEvent_AddStringArrayParam" - }, - { - "name": "OH_HiAppEvent_CreateParamList" - }, - { - "name": "OH_HiAppEvent_DestroyParamList" - } -] +[ + { + "name": "OH_HiAppEvent_Write" + }, + { + "name": "OH_HiAppEvent_Configure" + }, + { + "name": "OH_HiAppEvent_AddBoolParam" + }, + { + "name": "OH_HiAppEvent_AddBoolArrayParam" + }, + { + "name": "OH_HiAppEvent_AddInt8Param" + }, + { + "name": "OH_HiAppEvent_AddInt8ArrayParam" + }, + { + "name": "OH_HiAppEvent_AddInt16Param" + }, + { + "name": "OH_HiAppEvent_AddInt16ArrayParam" + }, + { + "name": "OH_HiAppEvent_AddInt32Param" + }, + { + "name": "OH_HiAppEvent_AddInt32ArrayParam" + }, + { + "name": "OH_HiAppEvent_AddInt64Param" + }, + { + "name": "OH_HiAppEvent_AddInt64ArrayParam" + }, + { + "name": "OH_HiAppEvent_AddFloatParam" + }, + { + "name": "OH_HiAppEvent_AddFloatArrayParam" + }, + { + "name": "OH_HiAppEvent_AddDoubleParam" + }, + { + "name": "OH_HiAppEvent_AddDoubleArrayParam" + }, + { + "name": "OH_HiAppEvent_AddStringParam" + }, + { + "name": "OH_HiAppEvent_AddStringArrayParam" + }, + { + "name": "OH_HiAppEvent_CreateParamList" + }, + { + "name": "OH_HiAppEvent_DestroyParamList" + } +] diff --git a/hiviewdfx/hilog/BUILD.gn b/hiviewdfx/hilog/BUILD.gn index 1d6816c6036a5fb35e626fbc6182821212b68638..429f93903b168658dd93dfd5ba40798b0c2f1d3b 100644 --- a/hiviewdfx/hilog/BUILD.gn +++ b/hiviewdfx/hilog/BUILD.gn @@ -1,26 +1,26 @@ -# Copyright (c) 2021 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") - -ohos_ndk_library("libhilog_ndk") { - output_name = "hilog_ndk" - ndk_description_file = "./libhilog.ndk.json" - min_compact_version = "1" - system_capability = "SystemCapability.HiviewDFX.HiLog" -} - -ohos_ndk_headers("hilog_header") { - dest_dir = "$ndk_headers_out_dir/hilog" - sources = [ "./include/hilog/log.h" ] -} +# Copyright (c) 2021 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") + +ohos_ndk_library("libhilog_ndk") { + output_name = "hilog_ndk" + ndk_description_file = "./libhilog.ndk.json" + min_compact_version = "1" + system_capability = "SystemCapability.HiviewDFX.HiLog" +} + +ohos_ndk_headers("hilog_header") { + dest_dir = "$ndk_headers_out_dir/hilog" + sources = [ "./include/hilog/log.h" ] +} diff --git a/hiviewdfx/hilog/include/hilog/log.h b/hiviewdfx/hilog/include/hilog/log.h index 26049d945ad80c33ee9d3f3d124b3951e4957d2c..6b3e9cc227e55ed0680090ac3290e5c61d0a90be 100644 --- a/hiviewdfx/hilog/include/hilog/log.h +++ b/hiviewdfx/hilog/include/hilog/log.h @@ -1,258 +1,258 @@ -/* - * Copyright (c) 2021-2022 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 HIVIEWDFX_HILOG_H -#define HIVIEWDFX_HILOG_H -/** - * @addtogroup HiLog - * @{ - * - * @brief Provides logging functions. - * - * For example, you can use these functions to output logs of the specified log type, service domain, log tag, - * and log level. - * - * @syscap SystemCapability.HiviewDFX.HiLog - * - * @since 8 - */ - -/** - * @file log.h - * - * @brief Defines the logging functions of the HiLog module. - * - * Before outputting logs, you must define the service domain, and log tag, use the function with - * the specified log type and level, and specify the privacy identifier.\n - *
  • Service domain: used to identify the subsystem and module of a service. Its value is a hexadecimal - * integer ranging from 0x0 to 0xFFFF. \n - *
  • Log tag: a string used to identify the class, file, or service.
  • \n - *
  • Log level: DEBUG, INFO, WARN, ERROR, and FATAL
  • \n - *
  • Parameter format: a printf format string that starts with a % character, including format specifiers - * and variable parameters.
  • \n - *
  • Privacy identifier: {public} or {private} added between the % character and the format specifier in - * each parameter. Note that each parameter has a privacy identifier. If no privacy identifier is added, - * the parameter is considered to be private.
\n - * - * Sample code:\n - * Defining the service domain and log tag:\n - * #include \n - * #define LOG_DOMAIN 0x0201\n - * #define LOG_TAG "MY_TAG"\n - * Outputting logs:\n - * HILOG_WARN({@link LOG_APP}, "Failed to visit %{private}s, reason:%{public}d.", url, errno);\n - * Output result:\n - * 05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit , reason:503.\n - * - * @since 8 - */ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines the service domain for a log file. - * - * The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer - * ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated. \n - * - * @since 8 - */ -#ifndef LOG_DOMAIN -#define LOG_DOMAIN 0 -#endif - -/** - * @brief Defines a string constant used to identify the class, file, or service. - * - * @since 8 - */ -#ifndef LOG_TAG -#define LOG_TAG NULL -#endif - -/** - * @brief Enumerates log types. - * - * Currently, LOG_APP is available. \n - * - * @since 8 - */ -typedef enum { - /** Third-party application logs */ - LOG_APP = 0, -} LogType; - -/** - * @brief Enumerates log levels. - * - * You are advised to select log levels based on their respective usage scenarios:\n - *
  • DEBUG: used for debugging and disabled from commercial releases
  • \n - *
  • INFO: used for logging important system running status and steps in key processes
  • \n - *
  • WARN: used for logging unexpected exceptions that have little impact on user experience and can - * automatically recover. Logs at this level are generally output when such exceptions are detected and - * captured.
  • \n - *
  • ERROR: used for logging malfunction that affects user experience and cannot automatically - * recover
  • \n - *
  • FATAL: used for logging major exceptions that have severely affected user experience and should - * not occur.
\n - * - * @since 8 - */ -typedef enum { - /** Debug level to be used by {@link OH_LOG_DEBUG} */ - LOG_DEBUG = 3, - /** Informational level to be used by {@link OH_LOG_INFO} */ - LOG_INFO = 4, - /** Warning level to be used by {@link OH_LOG_WARN} */ - LOG_WARN = 5, - /** Error level to be used by {@link OH_LOG_ERROR} */ - LOG_ERROR = 6, - /** Fatal level to be used by {@link OH_LOG_FATAL} */ - LOG_FATAL = 7, -} LogLevel; - -/** - * @brief Outputs logs. - * - * You can use this function to output logs based on the specified log type, log level, service domain, log tag, - * and variable parameters determined by the format specifier and privacy identifier in the printf format. - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, - * LOG_ERROR, and LOG_FATAL. - * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. - * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy - * identifier. Specifically, {public} or {private} is added between the % character and the format specifier - * in each parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @return Returns 0 or a larger value if the operation is successful; returns a value smaller - * than 0 otherwise. - * @since 8 - */ -int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) - __attribute__((__format__(os_log, 5, 6))); - -/** - * @brief Checks whether logs of the specified service domain, log tag, and log level can be output. - * - * @param domain Indicates the service domain of logs. - * @param tag Indicates the log tag. - * @param level Indicates the log level. - * @return Returns true if the specified logs can be output; returns false otherwise. - * @since 8 - */ -bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); - -/** - * @brief Outputs debug logs. This is a function-like macro. - * - * Before calling this function, define the log service domain and log tag. Generally, you need to define them at - * the beginning of the source file. \n - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the - * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier - * in each parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @see OH_LOG_Print - * @since 8 - */ -#define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) - -/** - * @brief Outputs informational logs. This is a function-like macro. - * - * Before calling this function, define the log service domain and log tag. Generally, you need to define them - * at the beginning of the source file. \n - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy - * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in - * each parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @see OH_LOG_Print - * @since 8 - */ -#define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) - -/** - * @brief Outputs warning logs. This is a function-like macro. - * - * Before calling this function, define the log service domain and log tag. Generally, you need to define them - * at the beginning of the source file. \n - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the - * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier - * in each parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @see OH_LOG_Print - * @since 8 - */ -#define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) - -/** - * @brief Outputs error logs. This is a function-like macro. - * - * Before calling this function, define the log service domain and log tag. Generally, you need to define - * them at the beginning of the source file. \n - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy - * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in each - * parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @see OH_LOG_Print - * @since 8 - */ -#define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) - -/** - * @brief Outputs fatal logs. This is a function-like macro. - * - * Before calling this function, define the log service domain and log tag. Generally, you need to define them at - * the beginning of the source file. \n - * - * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. - * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy - * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in - * each parameter. \n - * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers - * in the format string. - * @see OH_LOG_Print - * @since 8 - */ -#define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) - -#ifdef __cplusplus -} -#endif -/** @} */ - -#ifdef HILOG_RAWFORMAT -#include "hilog/log_inner.h" -#endif - -#endif // HIVIEWDFX_HILOG_C_H +/* + * Copyright (c) 2021-2022 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 HIVIEWDFX_HILOG_H +#define HIVIEWDFX_HILOG_H +/** + * @addtogroup HiLog + * @{ + * + * @brief Provides logging functions. + * + * For example, you can use these functions to output logs of the specified log type, service domain, log tag, + * and log level. + * + * @syscap SystemCapability.HiviewDFX.HiLog + * + * @since 8 + */ + +/** + * @file log.h + * + * @brief Defines the logging functions of the HiLog module. + * + * Before outputting logs, you must define the service domain, and log tag, use the function with + * the specified log type and level, and specify the privacy identifier.\n + *
  • Service domain: used to identify the subsystem and module of a service. Its value is a hexadecimal + * integer ranging from 0x0 to 0xFFFF. \n + *
  • Log tag: a string used to identify the class, file, or service.
  • \n + *
  • Log level: DEBUG, INFO, WARN, ERROR, and FATAL
  • \n + *
  • Parameter format: a printf format string that starts with a % character, including format specifiers + * and variable parameters.
  • \n + *
  • Privacy identifier: {public} or {private} added between the % character and the format specifier in + * each parameter. Note that each parameter has a privacy identifier. If no privacy identifier is added, + * the parameter is considered to be private.
\n + * + * Sample code:\n + * Defining the service domain and log tag:\n + * #include \n + * #define LOG_DOMAIN 0x0201\n + * #define LOG_TAG "MY_TAG"\n + * Outputting logs:\n + * HILOG_WARN({@link LOG_APP}, "Failed to visit %{private}s, reason:%{public}d.", url, errno);\n + * Output result:\n + * 05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit , reason:503.\n + * + * @since 8 + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the service domain for a log file. + * + * The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer + * ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated. \n + * + * @since 8 + */ +#ifndef LOG_DOMAIN +#define LOG_DOMAIN 0 +#endif + +/** + * @brief Defines a string constant used to identify the class, file, or service. + * + * @since 8 + */ +#ifndef LOG_TAG +#define LOG_TAG NULL +#endif + +/** + * @brief Enumerates log types. + * + * Currently, LOG_APP is available. \n + * + * @since 8 + */ +typedef enum { + /** Third-party application logs */ + LOG_APP = 0, +} LogType; + +/** + * @brief Enumerates log levels. + * + * You are advised to select log levels based on their respective usage scenarios:\n + *
  • DEBUG: used for debugging and disabled from commercial releases
  • \n + *
  • INFO: used for logging important system running status and steps in key processes
  • \n + *
  • WARN: used for logging unexpected exceptions that have little impact on user experience and can + * automatically recover. Logs at this level are generally output when such exceptions are detected and + * captured.
  • \n + *
  • ERROR: used for logging malfunction that affects user experience and cannot automatically + * recover
  • \n + *
  • FATAL: used for logging major exceptions that have severely affected user experience and should + * not occur.
\n + * + * @since 8 + */ +typedef enum { + /** Debug level to be used by {@link OH_LOG_DEBUG} */ + LOG_DEBUG = 3, + /** Informational level to be used by {@link OH_LOG_INFO} */ + LOG_INFO = 4, + /** Warning level to be used by {@link OH_LOG_WARN} */ + LOG_WARN = 5, + /** Error level to be used by {@link OH_LOG_ERROR} */ + LOG_ERROR = 6, + /** Fatal level to be used by {@link OH_LOG_FATAL} */ + LOG_FATAL = 7, +} LogLevel; + +/** + * @brief Outputs logs. + * + * You can use this function to output logs based on the specified log type, log level, service domain, log tag, + * and variable parameters determined by the format specifier and privacy identifier in the printf format. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @return Returns 0 or a larger value if the operation is successful; returns a value smaller + * than 0 otherwise. + * @since 8 + */ +int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); + +/** + * @brief Checks whether logs of the specified service domain, log tag, and log level can be output. + * + * @param domain Indicates the service domain of logs. + * @param tag Indicates the log tag. + * @param level Indicates the log level. + * @return Returns true if the specified logs can be output; returns false otherwise. + * @since 8 + */ +bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); + +/** + * @brief Outputs debug logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs informational logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs warning logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs error logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define + * them at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in each + * parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs fatal logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +#ifdef __cplusplus +} +#endif +/** @} */ + +#ifdef HILOG_RAWFORMAT +#include "hilog/log_inner.h" +#endif + +#endif // HIVIEWDFX_HILOG_C_H diff --git a/hiviewdfx/hilog/libhilog.ndk.json b/hiviewdfx/hilog/libhilog.ndk.json index f121a608ef1db5c01429864a05ba6e5dc1bb62e5..db9221d286f2cd2c2ac20bef6d92acac9a9d845f 100644 --- a/hiviewdfx/hilog/libhilog.ndk.json +++ b/hiviewdfx/hilog/libhilog.ndk.json @@ -1,8 +1,8 @@ -[ - { - "name": "OH_LOG_Print" - }, - { - "name": "OH_LOG_IsLoggable" - } -] +[ + { + "name": "OH_LOG_Print" + }, + { + "name": "OH_LOG_IsLoggable" + } +] diff --git a/hiviewdfx/hitrace/BUILD.gn b/hiviewdfx/hitrace/BUILD.gn index 00086c79a326f1ae5053b13a3c9fb5ab1bdce92e..e167958ac92e897ad61d3b7401f388c6f8039e4e 100644 --- a/hiviewdfx/hitrace/BUILD.gn +++ b/hiviewdfx/hitrace/BUILD.gn @@ -1,26 +1,26 @@ -# 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. - -import("//build/ohos.gni") - -ohos_ndk_library("libhitrace_ndk") { - output_name = "hitrace_ndk" - ndk_description_file = "./libhitrace.ndk.json" - min_compact_version = "1" - system_capability = "SystemCapability.HiviewDFX.HiTrace" -} - -ohos_ndk_headers("hitrace_header") { - dest_dir = "$ndk_headers_out_dir/hitrace" - sources = [ "./include/hitrace/trace.h" ] -} +# 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. + +import("//build/ohos.gni") + +ohos_ndk_library("libhitrace_ndk") { + output_name = "hitrace_ndk" + ndk_description_file = "./libhitrace.ndk.json" + min_compact_version = "1" + system_capability = "SystemCapability.HiviewDFX.HiTrace" +} + +ohos_ndk_headers("hitrace_header") { + dest_dir = "$ndk_headers_out_dir/hitrace" + sources = [ "./include/hitrace/trace.h" ] +} diff --git a/hiviewdfx/hitrace/include/hitrace/trace.h b/hiviewdfx/hitrace/include/hitrace/trace.h index 1940d14b18dfb83310b9e2d214a1f098f482e884..6d9b1f6151d6ad1809b68242c89c4547a1fb4fc7 100644 --- a/hiviewdfx/hitrace/include/hitrace/trace.h +++ b/hiviewdfx/hitrace/include/hitrace/trace.h @@ -1,144 +1,144 @@ -/* - * 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. - */ - -#ifndef HIVIEWDFX_HITRACE_H -#define HIVIEWDFX_HITRACE_H -/** - * @addtogroup Hitrace - * @{ - * - * @brief hiTraceMeter provides APIs for system performance trace. - * - * You can call the APIs provided by hiTraceMeter in your own service logic to effectively - * track service processes and check the system performance. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * - * @since 10 - */ - -/** - * @file trace.h - * - * @brief Defines APIs of the HiTraceMeter module for performance trace. - * - * Sample code: \n - * Synchronous timeslice trace event: \n - * OH_HiTrace_StartTrace("hitraceTest");\n - * OH_HiTrace_FinishTrace();\n - * Output: \n - * <...>-1668 (-------) [003] .... 135.059377: tracing_mark_write: B|1668|H:hitraceTest \n - * <...>-1668 (-------) [003] .... 135.059415: tracing_mark_write: E|1668| \n - * Asynchronous timeslice trace event:\n - * OH_HiTrace_StartAsyncTrace("hitraceTest", 123); \n - * OH_HiTrace_FinishAsyncTrace("hitraceTest", 123); \n - * Output: \n - * <...>-2477 (-------) [001] .... 396.427165: tracing_mark_write: S|2477|H:hitraceTest 123 \n - * <...>-2477 (-------) [001] .... 396.427196: tracing_mark_write: F|2477|H:hitraceTest 123 \n - * Integer value trace event:\n - * OH_HiTrace_CountTrace("hitraceTest", 500); \n - * Output: \n - * <...>-2638 (-------) [002] .... 458.904382: tracing_mark_write: C|2638|H:hitraceTest 500 \n - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Marks the start of a synchronous trace task. - * - * The OH_HiTrace_StartTrace and OH_HiTrace_FinishTrace APIs must be used in pairs. - * The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. - * - * @param name Name of a trace task. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -void OH_HiTrace_StartTrace(const char *name); - -/** - * @brief Marks the end of a synchronous trace task. - * - * This API must be used with OH_HiTrace_StartTrace in pairs. During trace data parsing, the system matches - * it with the OH_HiTrace_StartTrace API recently invoked in the service process. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -void OH_HiTrace_FinishTrace(void); - -/** - * @brief Marks the start of an asynchronous trace task. - * - * This API is called to implement performance trace in asynchronous manner. The start and end of an asynchronous - * trace task do not occur in sequence. Therefore, a unique taskId is required to ensure proper data parsing. - * It is passed as an input parameter for the asynchronous API. - * This API is used with OH_HiTrace_FinishAsyncTrace in pairs. The two APIs that have the same name and - * task ID together form an asynchronous timeslice trace task. - * If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be - * performed multiple times concurrently, different task IDs must be specified in OH_HiTrace_StartTrace. - * If the trace tasks with the same name are not performed at the same time, the same taskId can be used. - * - * @param name Name of the asynchronous trace task. - * @param taskId ID of the asynchronous trace task. The start and end of an asynchronous trace task do not occur in - * sequence. Therefore, the start and end of an asynchronous trace need to be matched based on the task name and the - * unique task ID together. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -void OH_HiTrace_StartAsyncTrace(const char *name, int32_t taskId); - -/** - * @brief Marks the end of an asynchronous trace task. - * - * This API is called in the callback function after an asynchronous trace is complete. - * It is used with OH_HiTrace_StartAsyncTrace in pairs. Its name and task ID must be the same as those of - * OH_HiTrace_StartAsyncTrace. - * - * @param name Name of the asynchronous trace task. - * @param taskId ID of the asynchronous trace task. The start and end of an asynchronous trace task do not occur in - * sequence. Therefore, the start and end of an asynchronous trace need to be matched based on the task name and the - * unique task ID together. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -void OH_HiTrace_FinishAsyncTrace(const char *name, int32_t taskId); - -/** - * @brief Traces the value change of an integer variable based on its name. - * - * This API can be executed for multiple times to trace the value change of a given integer variable at different - * time points. - * - * @param name Name of the integer variable. It does not need to be the same as the real variable name. - * @param count Integer value. Generally, an integer variable can be passed. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 10 - */ -void OH_HiTrace_CountTrace(const char *name, int64_t count); - -#ifdef __cplusplus -} -#endif -#endif // HIVIEWDFX_HITRACE_H +/* + * 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. + */ + +#ifndef HIVIEWDFX_HITRACE_H +#define HIVIEWDFX_HITRACE_H +/** + * @addtogroup Hitrace + * @{ + * + * @brief hiTraceMeter provides APIs for system performance trace. + * + * You can call the APIs provided by hiTraceMeter in your own service logic to effectively + * track service processes and check the system performance. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * + * @since 10 + */ + +/** + * @file trace.h + * + * @brief Defines APIs of the HiTraceMeter module for performance trace. + * + * Sample code: \n + * Synchronous timeslice trace event: \n + * OH_HiTrace_StartTrace("hitraceTest");\n + * OH_HiTrace_FinishTrace();\n + * Output: \n + * <...>-1668 (-------) [003] .... 135.059377: tracing_mark_write: B|1668|H:hitraceTest \n + * <...>-1668 (-------) [003] .... 135.059415: tracing_mark_write: E|1668| \n + * Asynchronous timeslice trace event:\n + * OH_HiTrace_StartAsyncTrace("hitraceTest", 123); \n + * OH_HiTrace_FinishAsyncTrace("hitraceTest", 123); \n + * Output: \n + * <...>-2477 (-------) [001] .... 396.427165: tracing_mark_write: S|2477|H:hitraceTest 123 \n + * <...>-2477 (-------) [001] .... 396.427196: tracing_mark_write: F|2477|H:hitraceTest 123 \n + * Integer value trace event:\n + * OH_HiTrace_CountTrace("hitraceTest", 500); \n + * Output: \n + * <...>-2638 (-------) [002] .... 458.904382: tracing_mark_write: C|2638|H:hitraceTest 500 \n + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Marks the start of a synchronous trace task. + * + * The OH_HiTrace_StartTrace and OH_HiTrace_FinishTrace APIs must be used in pairs. + * The two APIs can be used in nested mode. The stack data structure is used for matching during trace data parsing. + * + * @param name Name of a trace task. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +void OH_HiTrace_StartTrace(const char *name); + +/** + * @brief Marks the end of a synchronous trace task. + * + * This API must be used with OH_HiTrace_StartTrace in pairs. During trace data parsing, the system matches + * it with the OH_HiTrace_StartTrace API recently invoked in the service process. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +void OH_HiTrace_FinishTrace(void); + +/** + * @brief Marks the start of an asynchronous trace task. + * + * This API is called to implement performance trace in asynchronous manner. The start and end of an asynchronous + * trace task do not occur in sequence. Therefore, a unique taskId is required to ensure proper data parsing. + * It is passed as an input parameter for the asynchronous API. + * This API is used with OH_HiTrace_FinishAsyncTrace in pairs. The two APIs that have the same name and + * task ID together form an asynchronous timeslice trace task. + * If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be + * performed multiple times concurrently, different task IDs must be specified in OH_HiTrace_StartTrace. + * If the trace tasks with the same name are not performed at the same time, the same taskId can be used. + * + * @param name Name of the asynchronous trace task. + * @param taskId ID of the asynchronous trace task. The start and end of an asynchronous trace task do not occur in + * sequence. Therefore, the start and end of an asynchronous trace need to be matched based on the task name and the + * unique task ID together. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +void OH_HiTrace_StartAsyncTrace(const char *name, int32_t taskId); + +/** + * @brief Marks the end of an asynchronous trace task. + * + * This API is called in the callback function after an asynchronous trace is complete. + * It is used with OH_HiTrace_StartAsyncTrace in pairs. Its name and task ID must be the same as those of + * OH_HiTrace_StartAsyncTrace. + * + * @param name Name of the asynchronous trace task. + * @param taskId ID of the asynchronous trace task. The start and end of an asynchronous trace task do not occur in + * sequence. Therefore, the start and end of an asynchronous trace need to be matched based on the task name and the + * unique task ID together. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +void OH_HiTrace_FinishAsyncTrace(const char *name, int32_t taskId); + +/** + * @brief Traces the value change of an integer variable based on its name. + * + * This API can be executed for multiple times to trace the value change of a given integer variable at different + * time points. + * + * @param name Name of the integer variable. It does not need to be the same as the real variable name. + * @param count Integer value. Generally, an integer variable can be passed. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @since 10 + */ +void OH_HiTrace_CountTrace(const char *name, int64_t count); + +#ifdef __cplusplus +} +#endif +#endif // HIVIEWDFX_HITRACE_H diff --git a/hiviewdfx/hitrace/libhitrace.ndk.json b/hiviewdfx/hitrace/libhitrace.ndk.json index accfdcd97b3c4a1e2d9604d9af926090f9fe10dd..15ae1967fbb7d6bf21da94bd10a06ec88eabb6be 100644 --- a/hiviewdfx/hitrace/libhitrace.ndk.json +++ b/hiviewdfx/hitrace/libhitrace.ndk.json @@ -1,17 +1,17 @@ -[ - { - "name": "OH_HiTrace_StartTrace" - }, - { - "name": "OH_HiTrace_FinishTrace" - }, - { - "name": "OH_HiTrace_StartAsyncTrace" - }, - { - "name": "OH_HiTrace_FinishAsyncTrace" - }, - { - "name": "OH_HiTrace_CountTrace" - } +[ + { + "name": "OH_HiTrace_StartTrace" + }, + { + "name": "OH_HiTrace_FinishTrace" + }, + { + "name": "OH_HiTrace_StartAsyncTrace" + }, + { + "name": "OH_HiTrace_FinishAsyncTrace" + }, + { + "name": "OH_HiTrace_CountTrace" + } ] \ No newline at end of file diff --git a/multimedia/audio_framework/BUILD.gn b/multimedia/audio_framework/BUILD.gn index 52780d5141b8667b952a39cb3acf3403ce38de8e..38c1c83ea18b7c55bdc0388a151f20d8e6b55f9e 100644 --- a/multimedia/audio_framework/BUILD.gn +++ b/multimedia/audio_framework/BUILD.gn @@ -1,38 +1,38 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") - -ohos_ndk_headers("ohaudio_header") { - dest_dir = "$ndk_headers_out_dir/ohaudio" - sources = [ - "audio_capturer/native_audiocapturer.h", - "audio_renderer/native_audiorenderer.h", - "common/native_audiostream_base.h", - "common/native_audiostreambuilder.h", - ] -} - -ohos_ndk_library("libohaudio_ndk") { - output_name = "ohaudio" - output_extension = "so" - ndk_description_file = "./ohaudio.ndk.json" - system_capability = "SystemCapability.Multimedia.Audio.Core" - system_capability_headers = [ - "ohaudio/native_audiostream_base.h", - "ohaudio/native_audiostreambuilder.h", - "ohaudio/native_audiorenderer.h", - "ohaudio/native_audiocapturer.h", - ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("ohaudio_header") { + dest_dir = "$ndk_headers_out_dir/ohaudio" + sources = [ + "audio_capturer/native_audiocapturer.h", + "audio_renderer/native_audiorenderer.h", + "common/native_audiostream_base.h", + "common/native_audiostreambuilder.h", + ] +} + +ohos_ndk_library("libohaudio_ndk") { + output_name = "ohaudio" + output_extension = "so" + ndk_description_file = "./ohaudio.ndk.json" + system_capability = "SystemCapability.Multimedia.Audio.Core" + system_capability_headers = [ + "ohaudio/native_audiostream_base.h", + "ohaudio/native_audiostreambuilder.h", + "ohaudio/native_audiorenderer.h", + "ohaudio/native_audiocapturer.h", + ] +} diff --git a/multimedia/audio_framework/audio_capturer/native_audiocapturer.h b/multimedia/audio_framework/audio_capturer/native_audiocapturer.h index 68d5796ca55ec7112c46267dbd91abbd03d174b4..dccead57084a56608db1df4e7dd6271ff19bd26f 100644 --- a/multimedia/audio_framework/audio_capturer/native_audiocapturer.h +++ b/multimedia/audio_framework/audio_capturer/native_audiocapturer.h @@ -1,234 +1,234 @@ -/* - * 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 OHAudio - * @{ - * - * @brief Provide the definition of the C interface for the audio module. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * - * @since 10 - * @version 1.0 - */ - -/** - * @file native_audiocapturer.h - * - * @brief Declare audio stream related interfaces for input type. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * @since 10 - * @version 1.0 - */ - -#ifndef NATIVE_AUDIOCAPTURER_H -#define NATIVE_AUDIOCAPTURER_H - -#include -#include "native_audiostream_base.h" -#ifdef __cplusplus -extern "C" { -#endif -/* - * Request to release the capturer stream. - * - * @since 10 - * @permission ohos.permission.MICROPHONE - * - * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_Release(OH_AudioCapturer* capturer); - -/* - * Request to start the capturer stream. - * - * @since 10 - * @permission ohos.permission.MICROPHONE - * - * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_Start(OH_AudioCapturer* capturer); - -/* - * Request to pause the capturer stream. - * - * @since 10 - * @permission ohos.permission.MICROPHONE - * - * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_Pause(OH_AudioCapturer* capturer); - -/* - * Request to stop the capturer stream. - * - * @since 10 - * @permission ohos.permission.MICROPHONE - * - * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_Stop(OH_AudioCapturer* capturer); - -/* - * Request to flush the capturer stream. - * - * @since 10 - * - * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_Flush(OH_AudioCapturer* capturer); - -/* - * Query the current state of the capturer client. - * - * This function will return the capturer state without updating the state. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param state Pointer to a variable that will be set for the state value. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetCurrentState(OH_AudioCapturer* capturer, OH_AudioStream_State* state); - -/* - * Query the latency mode of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param latencyMode Pointer to a variable that will be set for the latency mode. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode(OH_AudioCapturer* capturer, - OH_AudioStream_LatencyMode* latencyMode); - -/* - * Query the stream id of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param stramId Pointer to a variable that will be set for the stream id. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetStreamId(OH_AudioCapturer* capturer, uint32_t* streamId); - -/* - * Query the sample rate value of the capturer client. - * - * This function will return the capturer sample rate value without updating the state. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param rate The state value to be updated - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate(OH_AudioCapturer* capturer, int32_t* rate); - -/* - * Query the channel count of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param channelCount Pointer to a variable that will be set for the channel count. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetChannelCount(OH_AudioCapturer* capturer, int32_t* channelCount); - -/* - * Query the sample format of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param sampleFormat Pointer to a variable that will be set for the sample format. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat(OH_AudioCapturer* capturer, - OH_AudioStream_SampleFormat* sampleFormat); - -/* - * Query the encoding type of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param encodingType Pointer to a variable that will be set for the encoding type. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetEncodingType(OH_AudioCapturer* capturer, - OH_AudioStream_EncodingType* encodingType); - -/* - * Query the capturer info of the capturer client. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param sourceType Pointer to a variable that will be set for the stream sourceType. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo(OH_AudioCapturer* capturer, - OH_AudioStream_SourceType* sourceType); - -/* - * Query the frame size in callback, it is a fixed length of the buffer returned by each callback. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param frameSize Pointer to a variable that will be set for the frame size. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetFrameSizeInCallback(OH_AudioCapturer* capturer, int32_t* frameSize); - -/* - * Query the the time at which a particular frame was presented - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param clockId {@link #CLOCK_MONOTONIC} - * @param framePosition Pointer to a variable to receive the position - * @param timestamp Pointer to a variable to receive the timestamp - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetTimestamp(OH_AudioCapturer* capturer, - clockid_t clockId, int64_t* framePosition, int64_t* timestamp); - -/* - * Query the the number of frames that have been read since the stream was created. - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() - * @param frames Pointer to a variable that will be set for the frame count number. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioCapturer_GetFramesRead(OH_AudioCapturer* capturer, int64_t* frames); -#ifdef __cplusplus -} -#endif -#endif // NATIVE_AUDIOCAPTURER_H +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 10 + * @version 1.0 + */ + +/** + * @file native_audiocapturer.h + * + * @brief Declare audio stream related interfaces for input type. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * @since 10 + * @version 1.0 + */ + +#ifndef NATIVE_AUDIOCAPTURER_H +#define NATIVE_AUDIOCAPTURER_H + +#include +#include "native_audiostream_base.h" +#ifdef __cplusplus +extern "C" { +#endif +/* + * Request to release the capturer stream. + * + * @since 10 + * @permission ohos.permission.MICROPHONE + * + * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_Release(OH_AudioCapturer* capturer); + +/* + * Request to start the capturer stream. + * + * @since 10 + * @permission ohos.permission.MICROPHONE + * + * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_Start(OH_AudioCapturer* capturer); + +/* + * Request to pause the capturer stream. + * + * @since 10 + * @permission ohos.permission.MICROPHONE + * + * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_Pause(OH_AudioCapturer* capturer); + +/* + * Request to stop the capturer stream. + * + * @since 10 + * @permission ohos.permission.MICROPHONE + * + * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_Stop(OH_AudioCapturer* capturer); + +/* + * Request to flush the capturer stream. + * + * @since 10 + * + * @param capturer reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_Flush(OH_AudioCapturer* capturer); + +/* + * Query the current state of the capturer client. + * + * This function will return the capturer state without updating the state. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param state Pointer to a variable that will be set for the state value. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetCurrentState(OH_AudioCapturer* capturer, OH_AudioStream_State* state); + +/* + * Query the latency mode of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param latencyMode Pointer to a variable that will be set for the latency mode. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetLatencyMode(OH_AudioCapturer* capturer, + OH_AudioStream_LatencyMode* latencyMode); + +/* + * Query the stream id of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param stramId Pointer to a variable that will be set for the stream id. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetStreamId(OH_AudioCapturer* capturer, uint32_t* streamId); + +/* + * Query the sample rate value of the capturer client. + * + * This function will return the capturer sample rate value without updating the state. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param rate The state value to be updated + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetSamplingRate(OH_AudioCapturer* capturer, int32_t* rate); + +/* + * Query the channel count of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param channelCount Pointer to a variable that will be set for the channel count. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetChannelCount(OH_AudioCapturer* capturer, int32_t* channelCount); + +/* + * Query the sample format of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param sampleFormat Pointer to a variable that will be set for the sample format. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetSampleFormat(OH_AudioCapturer* capturer, + OH_AudioStream_SampleFormat* sampleFormat); + +/* + * Query the encoding type of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param encodingType Pointer to a variable that will be set for the encoding type. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetEncodingType(OH_AudioCapturer* capturer, + OH_AudioStream_EncodingType* encodingType); + +/* + * Query the capturer info of the capturer client. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param sourceType Pointer to a variable that will be set for the stream sourceType. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetCapturerInfo(OH_AudioCapturer* capturer, + OH_AudioStream_SourceType* sourceType); + +/* + * Query the frame size in callback, it is a fixed length of the buffer returned by each callback. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param frameSize Pointer to a variable that will be set for the frame size. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetFrameSizeInCallback(OH_AudioCapturer* capturer, int32_t* frameSize); + +/* + * Query the the time at which a particular frame was presented + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param clockId {@link #CLOCK_MONOTONIC} + * @param framePosition Pointer to a variable to receive the position + * @param timestamp Pointer to a variable to receive the timestamp + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetTimestamp(OH_AudioCapturer* capturer, + clockid_t clockId, int64_t* framePosition, int64_t* timestamp); + +/* + * Query the the number of frames that have been read since the stream was created. + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer() + * @param frames Pointer to a variable that will be set for the frame count number. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioCapturer_GetFramesRead(OH_AudioCapturer* capturer, int64_t* frames); +#ifdef __cplusplus +} +#endif +#endif // NATIVE_AUDIOCAPTURER_H diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index 8b201d9789ff39032c418d16398d732681438f0b..3fe1a85d1c3af6198774bfdce25daab7b106562a 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -1,232 +1,232 @@ -/* - * 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 OHAudio - * @{ - * - * @brief Provide the definition of the C interface for the audio module. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * - * @since 10 - * @version 1.0 - */ - -/** - * @file native_audiorenderer.h - * - * @brief Declare audio stream related interfaces for output type. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * @since 10 - * @version 1.0 - */ - -#ifndef NATIVE_AUDIORENDERER_H -#define NATIVE_AUDIORENDERER_H - -#include -#include "native_audiostream_base.h" -#ifdef __cplusplus -extern "C" { -#endif -/* - * Request to release the renderer stream. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_Release(OH_AudioRenderer* renderer); - -/* - * Request to start the renderer stream. - * - * @since 10 - * - * @param renderer reference created by OH_AudioStreamBuilder - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_Start(OH_AudioRenderer* renderer); - -/* - * Request to pause the renderer stream. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_Pause(OH_AudioRenderer* renderer); - -/* - * Request to stop renderer stream. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_Stop(OH_AudioRenderer* renderer); - -/* - * Request to flush the renderer stream. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_Flush(OH_AudioRenderer* renderer); - -/* - * Query the current state of the renderer client. - * - * This function will return the renderer state without updating the state. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param state Pointer to a variable that will be set for the state value. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetCurrentState(OH_AudioRenderer* renderer, - OH_AudioStream_State* state); - -/* - * Query the sample rate value of the renderer client - * - * This function will return the renderer sample rate value without updating the state. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param rate The state value to be updated - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate(OH_AudioRenderer* renderer, int32_t* rate); - -/* - * Query the stream id of the renderer client. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param stramId Pointer to a variable that will be set for the stream id. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetStreamId(OH_AudioRenderer* renderer, uint32_t* streamId); - -/* - * Query the channel count of the renderer client. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param channelCount Pointer to a variable that will be set for the channel count. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetChannelCount(OH_AudioRenderer* renderer, int32_t* channelCount); - -/* - * Query the sample format of the renderer client. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param sampleFormat Pointer to a variable that will be set for the sample format. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat(OH_AudioRenderer* renderer, - OH_AudioStream_SampleFormat* sampleFormat); - -/* - * Query the latency mode of the renderer client. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param latencyMode Pointer to a variable that will be set for the latency mode. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode(OH_AudioRenderer* renderer, - OH_AudioStream_LatencyMode* latencyMode); -/* - * Query the renderer info of the renderer client. - * - * The rendere info includes {@link OH_AudioStream_Usage} value. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param usage Pointer to a variable that will be set for the stream usage. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo(OH_AudioRenderer* renderer, - OH_AudioStream_Usage* usage); - -/* - * Query the encoding type of the renderer client. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param encodingType Pointer to a variable that will be set for the encoding type. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetEncodingType(OH_AudioRenderer* renderer, - OH_AudioStream_EncodingType* encodingType); - -/* - * Query the the number of frames that have been written since the stream was created. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param frames Pointer to a variable that will be set for the frame count number. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetFramesWritten(OH_AudioRenderer* renderer, int64_t* frames); - -/* - * Query the the time at which a particular frame was presented. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param clockId {@link #CLOCK_MONOTONIC} - * @param framePosition Pointer to a variable to receive the position - * @param timestamp Pointer to a variable to receive the timestamp - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer* renderer, - clockid_t clockId, int64_t* framePosition, int64_t* timestamp); - -/* - * Query the frame size in callback, it is a fixed length that the stream want to be filled for each callback. - * - * @since 10 - * - * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() - * @param frameSize Pointer to a variable that will be set for the frame size. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer* renderer, int32_t* frameSize); -#ifdef __cplusplus -} -#endif -#endif // NATIVE_AUDIORENDERER_H +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 10 + * @version 1.0 + */ + +/** + * @file native_audiorenderer.h + * + * @brief Declare audio stream related interfaces for output type. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * @since 10 + * @version 1.0 + */ + +#ifndef NATIVE_AUDIORENDERER_H +#define NATIVE_AUDIORENDERER_H + +#include +#include "native_audiostream_base.h" +#ifdef __cplusplus +extern "C" { +#endif +/* + * Request to release the renderer stream. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_Release(OH_AudioRenderer* renderer); + +/* + * Request to start the renderer stream. + * + * @since 10 + * + * @param renderer reference created by OH_AudioStreamBuilder + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_Start(OH_AudioRenderer* renderer); + +/* + * Request to pause the renderer stream. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_Pause(OH_AudioRenderer* renderer); + +/* + * Request to stop renderer stream. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_Stop(OH_AudioRenderer* renderer); + +/* + * Request to flush the renderer stream. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_Flush(OH_AudioRenderer* renderer); + +/* + * Query the current state of the renderer client. + * + * This function will return the renderer state without updating the state. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param state Pointer to a variable that will be set for the state value. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetCurrentState(OH_AudioRenderer* renderer, + OH_AudioStream_State* state); + +/* + * Query the sample rate value of the renderer client + * + * This function will return the renderer sample rate value without updating the state. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param rate The state value to be updated + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetSamplingRate(OH_AudioRenderer* renderer, int32_t* rate); + +/* + * Query the stream id of the renderer client. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param stramId Pointer to a variable that will be set for the stream id. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetStreamId(OH_AudioRenderer* renderer, uint32_t* streamId); + +/* + * Query the channel count of the renderer client. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param channelCount Pointer to a variable that will be set for the channel count. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetChannelCount(OH_AudioRenderer* renderer, int32_t* channelCount); + +/* + * Query the sample format of the renderer client. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param sampleFormat Pointer to a variable that will be set for the sample format. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetSampleFormat(OH_AudioRenderer* renderer, + OH_AudioStream_SampleFormat* sampleFormat); + +/* + * Query the latency mode of the renderer client. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param latencyMode Pointer to a variable that will be set for the latency mode. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetLatencyMode(OH_AudioRenderer* renderer, + OH_AudioStream_LatencyMode* latencyMode); +/* + * Query the renderer info of the renderer client. + * + * The rendere info includes {@link OH_AudioStream_Usage} value. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param usage Pointer to a variable that will be set for the stream usage. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetRendererInfo(OH_AudioRenderer* renderer, + OH_AudioStream_Usage* usage); + +/* + * Query the encoding type of the renderer client. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param encodingType Pointer to a variable that will be set for the encoding type. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetEncodingType(OH_AudioRenderer* renderer, + OH_AudioStream_EncodingType* encodingType); + +/* + * Query the the number of frames that have been written since the stream was created. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param frames Pointer to a variable that will be set for the frame count number. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetFramesWritten(OH_AudioRenderer* renderer, int64_t* frames); + +/* + * Query the the time at which a particular frame was presented. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param clockId {@link #CLOCK_MONOTONIC} + * @param framePosition Pointer to a variable to receive the position + * @param timestamp Pointer to a variable to receive the timestamp + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer* renderer, + clockid_t clockId, int64_t* framePosition, int64_t* timestamp); + +/* + * Query the frame size in callback, it is a fixed length that the stream want to be filled for each callback. + * + * @since 10 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param frameSize Pointer to a variable that will be set for the frame size. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer* renderer, int32_t* frameSize); +#ifdef __cplusplus +} +#endif +#endif // NATIVE_AUDIORENDERER_H diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 9270d8437bc7d455310b1df8359bafccd07307b6..87b862d5f79b33be7b5beec41d63e4c8327d54eb 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -1,556 +1,556 @@ -/* - * 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 OHAudio - * @{ - * - * @brief Provide the definition of the C interface for the audio module. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * - * @since 10 - * @version 1.0 - */ - -/** - * @file native_audiostream_base.h - * - * @brief Declare the underlying data structure. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * @since 10 - * @version 1.0 - */ - -#ifndef ST_NATIVE_AUDIOSTREAM_BASE_H -#define ST_NATIVE_AUDIOSTREAM_BASE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Define the result of the function execution. - * - * @since 10 - */ -typedef enum { - /** - * The call was successful. - * - * @since 10 - */ - AUDIOSTREAM_SUCCESS = 0, - - /** - * This means that the function was executed with an invalid input parameter. - * - * @since 10 - */ - AUDIOSTREAM_ERROR_INVALID_PARAM = 1, - - /** - * Execution status exception. - * - * @since 10 - */ - AUDIOSTREAM_ERROR_ILLEGAL_STATE = 2, - - /** - * An system error has occurred. - * - * @since 10 - */ - AUDIOSTREAM_ERROR_SYSTEM = 3 -} OH_AudioStream_Result; - -/** - * Define the audio stream type. - * - * @since 10 - */ -typedef enum { - /** - * The type for audio stream is renderer. - * - * @since 10 - */ - AUDIOSTREAM_TYPE_RENDERER = 1, - - /** - * The type for audio stream is capturer. - * - * @since 10 - */ - AUDIOSTREAM_TYPE_CAPTURER = 2 -} OH_AudioStream_Type; - -/** - * Define the audio stream sample format. - * - * @since 10 - */ -typedef enum { - /** - * Unsigned 8 format. - * - * @since 10 - */ - AUDIOSTREAM_SAMPLE_U8 = 0, - /** - * Signed 16 bit integer, little endian. - * - * @since 10 - */ - AUDIOSTREAM_SAMPLE_S16LE = 1, - /** - * Signed 24 bit integer, little endian. - * - * @since 10 - */ - AUDIOSTREAM_SAMPLE_S24LE = 2, - /** - * Signed 32 bit integer, little endian. - * - * @since 10 - */ - AUDIOSTREAM_SAMPLE_S32LE = 3, -} OH_AudioStream_SampleFormat; - -/** - * Define the audio encoding type. - * - * @since 10 - */ -typedef enum { - /** - * PCM encoding type. - * - * @since 10 - */ - AUDIOSTREAM_ENCODING_TYPE_RAW = 0, -} OH_AudioStream_EncodingType; - -/** - * Define the audio stream usage. - * Audio stream usage is used to describe what work scenario - * the current stream is used for. - * - * @since 10 - */ -typedef enum { - /** - * Unknown usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_UNKNOWN = 0, - /** - * Music usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_MUSIC = 1, - /** - * Voice communication usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_VOICE_COMMUNICATION = 2, - /** - * Voice assistant usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_VOICE_ASSISTANT = 3, - /** - * Alarm usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_ALARM = 4, - /** - * Voice message usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_VOICE_MESSAGE = 5, - /** - * Ringtone usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_RINGTONE = 6, - /** - * Notification usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_NOTIFICATION = 7, - /** - * Accessibility usage, such as screen reader. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_ACCESSIBILITY = 8, - /** - * Movie or video usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_MOVIE = 10, - /** - * Game sound effect usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_GAME = 11, - /** - * Audiobook usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_AUDIOBOOK = 12, - /** - * Navigation usage. - * - * @since 10 - */ - AUDIOSTREAM_USAGE_NAVIGATION = 13, -} OH_AudioStream_Usage; - -/** - * Define the audio latency mode. - * - * @since 10 - */ -typedef enum { - /** - * This is a normal audio scene. - * - * @since 10 - */ - AUDIOSTREAM_LATENCY_MODE_NORMAL = 0, - /** - * This is a low latency audio scene. - * - * @since 10 - */ - AUDIOSTREAM_LATENCY_MODE_FAST = 1 -} OH_AudioStream_LatencyMode; - -/** - * Define the audio event. - * - * @since 10 - */ -typedef enum { - /** - * The routing of the audio has changed. - * - * @since 10 - */ - AUDIOSTREAM_EVENT_ROUTING_CHANGED = 0 -} OH_AudioStream_Event; - -/** - * The audio stream states - * - * @since 10 - */ -typedef enum { - /** - * The invalid state. - * - * @since 10 - */ - AUDIOSTREAM_STATE_INVALID = -1, - /** - * Create new instance state. - * - * @since 10 - */ - AUDIOSTREAM_STATE_NEW = 0, - /** - * The prepared state. - * - * @since 10 - */ - AUDIOSTREAM_STATE_PREPARED = 1, - /** - * The stream is running. - * - * @since 10 - */ - AUDIOSTREAM_STATE_RUNNING = 2, - /** - * The stream is stopped. - * - * @since 10 - */ - AUDIOSTREAM_STATE_STOPPED = 3, - /** - * The stream is released. - * - * @since 10 - */ - AUDIOSTREAM_STATE_RELEASED = 4, - /** - * The stream is paused. - * - * @since 10 - */ - AUDIOSTREAM_STATE_PAUSED = 5, -} OH_AudioStream_State; - -/** - * Defines the audio interrupt type. - * - * @since 10 - */ -typedef enum { - /** - * Force type, system change audio state. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_FORCE = 0, - /** - * Share type, application change audio state. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_SHARE = 1 -} OH_AudioInterrupt_ForceType; - -/** - * Defines the audio interrupt hint type. - * - * @since 10 - */ -typedef enum { - /** - * None. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_NONE = 0, - /** - * Resume the stream. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_RESUME = 1, - /** - * Pause the stream. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_PAUSE = 2, - /** - * Stop the stream. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_STOP = 3, - /** - * Ducked the stream. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_DUCK = 4, - /** - * Unducked the stream. - * - * @since 10 - */ - AUDIOSTREAM_INTERRUPT_HINT_UNDUCK = 5 -} OH_AudioInterrupt_Hint; - -/** - * Defines the audio source type. - * - * @since 10 - */ -typedef enum { - /** - * Invalid type. - * - * @since 10 - */ - AUDIOSTREAM_SOURCE_TYPE_INVALID = -1, - /** - * Mic source type. - * - * @since 10 - */ - AUDIOSTREAM_SOURCE_TYPE_MIC = 0, - /** - * Voice recognition source type. - * - * @since 10 - */ - AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION = 1, - /** - * Playback capture source type. - * - * @since 10 - */ - AUDIOSTREAM_SOURCE_TYPE_PLAYBACK_CAPTURE = 2, - /** - * Voice communication source type. - * - * @since 10 - */ - AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION = 7 -} OH_AudioStream_SourceType; - -/** - * Declaring the audio stream builder. - * The instance of builder is used for creating audio stream. - * - * @since 10 - */ -typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder; - -/** - * Declaring the audio renderer stream. - * The instance of renderer stream is used for playing audio data. - * - * @since 10 - */ -typedef struct OH_AudioRendererStruct OH_AudioRenderer; - -/** - * Declaring the audio capturer stream. - * The instance of renderer stream is used for capturing audio data. - * - * @since 10 - */ -typedef struct OH_AudioCapturerStruct OH_AudioCapturer; - -/** - * Declaring the callback struct for renderer stream. - * - * @since 10 - */ -typedef struct OH_AudioRenderer_Callbacks_Struct { - /** - * This function pointer will point to the callback function that - * is used to write audio data - * - * @since 10 - */ - int32_t (*OH_AudioRenderer_OnWriteData)( - OH_AudioRenderer* renderer, - void* userData, - void* buffer, - int32_t lenth); - - /** - * This function pointer will point to the callback function that - * is used to handle audio renderer stream events. - * - * @since 10 - */ - int32_t (*OH_AudioRenderer_OnStreamEvent)( - OH_AudioRenderer* renderer, - void* userData, - OH_AudioStream_Event event); - - /** - * This function pointer will point to the callback function that - * is used to handle audio interrupt events. - * - * @since 10 - */ - int32_t (*OH_AudioRenderer_OnInterrptEvent)( - OH_AudioRenderer* renderer, - void* userData, - OH_AudioInterrupt_ForceType type, - OH_AudioInterrupt_Hint hint); - - /** - * This function pointer will point to the callback function that - * is used to handle audio error result. - * - * @since 10 - */ - int32_t (*OH_AudioRenderer_OnError)( - OH_AudioRenderer* renderer, - void* userData, - OH_AudioStream_Result error); -} OH_AudioRenderer_Callbacks; - -/** - * Declaring the callback struct for capturer stream. - * - * @since 10 - */ -typedef struct OH_AudioCapturer_Callbacks_Struct { - /** - * This function pointer will point to the callback function that - * is used to read audio data. - * - * @since 10 - */ - int32_t (*OH_AudioCapturer_OnReadData)( - OH_AudioCapturer* capturer, - void* userData, - void* buffer, - int32_t lenth); - - /** - * This function pointer will point to the callback function that - * is used to handle audio capturer stream events. - * - * @since 10 - */ - int32_t (*OH_AudioCapturer_OnStreamEvent)( - OH_AudioCapturer* capturer, - void* userData, - OH_AudioStream_Event event); - - /** - * This function pointer will point to the callback function that - * is used to handle audio interrupt events. - * - * @since 10 - */ - int32_t (*OH_AudioCapturer_OnInterrptEvent)( - OH_AudioCapturer* renderer, - void* userData, - OH_AudioInterrupt_ForceType type, - OH_AudioInterrupt_Hint hint); - - /** - * This function pointer will point to the callback function that - * is used to handle audio error result. - * - * @since 10 - */ - int32_t (*OH_AudioCapturer_OnError)( - OH_AudioCapturer* capturer, - void* userData, - OH_AudioStream_Result error); -} OH_AudioCapturer_Callbacks; -#ifdef __cplusplus -} -#endif - -#endif // ST_NATIVE_AUDIOSTREAM_BASE_H +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 10 + * @version 1.0 + */ + +/** + * @file native_audiostream_base.h + * + * @brief Declare the underlying data structure. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * @since 10 + * @version 1.0 + */ + +#ifndef ST_NATIVE_AUDIOSTREAM_BASE_H +#define ST_NATIVE_AUDIOSTREAM_BASE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Define the result of the function execution. + * + * @since 10 + */ +typedef enum { + /** + * The call was successful. + * + * @since 10 + */ + AUDIOSTREAM_SUCCESS = 0, + + /** + * This means that the function was executed with an invalid input parameter. + * + * @since 10 + */ + AUDIOSTREAM_ERROR_INVALID_PARAM = 1, + + /** + * Execution status exception. + * + * @since 10 + */ + AUDIOSTREAM_ERROR_ILLEGAL_STATE = 2, + + /** + * An system error has occurred. + * + * @since 10 + */ + AUDIOSTREAM_ERROR_SYSTEM = 3 +} OH_AudioStream_Result; + +/** + * Define the audio stream type. + * + * @since 10 + */ +typedef enum { + /** + * The type for audio stream is renderer. + * + * @since 10 + */ + AUDIOSTREAM_TYPE_RENDERER = 1, + + /** + * The type for audio stream is capturer. + * + * @since 10 + */ + AUDIOSTREAM_TYPE_CAPTURER = 2 +} OH_AudioStream_Type; + +/** + * Define the audio stream sample format. + * + * @since 10 + */ +typedef enum { + /** + * Unsigned 8 format. + * + * @since 10 + */ + AUDIOSTREAM_SAMPLE_U8 = 0, + /** + * Signed 16 bit integer, little endian. + * + * @since 10 + */ + AUDIOSTREAM_SAMPLE_S16LE = 1, + /** + * Signed 24 bit integer, little endian. + * + * @since 10 + */ + AUDIOSTREAM_SAMPLE_S24LE = 2, + /** + * Signed 32 bit integer, little endian. + * + * @since 10 + */ + AUDIOSTREAM_SAMPLE_S32LE = 3, +} OH_AudioStream_SampleFormat; + +/** + * Define the audio encoding type. + * + * @since 10 + */ +typedef enum { + /** + * PCM encoding type. + * + * @since 10 + */ + AUDIOSTREAM_ENCODING_TYPE_RAW = 0, +} OH_AudioStream_EncodingType; + +/** + * Define the audio stream usage. + * Audio stream usage is used to describe what work scenario + * the current stream is used for. + * + * @since 10 + */ +typedef enum { + /** + * Unknown usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_UNKNOWN = 0, + /** + * Music usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_MUSIC = 1, + /** + * Voice communication usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_VOICE_COMMUNICATION = 2, + /** + * Voice assistant usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_VOICE_ASSISTANT = 3, + /** + * Alarm usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_ALARM = 4, + /** + * Voice message usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_VOICE_MESSAGE = 5, + /** + * Ringtone usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_RINGTONE = 6, + /** + * Notification usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_NOTIFICATION = 7, + /** + * Accessibility usage, such as screen reader. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_ACCESSIBILITY = 8, + /** + * Movie or video usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_MOVIE = 10, + /** + * Game sound effect usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_GAME = 11, + /** + * Audiobook usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_AUDIOBOOK = 12, + /** + * Navigation usage. + * + * @since 10 + */ + AUDIOSTREAM_USAGE_NAVIGATION = 13, +} OH_AudioStream_Usage; + +/** + * Define the audio latency mode. + * + * @since 10 + */ +typedef enum { + /** + * This is a normal audio scene. + * + * @since 10 + */ + AUDIOSTREAM_LATENCY_MODE_NORMAL = 0, + /** + * This is a low latency audio scene. + * + * @since 10 + */ + AUDIOSTREAM_LATENCY_MODE_FAST = 1 +} OH_AudioStream_LatencyMode; + +/** + * Define the audio event. + * + * @since 10 + */ +typedef enum { + /** + * The routing of the audio has changed. + * + * @since 10 + */ + AUDIOSTREAM_EVENT_ROUTING_CHANGED = 0 +} OH_AudioStream_Event; + +/** + * The audio stream states + * + * @since 10 + */ +typedef enum { + /** + * The invalid state. + * + * @since 10 + */ + AUDIOSTREAM_STATE_INVALID = -1, + /** + * Create new instance state. + * + * @since 10 + */ + AUDIOSTREAM_STATE_NEW = 0, + /** + * The prepared state. + * + * @since 10 + */ + AUDIOSTREAM_STATE_PREPARED = 1, + /** + * The stream is running. + * + * @since 10 + */ + AUDIOSTREAM_STATE_RUNNING = 2, + /** + * The stream is stopped. + * + * @since 10 + */ + AUDIOSTREAM_STATE_STOPPED = 3, + /** + * The stream is released. + * + * @since 10 + */ + AUDIOSTREAM_STATE_RELEASED = 4, + /** + * The stream is paused. + * + * @since 10 + */ + AUDIOSTREAM_STATE_PAUSED = 5, +} OH_AudioStream_State; + +/** + * Defines the audio interrupt type. + * + * @since 10 + */ +typedef enum { + /** + * Force type, system change audio state. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_FORCE = 0, + /** + * Share type, application change audio state. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_SHARE = 1 +} OH_AudioInterrupt_ForceType; + +/** + * Defines the audio interrupt hint type. + * + * @since 10 + */ +typedef enum { + /** + * None. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_NONE = 0, + /** + * Resume the stream. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_RESUME = 1, + /** + * Pause the stream. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_PAUSE = 2, + /** + * Stop the stream. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_STOP = 3, + /** + * Ducked the stream. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_DUCK = 4, + /** + * Unducked the stream. + * + * @since 10 + */ + AUDIOSTREAM_INTERRUPT_HINT_UNDUCK = 5 +} OH_AudioInterrupt_Hint; + +/** + * Defines the audio source type. + * + * @since 10 + */ +typedef enum { + /** + * Invalid type. + * + * @since 10 + */ + AUDIOSTREAM_SOURCE_TYPE_INVALID = -1, + /** + * Mic source type. + * + * @since 10 + */ + AUDIOSTREAM_SOURCE_TYPE_MIC = 0, + /** + * Voice recognition source type. + * + * @since 10 + */ + AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION = 1, + /** + * Playback capture source type. + * + * @since 10 + */ + AUDIOSTREAM_SOURCE_TYPE_PLAYBACK_CAPTURE = 2, + /** + * Voice communication source type. + * + * @since 10 + */ + AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION = 7 +} OH_AudioStream_SourceType; + +/** + * Declaring the audio stream builder. + * The instance of builder is used for creating audio stream. + * + * @since 10 + */ +typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder; + +/** + * Declaring the audio renderer stream. + * The instance of renderer stream is used for playing audio data. + * + * @since 10 + */ +typedef struct OH_AudioRendererStruct OH_AudioRenderer; + +/** + * Declaring the audio capturer stream. + * The instance of renderer stream is used for capturing audio data. + * + * @since 10 + */ +typedef struct OH_AudioCapturerStruct OH_AudioCapturer; + +/** + * Declaring the callback struct for renderer stream. + * + * @since 10 + */ +typedef struct OH_AudioRenderer_Callbacks_Struct { + /** + * This function pointer will point to the callback function that + * is used to write audio data + * + * @since 10 + */ + int32_t (*OH_AudioRenderer_OnWriteData)( + OH_AudioRenderer* renderer, + void* userData, + void* buffer, + int32_t lenth); + + /** + * This function pointer will point to the callback function that + * is used to handle audio renderer stream events. + * + * @since 10 + */ + int32_t (*OH_AudioRenderer_OnStreamEvent)( + OH_AudioRenderer* renderer, + void* userData, + OH_AudioStream_Event event); + + /** + * This function pointer will point to the callback function that + * is used to handle audio interrupt events. + * + * @since 10 + */ + int32_t (*OH_AudioRenderer_OnInterrptEvent)( + OH_AudioRenderer* renderer, + void* userData, + OH_AudioInterrupt_ForceType type, + OH_AudioInterrupt_Hint hint); + + /** + * This function pointer will point to the callback function that + * is used to handle audio error result. + * + * @since 10 + */ + int32_t (*OH_AudioRenderer_OnError)( + OH_AudioRenderer* renderer, + void* userData, + OH_AudioStream_Result error); +} OH_AudioRenderer_Callbacks; + +/** + * Declaring the callback struct for capturer stream. + * + * @since 10 + */ +typedef struct OH_AudioCapturer_Callbacks_Struct { + /** + * This function pointer will point to the callback function that + * is used to read audio data. + * + * @since 10 + */ + int32_t (*OH_AudioCapturer_OnReadData)( + OH_AudioCapturer* capturer, + void* userData, + void* buffer, + int32_t lenth); + + /** + * This function pointer will point to the callback function that + * is used to handle audio capturer stream events. + * + * @since 10 + */ + int32_t (*OH_AudioCapturer_OnStreamEvent)( + OH_AudioCapturer* capturer, + void* userData, + OH_AudioStream_Event event); + + /** + * This function pointer will point to the callback function that + * is used to handle audio interrupt events. + * + * @since 10 + */ + int32_t (*OH_AudioCapturer_OnInterrptEvent)( + OH_AudioCapturer* renderer, + void* userData, + OH_AudioInterrupt_ForceType type, + OH_AudioInterrupt_Hint hint); + + /** + * This function pointer will point to the callback function that + * is used to handle audio error result. + * + * @since 10 + */ + int32_t (*OH_AudioCapturer_OnError)( + OH_AudioCapturer* capturer, + void* userData, + OH_AudioStream_Result error); +} OH_AudioCapturer_Callbacks; +#ifdef __cplusplus +} +#endif + +#endif // ST_NATIVE_AUDIOSTREAM_BASE_H diff --git a/multimedia/audio_framework/common/native_audiostreambuilder.h b/multimedia/audio_framework/common/native_audiostreambuilder.h index 99d94288e42ee0dc85f0b48b05ff81314f47b3e5..f79d5cc46590b7391b069f84888e6689b52407e4 100644 --- a/multimedia/audio_framework/common/native_audiostreambuilder.h +++ b/multimedia/audio_framework/common/native_audiostreambuilder.h @@ -1,206 +1,206 @@ -/* - * 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 OHAudio - * @{ - * - * @brief Provide the definition of the C interface for the audio module. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * - * @since 10 - * @version 1.0 - */ - -/** - * @file native_audiostreambuilder.h - * - * @brief Declare audio stream builder related interfaces. - * - * @syscap SystemCapability.Multimedia.Audio.Core - * @since 10 - * @version 1.0 - */ - -#ifndef NATIVE_AUDIOSTREAM_BUILDER_H -#define NATIVE_AUDIOSTREAM_BUILDER_H - -#include "native_audiostream_base.h" -#include "native_audiorenderer.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Create a stremBuilder can be used to open a renderer or capturer client. - * - * OH_AudioStreamBuilder_Destroy() must be called when you are done using the builder. - * - * @since 10 - * - * @param builder The builder reference to the created result. - * @param type The stream type to be created. {@link #AUDIOSTREAM_TYPE_RENDERER} or {@link #AUDIOSTREAM_TYPE_CAPTURER} - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder** builder, OH_AudioStream_Type type); - -/** - * Destroy a streamBulder. - * - * This function must be called when you are done using the builder. - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder* builder); - -/* - * Set the channel count of the capturer client - * - * @since 10 - * - * @param capturer Reference created by OH_AudioStreamBuilder - * @param channelCount Pointer to a variable that will be set for the channel count. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder* builder, int32_t rate); - -/* - * Set the channel count of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param channelCount The channel count. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder* builder, int32_t channelCount); - -/* - * Set the sample format of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param format Sample data format. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder* builder, - OH_AudioStream_SampleFormat format); - -/* - * Set the encoding type of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param encodingType Encoding type for the stream client, {@link #AUDIOSTREAM_ENCODING_PCM} - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder* builder, - OH_AudioStream_EncodingType encodingType); - -/* - * Set the latency mode of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param latencyMode Latency mode for the stream client. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder* builder, - OH_AudioStream_LatencyMode latencyMode); - -/* - * Set the renderer information of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param usage Set the stream usage for the renderer client. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder* builder, - OH_AudioStream_Usage usage); - -/* - * Set the capturer information of the stream client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param sourceType Set the source type for the capturer client. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder* builder, - OH_AudioStream_SourceType sourceType); - -/* - * Set the callbacks for the renderer client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param callbacks Callbacks to the functions that will process renderer stream. - * @param userData Pointer to an application data structure that will be passed to the callback functions. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder* builder, - OH_AudioRenderer_Callbacks callbacks, void* userData); - -/* - * Set the callbacks for the capturer client - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param callbacks Callbacks to the functions that will process capturer stream. - * @param userData Pointer to an application data structure that will be passed to the callback functions. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder* builder, - OH_AudioCapturer_Callbacks callbacks, void* userData); - -/* - * Create the audio renderer client. - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param audioRenderer Pointer to a viriable to receive the stream client. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder* builder, - OH_AudioRenderer** audioRenderer); -/* - * Create the audio capturer client. - * - * @since 10 - * - * @param builder Reference provided by OH_AudioStreamBuilder_Create() - * @param audioCapturer Pointer to a viriable to receive the stream client. - * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. - */ -OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder, - OH_AudioCapturer** audioCapturer); -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_AUDIOSTREAM_BUILDER_H +/* + * 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 OHAudio + * @{ + * + * @brief Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 10 + * @version 1.0 + */ + +/** + * @file native_audiostreambuilder.h + * + * @brief Declare audio stream builder related interfaces. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * @since 10 + * @version 1.0 + */ + +#ifndef NATIVE_AUDIOSTREAM_BUILDER_H +#define NATIVE_AUDIOSTREAM_BUILDER_H + +#include "native_audiostream_base.h" +#include "native_audiorenderer.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Create a stremBuilder can be used to open a renderer or capturer client. + * + * OH_AudioStreamBuilder_Destroy() must be called when you are done using the builder. + * + * @since 10 + * + * @param builder The builder reference to the created result. + * @param type The stream type to be created. {@link #AUDIOSTREAM_TYPE_RENDERER} or {@link #AUDIOSTREAM_TYPE_CAPTURER} + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_Create(OH_AudioStreamBuilder** builder, OH_AudioStream_Type type); + +/** + * Destroy a streamBulder. + * + * This function must be called when you are done using the builder. + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_Destroy(OH_AudioStreamBuilder* builder); + +/* + * Set the channel count of the capturer client + * + * @since 10 + * + * @param capturer Reference created by OH_AudioStreamBuilder + * @param channelCount Pointer to a variable that will be set for the channel count. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetSamplingRate(OH_AudioStreamBuilder* builder, int32_t rate); + +/* + * Set the channel count of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param channelCount The channel count. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelCount(OH_AudioStreamBuilder* builder, int32_t channelCount); + +/* + * Set the sample format of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param format Sample data format. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetSampleFormat(OH_AudioStreamBuilder* builder, + OH_AudioStream_SampleFormat format); + +/* + * Set the encoding type of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param encodingType Encoding type for the stream client, {@link #AUDIOSTREAM_ENCODING_PCM} + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetEncodingType(OH_AudioStreamBuilder* builder, + OH_AudioStream_EncodingType encodingType); + +/* + * Set the latency mode of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param latencyMode Latency mode for the stream client. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetLatencyMode(OH_AudioStreamBuilder* builder, + OH_AudioStream_LatencyMode latencyMode); + +/* + * Set the renderer information of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param usage Set the stream usage for the renderer client. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInfo(OH_AudioStreamBuilder* builder, + OH_AudioStream_Usage usage); + +/* + * Set the capturer information of the stream client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param sourceType Set the source type for the capturer client. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInfo(OH_AudioStreamBuilder* builder, + OH_AudioStream_SourceType sourceType); + +/* + * Set the callbacks for the renderer client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param callbacks Callbacks to the functions that will process renderer stream. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_Callbacks callbacks, void* userData); + +/* + * Set the callbacks for the capturer client + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param callbacks Callbacks to the functions that will process capturer stream. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_Callbacks callbacks, void* userData); + +/* + * Create the audio renderer client. + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param audioRenderer Pointer to a viriable to receive the stream client. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuilder* builder, + OH_AudioRenderer** audioRenderer); +/* + * Create the audio capturer client. + * + * @since 10 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param audioCapturer Pointer to a viriable to receive the stream client. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder, + OH_AudioCapturer** audioCapturer); +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AUDIOSTREAM_BUILDER_H diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 1062c40a8802a22838615f094a4a8cacce7e1006..ee1a488652dd9e8b3247732afe010c0d1aed8ff7 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -1,41 +1,41 @@ -[ - { "name": "OH_AudioStreamBuilder_Create" }, - { "name": "OH_AudioStreamBuilder_Destroy" }, - { "name": "OH_AudioStreamBuilder_SetSamplingRate" }, - { "name": "OH_AudioStreamBuilder_SetChannelCount" }, - { "name": "OH_AudioStreamBuilder_SetSampleFormat" }, - { "name": "OH_AudioStreamBuilder_SetEncodingType" }, - { "name": "OH_AudioStreamBuilder_SetLatencyMode" }, - { "name": "OH_AudioStreamBuilder_SetRendererInfo" }, - { "name": "OH_AudioStreamBuilder_SetCapturerInfo" }, - { "name": "OH_AudioStreamBuilder_SetRendererCallback" }, - { "name": "OH_AudioStreamBuilder_SetCapturerCallback" }, - { "name": "OH_AudioStreamBuilder_GenerateRenderer" }, - { "name": "OH_AudioStreamBuilder_GenerateCapturer" }, - { "name": "OH_AudioRenderer_Release" }, - { "name": "OH_AudioRenderer_Start" }, - { "name": "OH_AudioRenderer_Pause" }, - { "name": "OH_AudioRenderer_Stop" }, - { "name": "OH_AudioRenderer_Flush" }, - { "name": "OH_AudioRenderer_GetCurrentState" }, - { "name": "OH_AudioRenderer_GetSamplingRate" }, - { "name": "OH_AudioRenderer_GetStreamId" }, - { "name": "OH_AudioRenderer_GetChannelCount" }, - { "name": "OH_AudioRenderer_GetSampleFormat" }, - { "name": "OH_AudioRenderer_GetLatencyMode" }, - { "name": "OH_AudioRenderer_GetRendererInfo" }, - { "name": "OH_AudioRenderer_GetEncodingType" }, - { "name": "OH_AudioCapturer_Release" }, - { "name": "OH_AudioCapturer_Start" }, - { "name": "OH_AudioCapturer_Pause" }, - { "name": "OH_AudioCapturer_Stop" }, - { "name": "OH_AudioCapturer_Flush" }, - { "name": "OH_AudioCapturer_GetCurrentState" }, - { "name": "OH_AudioCapturer_GetLatencyMode" }, - { "name": "OH_AudioCapturer_GetStreamId" }, - { "name": "OH_AudioCapturer_GetSamplingRate" }, - { "name": "OH_AudioCapturer_GetChannelCount" }, - { "name": "OH_AudioCapturer_GetSampleFormat" }, - { "name": "OH_AudioCapturer_GetEncodingType" }, - { "name": "OH_AudioCapturer_GetCapturerInfo" } +[ + { "name": "OH_AudioStreamBuilder_Create" }, + { "name": "OH_AudioStreamBuilder_Destroy" }, + { "name": "OH_AudioStreamBuilder_SetSamplingRate" }, + { "name": "OH_AudioStreamBuilder_SetChannelCount" }, + { "name": "OH_AudioStreamBuilder_SetSampleFormat" }, + { "name": "OH_AudioStreamBuilder_SetEncodingType" }, + { "name": "OH_AudioStreamBuilder_SetLatencyMode" }, + { "name": "OH_AudioStreamBuilder_SetRendererInfo" }, + { "name": "OH_AudioStreamBuilder_SetCapturerInfo" }, + { "name": "OH_AudioStreamBuilder_SetRendererCallback" }, + { "name": "OH_AudioStreamBuilder_SetCapturerCallback" }, + { "name": "OH_AudioStreamBuilder_GenerateRenderer" }, + { "name": "OH_AudioStreamBuilder_GenerateCapturer" }, + { "name": "OH_AudioRenderer_Release" }, + { "name": "OH_AudioRenderer_Start" }, + { "name": "OH_AudioRenderer_Pause" }, + { "name": "OH_AudioRenderer_Stop" }, + { "name": "OH_AudioRenderer_Flush" }, + { "name": "OH_AudioRenderer_GetCurrentState" }, + { "name": "OH_AudioRenderer_GetSamplingRate" }, + { "name": "OH_AudioRenderer_GetStreamId" }, + { "name": "OH_AudioRenderer_GetChannelCount" }, + { "name": "OH_AudioRenderer_GetSampleFormat" }, + { "name": "OH_AudioRenderer_GetLatencyMode" }, + { "name": "OH_AudioRenderer_GetRendererInfo" }, + { "name": "OH_AudioRenderer_GetEncodingType" }, + { "name": "OH_AudioCapturer_Release" }, + { "name": "OH_AudioCapturer_Start" }, + { "name": "OH_AudioCapturer_Pause" }, + { "name": "OH_AudioCapturer_Stop" }, + { "name": "OH_AudioCapturer_Flush" }, + { "name": "OH_AudioCapturer_GetCurrentState" }, + { "name": "OH_AudioCapturer_GetLatencyMode" }, + { "name": "OH_AudioCapturer_GetStreamId" }, + { "name": "OH_AudioCapturer_GetSamplingRate" }, + { "name": "OH_AudioCapturer_GetChannelCount" }, + { "name": "OH_AudioCapturer_GetSampleFormat" }, + { "name": "OH_AudioCapturer_GetEncodingType" }, + { "name": "OH_AudioCapturer_GetCapturerInfo" } ] \ No newline at end of file diff --git a/multimedia/av_codec/audio_decoder/BUILD.gn b/multimedia/av_codec/audio_decoder/BUILD.gn index bee0a5e69b2cb0ca70aa31ba144c76a0d5914661..dcadef3b06742339ab7490c48dfa97f1e7125879 100644 --- a/multimedia/av_codec/audio_decoder/BUILD.gn +++ b/multimedia/av_codec/audio_decoder/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_adec_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = - [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_audiodecoder.h" ] -} - -ohos_ndk_library("libnative_media_adec") { - ndk_description_file = "./libnative_media_adec.ndk.json" - min_compact_version = "1" - output_name = "native_media_adec" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.AudioDecoder" - system_capability_headers = - [ "multimedia/player_framework/native_avcodec_audiodecoder.h" ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_adec_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = + [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_audiodecoder.h" ] +} + +ohos_ndk_library("libnative_media_adec") { + ndk_description_file = "./libnative_media_adec.ndk.json" + min_compact_version = "1" + output_name = "native_media_adec" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.AudioDecoder" + system_capability_headers = + [ "multimedia/player_framework/native_avcodec_audiodecoder.h" ] +} diff --git a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json index 1b4472c0517b397be1e8af10c67488e46755a04e..eb040ab1a5ccf1565deecf375dfec37b78ec2003 100644 --- a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json +++ b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json @@ -1,17 +1,17 @@ -[ - { "name": "OH_AudioDecoder_CreateByMime" }, - { "name": "OH_AudioDecoder_CreateByName" }, - { "name": "OH_AudioDecoder_Destroy" }, - { "name": "OH_AudioDecoder_SetCallback" }, - { "name": "OH_AudioDecoder_Configure" }, - { "name": "OH_AudioDecoder_Prepare" }, - { "name": "OH_AudioDecoder_Start" }, - { "name": "OH_AudioDecoder_Stop" }, - { "name": "OH_AudioDecoder_Flush" }, - { "name": "OH_AudioDecoder_Reset" }, - { "name": "OH_AudioDecoder_GetOutputDescription" }, - { "name": "OH_AudioDecoder_SetParameter" }, - { "name": "OH_AudioDecoder_PushInputData" }, - { "name": "OH_AudioDecoder_FreeOutputData" }, - { "name": "OH_AudioDecoder_IsValid" } -] +[ + { "name": "OH_AudioDecoder_CreateByMime" }, + { "name": "OH_AudioDecoder_CreateByName" }, + { "name": "OH_AudioDecoder_Destroy" }, + { "name": "OH_AudioDecoder_SetCallback" }, + { "name": "OH_AudioDecoder_Configure" }, + { "name": "OH_AudioDecoder_Prepare" }, + { "name": "OH_AudioDecoder_Start" }, + { "name": "OH_AudioDecoder_Stop" }, + { "name": "OH_AudioDecoder_Flush" }, + { "name": "OH_AudioDecoder_Reset" }, + { "name": "OH_AudioDecoder_GetOutputDescription" }, + { "name": "OH_AudioDecoder_SetParameter" }, + { "name": "OH_AudioDecoder_PushInputData" }, + { "name": "OH_AudioDecoder_FreeOutputData" }, + { "name": "OH_AudioDecoder_IsValid" } +] diff --git a/multimedia/av_codec/audio_encoder/BUILD.gn b/multimedia/av_codec/audio_encoder/BUILD.gn index 8ecb69c8a34d3149a36ab031d1f51a428b786c66..55e9c90e1e291244935c8844d51ae31137d92b01 100644 --- a/multimedia/av_codec/audio_encoder/BUILD.gn +++ b/multimedia/av_codec/audio_encoder/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_aenc_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = - [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_audioencoder.h" ] -} - -ohos_ndk_library("libnative_media_aenc") { - ndk_description_file = "./libnative_media_aenc.ndk.json" - min_compact_version = "1" - output_name = "native_media_aenc" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.AudioEncoder" - system_capability_headers = - [ "multimedia/player_framework/native_avcodec_audioencoder.h" ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_aenc_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = + [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_audioencoder.h" ] +} + +ohos_ndk_library("libnative_media_aenc") { + ndk_description_file = "./libnative_media_aenc.ndk.json" + min_compact_version = "1" + output_name = "native_media_aenc" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.AudioEncoder" + system_capability_headers = + [ "multimedia/player_framework/native_avcodec_audioencoder.h" ] +} diff --git a/multimedia/av_codec/audio_encoder/libnative_media_aenc.ndk.json b/multimedia/av_codec/audio_encoder/libnative_media_aenc.ndk.json index 830a103a7e7ac939b2a96bba8d0215a6038c0f0a..25faac51a94f427ff64d8eafac47d9004988b668 100644 --- a/multimedia/av_codec/audio_encoder/libnative_media_aenc.ndk.json +++ b/multimedia/av_codec/audio_encoder/libnative_media_aenc.ndk.json @@ -1,17 +1,17 @@ -[ - { "name": "OH_AudioEncoder_CreateByMime" }, - { "name": "OH_AudioEncoder_CreateByName" }, - { "name": "OH_AudioEncoder_Destroy" }, - { "name": "OH_AudioEncoder_SetCallback" }, - { "name": "OH_AudioEncoder_Configure" }, - { "name": "OH_AudioEncoder_Prepare" }, - { "name": "OH_AudioEncoder_Start" }, - { "name": "OH_AudioEncoder_Stop" }, - { "name": "OH_AudioEncoder_Flush" }, - { "name": "OH_AudioEncoder_Reset" }, - { "name": "OH_AudioEncoder_GetOutputDescription" }, - { "name": "OH_AudioEncoder_SetParameter" }, - { "name": "OH_AudioEncoder_PushInputData" }, - { "name": "OH_AudioEncoder_FreeOutputData" }, - { "name": "OH_AudioEncoder_IsValid" } -] +[ + { "name": "OH_AudioEncoder_CreateByMime" }, + { "name": "OH_AudioEncoder_CreateByName" }, + { "name": "OH_AudioEncoder_Destroy" }, + { "name": "OH_AudioEncoder_SetCallback" }, + { "name": "OH_AudioEncoder_Configure" }, + { "name": "OH_AudioEncoder_Prepare" }, + { "name": "OH_AudioEncoder_Start" }, + { "name": "OH_AudioEncoder_Stop" }, + { "name": "OH_AudioEncoder_Flush" }, + { "name": "OH_AudioEncoder_Reset" }, + { "name": "OH_AudioEncoder_GetOutputDescription" }, + { "name": "OH_AudioEncoder_SetParameter" }, + { "name": "OH_AudioEncoder_PushInputData" }, + { "name": "OH_AudioEncoder_FreeOutputData" }, + { "name": "OH_AudioEncoder_IsValid" } +] diff --git a/multimedia/av_codec/avcodec_audio_channel_layout.h b/multimedia/av_codec/avcodec_audio_channel_layout.h index 364bd6a12fed0f27b0736e63978809fc5c645ddd..3f1ff8ea77edcf9cf6d545407c949adc7a359378 100644 --- a/multimedia/av_codec/avcodec_audio_channel_layout.h +++ b/multimedia/av_codec/avcodec_audio_channel_layout.h @@ -1,161 +1,161 @@ -/* - * 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. - */ - -#ifndef AVCODEC_AUDIO_CHANNEL_LAYOUT_H -#define AVCODEC_AUDIO_CHANNEL_LAYOUT_H -#include -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Audio Channel Set - * A 64-bit integer with bits set for each channel. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -enum AudioChannelSet : uint64_t { - FRONT_LEFT = 1ULL << 0U, - FRONT_RIGHT = 1ULL << 1U, - FRONT_CENTER = 1ULL << 2U, - LOW_FREQUENCY = 1ULL << 3U, - BACK_LEFT = 1ULL << 4U, - BACK_RIGHT = 1ULL << 5U, - FRONT_LEFT_OF_CENTER = 1ULL << 6U, - FRONT_RIGHT_OF_CENTER = 1ULL << 7U, - BACK_CENTER = 1ULL << 8U, - SIDE_LEFT = 1ULL << 9U, - SIDE_RIGHT = 1ULL << 10U, - TOP_CENTER = 1ULL << 11U, - TOP_FRONT_LEFT = 1ULL << 12U, - TOP_FRONT_CENTER = 1ULL << 13U, - TOP_FRONT_RIGHT = 1ULL << 14U, - TOP_BACK_LEFT = 1ULL << 15U, - TOP_BACK_CENTER = 1ULL << 16U, - TOP_BACK_RIGHT = 1ULL << 17U, - STEREO_LEFT = 1ULL << 29U, - STEREO_RIGHT = 1ULL << 30U, - WIDE_LEFT = 1ULL << 31U, - WIDE_RIGHT = 1ULL << 32U, - SURROUND_DIRECT_LEFT = 1ULL << 33U, - SURROUND_DIRECT_RIGHT = 1ULL << 34U, - LOW_FREQUENCY_2 = 1ULL << 35U, - TOP_SIDE_LEFT = 1ULL << 36U, - TOP_SIDE_RIGHT = 1ULL << 37U, - BOTTOM_FRONT_CENTER = 1ULL << 38U, - BOTTOM_FRONT_LEFT = 1ULL << 39U, - BOTTOM_FRONT_RIGHT = 1ULL << 40U, - - // Ambisonics ACN formats - // 0th and first order ambisonics ACN - AMBISONICS_ACN0 = 1ULL << 41U, /** 0th ambisonics channel number 0. */ - AMBISONICS_ACN1 = 1ULL << 42U, /** first-order ambisonics channel number 1. */ - AMBISONICS_ACN2 = 1ULL << 43U, /** first-order ambisonics channel number 2. */ - AMBISONICS_ACN3 = 1ULL << 44U, /** first-order ambisonics channel number 3. */ - AMBISONICS_W = AMBISONICS_ACN0, /** same as 0th ambisonics channel number 0. */ - AMBISONICS_Y = AMBISONICS_ACN1, /** same as first-order ambisonics channel number 1. */ - AMBISONICS_Z = AMBISONICS_ACN2, /** same as first-order ambisonics channel number 2. */ - AMBISONICS_X = AMBISONICS_ACN3, /** same as first-order ambisonics channel number 3. */ - - // second order ambisonics ACN - AMBISONICS_ACN4 = 1ULL << 45U, /** second-order ambisonics channel number 4. */ - AMBISONICS_ACN5 = 1ULL << 46U, /** second-order ambisonics channel number 5. */ - AMBISONICS_ACN6 = 1ULL << 47U, /** second-order ambisonics channel number 6. */ - AMBISONICS_ACN7 = 1ULL << 48U, /** second-order ambisonics channel number 7. */ - AMBISONICS_ACN8 = 1ULL << 49U, /** second-order ambisonics channel number 8. */ - - // third order ambisonics ACN - AMBISONICS_ACN9 = 1ULL << 50U, /** third-order ambisonics channel number 9. */ - AMBISONICS_ACN10 = 1ULL << 51U, /** third-order ambisonics channel number 10. */ - AMBISONICS_ACN11 = 1ULL << 52U, /** third-order ambisonics channel number 11. */ - AMBISONICS_ACN12 = 1ULL << 53U, /** third-order ambisonics channel number 12. */ - AMBISONICS_ACN13 = 1ULL << 54U, /** third-order ambisonics channel number 13. */ - AMBISONICS_ACN14 = 1ULL << 55U, /** third-order ambisonics channel number 14. */ - AMBISONICS_ACN15 = 1ULL << 56U, /** third-order ambisonics channel number 15. */ -}; - -/** - * @brief Audio AudioChannel Layout - * Indicates that the channel order in which the user requests decoder output - * is the native codec channel order. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -enum AudioChannelLayout : uint64_t { - UNKNOWN_CHANNEL_LAYOUT = 0, - MONO = (AudioChannelSet::FRONT_CENTER), - STEREO = (AudioChannelSet::FRONT_LEFT | AudioChannelSet::FRONT_RIGHT), - CH_2POINT1 = (STEREO | AudioChannelSet::LOW_FREQUENCY), - CH_2_1 = (STEREO | AudioChannelSet::BACK_CENTER), - SURROUND = (STEREO | AudioChannelSet::FRONT_CENTER), - CH_3POINT1 = (SURROUND | AudioChannelSet::LOW_FREQUENCY), - CH_4POINT0 = (SURROUND | AudioChannelSet::BACK_CENTER), - CH_4POINT1 = (CH_4POINT0 | AudioChannelSet::LOW_FREQUENCY), - CH_2_2 = (STEREO | AudioChannelSet::SIDE_LEFT | AudioChannelSet::SIDE_RIGHT), - QUAD = (STEREO | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), - CH_5POINT0 = (SURROUND | AudioChannelSet::SIDE_LEFT | AudioChannelSet::SIDE_RIGHT), - CH_5POINT1 = (CH_5POINT0 | AudioChannelSet::LOW_FREQUENCY), - CH_5POINT0_BACK = (SURROUND | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), - CH_5POINT1_BACK = (CH_5POINT0_BACK | AudioChannelSet::LOW_FREQUENCY), - CH_6POINT0 = (CH_5POINT0 | AudioChannelSet::BACK_CENTER), - CH_6POINT0_FRONT = (CH_2_2 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), - HEXAGONAL = (CH_5POINT0_BACK | AudioChannelSet::BACK_CENTER), - CH_6POINT1 = (CH_5POINT1 | AudioChannelSet::BACK_CENTER), - CH_6POINT1_BACK = (CH_5POINT1_BACK | AudioChannelSet::BACK_CENTER), - CH_6POINT1_FRONT = (CH_6POINT0_FRONT | AudioChannelSet::LOW_FREQUENCY), - CH_7POINT0 = (CH_5POINT0 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), - CH_7POINT0_FRONT = (CH_5POINT0 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), - CH_7POINT1 = (CH_5POINT1 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), - CH_7POINT1_WIDE = (CH_5POINT1 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), - CH_7POINT1_WIDE_BACK = - (CH_5POINT1_BACK | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), - CH_3POINT1POINT2 = (CH_3POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT), - CH_5POINT1POINT2 = (CH_5POINT1 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), - CH_5POINT1POINT4 = (CH_5POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | - AudioChannelSet::TOP_BACK_LEFT | AudioChannelSet::TOP_BACK_RIGHT), - CH_7POINT1POINT2 = (CH_7POINT1 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), - CH_7POINT1POINT4 = (CH_7POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | - AudioChannelSet::TOP_BACK_LEFT | AudioChannelSet::TOP_BACK_RIGHT), - CH_9POINT1POINT4 = (CH_7POINT1POINT4 | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT), - CH_9POINT1POINT6 = (CH_9POINT1POINT4 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), - CH_10POINT2 = (AudioChannelSet::FRONT_LEFT | AudioChannelSet::FRONT_RIGHT | AudioChannelSet::FRONT_CENTER | - AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | AudioChannelSet::BACK_LEFT | - AudioChannelSet::BACK_RIGHT | AudioChannelSet::BACK_CENTER | AudioChannelSet::SIDE_LEFT | - AudioChannelSet::SIDE_RIGHT | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT), - CH_22POINT2 = (CH_7POINT1POINT4 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER | - AudioChannelSet::BACK_CENTER | AudioChannelSet::TOP_CENTER | AudioChannelSet::TOP_FRONT_CENTER | - AudioChannelSet::TOP_BACK_CENTER | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT | - AudioChannelSet::BOTTOM_FRONT_LEFT | AudioChannelSet::BOTTOM_FRONT_RIGHT | - AudioChannelSet::BOTTOM_FRONT_CENTER | AudioChannelSet::LOW_FREQUENCY_2), - OCTAGONAL = (CH_5POINT0 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_CENTER | AudioChannelSet::BACK_RIGHT), - HEXADECAGONAL = - (OCTAGONAL | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT | AudioChannelSet::TOP_BACK_LEFT | - AudioChannelSet::TOP_BACK_RIGHT | AudioChannelSet::TOP_BACK_CENTER | AudioChannelSet::TOP_FRONT_CENTER | - AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT), - STEREO_DOWNMIX = (AudioChannelSet::STEREO_LEFT | AudioChannelSet::STEREO_RIGHT), - - HOA_FIRST = AudioChannelSet::AMBISONICS_ACN0 | AudioChannelSet::AMBISONICS_ACN1 | AudioChannelSet::AMBISONICS_ACN2 | - AudioChannelSet::AMBISONICS_ACN3, - HOA_SECOND = HOA_FIRST | AudioChannelSet::AMBISONICS_ACN4 | AudioChannelSet::AMBISONICS_ACN5 | - AudioChannelSet::AMBISONICS_ACN6 | AudioChannelSet::AMBISONICS_ACN7 | AudioChannelSet::AMBISONICS_ACN8, - HOA_THIRD = HOA_SECOND | AudioChannelSet::AMBISONICS_ACN9 | AudioChannelSet::AMBISONICS_ACN10 | - AudioChannelSet::AMBISONICS_ACN11 | AudioChannelSet::AMBISONICS_ACN12 | - AudioChannelSet::AMBISONICS_ACN13 | AudioChannelSet::AMBISONICS_ACN14 | - AudioChannelSet::AMBISONICS_ACN15, -}; -#ifdef __cplusplus -} -#endif +/* + * 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. + */ + +#ifndef AVCODEC_AUDIO_CHANNEL_LAYOUT_H +#define AVCODEC_AUDIO_CHANNEL_LAYOUT_H +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Audio Channel Set + * A 64-bit integer with bits set for each channel. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +enum AudioChannelSet : uint64_t { + FRONT_LEFT = 1ULL << 0U, + FRONT_RIGHT = 1ULL << 1U, + FRONT_CENTER = 1ULL << 2U, + LOW_FREQUENCY = 1ULL << 3U, + BACK_LEFT = 1ULL << 4U, + BACK_RIGHT = 1ULL << 5U, + FRONT_LEFT_OF_CENTER = 1ULL << 6U, + FRONT_RIGHT_OF_CENTER = 1ULL << 7U, + BACK_CENTER = 1ULL << 8U, + SIDE_LEFT = 1ULL << 9U, + SIDE_RIGHT = 1ULL << 10U, + TOP_CENTER = 1ULL << 11U, + TOP_FRONT_LEFT = 1ULL << 12U, + TOP_FRONT_CENTER = 1ULL << 13U, + TOP_FRONT_RIGHT = 1ULL << 14U, + TOP_BACK_LEFT = 1ULL << 15U, + TOP_BACK_CENTER = 1ULL << 16U, + TOP_BACK_RIGHT = 1ULL << 17U, + STEREO_LEFT = 1ULL << 29U, + STEREO_RIGHT = 1ULL << 30U, + WIDE_LEFT = 1ULL << 31U, + WIDE_RIGHT = 1ULL << 32U, + SURROUND_DIRECT_LEFT = 1ULL << 33U, + SURROUND_DIRECT_RIGHT = 1ULL << 34U, + LOW_FREQUENCY_2 = 1ULL << 35U, + TOP_SIDE_LEFT = 1ULL << 36U, + TOP_SIDE_RIGHT = 1ULL << 37U, + BOTTOM_FRONT_CENTER = 1ULL << 38U, + BOTTOM_FRONT_LEFT = 1ULL << 39U, + BOTTOM_FRONT_RIGHT = 1ULL << 40U, + + // Ambisonics ACN formats + // 0th and first order ambisonics ACN + AMBISONICS_ACN0 = 1ULL << 41U, /** 0th ambisonics channel number 0. */ + AMBISONICS_ACN1 = 1ULL << 42U, /** first-order ambisonics channel number 1. */ + AMBISONICS_ACN2 = 1ULL << 43U, /** first-order ambisonics channel number 2. */ + AMBISONICS_ACN3 = 1ULL << 44U, /** first-order ambisonics channel number 3. */ + AMBISONICS_W = AMBISONICS_ACN0, /** same as 0th ambisonics channel number 0. */ + AMBISONICS_Y = AMBISONICS_ACN1, /** same as first-order ambisonics channel number 1. */ + AMBISONICS_Z = AMBISONICS_ACN2, /** same as first-order ambisonics channel number 2. */ + AMBISONICS_X = AMBISONICS_ACN3, /** same as first-order ambisonics channel number 3. */ + + // second order ambisonics ACN + AMBISONICS_ACN4 = 1ULL << 45U, /** second-order ambisonics channel number 4. */ + AMBISONICS_ACN5 = 1ULL << 46U, /** second-order ambisonics channel number 5. */ + AMBISONICS_ACN6 = 1ULL << 47U, /** second-order ambisonics channel number 6. */ + AMBISONICS_ACN7 = 1ULL << 48U, /** second-order ambisonics channel number 7. */ + AMBISONICS_ACN8 = 1ULL << 49U, /** second-order ambisonics channel number 8. */ + + // third order ambisonics ACN + AMBISONICS_ACN9 = 1ULL << 50U, /** third-order ambisonics channel number 9. */ + AMBISONICS_ACN10 = 1ULL << 51U, /** third-order ambisonics channel number 10. */ + AMBISONICS_ACN11 = 1ULL << 52U, /** third-order ambisonics channel number 11. */ + AMBISONICS_ACN12 = 1ULL << 53U, /** third-order ambisonics channel number 12. */ + AMBISONICS_ACN13 = 1ULL << 54U, /** third-order ambisonics channel number 13. */ + AMBISONICS_ACN14 = 1ULL << 55U, /** third-order ambisonics channel number 14. */ + AMBISONICS_ACN15 = 1ULL << 56U, /** third-order ambisonics channel number 15. */ +}; + +/** + * @brief Audio AudioChannel Layout + * Indicates that the channel order in which the user requests decoder output + * is the native codec channel order. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +enum AudioChannelLayout : uint64_t { + UNKNOWN_CHANNEL_LAYOUT = 0, + MONO = (AudioChannelSet::FRONT_CENTER), + STEREO = (AudioChannelSet::FRONT_LEFT | AudioChannelSet::FRONT_RIGHT), + CH_2POINT1 = (STEREO | AudioChannelSet::LOW_FREQUENCY), + CH_2_1 = (STEREO | AudioChannelSet::BACK_CENTER), + SURROUND = (STEREO | AudioChannelSet::FRONT_CENTER), + CH_3POINT1 = (SURROUND | AudioChannelSet::LOW_FREQUENCY), + CH_4POINT0 = (SURROUND | AudioChannelSet::BACK_CENTER), + CH_4POINT1 = (CH_4POINT0 | AudioChannelSet::LOW_FREQUENCY), + CH_2_2 = (STEREO | AudioChannelSet::SIDE_LEFT | AudioChannelSet::SIDE_RIGHT), + QUAD = (STEREO | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), + CH_5POINT0 = (SURROUND | AudioChannelSet::SIDE_LEFT | AudioChannelSet::SIDE_RIGHT), + CH_5POINT1 = (CH_5POINT0 | AudioChannelSet::LOW_FREQUENCY), + CH_5POINT0_BACK = (SURROUND | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), + CH_5POINT1_BACK = (CH_5POINT0_BACK | AudioChannelSet::LOW_FREQUENCY), + CH_6POINT0 = (CH_5POINT0 | AudioChannelSet::BACK_CENTER), + CH_6POINT0_FRONT = (CH_2_2 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), + HEXAGONAL = (CH_5POINT0_BACK | AudioChannelSet::BACK_CENTER), + CH_6POINT1 = (CH_5POINT1 | AudioChannelSet::BACK_CENTER), + CH_6POINT1_BACK = (CH_5POINT1_BACK | AudioChannelSet::BACK_CENTER), + CH_6POINT1_FRONT = (CH_6POINT0_FRONT | AudioChannelSet::LOW_FREQUENCY), + CH_7POINT0 = (CH_5POINT0 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), + CH_7POINT0_FRONT = (CH_5POINT0 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), + CH_7POINT1 = (CH_5POINT1 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_RIGHT), + CH_7POINT1_WIDE = (CH_5POINT1 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), + CH_7POINT1_WIDE_BACK = + (CH_5POINT1_BACK | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER), + CH_3POINT1POINT2 = (CH_3POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT), + CH_5POINT1POINT2 = (CH_5POINT1 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), + CH_5POINT1POINT4 = (CH_5POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | + AudioChannelSet::TOP_BACK_LEFT | AudioChannelSet::TOP_BACK_RIGHT), + CH_7POINT1POINT2 = (CH_7POINT1 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), + CH_7POINT1POINT4 = (CH_7POINT1 | AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | + AudioChannelSet::TOP_BACK_LEFT | AudioChannelSet::TOP_BACK_RIGHT), + CH_9POINT1POINT4 = (CH_7POINT1POINT4 | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT), + CH_9POINT1POINT6 = (CH_9POINT1POINT4 | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT), + CH_10POINT2 = (AudioChannelSet::FRONT_LEFT | AudioChannelSet::FRONT_RIGHT | AudioChannelSet::FRONT_CENTER | + AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT | AudioChannelSet::BACK_LEFT | + AudioChannelSet::BACK_RIGHT | AudioChannelSet::BACK_CENTER | AudioChannelSet::SIDE_LEFT | + AudioChannelSet::SIDE_RIGHT | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT), + CH_22POINT2 = (CH_7POINT1POINT4 | AudioChannelSet::FRONT_LEFT_OF_CENTER | AudioChannelSet::FRONT_RIGHT_OF_CENTER | + AudioChannelSet::BACK_CENTER | AudioChannelSet::TOP_CENTER | AudioChannelSet::TOP_FRONT_CENTER | + AudioChannelSet::TOP_BACK_CENTER | AudioChannelSet::TOP_SIDE_LEFT | AudioChannelSet::TOP_SIDE_RIGHT | + AudioChannelSet::BOTTOM_FRONT_LEFT | AudioChannelSet::BOTTOM_FRONT_RIGHT | + AudioChannelSet::BOTTOM_FRONT_CENTER | AudioChannelSet::LOW_FREQUENCY_2), + OCTAGONAL = (CH_5POINT0 | AudioChannelSet::BACK_LEFT | AudioChannelSet::BACK_CENTER | AudioChannelSet::BACK_RIGHT), + HEXADECAGONAL = + (OCTAGONAL | AudioChannelSet::WIDE_LEFT | AudioChannelSet::WIDE_RIGHT | AudioChannelSet::TOP_BACK_LEFT | + AudioChannelSet::TOP_BACK_RIGHT | AudioChannelSet::TOP_BACK_CENTER | AudioChannelSet::TOP_FRONT_CENTER | + AudioChannelSet::TOP_FRONT_LEFT | AudioChannelSet::TOP_FRONT_RIGHT), + STEREO_DOWNMIX = (AudioChannelSet::STEREO_LEFT | AudioChannelSet::STEREO_RIGHT), + + HOA_FIRST = AudioChannelSet::AMBISONICS_ACN0 | AudioChannelSet::AMBISONICS_ACN1 | AudioChannelSet::AMBISONICS_ACN2 | + AudioChannelSet::AMBISONICS_ACN3, + HOA_SECOND = HOA_FIRST | AudioChannelSet::AMBISONICS_ACN4 | AudioChannelSet::AMBISONICS_ACN5 | + AudioChannelSet::AMBISONICS_ACN6 | AudioChannelSet::AMBISONICS_ACN7 | AudioChannelSet::AMBISONICS_ACN8, + HOA_THIRD = HOA_SECOND | AudioChannelSet::AMBISONICS_ACN9 | AudioChannelSet::AMBISONICS_ACN10 | + AudioChannelSet::AMBISONICS_ACN11 | AudioChannelSet::AMBISONICS_ACN12 | + AudioChannelSet::AMBISONICS_ACN13 | AudioChannelSet::AMBISONICS_ACN14 | + AudioChannelSet::AMBISONICS_ACN15, +}; +#ifdef __cplusplus +} +#endif #endif \ No newline at end of file diff --git a/multimedia/av_codec/avdemuxer/BUILD.gn b/multimedia/av_codec/avdemuxer/BUILD.gn index 54e236d9f29040326c29d6dc0685629077b2f765..0915d8425ad4c4c0e6ad7c0d03a9219b9ddf31dc 100644 --- a/multimedia/av_codec/avdemuxer/BUILD.gn +++ b/multimedia/av_codec/avdemuxer/BUILD.gn @@ -1,30 +1,30 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_avdemuxer_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ "//interface/sdk_c/multimedia/av_codec/native_avdemuxer.h" ] -} - -ohos_ndk_library("libnative_media_avdemuxer") { - ndk_description_file = "./libnative_media_avdemuxer.ndk.json" - min_compact_version = "1" - output_name = "native_media_avdemuxer" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.Spliter" - system_capability_headers = - [ "multimedia/player_framework/native_avdemuxer.h" ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avdemuxer_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "//interface/sdk_c/multimedia/av_codec/native_avdemuxer.h" ] +} + +ohos_ndk_library("libnative_media_avdemuxer") { + ndk_description_file = "./libnative_media_avdemuxer.ndk.json" + min_compact_version = "1" + output_name = "native_media_avdemuxer" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_avdemuxer.h" ] +} diff --git a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index bf9ca16b8a9bb96485c6792d7612d5b7eb96b32b..77e352fa4293482e8f8591b7151be30b031495ed 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -1,8 +1,8 @@ -[ - { "name": "OH_AVDemuxer_CreateWithSource" }, - { "name": "OH_AVDemuxer_Destroy" }, - { "name": "OH_AVDemuxer_SelectTrackByID" }, - { "name": "OH_AVDemuxer_UnselectTrackByID" }, - { "name": "OH_AVDemuxer_ReadSample" }, - { "name": "OH_AVDemuxer_SeekToTime" } -] +[ + { "name": "OH_AVDemuxer_CreateWithSource" }, + { "name": "OH_AVDemuxer_Destroy" }, + { "name": "OH_AVDemuxer_SelectTrackByID" }, + { "name": "OH_AVDemuxer_UnselectTrackByID" }, + { "name": "OH_AVDemuxer_ReadSample" }, + { "name": "OH_AVDemuxer_SeekToTime" } +] diff --git a/multimedia/av_codec/avmuxer/BUILD.gn b/multimedia/av_codec/avmuxer/BUILD.gn index 5002afe02aec31d2fb1cddb0a8149e6c4bbcf405..9ad101b59be110cef30bf9af7f84f1a7228174ca 100644 --- a/multimedia/av_codec/avmuxer/BUILD.gn +++ b/multimedia/av_codec/avmuxer/BUILD.gn @@ -1,29 +1,29 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_avmuxer_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ "//interface/sdk_c/multimedia/av_codec/native_avmuxer.h" ] -} - -ohos_ndk_library("libnative_media_avmuxer") { - ndk_description_file = "./libnative_media_avmuxer.ndk.json" - min_compact_version = "1" - output_name = "native_media_avmuxer" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.Muxer" - system_capability_headers = [ "multimedia/player_framework/native_avmuxer.h" ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avmuxer_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "//interface/sdk_c/multimedia/av_codec/native_avmuxer.h" ] +} + +ohos_ndk_library("libnative_media_avmuxer") { + ndk_description_file = "./libnative_media_avmuxer.ndk.json" + min_compact_version = "1" + output_name = "native_media_avmuxer" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Muxer" + system_capability_headers = [ "multimedia/player_framework/native_avmuxer.h" ] +} diff --git a/multimedia/av_codec/avmuxer/libnative_media_avmuxer.ndk.json b/multimedia/av_codec/avmuxer/libnative_media_avmuxer.ndk.json index b831c325d1deb250a719021b800aacde98de2f18..ba18db10bdaea920997cc47c7873886076871b16 100644 --- a/multimedia/av_codec/avmuxer/libnative_media_avmuxer.ndk.json +++ b/multimedia/av_codec/avmuxer/libnative_media_avmuxer.ndk.json @@ -1,9 +1,9 @@ -[ - { "name": "OH_AVMuxer_Create" }, - { "name": "OH_AVMuxer_SetRotation" }, - { "name": "OH_AVMuxer_AddTrack" }, - { "name": "OH_AVMuxer_Start" }, - { "name": "OH_AVMuxer_WriteSample" }, - { "name": "OH_AVMuxer_Stop" }, - { "name": "OH_AVMuxer_Destroy" } -] +[ + { "name": "OH_AVMuxer_Create" }, + { "name": "OH_AVMuxer_SetRotation" }, + { "name": "OH_AVMuxer_AddTrack" }, + { "name": "OH_AVMuxer_Start" }, + { "name": "OH_AVMuxer_WriteSample" }, + { "name": "OH_AVMuxer_Stop" }, + { "name": "OH_AVMuxer_Destroy" } +] diff --git a/multimedia/av_codec/avsource/BUILD.gn b/multimedia/av_codec/avsource/BUILD.gn index 395fc84749b4582499cc93e1ef540a1f02ec1ca1..3c0d2fdeb67f5d0b7247ee1ce84d699bbe1b8cd2 100644 --- a/multimedia/av_codec/avsource/BUILD.gn +++ b/multimedia/av_codec/avsource/BUILD.gn @@ -1,30 +1,30 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_avsource_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ "//interface/sdk_c/multimedia/av_codec/native_avsource.h" ] -} - -ohos_ndk_library("libnative_media_avsource") { - ndk_description_file = "./libnative_media_avsource.ndk.json" - min_compact_version = "1" - output_name = "native_media_avsource" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.Spliter" - system_capability_headers = - [ "multimedia/player_framework/native_avsource.h" ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avsource_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "//interface/sdk_c/multimedia/av_codec/native_avsource.h" ] +} + +ohos_ndk_library("libnative_media_avsource") { + ndk_description_file = "./libnative_media_avsource.ndk.json" + min_compact_version = "1" + output_name = "native_media_avsource" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_avsource.h" ] +} diff --git a/multimedia/av_codec/avsource/libnative_media_avsource.ndk.json b/multimedia/av_codec/avsource/libnative_media_avsource.ndk.json index 3232f28e29b83f4f68bf9a5fd393c0c02bddd393..735694b4496cee9d6920f222d1290f623495b4fd 100644 --- a/multimedia/av_codec/avsource/libnative_media_avsource.ndk.json +++ b/multimedia/av_codec/avsource/libnative_media_avsource.ndk.json @@ -1,7 +1,7 @@ -[ - { "name": "OH_AVSource_CreateWithURI" }, - { "name": "OH_AVSource_CreateWithFD" }, - { "name": "OH_AVSource_Destroy" }, - { "name": "OH_AVSource_GetSourceFormat" }, - { "name": "OH_AVSource_GetTrackFormat" } -] +[ + { "name": "OH_AVSource_CreateWithURI" }, + { "name": "OH_AVSource_CreateWithFD" }, + { "name": "OH_AVSource_Destroy" }, + { "name": "OH_AVSource_GetSourceFormat" }, + { "name": "OH_AVSource_GetTrackFormat" } +] diff --git a/multimedia/av_codec/codec_base/BUILD.gn b/multimedia/av_codec/codec_base/BUILD.gn index 99e9bf2801ac31e1366b59b706887ded33db4e60..c70756f7b7b46be409c8fe6e636afddbc4019df4 100644 --- a/multimedia/av_codec/codec_base/BUILD.gn +++ b/multimedia/av_codec/codec_base/BUILD.gn @@ -1,37 +1,37 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_codecbase_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ - "//interface/sdk_c/multimedia/av_codec/avcodec_audio_channel_layout.h", - "//interface/sdk_c/multimedia/av_codec/native_avcapability.h", - "//interface/sdk_c/multimedia/av_codec/native_avcodec_base.h", - ] -} - -ohos_ndk_library("libnative_media_codecbase") { - ndk_description_file = "./libnative_media_codecbase.ndk.json" - min_compact_version = "1" - output_name = "native_media_codecbase" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.CodecBase" - system_capability_headers = [ - "multimedia/player_framework/native_avcodec_base.h", - "multimedia/player_framework/native_avcapability.h", - "multimedia/player_framework/avcodec_audio_channel_layout.h", - ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_codecbase_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "//interface/sdk_c/multimedia/av_codec/avcodec_audio_channel_layout.h", + "//interface/sdk_c/multimedia/av_codec/native_avcapability.h", + "//interface/sdk_c/multimedia/av_codec/native_avcodec_base.h", + ] +} + +ohos_ndk_library("libnative_media_codecbase") { + ndk_description_file = "./libnative_media_codecbase.ndk.json" + min_compact_version = "1" + output_name = "native_media_codecbase" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.CodecBase" + system_capability_headers = [ + "multimedia/player_framework/native_avcodec_base.h", + "multimedia/player_framework/native_avcapability.h", + "multimedia/player_framework/avcodec_audio_channel_layout.h", + ] +} diff --git a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json index 3e19fb31dd7923688ec3f9485a6312b43ddfbdca..b849bb523b1ce91782b8ba1d2a83e765b9faee26 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -1,83 +1,83 @@ -[ - { "name": "OH_AVCODEC_MIMETYPE_VIDEO_AVC" }, - { "name": "OH_AVCODEC_MIMETYPE_AUDIO_AAC" }, - { "name": "OH_AVCODEC_MIMETYPE_VIDEO_MPEG4" }, - { "name": "OH_AVCODEC_MIMETYPE_VIDEO_HEVC" }, - { "name": "OH_AVCODEC_MIMETYPE_AUDIO_MPEG" }, - { "name": "OH_AVCODEC_MIMETYPE_IMAGE_JPG" }, - { "name": "OH_AVCODEC_MIMETYPE_IMAGE_PNG" }, - { "name": "OH_AVCODEC_MIMETYPE_IMAGE_BMP" }, - { "name": "OH_AVCODEC_MIMETYPE_AUDIO_FLAC" }, - { "name": "OH_AVCODEC_MIMETYPE_AUDIO_VORBIS" }, - { "name": "OH_ED_KEY_TIME_STAMP" }, - { "name": "OH_ED_KEY_EOS" }, - { "name": "OH_MD_KEY_TRACK_TYPE" }, - { "name": "OH_MD_KEY_CODEC_MIME" }, - { "name": "OH_MD_KEY_DURATION" }, - { "name": "OH_MD_KEY_BITRATE" }, - { "name": "OH_MD_KEY_MAX_INPUT_SIZE" }, - { "name": "OH_MD_KEY_WIDTH" }, - { "name": "OH_MD_KEY_HEIGHT" }, - { "name": "OH_MD_KEY_PIXEL_FORMAT" }, - { "name": "OH_MD_KEY_RANGE_FLAG" }, - { "name": "OH_MD_KEY_COLOR_PRIMARIES" }, - { "name": "OH_MD_KEY_TRANSFER_CHARACTERISTICS" }, - { "name": "OH_MD_KEY_MATRIX_COEFFICIENTS" }, - { "name": "OH_MD_KEY_AUDIO_SAMPLE_FORMAT" }, - { "name": "OH_MD_KEY_FRAME_RATE" }, - { "name": "OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE" }, - { "name": "OH_MD_KEY_PROFILE" }, - { "name": "OH_MD_KEY_AUD_CHANNEL_COUNT" }, - { "name": "OH_MD_KEY_AUD_SAMPLE_RATE" }, - { "name": "OH_MD_KEY_I_FRAME_INTERVAL" }, - { "name": "OH_MD_KEY_ROTATION" }, - { "name": "OH_MD_KEY_CODEC_CONFIG" }, - { "name": "OH_MD_KEY_REQUEST_I_FRAME" }, - { "name": "OH_MD_KEY_QUALITY" }, - { "name": "OH_MD_KEY_CHANNEL_LAYOUT" }, - { "name": "OH_MD_KEY_BITS_PER_CODED_SAMPLE" }, - { "name": "OH_MD_KEY_AAC_IS_ADTS" }, - { "name": "OH_MD_KEY_SBR" }, - { "name": "OH_MD_KEY_COMPLIANCE_LEVEL" }, - { "name": "OH_MD_KEY_IDENTIFICATION_HEADER" }, - { "name": "OH_MD_KEY_SETUP_HEADER" }, - { "name": "OH_MD_KEY_SCALING_MODE" }, - { "name": "OH_MD_MAX_INPUT_BUFFER_COUNT" }, - { "name": "OH_MD_MAX_OUTPUT_BUFFER_COUNT" }, - { "name": "OH_MD_KEY_TITLE" }, - { "name": "OH_MD_KEY_ARTIST" }, - { "name": "OH_MD_KEY_ALBUM" }, - { "name": "OH_MD_KEY_ALBUM_ARTIST" }, - { "name": "OH_MD_KEY_DATE" }, - { "name": "OH_MD_KEY_COMMENT" }, - { "name": "OH_MD_KEY_GENRE" }, - { "name": "OH_MD_KEY_COPYRIGHT" }, - { "name": "OH_MD_KEY_LANGUAGE" }, - { "name": "OH_MD_KEY_DESCRIPTION" }, - { "name": "OH_MD_KEY_LYRICS" }, - { "name": "OH_MD_KEY_TRACK_COUNT" }, - { "name": "OH_AVCapability_IsHardware" }, - { "name": "OH_AVCapability_GetName" }, - { "name": "OH_AVCapability_GetMaxSupportedInstances" }, - { "name": "OH_AVCapability_GetEncoderBitrateRange" }, - { "name": "OH_AVCapability_IsEncoderBitrateModeSupported" }, - { "name": "OH_AVCapability_GetEncoderQualityRange" }, - { "name": "OH_AVCapability_GetEncoderComplexityRange" }, - { "name": "OH_AVCapability_GetAudioSupportedSampleRates" }, - { "name": "OH_AVCapability_GetAudioChannelCountRange" }, - { "name": "OH_AVCapability_GetVideoWidthAlignment" }, - { "name": "OH_AVCapability_GetVideoHeightAlignment" }, - { "name": "OH_AVCapability_GetVideoWidthRangeForHeight" }, - { "name": "OH_AVCapability_GetVideoHeightRangeForWidth" }, - { "name": "OH_AVCapability_GetVideoWidthRange" }, - { "name": "OH_AVCapability_GetVideoHeightRange" }, - { "name": "OH_AVCapability_IsVideoSizeSupported" }, - { "name": "OH_AVCapability_GetVideoFrameRateRange" }, - { "name": "OH_AVCapability_GetVideoFrameRateRangeForSize" }, - { "name": "OH_AVCapability_AreVideoSizeAndFrameRateSupported" }, - { "name": "OH_AVCapability_GetVideoSupportedPixelFormats" }, - { "name": "OH_AVCapability_GetSupportedProfiles" }, - { "name": "OH_AVCapability_GetSupportedLevelsForProfile" }, - { "name": "OH_AVCapability_AreProfileAndLevelSupported" } -] - +[ + { "name": "OH_AVCODEC_MIMETYPE_VIDEO_AVC" }, + { "name": "OH_AVCODEC_MIMETYPE_AUDIO_AAC" }, + { "name": "OH_AVCODEC_MIMETYPE_VIDEO_MPEG4" }, + { "name": "OH_AVCODEC_MIMETYPE_VIDEO_HEVC" }, + { "name": "OH_AVCODEC_MIMETYPE_AUDIO_MPEG" }, + { "name": "OH_AVCODEC_MIMETYPE_IMAGE_JPG" }, + { "name": "OH_AVCODEC_MIMETYPE_IMAGE_PNG" }, + { "name": "OH_AVCODEC_MIMETYPE_IMAGE_BMP" }, + { "name": "OH_AVCODEC_MIMETYPE_AUDIO_FLAC" }, + { "name": "OH_AVCODEC_MIMETYPE_AUDIO_VORBIS" }, + { "name": "OH_ED_KEY_TIME_STAMP" }, + { "name": "OH_ED_KEY_EOS" }, + { "name": "OH_MD_KEY_TRACK_TYPE" }, + { "name": "OH_MD_KEY_CODEC_MIME" }, + { "name": "OH_MD_KEY_DURATION" }, + { "name": "OH_MD_KEY_BITRATE" }, + { "name": "OH_MD_KEY_MAX_INPUT_SIZE" }, + { "name": "OH_MD_KEY_WIDTH" }, + { "name": "OH_MD_KEY_HEIGHT" }, + { "name": "OH_MD_KEY_PIXEL_FORMAT" }, + { "name": "OH_MD_KEY_RANGE_FLAG" }, + { "name": "OH_MD_KEY_COLOR_PRIMARIES" }, + { "name": "OH_MD_KEY_TRANSFER_CHARACTERISTICS" }, + { "name": "OH_MD_KEY_MATRIX_COEFFICIENTS" }, + { "name": "OH_MD_KEY_AUDIO_SAMPLE_FORMAT" }, + { "name": "OH_MD_KEY_FRAME_RATE" }, + { "name": "OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE" }, + { "name": "OH_MD_KEY_PROFILE" }, + { "name": "OH_MD_KEY_AUD_CHANNEL_COUNT" }, + { "name": "OH_MD_KEY_AUD_SAMPLE_RATE" }, + { "name": "OH_MD_KEY_I_FRAME_INTERVAL" }, + { "name": "OH_MD_KEY_ROTATION" }, + { "name": "OH_MD_KEY_CODEC_CONFIG" }, + { "name": "OH_MD_KEY_REQUEST_I_FRAME" }, + { "name": "OH_MD_KEY_QUALITY" }, + { "name": "OH_MD_KEY_CHANNEL_LAYOUT" }, + { "name": "OH_MD_KEY_BITS_PER_CODED_SAMPLE" }, + { "name": "OH_MD_KEY_AAC_IS_ADTS" }, + { "name": "OH_MD_KEY_SBR" }, + { "name": "OH_MD_KEY_COMPLIANCE_LEVEL" }, + { "name": "OH_MD_KEY_IDENTIFICATION_HEADER" }, + { "name": "OH_MD_KEY_SETUP_HEADER" }, + { "name": "OH_MD_KEY_SCALING_MODE" }, + { "name": "OH_MD_MAX_INPUT_BUFFER_COUNT" }, + { "name": "OH_MD_MAX_OUTPUT_BUFFER_COUNT" }, + { "name": "OH_MD_KEY_TITLE" }, + { "name": "OH_MD_KEY_ARTIST" }, + { "name": "OH_MD_KEY_ALBUM" }, + { "name": "OH_MD_KEY_ALBUM_ARTIST" }, + { "name": "OH_MD_KEY_DATE" }, + { "name": "OH_MD_KEY_COMMENT" }, + { "name": "OH_MD_KEY_GENRE" }, + { "name": "OH_MD_KEY_COPYRIGHT" }, + { "name": "OH_MD_KEY_LANGUAGE" }, + { "name": "OH_MD_KEY_DESCRIPTION" }, + { "name": "OH_MD_KEY_LYRICS" }, + { "name": "OH_MD_KEY_TRACK_COUNT" }, + { "name": "OH_AVCapability_IsHardware" }, + { "name": "OH_AVCapability_GetName" }, + { "name": "OH_AVCapability_GetMaxSupportedInstances" }, + { "name": "OH_AVCapability_GetEncoderBitrateRange" }, + { "name": "OH_AVCapability_IsEncoderBitrateModeSupported" }, + { "name": "OH_AVCapability_GetEncoderQualityRange" }, + { "name": "OH_AVCapability_GetEncoderComplexityRange" }, + { "name": "OH_AVCapability_GetAudioSupportedSampleRates" }, + { "name": "OH_AVCapability_GetAudioChannelCountRange" }, + { "name": "OH_AVCapability_GetVideoWidthAlignment" }, + { "name": "OH_AVCapability_GetVideoHeightAlignment" }, + { "name": "OH_AVCapability_GetVideoWidthRangeForHeight" }, + { "name": "OH_AVCapability_GetVideoHeightRangeForWidth" }, + { "name": "OH_AVCapability_GetVideoWidthRange" }, + { "name": "OH_AVCapability_GetVideoHeightRange" }, + { "name": "OH_AVCapability_IsVideoSizeSupported" }, + { "name": "OH_AVCapability_GetVideoFrameRateRange" }, + { "name": "OH_AVCapability_GetVideoFrameRateRangeForSize" }, + { "name": "OH_AVCapability_AreVideoSizeAndFrameRateSupported" }, + { "name": "OH_AVCapability_GetVideoSupportedPixelFormats" }, + { "name": "OH_AVCapability_GetSupportedProfiles" }, + { "name": "OH_AVCapability_GetSupportedLevelsForProfile" }, + { "name": "OH_AVCapability_AreProfileAndLevelSupported" } +] + diff --git a/multimedia/av_codec/core/BUILD.gn b/multimedia/av_codec/core/BUILD.gn index 8d047d2eb4f42bccc5515902e29b76f2c0e95776..177b2febe093fcd5382513e61d770348fe6de529 100644 --- a/multimedia/av_codec/core/BUILD.gn +++ b/multimedia/av_codec/core/BUILD.gn @@ -1,37 +1,37 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_core_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ - "//interface/sdk_c/multimedia/av_codec/native_averrors.h", - "//interface/sdk_c/multimedia/av_codec/native_avformat.h", - "//interface/sdk_c/multimedia/av_codec/native_avmemory.h", - ] -} - -ohos_ndk_library("libnative_media_core") { - ndk_description_file = "./libnative_media_core.ndk.json" - min_compact_version = "1" - output_name = "native_media_core" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.Core" - system_capability_headers = [ - "multimedia/player_framework/native_averrors.h", - "multimedia/player_framework/native_avformat.h", - "multimedia/player_framework/native_avmemory.h", - ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_core_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "//interface/sdk_c/multimedia/av_codec/native_averrors.h", + "//interface/sdk_c/multimedia/av_codec/native_avformat.h", + "//interface/sdk_c/multimedia/av_codec/native_avmemory.h", + ] +} + +ohos_ndk_library("libnative_media_core") { + ndk_description_file = "./libnative_media_core.ndk.json" + min_compact_version = "1" + output_name = "native_media_core" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Core" + system_capability_headers = [ + "multimedia/player_framework/native_averrors.h", + "multimedia/player_framework/native_avformat.h", + "multimedia/player_framework/native_avmemory.h", + ] +} diff --git a/multimedia/av_codec/core/libnative_media_core.ndk.json b/multimedia/av_codec/core/libnative_media_core.ndk.json index f7ceabdb59df7bae0c68124e80913123c8585d48..2da9aff78957cf724f35efc4134913f47ff79791 100644 --- a/multimedia/av_codec/core/libnative_media_core.ndk.json +++ b/multimedia/av_codec/core/libnative_media_core.ndk.json @@ -1,26 +1,26 @@ -[ - { "name": "OH_AVFormat_Create" }, - { "name": "OH_AVFormat_CreateAudioFormat" }, - { "name": "OH_AVFormat_CreateVideoFormat" }, - { "name": "OH_AVFormat_Destroy" }, - { "name": "OH_AVFormat_Copy" }, - { "name": "OH_AVFormat_SetIntValue" }, - { "name": "OH_AVFormat_SetLongValue" }, - { "name": "OH_AVFormat_SetFloatValue" }, - { "name": "OH_AVFormat_SetDoubleValue" }, - { "name": "OH_AVFormat_SetStringValue" }, - { "name": "OH_AVFormat_SetBuffer" }, - { "name": "OH_AVFormat_GetIntValue" }, - { "name": "OH_AVFormat_GetLongValue" }, - { "name": "OH_AVFormat_GetFloatValue" }, - { "name": "OH_AVFormat_GetDoubleValue" }, - { "name": "OH_AVFormat_GetStringValue" }, - { "name": "OH_AVFormat_GetBuffer" }, - { "name": "OH_AVFormat_DumpInfo" }, - { "name": "OH_AVMemory_Create" }, - { "name": "OH_AVMemory_GetAddr" }, - { "name": "OH_AVMemory_GetSize" }, - { "name": "OH_AVMemory_Destroy" }, - { "name": "OH_AVCodec_GetCapability" }, - { "name": "OH_AVCodec_GetCapabilityByCategory" } -] +[ + { "name": "OH_AVFormat_Create" }, + { "name": "OH_AVFormat_CreateAudioFormat" }, + { "name": "OH_AVFormat_CreateVideoFormat" }, + { "name": "OH_AVFormat_Destroy" }, + { "name": "OH_AVFormat_Copy" }, + { "name": "OH_AVFormat_SetIntValue" }, + { "name": "OH_AVFormat_SetLongValue" }, + { "name": "OH_AVFormat_SetFloatValue" }, + { "name": "OH_AVFormat_SetDoubleValue" }, + { "name": "OH_AVFormat_SetStringValue" }, + { "name": "OH_AVFormat_SetBuffer" }, + { "name": "OH_AVFormat_GetIntValue" }, + { "name": "OH_AVFormat_GetLongValue" }, + { "name": "OH_AVFormat_GetFloatValue" }, + { "name": "OH_AVFormat_GetDoubleValue" }, + { "name": "OH_AVFormat_GetStringValue" }, + { "name": "OH_AVFormat_GetBuffer" }, + { "name": "OH_AVFormat_DumpInfo" }, + { "name": "OH_AVMemory_Create" }, + { "name": "OH_AVMemory_GetAddr" }, + { "name": "OH_AVMemory_GetSize" }, + { "name": "OH_AVMemory_Destroy" }, + { "name": "OH_AVCodec_GetCapability" }, + { "name": "OH_AVCodec_GetCapabilityByCategory" } +] diff --git a/multimedia/av_codec/native_avcapability.h b/multimedia/av_codec/native_avcapability.h index 043678aab03b8fb3761b663e3a429606921e202b..304c8533e3dbbafcfdcca2ed125e5fc8295a816a 100644 --- a/multimedia/av_codec/native_avcapability.h +++ b/multimedia/av_codec/native_avcapability.h @@ -1,356 +1,356 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCAPABILITY_H -#define NATIVE_AVCAPABILITY_H - -#include -#include "native_averrors.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVCapability OH_AVCapability; - -/** - * @brief The bitrate mode of encoder. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_BitrateMode { - /* Constant Bit rate mode. */ - BITRATE_MODE_CBR = 0, - /* Variable Bit rate mode. */ - BITRATE_MODE_VBR = 1, - /* Constant Quality mode. */ - BITRATE_MODE_CQ = 2 -} OH_BitrateMode; - -/** - * @brief Range contain min and max value - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef struct OH_AVRange { - int32_t minVal; - int32_t maxVal; -} OH_AVRange; - -/** - * @brief The codec category - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_AVCodecCategory { - HARDWARE = 0, - SOFTWARE -} OH_AVCodecCategory; - -/** - * @brief Get a system-recommended codec's capability. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param mime Mime type - * @param isEncoder True for encoder, false for decoder - * @return Returns a capability instance if an existing codec matches, - * if the specified mime type doesn't match any existing codec, returns NULL. - * @since 10 - */ -OH_AVCapability *OH_AVCodec_GetCapability(const char *mime, bool isEncoder); - -/** - * @brief Get a codec's capability within the specified category. By specifying the category, - * the matched codec is limited to either hardware codecs or software codecs. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param mime Mime type - * @param isEncoder True for encoder, false for decoder - * @param category The codec category - * @return Returns a capability instance if an existing codec matches, - * if the specified mime type doesn't match any existing codec, returns NULL - * @since 10 - */ -OH_AVCapability *OH_AVCodec_GetCapabilityByCategory(const char *mime, bool isEncoder, OH_AVCodecCategory category); - -/** - * @brief Check if the capability instance is describing a hardware codec. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @return Returns true if the capability instance is describing a hardware codec, - * false if the capability instance is describing a software codec - * @since 10 - */ -bool OH_AVCapability_IsHardware(OH_AVCapability *capability); - -/** - * @brief Get the codec name. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @return Returns codec name string - * @since 10 - */ -const char *OH_AVCapability_GetName(OH_AVCapability *capability); - -/** - * @brief Get the supported max instance number of the codec. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @return Returns the max supported codec instance number - * @since 10 - */ -int32_t OH_AVCapability_GetMaxSupportedInstances(OH_AVCapability *capability); - -/** - * @brief Get the encoder's supported bitrate range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Encoder capability pointer. Do not give a decoder capability pointer - * @param bitrateRange Output parameter. Encoder bitrate range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetEncoderBitrateRange(OH_AVCapability *capability, OH_AVRange *bitrateRange); - -/** - * @brief Check if the encoder supports the specific bitrate mode. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Encoder capability pointer. Do not give a decoder capability pointer - * @param bitrateMode Bitrate mode - * @return Returns true if the bitrate mode is supported, false if the bitrate mode is not supported - * @since 10 - */ -bool OH_AVCapability_IsEncoderBitrateModeSupported(OH_AVCapability *capability, OH_BitrateMode bitrateMode); - -/** - * @brief Get the encoder's supported quality range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Encoder capability pointer. Do not give a decoder capability pointer - * @param qualityRange Output parameter. Encoder quality range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetEncoderQualityRange(OH_AVCapability *capability, OH_AVRange *qualityRange); - -/** - * @brief Get the encoder's supported encoder complexity range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Encoder capability pointer. Do not give a decoder capability pointer - * @param complexityRange Output parameter. Encoder complexity range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetEncoderComplexityRange(OH_AVCapability *capability, OH_AVRange *complexityRange); - -/** - * @brief Get the audio codec's supported sample rates. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Audio codec capability pointer. Do not give a video codec capability pointer - * @param sampleRates Output parameter. A pointer to the sample rates array - * @param sampleRateNum Output parameter. The element number of the sample rates array - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRates(OH_AVCapability *capability, const int32_t **sampleRates, - uint32_t *sampleRateNum); - -/** - * @brief Get the audio codec's supported audio channel count range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Audio codec capability pointer. Do not give a video codec capability pointer - * @param channelCountRange Output parameter. Audio channel count range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetAudioChannelCountRange(OH_AVCapability *capability, OH_AVRange *channelCountRange); - -/** - * @brief Get the video codec's supported video width alignment. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param widthAlignment Output parameter. Video width alignment - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoWidthAlignment(OH_AVCapability *capability, int32_t *widthAlignment); - -/** - * @brief Get the video codec's supported video height alignment. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param heightAlignment Output parameter. Video height alignment - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoHeightAlignment(OH_AVCapability *capability, int32_t *heightAlignment); - -/** - * @brief Get the video codec's supported video width range for a specific height. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability video codec capability pointer. Do not give an audio codec capability pointer - * @param height Vertical pixel number of the video - * @param widthRange Output parameter. Video width range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoWidthRangeForHeight(OH_AVCapability *capability, int32_t height, - OH_AVRange *widthRange); - -/** - * @brief Get the video codec's supported video height range for a specific width. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param width Horizontal pixel number of the video - * @param heightRange Output parameter. Video height range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoHeightRangeForWidth(OH_AVCapability *capability, int32_t width, - OH_AVRange *heightRange); - -/** - * @brief Get the video codec's supported video width range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. DO not give an audio codec capability pointer - * @param widthRange Output parameter. Video width range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoWidthRange(OH_AVCapability *capability, OH_AVRange *widthRange); - -/** - * @brief Get the video codec's supported video height range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param heightRange Output parameter. Video height range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoHeightRange(OH_AVCapability *capability, OH_AVRange *heightRange); - -/** - * @brief Check if the video codec supports the specific video size. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param width Horizontal pixel number of the video - * @param height Vertical pixel number of the video - * @return Returns true if the video size is supported, false if the video size is not supported - * @since 10 - */ -bool OH_AVCapability_IsVideoSizeSupported(OH_AVCapability *capability, int32_t width, int32_t height); - -/** - * @brief Get the video codec's supported video frame rate range. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param frameRateRange Output parameter. Video frame rate range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoFrameRateRange(OH_AVCapability *capability, OH_AVRange *frameRateRange); - -/** - * @brief Get the Video codec's supported video frame rate range for a specified video size. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param width Horizontal pixel number of the video - * @param height Vertical pixel number of the video - * @param frameRateRange Output parameter. Frame rate range - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoFrameRateRangeForSize(OH_AVCapability *capability, int32_t width, int32_t height, - OH_AVRange *frameRateRange); - -/** - * @brief Check if the video codec supports the specific combination of video size and frame rate. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param width Horizontal pixel number of the video - * @param height Vertical pixel number of the video - * @param frameRate Frame number per second - * @return Returns true if the combination of video size and frame rate is supported, - * false if it is not supported - * @since 10 - */ -bool OH_AVCapability_AreVideoSizeAndFrameRateSupported(OH_AVCapability *capability, int32_t width, int32_t height, - int32_t frameRate); - -/** - * @brief Get the video codec's supported video pixel format. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Video codec capability pointer. Do not give an audio codec capability pointer - * @param pixelFormats Output parameter. A pointer to the video pixel format array - * @param pixelFormatNum Output parameter. The element number of the pixel format array - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetVideoSupportedPixelFormats(OH_AVCapability *capability, const int32_t **pixelFormats, - uint32_t *pixelFormatNum); - -/** - * @brief Get the codec's supported profiles. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @param profiles Output parameter. A pointer to the profile array - * @param profileNum Output parameter. The element number of the profile array - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetSupportedProfiles(OH_AVCapability *capability, const int32_t **profiles, - uint32_t *profileNum); - -/** - * @brief Get codec's supported levels for a specific profile. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @param profile Codec profile - * @param levels Output parameter. A pointer to the level array - * @param levelNum Output parameter. The element number of the level array - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVCapability_GetSupportedLevelsForProfile(OH_AVCapability *capability, int32_t profile, - const int32_t **levels, uint32_t *levelNum); - -/** - * @brief Check if the codec supports the specific combination of the profile and level. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param capability Codec capability pointer - * @param profile Codec profile - * @param level Codec level - * @return Returns true if the combination of profile and level is supported, - * false if it is not supported - * @since 10 - */ -bool OH_AVCapability_AreProfileAndLevelSupported(OH_AVCapability *capability, int32_t profile, int32_t level); - -#ifdef __cplusplus -} -#endif +/* + * 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. + */ + +#ifndef NATIVE_AVCAPABILITY_H +#define NATIVE_AVCAPABILITY_H + +#include +#include "native_averrors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVCapability OH_AVCapability; + +/** + * @brief The bitrate mode of encoder. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_BitrateMode { + /* Constant Bit rate mode. */ + BITRATE_MODE_CBR = 0, + /* Variable Bit rate mode. */ + BITRATE_MODE_VBR = 1, + /* Constant Quality mode. */ + BITRATE_MODE_CQ = 2 +} OH_BitrateMode; + +/** + * @brief Range contain min and max value + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef struct OH_AVRange { + int32_t minVal; + int32_t maxVal; +} OH_AVRange; + +/** + * @brief The codec category + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_AVCodecCategory { + HARDWARE = 0, + SOFTWARE +} OH_AVCodecCategory; + +/** + * @brief Get a system-recommended codec's capability. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param mime Mime type + * @param isEncoder True for encoder, false for decoder + * @return Returns a capability instance if an existing codec matches, + * if the specified mime type doesn't match any existing codec, returns NULL. + * @since 10 + */ +OH_AVCapability *OH_AVCodec_GetCapability(const char *mime, bool isEncoder); + +/** + * @brief Get a codec's capability within the specified category. By specifying the category, + * the matched codec is limited to either hardware codecs or software codecs. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param mime Mime type + * @param isEncoder True for encoder, false for decoder + * @param category The codec category + * @return Returns a capability instance if an existing codec matches, + * if the specified mime type doesn't match any existing codec, returns NULL + * @since 10 + */ +OH_AVCapability *OH_AVCodec_GetCapabilityByCategory(const char *mime, bool isEncoder, OH_AVCodecCategory category); + +/** + * @brief Check if the capability instance is describing a hardware codec. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @return Returns true if the capability instance is describing a hardware codec, + * false if the capability instance is describing a software codec + * @since 10 + */ +bool OH_AVCapability_IsHardware(OH_AVCapability *capability); + +/** + * @brief Get the codec name. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @return Returns codec name string + * @since 10 + */ +const char *OH_AVCapability_GetName(OH_AVCapability *capability); + +/** + * @brief Get the supported max instance number of the codec. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @return Returns the max supported codec instance number + * @since 10 + */ +int32_t OH_AVCapability_GetMaxSupportedInstances(OH_AVCapability *capability); + +/** + * @brief Get the encoder's supported bitrate range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Encoder capability pointer. Do not give a decoder capability pointer + * @param bitrateRange Output parameter. Encoder bitrate range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetEncoderBitrateRange(OH_AVCapability *capability, OH_AVRange *bitrateRange); + +/** + * @brief Check if the encoder supports the specific bitrate mode. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Encoder capability pointer. Do not give a decoder capability pointer + * @param bitrateMode Bitrate mode + * @return Returns true if the bitrate mode is supported, false if the bitrate mode is not supported + * @since 10 + */ +bool OH_AVCapability_IsEncoderBitrateModeSupported(OH_AVCapability *capability, OH_BitrateMode bitrateMode); + +/** + * @brief Get the encoder's supported quality range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Encoder capability pointer. Do not give a decoder capability pointer + * @param qualityRange Output parameter. Encoder quality range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetEncoderQualityRange(OH_AVCapability *capability, OH_AVRange *qualityRange); + +/** + * @brief Get the encoder's supported encoder complexity range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Encoder capability pointer. Do not give a decoder capability pointer + * @param complexityRange Output parameter. Encoder complexity range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetEncoderComplexityRange(OH_AVCapability *capability, OH_AVRange *complexityRange); + +/** + * @brief Get the audio codec's supported sample rates. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Audio codec capability pointer. Do not give a video codec capability pointer + * @param sampleRates Output parameter. A pointer to the sample rates array + * @param sampleRateNum Output parameter. The element number of the sample rates array + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRates(OH_AVCapability *capability, const int32_t **sampleRates, + uint32_t *sampleRateNum); + +/** + * @brief Get the audio codec's supported audio channel count range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Audio codec capability pointer. Do not give a video codec capability pointer + * @param channelCountRange Output parameter. Audio channel count range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetAudioChannelCountRange(OH_AVCapability *capability, OH_AVRange *channelCountRange); + +/** + * @brief Get the video codec's supported video width alignment. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param widthAlignment Output parameter. Video width alignment + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoWidthAlignment(OH_AVCapability *capability, int32_t *widthAlignment); + +/** + * @brief Get the video codec's supported video height alignment. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param heightAlignment Output parameter. Video height alignment + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoHeightAlignment(OH_AVCapability *capability, int32_t *heightAlignment); + +/** + * @brief Get the video codec's supported video width range for a specific height. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability video codec capability pointer. Do not give an audio codec capability pointer + * @param height Vertical pixel number of the video + * @param widthRange Output parameter. Video width range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoWidthRangeForHeight(OH_AVCapability *capability, int32_t height, + OH_AVRange *widthRange); + +/** + * @brief Get the video codec's supported video height range for a specific width. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param width Horizontal pixel number of the video + * @param heightRange Output parameter. Video height range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoHeightRangeForWidth(OH_AVCapability *capability, int32_t width, + OH_AVRange *heightRange); + +/** + * @brief Get the video codec's supported video width range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. DO not give an audio codec capability pointer + * @param widthRange Output parameter. Video width range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoWidthRange(OH_AVCapability *capability, OH_AVRange *widthRange); + +/** + * @brief Get the video codec's supported video height range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param heightRange Output parameter. Video height range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoHeightRange(OH_AVCapability *capability, OH_AVRange *heightRange); + +/** + * @brief Check if the video codec supports the specific video size. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param width Horizontal pixel number of the video + * @param height Vertical pixel number of the video + * @return Returns true if the video size is supported, false if the video size is not supported + * @since 10 + */ +bool OH_AVCapability_IsVideoSizeSupported(OH_AVCapability *capability, int32_t width, int32_t height); + +/** + * @brief Get the video codec's supported video frame rate range. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param frameRateRange Output parameter. Video frame rate range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoFrameRateRange(OH_AVCapability *capability, OH_AVRange *frameRateRange); + +/** + * @brief Get the Video codec's supported video frame rate range for a specified video size. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param width Horizontal pixel number of the video + * @param height Vertical pixel number of the video + * @param frameRateRange Output parameter. Frame rate range + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoFrameRateRangeForSize(OH_AVCapability *capability, int32_t width, int32_t height, + OH_AVRange *frameRateRange); + +/** + * @brief Check if the video codec supports the specific combination of video size and frame rate. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param width Horizontal pixel number of the video + * @param height Vertical pixel number of the video + * @param frameRate Frame number per second + * @return Returns true if the combination of video size and frame rate is supported, + * false if it is not supported + * @since 10 + */ +bool OH_AVCapability_AreVideoSizeAndFrameRateSupported(OH_AVCapability *capability, int32_t width, int32_t height, + int32_t frameRate); + +/** + * @brief Get the video codec's supported video pixel format. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Video codec capability pointer. Do not give an audio codec capability pointer + * @param pixelFormats Output parameter. A pointer to the video pixel format array + * @param pixelFormatNum Output parameter. The element number of the pixel format array + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetVideoSupportedPixelFormats(OH_AVCapability *capability, const int32_t **pixelFormats, + uint32_t *pixelFormatNum); + +/** + * @brief Get the codec's supported profiles. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @param profiles Output parameter. A pointer to the profile array + * @param profileNum Output parameter. The element number of the profile array + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetSupportedProfiles(OH_AVCapability *capability, const int32_t **profiles, + uint32_t *profileNum); + +/** + * @brief Get codec's supported levels for a specific profile. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @param profile Codec profile + * @param levels Output parameter. A pointer to the level array + * @param levelNum Output parameter. The element number of the level array + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVCapability_GetSupportedLevelsForProfile(OH_AVCapability *capability, int32_t profile, + const int32_t **levels, uint32_t *levelNum); + +/** + * @brief Check if the codec supports the specific combination of the profile and level. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param capability Codec capability pointer + * @param profile Codec profile + * @param level Codec level + * @return Returns true if the combination of profile and level is supported, + * false if it is not supported + * @since 10 + */ +bool OH_AVCapability_AreProfileAndLevelSupported(OH_AVCapability *capability, int32_t profile, int32_t level); + +#ifdef __cplusplus +} +#endif #endif // NATIVE_AVCAPABILITY_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avcodec_audiodecoder.h b/multimedia/av_codec/native_avcodec_audiodecoder.h index bb62e8a8c20f4026b1cedd2cb9ffc4ccb7da7030..d6ec15da4485b1a9a16169fc13f08893c781fe79 100644 --- a/multimedia/av_codec/native_avcodec_audiodecoder.h +++ b/multimedia/av_codec/native_avcodec_audiodecoder.h @@ -1,224 +1,224 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCODEC_AUDIODECODER_H -#define NATIVE_AVCODEC_AUDIODECODER_H - -#include -#include -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" -#include "native_avcodec_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Creates an audio decoder instance from the mime type, which is recommended in most cases. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_AudioDecoder_CreateByMime(const char *mime); - -/** - * @brief Create an audio decoder instance through the audio decoder name. - * The premise of using this interface is to know the exact name of the decoder. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param name Audio codec name - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_AudioDecoder_CreateByName(const char *name); - -/** - * @brief Clear the internal resources of the decoder and destroy the decoder instance - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Destroy(OH_AVCodec *codec); - -/** - * @brief Set the asynchronous callback function so that your application - * can respond to the events generated by the audio decoder. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} - * @param userData User specific data - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); - -/** - * @brief To configure the audio decoder, typically, you need to configure the description information of the decoded - * audio track, which can be extracted from the container. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param format A pointer to an OH_AVFormat giving a description of the audio track to be decoded - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief To prepare the internal resources of the decoder, the Configure interface must be called - * before calling this interface. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Prepare(OH_AVCodec *codec); - -/** - * @brief Start the decoder, this interface must be called after the Prepare is successful. - * After being successfully started, the decoder will start reporting NeedInputData events. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Start(OH_AVCodec *codec); - -/** - * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start, - * but it should be noted that need to re-enter if the decoder has been input before - * Codec-Specific-Data. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Stop(OH_AVCodec *codec); - -/** - * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer - * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access - * the Buffers corresponding to these indexes. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_Flush(OH_AVCodec *codec); - -/** - * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again to - * configure the decoder instance. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ - -OH_AVErrCode OH_AudioDecoder_Reset(OH_AVCodec *codec); - -/** - * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} for details. - * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to - * be manually released by the caller - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns the OH_AVFormat handle pointer, the life cycle is refreshed with the next GetOutputMediaDescription, - * or destroyed with OH_AVCodec; - * @since 9 - * @version 1.0 - */ -OH_AVFormat *OH_AudioDecoder_GetOutputDescription(OH_AVCodec *codec); - -/** - * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. - * At the same time, incorrect parameter settings may cause decoding failure. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param format OH_AVFormat handle pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief Submit the input buffer filled with data to the audio decoder. The {@link OH_AVCodecOnNeedInputData} callback - * will report the available input buffer and the corresponding index value. Once the buffer with the specified index - * is submitted to the audio decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} - * callback is received again reporting that the buffer with the same index is available. In addition, for some - * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding - * process of the decoder. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer - * @param attr Information describing the data contained in the Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); - -/** - * @brief Return the processed output Buffer to the decoder. - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); - -/** - * @brief Check whether the current codec instance is valid. It can be used fault recovery or app - * switchback from the background - * @syscap SystemCapability.Multimedia.Media.AudioDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, - * false if the codec instance is invalid - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid); - -#ifdef __cplusplus -} -#endif +/* + * 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. + */ + +#ifndef NATIVE_AVCODEC_AUDIODECODER_H +#define NATIVE_AVCODEC_AUDIODECODER_H + +#include +#include +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" +#include "native_avcodec_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an audio decoder instance from the mime type, which is recommended in most cases. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_AudioDecoder_CreateByMime(const char *mime); + +/** + * @brief Create an audio decoder instance through the audio decoder name. + * The premise of using this interface is to know the exact name of the decoder. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param name Audio codec name + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_AudioDecoder_CreateByName(const char *name); + +/** + * @brief Clear the internal resources of the decoder and destroy the decoder instance + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Destroy(OH_AVCodec *codec); + +/** + * @brief Set the asynchronous callback function so that your application + * can respond to the events generated by the audio decoder. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} + * @param userData User specific data + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); + +/** + * @brief To configure the audio decoder, typically, you need to configure the description information of the decoded + * audio track, which can be extracted from the container. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param format A pointer to an OH_AVFormat giving a description of the audio track to be decoded + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief To prepare the internal resources of the decoder, the Configure interface must be called + * before calling this interface. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Prepare(OH_AVCodec *codec); + +/** + * @brief Start the decoder, this interface must be called after the Prepare is successful. + * After being successfully started, the decoder will start reporting NeedInputData events. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Start(OH_AVCodec *codec); + +/** + * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start, + * but it should be noted that need to re-enter if the decoder has been input before + * Codec-Specific-Data. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Stop(OH_AVCodec *codec); + +/** + * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer + * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access + * the Buffers corresponding to these indexes. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_Flush(OH_AVCodec *codec); + +/** + * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again to + * configure the decoder instance. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ + +OH_AVErrCode OH_AudioDecoder_Reset(OH_AVCodec *codec); + +/** + * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} for details. + * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to + * be manually released by the caller + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns the OH_AVFormat handle pointer, the life cycle is refreshed with the next GetOutputMediaDescription, + * or destroyed with OH_AVCodec; + * @since 9 + * @version 1.0 + */ +OH_AVFormat *OH_AudioDecoder_GetOutputDescription(OH_AVCodec *codec); + +/** + * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. + * At the same time, incorrect parameter settings may cause decoding failure. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param format OH_AVFormat handle pointer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief Submit the input buffer filled with data to the audio decoder. The {@link OH_AVCodecOnNeedInputData} callback + * will report the available input buffer and the corresponding index value. Once the buffer with the specified index + * is submitted to the audio decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} + * callback is received again reporting that the buffer with the same index is available. In addition, for some + * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding + * process of the decoder. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index Enter the index value corresponding to the Buffer + * @param attr Information describing the data contained in the Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); + +/** + * @brief Return the processed output Buffer to the decoder. + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); + +/** + * @brief Check whether the current codec instance is valid. It can be used fault recovery or app + * switchback from the background + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, + * false if the codec instance is invalid + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid); + +#ifdef __cplusplus +} +#endif #endif // NATIVE_AVCODEC_AUDIODECODER_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avcodec_audioencoder.h b/multimedia/av_codec/native_avcodec_audioencoder.h index 7493f69e06e3727fb2caa7433b8a2d4a116ef774..981e81b13b089a72f0e17fbf72d9f2c9500a1d47 100644 --- a/multimedia/av_codec/native_avcodec_audioencoder.h +++ b/multimedia/av_codec/native_avcodec_audioencoder.h @@ -1,218 +1,218 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCODEC_AUDIOENCODER_H -#define NATIVE_AVCODEC_AUDIOENCODER_H - -#include -#include -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" -#include "native_avcodec_base.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Creates an audio encoder instance from the mime type, this interface is recommended in most cases. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_AudioEncoder_CreateByMime(const char *mime); - -/** - * @brief Create an audio encoder instance through the audio encoder name. - * The premise of using this interface is to know the exact name of the encoder. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param name Audio encoder name - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_AudioEncoder_CreateByName(const char *name); - -/** - * @brief Clear the internal resources of the encoder and destroy the encoder instance - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Destroy(OH_AVCodec *codec); - -/** - * @brief Set the asynchronous callback function so that your application can respond to - * the events generated by the audio encoder. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} - * @param userData User specific data - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); - -/** - * @brief To configure the audio encoder, typically, you need to configure the description information of - * the encoded audio track. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param format OH_AVFormat handle pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief To prepare the internal resources of the encoder, - * the Configure interface must be called before calling this interface. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Prepare(OH_AVCodec *codec); - -/** - * @brief Start the encoder, this interface must be called after the Prepare is successful. - * After being successfully started, the encoder will start reporting NeedInputData events. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Start(OH_AVCodec *codec); - -/** - * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Stop(OH_AVCodec *codec); - -/** - * @brief Clear the input and output data buffered in the encoder. After this interface is called, - * all the Buffer indexes previously reported through the asynchronous callback will be invalidated, - * make sure not to access the Buffers corresponding to these indexes. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Flush(OH_AVCodec *codec); - -/** - * @brief Reset the encoder. To continue coding, you need to call the Configure interface - * again to configure the encoder instance. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_Reset(OH_AVCodec *codec); - -/** - * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details. - * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to - * be manually released by the caller. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns the OH_AVFormat handle pointer, the life cycle is refreshed with the next GetOutputMediaDescription, - * or destroyed with OH_AVCodec; - * @since 9 - * @version 1.0 - */ -OH_AVFormat *OH_AudioEncoder_GetOutputDescription(OH_AVCodec *codec); - -/** - * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started. - * At the same time, incorrect parameter settings may cause the encoding to fail. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param format OH_AVFormat handle pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief Submit the input buffer filled with data to the audio encoder. The {@link OH_AVCodecOnNeedInputData} - * callback will report the available input buffer and the corresponding index value. Once the buffer with the - * specified index is submitted to the audio encoder, the buffer cannot be accessed again until the - * callback is received again reporting that the buffer with the same index is available - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer - * @param attr Information describing the data contained in the Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); - -/** - * @brief Return the processed output Buffer to the encoder. - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_AudioEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); - -/** - * @brief Check whether the current codec instance is valid. It can be used fault recovery or app - * switchback from the background - * @syscap SystemCapability.Multimedia.Media.AudioEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, - * false if the codec instance is invalid - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AudioEncoder_IsValid(OH_AVCodec *codec, bool *isValid); - -#ifdef __cplusplus -} -#endif +/* + * 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. + */ + +#ifndef NATIVE_AVCODEC_AUDIOENCODER_H +#define NATIVE_AVCODEC_AUDIOENCODER_H + +#include +#include +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" +#include "native_avcodec_base.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an audio encoder instance from the mime type, this interface is recommended in most cases. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_AudioEncoder_CreateByMime(const char *mime); + +/** + * @brief Create an audio encoder instance through the audio encoder name. + * The premise of using this interface is to know the exact name of the encoder. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param name Audio encoder name + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_AudioEncoder_CreateByName(const char *name); + +/** + * @brief Clear the internal resources of the encoder and destroy the encoder instance + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Destroy(OH_AVCodec *codec); + +/** + * @brief Set the asynchronous callback function so that your application can respond to + * the events generated by the audio encoder. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} + * @param userData User specific data + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); + +/** + * @brief To configure the audio encoder, typically, you need to configure the description information of + * the encoded audio track. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param format OH_AVFormat handle pointer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief To prepare the internal resources of the encoder, + * the Configure interface must be called before calling this interface. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Prepare(OH_AVCodec *codec); + +/** + * @brief Start the encoder, this interface must be called after the Prepare is successful. + * After being successfully started, the encoder will start reporting NeedInputData events. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Start(OH_AVCodec *codec); + +/** + * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Stop(OH_AVCodec *codec); + +/** + * @brief Clear the input and output data buffered in the encoder. After this interface is called, + * all the Buffer indexes previously reported through the asynchronous callback will be invalidated, + * make sure not to access the Buffers corresponding to these indexes. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Flush(OH_AVCodec *codec); + +/** + * @brief Reset the encoder. To continue coding, you need to call the Configure interface + * again to configure the encoder instance. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_Reset(OH_AVCodec *codec); + +/** + * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details. + * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to + * be manually released by the caller. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns the OH_AVFormat handle pointer, the life cycle is refreshed with the next GetOutputMediaDescription, + * or destroyed with OH_AVCodec; + * @since 9 + * @version 1.0 + */ +OH_AVFormat *OH_AudioEncoder_GetOutputDescription(OH_AVCodec *codec); + +/** + * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started. + * At the same time, incorrect parameter settings may cause the encoding to fail. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param format OH_AVFormat handle pointer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief Submit the input buffer filled with data to the audio encoder. The {@link OH_AVCodecOnNeedInputData} + * callback will report the available input buffer and the corresponding index value. Once the buffer with the + * specified index is submitted to the audio encoder, the buffer cannot be accessed again until the + * callback is received again reporting that the buffer with the same index is available + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index Enter the index value corresponding to the Buffer + * @param attr Information describing the data contained in the Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); + +/** + * @brief Return the processed output Buffer to the encoder. + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_AudioEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); + +/** + * @brief Check whether the current codec instance is valid. It can be used fault recovery or app + * switchback from the background + * @syscap SystemCapability.Multimedia.Media.AudioEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, + * false if the codec instance is invalid + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AudioEncoder_IsValid(OH_AVCodec *codec, bool *isValid); + +#ifdef __cplusplus +} +#endif #endif // NATIVE_AVCODEC_AUDIOENCODER_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index bedee400433dfc650511679824a8af35d9e1868d..aa4172916f838fba967709eac8affb3a37ea628b 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1,450 +1,450 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCODEC_BASE_H -#define NATIVE_AVCODEC_BASE_H - -#include -#include -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct NativeWindow OHNativeWindow; -typedef struct OH_AVCodec OH_AVCodec; - -/** - * @brief Enumerate the categories of OH_AVCodec's Buffer tags - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -typedef enum OH_AVCodecBufferFlags { - AVCODEC_BUFFER_FLAGS_NONE = 0, - /* Indicates that the Buffer is an End-of-Stream frame */ - AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, - /* Indicates that the Buffer contains keyframes */ - AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, - /* Indicates that the data contained in the Buffer is only part of a frame */ - AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2, - /* Indicates that the Buffer contains Codec-Specific-Data */ - AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3, -} OH_AVCodecBufferFlags; - -/** - * @brief Define the Buffer description information of OH_AVCodec - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -typedef struct OH_AVCodecBufferAttr { - /* Presentation timestamp of this Buffer in microseconds */ - int64_t pts; - /* The size of the data contained in the Buffer in bytes */ - int32_t size; - /* The starting offset of valid data in this Buffer */ - int32_t offset; - /* The flags this Buffer has, which is also a combination of multiple {@link OH_AVCodecBufferFlags}. */ - uint32_t flags; -} OH_AVCodecBufferAttr; - -/** - * @brief When an error occurs in the running of the OH_AVCodec instance, the function pointer will be called - * to report specific error information. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param codec OH_AVCodec instance - * @param errorCode specific error code - * @param userData User specific data - * @since 9 - * @version 1.0 - */ -typedef void (*OH_AVCodecOnError)(OH_AVCodec *codec, int32_t errorCode, void *userData); - -/** - * @brief When the output stream changes, the function pointer will be called to report the new stream description - * information. It should be noted that the life cycle of the OH_AVFormat pointer - * is only valid when the function pointer is called, and it is forbidden to continue to access after the call ends. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param codec OH_AVCodec instance - * @param format New output stream description information - * @param userData User specific data - * @since 9 - * @version 1.0 - */ -typedef void (*OH_AVCodecOnStreamChanged)(OH_AVCodec *codec, OH_AVFormat *format, void *userData); - -/** - * @brief When OH_AVCodec needs new input data during the running process, - * the function pointer will be called and carry an available Buffer to fill in the new input data. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param codec OH_AVCodec instance - * @param index The index corresponding to the newly available input buffer. - * @param data New available input buffer. - * @param userData User specific data - * @since 9 - * @version 1.0 - */ -typedef void (*OH_AVCodecOnNeedInputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData); - -/** - * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be - * called and carry a Buffer containing the new output data. It should be noted that the life cycle of the - * OH_AVCodecBufferAttr pointer is only valid when the function pointer is called. , which prohibits continued - * access after the call ends. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param codec OH_AVCodec instance - * @param index The index corresponding to the new output Buffer. - * @param data Buffer containing the new output data - * @param attr The description of the new output Buffer, please refer to {@link OH_AVCodecBufferAttr} - * @param userData specified data - * @since 9 - * @version 1.0 - */ -typedef void (*OH_AVCodecOnNewOutputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, - OH_AVCodecBufferAttr *attr, void *userData); - -/** - * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this - * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the - * normal operation of OH_AVCodec. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError} - * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged} - * @param onNeedInputData Monitoring codec requires input data, refer to {@link OH_AVCodecOnNeedInputData} - * @param onNeedInputData Monitor codec to generate output data, refer to {@link onNeedInputData} - * @since 9 - * @version 1.0 - */ -typedef struct OH_AVCodecAsyncCallback { - OH_AVCodecOnError onError; - OH_AVCodecOnStreamChanged onStreamChanged; - OH_AVCodecOnNeedInputData onNeedInputData; - OH_AVCodecOnNewOutputData onNeedOutputData; -} OH_AVCodecAsyncCallback; - -/** - * @brief Enumerates the MIME types of audio and video codecs - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -extern const char *OH_AVCODEC_MIMETYPE_VIDEO_AVC; -extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AAC; - -/** - * @brief Enumerates the MIME types of audio and video codecs - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -extern const char *OH_AVCODEC_MIMETYPE_AUDIO_FLAC; -extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VORBIS; -extern const char *OH_AVCODEC_MIMETYPE_AUDIO_MPEG; -extern const char *OH_AVCODEC_MIMETYPE_VIDEO_HEVC; -extern const char *OH_AVCODEC_MIMETYPE_VIDEO_MPEG4; -extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG; -extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG; -extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP; - -/** - * @brief The extra data's key of surface Buffer - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -/* Key for timeStamp in surface's extraData, value type is int64 */ -extern const char *OH_ED_KEY_TIME_STAMP; -/* Key for endOfStream in surface's extraData, value type is bool */ -extern const char *OH_ED_KEY_EOS; - -/** - * @brief Provides the uniform container for storing the media description. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -/* Key for track type, value type is uint8_t, see @OH_MediaType. */ -extern const char *OH_MD_KEY_TRACK_TYPE; -/* Key for codec mime type, value type is string. */ -extern const char *OH_MD_KEY_CODEC_MIME; -/* Key for duration, value type is int64_t. */ -extern const char *OH_MD_KEY_DURATION; -/* Key for bitrate, value type is uint32_t. */ -extern const char *OH_MD_KEY_BITRATE; -/* Key for max input size, value type is uint32_t */ -extern const char *OH_MD_KEY_MAX_INPUT_SIZE; -/* Key for video width, value type is uint32_t */ -extern const char *OH_MD_KEY_WIDTH; -/* Key for video height, value type is uint32_t */ -extern const char *OH_MD_KEY_HEIGHT; -/* Key for video pixel format, value type is int32_t, see @OH_AVPixelFormat */ -extern const char *OH_MD_KEY_PIXEL_FORMAT; -/* key for audio raw format, value type is uint32_t , see @AudioSampleFormat */ -extern const char *OH_MD_KEY_AUDIO_SAMPLE_FORMAT; -/* Key for video frame rate, value type is double. */ -extern const char *OH_MD_KEY_FRAME_RATE; -/* video encode bitrate mode, the value type is int32_t, see @OH_VideoEncodeBitrateMode */ -extern const char *OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE; -/* encode profile, the value type is number. see @OH_AVCProfile, OH_HEVCProfile, OH_AACProfile. */ -extern const char *OH_MD_KEY_PROFILE; -/* Key for audio channel count, value type is uint32_t */ -extern const char *OH_MD_KEY_AUD_CHANNEL_COUNT; -/* Key for audio sample rate, value type is uint32_t */ -extern const char *OH_MD_KEY_AUD_SAMPLE_RATE; -/* Key for the interval of key frame. value type is int32_t, the unit is milliseconds. */ -extern const char *OH_MD_KEY_I_FRAME_INTERVAL; -/* Key of the surface rotation angle. value type is int32_t: should be {0, 90, 180, 270}, default is 0. */ -extern const char *OH_MD_KEY_ROTATION; - -/** - * @brief Provides the uniform container for storing the media description. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -/* Key for video YUV value range flag, value type is boolean */ -extern const char *OH_MD_KEY_RANGE_FLAG; -/* Key for video color primaries, value type is int32_t, see @OH_ColorPrimary */ -extern const char *OH_MD_KEY_COLOR_PRIMARIES; -/* Key for video transfer characteristics, value type is int32_t, see @OH_TransferCharacteristic */ -extern const char *OH_MD_KEY_TRANSFER_CHARACTERISTICS; -/* Key for video matrix coefficients, value type is int32_t, see @OH_MatrixCoefficient */ -extern const char *OH_MD_KEY_MATRIX_COEFFICIENTS; -/* Key for the request an I-Frame immediately, value type is boolean */ -extern const char *OH_MD_KEY_REQUEST_I_FRAME; -/* Key for the desired encoding quality, value type is uint32_t, this key is only - * supported for encoders that are configured in constant quality mode */ -extern const char *OH_MD_KEY_QUALITY; -/* Key of the codec specific data. value type is a uint8_t pointer */ -extern const char *OH_MD_KEY_CODEC_CONFIG; -/* source format Key for title, value type is string */ -extern const char *OH_MD_KEY_TITLE; -/* source format Key for artist, value type is string */ -extern const char *OH_MD_KEY_ARTIST; -/* source format Key for album, value type is string */ -extern const char *OH_MD_KEY_ALBUM; -/* source format Key for album artist, value type is string */ -extern const char *OH_MD_KEY_ALBUM_ARTIST; -/* source format Key for date, value type is string */ -extern const char *OH_MD_KEY_DATE; -/* source format Key for comment, value type is string */ -extern const char *OH_MD_KEY_COMMENT; -/* source format Key for genre, value type is string */ -extern const char *OH_MD_KEY_GENRE; -/* source format Key for copyright, value type is string */ -extern const char *OH_MD_KEY_COPYRIGHT; -/* source format Key for language, value type is string */ -extern const char *OH_MD_KEY_LANGUAGE; -/* source format Key for description, value type is string */ -extern const char *OH_MD_KEY_DESCRIPTION; -/* source format Key for lyrics, value type is string */ -extern const char *OH_MD_KEY_LYRICS; -/* source format Key for track count, value type is uint32_t */ -extern const char *OH_MD_KEY_TRACK_COUNT; -/* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */ -extern const char *OH_MD_KEY_CHANNEL_LAYOUT; -/* Key for bits per coded sample, value type is uint32_t, supported for flac encoder, see @OH_BitsPerSample */ -extern const char *OH_MD_KEY_BITS_PER_CODED_SAMPLE; -/* Key for the aac format, value type is uint32_t, supported for aac decoder */ -extern const char *OH_MD_KEY_AAC_IS_ADTS; -/* Key for aac sbr mode, value type is uint32_t, supported for aac encoder */ -extern const char *OH_MD_KEY_SBR; -/* Key for flac compliance level, value type is int32_t */ -extern const char *OH_MD_KEY_COMPLIANCE_LEVEL; -/* Key for vorbis identification header, value type is a uint8_t pointer, supported only for vorbis decoder */ -extern const char *OH_MD_KEY_IDENTIFICATION_HEADER; -/* Key for vorbis setup header, value type is a uint8_t pointer, supported only for vorbis decoder */ -extern const char *OH_MD_KEY_SETUP_HEADER; -/* Key for video scale type, value type is int32_t, see @OH_ScalingMode */ -extern const char *OH_MD_KEY_SCALING_MODE; -/* Key for max input buffer count, value type is int32_t */ -extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT; -/* Key for max output buffer count, value type is int32_t */ -extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT; - -/** - * @brief Media type. - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -typedef enum OH_MediaType { - /* track is audio. */ - MEDIA_TYPE_AUD = 0, - /* track is video. */ - MEDIA_TYPE_VID = 1, -} OH_MediaType; - -/** - * @brief AAC Profile - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -typedef enum OH_AACProfile { - AAC_PROFILE_LC = 0, -} OH_AACProfile; - -/** - * @brief AVC Profile - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 9 - * @version 1.0 - */ -typedef enum OH_AVCProfile { - AVC_PROFILE_BASELINE = 0, - AVC_PROFILE_HIGH = 4, - AVC_PROFILE_MAIN = 8, -} OH_AVCProfile; - -/** - * @brief Enumerates the muxer output file format - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_AVOutputFormat { - AV_OUTPUT_FORMAT_DEFAULT = 0, - AV_OUTPUT_FORMAT_MPEG_4 = 2, - AV_OUTPUT_FORMAT_M4A = 6, -} OH_AVOutputFormat; - -/** - * @brief Seek Mode - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_AVSeekMode { - /* seek to sync sample after the time */ - SEEK_MODE_NEXT_SYNC = 0, - /* seek to sync sample before the time */ - SEEK_MODE_PREVIOUS_SYNC, - /* seek to sync sample closest to time */ - SEEK_MODE_CLOSEST_SYNC, -} OH_AVSeekMode; - -/** - * @brief HEVC Profile - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_HEVCProfile { - HEVC_PROFILE_MAIN = 0, - HEVC_PROFILE_MAIN_10 = 1, - HEVC_PROFILE_MAIN_STILL = 2, - HEVC_PROFILE_MAIN_10_HDR10 = 3, - HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4, -} OH_HEVCProfile; - -/** - * @brief Color Primary - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_ColorPrimary { - COLOR_PRIMARY_BT709 = 1, - COLOR_PRIMARY_UNSPECIFIED = 2, - COLOR_PRIMARY_BT470_M = 4, - COLOR_PRIMARY_BT601_625 = 5, - COLOR_PRIMARY_BT601_525 = 6, - COLOR_PRIMARY_SMPTE_ST240 = 7, - COLOR_PRIMARY_GENERIC_FILM = 8, - COLOR_PRIMARY_BT2020 = 9, - COLOR_PRIMARY_SMPTE_ST428 = 10, - COLOR_PRIMARY_P3DCI = 11, - COLOR_PRIMARY_P3D65 = 12, -} OH_ColorPrimary; - -/** - * @brief Transfer Characteristic - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_TransferCharacteristic { - TRANSFER_CHARACTERISTIC_BT709 = 1, - TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2, - TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4, - TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5, - TRANSFER_CHARACTERISTIC_BT601 = 6, - TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7, - TRANSFER_CHARACTERISTIC_LINEAR = 8, - TRANSFER_CHARACTERISTIC_LOG = 9, - TRANSFER_CHARACTERISTIC_LOG_SQRT = 10, - TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11, - TRANSFER_CHARACTERISTIC_BT1361 = 12, - TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13, - TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14, - TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15, - TRANSFER_CHARACTERISTIC_PQ = 16, - TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17, - TRANSFER_CHARACTERISTIC_HLG = 18, -} OH_TransferCharacteristic; - -/** - * @brief Matrix Coefficient - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_MatrixCoefficient { - MATRIX_COEFFICIENT_IDENTITY = 0, - MATRIX_COEFFICIENT_BT709 = 1, - MATRIX_COEFFICIENT_UNSPECIFIED = 2, - MATRIX_COEFFICIENT_FCC = 4, - MATRIX_COEFFICIENT_BT601_625 = 5, - MATRIX_COEFFICIENT_BT601_525 = 6, - MATRIX_COEFFICIENT_SMPTE_ST240 = 7, - MATRIX_COEFFICIENT_YCGCO = 8, - MATRIX_COEFFICIENT_BT2020_NCL = 9, - MATRIX_COEFFICIENT_BT2020_CL = 10, - MATRIX_COEFFICIENT_SMPTE_ST2085 = 11, - MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12, - MATRIX_COEFFICIENT_CHROMATICITY_CL = 13, - MATRIX_COEFFICIENT_ICTCP = 14, -} OH_MatrixCoefficient; - -/** - * @brief Scaling Mode - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_ScalingMode { - SCALING_MODE_SCALE_TO_WINDOW = 1, - SCALING_MODE_SCALE_CROP = 2, -} OH_ScalingMode; - -/** - * @brief enum Audio Bits Per Coded Sample - * @syscap SystemCapability.Multimedia.Media.CodecBase - * @since 10 - */ -typedef enum OH_BitsPerSample { - SAMPLE_U8 = 0, - SAMPLE_S16LE = 1, - SAMPLE_S24LE = 2, - SAMPLE_S32LE = 3, - SAMPLE_F32LE = 4, - SAMPLE_U8P = 5, - SAMPLE_S16P = 6, - SAMPLE_S24P = 7, - SAMPLE_S32P = 8, - SAMPLE_F32P = 9, - INVALID_WIDTH = -1 -} OH_BitsPerSample; -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_AVCODEC_BASE_H +/* + * 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. + */ + +#ifndef NATIVE_AVCODEC_BASE_H +#define NATIVE_AVCODEC_BASE_H + +#include +#include +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct NativeWindow OHNativeWindow; +typedef struct OH_AVCodec OH_AVCodec; + +/** + * @brief Enumerate the categories of OH_AVCodec's Buffer tags + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +typedef enum OH_AVCodecBufferFlags { + AVCODEC_BUFFER_FLAGS_NONE = 0, + /* Indicates that the Buffer is an End-of-Stream frame */ + AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, + /* Indicates that the Buffer contains keyframes */ + AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, + /* Indicates that the data contained in the Buffer is only part of a frame */ + AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2, + /* Indicates that the Buffer contains Codec-Specific-Data */ + AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3, +} OH_AVCodecBufferFlags; + +/** + * @brief Define the Buffer description information of OH_AVCodec + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +typedef struct OH_AVCodecBufferAttr { + /* Presentation timestamp of this Buffer in microseconds */ + int64_t pts; + /* The size of the data contained in the Buffer in bytes */ + int32_t size; + /* The starting offset of valid data in this Buffer */ + int32_t offset; + /* The flags this Buffer has, which is also a combination of multiple {@link OH_AVCodecBufferFlags}. */ + uint32_t flags; +} OH_AVCodecBufferAttr; + +/** + * @brief When an error occurs in the running of the OH_AVCodec instance, the function pointer will be called + * to report specific error information. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param codec OH_AVCodec instance + * @param errorCode specific error code + * @param userData User specific data + * @since 9 + * @version 1.0 + */ +typedef void (*OH_AVCodecOnError)(OH_AVCodec *codec, int32_t errorCode, void *userData); + +/** + * @brief When the output stream changes, the function pointer will be called to report the new stream description + * information. It should be noted that the life cycle of the OH_AVFormat pointer + * is only valid when the function pointer is called, and it is forbidden to continue to access after the call ends. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param codec OH_AVCodec instance + * @param format New output stream description information + * @param userData User specific data + * @since 9 + * @version 1.0 + */ +typedef void (*OH_AVCodecOnStreamChanged)(OH_AVCodec *codec, OH_AVFormat *format, void *userData); + +/** + * @brief When OH_AVCodec needs new input data during the running process, + * the function pointer will be called and carry an available Buffer to fill in the new input data. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param codec OH_AVCodec instance + * @param index The index corresponding to the newly available input buffer. + * @param data New available input buffer. + * @param userData User specific data + * @since 9 + * @version 1.0 + */ +typedef void (*OH_AVCodecOnNeedInputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData); + +/** + * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be + * called and carry a Buffer containing the new output data. It should be noted that the life cycle of the + * OH_AVCodecBufferAttr pointer is only valid when the function pointer is called. , which prohibits continued + * access after the call ends. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param codec OH_AVCodec instance + * @param index The index corresponding to the new output Buffer. + * @param data Buffer containing the new output data + * @param attr The description of the new output Buffer, please refer to {@link OH_AVCodecBufferAttr} + * @param userData specified data + * @since 9 + * @version 1.0 + */ +typedef void (*OH_AVCodecOnNewOutputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, + OH_AVCodecBufferAttr *attr, void *userData); + +/** + * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this + * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the + * normal operation of OH_AVCodec. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError} + * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged} + * @param onNeedInputData Monitoring codec requires input data, refer to {@link OH_AVCodecOnNeedInputData} + * @param onNeedInputData Monitor codec to generate output data, refer to {@link onNeedInputData} + * @since 9 + * @version 1.0 + */ +typedef struct OH_AVCodecAsyncCallback { + OH_AVCodecOnError onError; + OH_AVCodecOnStreamChanged onStreamChanged; + OH_AVCodecOnNeedInputData onNeedInputData; + OH_AVCodecOnNewOutputData onNeedOutputData; +} OH_AVCodecAsyncCallback; + +/** + * @brief Enumerates the MIME types of audio and video codecs + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +extern const char *OH_AVCODEC_MIMETYPE_VIDEO_AVC; +extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AAC; + +/** + * @brief Enumerates the MIME types of audio and video codecs + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +extern const char *OH_AVCODEC_MIMETYPE_AUDIO_FLAC; +extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VORBIS; +extern const char *OH_AVCODEC_MIMETYPE_AUDIO_MPEG; +extern const char *OH_AVCODEC_MIMETYPE_VIDEO_HEVC; +extern const char *OH_AVCODEC_MIMETYPE_VIDEO_MPEG4; +extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG; +extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG; +extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP; + +/** + * @brief The extra data's key of surface Buffer + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +/* Key for timeStamp in surface's extraData, value type is int64 */ +extern const char *OH_ED_KEY_TIME_STAMP; +/* Key for endOfStream in surface's extraData, value type is bool */ +extern const char *OH_ED_KEY_EOS; + +/** + * @brief Provides the uniform container for storing the media description. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +/* Key for track type, value type is uint8_t, see @OH_MediaType. */ +extern const char *OH_MD_KEY_TRACK_TYPE; +/* Key for codec mime type, value type is string. */ +extern const char *OH_MD_KEY_CODEC_MIME; +/* Key for duration, value type is int64_t. */ +extern const char *OH_MD_KEY_DURATION; +/* Key for bitrate, value type is uint32_t. */ +extern const char *OH_MD_KEY_BITRATE; +/* Key for max input size, value type is uint32_t */ +extern const char *OH_MD_KEY_MAX_INPUT_SIZE; +/* Key for video width, value type is uint32_t */ +extern const char *OH_MD_KEY_WIDTH; +/* Key for video height, value type is uint32_t */ +extern const char *OH_MD_KEY_HEIGHT; +/* Key for video pixel format, value type is int32_t, see @OH_AVPixelFormat */ +extern const char *OH_MD_KEY_PIXEL_FORMAT; +/* key for audio raw format, value type is uint32_t , see @AudioSampleFormat */ +extern const char *OH_MD_KEY_AUDIO_SAMPLE_FORMAT; +/* Key for video frame rate, value type is double. */ +extern const char *OH_MD_KEY_FRAME_RATE; +/* video encode bitrate mode, the value type is int32_t, see @OH_VideoEncodeBitrateMode */ +extern const char *OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE; +/* encode profile, the value type is number. see @OH_AVCProfile, OH_HEVCProfile, OH_AACProfile. */ +extern const char *OH_MD_KEY_PROFILE; +/* Key for audio channel count, value type is uint32_t */ +extern const char *OH_MD_KEY_AUD_CHANNEL_COUNT; +/* Key for audio sample rate, value type is uint32_t */ +extern const char *OH_MD_KEY_AUD_SAMPLE_RATE; +/* Key for the interval of key frame. value type is int32_t, the unit is milliseconds. */ +extern const char *OH_MD_KEY_I_FRAME_INTERVAL; +/* Key of the surface rotation angle. value type is int32_t: should be {0, 90, 180, 270}, default is 0. */ +extern const char *OH_MD_KEY_ROTATION; + +/** + * @brief Provides the uniform container for storing the media description. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +/* Key for video YUV value range flag, value type is boolean */ +extern const char *OH_MD_KEY_RANGE_FLAG; +/* Key for video color primaries, value type is int32_t, see @OH_ColorPrimary */ +extern const char *OH_MD_KEY_COLOR_PRIMARIES; +/* Key for video transfer characteristics, value type is int32_t, see @OH_TransferCharacteristic */ +extern const char *OH_MD_KEY_TRANSFER_CHARACTERISTICS; +/* Key for video matrix coefficients, value type is int32_t, see @OH_MatrixCoefficient */ +extern const char *OH_MD_KEY_MATRIX_COEFFICIENTS; +/* Key for the request an I-Frame immediately, value type is boolean */ +extern const char *OH_MD_KEY_REQUEST_I_FRAME; +/* Key for the desired encoding quality, value type is uint32_t, this key is only + * supported for encoders that are configured in constant quality mode */ +extern const char *OH_MD_KEY_QUALITY; +/* Key of the codec specific data. value type is a uint8_t pointer */ +extern const char *OH_MD_KEY_CODEC_CONFIG; +/* source format Key for title, value type is string */ +extern const char *OH_MD_KEY_TITLE; +/* source format Key for artist, value type is string */ +extern const char *OH_MD_KEY_ARTIST; +/* source format Key for album, value type is string */ +extern const char *OH_MD_KEY_ALBUM; +/* source format Key for album artist, value type is string */ +extern const char *OH_MD_KEY_ALBUM_ARTIST; +/* source format Key for date, value type is string */ +extern const char *OH_MD_KEY_DATE; +/* source format Key for comment, value type is string */ +extern const char *OH_MD_KEY_COMMENT; +/* source format Key for genre, value type is string */ +extern const char *OH_MD_KEY_GENRE; +/* source format Key for copyright, value type is string */ +extern const char *OH_MD_KEY_COPYRIGHT; +/* source format Key for language, value type is string */ +extern const char *OH_MD_KEY_LANGUAGE; +/* source format Key for description, value type is string */ +extern const char *OH_MD_KEY_DESCRIPTION; +/* source format Key for lyrics, value type is string */ +extern const char *OH_MD_KEY_LYRICS; +/* source format Key for track count, value type is uint32_t */ +extern const char *OH_MD_KEY_TRACK_COUNT; +/* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */ +extern const char *OH_MD_KEY_CHANNEL_LAYOUT; +/* Key for bits per coded sample, value type is uint32_t, supported for flac encoder, see @OH_BitsPerSample */ +extern const char *OH_MD_KEY_BITS_PER_CODED_SAMPLE; +/* Key for the aac format, value type is uint32_t, supported for aac decoder */ +extern const char *OH_MD_KEY_AAC_IS_ADTS; +/* Key for aac sbr mode, value type is uint32_t, supported for aac encoder */ +extern const char *OH_MD_KEY_SBR; +/* Key for flac compliance level, value type is int32_t */ +extern const char *OH_MD_KEY_COMPLIANCE_LEVEL; +/* Key for vorbis identification header, value type is a uint8_t pointer, supported only for vorbis decoder */ +extern const char *OH_MD_KEY_IDENTIFICATION_HEADER; +/* Key for vorbis setup header, value type is a uint8_t pointer, supported only for vorbis decoder */ +extern const char *OH_MD_KEY_SETUP_HEADER; +/* Key for video scale type, value type is int32_t, see @OH_ScalingMode */ +extern const char *OH_MD_KEY_SCALING_MODE; +/* Key for max input buffer count, value type is int32_t */ +extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT; +/* Key for max output buffer count, value type is int32_t */ +extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT; + +/** + * @brief Media type. + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +typedef enum OH_MediaType { + /* track is audio. */ + MEDIA_TYPE_AUD = 0, + /* track is video. */ + MEDIA_TYPE_VID = 1, +} OH_MediaType; + +/** + * @brief AAC Profile + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +typedef enum OH_AACProfile { + AAC_PROFILE_LC = 0, +} OH_AACProfile; + +/** + * @brief AVC Profile + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 9 + * @version 1.0 + */ +typedef enum OH_AVCProfile { + AVC_PROFILE_BASELINE = 0, + AVC_PROFILE_HIGH = 4, + AVC_PROFILE_MAIN = 8, +} OH_AVCProfile; + +/** + * @brief Enumerates the muxer output file format + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_AVOutputFormat { + AV_OUTPUT_FORMAT_DEFAULT = 0, + AV_OUTPUT_FORMAT_MPEG_4 = 2, + AV_OUTPUT_FORMAT_M4A = 6, +} OH_AVOutputFormat; + +/** + * @brief Seek Mode + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_AVSeekMode { + /* seek to sync sample after the time */ + SEEK_MODE_NEXT_SYNC = 0, + /* seek to sync sample before the time */ + SEEK_MODE_PREVIOUS_SYNC, + /* seek to sync sample closest to time */ + SEEK_MODE_CLOSEST_SYNC, +} OH_AVSeekMode; + +/** + * @brief HEVC Profile + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_HEVCProfile { + HEVC_PROFILE_MAIN = 0, + HEVC_PROFILE_MAIN_10 = 1, + HEVC_PROFILE_MAIN_STILL = 2, + HEVC_PROFILE_MAIN_10_HDR10 = 3, + HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4, +} OH_HEVCProfile; + +/** + * @brief Color Primary + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_ColorPrimary { + COLOR_PRIMARY_BT709 = 1, + COLOR_PRIMARY_UNSPECIFIED = 2, + COLOR_PRIMARY_BT470_M = 4, + COLOR_PRIMARY_BT601_625 = 5, + COLOR_PRIMARY_BT601_525 = 6, + COLOR_PRIMARY_SMPTE_ST240 = 7, + COLOR_PRIMARY_GENERIC_FILM = 8, + COLOR_PRIMARY_BT2020 = 9, + COLOR_PRIMARY_SMPTE_ST428 = 10, + COLOR_PRIMARY_P3DCI = 11, + COLOR_PRIMARY_P3D65 = 12, +} OH_ColorPrimary; + +/** + * @brief Transfer Characteristic + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_TransferCharacteristic { + TRANSFER_CHARACTERISTIC_BT709 = 1, + TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2, + TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4, + TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5, + TRANSFER_CHARACTERISTIC_BT601 = 6, + TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7, + TRANSFER_CHARACTERISTIC_LINEAR = 8, + TRANSFER_CHARACTERISTIC_LOG = 9, + TRANSFER_CHARACTERISTIC_LOG_SQRT = 10, + TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11, + TRANSFER_CHARACTERISTIC_BT1361 = 12, + TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13, + TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14, + TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15, + TRANSFER_CHARACTERISTIC_PQ = 16, + TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17, + TRANSFER_CHARACTERISTIC_HLG = 18, +} OH_TransferCharacteristic; + +/** + * @brief Matrix Coefficient + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_MatrixCoefficient { + MATRIX_COEFFICIENT_IDENTITY = 0, + MATRIX_COEFFICIENT_BT709 = 1, + MATRIX_COEFFICIENT_UNSPECIFIED = 2, + MATRIX_COEFFICIENT_FCC = 4, + MATRIX_COEFFICIENT_BT601_625 = 5, + MATRIX_COEFFICIENT_BT601_525 = 6, + MATRIX_COEFFICIENT_SMPTE_ST240 = 7, + MATRIX_COEFFICIENT_YCGCO = 8, + MATRIX_COEFFICIENT_BT2020_NCL = 9, + MATRIX_COEFFICIENT_BT2020_CL = 10, + MATRIX_COEFFICIENT_SMPTE_ST2085 = 11, + MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12, + MATRIX_COEFFICIENT_CHROMATICITY_CL = 13, + MATRIX_COEFFICIENT_ICTCP = 14, +} OH_MatrixCoefficient; + +/** + * @brief Scaling Mode + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_ScalingMode { + SCALING_MODE_SCALE_TO_WINDOW = 1, + SCALING_MODE_SCALE_CROP = 2, +} OH_ScalingMode; + +/** + * @brief enum Audio Bits Per Coded Sample + * @syscap SystemCapability.Multimedia.Media.CodecBase + * @since 10 + */ +typedef enum OH_BitsPerSample { + SAMPLE_U8 = 0, + SAMPLE_S16LE = 1, + SAMPLE_S24LE = 2, + SAMPLE_S32LE = 3, + SAMPLE_F32LE = 4, + SAMPLE_U8P = 5, + SAMPLE_S16P = 6, + SAMPLE_S24P = 7, + SAMPLE_S32P = 8, + SAMPLE_F32P = 9, + INVALID_WIDTH = -1 +} OH_BitsPerSample; +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVCODEC_BASE_H diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index 3bc557751bb5aef040fedc6c4651f7c988315fc3..626c6a02e02bdb17e6e28ef6b9618c7a9c9f258f 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -1,249 +1,249 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCODEC_VIDEODECODER_H -#define NATIVE_AVCODEC_VIDEODECODER_H - -#include -#include -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" -#include "native_avcodec_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Creates a video decoder instance from the mime type, which is recommended in most cases. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_VideoDecoder_CreateByMime(const char *mime); - -/** - * @brief Create a video decoder instance through the video decoder name. - * The premise of using this interface is to know the exact name of the decoder. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param name video codec name - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_VideoDecoder_CreateByName(const char *name); - -/** - * @brief Clear the internal resources of the decoder and destroy the decoder instance - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Destroy(OH_AVCodec *codec); - -/** - * @brief Set the asynchronous callback function so that your application can respond to the events - * generated by the video decoder. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} - * @param userData User specific data - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); - -/** - * @brief Specify the output Surface to provide video decoding output, - * this interface must be called before Prepare is called - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *window); - -/** - * @brief To configure the video decoder, typically, you need to configure the description information of the decoded - * video track, which can be extracted from the container. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief To prepare the internal resources of the decoder, the Configure interface must be called before - * calling this interface. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); - -/** - * @brief Start the decoder, this interface must be called after the Prepare is successful. - * After being successfully started, the decoder will start reporting NeedInputData events. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec); - -/** - * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start, - * but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Stop(OH_AVCodec *codec); - -/** - * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer - * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access - * the Buffers corresponding to these indexes. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Flush(OH_AVCodec *codec); - -/** - * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again - * to configure the decoder instance. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_Reset(OH_AVCodec *codec); - -/** - * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} - * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs - * to be manually released by the caller. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns a pointer to an OH_AVFormat instance - * @since 9 - * @version 1.0 - */ -OH_AVFormat *OH_VideoDecoder_GetOutputDescription(OH_AVCodec *codec); - -/** - * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. - * At the same time, incorrect parameter settings may cause decoding failure. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param format pointer to an OH_AVFormat instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputData} callback - * will report the available input buffer and the corresponding index value. Once the buffer with the specified index - * is submitted to the video decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} - * callback is received again reporting that the buffer with the same index is available. In addition, for some - * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding - * process of the decoder, such as PPS/SPS data in H264 format. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer - * @param attr Information describing the data contained in the Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); - -/** - * @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the - * decoded data contained in the Buffer on the output Surface. If the output surface is not configured before, - * calling this interface only returns the output buffer corresponding to the specified index to the decoder. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_RenderOutputData(OH_AVCodec *codec, uint32_t index); - -/** - * @brief Return the processed output Buffer to the decoder. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); - -/** - * @brief Check whether the current codec instance is valid. It can be used fault recovery or app - * switchback from the background. - * @syscap SystemCapability.Multimedia.Media.VideoDecoder - * @param codec Pointer to an OH_AVCodec instance - * @param isValid Output parameter. A pointer to a boolean instance, it is true if the codec instance is valid, - * false if the codec instance is invalid - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVCODEC_VIDEODECODER_H +#define NATIVE_AVCODEC_VIDEODECODER_H + +#include +#include +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" +#include "native_avcodec_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates a video decoder instance from the mime type, which is recommended in most cases. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_VideoDecoder_CreateByMime(const char *mime); + +/** + * @brief Create a video decoder instance through the video decoder name. + * The premise of using this interface is to know the exact name of the decoder. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param name video codec name + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_VideoDecoder_CreateByName(const char *name); + +/** + * @brief Clear the internal resources of the decoder and destroy the decoder instance + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Destroy(OH_AVCodec *codec); + +/** + * @brief Set the asynchronous callback function so that your application can respond to the events + * generated by the video decoder. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} + * @param userData User specific data + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); + +/** + * @brief Specify the output Surface to provide video decoding output, + * this interface must be called before Prepare is called + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *window); + +/** + * @brief To configure the video decoder, typically, you need to configure the description information of the decoded + * video track, which can be extracted from the container. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief To prepare the internal resources of the decoder, the Configure interface must be called before + * calling this interface. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Prepare(OH_AVCodec *codec); + +/** + * @brief Start the decoder, this interface must be called after the Prepare is successful. + * After being successfully started, the decoder will start reporting NeedInputData events. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Start(OH_AVCodec *codec); + +/** + * @brief Stop the decoder. After stopping, you can re-enter the Started state through Start, + * but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Stop(OH_AVCodec *codec); + +/** + * @brief Clear the input and output data buffered in the decoder. After this interface is called, all the Buffer + * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access + * the Buffers corresponding to these indexes. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Flush(OH_AVCodec *codec); + +/** + * @brief Reset the decoder. To continue decoding, you need to call the Configure interface again + * to configure the decoder instance. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_Reset(OH_AVCodec *codec); + +/** + * @brief Get the description information of the output data of the decoder, refer to {@link OH_AVFormat} + * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs + * to be manually released by the caller. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns a pointer to an OH_AVFormat instance + * @since 9 + * @version 1.0 + */ +OH_AVFormat *OH_VideoDecoder_GetOutputDescription(OH_AVCodec *codec); + +/** + * @brief Set dynamic parameters to the decoder. Note: This interface can only be called after the decoder is started. + * At the same time, incorrect parameter settings may cause decoding failure. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param format pointer to an OH_AVFormat instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief Submit the input buffer filled with data to the video decoder. The {@link OH_AVCodecOnNeedInputData} callback + * will report the available input buffer and the corresponding index value. Once the buffer with the specified index + * is submitted to the video decoder, the buffer cannot be accessed again until the {@link OH_AVCodecOnNeedInputData} + * callback is received again reporting that the buffer with the same index is available. In addition, for some + * decoders, it is required to input Codec-Specific-Data to the decoder at the beginning to initialize the decoding + * process of the decoder, such as PPS/SPS data in H264 format. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index Enter the index value corresponding to the Buffer + * @param attr Information describing the data contained in the Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); + +/** + * @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the + * decoded data contained in the Buffer on the output Surface. If the output surface is not configured before, + * calling this interface only returns the output buffer corresponding to the specified index to the decoder. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_RenderOutputData(OH_AVCodec *codec, uint32_t index); + +/** + * @brief Return the processed output Buffer to the decoder. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); + +/** + * @brief Check whether the current codec instance is valid. It can be used fault recovery or app + * switchback from the background. + * @syscap SystemCapability.Multimedia.Media.VideoDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param isValid Output parameter. A pointer to a boolean instance, it is true if the codec instance is valid, + * false if the codec instance is invalid + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVCODEC_VIDEODECODER_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avcodec_videoencoder.h b/multimedia/av_codec/native_avcodec_videoencoder.h index 86b8750d6ac28000baec2147aebe6e1ebe581d6c..1c696d42435e722c34610880445de60d465c4467 100644 --- a/multimedia/av_codec/native_avcodec_videoencoder.h +++ b/multimedia/av_codec/native_avcodec_videoencoder.h @@ -1,265 +1,265 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVCODEC_VIDEOENCODER_H -#define NATIVE_AVCODEC_VIDEOENCODER_H - -#include -#include -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" -#include "native_avcodec_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Creates a video encoder instance from the mime type, which is recommended in most cases. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_VideoEncoder_CreateByMime(const char *mime); - -/** - * @brief Create a video encoder instance through the video encoder name. The premise of using this interface is to - * know the exact name of the encoder. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param name Video encoder name - * @return Returns a Pointer to an OH_AVCodec instance - * @since 9 - * @version 1.0 - */ -OH_AVCodec *OH_VideoEncoder_CreateByName(const char *name); - -/** - * @brief Clear the internal resources of the encoder and destroy the encoder instance - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec); - -/** - * @brief Set the asynchronous callback function so that your application can respond to the events generated by the - * video encoder. This interface must be called before Prepare is called - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} - * @param userData User specific data - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); - -/** - * @brief To configure the video encoder, typically, you need to configure the description information of the - * encoded video track. This interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param format A pointer to an OH_AVFormat that gives the description of the video track to be encoded - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief To prepare the internal resources of the encoder, the Configure interface must be called before - * calling this interface. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Prepare(OH_AVCodec *codec); - -/** - * @brief Start the encoder, this interface must be called after the Prepare is successful. After being - * successfully started, the encoder will start reporting NeedInputData events. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Start(OH_AVCodec *codec); - -/** - * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Stop(OH_AVCodec *codec); - -/** - * @brief Clear the input and output data buffered in the encoder. After this interface is called, all the Buffer - * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access the - * Buffers corresponding to these indexes. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Flush(OH_AVCodec *codec); - -/** - * @brief Reset the encoder. To continue coding, you need to call the Configure interface again to - * configure the encoder instance. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_Reset(OH_AVCodec *codec); - -/** - * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details. - * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to - * be manually released by the caller. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns a pointer to an OH_AVFormat instance - * @since 9 - * @version 1.0 - */ -OH_AVFormat *OH_VideoEncoder_GetOutputDescription(OH_AVCodec *codec); - -/** - * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started. - * At the same time, incorrect parameter settings may cause the encoding to fail. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param format OH_AVFormat handle pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); - -/** - * @brief Get the input Surface from the video encoder, this interface must be called before Prepare is called. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **window); - -/** - * @brief Return the processed output Buffer to the encoder. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param index The index value corresponding to the output Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); - -/** - * @brief Notifies the video encoder that the input stream has ended. It is recommended to use this interface to notify - * the encoder of the end of the stream in surface mode - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 9 - * @version 1.0 - */ -OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec); - -/** - * @brief Submit the input buffer filled with data to the video encoder. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param index Enter the index value corresponding to the Buffer - * @param attr Information describing the data contained in the Buffer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); - -/** - * @brief Get the input data description of the encoder after call {@OH_VideoEncoder_Configure}, - * refer to {@link OH_AVFormat} for details. It should be noted that the life cycle of the OH_AVFormat - * instance pointed to by the return value needs to be manually released by the caller. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @return Returns a pointer to an OH_AVFormat instance - * @since 10 - */ -OH_AVFormat *OH_VideoEncoder_GetInputDescription(OH_AVCodec *codec); - -/** - * @brief Check whether the current codec instance is valid. It can be used fault recovery or app - * switchback from the background - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @param codec Pointer to an OH_AVCodec instance - * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, - * false if the codec instance is invalid - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec *codec, bool *isValid); - -/** - * @brief The bitrate mode of video encoder. - * @syscap SystemCapability.Multimedia.Media.VideoEncoder - * @since 9 - * @version 1.0 - */ -typedef enum OH_VideoEncodeBitrateMode { - /* constant bit rate mode. */ - CBR = 0, - /* variable bit rate mode. */ - VBR = 1, - /* constant quality mode. */ - CQ = 2, -} OH_VideoEncodeBitrateMode; - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVCODEC_VIDEOENCODER_H +#define NATIVE_AVCODEC_VIDEOENCODER_H + +#include +#include +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" +#include "native_avcodec_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates a video encoder instance from the mime type, which is recommended in most cases. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param mime mime type description string, refer to {@link AVCODEC_MIME_TYPE} + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_VideoEncoder_CreateByMime(const char *mime); + +/** + * @brief Create a video encoder instance through the video encoder name. The premise of using this interface is to + * know the exact name of the encoder. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param name Video encoder name + * @return Returns a Pointer to an OH_AVCodec instance + * @since 9 + * @version 1.0 + */ +OH_AVCodec *OH_VideoEncoder_CreateByName(const char *name); + +/** + * @brief Clear the internal resources of the encoder and destroy the encoder instance + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Destroy(OH_AVCodec *codec); + +/** + * @brief Set the asynchronous callback function so that your application can respond to the events generated by the + * video encoder. This interface must be called before Prepare is called + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param callback A collection of all callback functions, see {@link OH_AVCodecAsyncCallback} + * @param userData User specific data + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData); + +/** + * @brief To configure the video encoder, typically, you need to configure the description information of the + * encoded video track. This interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param format A pointer to an OH_AVFormat that gives the description of the video track to be encoded + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Configure(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief To prepare the internal resources of the encoder, the Configure interface must be called before + * calling this interface. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Prepare(OH_AVCodec *codec); + +/** + * @brief Start the encoder, this interface must be called after the Prepare is successful. After being + * successfully started, the encoder will start reporting NeedInputData events. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Start(OH_AVCodec *codec); + +/** + * @brief Stop the encoder. After stopping, you can re-enter the Started state through Start. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Stop(OH_AVCodec *codec); + +/** + * @brief Clear the input and output data buffered in the encoder. After this interface is called, all the Buffer + * indexes previously reported through the asynchronous callback will be invalidated, make sure not to access the + * Buffers corresponding to these indexes. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Flush(OH_AVCodec *codec); + +/** + * @brief Reset the encoder. To continue coding, you need to call the Configure interface again to + * configure the encoder instance. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_Reset(OH_AVCodec *codec); + +/** + * @brief Get the description information of the output data of the encoder, refer to {@link OH_AVFormat} for details. + * It should be noted that the life cycle of the OH_AVFormat instance pointed to by the return value * needs to + * be manually released by the caller. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns a pointer to an OH_AVFormat instance + * @since 9 + * @version 1.0 + */ +OH_AVFormat *OH_VideoEncoder_GetOutputDescription(OH_AVCodec *codec); + +/** + * @brief Set dynamic parameters to the encoder. Note: This interface can only be called after the encoder is started. + * At the same time, incorrect parameter settings may cause the encoding to fail. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param format OH_AVFormat handle pointer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format); + +/** + * @brief Get the input Surface from the video encoder, this interface must be called before Prepare is called. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_GetSurface(OH_AVCodec *codec, OHNativeWindow **window); + +/** + * @brief Return the processed output Buffer to the encoder. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index The index value corresponding to the output Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); + +/** + * @brief Notifies the video encoder that the input stream has ended. It is recommended to use this interface to notify + * the encoder of the end of the stream in surface mode + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 9 + * @version 1.0 + */ +OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream(OH_AVCodec *codec); + +/** + * @brief Submit the input buffer filled with data to the video encoder. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param index Enter the index value corresponding to the Buffer + * @param attr Information describing the data contained in the Buffer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr); + +/** + * @brief Get the input data description of the encoder after call {@OH_VideoEncoder_Configure}, + * refer to {@link OH_AVFormat} for details. It should be noted that the life cycle of the OH_AVFormat + * instance pointed to by the return value needs to be manually released by the caller. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @return Returns a pointer to an OH_AVFormat instance + * @since 10 + */ +OH_AVFormat *OH_VideoEncoder_GetInputDescription(OH_AVCodec *codec); + +/** + * @brief Check whether the current codec instance is valid. It can be used fault recovery or app + * switchback from the background + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @param codec Pointer to an OH_AVCodec instance + * @param isValid Output Parameter. A pointer to a boolean instance, it is true if the codec instance is valid, + * false if the codec instance is invalid + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec *codec, bool *isValid); + +/** + * @brief The bitrate mode of video encoder. + * @syscap SystemCapability.Multimedia.Media.VideoEncoder + * @since 9 + * @version 1.0 + */ +typedef enum OH_VideoEncodeBitrateMode { + /* constant bit rate mode. */ + CBR = 0, + /* variable bit rate mode. */ + VBR = 1, + /* constant quality mode. */ + CQ = 2, +} OH_VideoEncodeBitrateMode; + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVCODEC_VIDEOENCODER_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index cdcff091443aa49dcd6b8b6a1565143afcab8a26..fc12c14b8084f612eaded288cf0533a5f64f7711 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -1,117 +1,117 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVDEMUXER_H -#define NATIVE_AVDEMUXER_H - -#include -#include "native_avcodec_base.h" -#include "native_averrors.h" -#include "native_avmemory.h" -#include "native_avsource.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVDemuxer OH_AVDemuxer; - -/** - * @brief Creates an OH_AVDemuxer instance for getting samples from source. - * Free the resources of the instance by calling OH_AVDemuxer_Destroy. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param source Pointer to an OH_AVSource instance. - * @return Returns a pointer to an OH_AVDemuxer instance - * @since 10 -*/ -OH_AVDemuxer *OH_AVDemuxer_CreateWithSource(OH_AVSource *source); - -/** - * @brief Destroy the OH_AVDemuxer instance and free the internal resources. - * The same instance can only be destroyed once. The destroyed instance - * should not be used before it is created again. It is recommended setting - * the instance pointer to NULL right after the instance is destroyed successfully. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param demuxer Pointer to an OH_AVDemuxer instance. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVDemuxer_Destroy(OH_AVDemuxer *demuxer); - -/** - * @brief The specified track is selected and the demuxer will read samples from - * this track. Multiple tracks are selected by calling this interface multiple times - * with different track indexes. Only the selected tracks are valid when calling - * OH_AVDemuxer_ReadSample to read samples. The interface returns AV_ERR_OK and the - * track is selected only once if the same track is selected multiple times. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param demuxer Pointer to an OH_AVDemuxer instance. - * @param trackIndex The index of the selected track. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVDemuxer_SelectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); - -/** - * @brief The specified selected track is unselected. The unselected track's sample - * can not be read from demuxer. Multiple selected tracks are unselected by calling - * this interface multiple times with different track indexes. The interface returns - * AV_ERR_OK and the track is unselected only once if the same track is unselected - * multiple times. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param demuxer Pointer to an OH_AVDemuxer instance. - * @param trackIndex The index of the unselected track. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVDemuxer_UnselectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); - -/** - * @brief Get the current encoded sample and sample-related information from the specified - * track. The track index must be selected before reading sample. The demuxer will advance - * automatically after calling this interface. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param demuxer Pointer to an OH_AVDemuxer instance. - * @param trackIndex The index of the track from which read an encoded sample. - * @param sample The OH_AVMemory handle pointer to the buffer storing the sample data. - * @param info The OH_AVCodecBufferAttr handle pointer to the buffer storing sample information. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVDemuxer_ReadSample(OH_AVDemuxer *demuxer, uint32_t trackIndex, - OH_AVMemory *sample, OH_AVCodecBufferAttr *info); - -/** - * @brief All selected tracks seek near to the requested time according to the seek mode. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param demuxer Pointer to an OH_AVDemuxer instance. - * @param millisecond The millisecond for seeking, the timestamp is the position of - * the file relative to the start of the file. - * @param mode The mode for seeking. See {@link OH_AVSeekMode}. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVSeekMode mode); - -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_AVDEMUXER_H +/* + * 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. + */ + +#ifndef NATIVE_AVDEMUXER_H +#define NATIVE_AVDEMUXER_H + +#include +#include "native_avcodec_base.h" +#include "native_averrors.h" +#include "native_avmemory.h" +#include "native_avsource.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVDemuxer OH_AVDemuxer; + +/** + * @brief Creates an OH_AVDemuxer instance for getting samples from source. + * Free the resources of the instance by calling OH_AVDemuxer_Destroy. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param source Pointer to an OH_AVSource instance. + * @return Returns a pointer to an OH_AVDemuxer instance + * @since 10 +*/ +OH_AVDemuxer *OH_AVDemuxer_CreateWithSource(OH_AVSource *source); + +/** + * @brief Destroy the OH_AVDemuxer instance and free the internal resources. + * The same instance can only be destroyed once. The destroyed instance + * should not be used before it is created again. It is recommended setting + * the instance pointer to NULL right after the instance is destroyed successfully. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVDemuxer_Destroy(OH_AVDemuxer *demuxer); + +/** + * @brief The specified track is selected and the demuxer will read samples from + * this track. Multiple tracks are selected by calling this interface multiple times + * with different track indexes. Only the selected tracks are valid when calling + * OH_AVDemuxer_ReadSample to read samples. The interface returns AV_ERR_OK and the + * track is selected only once if the same track is selected multiple times. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance. + * @param trackIndex The index of the selected track. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVDemuxer_SelectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); + +/** + * @brief The specified selected track is unselected. The unselected track's sample + * can not be read from demuxer. Multiple selected tracks are unselected by calling + * this interface multiple times with different track indexes. The interface returns + * AV_ERR_OK and the track is unselected only once if the same track is unselected + * multiple times. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance. + * @param trackIndex The index of the unselected track. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVDemuxer_UnselectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); + +/** + * @brief Get the current encoded sample and sample-related information from the specified + * track. The track index must be selected before reading sample. The demuxer will advance + * automatically after calling this interface. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance. + * @param trackIndex The index of the track from which read an encoded sample. + * @param sample The OH_AVMemory handle pointer to the buffer storing the sample data. + * @param info The OH_AVCodecBufferAttr handle pointer to the buffer storing sample information. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVDemuxer_ReadSample(OH_AVDemuxer *demuxer, uint32_t trackIndex, + OH_AVMemory *sample, OH_AVCodecBufferAttr *info); + +/** + * @brief All selected tracks seek near to the requested time according to the seek mode. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance. + * @param millisecond The millisecond for seeking, the timestamp is the position of + * the file relative to the start of the file. + * @param mode The mode for seeking. See {@link OH_AVSeekMode}. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVSeekMode mode); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVDEMUXER_H diff --git a/multimedia/av_codec/native_averrors.h b/multimedia/av_codec/native_averrors.h index fe02f4aeeaa604db25429623e85dd8bbcc44a3a7..75c9a4cafdb8173a7578d1c7d59d3e05f75532b9 100644 --- a/multimedia/av_codec/native_averrors.h +++ b/multimedia/av_codec/native_averrors.h @@ -1,79 +1,79 @@ -/* - * 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. - */ -#ifndef NATIVE_AVERRORS_H -#define NATIVE_AVERRORS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief AV error code - * @syscap SystemCapability.Multimedia.Media.Core - * @since 9 - * @version 1.0 - */ -typedef enum OH_AVErrCode { - /** - * the operation completed successfully. - */ - AV_ERR_OK = 0, - /** - * no memory. - */ - AV_ERR_NO_MEMORY = 1, - /** - * opertation not be permitted. - */ - AV_ERR_OPERATE_NOT_PERMIT = 2, - /** - * invalid argument. - */ - AV_ERR_INVALID_VAL = 3, - /** - * IO error. - */ - AV_ERR_IO = 4, - /** - * network timeout. - */ - AV_ERR_TIMEOUT = 5, - /** - * unknown error. - */ - AV_ERR_UNKNOWN = 6, - /** - * media service died. - */ - AV_ERR_SERVICE_DIED = 7, - /** - * the state is not support this operation. - */ - AV_ERR_INVALID_STATE = 8, - /** - * unsupport interface. - */ - AV_ERR_UNSUPPORT = 9, - /** - * extend err start. - */ - AV_ERR_EXTEND_START = 100, -} OH_AVErrCode; - -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_AVERRORS_H +/* + * 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. + */ +#ifndef NATIVE_AVERRORS_H +#define NATIVE_AVERRORS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief AV error code + * @syscap SystemCapability.Multimedia.Media.Core + * @since 9 + * @version 1.0 + */ +typedef enum OH_AVErrCode { + /** + * the operation completed successfully. + */ + AV_ERR_OK = 0, + /** + * no memory. + */ + AV_ERR_NO_MEMORY = 1, + /** + * opertation not be permitted. + */ + AV_ERR_OPERATE_NOT_PERMIT = 2, + /** + * invalid argument. + */ + AV_ERR_INVALID_VAL = 3, + /** + * IO error. + */ + AV_ERR_IO = 4, + /** + * network timeout. + */ + AV_ERR_TIMEOUT = 5, + /** + * unknown error. + */ + AV_ERR_UNKNOWN = 6, + /** + * media service died. + */ + AV_ERR_SERVICE_DIED = 7, + /** + * the state is not support this operation. + */ + AV_ERR_INVALID_STATE = 8, + /** + * unsupport interface. + */ + AV_ERR_UNSUPPORT = 9, + /** + * extend err start. + */ + AV_ERR_EXTEND_START = 100, +} OH_AVErrCode; + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVERRORS_H diff --git a/multimedia/av_codec/native_avformat.h b/multimedia/av_codec/native_avformat.h index 4335cee3370160b09cf5cf5d9b866ed699bc82c7..528625b7ad7a6dd6053a53fa23e990bbfc14ae4e 100644 --- a/multimedia/av_codec/native_avformat.h +++ b/multimedia/av_codec/native_avformat.h @@ -1,278 +1,278 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVFORMAT_H -#define NATIVE_AVFORMAT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVFormat OH_AVFormat; - -/** - * @brief Enumerates AVPixel Format. - * @syscap SystemCapability.Multimedia.Media.Core - * @since 9 - * @version 1.0 - */ -typedef enum OH_AVPixelFormat { - /** - * yuv 420 planar. - */ - AV_PIXEL_FORMAT_YUVI420 = 1, - /** - * NV12. yuv 420 semiplanar. - */ - AV_PIXEL_FORMAT_NV12 = 2, - /** - * NV21. yvu 420 semiplanar. - */ - AV_PIXEL_FORMAT_NV21 = 3, - /** - * format from surface. - */ - AV_PIXEL_FORMAT_SURFACE_FORMAT = 4, - /** - * RGBA8888 - */ - AV_PIXEL_FORMAT_RGBA = 5, -} OH_AVPixelFormat; - -/** - * @briefCreate an OH_AVFormat handle pointer to read and write data - * @syscap SystemCapability.Multimedia.Media.Core - * @return Returns a pointer to an OH_AVFormat instance - * @since 9 - * @version 1.0 - */ -struct OH_AVFormat *OH_AVFormat_Create(void); - -/** - * @briefCreate an audio OH_AVFormat handle pointer to read and write data - * @syscap SystemCapability.Multimedia.Media.Core - * @param mimeType mime type - * @param sampleRate sample rate - * @param channelCount channel count - * @return Returns a pointer to an OH_AVFormat instance - * @since 10 - * @version 1.0 - */ -struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType, - int32_t sampleRate, - int32_t channelCount); - -/** - * @briefCreate an video OH_AVFormat handle pointer to read and write data - * @syscap SystemCapability.Multimedia.Media.Core - * @param mimeType mime type - * @param width width - * @param height height - * @return Returns a pointer to an OH_AVFormat instance - * @since 10 - * @version 1.0 - */ -struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType, - int32_t width, - int32_t height); - -/** - * @brief Destroy the specified OH_AVFormat handle resource - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @return void - * @since 9 - * @version 1.0 - */ -void OH_AVFormat_Destroy(struct OH_AVFormat *format); - -/** - * @brief Copy OH_AVFormat handle resource - * @syscap SystemCapability.Multimedia.Media.Core - * @param to OH_AVFormat handle pointer to receive data - * @param from pointer to the OH_AVFormat handle of the copied data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from); - -/** - * @brief Write Int data to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param value written data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value); - -/** - * @brief Write Long data to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param value written data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value); - -/** - * @brief Write Float data to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param value written data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value); - -/** - * @brief Write Double data to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param value written data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value); - -/** - * @brief Write String data to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param value written data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value); - -/** - * @brief Write a block of data of a specified length to OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key key to write data - * @param addr written data addr - * @param size written data length - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size); - -/** - * @brief Read Int data from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key read key value - * @param out read data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out); - -/** - * @brief Read Long data from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key read key value - * @param out read data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out); - -/** - * @brief Read Float data from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key read key value - * @param out read data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out); - -/** - * @brief Read Double data from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key read key value - * @param out read data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out); - -/** - * @brief Read String data from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key read key value - * @param out The read string pointer, the data life cycle pointed to is updated with GetString, - * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, const char **out); - -/** - * @brief Read a block of data of specified length from OH_AVFormat - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @param key Key value for reading and writing data - * @param addr The life cycle is held by the format, with the destruction of the format, - * if the caller needs to hold it for a long time, it must copy the memory - * @param size Length of read and write data - * @return The return value is TRUE for success, FALSE for failure - * @since 9 - * @version 1.0 - */ -bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size); - -/** - * @brief Output the information contained in OH_AVFormat as a string. - * @syscap SystemCapability.Multimedia.Media.Core - * @param format pointer to an OH_AVFormat instance - * @return Returns a string consisting of key and data - * @since 9 - * @version 1.0 - */ -const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format); - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVFORMAT_H +#define NATIVE_AVFORMAT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVFormat OH_AVFormat; + +/** + * @brief Enumerates AVPixel Format. + * @syscap SystemCapability.Multimedia.Media.Core + * @since 9 + * @version 1.0 + */ +typedef enum OH_AVPixelFormat { + /** + * yuv 420 planar. + */ + AV_PIXEL_FORMAT_YUVI420 = 1, + /** + * NV12. yuv 420 semiplanar. + */ + AV_PIXEL_FORMAT_NV12 = 2, + /** + * NV21. yvu 420 semiplanar. + */ + AV_PIXEL_FORMAT_NV21 = 3, + /** + * format from surface. + */ + AV_PIXEL_FORMAT_SURFACE_FORMAT = 4, + /** + * RGBA8888 + */ + AV_PIXEL_FORMAT_RGBA = 5, +} OH_AVPixelFormat; + +/** + * @briefCreate an OH_AVFormat handle pointer to read and write data + * @syscap SystemCapability.Multimedia.Media.Core + * @return Returns a pointer to an OH_AVFormat instance + * @since 9 + * @version 1.0 + */ +struct OH_AVFormat *OH_AVFormat_Create(void); + +/** + * @briefCreate an audio OH_AVFormat handle pointer to read and write data + * @syscap SystemCapability.Multimedia.Media.Core + * @param mimeType mime type + * @param sampleRate sample rate + * @param channelCount channel count + * @return Returns a pointer to an OH_AVFormat instance + * @since 10 + * @version 1.0 + */ +struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType, + int32_t sampleRate, + int32_t channelCount); + +/** + * @briefCreate an video OH_AVFormat handle pointer to read and write data + * @syscap SystemCapability.Multimedia.Media.Core + * @param mimeType mime type + * @param width width + * @param height height + * @return Returns a pointer to an OH_AVFormat instance + * @since 10 + * @version 1.0 + */ +struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType, + int32_t width, + int32_t height); + +/** + * @brief Destroy the specified OH_AVFormat handle resource + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @return void + * @since 9 + * @version 1.0 + */ +void OH_AVFormat_Destroy(struct OH_AVFormat *format); + +/** + * @brief Copy OH_AVFormat handle resource + * @syscap SystemCapability.Multimedia.Media.Core + * @param to OH_AVFormat handle pointer to receive data + * @param from pointer to the OH_AVFormat handle of the copied data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from); + +/** + * @brief Write Int data to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param value written data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value); + +/** + * @brief Write Long data to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param value written data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value); + +/** + * @brief Write Float data to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param value written data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value); + +/** + * @brief Write Double data to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param value written data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value); + +/** + * @brief Write String data to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param value written data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value); + +/** + * @brief Write a block of data of a specified length to OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key key to write data + * @param addr written data addr + * @param size written data length + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size); + +/** + * @brief Read Int data from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key read key value + * @param out read data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out); + +/** + * @brief Read Long data from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key read key value + * @param out read data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out); + +/** + * @brief Read Float data from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key read key value + * @param out read data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out); + +/** + * @brief Read Double data from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key read key value + * @param out read data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out); + +/** + * @brief Read String data from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key read key value + * @param out The read string pointer, the data life cycle pointed to is updated with GetString, + * and Format is destroyed. If the caller needs to hold it for a long time, it must copy the memory + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, const char **out); + +/** + * @brief Read a block of data of specified length from OH_AVFormat + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @param key Key value for reading and writing data + * @param addr The life cycle is held by the format, with the destruction of the format, + * if the caller needs to hold it for a long time, it must copy the memory + * @param size Length of read and write data + * @return The return value is TRUE for success, FALSE for failure + * @since 9 + * @version 1.0 + */ +bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size); + +/** + * @brief Output the information contained in OH_AVFormat as a string. + * @syscap SystemCapability.Multimedia.Media.Core + * @param format pointer to an OH_AVFormat instance + * @return Returns a string consisting of key and data + * @since 9 + * @version 1.0 + */ +const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format); + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVFORMAT_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avmemory.h b/multimedia/av_codec/native_avmemory.h index a165d290a0a8048f3eefd92b111ab5385f4f49fc..5453088505b8aa7f23f07ac1668f010c64a79696 100644 --- a/multimedia/av_codec/native_avmemory.h +++ b/multimedia/av_codec/native_avmemory.h @@ -1,71 +1,71 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVMEMORY_H -#define NATIVE_AVMEMORY_H - -#include -#include "native_averrors.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVMemory OH_AVMemory; - -/** - * @brief Create an OH_AVMemory instance - * @syscap SystemCapability.Multimedia.Media.Core - * @param size the memory's size, bytes. - * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. - * @since 10 - */ -OH_AVMemory *OH_AVMemory_Create(int32_t size); - -/** - * @brief Get the memory's virtual address - * @syscap SystemCapability.Multimedia.Media.Core - * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return the memory's virtual address if the memory is valid, otherwise nullptr. - * @since 9 - * @version 1.0 - */ -uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); - -/** - * @brief Get the memory's size - * @syscap SystemCapability.Multimedia.Media.Core - * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return the memory's size if the memory is valid, otherwise -1. - * @since 9 - * @version 1.0 - */ -int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); - -/** - * @brief Clear the internal resources of the memory and destroy the memory instance - * @syscap SystemCapability.Multimedia.Media.Core - * @param mem Encapsulate OH_AVMemory structure instance pointer - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); - -#ifdef __cplusplus -} -#endif - -#endif // NATIVE_AVMEMORY_H +/* + * 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. + */ + +#ifndef NATIVE_AVMEMORY_H +#define NATIVE_AVMEMORY_H + +#include +#include "native_averrors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVMemory OH_AVMemory; + +/** + * @brief Create an OH_AVMemory instance + * @syscap SystemCapability.Multimedia.Media.Core + * @param size the memory's size, bytes. + * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. + * @since 10 + */ +OH_AVMemory *OH_AVMemory_Create(int32_t size); + +/** + * @brief Get the memory's virtual address + * @syscap SystemCapability.Multimedia.Media.Core + * @param mem Encapsulate OH_AVMemory structure instance pointer + * @return the memory's virtual address if the memory is valid, otherwise nullptr. + * @since 9 + * @version 1.0 + */ +uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); + +/** + * @brief Get the memory's size + * @syscap SystemCapability.Multimedia.Media.Core + * @param mem Encapsulate OH_AVMemory structure instance pointer + * @return the memory's size if the memory is valid, otherwise -1. + * @since 9 + * @version 1.0 + */ +int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); + +/** + * @brief Clear the internal resources of the memory and destroy the memory instance + * @syscap SystemCapability.Multimedia.Media.Core + * @param mem Encapsulate OH_AVMemory structure instance pointer + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVMEMORY_H diff --git a/multimedia/av_codec/native_avmuxer.h b/multimedia/av_codec/native_avmuxer.h index ec7e647dcf0e8437393733f53722ddd1633b986e..bf61dde446d3c5fdacf0c9a698967dae5d142f84 100644 --- a/multimedia/av_codec/native_avmuxer.h +++ b/multimedia/av_codec/native_avmuxer.h @@ -1,125 +1,125 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVMUXER_H -#define NATIVE_AVMUXER_H - -#include -#include -#include "native_avcodec_base.h" -#include "native_averrors.h" -#include "native_avformat.h" -#include "native_avmemory.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVMuxer OH_AVMuxer; - -/** - * @brief Create an OH_AVMuxer instance by output file description and format. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param fd Must be opened with read and write permission. Caller is responsible for closing fd. - * @param format The output format is {@link OH_AVOutputFormat} . - * @return Returns a pointer to an OH_AVMuxer instance, needs to be freed by OH_AVMuxer_Destroy. - * @since 10 - */ -OH_AVMuxer *OH_AVMuxer_Create(int32_t fd, OH_AVOutputFormat format); - -/** - * @brief Set the rotation for output video playback. - * Note: This interface can only be called before OH_AVMuxer_Start. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance. - * @param rotation The supported angles are 0, 90, 180, and 270 degrees. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_SetRotation(OH_AVMuxer *muxer, int32_t rotation); - -/** - * @brief Add track format to the muxer. - * Note: This interface can only be called before OH_AVMuxer_Start. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance - * @param trackIndex The int32_t handle pointer used to get the track index for this newly added track, - * and it should be used in the OH_AVMuxer_WriteSample. The track index is greater than or equal to 0, - * others is error index. - * @param trackFormat OH_AVFormat handle pointer contain track format - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_AddTrack(OH_AVMuxer *muxer, int32_t *trackIndex, OH_AVFormat *trackFormat); - -/** - * @brief Start the muxer. - * Note: This interface is called after OH_AVMuxer_AddTrack and before OH_AVMuxer_WriteSample. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_Start(OH_AVMuxer *muxer); - -/** - * @brief Write an encoded sample to the muxer. - * Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to - * make sure that the samples are written to the right tacks. Also, it needs to make sure the samples for each track are - * written in chronological order. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance - * @param trackIndex The track index for this sample - * @param sample The encoded or demuxer sample - * @param info The buffer information related to this sample {@link OH_AVCodecBufferAttr} - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_WriteSample(OH_AVMuxer *muxer, - uint32_t trackIndex, - OH_AVMemory *sample, - OH_AVCodecBufferAttr info); - -/** - * @brief Stop the muxer. - * Note: Once the muxer stops, it can not be restarted. - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_Stop(OH_AVMuxer *muxer); - -/** - * @brief Clear the internal resources of the muxer and destroy the muxer instance - * @syscap SystemCapability.Multimedia.Media.Muxer - * @param muxer Pointer to an OH_AVMuxer instance - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 - */ -OH_AVErrCode OH_AVMuxer_Destroy(OH_AVMuxer *muxer); - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVMUXER_H +#define NATIVE_AVMUXER_H + +#include +#include +#include "native_avcodec_base.h" +#include "native_averrors.h" +#include "native_avformat.h" +#include "native_avmemory.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVMuxer OH_AVMuxer; + +/** + * @brief Create an OH_AVMuxer instance by output file description and format. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param fd Must be opened with read and write permission. Caller is responsible for closing fd. + * @param format The output format is {@link OH_AVOutputFormat} . + * @return Returns a pointer to an OH_AVMuxer instance, needs to be freed by OH_AVMuxer_Destroy. + * @since 10 + */ +OH_AVMuxer *OH_AVMuxer_Create(int32_t fd, OH_AVOutputFormat format); + +/** + * @brief Set the rotation for output video playback. + * Note: This interface can only be called before OH_AVMuxer_Start. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance. + * @param rotation The supported angles are 0, 90, 180, and 270 degrees. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_SetRotation(OH_AVMuxer *muxer, int32_t rotation); + +/** + * @brief Add track format to the muxer. + * Note: This interface can only be called before OH_AVMuxer_Start. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance + * @param trackIndex The int32_t handle pointer used to get the track index for this newly added track, + * and it should be used in the OH_AVMuxer_WriteSample. The track index is greater than or equal to 0, + * others is error index. + * @param trackFormat OH_AVFormat handle pointer contain track format + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_AddTrack(OH_AVMuxer *muxer, int32_t *trackIndex, OH_AVFormat *trackFormat); + +/** + * @brief Start the muxer. + * Note: This interface is called after OH_AVMuxer_AddTrack and before OH_AVMuxer_WriteSample. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_Start(OH_AVMuxer *muxer); + +/** + * @brief Write an encoded sample to the muxer. + * Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to + * make sure that the samples are written to the right tacks. Also, it needs to make sure the samples for each track are + * written in chronological order. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance + * @param trackIndex The track index for this sample + * @param sample The encoded or demuxer sample + * @param info The buffer information related to this sample {@link OH_AVCodecBufferAttr} + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_WriteSample(OH_AVMuxer *muxer, + uint32_t trackIndex, + OH_AVMemory *sample, + OH_AVCodecBufferAttr info); + +/** + * @brief Stop the muxer. + * Note: Once the muxer stops, it can not be restarted. + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_Stop(OH_AVMuxer *muxer); + +/** + * @brief Clear the internal resources of the muxer and destroy the muxer instance + * @syscap SystemCapability.Multimedia.Media.Muxer + * @param muxer Pointer to an OH_AVMuxer instance + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 + */ +OH_AVErrCode OH_AVMuxer_Destroy(OH_AVMuxer *muxer); + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVMUXER_H \ No newline at end of file diff --git a/multimedia/av_codec/native_avsource.h b/multimedia/av_codec/native_avsource.h index fe6ab38dc93ce6f9de1db2b595df553f755986e4..05af44ed466189a90fa5f4b58868420bfc8de940 100644 --- a/multimedia/av_codec/native_avsource.h +++ b/multimedia/av_codec/native_avsource.h @@ -1,85 +1,85 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVSOURCE_H -#define NATIVE_AVSOURCE_H - -#include -#include "native_avcodec_base.h" -#include "native_averrors.h" -#include "native_avformat.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct OH_AVSource OH_AVSource; - -/** - * @brief Creates an OH_AVSource instance that models the media at the URI. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param uri An URI for a remote media resource. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVSource *OH_AVSource_CreateWithURI(char *uri); - -/** - * @brief Creates an OH_AVSource instance that models the media at the FileDescriptor. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param fd The fileDescriptor of data source. - * @param offset The offset into the file to start reading. - * @param size The file size in bytes. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size); - -/** - * @brief Destroy the OH_AVSource instance and free the internal resources. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param source Pointer to an OH_AVSource instance. - * @return Returns AV_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVErrCode} - * @since 10 -*/ -OH_AVErrCode OH_AVSource_Destroy(OH_AVSource *source); - -/** - * @brief Get the format info of source. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param source Pointer to an OH_AVSource instance. - * @return Returns the source's format info. - * @since 10 -*/ -OH_AVFormat *OH_AVSource_GetSourceFormat(OH_AVSource *source); - -/** - * @brief Get the format info of track. - * @syscap SystemCapability.Multimedia.Media.Spliter - * @param source Pointer to an OH_AVSource instance. - * @param trackIndex The track index to get format. - * @return Returns the track's format info. - * @since 10 -*/ -OH_AVFormat *OH_AVSource_GetTrackFormat(OH_AVSource *source, uint32_t trackIndex); - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVSOURCE_H +#define NATIVE_AVSOURCE_H + +#include +#include "native_avcodec_base.h" +#include "native_averrors.h" +#include "native_avformat.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVSource OH_AVSource; + +/** + * @brief Creates an OH_AVSource instance that models the media at the URI. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param uri An URI for a remote media resource. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVSource *OH_AVSource_CreateWithURI(char *uri); + +/** + * @brief Creates an OH_AVSource instance that models the media at the FileDescriptor. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param fd The fileDescriptor of data source. + * @param offset The offset into the file to start reading. + * @param size The file size in bytes. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size); + +/** + * @brief Destroy the OH_AVSource instance and free the internal resources. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param source Pointer to an OH_AVSource instance. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 10 +*/ +OH_AVErrCode OH_AVSource_Destroy(OH_AVSource *source); + +/** + * @brief Get the format info of source. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param source Pointer to an OH_AVSource instance. + * @return Returns the source's format info. + * @since 10 +*/ +OH_AVFormat *OH_AVSource_GetSourceFormat(OH_AVSource *source); + +/** + * @brief Get the format info of track. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param source Pointer to an OH_AVSource instance. + * @param trackIndex The track index to get format. + * @return Returns the track's format info. + * @since 10 +*/ +OH_AVFormat *OH_AVSource_GetTrackFormat(OH_AVSource *source, uint32_t trackIndex); + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVSOURCE_H \ No newline at end of file diff --git a/multimedia/av_codec/video_decoder/BUILD.gn b/multimedia/av_codec/video_decoder/BUILD.gn index ed160ae9626cd9dc1e405b79c137a32d3f0e03f8..9484c0e3036e7f59175057d868a15926da1899d8 100644 --- a/multimedia/av_codec/video_decoder/BUILD.gn +++ b/multimedia/av_codec/video_decoder/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_vdec_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = - [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_videodecoder.h" ] -} - -ohos_ndk_library("libnative_media_vdec") { - ndk_description_file = "./libnative_media_vdec.ndk.json" - min_compact_version = "1" - output_name = "native_media_vdec" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.VideoDecoder" - system_capability_headers = - [ "multimedia/player_framework/native_avcodec_videodecoder.h" ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_vdec_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = + [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_videodecoder.h" ] +} + +ohos_ndk_library("libnative_media_vdec") { + ndk_description_file = "./libnative_media_vdec.ndk.json" + min_compact_version = "1" + output_name = "native_media_vdec" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.VideoDecoder" + system_capability_headers = + [ "multimedia/player_framework/native_avcodec_videodecoder.h" ] +} diff --git a/multimedia/av_codec/video_decoder/libnative_media_vdec.ndk.json b/multimedia/av_codec/video_decoder/libnative_media_vdec.ndk.json index 7e6fd7d7a269e611b4e2ab3781005ca759dc527b..8730155216e808eb4589b3c42a56976277193b44 100644 --- a/multimedia/av_codec/video_decoder/libnative_media_vdec.ndk.json +++ b/multimedia/av_codec/video_decoder/libnative_media_vdec.ndk.json @@ -1,19 +1,19 @@ -[ - { "name": "OH_VideoDecoder_CreateByMime" }, - { "name": "OH_VideoDecoder_CreateByName" }, - { "name": "OH_VideoDecoder_Destroy" }, - { "name": "OH_VideoDecoder_SetCallback" }, - { "name": "OH_VideoDecoder_SetSurface" }, - { "name": "OH_VideoDecoder_Configure" }, - { "name": "OH_VideoDecoder_Prepare" }, - { "name": "OH_VideoDecoder_Start" }, - { "name": "OH_VideoDecoder_Stop" }, - { "name": "OH_VideoDecoder_Flush" }, - { "name": "OH_VideoDecoder_Reset" }, - { "name": "OH_VideoDecoder_GetOutputDescription" }, - { "name": "OH_VideoDecoder_SetParameter" }, - { "name": "OH_VideoDecoder_PushInputData" }, - { "name": "OH_VideoDecoder_RenderOutputData" }, - { "name": "OH_VideoDecoder_FreeOutputData" }, - { "name": "OH_VideoDecoder_IsValid" } -] +[ + { "name": "OH_VideoDecoder_CreateByMime" }, + { "name": "OH_VideoDecoder_CreateByName" }, + { "name": "OH_VideoDecoder_Destroy" }, + { "name": "OH_VideoDecoder_SetCallback" }, + { "name": "OH_VideoDecoder_SetSurface" }, + { "name": "OH_VideoDecoder_Configure" }, + { "name": "OH_VideoDecoder_Prepare" }, + { "name": "OH_VideoDecoder_Start" }, + { "name": "OH_VideoDecoder_Stop" }, + { "name": "OH_VideoDecoder_Flush" }, + { "name": "OH_VideoDecoder_Reset" }, + { "name": "OH_VideoDecoder_GetOutputDescription" }, + { "name": "OH_VideoDecoder_SetParameter" }, + { "name": "OH_VideoDecoder_PushInputData" }, + { "name": "OH_VideoDecoder_RenderOutputData" }, + { "name": "OH_VideoDecoder_FreeOutputData" }, + { "name": "OH_VideoDecoder_IsValid" } +] diff --git a/multimedia/av_codec/video_encoder/BUILD.gn b/multimedia/av_codec/video_encoder/BUILD.gn index e3d3000a03e66a903832da6d6aeab5c396e865ec..eafb6f2cfd517ce14ca8e95132566748d7791269 100644 --- a/multimedia/av_codec/video_encoder/BUILD.gn +++ b/multimedia/av_codec/video_encoder/BUILD.gn @@ -1,31 +1,31 @@ -# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") -ohos_ndk_headers("native_media_venc_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = - [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_videoencoder.h" ] -} - -ohos_ndk_library("libnative_media_venc") { - ndk_description_file = "./libnative_media_venc.ndk.json" - min_compact_version = "1" - output_name = "native_media_venc" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.VideoEncoder" - system_capability_headers = - [ "multimedia/player_framework/native_avcodec_videoencoder.h" ] -} +# Copyright (C) 2022 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("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_venc_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = + [ "//interface/sdk_c/multimedia/av_codec/native_avcodec_videoencoder.h" ] +} + +ohos_ndk_library("libnative_media_venc") { + ndk_description_file = "./libnative_media_venc.ndk.json" + min_compact_version = "1" + output_name = "native_media_venc" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.VideoEncoder" + system_capability_headers = + [ "multimedia/player_framework/native_avcodec_videoencoder.h" ] +} diff --git a/multimedia/av_codec/video_encoder/libnative_media_venc.ndk.json b/multimedia/av_codec/video_encoder/libnative_media_venc.ndk.json index 28febaa454ae601d1cdf476b495c4eed3892d950..d31e89f457626b298deca163efe8a5c92837e3cc 100644 --- a/multimedia/av_codec/video_encoder/libnative_media_venc.ndk.json +++ b/multimedia/av_codec/video_encoder/libnative_media_venc.ndk.json @@ -1,20 +1,20 @@ -[ - { "name": "OH_VideoEncoder_CreateByMime" }, - { "name": "OH_VideoEncoder_CreateByName" }, - { "name": "OH_VideoEncoder_Destroy" }, - { "name": "OH_VideoEncoder_SetCallback" }, - { "name": "OH_VideoEncoder_Configure" }, - { "name": "OH_VideoEncoder_Prepare" }, - { "name": "OH_VideoEncoder_Start" }, - { "name": "OH_VideoEncoder_Stop" }, - { "name": "OH_VideoEncoder_Flush" }, - { "name": "OH_VideoEncoder_Reset" }, - { "name": "OH_VideoEncoder_GetOutputDescription" }, - { "name": "OH_VideoEncoder_SetParameter" }, - { "name": "OH_VideoEncoder_GetSurface" }, - { "name": "OH_VideoEncoder_FreeOutputData" }, - { "name": "OH_VideoEncoder_NotifyEndOfStream" }, - { "name": "OH_VideoEncoder_PushInputData" }, - { "name": "OH_VideoEncoder_GetInputDescription" }, - { "name": "OH_VideoEncoder_IsValid" } -] +[ + { "name": "OH_VideoEncoder_CreateByMime" }, + { "name": "OH_VideoEncoder_CreateByName" }, + { "name": "OH_VideoEncoder_Destroy" }, + { "name": "OH_VideoEncoder_SetCallback" }, + { "name": "OH_VideoEncoder_Configure" }, + { "name": "OH_VideoEncoder_Prepare" }, + { "name": "OH_VideoEncoder_Start" }, + { "name": "OH_VideoEncoder_Stop" }, + { "name": "OH_VideoEncoder_Flush" }, + { "name": "OH_VideoEncoder_Reset" }, + { "name": "OH_VideoEncoder_GetOutputDescription" }, + { "name": "OH_VideoEncoder_SetParameter" }, + { "name": "OH_VideoEncoder_GetSurface" }, + { "name": "OH_VideoEncoder_FreeOutputData" }, + { "name": "OH_VideoEncoder_NotifyEndOfStream" }, + { "name": "OH_VideoEncoder_PushInputData" }, + { "name": "OH_VideoEncoder_GetInputDescription" }, + { "name": "OH_VideoEncoder_IsValid" } +] diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index 833b5fb732632ab0fedfef405157769e9f766cc3..c6e37ae888de0bedf7126ab72dff564b842ccbc5 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -1,64 +1,64 @@ -# Copyright (C) 2022 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") - -ohos_ndk_library("libpixelmap_ndk") { - ndk_description_file = "./libimage_pixelmap_napi.ndk.json" - min_compact_version = "1" - output_name = "pixelmap_ndk" -} - -ohos_ndk_headers("image_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" - sources = [ - "./include/image_pixel_map_mdk.h", - "./include/image_pixel_map_napi.h", - ] -} - -ohos_ndk_library("libimage_ndk") { - ndk_description_file = "./libimage_ndk.ndk.json" - min_compact_version = "1" - output_name = "image_ndk" -} - -ohos_ndk_headers("image_ndk_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" - sources = [ - "./include/image_mdk.h", - "./include/image_mdk_common.h", - ] -} - -ohos_ndk_library("libimage_receiver_ndk") { - ndk_description_file = "./libimage_receiver_ndk.ndk.json" - min_compact_version = "1" - output_name = "image_receiver_ndk" -} - -ohos_ndk_headers("image_receiver_ndk_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" - sources = [ "./include/image_receiver_mdk.h" ] -} - -ohos_ndk_library("libimage_source_ndk") { - ndk_description_file = "./libimage_source_ndk.ndk.json" - min_compact_version = "1" - output_name = "image_source_ndk" -} - -ohos_ndk_headers("image_source_ndk_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" - sources = [ "./include/image_source_mdk.h" ] -} +# Copyright (C) 2022 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") + +ohos_ndk_library("libpixelmap_ndk") { + ndk_description_file = "./libimage_pixelmap_napi.ndk.json" + min_compact_version = "1" + output_name = "pixelmap_ndk" +} + +ohos_ndk_headers("image_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ + "./include/image_pixel_map_mdk.h", + "./include/image_pixel_map_napi.h", + ] +} + +ohos_ndk_library("libimage_ndk") { + ndk_description_file = "./libimage_ndk.ndk.json" + min_compact_version = "1" + output_name = "image_ndk" +} + +ohos_ndk_headers("image_ndk_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ + "./include/image_mdk.h", + "./include/image_mdk_common.h", + ] +} + +ohos_ndk_library("libimage_receiver_ndk") { + ndk_description_file = "./libimage_receiver_ndk.ndk.json" + min_compact_version = "1" + output_name = "image_receiver_ndk" +} + +ohos_ndk_headers("image_receiver_ndk_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ "./include/image_receiver_mdk.h" ] +} + +ohos_ndk_library("libimage_source_ndk") { + ndk_description_file = "./libimage_source_ndk.ndk.json" + min_compact_version = "1" + output_name = "image_source_ndk" +} + +ohos_ndk_headers("image_source_ndk_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ "./include/image_source_mdk.h" ] +} diff --git a/multimedia/image_framework/include/image_mdk.h b/multimedia/image_framework/include/image_mdk.h index cb1aa629a37a0b2fe1971bfe4a55a71925517b5e..c6b2385c3b9368085c0dd7930232225f1069061a 100644 --- a/multimedia/image_framework/include/image_mdk.h +++ b/multimedia/image_framework/include/image_mdk.h @@ -1,221 +1,221 @@ -/* - * 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. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 2.0 - */ - -/** - * @file image_mdk.h - * - * @brief Declares functions that access the image rectangle, size, format, and component data. - * Need link libimagendk.z.so - * - * @since 10 - * @version 2.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ -#include "napi/native_api.h" -#include "image_mdk_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct ImageNative_; - -/** - * @brief Defines an image object at the native layer for the image interface. - * - * @since 10 - * @version 2.0 - */ -typedef struct ImageNative_ ImageNative; - -/** - * @brief Enumerates the image formats. - * - * @since 10 - * @version 2.0 - */ -enum { - /** YCbCr422 semi-planar format. */ - OHOS_IMAGE_FORMAT_YCBCR_422_SP = 1000, - /** JPEG encoding format. */ - OHOS_IMAGE_FORMAT_JPEG = 2000 -}; - -/** - * @brief Enumerates the image components. - * - * @since 10 - * @version 2.0 - */ -enum { - /** Luminance component. */ - OHOS_IMAGE_COMPONENT_FORMAT_YUV_Y = 1, - /** Chrominance component - blue projection. */ - OHOS_IMAGE_COMPONENT_FORMAT_YUV_U = 2, - /** Chrominance component - red projection. */ - OHOS_IMAGE_COMPONENT_FORMAT_YUV_V = 3, - /** JPEG format. */ - OHOS_IMAGE_COMPONENT_FORMAT_JPEG = 4, -}; - -/** - * @brief Defines the information about an image rectangle. - * - * @since 10 - * @version 2.0 - */ -struct OhosImageRect { - /** X coordinate of the rectangle. */ - int32_t x; - /** Y coordinate of the rectangle. */ - int32_t y; - /** Width of the rectangle, in pixels. */ - int32_t width; - /** Height of the rectangle, in pixels. */ - int32_t height; -}; - -/** - * @brief Defines the image composition information. - * - * @since 10 - * @version 2.0 - */ -struct OhosImageComponent { - /** Buffer that stores the pixel data. */ - uint8_t* byteBuffer; - /** Size of the pixel data in the memory. */ - size_t size; - /** Type of the pixel data. */ - int32_t componentType; - /** Row stride of the pixel data. */ - int32_t rowStride; - /** Pixel stride of the pixel data */ - int32_t pixelStride; -}; - -/** - * @brief Parses an {@link ImageNative} object at the native layer from a JavaScript native API image object. - * - * @param env Indicates the pointer to the Java Native Interface (JNI) environment. - * @param source Indicates a JavaScript native API image object. - * @return Returns an {@link ImageNative} pointer object if the operation is successful - * returns a null pointer otherwise. - * @see ImageNative, OH_Image_Release - * @since 10 - * @version 2.0 - */ -ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source); - -/** - * @brief Obtains {@link OhosImageRect} of an {@link ImageNative} at the native layer. - * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. - * @param rect Indicates the pointer to the {@link OhosImageRect} object obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * @see ImageNative, OhosImageRect - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect); - -/** - * @brief Obtains {@link OhosImageSize} of an {@link ImageNative} object at the native layer. - * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. - * @param size Indicates the pointer to the {@link OhosImageSize} object obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * @see ImageNative, OhosImageSize - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size); - -/** - * @brief Obtains the image format of an {@link ImageNative} object at the native layer. - * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. - * @param format Indicates the pointer to the image format obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * @see ImageNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Format(const ImageNative* native, int32_t* format); - -/** - * @brief Obtains {@link OhosImageComponent} of an {@link ImageNative} object at the native layer. - * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. - * @param componentType Indicates the type of the required component. - * @param componentNative Indicates the pointer to the {@link OhosImageComponent} object obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * @see ImageNative, OhosImageComponent - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_GetComponent(const ImageNative* native, - int32_t componentType, struct OhosImageComponent* componentNative); - -/** - * @brief Releases an {@link ImageNative} object at the native layer. - * Note: This API is not used to release a JavaScript native API Image object. - * It is used to release the object {@link ImageNative} at the native layer - * parsed by calling {@link OH_Image_InitImageNative}. - * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * @see ImageNative, OH_Image_InitImageNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Release(ImageNative* native); -#ifdef __cplusplus -}; -#endif -/** @} */ -#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ +/* + * 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. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 2.0 + */ + +/** + * @file image_mdk.h + * + * @brief Declares functions that access the image rectangle, size, format, and component data. + * Need link libimagendk.z.so + * + * @since 10 + * @version 2.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ +#include "napi/native_api.h" +#include "image_mdk_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct ImageNative_; + +/** + * @brief Defines an image object at the native layer for the image interface. + * + * @since 10 + * @version 2.0 + */ +typedef struct ImageNative_ ImageNative; + +/** + * @brief Enumerates the image formats. + * + * @since 10 + * @version 2.0 + */ +enum { + /** YCbCr422 semi-planar format. */ + OHOS_IMAGE_FORMAT_YCBCR_422_SP = 1000, + /** JPEG encoding format. */ + OHOS_IMAGE_FORMAT_JPEG = 2000 +}; + +/** + * @brief Enumerates the image components. + * + * @since 10 + * @version 2.0 + */ +enum { + /** Luminance component. */ + OHOS_IMAGE_COMPONENT_FORMAT_YUV_Y = 1, + /** Chrominance component - blue projection. */ + OHOS_IMAGE_COMPONENT_FORMAT_YUV_U = 2, + /** Chrominance component - red projection. */ + OHOS_IMAGE_COMPONENT_FORMAT_YUV_V = 3, + /** JPEG format. */ + OHOS_IMAGE_COMPONENT_FORMAT_JPEG = 4, +}; + +/** + * @brief Defines the information about an image rectangle. + * + * @since 10 + * @version 2.0 + */ +struct OhosImageRect { + /** X coordinate of the rectangle. */ + int32_t x; + /** Y coordinate of the rectangle. */ + int32_t y; + /** Width of the rectangle, in pixels. */ + int32_t width; + /** Height of the rectangle, in pixels. */ + int32_t height; +}; + +/** + * @brief Defines the image composition information. + * + * @since 10 + * @version 2.0 + */ +struct OhosImageComponent { + /** Buffer that stores the pixel data. */ + uint8_t* byteBuffer; + /** Size of the pixel data in the memory. */ + size_t size; + /** Type of the pixel data. */ + int32_t componentType; + /** Row stride of the pixel data. */ + int32_t rowStride; + /** Pixel stride of the pixel data */ + int32_t pixelStride; +}; + +/** + * @brief Parses an {@link ImageNative} object at the native layer from a JavaScript native API image object. + * + * @param env Indicates the pointer to the Java Native Interface (JNI) environment. + * @param source Indicates a JavaScript native API image object. + * @return Returns an {@link ImageNative} pointer object if the operation is successful + * returns a null pointer otherwise. + * @see ImageNative, OH_Image_Release + * @since 10 + * @version 2.0 + */ +ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source); + +/** + * @brief Obtains {@link OhosImageRect} of an {@link ImageNative} at the native layer. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @param rect Indicates the pointer to the {@link OhosImageRect} object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OhosImageRect + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect); + +/** + * @brief Obtains {@link OhosImageSize} of an {@link ImageNative} object at the native layer. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @param size Indicates the pointer to the {@link OhosImageSize} object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OhosImageSize + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size); + +/** + * @brief Obtains the image format of an {@link ImageNative} object at the native layer. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @param format Indicates the pointer to the image format obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * @see ImageNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Format(const ImageNative* native, int32_t* format); + +/** + * @brief Obtains {@link OhosImageComponent} of an {@link ImageNative} object at the native layer. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @param componentType Indicates the type of the required component. + * @param componentNative Indicates the pointer to the {@link OhosImageComponent} object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OhosImageComponent + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_GetComponent(const ImageNative* native, + int32_t componentType, struct OhosImageComponent* componentNative); + +/** + * @brief Releases an {@link ImageNative} object at the native layer. + * Note: This API is not used to release a JavaScript native API Image object. + * It is used to release the object {@link ImageNative} at the native layer + * parsed by calling {@link OH_Image_InitImageNative}. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OH_Image_InitImageNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Release(ImageNative* native); +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ diff --git a/multimedia/image_framework/include/image_mdk_common.h b/multimedia/image_framework/include/image_mdk_common.h index 65fe6088571c846f5aa15c6fb609885d596bef93..92eb68c9e88e41efb459199502a5d5584ed35550 100644 --- a/multimedia/image_framework/include/image_mdk_common.h +++ b/multimedia/image_framework/include/image_mdk_common.h @@ -1,180 +1,180 @@ -/* - * 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. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 2.0 - */ - -/** - * @file image_mdk_common.h - * - * @brief Declares the common enums and structs used by the image interface. - * - * @since 10 - * @version 2.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_COMMON_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_COMMON_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif -#define IMAGE_RESULT_BASE 62980096 -/** - * @brief Enumerates the return values that may be used by the interface. - * - * @since 10 - * @version 2.0 - */ -typedef enum { - IMAGE_RESULT_SUCCESS = 0, // Operation success - IMAGE_RESULT_BAD_PARAMETER = -1, // Invalid parameter - IMAGE_RESULT_IMAGE_RESULT_BASE = IMAGE_RESULT_BASE, // Operation failed - IMAGE_RESULT_ERR_IPC = IMAGE_RESULT_BASE + 1, // ipc error - IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST = IMAGE_RESULT_BASE + 2, // sharememory error - IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL = IMAGE_RESULT_BASE + 3, // sharememory data abnormal - IMAGE_RESULT_DECODE_ABNORMAL = IMAGE_RESULT_BASE + 4, // image decode error - IMAGE_RESULT_DATA_ABNORMAL = IMAGE_RESULT_BASE + 5, // image input data error - IMAGE_RESULT_MALLOC_ABNORMAL = IMAGE_RESULT_BASE + 6, // image malloc error - IMAGE_RESULT_DATA_UNSUPPORT = IMAGE_RESULT_BASE + 7, // image type unsupported - IMAGE_RESULT_INIT_ABNORMAL = IMAGE_RESULT_BASE + 8, // image init error - IMAGE_RESULT_GET_DATA_ABNORMAL = IMAGE_RESULT_BASE + 9, // image get data error - IMAGE_RESULT_TOO_LARGE = IMAGE_RESULT_BASE + 10, // image data too large - IMAGE_RESULT_TRANSFORM = IMAGE_RESULT_BASE + 11, // image transform error - IMAGE_RESULT_COLOR_CONVERT = IMAGE_RESULT_BASE + 12, // image color convert error - IMAGE_RESULT_CROP = IMAGE_RESULT_BASE + 13, // crop error - IMAGE_RESULT_SOURCE_DATA = IMAGE_RESULT_BASE + 14, // image source data error - IMAGE_RESULT_SOURCE_DATA_INCOMPLETE = IMAGE_RESULT_BASE + 15, // image source data incomplete - IMAGE_RESULT_MISMATCHED_FORMAT = IMAGE_RESULT_BASE + 16, // image mismatched format - IMAGE_RESULT_UNKNOWN_FORMAT = IMAGE_RESULT_BASE + 17, // image unknown format - IMAGE_RESULT_SOURCE_UNRESOLVED = IMAGE_RESULT_BASE + 18, // image source unresolved - IMAGE_RESULT_INVALID_PARAMETER = IMAGE_RESULT_BASE + 19, // image invalid parameter - IMAGE_RESULT_DECODE_FAILED = IMAGE_RESULT_BASE + 20, // decode fail - IMAGE_RESULT_PLUGIN_REGISTER_FAILED = IMAGE_RESULT_BASE + 21, // register plugin fail - IMAGE_RESULT_PLUGIN_CREATE_FAILED = IMAGE_RESULT_BASE + 22, // create plugin fail - IMAGE_RESULT_ENCODE_FAILED = IMAGE_RESULT_BASE + 23, // image encode fail - IMAGE_RESULT_ADD_PIXEL_MAP_FAILED = IMAGE_RESULT_BASE + 24, // image add pixel map fail - IMAGE_RESULT_HW_DECODE_UNSUPPORT = IMAGE_RESULT_BASE + 25, // image hardware decode unsupported - IMAGE_RESULT_DECODE_HEAD_ABNORMAL = IMAGE_RESULT_BASE + 26, // image decode head error - IMAGE_RESULT_DECODE_EXIF_UNSUPPORT = IMAGE_RESULT_BASE + 27, // image decode exif unsupport - IMAGE_RESULT_PROPERTY_NOT_EXIST = IMAGE_RESULT_BASE + 28, // image property not exist - - IMAGE_RESULT_MEDIA_DATA_UNSUPPORT = IMAGE_RESULT_BASE + 30, // media type unsupported - IMAGE_RESULT_MEDIA_TOO_LARGE = IMAGE_RESULT_BASE + 31, // media data too large - IMAGE_RESULT_MEDIA_MALLOC_FAILED = IMAGE_RESULT_BASE + 32, // media malloc memory failed - IMAGE_RESULT_MEDIA_END_OF_STREAM = IMAGE_RESULT_BASE + 33, // media end of stream error - IMAGE_RESULT_MEDIA_IO_ABNORMAL = IMAGE_RESULT_BASE + 34, // media io error - IMAGE_RESULT_MEDIA_MALFORMED = IMAGE_RESULT_BASE + 35, // media malformed error - IMAGE_RESULT_MEDIA_BUFFER_TOO_SMALL = IMAGE_RESULT_BASE + 36, // media buffer too small error - IMAGE_RESULT_MEDIA_OUT_OF_RANGE = IMAGE_RESULT_BASE + 37, // media out of range error - IMAGE_RESULT_MEDIA_STATUS_ABNORMAL = IMAGE_RESULT_BASE + 38, // media status abnormal error - IMAGE_RESULT_MEDIA_VALUE_INVALID = IMAGE_RESULT_BASE + 39, // media value invalid - IMAGE_RESULT_MEDIA_NULL_POINTER = IMAGE_RESULT_BASE + 40, // media error operation - IMAGE_RESULT_MEDIA_INVALID_OPERATION = IMAGE_RESULT_BASE + 41, // media invalid operation - IMAGE_RESULT_MEDIA_ERR_PLAYER_NOT_INIT = IMAGE_RESULT_BASE + 42, // media init error - IMAGE_RESULT_MEDIA_EARLY_PREPARE = IMAGE_RESULT_BASE + 43, // media early prepare - IMAGE_RESULT_MEDIA_SEEK_ERR = IMAGE_RESULT_BASE + 44, // media rewind error - IMAGE_RESULT_MEDIA_PERMISSION_DENIED = IMAGE_RESULT_BASE + 45, // media permission denied - IMAGE_RESULT_MEDIA_DEAD_OBJECT = IMAGE_RESULT_BASE + 46, // media dead object - IMAGE_RESULT_MEDIA_TIMED_OUT = IMAGE_RESULT_BASE + 47, // media time out - IMAGE_RESULT_MEDIA_TRACK_NOT_ALL_SUPPORTED = IMAGE_RESULT_BASE + 48, // media track subset support - IMAGE_RESULT_MEDIA_ADAPTER_INIT_FAILED = IMAGE_RESULT_BASE + 49, // media recorder adapter init failed - IMAGE_RESULT_MEDIA_WRITE_PARCEL_FAIL = IMAGE_RESULT_BASE + 50, // write parcel failed - IMAGE_RESULT_MEDIA_READ_PARCEL_FAIL = IMAGE_RESULT_BASE + 51, // read parcel failed - IMAGE_RESULT_MEDIA_NO_AVAIL_BUFFER = IMAGE_RESULT_BASE + 52, // read parcel failed - IMAGE_RESULT_MEDIA_INVALID_PARAM = IMAGE_RESULT_BASE + 53, // media function found invalid param - IMAGE_RESULT_MEDIA_CODEC_ADAPTER_NOT_EXIST = IMAGE_RESULT_BASE + 54, // media zcodec adapter not init - IMAGE_RESULT_MEDIA_CREATE_CODEC_ADAPTER_FAILED = IMAGE_RESULT_BASE + 55, // media create zcodec adapter failed - IMAGE_RESULT_MEDIA_CODEC_ADAPTER_NOT_INIT = IMAGE_RESULT_BASE + 56, // media adapter inner not init - IMAGE_RESULT_MEDIA_ZCODEC_CREATE_FAILED = IMAGE_RESULT_BASE + 57, // media adapter inner not init - IMAGE_RESULT_MEDIA_ZCODEC_NOT_EXIST = IMAGE_RESULT_BASE + 58, // media zcodec not exist - IMAGE_RESULT_MEDIA_JNI_CLASS_NOT_EXIST = IMAGE_RESULT_BASE + 59, // media jni class not found - IMAGE_RESULT_MEDIA_JNI_METHOD_NOT_EXIST = IMAGE_RESULT_BASE + 60, // media jni method not found - IMAGE_RESULT_MEDIA_JNI_NEW_OBJ_FAILED = IMAGE_RESULT_BASE + 61, // media jni obj new failed - IMAGE_RESULT_MEDIA_JNI_COMMON_ERROR = IMAGE_RESULT_BASE + 62, // media jni normal error - IMAGE_RESULT_MEDIA_DISTRIBUTE_NOT_SUPPORT = IMAGE_RESULT_BASE + 63, // media distribute not support - IMAGE_RESULT_MEDIA_SOURCE_NOT_SET = IMAGE_RESULT_BASE + 64, // media source not set - IMAGE_RESULT_MEDIA_RTSP_ADAPTER_NOT_INIT = IMAGE_RESULT_BASE + 65, // media rtsp adapter not init - IMAGE_RESULT_MEDIA_RTSP_ADAPTER_NOT_EXIST = IMAGE_RESULT_BASE + 66, // media rtsp adapter not exist - IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT = IMAGE_RESULT_BASE + 67, // media rtsp surface not support - IMAGE_RESULT_MEDIA_RTSP_CAPTURE_NOT_INIT = IMAGE_RESULT_BASE + 68, // media rtsp capture init error - IMAGE_RESULT_MEDIA_RTSP_SOURCE_URL_INVALID = IMAGE_RESULT_BASE + 69, // media rtsp source url invalid - IMAGE_RESULT_MEDIA_RTSP_VIDEO_TRACK_NOT_FOUND = IMAGE_RESULT_BASE + 70, // media rtsp can't find video track - IMAGE_RESULT_MEDIA_RTSP_CAMERA_NUM_REACH_MAX = IMAGE_RESULT_BASE + 71, // rtsp camera num reach to max num - IMAGE_RESULT_MEDIA_SET_VOLUME = IMAGE_RESULT_BASE + 72, // media set volume error - IMAGE_RESULT_MEDIA_NUMBER_OVERFLOW = IMAGE_RESULT_BASE + 73, // media number operation overflow - IMAGE_RESULT_MEDIA_DIS_PLAYER_UNSUPPORTED = IMAGE_RESULT_BASE + 74, // media distribute player unsupporteded - IMAGE_RESULT_MEDIA_DENCODE_ICC_FAILED = IMAGE_RESULT_BASE + 75, // image dencode ICC fail - IMAGE_RESULT_MEDIA_ENCODE_ICC_FAILED = IMAGE_RESULT_BASE + 76, // image encode ICC fail - - IMAGE_RESULT_MEDIA_READ_PIXELMAP_FAILED = IMAGE_RESULT_BASE + 150, // read pixelmap failed - IMAGE_RESULT_MEDIA_WRITE_PIXELMAP_FAILED = IMAGE_RESULT_BASE + 151, // write pixelmap failed - IMAGE_RESULT_MEDIA_PIXELMAP_NOT_ALLOW_MODIFY = IMAGE_RESULT_BASE + 152, // pixelmap not allow modify - IMAGE_RESULT_MEDIA_CONFIG_FAILED = IMAGE_RESULT_BASE + 153, // config error - IMAGE_RESULT_JNI_ENV_ABNORMAL = IMAGE_RESULT_BASE + 154, // Abnormal JNI environment - IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED = IMAGE_RESULT_BASE + 155, // surface gralloc buffer failed - IMAGE_RESULT_CREATE_SURFACE_FAILED = IMAGE_RESULT_BASE + 156, // create surface failed - IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED = IMAGE_RESULT_BASE + 157, // Failed to obtain parameters for surface - IMAGE_RESULT_GET_SURFACE_FAILED = IMAGE_RESULT_BASE + 158, // get sufrace failed - IMAGE_RESULT_SURFACE_ACQUIRE_BUFFER_FAILED = IMAGE_RESULT_BASE + 159, // Acquire Buffer failed - IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED = IMAGE_RESULT_BASE + 160, // request Buffer failed - IMAGE_RESULT_REGISTER_LISTENER_FAILED = IMAGE_RESULT_BASE + 161, // Failed to register listener - IMAGE_RESULT_REGISTER_BUFFER_FAILED = IMAGE_RESULT_BASE + 162, // Failed to register buffer - IMAGE_RESULT_FREAD_FAILED = IMAGE_RESULT_BASE + 163, // read file failed - IMAGE_RESULT_PEEK_FAILED = IMAGE_RESULT_BASE + 164, // peek file failed - IMAGE_RESULT_SEEK_FAILED = IMAGE_RESULT_BASE + 165, // seek file failed - IMAGE_RESULT_STREAM_SIZE_ERROR = IMAGE_RESULT_BASE + 166, // stream bad - IMAGE_RESULT_FILE_FD_ERROR = IMAGE_RESULT_BASE + 167, // file fd is bad - IMAGE_RESULT_FILE_DAMAGED = IMAGE_RESULT_BASE + 168, // file damaged - IMAGE_RESULT_CREATE_DECODER_FAILED = IMAGE_RESULT_BASE + 169, // create decoder failed - IMAGE_RESULT_CREATE_ENCODER_FAILED = IMAGE_RESULT_BASE + 170, // create encoder failed - IMAGE_RESULT_CHECK_FORMAT_ERROR = IMAGE_RESULT_BASE + 171, // check format failed - IMAGE_RESULT_THIRDPART_SKIA_ERROR = IMAGE_RESULT_BASE + 172, // skia error - IMAGE_RESULT_HW_DECODE_FAILED = IMAGE_RESULT_BASE + 173, // hard decode failed - IMAGE_RESULT_ALLOCATER_TYPE_ERROR = IMAGE_RESULT_BASE + 174, // hard decode failed - IMAGE_RESULT_ALPHA_TYPE_ERROR = IMAGE_RESULT_BASE + 175, // hard decode failed - IMAGE_RESULT_INDEX_INVALID = IMAGE_RESULT_BASE + 176, // invalid index - - IMAGE_RESULT_MEDIA_UNKNOWN = IMAGE_RESULT_BASE + 200, // media unknown error -} IRNdkErrCode; - -/** - * @brief Defines the image size. - * - * @since 10 - * @version 2.0 - */ -struct OhosImageSize { - /** Image width, in pixels. */ - int32_t width; - /** Image height, in pixels. */ - int32_t height; -}; - -#ifdef __cplusplus -}; -#endif -/** @} */ - +/* + * 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. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 2.0 + */ + +/** + * @file image_mdk_common.h + * + * @brief Declares the common enums and structs used by the image interface. + * + * @since 10 + * @version 2.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_COMMON_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_COMMON_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif +#define IMAGE_RESULT_BASE 62980096 +/** + * @brief Enumerates the return values that may be used by the interface. + * + * @since 10 + * @version 2.0 + */ +typedef enum { + IMAGE_RESULT_SUCCESS = 0, // Operation success + IMAGE_RESULT_BAD_PARAMETER = -1, // Invalid parameter + IMAGE_RESULT_IMAGE_RESULT_BASE = IMAGE_RESULT_BASE, // Operation failed + IMAGE_RESULT_ERR_IPC = IMAGE_RESULT_BASE + 1, // ipc error + IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST = IMAGE_RESULT_BASE + 2, // sharememory error + IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL = IMAGE_RESULT_BASE + 3, // sharememory data abnormal + IMAGE_RESULT_DECODE_ABNORMAL = IMAGE_RESULT_BASE + 4, // image decode error + IMAGE_RESULT_DATA_ABNORMAL = IMAGE_RESULT_BASE + 5, // image input data error + IMAGE_RESULT_MALLOC_ABNORMAL = IMAGE_RESULT_BASE + 6, // image malloc error + IMAGE_RESULT_DATA_UNSUPPORT = IMAGE_RESULT_BASE + 7, // image type unsupported + IMAGE_RESULT_INIT_ABNORMAL = IMAGE_RESULT_BASE + 8, // image init error + IMAGE_RESULT_GET_DATA_ABNORMAL = IMAGE_RESULT_BASE + 9, // image get data error + IMAGE_RESULT_TOO_LARGE = IMAGE_RESULT_BASE + 10, // image data too large + IMAGE_RESULT_TRANSFORM = IMAGE_RESULT_BASE + 11, // image transform error + IMAGE_RESULT_COLOR_CONVERT = IMAGE_RESULT_BASE + 12, // image color convert error + IMAGE_RESULT_CROP = IMAGE_RESULT_BASE + 13, // crop error + IMAGE_RESULT_SOURCE_DATA = IMAGE_RESULT_BASE + 14, // image source data error + IMAGE_RESULT_SOURCE_DATA_INCOMPLETE = IMAGE_RESULT_BASE + 15, // image source data incomplete + IMAGE_RESULT_MISMATCHED_FORMAT = IMAGE_RESULT_BASE + 16, // image mismatched format + IMAGE_RESULT_UNKNOWN_FORMAT = IMAGE_RESULT_BASE + 17, // image unknown format + IMAGE_RESULT_SOURCE_UNRESOLVED = IMAGE_RESULT_BASE + 18, // image source unresolved + IMAGE_RESULT_INVALID_PARAMETER = IMAGE_RESULT_BASE + 19, // image invalid parameter + IMAGE_RESULT_DECODE_FAILED = IMAGE_RESULT_BASE + 20, // decode fail + IMAGE_RESULT_PLUGIN_REGISTER_FAILED = IMAGE_RESULT_BASE + 21, // register plugin fail + IMAGE_RESULT_PLUGIN_CREATE_FAILED = IMAGE_RESULT_BASE + 22, // create plugin fail + IMAGE_RESULT_ENCODE_FAILED = IMAGE_RESULT_BASE + 23, // image encode fail + IMAGE_RESULT_ADD_PIXEL_MAP_FAILED = IMAGE_RESULT_BASE + 24, // image add pixel map fail + IMAGE_RESULT_HW_DECODE_UNSUPPORT = IMAGE_RESULT_BASE + 25, // image hardware decode unsupported + IMAGE_RESULT_DECODE_HEAD_ABNORMAL = IMAGE_RESULT_BASE + 26, // image decode head error + IMAGE_RESULT_DECODE_EXIF_UNSUPPORT = IMAGE_RESULT_BASE + 27, // image decode exif unsupport + IMAGE_RESULT_PROPERTY_NOT_EXIST = IMAGE_RESULT_BASE + 28, // image property not exist + + IMAGE_RESULT_MEDIA_DATA_UNSUPPORT = IMAGE_RESULT_BASE + 30, // media type unsupported + IMAGE_RESULT_MEDIA_TOO_LARGE = IMAGE_RESULT_BASE + 31, // media data too large + IMAGE_RESULT_MEDIA_MALLOC_FAILED = IMAGE_RESULT_BASE + 32, // media malloc memory failed + IMAGE_RESULT_MEDIA_END_OF_STREAM = IMAGE_RESULT_BASE + 33, // media end of stream error + IMAGE_RESULT_MEDIA_IO_ABNORMAL = IMAGE_RESULT_BASE + 34, // media io error + IMAGE_RESULT_MEDIA_MALFORMED = IMAGE_RESULT_BASE + 35, // media malformed error + IMAGE_RESULT_MEDIA_BUFFER_TOO_SMALL = IMAGE_RESULT_BASE + 36, // media buffer too small error + IMAGE_RESULT_MEDIA_OUT_OF_RANGE = IMAGE_RESULT_BASE + 37, // media out of range error + IMAGE_RESULT_MEDIA_STATUS_ABNORMAL = IMAGE_RESULT_BASE + 38, // media status abnormal error + IMAGE_RESULT_MEDIA_VALUE_INVALID = IMAGE_RESULT_BASE + 39, // media value invalid + IMAGE_RESULT_MEDIA_NULL_POINTER = IMAGE_RESULT_BASE + 40, // media error operation + IMAGE_RESULT_MEDIA_INVALID_OPERATION = IMAGE_RESULT_BASE + 41, // media invalid operation + IMAGE_RESULT_MEDIA_ERR_PLAYER_NOT_INIT = IMAGE_RESULT_BASE + 42, // media init error + IMAGE_RESULT_MEDIA_EARLY_PREPARE = IMAGE_RESULT_BASE + 43, // media early prepare + IMAGE_RESULT_MEDIA_SEEK_ERR = IMAGE_RESULT_BASE + 44, // media rewind error + IMAGE_RESULT_MEDIA_PERMISSION_DENIED = IMAGE_RESULT_BASE + 45, // media permission denied + IMAGE_RESULT_MEDIA_DEAD_OBJECT = IMAGE_RESULT_BASE + 46, // media dead object + IMAGE_RESULT_MEDIA_TIMED_OUT = IMAGE_RESULT_BASE + 47, // media time out + IMAGE_RESULT_MEDIA_TRACK_NOT_ALL_SUPPORTED = IMAGE_RESULT_BASE + 48, // media track subset support + IMAGE_RESULT_MEDIA_ADAPTER_INIT_FAILED = IMAGE_RESULT_BASE + 49, // media recorder adapter init failed + IMAGE_RESULT_MEDIA_WRITE_PARCEL_FAIL = IMAGE_RESULT_BASE + 50, // write parcel failed + IMAGE_RESULT_MEDIA_READ_PARCEL_FAIL = IMAGE_RESULT_BASE + 51, // read parcel failed + IMAGE_RESULT_MEDIA_NO_AVAIL_BUFFER = IMAGE_RESULT_BASE + 52, // read parcel failed + IMAGE_RESULT_MEDIA_INVALID_PARAM = IMAGE_RESULT_BASE + 53, // media function found invalid param + IMAGE_RESULT_MEDIA_CODEC_ADAPTER_NOT_EXIST = IMAGE_RESULT_BASE + 54, // media zcodec adapter not init + IMAGE_RESULT_MEDIA_CREATE_CODEC_ADAPTER_FAILED = IMAGE_RESULT_BASE + 55, // media create zcodec adapter failed + IMAGE_RESULT_MEDIA_CODEC_ADAPTER_NOT_INIT = IMAGE_RESULT_BASE + 56, // media adapter inner not init + IMAGE_RESULT_MEDIA_ZCODEC_CREATE_FAILED = IMAGE_RESULT_BASE + 57, // media adapter inner not init + IMAGE_RESULT_MEDIA_ZCODEC_NOT_EXIST = IMAGE_RESULT_BASE + 58, // media zcodec not exist + IMAGE_RESULT_MEDIA_JNI_CLASS_NOT_EXIST = IMAGE_RESULT_BASE + 59, // media jni class not found + IMAGE_RESULT_MEDIA_JNI_METHOD_NOT_EXIST = IMAGE_RESULT_BASE + 60, // media jni method not found + IMAGE_RESULT_MEDIA_JNI_NEW_OBJ_FAILED = IMAGE_RESULT_BASE + 61, // media jni obj new failed + IMAGE_RESULT_MEDIA_JNI_COMMON_ERROR = IMAGE_RESULT_BASE + 62, // media jni normal error + IMAGE_RESULT_MEDIA_DISTRIBUTE_NOT_SUPPORT = IMAGE_RESULT_BASE + 63, // media distribute not support + IMAGE_RESULT_MEDIA_SOURCE_NOT_SET = IMAGE_RESULT_BASE + 64, // media source not set + IMAGE_RESULT_MEDIA_RTSP_ADAPTER_NOT_INIT = IMAGE_RESULT_BASE + 65, // media rtsp adapter not init + IMAGE_RESULT_MEDIA_RTSP_ADAPTER_NOT_EXIST = IMAGE_RESULT_BASE + 66, // media rtsp adapter not exist + IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT = IMAGE_RESULT_BASE + 67, // media rtsp surface not support + IMAGE_RESULT_MEDIA_RTSP_CAPTURE_NOT_INIT = IMAGE_RESULT_BASE + 68, // media rtsp capture init error + IMAGE_RESULT_MEDIA_RTSP_SOURCE_URL_INVALID = IMAGE_RESULT_BASE + 69, // media rtsp source url invalid + IMAGE_RESULT_MEDIA_RTSP_VIDEO_TRACK_NOT_FOUND = IMAGE_RESULT_BASE + 70, // media rtsp can't find video track + IMAGE_RESULT_MEDIA_RTSP_CAMERA_NUM_REACH_MAX = IMAGE_RESULT_BASE + 71, // rtsp camera num reach to max num + IMAGE_RESULT_MEDIA_SET_VOLUME = IMAGE_RESULT_BASE + 72, // media set volume error + IMAGE_RESULT_MEDIA_NUMBER_OVERFLOW = IMAGE_RESULT_BASE + 73, // media number operation overflow + IMAGE_RESULT_MEDIA_DIS_PLAYER_UNSUPPORTED = IMAGE_RESULT_BASE + 74, // media distribute player unsupporteded + IMAGE_RESULT_MEDIA_DENCODE_ICC_FAILED = IMAGE_RESULT_BASE + 75, // image dencode ICC fail + IMAGE_RESULT_MEDIA_ENCODE_ICC_FAILED = IMAGE_RESULT_BASE + 76, // image encode ICC fail + + IMAGE_RESULT_MEDIA_READ_PIXELMAP_FAILED = IMAGE_RESULT_BASE + 150, // read pixelmap failed + IMAGE_RESULT_MEDIA_WRITE_PIXELMAP_FAILED = IMAGE_RESULT_BASE + 151, // write pixelmap failed + IMAGE_RESULT_MEDIA_PIXELMAP_NOT_ALLOW_MODIFY = IMAGE_RESULT_BASE + 152, // pixelmap not allow modify + IMAGE_RESULT_MEDIA_CONFIG_FAILED = IMAGE_RESULT_BASE + 153, // config error + IMAGE_RESULT_JNI_ENV_ABNORMAL = IMAGE_RESULT_BASE + 154, // Abnormal JNI environment + IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED = IMAGE_RESULT_BASE + 155, // surface gralloc buffer failed + IMAGE_RESULT_CREATE_SURFACE_FAILED = IMAGE_RESULT_BASE + 156, // create surface failed + IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED = IMAGE_RESULT_BASE + 157, // Failed to obtain parameters for surface + IMAGE_RESULT_GET_SURFACE_FAILED = IMAGE_RESULT_BASE + 158, // get sufrace failed + IMAGE_RESULT_SURFACE_ACQUIRE_BUFFER_FAILED = IMAGE_RESULT_BASE + 159, // Acquire Buffer failed + IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED = IMAGE_RESULT_BASE + 160, // request Buffer failed + IMAGE_RESULT_REGISTER_LISTENER_FAILED = IMAGE_RESULT_BASE + 161, // Failed to register listener + IMAGE_RESULT_REGISTER_BUFFER_FAILED = IMAGE_RESULT_BASE + 162, // Failed to register buffer + IMAGE_RESULT_FREAD_FAILED = IMAGE_RESULT_BASE + 163, // read file failed + IMAGE_RESULT_PEEK_FAILED = IMAGE_RESULT_BASE + 164, // peek file failed + IMAGE_RESULT_SEEK_FAILED = IMAGE_RESULT_BASE + 165, // seek file failed + IMAGE_RESULT_STREAM_SIZE_ERROR = IMAGE_RESULT_BASE + 166, // stream bad + IMAGE_RESULT_FILE_FD_ERROR = IMAGE_RESULT_BASE + 167, // file fd is bad + IMAGE_RESULT_FILE_DAMAGED = IMAGE_RESULT_BASE + 168, // file damaged + IMAGE_RESULT_CREATE_DECODER_FAILED = IMAGE_RESULT_BASE + 169, // create decoder failed + IMAGE_RESULT_CREATE_ENCODER_FAILED = IMAGE_RESULT_BASE + 170, // create encoder failed + IMAGE_RESULT_CHECK_FORMAT_ERROR = IMAGE_RESULT_BASE + 171, // check format failed + IMAGE_RESULT_THIRDPART_SKIA_ERROR = IMAGE_RESULT_BASE + 172, // skia error + IMAGE_RESULT_HW_DECODE_FAILED = IMAGE_RESULT_BASE + 173, // hard decode failed + IMAGE_RESULT_ALLOCATER_TYPE_ERROR = IMAGE_RESULT_BASE + 174, // hard decode failed + IMAGE_RESULT_ALPHA_TYPE_ERROR = IMAGE_RESULT_BASE + 175, // hard decode failed + IMAGE_RESULT_INDEX_INVALID = IMAGE_RESULT_BASE + 176, // invalid index + + IMAGE_RESULT_MEDIA_UNKNOWN = IMAGE_RESULT_BASE + 200, // media unknown error +} IRNdkErrCode; + +/** + * @brief Defines the image size. + * + * @since 10 + * @version 2.0 + */ +struct OhosImageSize { + /** Image width, in pixels. */ + int32_t width; + /** Image height, in pixels. */ + int32_t height; +}; + +#ifdef __cplusplus +}; +#endif +/** @} */ + #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_COMMON_H_ \ No newline at end of file diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index cd511ca30a8a73080a93f7c7c150b5a578679b9b..9546e0ccde6eff171c0a4177ea17f4fec40f4335 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -1,615 +1,615 @@ -/* - * Copyright (C) 2022 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 pixel map data and information. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 1.0 - */ - -/** - * @file image_pixel_map_mdk.h - * - * @brief Declares the APIs that can lock, access, and unlock a pixel map. - * Need link libpixelmapndk.z.so - * - * @since 10 - * @version 1.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_MDK_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_MDK_H_ -#include -#include "napi/native_api.h" -#include "image_mdk_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines the native pixel map information. - * @since 10 - * @version 1.0 - */ -struct NativePixelMap_; - -/** - * @brief Defines the data type name of the native pixel map. - * @since 10 - * @version 1.0 - */ -typedef struct NativePixelMap_ NativePixelMap; - -/** - * @brief Defines the pixel map information. - * - * @since 10 - * @version 1.0 - */ -typedef struct OhosPixelMapInfos { - /** Image width, in pixels. */ - uint32_t width; - /** Image height, in pixels. */ - uint32_t height; - /** Number of bytes per row. */ - uint32_t rowSize; - /** Pixel format. */ - int32_t pixelFormat; -} OhosPixelMapInfos; - -/** - * @brief Enumerates the pixel map alpha types. - * - * @since 10 - * @version 1.0 - */ -enum { - /** - * Unknown format. - */ - OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0, - /** - * Opaque format. - */ - OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1, - /** - * Premultiplied format. - */ - OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2, - /** - * Unpremultiplied format. - */ - OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3 -}; - -/** - * @brief Enumerates the pixel map editing types. - * - * @since 10 - * @version 1.0 - */ -enum { - /** - * Read-only. - */ - OHOS_PIXEL_MAP_READ_ONLY = 0, - /** - * Editable. - */ - OHOS_PIXEL_MAP_EDITABLE = 1, -}; - -/** - * @brief Defines the options used for creating a pixel map. - * - * @since 10 - * @version 1.0 - */ -struct OhosPixelMapCreateOps { - /** Image width, in pixels. */ - uint32_t width; - /** Image height, in pixels. */ - uint32_t height; - /** Image format. */ - int32_t pixelFormat; - /** Editing type of the image. */ - uint32_t editable; - /** Alpha type of the image. */ - uint32_t alphaType; - /** Scale mode of the image. */ - uint32_t scaleMode; -}; - -/** - * @brief Creates a PixelMap object. - * - * @param env Indicates the NAPI environment pointer. - * @param info Indicates the options for setting the PixelMap object. - * @param buf Indicates the pointer to the buffer of the image. - * @param len Indicates the image size. - * @param res Indicates the pointer to the PixelMap object at the application layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see CreatePixelMap - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_CreatePixelMap(napi_env env, OhosPixelMapCreateOps info, - void* buf, size_t len, napi_value* res); - -/** - * @brief Creates a PixelMap object that contains only alpha channel information. - * - * @param env Indicates the NAPI environment pointer. - * @param source Indicates the options for setting the PixelMap object. - * @param alpha Indicates the pointer to the alpha channel. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see CreateAlphaPixelMap - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_CreateAlphaPixelMap(napi_env env, napi_value source, napi_value* alpha); - -/** - * @brief Initializes a PixelMap object. - * - * @param env Indicates the NAPI environment pointer. - * @param source Indicates the options for setting the PixelMap object. - * @return Returns a pointer to the NativePixelMap object - * if the operation is successful; returns nullptr otherwise. - * @see InitNativePixelMap - * @since 10 - * @version 1.0 - */ -NativePixelMap* OH_PixelMap_InitNativePixelMap(napi_env env, napi_value source); - -/** - * @brief Obtains the number of bytes per row of a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param num Indicates the pointer to the number of bytes per row of the PixelMap object. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see GetBytesNumberPerRow - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_GetBytesNumberPerRow(const NativePixelMap* native, int32_t* num); - -/** - * @brief Checks whether a PixelMap object is editable. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param editable Indicates the pointer to the editing type of the PixelMap object. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see GetIsEditable - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_GetIsEditable(const NativePixelMap* native, int32_t* editable); - -/** - * @brief Checks whether a PixelMap object supports alpha channels. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param alpha Indicates the pointer to the support for alpha channels. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see IsSupportAlpha - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_IsSupportAlpha(const NativePixelMap* native, int32_t* alpha); - -/** - * @brief Sets an alpha channel for a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param alpha Indicates the alpha channel to set. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see SetAlphaAble - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_SetAlphaAble(const NativePixelMap* native, int32_t alpha); - -/** - * @brief Obtains the pixel density of a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param density Indicates the pointer to the pixel density. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see GetDensity - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_GetDensity(const NativePixelMap* native, int32_t* density); - -/** - * @brief Sets the pixel density for a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param density Indicates the pixel density to set. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see GetDensity - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_SetDensity(const NativePixelMap* native, int32_t density); - -/** - * @brief Sets the opacity for a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param opacity Indicates the opacity to set. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * @see SetOpacity - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity); - -/** - * @brief Scales a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param x Indicates the scaling ratio of the width. - * @param y Indicates the scaling ratio of the height. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see Scale - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); - -/** - * @brief Translates a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param x Indicates the horizontal distance to translate. - * @param y Indicates the vertical distance to translate. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see Translate - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_Translate(const NativePixelMap* native, float x, float y); - -/** - * @brief Rotates a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param angle Indicates the angle to rotate. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see Rotate - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_Rotate(const NativePixelMap* native, float angle); - -/** - * @brief Flips a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param x Specifies whether to flip around the x axis. - * @param y Specifies whether to flip around the y axis. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see Flip - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_Flip(const NativePixelMap* native, int32_t x, int32_t y); - -/** - * @brief Crops a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param x Indicates the x-coordinate of the upper left corner of the target image. - * @param y Indicates the y-coordinate of the upper left corner of the target image. - * @param width Indicates the width of the cropped region. - * @param height Indicates the height of the cropped region. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see Crop - * @since 10 - * @version 1.0 - */ -int32_t OH_PixelMap_Crop(const NativePixelMap* native, int32_t x, int32_t y, int32_t width, int32_t height); - -/** - * @brief Obtains the image information of a PixelMap object. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param info Indicates the pointer to the image information. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see OhosPixelMapInfos - * @since 10 - * @version 2.0 - */ -int32_t OH_PixelMap_GetImageInfo(const NativePixelMap* native, OhosPixelMapInfos *info); - -/** - * @brief Obtains the memory address of a NativePixelMap object and locks the memory. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @param addr Indicates the double pointer to the memory address. - * @see UnAccessPixels - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. * @since 10 - * @version 2.0 - */ -int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr); - -/** - * @brief Unlocks the memory of the NativePixelMap object data. - * This function is used with {@link OH_PixelMap_AccessPixels} in pairs. - * - * @param native Indicates the pointer to a NativePixelMap object. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. * @see AccessPixels - * @since 10 - * @version 2.0 - */ -int32_t OH_PixelMap_UnAccessPixels(const NativePixelMap* native); - -#ifdef __cplusplus -}; -#endif -/** @} */ - -#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ +/* + * Copyright (C) 2022 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 pixel map data and information. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 1.0 + */ + +/** + * @file image_pixel_map_mdk.h + * + * @brief Declares the APIs that can lock, access, and unlock a pixel map. + * Need link libpixelmapndk.z.so + * + * @since 10 + * @version 1.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_MDK_H_ +#include +#include "napi/native_api.h" +#include "image_mdk_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the native pixel map information. + * @since 10 + * @version 1.0 + */ +struct NativePixelMap_; + +/** + * @brief Defines the data type name of the native pixel map. + * @since 10 + * @version 1.0 + */ +typedef struct NativePixelMap_ NativePixelMap; + +/** + * @brief Defines the pixel map information. + * + * @since 10 + * @version 1.0 + */ +typedef struct OhosPixelMapInfos { + /** Image width, in pixels. */ + uint32_t width; + /** Image height, in pixels. */ + uint32_t height; + /** Number of bytes per row. */ + uint32_t rowSize; + /** Pixel format. */ + int32_t pixelFormat; +} OhosPixelMapInfos; + +/** + * @brief Enumerates the pixel map alpha types. + * + * @since 10 + * @version 1.0 + */ +enum { + /** + * Unknown format. + */ + OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0, + /** + * Opaque format. + */ + OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1, + /** + * Premultiplied format. + */ + OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2, + /** + * Unpremultiplied format. + */ + OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3 +}; + +/** + * @brief Enumerates the pixel map editing types. + * + * @since 10 + * @version 1.0 + */ +enum { + /** + * Read-only. + */ + OHOS_PIXEL_MAP_READ_ONLY = 0, + /** + * Editable. + */ + OHOS_PIXEL_MAP_EDITABLE = 1, +}; + +/** + * @brief Defines the options used for creating a pixel map. + * + * @since 10 + * @version 1.0 + */ +struct OhosPixelMapCreateOps { + /** Image width, in pixels. */ + uint32_t width; + /** Image height, in pixels. */ + uint32_t height; + /** Image format. */ + int32_t pixelFormat; + /** Editing type of the image. */ + uint32_t editable; + /** Alpha type of the image. */ + uint32_t alphaType; + /** Scale mode of the image. */ + uint32_t scaleMode; +}; + +/** + * @brief Creates a PixelMap object. + * + * @param env Indicates the NAPI environment pointer. + * @param info Indicates the options for setting the PixelMap object. + * @param buf Indicates the pointer to the buffer of the image. + * @param len Indicates the image size. + * @param res Indicates the pointer to the PixelMap object at the application layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see CreatePixelMap + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_CreatePixelMap(napi_env env, OhosPixelMapCreateOps info, + void* buf, size_t len, napi_value* res); + +/** + * @brief Creates a PixelMap object that contains only alpha channel information. + * + * @param env Indicates the NAPI environment pointer. + * @param source Indicates the options for setting the PixelMap object. + * @param alpha Indicates the pointer to the alpha channel. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see CreateAlphaPixelMap + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_CreateAlphaPixelMap(napi_env env, napi_value source, napi_value* alpha); + +/** + * @brief Initializes a PixelMap object. + * + * @param env Indicates the NAPI environment pointer. + * @param source Indicates the options for setting the PixelMap object. + * @return Returns a pointer to the NativePixelMap object + * if the operation is successful; returns nullptr otherwise. + * @see InitNativePixelMap + * @since 10 + * @version 1.0 + */ +NativePixelMap* OH_PixelMap_InitNativePixelMap(napi_env env, napi_value source); + +/** + * @brief Obtains the number of bytes per row of a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param num Indicates the pointer to the number of bytes per row of the PixelMap object. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see GetBytesNumberPerRow + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_GetBytesNumberPerRow(const NativePixelMap* native, int32_t* num); + +/** + * @brief Checks whether a PixelMap object is editable. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param editable Indicates the pointer to the editing type of the PixelMap object. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see GetIsEditable + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_GetIsEditable(const NativePixelMap* native, int32_t* editable); + +/** + * @brief Checks whether a PixelMap object supports alpha channels. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param alpha Indicates the pointer to the support for alpha channels. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see IsSupportAlpha + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_IsSupportAlpha(const NativePixelMap* native, int32_t* alpha); + +/** + * @brief Sets an alpha channel for a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param alpha Indicates the alpha channel to set. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see SetAlphaAble + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_SetAlphaAble(const NativePixelMap* native, int32_t alpha); + +/** + * @brief Obtains the pixel density of a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param density Indicates the pointer to the pixel density. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see GetDensity + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_GetDensity(const NativePixelMap* native, int32_t* density); + +/** + * @brief Sets the pixel density for a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param density Indicates the pixel density to set. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see GetDensity + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_SetDensity(const NativePixelMap* native, int32_t density); + +/** + * @brief Sets the opacity for a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param opacity Indicates the opacity to set. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * @see SetOpacity + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity); + +/** + * @brief Scales a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param x Indicates the scaling ratio of the width. + * @param y Indicates the scaling ratio of the height. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see Scale + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); + +/** + * @brief Translates a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param x Indicates the horizontal distance to translate. + * @param y Indicates the vertical distance to translate. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see Translate + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_Translate(const NativePixelMap* native, float x, float y); + +/** + * @brief Rotates a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param angle Indicates the angle to rotate. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see Rotate + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_Rotate(const NativePixelMap* native, float angle); + +/** + * @brief Flips a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param x Specifies whether to flip around the x axis. + * @param y Specifies whether to flip around the y axis. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see Flip + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_Flip(const NativePixelMap* native, int32_t x, int32_t y); + +/** + * @brief Crops a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param x Indicates the x-coordinate of the upper left corner of the target image. + * @param y Indicates the y-coordinate of the upper left corner of the target image. + * @param width Indicates the width of the cropped region. + * @param height Indicates the height of the cropped region. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see Crop + * @since 10 + * @version 1.0 + */ +int32_t OH_PixelMap_Crop(const NativePixelMap* native, int32_t x, int32_t y, int32_t width, int32_t height); + +/** + * @brief Obtains the image information of a PixelMap object. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param info Indicates the pointer to the image information. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see OhosPixelMapInfos + * @since 10 + * @version 2.0 + */ +int32_t OH_PixelMap_GetImageInfo(const NativePixelMap* native, OhosPixelMapInfos *info); + +/** + * @brief Obtains the memory address of a NativePixelMap object and locks the memory. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param addr Indicates the double pointer to the memory address. + * @see UnAccessPixels + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. * @since 10 + * @version 2.0 + */ +int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr); + +/** + * @brief Unlocks the memory of the NativePixelMap object data. + * This function is used with {@link OH_PixelMap_AccessPixels} in pairs. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. * @see AccessPixels + * @since 10 + * @version 2.0 + */ +int32_t OH_PixelMap_UnAccessPixels(const NativePixelMap* native); + +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ diff --git a/multimedia/image_framework/include/image_pixel_map_napi.h b/multimedia/image_framework/include/image_pixel_map_napi.h index 4ce97331e988534402f9047a6ca45ef975e2941e..66f1428ac67222c1760b4e8d6462eae0a5b8cd41 100644 --- a/multimedia/image_framework/include/image_pixel_map_napi.h +++ b/multimedia/image_framework/include/image_pixel_map_napi.h @@ -1,173 +1,173 @@ -/* - * Copyright (C) 2022 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 pixel map data and information. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 8 - * @version 1.0 - */ - -/** - * @file image_pixel_map_napi.h - * - * @brief Declares the APIs that can lock, access, and unlock a pixel map. - * - * @since 8 - * @version 1.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ -#include -#include "napi/native_api.h" -namespace OHOS { -namespace Media { -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Enumerates the error codes returned by the functions. - * - * @deprecated since 10 - * @since 8 - * @version 1.0 - */ -enum { - /** Operation success. */ - OHOS_IMAGE_RESULT_SUCCESS = 0, - /** Invalid value. */ - OHOS_IMAGE_RESULT_BAD_PARAMETER = -1, -}; - -/** - * @brief Enumerates the pixel formats. - * - * @deprecated since 10 - * @since 8 - * @version 1.0 - */ -enum { - /** - * Unknown format. - */ - OHOS_PIXEL_MAP_FORMAT_NONE = 0, - /** - * 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). - * The data is stored from the most significant bit to the least significant bit. - */ - OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, - /** - * 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. - * The data is stored from the most significant bit to the least significant bit. - */ - OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2, -}; - -/** - * @brief Defines the pixel map information. - * - * @deprecated since 10 - * @since 8 - * @version 1.0 - */ -struct OhosPixelMapInfo { - /** Image width, in pixels. */ - uint32_t width; - /** Image height, in pixels. */ - uint32_t height; - /** Number of bytes per row. */ - uint32_t rowSize; - /** Pixel format. */ - int32_t pixelFormat; -}; - -/** - * @brief Enumerates the pixel map scale modes. - * - * @since 10 - * @version 2.0 - */ -enum { - /** - * Adaptation to the target image size. - */ - OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0, - /** - * Cropping the center portion of an image to the target size. - */ - OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1, -}; - -/** - * @brief Obtains the information about a PixelMap object - * and stores the information to the {@link OhosPixelMapInfo} struct. - * - * @deprecated since 10 - * @param env Indicates the NAPI environment pointer. - * @param value Indicates the PixelMap object at the application layer. - * @param info Indicates the pointer to the object that stores the information obtained. - * For details, see {@link OhosPixelMapInfo}. - * @return Returns 0 if the information is obtained and stored successfully; returns an error code otherwise. - * @see OhosPixelMapInfo - * @since 8 - * @version 1.0 - */ -int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info); - -/** - * @brief Obtains the memory address of a PixelMap object and locks the memory. - * - * After the function is executed successfully, *addrPtr is the memory address to be accessed. - * After the access operation is complete, you must use {@link OH_UnAccessPixels} to unlock the memory. - * Otherwise, the resources in the memory cannot be released. - * After the memory is unlocked, its address cannot be accessed or operated. - * - * @deprecated since 10 - * @param env Indicates the NAPI environment pointer. - * @param value Indicates the PixelMap object at the application layer. - * @param addrPtr Indicates the double pointer to the memory address. - * @see UnAccessPixels - * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. - * @since 8 - * @version 1.0 - */ -int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr); - -/** - * @brief Unlocks the memory of a PixelMap object. This function is used with {@link OH_AccessPixels} in pairs. - * - * @deprecated since 10 - * @param env Indicates the NAPI environment pointer. - * @param value Indicates the PixelMap object at the application layer. - * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. - * @see AccessPixels - * @since 8 - * @version 1.0 - */ -int32_t OH_UnAccessPixels(napi_env env, napi_value value); - -#ifdef __cplusplus -}; -#endif -/** @} */ -} // namespace Media -} // namespace OHOS -#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ +/* + * Copyright (C) 2022 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 pixel map data and information. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 8 + * @version 1.0 + */ + +/** + * @file image_pixel_map_napi.h + * + * @brief Declares the APIs that can lock, access, and unlock a pixel map. + * + * @since 8 + * @version 1.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ +#include +#include "napi/native_api.h" +namespace OHOS { +namespace Media { +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes returned by the functions. + * + * @deprecated since 10 + * @since 8 + * @version 1.0 + */ +enum { + /** Operation success. */ + OHOS_IMAGE_RESULT_SUCCESS = 0, + /** Invalid value. */ + OHOS_IMAGE_RESULT_BAD_PARAMETER = -1, +}; + +/** + * @brief Enumerates the pixel formats. + * + * @deprecated since 10 + * @since 8 + * @version 1.0 + */ +enum { + /** + * Unknown format. + */ + OHOS_PIXEL_MAP_FORMAT_NONE = 0, + /** + * 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). + * The data is stored from the most significant bit to the least significant bit. + */ + OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, + /** + * 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. + * The data is stored from the most significant bit to the least significant bit. + */ + OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2, +}; + +/** + * @brief Defines the pixel map information. + * + * @deprecated since 10 + * @since 8 + * @version 1.0 + */ +struct OhosPixelMapInfo { + /** Image width, in pixels. */ + uint32_t width; + /** Image height, in pixels. */ + uint32_t height; + /** Number of bytes per row. */ + uint32_t rowSize; + /** Pixel format. */ + int32_t pixelFormat; +}; + +/** + * @brief Enumerates the pixel map scale modes. + * + * @since 10 + * @version 2.0 + */ +enum { + /** + * Adaptation to the target image size. + */ + OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0, + /** + * Cropping the center portion of an image to the target size. + */ + OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1, +}; + +/** + * @brief Obtains the information about a PixelMap object + * and stores the information to the {@link OhosPixelMapInfo} struct. + * + * @deprecated since 10 + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @param info Indicates the pointer to the object that stores the information obtained. + * For details, see {@link OhosPixelMapInfo}. + * @return Returns 0 if the information is obtained and stored successfully; returns an error code otherwise. + * @see OhosPixelMapInfo + * @since 8 + * @version 1.0 + */ +int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info); + +/** + * @brief Obtains the memory address of a PixelMap object and locks the memory. + * + * After the function is executed successfully, *addrPtr is the memory address to be accessed. + * After the access operation is complete, you must use {@link OH_UnAccessPixels} to unlock the memory. + * Otherwise, the resources in the memory cannot be released. + * After the memory is unlocked, its address cannot be accessed or operated. + * + * @deprecated since 10 + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @param addrPtr Indicates the double pointer to the memory address. + * @see UnAccessPixels + * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. + * @since 8 + * @version 1.0 + */ +int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr); + +/** + * @brief Unlocks the memory of a PixelMap object. This function is used with {@link OH_AccessPixels} in pairs. + * + * @deprecated since 10 + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. + * @see AccessPixels + * @since 8 + * @version 1.0 + */ +int32_t OH_UnAccessPixels(napi_env env, napi_value value); + +#ifdef __cplusplus +}; +#endif +/** @} */ +} // namespace Media +} // namespace OHOS +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PIXEL_MAP_NAPI_H_ diff --git a/multimedia/image_framework/include/image_receiver_mdk.h b/multimedia/image_framework/include/image_receiver_mdk.h index 2ca87438f4b2ea8e00985bf210d37f1348440d88..aa6a2bbdb58742c585ec619c30d068c957a0ce0a 100644 --- a/multimedia/image_framework/include/image_receiver_mdk.h +++ b/multimedia/image_framework/include/image_receiver_mdk.h @@ -1,278 +1,278 @@ -/* - * 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 obtaining image data from the native layer. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 2.0 - */ - -/** - * @file image_receiver_mdk.h - * - * @brief Declares the APIs for obtaining image data from the native layer. - * Need link libimagendk.z.so and libimage_receiverndk.z.so - * @since 10 - * @version 2.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ -#include "napi/native_api.h" -#include "image_mdk_common.h" -#include "image_mdk.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines an ImageReceiver object at the native layer. - * - * @since 10 - * @version 2.0 - */ -struct ImageReceiverNative_; - -/** - * @brief Defines the data type name of a native image receiver. - * - * @since 10 - * @version 2.0 - */ -typedef struct ImageReceiverNative_ ImageReceiverNative; - -/** - * @brief Defines the callbacks for images at the native layer. - * - * @since 10 - * @version 2.0 - */ -typedef void (*OH_Image_Receiver_On_Callback)(void); - -/** - * @brief Defines the information about an image receiver. - * - * @since 10 - * @version 2.0 - */ -struct OhosImageReceiverInfo { - /* Default width of the image received by the consumer, in pixels. */ - int32_t width; - /* Default height of the image received by the consumer, in pixels. */ - int32_t height; - /* Image format {@link OHOS_IMAGE_FORMAT_JPEG} created by using the receiver. */ - int32_t format; - /* Maximum number of images that can be cached. */ - int32_t capicity; -}; - -/** - * @brief Creates an ImageReceiver object at the application layer. - * - * @param env Indicates the NAPI environment pointer. - * @param info Indicates the options for setting the ImageReceiver object. - * @param res Indicates the pointer to the ImageReceiver object obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. - * @see OhosImageReceiverInfo - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_CreateImageReceiver(napi_env env, struct OhosImageReceiverInfo info, napi_value* res); - -/** - * @brief Initializes an {@link ImageReceiverNative} object at the native layer - * through an ImageReceiver object at the application layer. - * - * @param env Indicates the NAPI environment pointer. - * @param source Indicates an ImageReceiver object. - * @return Returns the pointer to the {@link ImageReceiverNative} object obtained if the operation is successful; - * returns a null pointer otherwise. - * @see ImageReceiverNative, OH_Image_Receiver_Release - * @since 10 - * @version 2.0 - */ -ImageReceiverNative* OH_Image_Receiver_InitImageReceiverNative(napi_env env, napi_value source); - -/** - * @brief Obtains the receiver ID through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param id Indicates the pointer to the buffer that stores the ID string obtained. - * @param len Indicates the size of the buffer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. - * @see ImageReceiverNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_GetReceivingSurfaceId(const ImageReceiverNative* native, char* id, size_t len); - -/** - * @brief Obtains the latest image through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param image Indicates the pointer to an Image object at the application layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. - * @see ImageReceiverNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_ReadLatestImage(const ImageReceiverNative* native, napi_value* image); - -/** - * @brief Obtains the next image through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param image Indicates the pointer to an Image object at the application layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. - * @see ImageReceiverNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_ReadNextImage(const ImageReceiverNative* native, napi_value* image); - -/** - * @brief Registers an {@link OH_Image_Receiver_On_Callback} callback event. - * - * This callback event is triggered whenever a new image is received. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param callback Indicates the {@link OH_Image_Receiver_On_Callback} callback event to register. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_LISTENER_FAILED - if Failed to register listener. - * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_BUFFER_FAILED - if Failed to register buffer. - * @see ImageReceiverNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_On(const ImageReceiverNative* native, OH_Image_Receiver_On_Callback callback); - -/** - * @brief Obtains the size of the image receiver through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param size Indicates the pointer to the {@link OhosImageSize} object obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * @see ImageReceiverNative, OH_Image_Receiver_On_Callback - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_GetSize(const ImageReceiverNative* native, struct OhosImageSize* size); - -/** - * @brief Obtains the capacity of the image receiver through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param capacity Indicates the pointer to the capacity obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * @see ImageReceiverNative, OhosImageSize - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_GetCapacity(const ImageReceiverNative* native, int32_t* capacity); - -/** - * @brief Obtains the format of the image receiver through an {@link ImageReceiverNative} object. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @param format Indicates the pointer to the format obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * @see ImageReceiverNative - - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_GetFormat(const ImageReceiverNative* native, int32_t* format); - -/** - * @brief Releases an {@link ImageReceiverNative} object at the native layer. - * - * This API is not used to release an ImageReceiver object at the application layer. - * - * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * @see ImageReceiverNative - * @since 10 - * @version 2.0 - */ -int32_t OH_Image_Receiver_Release(ImageReceiverNative* native); -#ifdef __cplusplus -}; -#endif -/** @} */ - -#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ +/* + * 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 obtaining image data from the native layer. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 2.0 + */ + +/** + * @file image_receiver_mdk.h + * + * @brief Declares the APIs for obtaining image data from the native layer. + * Need link libimagendk.z.so and libimage_receiverndk.z.so + * @since 10 + * @version 2.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ +#include "napi/native_api.h" +#include "image_mdk_common.h" +#include "image_mdk.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines an ImageReceiver object at the native layer. + * + * @since 10 + * @version 2.0 + */ +struct ImageReceiverNative_; + +/** + * @brief Defines the data type name of a native image receiver. + * + * @since 10 + * @version 2.0 + */ +typedef struct ImageReceiverNative_ ImageReceiverNative; + +/** + * @brief Defines the callbacks for images at the native layer. + * + * @since 10 + * @version 2.0 + */ +typedef void (*OH_Image_Receiver_On_Callback)(void); + +/** + * @brief Defines the information about an image receiver. + * + * @since 10 + * @version 2.0 + */ +struct OhosImageReceiverInfo { + /* Default width of the image received by the consumer, in pixels. */ + int32_t width; + /* Default height of the image received by the consumer, in pixels. */ + int32_t height; + /* Image format {@link OHOS_IMAGE_FORMAT_JPEG} created by using the receiver. */ + int32_t format; + /* Maximum number of images that can be cached. */ + int32_t capicity; +}; + +/** + * @brief Creates an ImageReceiver object at the application layer. + * + * @param env Indicates the NAPI environment pointer. + * @param info Indicates the options for setting the ImageReceiver object. + * @param res Indicates the pointer to the ImageReceiver object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. + * @see OhosImageReceiverInfo + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_CreateImageReceiver(napi_env env, struct OhosImageReceiverInfo info, napi_value* res); + +/** + * @brief Initializes an {@link ImageReceiverNative} object at the native layer + * through an ImageReceiver object at the application layer. + * + * @param env Indicates the NAPI environment pointer. + * @param source Indicates an ImageReceiver object. + * @return Returns the pointer to the {@link ImageReceiverNative} object obtained if the operation is successful; + * returns a null pointer otherwise. + * @see ImageReceiverNative, OH_Image_Receiver_Release + * @since 10 + * @version 2.0 + */ +ImageReceiverNative* OH_Image_Receiver_InitImageReceiverNative(napi_env env, napi_value source); + +/** + * @brief Obtains the receiver ID through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param id Indicates the pointer to the buffer that stores the ID string obtained. + * @param len Indicates the size of the buffer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. + * @see ImageReceiverNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_GetReceivingSurfaceId(const ImageReceiverNative* native, char* id, size_t len); + +/** + * @brief Obtains the latest image through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param image Indicates the pointer to an Image object at the application layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. + * @see ImageReceiverNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_ReadLatestImage(const ImageReceiverNative* native, napi_value* image); + +/** + * @brief Obtains the next image through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param image Indicates the pointer to an Image object at the application layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. + * @see ImageReceiverNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_ReadNextImage(const ImageReceiverNative* native, napi_value* image); + +/** + * @brief Registers an {@link OH_Image_Receiver_On_Callback} callback event. + * + * This callback event is triggered whenever a new image is received. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param callback Indicates the {@link OH_Image_Receiver_On_Callback} callback event to register. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_LISTENER_FAILED - if Failed to register listener. + * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_BUFFER_FAILED - if Failed to register buffer. + * @see ImageReceiverNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_On(const ImageReceiverNative* native, OH_Image_Receiver_On_Callback callback); + +/** + * @brief Obtains the size of the image receiver through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param size Indicates the pointer to the {@link OhosImageSize} object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * @see ImageReceiverNative, OH_Image_Receiver_On_Callback + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_GetSize(const ImageReceiverNative* native, struct OhosImageSize* size); + +/** + * @brief Obtains the capacity of the image receiver through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param capacity Indicates the pointer to the capacity obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * @see ImageReceiverNative, OhosImageSize + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_GetCapacity(const ImageReceiverNative* native, int32_t* capacity); + +/** + * @brief Obtains the format of the image receiver through an {@link ImageReceiverNative} object. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @param format Indicates the pointer to the format obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * @see ImageReceiverNative + + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_GetFormat(const ImageReceiverNative* native, int32_t* format); + +/** + * @brief Releases an {@link ImageReceiverNative} object at the native layer. + * + * This API is not used to release an ImageReceiver object at the application layer. + * + * @param native Indicates the pointer to an {@link ImageReceiverNative} object at the native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * @see ImageReceiverNative + * @since 10 + * @version 2.0 + */ +int32_t OH_Image_Receiver_Release(ImageReceiverNative* native); +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_RECEIVER_MDK_H_ diff --git a/multimedia/image_framework/include/image_source_mdk.h b/multimedia/image_framework/include/image_source_mdk.h index 3f40a28eb20f633dc700589fec5c559ac98e9e40..ed54ed71185c726252241756d7b2913eeda05352 100644 --- a/multimedia/image_framework/include/image_source_mdk.h +++ b/multimedia/image_framework/include/image_source_mdk.h @@ -1,827 +1,827 @@ -/* - * 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 native APIs for image sources. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ - -/** - * @file image_source_mdk.h - * - * @brief Declares APIs for decoding an image source into a pixel map. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ - -#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ -#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ -#include -#include "napi/native_api.h" -#include "image_mdk_common.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines a native image source object for the image source APIs. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct ImageSourceNative_; - -/** - * @brief Defines a native image source object for the image source APIs. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -typedef struct ImageSourceNative_ ImageSourceNative; - -/** - * @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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -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}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -const char* OHOS_IMAGE_PROPERTY_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel"; - -/** - * @brief Defines the region of the image source to decode. - * It is used in {@link OhosImageDecodingOps}, {@link OH_ImageSource_CreatePixelMap}, and - * {@link OH_ImageSource_CreatePixelMapList}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageRegion { - /** X coordinate of the start point, in pixels. */ - int32_t x; - /** Y coordinate of the start point, in pixels. */ - int32_t y; - /** Width of the region, in pixels. */ - int32_t width; - /** Height of the region, in pixels. */ - int32_t height; -}; - -/** - * @brief Defines image source options infomation - * {@link OH_ImageSource_Create} and {@link OH_ImageSource_CreateIncremental}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceOps { - /** Pixel density of the image source. */ - int32_t density; - /** Image source pixel format, used to describe YUV buffer usually. */ - int32_t pixelFormat; - /** Image source pixel size of width and height. */ - struct OhosImageSize size; -}; - -/** - * @brief Defines the options for decoding the image source. - * It is used in {@link OH_ImageSource_CreatePixelMap} and {@link OH_ImageSource_CreatePixelMapList}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageDecodingOps { - /** Defines output pixel map editable. */ - int8_t editable; - /** Defines output pixel format. */ - int32_t pixelFormat; - /** Defines decoding target pixel density. */ - int32_t fitDensity; - /** Defines decoding index of image source. */ - uint32_t index; - /** Defines decoding sample size option. */ - uint32_t sampleSize; - /** Defines decoding rotate option. */ - uint32_t rotate; - /** Defines decoding target pixel size of width and height. */ - struct OhosImageSize size; - /** Defines image source pixel region for decoding. */ - struct OhosImageRegion region; -}; - -/** - * @brief Defines the image source information, which is obtained by calling {@link OH_ImageSource_GetImageInfo}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceInfo { - /** Pixel format of the image source. It is set in {@link OH_ImageSource_Create}. */ - int32_t pixelFormat; - /** Color space of the image source. */ - int32_t colorSpace; - /** Alpha type of the image source. */ - int32_t alphaType; - /** Image density of the image source. It is set in {@link OH_ImageSource_Create}. */ - int32_t density; - /** Pixel width and height of the image source. */ - struct OhosImageSize size; -}; - -/** - * @brief Defines the input resource of the image source. It is obtained by calling {@link OH_ImageSource_Create}. - * Only one type of resource is accepted at a time. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSource { - /** Pointer to the image source URI. Only a file URI or Base64 URI is accepted. */ - char* uri = nullptr; - /** Length of the image source URI. */ - size_t uriSize = 0; - /** Descriptor of the image source. */ - int32_t fd = -1; - /** Pointer to the image source buffer. Only a formatted packet buffer or Base64 buffer is accepted. */ - uint8_t* buffer = nullptr; - /** Size of the image source buffer. */ - size_t bufferSize = 0; -}; - -/** - * @brief Defines the delay time list of the image source. It is obtained by calling - * {@link OH_ImageSource_GetDelayTime}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceDelayTimeList { - /** Pointer to the head of the image source delay time list. */ - int32_t* delayTimeList; - /** Size of the image source delay time list. */ - size_t size = 0; -}; - -/** - * @brief Defines image source supported format string. - * {@link OhosImageSourceSupportedFormatList} and {@link OH_ImageSource_GetSupportedFormats} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceSupportedFormat { - /** Image source supported format string head.*/ - char* format = nullptr; - /** Image source supported format string size.*/ - size_t size = 0; -}; - -/** - * @brief Defines the format string list supported by the image source. - * It is obtained by calling {@link OH_ImageSource_GetSupportedFormats}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceSupportedFormatList { - /** Image source supported format string list head.*/ - struct OhosImageSourceSupportedFormat** supportedFormatList = nullptr; - /** Image source supported format string list size.*/ - size_t size = 0; -}; - -/** - * @brief Defines the property string (in key-value format) of the image source. - * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceProperty { - /** Image source property key and value string head.*/ - char* value = nullptr; - /** Image source property key and value string size.*/ - size_t size = 0; -}; - -/** - * @brief Defines the update data of the image source. It is obtained by calling {@link OH_ImageSource_UpdateData}. - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -struct OhosImageSourceUpdateData { - /** Image source update data buffer.*/ - uint8_t* buffer = nullptr; - /** Image source update data buffer size.*/ - size_t bufferSize = 0; - /** Image source offset of update data buffer.*/ - uint32_t offset = 0; - /** Image source update data length in update data buffer.*/ - uint32_t updateLength = 0; - /** Image source update data is completed in this session.*/ - int8_t isCompleted = 0; -}; - -/** - * @brief Creates an ImageSource object at the JavaScript native layer based on the specified - * {@link OhosImageSource} and {@link OhosImageSourceOps} structs. - * - * @param env Indicates a pointer to the Java Native Interface (JNI) environment. - * @param src Indicates a pointer to the input resource of the image source. For details, see {@link OhosImageSource}. - * @param ops Indicates a pointer to the options for creating the image source. - * For details, see {@link OhosImageSourceOps}. - * @param res Indicates a pointer to the ImageSource object created at the JavaScript native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA_INCOMPLETE - if image source data incomplete. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA - if image source data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_TOO_LARGE - if image data too large. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_DAMAGED - if file damaged. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_FD_ERROR - if file fd is bad. - * returns {@link IRNdkErrCode} IMAGE_RESULT_STREAM_SIZE_ERROR - if stream bad. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SEEK_FAILED - if seek file failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PEEK_FAILED - if peek file failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FREAD_FAILED - if read file failed. - * @see {@link OhosImageSource}, {@link OhosImageSourceOps} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_Create(napi_env env, struct OhosImageSource* src, - struct OhosImageSourceOps* ops, napi_value *res); - -/** - * @brief Creates an incremental ImageSource object at the JavaScript native layer based on the specified - * {@link OhosImageSource} and {@link OhosImageSourceOps} structs. - * The image source data will be updated through {@link OH_ImageSource_UpdateData}. - * - * @param env Indicates a pointer to the JNI environment. - * @param src Indicates a pointer to the input resource of the image source. Only the buffer type is accepted. - * For details, see {@link OhosImageSource}. - * @param ops Indicates a pointer to the options for creating the image source. - * For details, see {@link OhosImageSourceOps}. - * @param res Indicates a pointer to the ImageSource object created at the JavaScript native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA_INCOMPLETE - if image source data incomplete. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA - if image source data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_TOO_LARGE - if image data too large. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_DAMAGED - if file damaged. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_FD_ERROR - if file fd is bad. - * returns {@link IRNdkErrCode} IMAGE_RESULT_STREAM_SIZE_ERROR - if stream bad. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SEEK_FAILED - if seek file failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PEEK_FAILED - if peek file failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_FREAD_FAILED - if read file failed. - * @see {@link OhosImageSource}, {@link OhosImageSourceOps}, {@link OH_ImageSource_UpdateData} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_CreateIncremental(napi_env env, struct OhosImageSource* source, - struct OhosImageSourceOps* ops, napi_value *res); - -/** - * @brief Obtains all supported decoding formats. - * - * @param res Indicates a pointer to the OhosImageSourceSupportedFormatList struct. - * When the input supportedFormatList is a null pointer and size is 0, the size of the supported formats - * is returned through size in res. - * To obtain all formats, a space larger than size is required. - * In addition, sufficient space must be reserved for each format supported. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if decode fail. - * @see {@link OhosImageSourceSupportedFormatList}, {@link OhosImageSourceSupportedFormat} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_GetSupportedFormats(struct OhosImageSourceSupportedFormatList* res); - -/** - * @brief Converts an {@link ImageSource} object at the JavaScript native layer to an ImageSourceNative object - * at the C++ native layer. - * - * @param env Indicates a pointer to the JNI environment. - * @param source Indicates a pointer to the ImageSource object at the JavaScript native layer. - * @return Returns a pointer to the {@link ImageSourceNative} object if the operation is successful; - * returns a null pointer otherwise. - * @see {@link ImageSourceNative}, {@link OH_ImageSource_Release} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -ImageSourceNative* OH_ImageSource_InitNative(napi_env env, napi_value source); - -/** - * @brief Decodes an ImageSource object to obtain a PixelMap object at the JavaScript native layer - * based on the specified {@link OhosImageDecodingOps} struct. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param ops Indicates a pointer to the options for decoding the image source. - * For details, see {@link OhosImageDecodingOps}. - * @param res Indicates a pointer to the PixelMap object obtained at the JavaScript native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see {@link ImageSourceNative}, {@link OhosImageDecodingOps} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_CreatePixelMap(const ImageSourceNative* native, - struct OhosImageDecodingOps* ops, napi_value *res); - -/** - * @brief Decodes an ImageSource to obtain all the PixelMap objects at the JavaScript native layer - * based on the specified {@link OhosImageDecodingOps} struct. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param ops Indicates a pointer to the options for decoding the image source. - * For details, see {@link OhosImageDecodingOps}. - * @param res Indicates a pointer to the PixelMap objects obtained at the JavaScript native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative}, {@link OhosImageDecodingOps} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_CreatePixelMapList(const ImageSourceNative* native, - struct OhosImageDecodingOps* ops, napi_value *res); - -/** - * @brief Obtains the delay time list from some ImageSource objects (such as GIF image sources). - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param res Indicates a pointer to the delay time list obtained. - * For details, see {@link OhosImageSourceDelayTimeList}. When the input delayTimeList is a null pointer and - * size is 0, the size of the delay time list is returned through size in res. - * To obtain the complete delay time list, a space greater than size is required. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative}, {@link OhosImageSourceDelayTimeList} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_GetDelayTime(const ImageSourceNative* native, - struct OhosImageSourceDelayTimeList* res); - -/** - * @brief Obtains the number of frames from an ImageSource object. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param res Indicates a pointer to the number of frames obtained. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_GetFrameCount(const ImageSourceNative* native, uint32_t *res); - -/** - * @brief Obtains image source information from an ImageSource object by index. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param index Indicates the index of the frame. - * @param info Indicates a pointer to the image source information obtained. - * For details, see {@link OhosImageSourceInfo}. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative}, {@link OhosImageSourceInfo} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_GetImageInfo(const ImageSourceNative* native, int32_t index, - struct OhosImageSourceInfo* info); - -/** - * @brief Obtains the value of an image property from an ImageSource object. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param key Indicates a pointer to the property. For details, see {@link OhosImageSourceProperty}. - * @param value Indicates a pointer to the property value obtained. - * If the input value is a null pointer and size is 0, the size of the property value is returned - * through size in value. - * To obtain the complete property value, a space greater than size is required. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative}, {@link OhosImageSourceProperty} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_GetImageProperty(const ImageSourceNative* native, - struct OhosImageSourceProperty* key, struct OhosImageSourceProperty* value); - -/** - * @brief Modifies the value of an image property of an ImageSource object. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param key Indicates a pointer to the property. For details, see {@link OhosImageSourceProperty}. - * @param value Indicates a pointer to the new value of the property. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. - * @see {@link ImageSourceNative}, {@link OhosImageSourceProperty} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_ModifyImageProperty(const ImageSourceNative* native, - struct OhosImageSourceProperty* key, struct OhosImageSourceProperty* value); - -/** - * @brief Updates the data of an ImageSource object. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @param data Indicates a pointer to the update data. For details, see {@link OhosImageSourceUpdateData}. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - image add pixel map fail. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see {@link ImageSourceNative}, {@link OhosImageSourceUpdateData} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_UpdateData(const ImageSourceNative* native, struct OhosImageSourceUpdateData* data); - - -/** - * @brief Releases an ImageSourceNative object. - * - * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. - * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. - * @see {@link ImageSourceNative}, {@link OH_ImageSource_Create}, {@link OH_ImageSource_CreateIncremental} - * - * @Syscap SystemCapability.Multimedia.Image - * @since 10 - * @version 4.0 - */ -int32_t OH_ImageSource_Release(ImageSourceNative* native); -#ifdef __cplusplus -}; -#endif -#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ +/* + * 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 native APIs for image sources. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ + +/** + * @file image_source_mdk.h + * + * @brief Declares APIs for decoding an image source into a pixel map. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ +#include +#include "napi/native_api.h" +#include "image_mdk_common.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines a native image source object for the image source APIs. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct ImageSourceNative_; + +/** + * @brief Defines a native image source object for the image source APIs. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +typedef struct ImageSourceNative_ ImageSourceNative; + +/** + * @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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +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}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +const char* OHOS_IMAGE_PROPERTY_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel"; + +/** + * @brief Defines the region of the image source to decode. + * It is used in {@link OhosImageDecodingOps}, {@link OH_ImageSource_CreatePixelMap}, and + * {@link OH_ImageSource_CreatePixelMapList}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageRegion { + /** X coordinate of the start point, in pixels. */ + int32_t x; + /** Y coordinate of the start point, in pixels. */ + int32_t y; + /** Width of the region, in pixels. */ + int32_t width; + /** Height of the region, in pixels. */ + int32_t height; +}; + +/** + * @brief Defines image source options infomation + * {@link OH_ImageSource_Create} and {@link OH_ImageSource_CreateIncremental}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceOps { + /** Pixel density of the image source. */ + int32_t density; + /** Image source pixel format, used to describe YUV buffer usually. */ + int32_t pixelFormat; + /** Image source pixel size of width and height. */ + struct OhosImageSize size; +}; + +/** + * @brief Defines the options for decoding the image source. + * It is used in {@link OH_ImageSource_CreatePixelMap} and {@link OH_ImageSource_CreatePixelMapList}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageDecodingOps { + /** Defines output pixel map editable. */ + int8_t editable; + /** Defines output pixel format. */ + int32_t pixelFormat; + /** Defines decoding target pixel density. */ + int32_t fitDensity; + /** Defines decoding index of image source. */ + uint32_t index; + /** Defines decoding sample size option. */ + uint32_t sampleSize; + /** Defines decoding rotate option. */ + uint32_t rotate; + /** Defines decoding target pixel size of width and height. */ + struct OhosImageSize size; + /** Defines image source pixel region for decoding. */ + struct OhosImageRegion region; +}; + +/** + * @brief Defines the image source information, which is obtained by calling {@link OH_ImageSource_GetImageInfo}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceInfo { + /** Pixel format of the image source. It is set in {@link OH_ImageSource_Create}. */ + int32_t pixelFormat; + /** Color space of the image source. */ + int32_t colorSpace; + /** Alpha type of the image source. */ + int32_t alphaType; + /** Image density of the image source. It is set in {@link OH_ImageSource_Create}. */ + int32_t density; + /** Pixel width and height of the image source. */ + struct OhosImageSize size; +}; + +/** + * @brief Defines the input resource of the image source. It is obtained by calling {@link OH_ImageSource_Create}. + * Only one type of resource is accepted at a time. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSource { + /** Pointer to the image source URI. Only a file URI or Base64 URI is accepted. */ + char* uri = nullptr; + /** Length of the image source URI. */ + size_t uriSize = 0; + /** Descriptor of the image source. */ + int32_t fd = -1; + /** Pointer to the image source buffer. Only a formatted packet buffer or Base64 buffer is accepted. */ + uint8_t* buffer = nullptr; + /** Size of the image source buffer. */ + size_t bufferSize = 0; +}; + +/** + * @brief Defines the delay time list of the image source. It is obtained by calling + * {@link OH_ImageSource_GetDelayTime}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceDelayTimeList { + /** Pointer to the head of the image source delay time list. */ + int32_t* delayTimeList; + /** Size of the image source delay time list. */ + size_t size = 0; +}; + +/** + * @brief Defines image source supported format string. + * {@link OhosImageSourceSupportedFormatList} and {@link OH_ImageSource_GetSupportedFormats} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceSupportedFormat { + /** Image source supported format string head.*/ + char* format = nullptr; + /** Image source supported format string size.*/ + size_t size = 0; +}; + +/** + * @brief Defines the format string list supported by the image source. + * It is obtained by calling {@link OH_ImageSource_GetSupportedFormats}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceSupportedFormatList { + /** Image source supported format string list head.*/ + struct OhosImageSourceSupportedFormat** supportedFormatList = nullptr; + /** Image source supported format string list size.*/ + size_t size = 0; +}; + +/** + * @brief Defines the property string (in key-value format) of the image source. + * It is used in {@link OH_ImageSource_GetImageProperty} and {@link OH_ImageSource_ModifyImageProperty}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceProperty { + /** Image source property key and value string head.*/ + char* value = nullptr; + /** Image source property key and value string size.*/ + size_t size = 0; +}; + +/** + * @brief Defines the update data of the image source. It is obtained by calling {@link OH_ImageSource_UpdateData}. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +struct OhosImageSourceUpdateData { + /** Image source update data buffer.*/ + uint8_t* buffer = nullptr; + /** Image source update data buffer size.*/ + size_t bufferSize = 0; + /** Image source offset of update data buffer.*/ + uint32_t offset = 0; + /** Image source update data length in update data buffer.*/ + uint32_t updateLength = 0; + /** Image source update data is completed in this session.*/ + int8_t isCompleted = 0; +}; + +/** + * @brief Creates an ImageSource object at the JavaScript native layer based on the specified + * {@link OhosImageSource} and {@link OhosImageSourceOps} structs. + * + * @param env Indicates a pointer to the Java Native Interface (JNI) environment. + * @param src Indicates a pointer to the input resource of the image source. For details, see {@link OhosImageSource}. + * @param ops Indicates a pointer to the options for creating the image source. + * For details, see {@link OhosImageSourceOps}. + * @param res Indicates a pointer to the ImageSource object created at the JavaScript native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA_INCOMPLETE - if image source data incomplete. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA - if image source data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_TOO_LARGE - if image data too large. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_DAMAGED - if file damaged. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_FD_ERROR - if file fd is bad. + * returns {@link IRNdkErrCode} IMAGE_RESULT_STREAM_SIZE_ERROR - if stream bad. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SEEK_FAILED - if seek file failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PEEK_FAILED - if peek file failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FREAD_FAILED - if read file failed. + * @see {@link OhosImageSource}, {@link OhosImageSourceOps} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_Create(napi_env env, struct OhosImageSource* src, + struct OhosImageSourceOps* ops, napi_value *res); + +/** + * @brief Creates an incremental ImageSource object at the JavaScript native layer based on the specified + * {@link OhosImageSource} and {@link OhosImageSourceOps} structs. + * The image source data will be updated through {@link OH_ImageSource_UpdateData}. + * + * @param env Indicates a pointer to the JNI environment. + * @param src Indicates a pointer to the input resource of the image source. Only the buffer type is accepted. + * For details, see {@link OhosImageSource}. + * @param ops Indicates a pointer to the options for creating the image source. + * For details, see {@link OhosImageSourceOps}. + * @param res Indicates a pointer to the ImageSource object created at the JavaScript native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA_INCOMPLETE - if image source data incomplete. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SOURCE_DATA - if image source data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_TOO_LARGE - if image data too large. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_DAMAGED - if file damaged. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FILE_FD_ERROR - if file fd is bad. + * returns {@link IRNdkErrCode} IMAGE_RESULT_STREAM_SIZE_ERROR - if stream bad. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SEEK_FAILED - if seek file failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PEEK_FAILED - if peek file failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_FREAD_FAILED - if read file failed. + * @see {@link OhosImageSource}, {@link OhosImageSourceOps}, {@link OH_ImageSource_UpdateData} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_CreateIncremental(napi_env env, struct OhosImageSource* source, + struct OhosImageSourceOps* ops, napi_value *res); + +/** + * @brief Obtains all supported decoding formats. + * + * @param res Indicates a pointer to the OhosImageSourceSupportedFormatList struct. + * When the input supportedFormatList is a null pointer and size is 0, the size of the supported formats + * is returned through size in res. + * To obtain all formats, a space larger than size is required. + * In addition, sufficient space must be reserved for each format supported. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if decode fail. + * @see {@link OhosImageSourceSupportedFormatList}, {@link OhosImageSourceSupportedFormat} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_GetSupportedFormats(struct OhosImageSourceSupportedFormatList* res); + +/** + * @brief Converts an {@link ImageSource} object at the JavaScript native layer to an ImageSourceNative object + * at the C++ native layer. + * + * @param env Indicates a pointer to the JNI environment. + * @param source Indicates a pointer to the ImageSource object at the JavaScript native layer. + * @return Returns a pointer to the {@link ImageSourceNative} object if the operation is successful; + * returns a null pointer otherwise. + * @see {@link ImageSourceNative}, {@link OH_ImageSource_Release} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +ImageSourceNative* OH_ImageSource_InitNative(napi_env env, napi_value source); + +/** + * @brief Decodes an ImageSource object to obtain a PixelMap object at the JavaScript native layer + * based on the specified {@link OhosImageDecodingOps} struct. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param ops Indicates a pointer to the options for decoding the image source. + * For details, see {@link OhosImageDecodingOps}. + * @param res Indicates a pointer to the PixelMap object obtained at the JavaScript native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see {@link ImageSourceNative}, {@link OhosImageDecodingOps} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_CreatePixelMap(const ImageSourceNative* native, + struct OhosImageDecodingOps* ops, napi_value *res); + +/** + * @brief Decodes an ImageSource to obtain all the PixelMap objects at the JavaScript native layer + * based on the specified {@link OhosImageDecodingOps} struct. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param ops Indicates a pointer to the options for decoding the image source. + * For details, see {@link OhosImageDecodingOps}. + * @param res Indicates a pointer to the PixelMap objects obtained at the JavaScript native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - if image add pixel map fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative}, {@link OhosImageDecodingOps} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_CreatePixelMapList(const ImageSourceNative* native, + struct OhosImageDecodingOps* ops, napi_value *res); + +/** + * @brief Obtains the delay time list from some ImageSource objects (such as GIF image sources). + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param res Indicates a pointer to the delay time list obtained. + * For details, see {@link OhosImageSourceDelayTimeList}. When the input delayTimeList is a null pointer and + * size is 0, the size of the delay time list is returned through size in res. + * To obtain the complete delay time list, a space greater than size is required. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative}, {@link OhosImageSourceDelayTimeList} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_GetDelayTime(const ImageSourceNative* native, + struct OhosImageSourceDelayTimeList* res); + +/** + * @brief Obtains the number of frames from an ImageSource object. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param res Indicates a pointer to the number of frames obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_GetFrameCount(const ImageSourceNative* native, uint32_t *res); + +/** + * @brief Obtains image source information from an ImageSource object by index. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param index Indicates the index of the frame. + * @param info Indicates a pointer to the image source information obtained. + * For details, see {@link OhosImageSourceInfo}. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative}, {@link OhosImageSourceInfo} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_GetImageInfo(const ImageSourceNative* native, int32_t index, + struct OhosImageSourceInfo* info); + +/** + * @brief Obtains the value of an image property from an ImageSource object. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param key Indicates a pointer to the property. For details, see {@link OhosImageSourceProperty}. + * @param value Indicates a pointer to the property value obtained. + * If the input value is a null pointer and size is 0, the size of the property value is returned + * through size in value. + * To obtain the complete property value, a space greater than size is required. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative}, {@link OhosImageSourceProperty} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_GetImageProperty(const ImageSourceNative* native, + struct OhosImageSourceProperty* key, struct OhosImageSourceProperty* value); + +/** + * @brief Modifies the value of an image property of an ImageSource object. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param key Indicates a pointer to the property. For details, see {@link OhosImageSourceProperty}. + * @param value Indicates a pointer to the new value of the property. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_EXIF_UNSUPPORT - if image decode exif unsupport. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PROPERTY_NOT_EXIST - if image property not exist. + * @see {@link ImageSourceNative}, {@link OhosImageSourceProperty} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_ModifyImageProperty(const ImageSourceNative* native, + struct OhosImageSourceProperty* key, struct OhosImageSourceProperty* value); + +/** + * @brief Updates the data of an ImageSource object. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @param data Indicates a pointer to the update data. For details, see {@link OhosImageSourceUpdateData}. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_HEAD_ABNORMAL - if image decode head error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_DECODER_FAILED - if create decoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_ENCODER_FAILED - if create encoder failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_ABNORMAL - if image decode error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INIT_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ENCODE_FAILED - image add pixel map fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_UNSUPPORT - if image hardware decode unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_HW_DECODE_FAILED - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_IPC - if ipc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see {@link ImageSourceNative}, {@link OhosImageSourceUpdateData} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_UpdateData(const ImageSourceNative* native, struct OhosImageSourceUpdateData* data); + + +/** + * @brief Releases an ImageSourceNative object. + * + * @param native Indicates a pointer to the {@link ImageSourceNative} object at the C++ native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * @see {@link ImageSourceNative}, {@link OH_ImageSource_Create}, {@link OH_ImageSource_CreateIncremental} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 4.0 + */ +int32_t OH_ImageSource_Release(ImageSourceNative* native); +#ifdef __cplusplus +}; +#endif +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_SOURCE_MDK_H_ diff --git a/multimedia/image_framework/libimage_ndk.ndk.json b/multimedia/image_framework/libimage_ndk.ndk.json index b7bba91e2c91d76036b542fdbee9bf9545f99784..b1639242ab73b68dd77fe2c278fe768ddec2e559 100644 --- a/multimedia/image_framework/libimage_ndk.ndk.json +++ b/multimedia/image_framework/libimage_ndk.ndk.json @@ -1,21 +1,21 @@ -[ - { - "first_introduced": "1", - "name": "OH_Image_InitImageNative" - }, - { - "name": "OH_Image_ClipRect" - }, - { - "name": "OH_Image_Size" - }, - { - "name": "OH_Image_Format" - }, - { - "name": "OH_Image_GetComponent" - }, - { - "name": "OH_Image_Release" - } +[ + { + "first_introduced": "1", + "name": "OH_Image_InitImageNative" + }, + { + "name": "OH_Image_ClipRect" + }, + { + "name": "OH_Image_Size" + }, + { + "name": "OH_Image_Format" + }, + { + "name": "OH_Image_GetComponent" + }, + { + "name": "OH_Image_Release" + } ] \ No newline at end of file diff --git a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json index 64800fe826282f2c62c68ee354f432af18ea4fed..08b70f8a99671df0729c13bc9cd9775804638094 100644 --- a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json +++ b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json @@ -1,66 +1,66 @@ -[ - { - "first_introduced": "1", - "name": "OH_GetImageInfo" - }, - { - "name": "OH_AccessPixels" - }, - { - "name": "OH_UnAccessPixels" - }, - { - "name": "OH_PixelMap_CreatePixelMap" - }, - { - "name": "OH_PixelMap_CreateAlphaPixelMap" - }, - { - "name": "OH_PixelMap_InitNativePixelMap" - }, - { - "name": "OH_PixelMap_GetBytesNumberPerRow" - }, - { - "name": "OH_PixelMap_GetIsEditable" - }, - { - "name": "OH_PixelMap_IsSupportAlpha" - }, - { - "name": "OH_PixelMap_SetAlphaAble" - }, - { - "name": "OH_PixelMap_GetDensity" - }, - { - "name": "OH_PixelMap_SetDensity" - }, - { - "name": "OH_PixelMap_SetOpacity" - }, - { - "name": "OH_PixelMap_Scale" - }, - { - "name": "OH_PixelMap_Translate" - }, - { - "name": "OH_PixelMap_Rotate" - }, - { - "name": "OH_PixelMap_Flip" - }, - { - "name": "OH_PixelMap_Crop" - }, - { - "name": "OH_PixelMap_GetImageInfo" - }, - { - "name": "OH_PixelMap_AccessPixels" - }, - { - "name": "OH_PixelMap_UnAccessPixels" - } +[ + { + "first_introduced": "1", + "name": "OH_GetImageInfo" + }, + { + "name": "OH_AccessPixels" + }, + { + "name": "OH_UnAccessPixels" + }, + { + "name": "OH_PixelMap_CreatePixelMap" + }, + { + "name": "OH_PixelMap_CreateAlphaPixelMap" + }, + { + "name": "OH_PixelMap_InitNativePixelMap" + }, + { + "name": "OH_PixelMap_GetBytesNumberPerRow" + }, + { + "name": "OH_PixelMap_GetIsEditable" + }, + { + "name": "OH_PixelMap_IsSupportAlpha" + }, + { + "name": "OH_PixelMap_SetAlphaAble" + }, + { + "name": "OH_PixelMap_GetDensity" + }, + { + "name": "OH_PixelMap_SetDensity" + }, + { + "name": "OH_PixelMap_SetOpacity" + }, + { + "name": "OH_PixelMap_Scale" + }, + { + "name": "OH_PixelMap_Translate" + }, + { + "name": "OH_PixelMap_Rotate" + }, + { + "name": "OH_PixelMap_Flip" + }, + { + "name": "OH_PixelMap_Crop" + }, + { + "name": "OH_PixelMap_GetImageInfo" + }, + { + "name": "OH_PixelMap_AccessPixels" + }, + { + "name": "OH_PixelMap_UnAccessPixels" + } ] \ No newline at end of file diff --git a/multimedia/image_framework/libimage_receiver_ndk.ndk.json b/multimedia/image_framework/libimage_receiver_ndk.ndk.json index c92209afc26e6a16a0657b61c2f9424105ad76e9..cfbaa7dfb68e74d078207ad39bf7aedd92fffc1a 100644 --- a/multimedia/image_framework/libimage_receiver_ndk.ndk.json +++ b/multimedia/image_framework/libimage_receiver_ndk.ndk.json @@ -1,33 +1,33 @@ -[ - { - "first_introduced": "1", - "name": "OH_Image_Receiver_CreateImageReceiver" - }, - { - "name": "OH_Image_Receiver_InitImageReceiverNative" - }, - { - "name": "OH_Image_Receiver_GetReceivingSurfaceId" - }, - { - "name": "OH_Image_Receiver_ReadLatestImage" - }, - { - "name": "OH_Image_Receiver_ReadNextImage" - }, - { - "name": "OH_Image_Receiver_On" - }, - { - "name": "OH_Image_Receiver_GetSize" - }, - { - "name": "OH_Image_Receiver_GetCapacity" - }, - { - "name": "OH_Image_Receiver_GetFormat" - }, - { - "name": "OH_Image_Receiver_Release" - } +[ + { + "first_introduced": "1", + "name": "OH_Image_Receiver_CreateImageReceiver" + }, + { + "name": "OH_Image_Receiver_InitImageReceiverNative" + }, + { + "name": "OH_Image_Receiver_GetReceivingSurfaceId" + }, + { + "name": "OH_Image_Receiver_ReadLatestImage" + }, + { + "name": "OH_Image_Receiver_ReadNextImage" + }, + { + "name": "OH_Image_Receiver_On" + }, + { + "name": "OH_Image_Receiver_GetSize" + }, + { + "name": "OH_Image_Receiver_GetCapacity" + }, + { + "name": "OH_Image_Receiver_GetFormat" + }, + { + "name": "OH_Image_Receiver_Release" + } ] \ No newline at end of file diff --git a/multimedia/image_framework/libimage_source_ndk.ndk.json b/multimedia/image_framework/libimage_source_ndk.ndk.json index b2606bfb22ec3ef3a8fb4647d908d0534e4b870a..6e24ca18ac8ae952be20824cae15cf84e41353a9 100644 --- a/multimedia/image_framework/libimage_source_ndk.ndk.json +++ b/multimedia/image_framework/libimage_source_ndk.ndk.json @@ -1,42 +1,42 @@ -[ - { - "first_introduced": "1", - "name": "OH_ImageSource_Create" - }, - { - "name": "OH_ImageSource_CreateIncremental" - }, - { - "name": "OH_ImageSource_InitNative" - }, - { - "name": "OH_ImageSource_CreatePixelMap" - }, - { - "name": "OH_ImageSource_CreatePixelMapList" - }, - { - "name": "OH_ImageSource_GetDelayTime" - }, - { - "name": "OH_ImageSource_GetFrameCount" - }, - { - "name": "OH_ImageSource_GetSupportedFormats" - }, - { - "name": "OH_ImageSource_GetImageInfo" - }, - { - "name": "OH_ImageSource_GetImageProperty" - }, - { - "name": "OH_ImageSource_ModifyImageProperty" - }, - { - "name": "OH_ImageSource_UpdateData" - }, - { - "name": "OH_ImageSource_Release" - } +[ + { + "first_introduced": "1", + "name": "OH_ImageSource_Create" + }, + { + "name": "OH_ImageSource_CreateIncremental" + }, + { + "name": "OH_ImageSource_InitNative" + }, + { + "name": "OH_ImageSource_CreatePixelMap" + }, + { + "name": "OH_ImageSource_CreatePixelMapList" + }, + { + "name": "OH_ImageSource_GetDelayTime" + }, + { + "name": "OH_ImageSource_GetFrameCount" + }, + { + "name": "OH_ImageSource_GetSupportedFormats" + }, + { + "name": "OH_ImageSource_GetImageInfo" + }, + { + "name": "OH_ImageSource_GetImageProperty" + }, + { + "name": "OH_ImageSource_ModifyImageProperty" + }, + { + "name": "OH_ImageSource_UpdateData" + }, + { + "name": "OH_ImageSource_Release" + } ] \ No newline at end of file diff --git a/multimedia/image_framework/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts b/multimedia/image_framework/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts index baff7239aba50735546ff8fbb906bc7ed3ac6c59..7f465aeec7b8685bd319c89c5f160a6fdebf078f 100644 --- a/multimedia/image_framework/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts +++ b/multimedia/image_framework/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts @@ -1,23 +1,23 @@ -/* -* Copyright (C) 2022 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 image from '@ohos.multimedia.image' - -declare namespace mypixelmap { - function testGetImageInfo(PixelMap pixelMap): void; - function testAccessPixels(PixelMap pixelMap): void; - function testUnAccessPixels(PixelMap pixelMap): void; -} - +/* +* Copyright (C) 2022 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 image from '@ohos.multimedia.image' + +declare namespace mypixelmap { + function testGetImageInfo(PixelMap pixelMap): void; + function testAccessPixels(PixelMap pixelMap): void; + function testUnAccessPixels(PixelMap pixelMap): void; +} + export default mypixelmap; \ No newline at end of file diff --git a/multimedia/image_framework/ndk_test_example/BUILD.gn b/multimedia/image_framework/ndk_test_example/BUILD.gn index 8834d5e1f4dbf31f2a72a2d76935d25cfa4e8773..52e69539a67033704cd8a5ddb08ad07a8b664517 100644 --- a/multimedia/image_framework/ndk_test_example/BUILD.gn +++ b/multimedia/image_framework/ndk_test_example/BUILD.gn @@ -1,58 +1,58 @@ -# Copyright (C) 2022 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") - -############################################################################ -# Debug Used : mypixelmap -############################################################################ - -js_declaration("mypixelmap_js") { - part_name = "multimedia_image" - sources = [ "//foundation/multimedia/image_framework/interfaces/kits/native/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts" ] -} - -ohos_copy("mypixelmap_declaration") { - sources = [ "//foundation/multimedia/image_framework/interfaces/kits/native/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts" ] - outputs = [ target_out_dir + "/$target_name/" ] - module_source_dir = target_out_dir + "/$target_name" - module_install_name = "" -} - -ohos_shared_library("mypixelmap") { - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - install_enable = true - - sources = [ "my_pixel_map.cpp" ] - - include_dirs = [ - "include", - "//foundation/multimedia/image_framework/interfaces/kits/native/include", - ] - - deps = [ - "//foundation/arkui/napi:ace_napi", - "//foundation/multimedia/image_framework/frameworks/kits/js/common/pixelmap_ndk:pixelmap_ndk", - ] - - external_deps = [ "hilog:libhilog" ] - - relative_install_dir = "module" - - subsystem_name = "multimedia" - part_name = "multimedia_image" -} +# Copyright (C) 2022 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") + +############################################################################ +# Debug Used : mypixelmap +############################################################################ + +js_declaration("mypixelmap_js") { + part_name = "multimedia_image" + sources = [ "//foundation/multimedia/image_framework/interfaces/kits/native/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts" ] +} + +ohos_copy("mypixelmap_declaration") { + sources = [ "//foundation/multimedia/image_framework/interfaces/kits/native/ndk_test_example/@ohos.xtstest.mypixelmap.d.ts" ] + outputs = [ target_out_dir + "/$target_name/" ] + module_source_dir = target_out_dir + "/$target_name" + module_install_name = "" +} + +ohos_shared_library("mypixelmap") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + install_enable = true + + sources = [ "my_pixel_map.cpp" ] + + include_dirs = [ + "include", + "//foundation/multimedia/image_framework/interfaces/kits/native/include", + ] + + deps = [ + "//foundation/arkui/napi:ace_napi", + "//foundation/multimedia/image_framework/frameworks/kits/js/common/pixelmap_ndk:pixelmap_ndk", + ] + + external_deps = [ "hilog:libhilog" ] + + relative_install_dir = "module" + + subsystem_name = "multimedia" + part_name = "multimedia_image" +} diff --git a/multimedia/image_framework/ndk_test_example/my_pixel_map.cpp b/multimedia/image_framework/ndk_test_example/my_pixel_map.cpp index a4172f198f8c8db5073f1138aa844b882efa78ca..bb5722e413975bdc74e77735ca140d2fd57dafad 100644 --- a/multimedia/image_framework/ndk_test_example/my_pixel_map.cpp +++ b/multimedia/image_framework/ndk_test_example/my_pixel_map.cpp @@ -1,203 +1,203 @@ -/* - * Copyright (C) 2022 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 "my_pixel_map.h" -#include "media_errors.h" -#include "hilog/log.h" -#include "image_napi_utils.h" -#include "image_pixel_map_napi.h" - -using OHOS::HiviewDFX::HiLog; -namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "MyPixelMapNapiTest"}; -constexpr uint32_t TEST_ARG_SUM = 1; -} -namespace OHOS { -namespace Media { -static const std::string CLASS_NAME = "MyPixelMap"; -napi_ref MyPixelMap::sConstructor_ = nullptr; -MyPixelMap::MyPixelMap():env_(nullptr) -{ -} - -MyPixelMap::~MyPixelMap() -{ -} - -napi_value MyPixelMap::Init(napi_env env, napi_value exports) -{ - napi_property_descriptor props[] = { - }; - - napi_property_descriptor static_prop[] = { - DECLARE_NAPI_STATIC_FUNCTION("testGetImageInfo", TestGetImageInfo), - DECLARE_NAPI_STATIC_FUNCTION("testAccessPixels", TestAccessPixels), - DECLARE_NAPI_STATIC_FUNCTION("testUnAccessPixels", TestUnAccessPixels), - }; - - napi_value constructor = nullptr; - - if (napi_define_class(env, CLASS_NAME.c_str(), NAPI_AUTO_LENGTH, Constructor, nullptr, IMG_ARRAY_SIZE(props), - props, &constructor) != napi_ok) { - HiLog::Error(LABEL, "define class fail"); - return nullptr; - } - - if (napi_create_reference(env, constructor, 1, &sConstructor_) != napi_ok) { - HiLog::Error(LABEL, "create reference fail"); - return nullptr; - } - - if (napi_set_named_property(env, exports, CLASS_NAME.c_str(), constructor) != napi_ok) { - HiLog::Error(LABEL, "set named property fail"); - return nullptr; - } - - if (napi_define_properties(env, exports, IMG_ARRAY_SIZE(static_prop), static_prop) != napi_ok) { - HiLog::Error(LABEL, "define properties fail"); - return nullptr; - } - - HiLog::Debug(LABEL, "Init success"); - return exports; -} - -napi_value MyPixelMap::Constructor(napi_env env, napi_callback_info info) -{ - HiLog::Debug(LABEL, "Constructor IN"); - napi_value undefineVar = nullptr; - napi_get_undefined(env, &undefineVar); - - napi_status status; - napi_value thisVar = nullptr; - napi_get_undefined(env, &thisVar); - - napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); - - HiLog::Debug(LABEL, "Constructor OUT"); - return thisVar; -} - -napi_value MyPixelMap::TestGetImageInfo(napi_env env, napi_callback_info info) -{ - HiLog::Debug(LABEL, "TestGetImageInfo IN"); - - napi_value result = nullptr; - napi_get_undefined(env, &result); - - napi_status status; - napi_value thisVar = nullptr; - napi_value argValue[TEST_ARG_SUM] = {0}; - size_t argCount = TEST_ARG_SUM; - - status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); - if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); - } - - HiLog::Debug(LABEL, "OH_GetImageInfo Test|Begin"); - OhosPixelMapInfo pixelMapInfo; - int32_t res = OH_GetImageInfo(env, argValue[0], &pixelMapInfo); - HiLog::Debug(LABEL, "OH_GetImageInfo Test|End, res=%{public}d", res); - HiLog::Debug(LABEL, "OH_GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", - pixelMapInfo.width, pixelMapInfo.height, pixelMapInfo.rowSize, pixelMapInfo.pixelFormat); - - HiLog::Debug(LABEL, "TestGetImageInfo OUT"); - return result; -} - -napi_value MyPixelMap::TestAccessPixels(napi_env env, napi_callback_info info) -{ - HiLog::Debug(LABEL, "TestAccessPixels IN"); - - napi_value result = nullptr; - napi_get_undefined(env, &result); - - napi_status status; - napi_value thisVar = nullptr; - napi_value argValue[TEST_ARG_SUM] = {0}; - size_t argCount = TEST_ARG_SUM; - - status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); - if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); - } - - HiLog::Debug(LABEL, "OH_AccessPixels Test|Begin"); - void* addrPtr = nullptr; - int32_t res = OH_AccessPixels(env, argValue[0], &addrPtr); - HiLog::Debug(LABEL, "OH_AccessPixels Test|End, res=%{public}d", res); - - HiLog::Debug(LABEL, "TestAccessPixels OUT"); - return result; -} - -napi_value MyPixelMap::TestUnAccessPixels(napi_env env, napi_callback_info info) -{ - HiLog::Debug(LABEL, "TestUnAccessPixels IN"); - - napi_value result = nullptr; - napi_get_undefined(env, &result); - - napi_status status; - napi_value thisVar = nullptr; - napi_value argValue[TEST_ARG_SUM] = {0}; - size_t argCount = TEST_ARG_SUM; - - status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); - if (status != napi_ok) { - HiLog::Error(LABEL, "napi_get_cb_info fail"); - } - - HiLog::Debug(LABEL, "OH_UnAccessPixels Test|Begin"); - int32_t res = OH_UnAccessPixels(env, argValue[0]); - HiLog::Debug(LABEL, "OH_UnAccessPixels Test|End, res=%{public}d", res); - - HiLog::Debug(LABEL, "TestUnAccessPixels OUT"); - return result; -} - -/* - * Function registering all props and functions of ohos.medialibrary module - */ -static napi_value Export(napi_env env, napi_value exports) -{ - HiLog::Error(LABEL, "MyPixelMap CALL"); - MyPixelMap::Init(env, exports); - return exports; -} - -/* - * module define - */ -static napi_module g_module = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Export, - .nm_modname = "xtstest.mypixelmap", - .nm_priv = ((void*)0), - .reserved = {0} -}; - -/* - * module register - */ -extern "C" __attribute__((constructor)) void MyPixelMapRegisterModule(void) -{ - napi_module_register(&g_module); -} -} // namespace Media -} // namespace OHOS +/* + * Copyright (C) 2022 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 "my_pixel_map.h" +#include "media_errors.h" +#include "hilog/log.h" +#include "image_napi_utils.h" +#include "image_pixel_map_napi.h" + +using OHOS::HiviewDFX::HiLog; +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "MyPixelMapNapiTest"}; +constexpr uint32_t TEST_ARG_SUM = 1; +} +namespace OHOS { +namespace Media { +static const std::string CLASS_NAME = "MyPixelMap"; +napi_ref MyPixelMap::sConstructor_ = nullptr; +MyPixelMap::MyPixelMap():env_(nullptr) +{ +} + +MyPixelMap::~MyPixelMap() +{ +} + +napi_value MyPixelMap::Init(napi_env env, napi_value exports) +{ + napi_property_descriptor props[] = { + }; + + napi_property_descriptor static_prop[] = { + DECLARE_NAPI_STATIC_FUNCTION("testGetImageInfo", TestGetImageInfo), + DECLARE_NAPI_STATIC_FUNCTION("testAccessPixels", TestAccessPixels), + DECLARE_NAPI_STATIC_FUNCTION("testUnAccessPixels", TestUnAccessPixels), + }; + + napi_value constructor = nullptr; + + if (napi_define_class(env, CLASS_NAME.c_str(), NAPI_AUTO_LENGTH, Constructor, nullptr, IMG_ARRAY_SIZE(props), + props, &constructor) != napi_ok) { + HiLog::Error(LABEL, "define class fail"); + return nullptr; + } + + if (napi_create_reference(env, constructor, 1, &sConstructor_) != napi_ok) { + HiLog::Error(LABEL, "create reference fail"); + return nullptr; + } + + if (napi_set_named_property(env, exports, CLASS_NAME.c_str(), constructor) != napi_ok) { + HiLog::Error(LABEL, "set named property fail"); + return nullptr; + } + + if (napi_define_properties(env, exports, IMG_ARRAY_SIZE(static_prop), static_prop) != napi_ok) { + HiLog::Error(LABEL, "define properties fail"); + return nullptr; + } + + HiLog::Debug(LABEL, "Init success"); + return exports; +} + +napi_value MyPixelMap::Constructor(napi_env env, napi_callback_info info) +{ + HiLog::Debug(LABEL, "Constructor IN"); + napi_value undefineVar = nullptr; + napi_get_undefined(env, &undefineVar); + + napi_status status; + napi_value thisVar = nullptr; + napi_get_undefined(env, &thisVar); + + napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr); + + HiLog::Debug(LABEL, "Constructor OUT"); + return thisVar; +} + +napi_value MyPixelMap::TestGetImageInfo(napi_env env, napi_callback_info info) +{ + HiLog::Debug(LABEL, "TestGetImageInfo IN"); + + napi_value result = nullptr; + napi_get_undefined(env, &result); + + napi_status status; + napi_value thisVar = nullptr; + napi_value argValue[TEST_ARG_SUM] = {0}; + size_t argCount = TEST_ARG_SUM; + + status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); + if (status != napi_ok) { + HiLog::Error(LABEL, "napi_get_cb_info fail"); + } + + HiLog::Debug(LABEL, "OH_GetImageInfo Test|Begin"); + OhosPixelMapInfo pixelMapInfo; + int32_t res = OH_GetImageInfo(env, argValue[0], &pixelMapInfo); + HiLog::Debug(LABEL, "OH_GetImageInfo Test|End, res=%{public}d", res); + HiLog::Debug(LABEL, "OH_GetImageInfo, w=%{public}u, h=%{public}u, r=%{public}u, f=%{public}d", + pixelMapInfo.width, pixelMapInfo.height, pixelMapInfo.rowSize, pixelMapInfo.pixelFormat); + + HiLog::Debug(LABEL, "TestGetImageInfo OUT"); + return result; +} + +napi_value MyPixelMap::TestAccessPixels(napi_env env, napi_callback_info info) +{ + HiLog::Debug(LABEL, "TestAccessPixels IN"); + + napi_value result = nullptr; + napi_get_undefined(env, &result); + + napi_status status; + napi_value thisVar = nullptr; + napi_value argValue[TEST_ARG_SUM] = {0}; + size_t argCount = TEST_ARG_SUM; + + status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); + if (status != napi_ok) { + HiLog::Error(LABEL, "napi_get_cb_info fail"); + } + + HiLog::Debug(LABEL, "OH_AccessPixels Test|Begin"); + void* addrPtr = nullptr; + int32_t res = OH_AccessPixels(env, argValue[0], &addrPtr); + HiLog::Debug(LABEL, "OH_AccessPixels Test|End, res=%{public}d", res); + + HiLog::Debug(LABEL, "TestAccessPixels OUT"); + return result; +} + +napi_value MyPixelMap::TestUnAccessPixels(napi_env env, napi_callback_info info) +{ + HiLog::Debug(LABEL, "TestUnAccessPixels IN"); + + napi_value result = nullptr; + napi_get_undefined(env, &result); + + napi_status status; + napi_value thisVar = nullptr; + napi_value argValue[TEST_ARG_SUM] = {0}; + size_t argCount = TEST_ARG_SUM; + + status = napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); + if (status != napi_ok) { + HiLog::Error(LABEL, "napi_get_cb_info fail"); + } + + HiLog::Debug(LABEL, "OH_UnAccessPixels Test|Begin"); + int32_t res = OH_UnAccessPixels(env, argValue[0]); + HiLog::Debug(LABEL, "OH_UnAccessPixels Test|End, res=%{public}d", res); + + HiLog::Debug(LABEL, "TestUnAccessPixels OUT"); + return result; +} + +/* + * Function registering all props and functions of ohos.medialibrary module + */ +static napi_value Export(napi_env env, napi_value exports) +{ + HiLog::Error(LABEL, "MyPixelMap CALL"); + MyPixelMap::Init(env, exports); + return exports; +} + +/* + * module define + */ +static napi_module g_module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Export, + .nm_modname = "xtstest.mypixelmap", + .nm_priv = ((void*)0), + .reserved = {0} +}; + +/* + * module register + */ +extern "C" __attribute__((constructor)) void MyPixelMapRegisterModule(void) +{ + napi_module_register(&g_module); +} +} // namespace Media +} // namespace OHOS diff --git a/multimedia/image_framework/ndk_test_example/my_pixel_map.h b/multimedia/image_framework/ndk_test_example/my_pixel_map.h index 5542df1f0af39a7ef512305fab72fa0a9896f5a8..3dbc070097dc497c50503a9f2596046ab2009e21 100644 --- a/multimedia/image_framework/ndk_test_example/my_pixel_map.h +++ b/multimedia/image_framework/ndk_test_example/my_pixel_map.h @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2022 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 PIXEL_MAP_NAPI_TEST_H_ -#define PIXEL_MAP_NAPI_TEST_H_ - -#include "pixel_map.h" -#include "image_type.h" -#include "image_source.h" -#include "napi/native_api.h" -#include "napi/native_node_api.h" - -namespace OHOS { -namespace Media { -class MyPixelMap { -public: - MyPixelMap(); - ~MyPixelMap(); - - static napi_value Init(napi_env env, napi_value exports); - - static napi_value TestGetImageInfo(napi_env env, napi_callback_info info); - static napi_value TestAccessPixels(napi_env env, napi_callback_info info); - static napi_value TestUnAccessPixels(napi_env env, napi_callback_info info); - -private: - static napi_value Constructor(napi_env env, napi_callback_info info); - - static napi_ref sConstructor_; - - napi_env env_ = nullptr; -}; -} // namespace Media -} // namespace OHOS -#endif /* PIXEL_MAP_NAPI_TEST_H_ */ +/* + * Copyright (C) 2022 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 PIXEL_MAP_NAPI_TEST_H_ +#define PIXEL_MAP_NAPI_TEST_H_ + +#include "pixel_map.h" +#include "image_type.h" +#include "image_source.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" + +namespace OHOS { +namespace Media { +class MyPixelMap { +public: + MyPixelMap(); + ~MyPixelMap(); + + static napi_value Init(napi_env env, napi_value exports); + + static napi_value TestGetImageInfo(napi_env env, napi_callback_info info); + static napi_value TestAccessPixels(napi_env env, napi_callback_info info); + static napi_value TestUnAccessPixels(napi_env env, napi_callback_info info); + +private: + static napi_value Constructor(napi_env env, napi_callback_info info); + + static napi_ref sConstructor_; + + napi_env env_ = nullptr; +}; +} // namespace Media +} // namespace OHOS +#endif /* PIXEL_MAP_NAPI_TEST_H_ */ diff --git a/multimedia/player_framework/avscreen_capture/BUILD.gn b/multimedia/player_framework/avscreen_capture/BUILD.gn index 35f4bdef94b57054247dfd7a6fa7f6035a4677ef..336a70e823f6318ccd1a314df907b8311cb31411 100644 --- a/multimedia/player_framework/avscreen_capture/BUILD.gn +++ b/multimedia/player_framework/avscreen_capture/BUILD.gn @@ -1,39 +1,39 @@ -# 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. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") -import("//foundation/multimedia/player_framework/config.gni") - -ohos_ndk_headers("native_avscreen_capture_header") { - dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" - sources = [ - "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture.h", - "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture_base.h", - "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture_errors.h", - ] -} - -ohos_ndk_library("libnative_avscreen_capture") { - ndk_description_file = "./libnative_avscreen_capture.ndk.json" - min_compact_version = "1" - output_name = "native_avscreen_capture" - output_extension = "so" - - system_capability = "SystemCapability.Multimedia.Media.AVScreenCapture" - system_capability_headers = [ - "multimedia/player_framework/native_avscreen_capture.h", - "multimedia/player_framework/native_avscreen_capture_base.h", - "multimedia/player_framework/native_avscreen_capture_errors.h", - ] -} +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +import("//foundation/multimedia/player_framework/config.gni") + +ohos_ndk_headers("native_avscreen_capture_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture.h", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture_base.h", + "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c/native_avscreen_capture_errors.h", + ] +} + +ohos_ndk_library("libnative_avscreen_capture") { + ndk_description_file = "./libnative_avscreen_capture.ndk.json" + min_compact_version = "1" + output_name = "native_avscreen_capture" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.AVScreenCapture" + system_capability_headers = [ + "multimedia/player_framework/native_avscreen_capture.h", + "multimedia/player_framework/native_avscreen_capture_base.h", + "multimedia/player_framework/native_avscreen_capture_errors.h", + ] +} diff --git a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json index cf7bda8c551af1cb015227c9d62c5648812f412a..e7699c2f4c79de9563033ef7e618bebeee68568e 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -1,13 +1,13 @@ -[ - { "name": "OH_AVScreenCapture_Create" }, - { "name": "OH_AVScreenCapture_Init" }, - { "name": "OH_AVScreenCapture_StartScreenCapture" }, - { "name": "OH_AVScreenCapture_StopScreenCapture" }, - { "name": "OH_AVScreenCapture_AcquireAudioBuffer" }, - { "name": "OH_AVScreenCapture_AcquireVideoBuffer" }, - { "name": "OH_AVScreenCapture_ReleaseAudioBuffer" }, - { "name": "OH_AVScreenCapture_ReleaseVideoBuffer" }, - { "name": "OH_AVScreenCapture_SetCallback" }, - { "name": "OH_AVScreenCapture_Release" }, - { "name": "OH_AVScreenCapture_SetMicrophoneEnabled" } +[ + { "name": "OH_AVScreenCapture_Create" }, + { "name": "OH_AVScreenCapture_Init" }, + { "name": "OH_AVScreenCapture_StartScreenCapture" }, + { "name": "OH_AVScreenCapture_StopScreenCapture" }, + { "name": "OH_AVScreenCapture_AcquireAudioBuffer" }, + { "name": "OH_AVScreenCapture_AcquireVideoBuffer" }, + { "name": "OH_AVScreenCapture_ReleaseAudioBuffer" }, + { "name": "OH_AVScreenCapture_ReleaseVideoBuffer" }, + { "name": "OH_AVScreenCapture_SetCallback" }, + { "name": "OH_AVScreenCapture_Release" }, + { "name": "OH_AVScreenCapture_SetMicrophoneEnabled" } ] \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 22837a29dac5448236f11f5a47ce624914e94396..9f4fe251a26b33ee9be170bfb770fa5a87994927 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -1,191 +1,191 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVSCREEN_CAPTURE_H -#define NATIVE_AVSCREEN_CAPTURE_H - -#include -#include -#include "native_avscreen_capture_errors.h" -#include "native_avscreen_capture_base.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Create a screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @return Returns a pointer to an OH_AVScreenCapture instance - * @since 10 - * @version 1.0 - */ -struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void); - -/** - * @brief To init the screen capture, typically, you need to configure the description information of the audio - * and video, which can be extracted from the container. This interface must be called before StartAVScreenCapture - * called. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param config Information describing the audio and video config - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture, - OH_AVScreenCaptureConfig config); - -/** - * @brief Start the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param type Information describing the data type of the capture - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture); - -/** - * @brief Stop the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture); - -/** - * @brief Start av screen record use to start save screen record file. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture); - -/** - * @brief Start av screen record use to stop save screen record file. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture); - -/** - * @brief Acquire the audio buffer for the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param audiobuffer Information describing the audio buffer of the capture - * @param type Information describing the audio source type - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture, - OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type); - -/** - * @brief Acquire the video buffer for the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param fence A processing state of display buffer - * @param timestamp Information about the video buffer - * @param region Information about the video buffer - * @return Returns a pointer to an OH_NativeBuffer instance - * @since 10 - * @version 1.0 - */ -OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture, - int32_t *fence, int64_t *timestamp, struct OH_Rect *region); - -/** - * @brief Release the audio buffer for the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param type Information describing the audio source type - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture, - OH_AudioCaptureSourceType type); - -/** - * @brief Release the video buffer for the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture); - -/** - * @brief Set the callback function so that your application - * can respond to the events generated by the av screen capture. This interface must be called before Init is called. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param callback A collection of all callback functions, see {@link OH_AVScreenCaptureCallback} - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture, - struct OH_AVScreenCaptureCallback callback); - -/** - * @brief Release the av screen capture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture); - -/** - * @brief Controls the switch of the microphone, which is turned on by default - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param isMicrophone The switch of the microphone - * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, - * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} - * @since 10 - * @version 1.0 - */ -OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture, - bool isMicrophone); - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVSCREEN_CAPTURE_H +#define NATIVE_AVSCREEN_CAPTURE_H + +#include +#include +#include "native_avscreen_capture_errors.h" +#include "native_avscreen_capture_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @return Returns a pointer to an OH_AVScreenCapture instance + * @since 10 + * @version 1.0 + */ +struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void); + +/** + * @brief To init the screen capture, typically, you need to configure the description information of the audio + * and video, which can be extracted from the container. This interface must be called before StartAVScreenCapture + * called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param config Information describing the audio and video config + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture, + OH_AVScreenCaptureConfig config); + +/** + * @brief Start the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param type Information describing the data type of the capture + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture); + +/** + * @brief Stop the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture); + +/** + * @brief Start av screen record use to start save screen record file. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture); + +/** + * @brief Start av screen record use to stop save screen record file. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture); + +/** + * @brief Acquire the audio buffer for the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param audiobuffer Information describing the audio buffer of the capture + * @param type Information describing the audio source type + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture, + OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type); + +/** + * @brief Acquire the video buffer for the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param fence A processing state of display buffer + * @param timestamp Information about the video buffer + * @param region Information about the video buffer + * @return Returns a pointer to an OH_NativeBuffer instance + * @since 10 + * @version 1.0 + */ +OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture, + int32_t *fence, int64_t *timestamp, struct OH_Rect *region); + +/** + * @brief Release the audio buffer for the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param type Information describing the audio source type + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture, + OH_AudioCaptureSourceType type); + +/** + * @brief Release the video buffer for the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture); + +/** + * @brief Set the callback function so that your application + * can respond to the events generated by the av screen capture. This interface must be called before Init is called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param callback A collection of all callback functions, see {@link OH_AVScreenCaptureCallback} + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture, + struct OH_AVScreenCaptureCallback callback); + +/** + * @brief Release the av screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture); + +/** + * @brief Controls the switch of the microphone, which is turned on by default + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param isMicrophone The switch of the microphone + * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 10 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture, + bool isMicrophone); + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVSCREEN_CAPTURE_H \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture_base.h b/multimedia/player_framework/native_avscreen_capture_base.h index 97b27e3f16aea7201b30461c3140cf6595305765..b7e36c436c143424dfed3e5700cdba7acbaa7665 100644 --- a/multimedia/player_framework/native_avscreen_capture_base.h +++ b/multimedia/player_framework/native_avscreen_capture_base.h @@ -1,394 +1,394 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVSCREEN_CAPTURE_BASE_H -#define NATIVE_AVSCREEN_CAPTURE_BASE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Nativebuffer of avscreeencapture that from graphics. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_NativeBuffer OH_NativeBuffer; - -/** - * @brief Initialization of avscreeencapture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AVScreenCapture OH_AVScreenCapture; - -/** - * @brief Enumerates screen capture mode. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_CaptureMode { - /* capture home screen */ - OH_CAPTURE_HOME_SCREEN = 0, - /* capture a specified screen */ - OH_CAPTURE_SPECIFIED_SCREEN = 1, - /* capture a specified window */ - OH_CAPTURE_SPECIFIED_WINDOW = 2, - OH_CAPTURE_INVAILD = -1 -} OH_CaptureMode; - -/** - * @brief Enumerates audio cap source type. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_AudioCaptureSourceType { - /* Invalid audio source */ - OH_SOURCE_INVALID = -1, - /* Default audio source */ - OH_SOURCE_DEFAULT = 0, - /* Microphone */ - OH_MIC = 1, - /* inner all PlayBack */ - OH_ALL_PLAYBACK = 2, - /* inner app PlayBack */ - OH_APP_PLAYBACK = 3, -} OH_AudioCaptureSourceType; - -/** - * @brief Enumerates audio codec formats. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_AudioCodecFormat { - /* Default format */ - OH_AUDIO_DEFAULT = 0, - /* Advanced Audio Coding Low Complexity (AAC-LC) */ - OH_AAC_LC = 3, - /* Invalid value */ - OH_AUDIO_CODEC_FORMAT_BUTT, -} OH_AudioCodecFormat; - -/** - * @brief Enumerates video codec formats. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_VideoCodecFormat { - /* Default format */ - OH_VIDEO_DEFAULT = 0, - /* H.264 */ - OH_H264 = 2, - /* H.265/HEVC */ - OH_H265 = 4, - /* MPEG4 */ - OH_MPEG4 = 6, - /* VP8 */ - OH_VP8 = 8, - /* VP9 */ - OH_VP9 = 10, - /* Invalid format */ - OH_VIDEO_CODEC_FORMAT_BUTT, -} OH_VideoCodecFormat; - -/** - * @brief Enumerates screen capture data type. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_DataType { - /* YUV/RGBA/PCM, etc. original stream */ - OH_ORIGINAL_STREAM = 0, - /* h264/AAC, etc. encoded stream */ - OH_ENCODED_STREAM = 1, - /* mp4 file */ - OH_CAPTURE_FILE = 2, - OH_INVAILD = -1 -} OH_DataType; - -/** - * @brief Enumerates video source types. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_VideoSourceType { - /* Unsupported App Usage. */ - /* YUV video data provided through graphic */ - OH_VIDEO_SOURCE_SURFACE_YUV = 0, - /* Raw encoded data provided through graphic */ - OH_VIDEO_SOURCE_SURFACE_ES, - /* RGBA video data provided through graphic */ - OH_VIDEO_SOURCE_SURFACE_RGBA, - /* Invalid value */ - OH_VIDEO_SOURCE_BUTT -} OH_VideoSourceType; - -/** - * @brief Enumerates the container format types. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef enum OH_ContainerFormatType { - /* Audio format type -- m4a */ - CFT_MPEG_4A = 0, - /* Video format type -- mp4 */ - CFT_MPEG_4 = 1 -} OH_ContainerFormatType; - -/** - * @brief Audio capture info struct - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AudioCaptureInfo { - /* Audio capture sample rate info */ - int32_t audioSampleRate; - /* Audio capture channel info */ - int32_t audioChannels; - /* Audio capture source type */ - OH_AudioCaptureSourceType audioSource; -} OH_AudioCaptureInfo; - -/** - * @brief Audio encoder info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AudioEncInfo { - /* Audio encoder bitrate */ - int32_t audioBitrate; - /* Audio codec format */ - OH_AudioCodecFormat audioCodecformat; -} OH_AudioEncInfo; - -/** - * @brief The audio info of avscreeencapture - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AudioInfo { - /* Audio capture info of microphone */ - OH_AudioCaptureInfo micCapInfo; - /* Audio capture info of inner */ - OH_AudioCaptureInfo innerCapInfo; - /* Audio encoder info, no need to set, while dataType = OH_ORIGINAL_STREAM */ - OH_AudioEncInfo audioEncInfo; -} OH_AudioInfo; - -/** - * @brief Video capture info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_VideoCaptureInfo { - /* Display id, should be set while captureMode = CAPTURE_SPECIFIED_SCREEN */ - uint64_t displayId; - /* The ids of mission, should be set while captureMode = CAPTURE_SPECIFIED_WINDOW */ - int32_t *missionIDs; - /* Mission ids length, should be set while captureMode = CAPTURE_SPECIFIED_WINDOW */ - int32_t missionIDsLen; - /* Video frame width of avscreeencapture */ - int32_t videoFrameWidth; - /* Video frame height of avscreeencapture */ - int32_t videoFrameHeight; - /* Video source type of avscreeencapture */ - OH_VideoSourceType videoSource; -} OH_VideoCaptureInfo; - -/** - * @brief Videoc encoder info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_VideoEncInfo { - /* Video encoder format */ - OH_VideoCodecFormat videoCodec; - /* Video encoder bitrate */ - int32_t videoBitrate; - /* Video encoder frame rate */ - int32_t videoFrameRate; -} OH_VideoEncInfo; - -/** - * @brief Video info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_VideoInfo { - /* Video capture info */ - OH_VideoCaptureInfo videoCapInfo; - /* Video encoder info */ - OH_VideoEncInfo videoEncInfo; -} OH_VideoInfo; - -/** - * @brief Recorder file info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_RecorderInfo { - /* Recorder file url */ - char *url; - /* Recorder file url length */ - uint32_t urlLen; - /* Recorder file format */ - OH_ContainerFormatType fileFormat; -} OH_RecorderInfo; - -/** - * @brief AV screeen capture config info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AVScreenCaptureConfig { - OH_CaptureMode captureMode; - OH_DataType dataType; - OH_AudioInfo audioInfo; - OH_VideoInfo videoInfo; - /* should be set, while dataType = OH_CAPTURE_FILE */ - OH_RecorderInfo recorderInfo; -} OH_AVScreenCaptureConfig; - -/** - * @brief When an error occurs in the running of the OH_AVScreenCapture instance, the function pointer will be called - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param errorCode specific error code - * - * @since 10 - * @version 1.0 - */ -typedef void (*OH_AVScreenCaptureOnError)(OH_AVScreenCapture *capture, int32_t errorCode); - -/** - * @brief When audio buffer is available during the operation of OH_AVScreenCapture, the function pointer will - * be called. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param isReady Information describing whether audio buffer is available - * @param type Information describing the audio source type - * - * @since 10 - * @version 1.0 - */ -typedef void (*OH_AVScreenCaptureOnAudioBufferAvailable)(OH_AVScreenCapture *capture, bool isReady, - OH_AudioCaptureSourceType type); - -/** - * @brief When video buffer is available during the operation of OH_AVScreenCapture, the function pointer will - * be called. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param capture Pointer to an OH_AVScreenCapture instance - * @param isReady Information describing whether video buffer is available - * - * @since 10 - * @version 1.0 - */ -typedef void (*OH_AVScreenCaptureOnVideoBufferAvailable)(OH_AVScreenCapture *capture, bool isReady); - -/** - * @brief A collection of all callback function pointers in OH_AVScreenCapture. Register an instance of this - * structure to the OH_AVScreenCapture instance, and process the information reported through the callback to ensure the - * normal operation of OH_AVScreenCapture. - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @param onError Monitor OH_AVScreenCapture operation errors, refer to {@link OH_AVScreenCaptureOnError} - * @param onAudioBufferAvailable Monitor audio buffer, refer to {@link OH_AVScreenCaptureOnAudioBufferAvailable} - * @param onVideoBufferAvailable Monitor video buffer, refer to {@link OH_AVScreenCaptureOnVideoBufferAvailable} - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AVScreenCaptureCallback { - OH_AVScreenCaptureOnError onError; - OH_AVScreenCaptureOnAudioBufferAvailable onAudioBufferAvailable; - OH_AVScreenCaptureOnVideoBufferAvailable onVideoBufferAvailable; -} OH_AVScreenCaptureCallback; - -/** - * @brief avscreeencapture rect info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_Rect { - /* X-coordinate of screen recording */ - int32_t x; - /* y-coordinate of screen recording */ - int32_t y; - /* Width of screen recording */ - int32_t width; - /* Height of screen recording */ - int32_t height; -} OH_Rect; - - -/** - * @brief Audiobuffer struct info - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * - * @since 10 - * @version 1.0 - */ -typedef struct OH_AudioBuffer { - /* Audio buffer memory block */ - uint8_t *buf; - /* Audio buffer memory block size */ - int32_t size; - /* Audio buffer timestamp info */ - int64_t timestamp; - /* Audio capture source type */ - OH_AudioCaptureSourceType type; -} OH_AudioBuffer; - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVSCREEN_CAPTURE_BASE_H +#define NATIVE_AVSCREEN_CAPTURE_BASE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Nativebuffer of avscreeencapture that from graphics. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_NativeBuffer OH_NativeBuffer; + +/** + * @brief Initialization of avscreeencapture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AVScreenCapture OH_AVScreenCapture; + +/** + * @brief Enumerates screen capture mode. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_CaptureMode { + /* capture home screen */ + OH_CAPTURE_HOME_SCREEN = 0, + /* capture a specified screen */ + OH_CAPTURE_SPECIFIED_SCREEN = 1, + /* capture a specified window */ + OH_CAPTURE_SPECIFIED_WINDOW = 2, + OH_CAPTURE_INVAILD = -1 +} OH_CaptureMode; + +/** + * @brief Enumerates audio cap source type. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_AudioCaptureSourceType { + /* Invalid audio source */ + OH_SOURCE_INVALID = -1, + /* Default audio source */ + OH_SOURCE_DEFAULT = 0, + /* Microphone */ + OH_MIC = 1, + /* inner all PlayBack */ + OH_ALL_PLAYBACK = 2, + /* inner app PlayBack */ + OH_APP_PLAYBACK = 3, +} OH_AudioCaptureSourceType; + +/** + * @brief Enumerates audio codec formats. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_AudioCodecFormat { + /* Default format */ + OH_AUDIO_DEFAULT = 0, + /* Advanced Audio Coding Low Complexity (AAC-LC) */ + OH_AAC_LC = 3, + /* Invalid value */ + OH_AUDIO_CODEC_FORMAT_BUTT, +} OH_AudioCodecFormat; + +/** + * @brief Enumerates video codec formats. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_VideoCodecFormat { + /* Default format */ + OH_VIDEO_DEFAULT = 0, + /* H.264 */ + OH_H264 = 2, + /* H.265/HEVC */ + OH_H265 = 4, + /* MPEG4 */ + OH_MPEG4 = 6, + /* VP8 */ + OH_VP8 = 8, + /* VP9 */ + OH_VP9 = 10, + /* Invalid format */ + OH_VIDEO_CODEC_FORMAT_BUTT, +} OH_VideoCodecFormat; + +/** + * @brief Enumerates screen capture data type. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_DataType { + /* YUV/RGBA/PCM, etc. original stream */ + OH_ORIGINAL_STREAM = 0, + /* h264/AAC, etc. encoded stream */ + OH_ENCODED_STREAM = 1, + /* mp4 file */ + OH_CAPTURE_FILE = 2, + OH_INVAILD = -1 +} OH_DataType; + +/** + * @brief Enumerates video source types. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_VideoSourceType { + /* Unsupported App Usage. */ + /* YUV video data provided through graphic */ + OH_VIDEO_SOURCE_SURFACE_YUV = 0, + /* Raw encoded data provided through graphic */ + OH_VIDEO_SOURCE_SURFACE_ES, + /* RGBA video data provided through graphic */ + OH_VIDEO_SOURCE_SURFACE_RGBA, + /* Invalid value */ + OH_VIDEO_SOURCE_BUTT +} OH_VideoSourceType; + +/** + * @brief Enumerates the container format types. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef enum OH_ContainerFormatType { + /* Audio format type -- m4a */ + CFT_MPEG_4A = 0, + /* Video format type -- mp4 */ + CFT_MPEG_4 = 1 +} OH_ContainerFormatType; + +/** + * @brief Audio capture info struct + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AudioCaptureInfo { + /* Audio capture sample rate info */ + int32_t audioSampleRate; + /* Audio capture channel info */ + int32_t audioChannels; + /* Audio capture source type */ + OH_AudioCaptureSourceType audioSource; +} OH_AudioCaptureInfo; + +/** + * @brief Audio encoder info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AudioEncInfo { + /* Audio encoder bitrate */ + int32_t audioBitrate; + /* Audio codec format */ + OH_AudioCodecFormat audioCodecformat; +} OH_AudioEncInfo; + +/** + * @brief The audio info of avscreeencapture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AudioInfo { + /* Audio capture info of microphone */ + OH_AudioCaptureInfo micCapInfo; + /* Audio capture info of inner */ + OH_AudioCaptureInfo innerCapInfo; + /* Audio encoder info, no need to set, while dataType = OH_ORIGINAL_STREAM */ + OH_AudioEncInfo audioEncInfo; +} OH_AudioInfo; + +/** + * @brief Video capture info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_VideoCaptureInfo { + /* Display id, should be set while captureMode = CAPTURE_SPECIFIED_SCREEN */ + uint64_t displayId; + /* The ids of mission, should be set while captureMode = CAPTURE_SPECIFIED_WINDOW */ + int32_t *missionIDs; + /* Mission ids length, should be set while captureMode = CAPTURE_SPECIFIED_WINDOW */ + int32_t missionIDsLen; + /* Video frame width of avscreeencapture */ + int32_t videoFrameWidth; + /* Video frame height of avscreeencapture */ + int32_t videoFrameHeight; + /* Video source type of avscreeencapture */ + OH_VideoSourceType videoSource; +} OH_VideoCaptureInfo; + +/** + * @brief Videoc encoder info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_VideoEncInfo { + /* Video encoder format */ + OH_VideoCodecFormat videoCodec; + /* Video encoder bitrate */ + int32_t videoBitrate; + /* Video encoder frame rate */ + int32_t videoFrameRate; +} OH_VideoEncInfo; + +/** + * @brief Video info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_VideoInfo { + /* Video capture info */ + OH_VideoCaptureInfo videoCapInfo; + /* Video encoder info */ + OH_VideoEncInfo videoEncInfo; +} OH_VideoInfo; + +/** + * @brief Recorder file info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_RecorderInfo { + /* Recorder file url */ + char *url; + /* Recorder file url length */ + uint32_t urlLen; + /* Recorder file format */ + OH_ContainerFormatType fileFormat; +} OH_RecorderInfo; + +/** + * @brief AV screeen capture config info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AVScreenCaptureConfig { + OH_CaptureMode captureMode; + OH_DataType dataType; + OH_AudioInfo audioInfo; + OH_VideoInfo videoInfo; + /* should be set, while dataType = OH_CAPTURE_FILE */ + OH_RecorderInfo recorderInfo; +} OH_AVScreenCaptureConfig; + +/** + * @brief When an error occurs in the running of the OH_AVScreenCapture instance, the function pointer will be called + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param errorCode specific error code + * + * @since 10 + * @version 1.0 + */ +typedef void (*OH_AVScreenCaptureOnError)(OH_AVScreenCapture *capture, int32_t errorCode); + +/** + * @brief When audio buffer is available during the operation of OH_AVScreenCapture, the function pointer will + * be called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param isReady Information describing whether audio buffer is available + * @param type Information describing the audio source type + * + * @since 10 + * @version 1.0 + */ +typedef void (*OH_AVScreenCaptureOnAudioBufferAvailable)(OH_AVScreenCapture *capture, bool isReady, + OH_AudioCaptureSourceType type); + +/** + * @brief When video buffer is available during the operation of OH_AVScreenCapture, the function pointer will + * be called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param isReady Information describing whether video buffer is available + * + * @since 10 + * @version 1.0 + */ +typedef void (*OH_AVScreenCaptureOnVideoBufferAvailable)(OH_AVScreenCapture *capture, bool isReady); + +/** + * @brief A collection of all callback function pointers in OH_AVScreenCapture. Register an instance of this + * structure to the OH_AVScreenCapture instance, and process the information reported through the callback to ensure the + * normal operation of OH_AVScreenCapture. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param onError Monitor OH_AVScreenCapture operation errors, refer to {@link OH_AVScreenCaptureOnError} + * @param onAudioBufferAvailable Monitor audio buffer, refer to {@link OH_AVScreenCaptureOnAudioBufferAvailable} + * @param onVideoBufferAvailable Monitor video buffer, refer to {@link OH_AVScreenCaptureOnVideoBufferAvailable} + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AVScreenCaptureCallback { + OH_AVScreenCaptureOnError onError; + OH_AVScreenCaptureOnAudioBufferAvailable onAudioBufferAvailable; + OH_AVScreenCaptureOnVideoBufferAvailable onVideoBufferAvailable; +} OH_AVScreenCaptureCallback; + +/** + * @brief avscreeencapture rect info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_Rect { + /* X-coordinate of screen recording */ + int32_t x; + /* y-coordinate of screen recording */ + int32_t y; + /* Width of screen recording */ + int32_t width; + /* Height of screen recording */ + int32_t height; +} OH_Rect; + + +/** + * @brief Audiobuffer struct info + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 10 + * @version 1.0 + */ +typedef struct OH_AudioBuffer { + /* Audio buffer memory block */ + uint8_t *buf; + /* Audio buffer memory block size */ + int32_t size; + /* Audio buffer timestamp info */ + int64_t timestamp; + /* Audio capture source type */ + OH_AudioCaptureSourceType type; +} OH_AudioBuffer; + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVSCREEN_CAPTURE_BASE_H \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture_errors.h b/multimedia/player_framework/native_avscreen_capture_errors.h index d202659f0da89789496eb3de5b401fb860013d0b..14bd46204eca85a3a5b553505fcdca446e48f4e8 100644 --- a/multimedia/player_framework/native_avscreen_capture_errors.h +++ b/multimedia/player_framework/native_avscreen_capture_errors.h @@ -1,85 +1,85 @@ -/* - * 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. - */ - -#ifndef NATIVE_AVSCREEN_CAPTURE_ERRORS_H -#define NATIVE_AVSCREEN_CAPTURE_ERRORS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Screen capture error code - * @syscap SystemCapability.Multimedia.Media.AVScreenCapture - * @since 10 - * @version 1.0 - */ - -typedef enum OH_AVSCREEN_CAPTURE_ErrCode { - /** - * basic error mask for screen recording. - */ - AV_SCREEN_CAPTURE_ERR_BASE = 0, - /** - * the operation completed successfully. - */ - AV_SCREEN_CAPTURE_ERR_OK = AV_SCREEN_CAPTURE_ERR_BASE, - /** - * no memory. - */ - AV_SCREEN_CAPTURE_ERR_NO_MEMORY = AV_SCREEN_CAPTURE_ERR_BASE + 1, - /** - * opertation not be permitted. - */ - AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT = AV_SCREEN_CAPTURE_ERR_BASE + 2, - /** - * invalid argument. - */ - AV_SCREEN_CAPTURE_ERR_INVALID_VAL = AV_SCREEN_CAPTURE_ERR_BASE + 3, - /** - * IO error. - */ - AV_SCREEN_CAPTURE_ERR_IO = AV_SCREEN_CAPTURE_ERR_BASE + 4, - /** - * network timeout. - */ - AV_SCREEN_CAPTURE_ERR_TIMEOUT = AV_SCREEN_CAPTURE_ERR_BASE + 5, - /** - * unknown error. - */ - AV_SCREEN_CAPTURE_ERR_UNKNOWN = AV_SCREEN_CAPTURE_ERR_BASE + 6, - /** - * media service died. - */ - AV_SCREEN_CAPTURE_ERR_SERVICE_DIED = AV_SCREEN_CAPTURE_ERR_BASE + 7, - /** - * the state is not support this operation. - */ - AV_SCREEN_CAPTURE_ERR_INVALID_STATE = AV_SCREEN_CAPTURE_ERR_BASE + 8, - /** - * unsupport interface. - */ - AV_SCREEN_CAPTURE_ERR_UNSUPPORT = AV_SCREEN_CAPTURE_ERR_BASE + 9, - /** - * extend err start. - */ - AV_SCREEN_CAPTURE_ERR_EXTEND_START = AV_SCREEN_CAPTURE_ERR_BASE + 100, -} OH_AVSCREEN_CAPTURE_ErrCode; - -#ifdef __cplusplus -} -#endif - +/* + * 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. + */ + +#ifndef NATIVE_AVSCREEN_CAPTURE_ERRORS_H +#define NATIVE_AVSCREEN_CAPTURE_ERRORS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Screen capture error code + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @since 10 + * @version 1.0 + */ + +typedef enum OH_AVSCREEN_CAPTURE_ErrCode { + /** + * basic error mask for screen recording. + */ + AV_SCREEN_CAPTURE_ERR_BASE = 0, + /** + * the operation completed successfully. + */ + AV_SCREEN_CAPTURE_ERR_OK = AV_SCREEN_CAPTURE_ERR_BASE, + /** + * no memory. + */ + AV_SCREEN_CAPTURE_ERR_NO_MEMORY = AV_SCREEN_CAPTURE_ERR_BASE + 1, + /** + * opertation not be permitted. + */ + AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT = AV_SCREEN_CAPTURE_ERR_BASE + 2, + /** + * invalid argument. + */ + AV_SCREEN_CAPTURE_ERR_INVALID_VAL = AV_SCREEN_CAPTURE_ERR_BASE + 3, + /** + * IO error. + */ + AV_SCREEN_CAPTURE_ERR_IO = AV_SCREEN_CAPTURE_ERR_BASE + 4, + /** + * network timeout. + */ + AV_SCREEN_CAPTURE_ERR_TIMEOUT = AV_SCREEN_CAPTURE_ERR_BASE + 5, + /** + * unknown error. + */ + AV_SCREEN_CAPTURE_ERR_UNKNOWN = AV_SCREEN_CAPTURE_ERR_BASE + 6, + /** + * media service died. + */ + AV_SCREEN_CAPTURE_ERR_SERVICE_DIED = AV_SCREEN_CAPTURE_ERR_BASE + 7, + /** + * the state is not support this operation. + */ + AV_SCREEN_CAPTURE_ERR_INVALID_STATE = AV_SCREEN_CAPTURE_ERR_BASE + 8, + /** + * unsupport interface. + */ + AV_SCREEN_CAPTURE_ERR_UNSUPPORT = AV_SCREEN_CAPTURE_ERR_BASE + 9, + /** + * extend err start. + */ + AV_SCREEN_CAPTURE_ERR_EXTEND_START = AV_SCREEN_CAPTURE_ERR_BASE + 100, +} OH_AVSCREEN_CAPTURE_ErrCode; + +#ifdef __cplusplus +} +#endif + #endif // NATIVE_AVSCREEN_CAPTURE_ERRORS_H \ No newline at end of file diff --git a/patches/patches.json b/patches/patches.json index 10f32254842b4a1f997736a6e5fbee890b8bd625..d673c4563b429e3263e813d57e327fe5978966b4 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -1,9 +1,9 @@ -{ - "patches": [ - { - "project":"build", - "path":"build", - "pr_url":"https://gitee.com/openharmony/build/pulls/2215" - } - ] +{ + "patches": [ + { + "project":"build", + "path":"build", + "pr_url":"https://gitee.com/openharmony/build/pulls/2215" + } + ] } \ No newline at end of file diff --git a/resourceschedule/ffrt/ffrt.h b/resourceschedule/ffrt/ffrt.h deleted file mode 100644 index de48d6f52afb583387c2076187349ecadc0f4fba..0000000000000000000000000000000000000000 --- a/resourceschedule/ffrt/ffrt.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ -#ifndef FFRT_API_FFRT_H -#define FFRT_API_FFRT_H -#ifdef __cplusplus -#include "cpp/task.h" -#include "cpp/mutex.h" -#include "cpp/condition_variable.h" -#include "cpp/sleep.h" -#include "cpp/queue.h" -#else -#include "c/task.h" -#include "c/mutex.h" -#include "c/condition_variable.h" -#include "c/sleep.h" -#include "c/queue.h" -#endif -#endif diff --git a/security/huks/BUILD.gn b/security/huks/BUILD.gn index 9c8b729850b37665f960c1e4138b4815aaa2f2eb..3f1740fe8d76cf62a7ae6be87471cc2047732ff2 100644 --- a/security/huks/BUILD.gn +++ b/security/huks/BUILD.gn @@ -1,32 +1,32 @@ -# Copyright (c) 2021 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") - -ohos_ndk_library("libhuks_ndk") { - output_name = "huks_ndk" - output_extension = "z.so" - ndk_description_file = "./libhuks.ndk.json" - min_compact_version = "1" - - # system_capability = "SystemCapability.Security.Huks" -} - -ohos_ndk_headers("huks_header") { - dest_dir = "$ndk_headers_out_dir/huks" - sources = [ - "./include/native_huks_api.h", - "./include/native_huks_param.h", - "./include/native_huks_type.h", - ] -} +# Copyright (c) 2021 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") + +ohos_ndk_library("libhuks_ndk") { + output_name = "huks_ndk" + output_extension = "z.so" + ndk_description_file = "./libhuks.ndk.json" + min_compact_version = "1" + + # system_capability = "SystemCapability.Security.Huks" +} + +ohos_ndk_headers("huks_header") { + dest_dir = "$ndk_headers_out_dir/huks" + sources = [ + "./include/native_huks_api.h", + "./include/native_huks_param.h", + "./include/native_huks_type.h", + ] +} diff --git a/security/huks/include/native_huks_api.h b/security/huks/include/native_huks_api.h index f052661e21981d10971e1a98d4f05457a67f1d3f..485ba147314245ff8a66805951db43ac595e6200 100644 --- a/security/huks/include/native_huks_api.h +++ b/security/huks/include/native_huks_api.h @@ -1,263 +1,263 @@ -/* - * Copyright (c) 2022 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 NATIVE_HUKS_API_H -#define NATIVE_HUKS_API_H - -/** - * @addtogroup HuksKeyApi - * @{ - * - * @brief Describes the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and - * cryptography operations, provided for applications. - * The keys managed by HUKS can be imported by applications or generated by calling the HUKS APIs. - * - * @syscap SystemCapability.Security.Huks - * @since 9 - * @version 1.0 - */ - -/** - * @file native_huks_api.h - * - * @brief Declares the APIs used to access the HUKS. - * - * @since 9 - * @version 1.0 - */ - -#include "native_huks_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Obtains the current HUKS SDK version. - * - * @param sdkVersion Indicates the pointer to the SDK version (in string format) obtained. - * return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_GetSdkVersion(struct OH_Huks_Blob *sdkVersion); - -/** - * @brief Generates a key. - * - * @param keyAlias Indicates the pointer to the alias of the key to generate. - * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. - * @param paramSetIn Indicates the pointer to the parameter set for generating the key. - * @param paramSetOut Indicates the pointer to a temporary key generated. If the generated key is - * not of a temporary type, this parameter is a null pointer. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_GenerateKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut); - -/** - * @brief Imports a key in plaintext. - * - * @param keyAlias Indicates the pointer to the alias of the key to import. - * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. - * @param paramSet Indicates the pointer to the parameters of the key to import. - * @param key Indicates the pointer to the key to import. The key must be in the format required by the HUKS. - * For details, see {@link HuksTypeApi}. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_ImportKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *key); - -/** - * @brief Imports a wrapped key. - * - * @param keyAlias Indicates the pointer to the alias of the key to import. - * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. - * @param wrappingKeyAlias Indicates the pointer to the alias of the wrapping key, - * which is obtained through key agreement and used to decrypt the key to import. - * @param paramSet Indicates the pointer to the parameters of the wrapped key to import. - * @param wrappedKeyData Indicates the pointer to the wrapped key to import. - * The key must be in the format required by the HUKS. For details, see {@link OH_Huks_AlgSuite}. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_Blob *wrappingKeyAlias, const struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Blob *wrappedKeyData); - -/** - * @brief Exports a public key. - * - * @param keyAlias Indicates the pointer to the alias of the public key to export. - * The alias must be the same as the alias for the key generated. - * @param paramSet Indicates the pointer to the parameters required for exporting the public key. - * @param key Indicates the pointer to the public key exported. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_ExportPublicKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *key); - -/** - * @brief Deletes a key. - * - * @param keyAlias Indicates the pointer to the alias of the key to delete. - * The alias must be the same as the alias for the key generated. - * @param paramSet Indicates the pointer to the parameters required for deleting the key. - * By default, this parameter is a null pointer. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_DeleteKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet); - -/** - * @brief Obtains the attributes of a key. - * - * @param keyAlias Indicates the pointer to the alias of the target key. - * @param paramSetIn Indicates the pointer to the attribute tag required for - * obtaining the attributes. By default, this parameter is a null pointer. - * @param paramSetOut Indicates the pointer to the attributes obtained. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_GetKeyItemParamSet(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut); - -/** - * @brief Checks whether a key exists. - * - * @param keyAlias Indicates the pointer to the alias of the target key. - * @param paramSet Indicates the pointer to the attribute tag required for checking the key. - * By default, this parameter is a null pointer. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the key exists. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_ERR_CODE_ITEM_NOT_EXIST} if the key does not exist. - * @return Returns any other error code for other cases. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_IsKeyItemExist(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet); - -/** - * @brief Obtain the key certificate chain. - * - * @param keyAlias Indicates the pointer to the alias of the target key. - * @param paramSet Indicates the pointer to the parameters required for obtaining the key certificate. - * @param certChain Indicates the pointer to the key certificate chain obtained. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_AttestKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_CertChain *certChain); - -/** - * @brief Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). - * - * @param keyAlias Indicates the pointer to the alias of the target key. - * @param paramSet Indicates the pointer to the parameters for the initialization operation. - * @param handle Indicates the pointer to the handle of the key session obtained. - * This handle is required for subsequent operations, including {@link OH_Huks_UpdateSession}, - * {@link OH_Huks_FinishSession}, and {@link OH_Huks_AbortSession}. - * @param challenge Indicates the pointer to the challenge value obtained. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - * @see OH_Huks_UpdateSession - * @see OH_Huks_FinishSession - * @see OH_Huks_AbortSession - */ -struct OH_Huks_Result OH_Huks_InitSession(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *handle, struct OH_Huks_Blob *token); - -/** - * @brief Adds data by segment for the key operation, performs the related key operation, - * and outputs the processed data. - * - * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. - * @param paramSet Indicates the pointer to the parameters required for the key operation. - * @param inData Indicates the pointer to the data to be processed. - * This API can be called multiples time to process large data by segment. - * @param outData Indicates the pointer to the output data. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - * @see OH_Huks_InitSession - * @see OH_Huks_FinishSession - * @see OH_Huks_AbortSession - */ -struct OH_Huks_Result OH_Huks_UpdateSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData); - -/** - * @brief Ends the key session. - * - * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. - * @param paramSet Indicates the pointer to the parameters required for the key operation. - * @param inData Indicates the pointer to the data to be processed. - * @param outData Indicates the pointer to the output data. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - * @see OH_Huks_InitSession - * @see OH_Huks_UpdateSession - * @see OH_Huks_AbortSession - */ -struct OH_Huks_Result OH_Huks_FinishSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData); - -/** - * @brief Aborts a key session. - * - * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. - * @param paramSet Indicates the pointer to the parameters required for aborting the key session. - * By default, this parameter is a null pointer. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - * @see OH_Huks_InitSession - * @see OH_Huks_UpdateSession - * @see OH_Huks_FinishSession - */ -struct OH_Huks_Result OH_Huks_AbortSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* NATIVE_HUKS_API_H */ +/* + * Copyright (c) 2022 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 NATIVE_HUKS_API_H +#define NATIVE_HUKS_API_H + +/** + * @addtogroup HuksKeyApi + * @{ + * + * @brief Describes the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and + * cryptography operations, provided for applications. + * The keys managed by HUKS can be imported by applications or generated by calling the HUKS APIs. + * + * @syscap SystemCapability.Security.Huks + * @since 9 + * @version 1.0 + */ + +/** + * @file native_huks_api.h + * + * @brief Declares the APIs used to access the HUKS. + * + * @since 9 + * @version 1.0 + */ + +#include "native_huks_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtains the current HUKS SDK version. + * + * @param sdkVersion Indicates the pointer to the SDK version (in string format) obtained. + * return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_GetSdkVersion(struct OH_Huks_Blob *sdkVersion); + +/** + * @brief Generates a key. + * + * @param keyAlias Indicates the pointer to the alias of the key to generate. + * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. + * @param paramSetIn Indicates the pointer to the parameter set for generating the key. + * @param paramSetOut Indicates the pointer to a temporary key generated. If the generated key is + * not of a temporary type, this parameter is a null pointer. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_GenerateKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut); + +/** + * @brief Imports a key in plaintext. + * + * @param keyAlias Indicates the pointer to the alias of the key to import. + * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. + * @param paramSet Indicates the pointer to the parameters of the key to import. + * @param key Indicates the pointer to the key to import. The key must be in the format required by the HUKS. + * For details, see {@link HuksTypeApi}. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_ImportKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *key); + +/** + * @brief Imports a wrapped key. + * + * @param keyAlias Indicates the pointer to the alias of the key to import. + * The alias must be unique in the process of the service. Otherwise, the key will be overwritten. + * @param wrappingKeyAlias Indicates the pointer to the alias of the wrapping key, + * which is obtained through key agreement and used to decrypt the key to import. + * @param paramSet Indicates the pointer to the parameters of the wrapped key to import. + * @param wrappedKeyData Indicates the pointer to the wrapped key to import. + * The key must be in the format required by the HUKS. For details, see {@link OH_Huks_AlgSuite}. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_Blob *wrappingKeyAlias, const struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Blob *wrappedKeyData); + +/** + * @brief Exports a public key. + * + * @param keyAlias Indicates the pointer to the alias of the public key to export. + * The alias must be the same as the alias for the key generated. + * @param paramSet Indicates the pointer to the parameters required for exporting the public key. + * @param key Indicates the pointer to the public key exported. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_ExportPublicKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *key); + +/** + * @brief Deletes a key. + * + * @param keyAlias Indicates the pointer to the alias of the key to delete. + * The alias must be the same as the alias for the key generated. + * @param paramSet Indicates the pointer to the parameters required for deleting the key. + * By default, this parameter is a null pointer. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_DeleteKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet); + +/** + * @brief Obtains the attributes of a key. + * + * @param keyAlias Indicates the pointer to the alias of the target key. + * @param paramSetIn Indicates the pointer to the attribute tag required for + * obtaining the attributes. By default, this parameter is a null pointer. + * @param paramSetOut Indicates the pointer to the attributes obtained. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_GetKeyItemParamSet(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut); + +/** + * @brief Checks whether a key exists. + * + * @param keyAlias Indicates the pointer to the alias of the target key. + * @param paramSet Indicates the pointer to the attribute tag required for checking the key. + * By default, this parameter is a null pointer. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the key exists. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_ERR_CODE_ITEM_NOT_EXIST} if the key does not exist. + * @return Returns any other error code for other cases. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_IsKeyItemExist(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet); + +/** + * @brief Obtain the key certificate chain. + * + * @param keyAlias Indicates the pointer to the alias of the target key. + * @param paramSet Indicates the pointer to the parameters required for obtaining the key certificate. + * @param certChain Indicates the pointer to the key certificate chain obtained. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_AttestKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_CertChain *certChain); + +/** + * @brief Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). + * + * @param keyAlias Indicates the pointer to the alias of the target key. + * @param paramSet Indicates the pointer to the parameters for the initialization operation. + * @param handle Indicates the pointer to the handle of the key session obtained. + * This handle is required for subsequent operations, including {@link OH_Huks_UpdateSession}, + * {@link OH_Huks_FinishSession}, and {@link OH_Huks_AbortSession}. + * @param challenge Indicates the pointer to the challenge value obtained. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + * @see OH_Huks_UpdateSession + * @see OH_Huks_FinishSession + * @see OH_Huks_AbortSession + */ +struct OH_Huks_Result OH_Huks_InitSession(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *handle, struct OH_Huks_Blob *token); + +/** + * @brief Adds data by segment for the key operation, performs the related key operation, + * and outputs the processed data. + * + * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. + * @param paramSet Indicates the pointer to the parameters required for the key operation. + * @param inData Indicates the pointer to the data to be processed. + * This API can be called multiples time to process large data by segment. + * @param outData Indicates the pointer to the output data. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + * @see OH_Huks_InitSession + * @see OH_Huks_FinishSession + * @see OH_Huks_AbortSession + */ +struct OH_Huks_Result OH_Huks_UpdateSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData); + +/** + * @brief Ends the key session. + * + * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. + * @param paramSet Indicates the pointer to the parameters required for the key operation. + * @param inData Indicates the pointer to the data to be processed. + * @param outData Indicates the pointer to the output data. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + * @see OH_Huks_InitSession + * @see OH_Huks_UpdateSession + * @see OH_Huks_AbortSession + */ +struct OH_Huks_Result OH_Huks_FinishSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData); + +/** + * @brief Aborts a key session. + * + * @param handle Indicates the pointer to the key session handle, which is generated by {@link OH_Huks_InitSession}. + * @param paramSet Indicates the pointer to the parameters required for aborting the key session. + * By default, this parameter is a null pointer. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + * @see OH_Huks_InitSession + * @see OH_Huks_UpdateSession + * @see OH_Huks_FinishSession + */ +struct OH_Huks_Result OH_Huks_AbortSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NATIVE_HUKS_API_H */ diff --git a/security/huks/include/native_huks_api_adapter.h b/security/huks/include/native_huks_api_adapter.h index 25f187cc3adaee59bdeea96def9d042fd1578fe8..4282a3823cabba4c3a4e61a897b49599eefcceea 100644 --- a/security/huks/include/native_huks_api_adapter.h +++ b/security/huks/include/native_huks_api_adapter.h @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2022 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 NATIVE_HUKS_API_ADAPTER_H -#define NATIVE_HUKS_API_ADAPTER_H - -#include "native_huks_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t HuksAttestAdapter(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *paramSet, - struct OH_Huks_CertChain *certChain); - -#ifdef __cplusplus -} -#endif - -#endif /* NATIVE_HUKS_API_ADAPTER_H */ +/* + * Copyright (c) 2022 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 NATIVE_HUKS_API_ADAPTER_H +#define NATIVE_HUKS_API_ADAPTER_H + +#include "native_huks_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t HuksAttestAdapter(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *paramSet, + struct OH_Huks_CertChain *certChain); + +#ifdef __cplusplus +} +#endif + +#endif /* NATIVE_HUKS_API_ADAPTER_H */ diff --git a/security/huks/include/native_huks_param.h b/security/huks/include/native_huks_param.h index c375fe1f9a67f82462e984b326bef9acad3cc7af..536b5ef3162a014bfe2b14e3e3687df99ae124ba 100644 --- a/security/huks/include/native_huks_param.h +++ b/security/huks/include/native_huks_param.h @@ -1,176 +1,176 @@ -/* - * Copyright (c) 2022 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 NATIVE_HUKS_PARAM_H -#define NATIVE_HUKS_PARAM_H - -/** - * @addtogroup HuksParamSetApi - * @{ - * - * @brief Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. - * The HUKS APIs can be used to perform parameter set lifecycle management, - * including initializing a parameter set, adding parameters to a parameter set, constructing - * a parameter set, and destroying a parameter set. - * They can also be used to obtain parameters, copy parameter sets, and check parameter validity. - * - * @syscap SystemCapability.Security.Huks - * @since 9 - * @version 1.0 - */ - -/** - * @file native_huks_param.h - * - * @brief Provides APIs for constructing, using, and destroying parameter sets. - * - * @since 9 - * @version 1.0 - */ - -#include "native_huks_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Initializes a parameter set. - * - * @param paramSet Indicates the double pointer to the parameter set to initialize. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the initialization is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet); - -/** - * @brief Adds parameters to a parameter set. - * - * @param paramSet Indicates the pointer to the parameter set to which parameters are to be added. - * @param params Indicates the pointer to the array of parameters to add. - * @param paramCnt Indicates the number of parameters to add. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Param *params, uint32_t paramCnt); - -/** - * @brief Constructs a parameter set. - * - * @param paramSet Indicates the double pointer to the parameter set to construct. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet); - -/** - * @brief Destroys a parameter set. - * - * @param paramSet Indicates the double pointer to the parameter set to destroy. - * @since 9 - * @version 1.0 - */ -void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet); - -/** - * @brief Copies a parameter set (deep copy). - * - * @param fromParamSet Indicates the pointer to the parameter set to copy. - * @param fromParamSetSize Indicates the memory size occupied by the source parameter set. - * @param paramSet Indicates the double pointer to the new parameter set generated. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet, - uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet); - -/** - * @brief Obtains parameters from a parameter set. - * - * @param paramSet Indicates the pointer to the target parameter set. - * @param tag Indicates the value of the parameter to be obtained. - * @param param Indicates the double pointer to the parameter obtained. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful, - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag, - struct OH_Huks_Param **param); - -/** - * @brief Refreshes data of the Blob type in a parameter set. - * - * @param paramSet Indicates the pointer to the target parameter set. - * @param isCopy Specifies whether to copy the data of the Blob type to the parameter set. - * If yes, the data of the Blob type will be copied to the parameter set. - * Otherwise, only the address of the Blob data will be refreshed. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if operation is successful; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy); - -/** - * @brief Checks whether the parameters in a parameter set are valid. - * - * @param paramSet Indicates the pointer to the parameter set to check. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the parameters in the parameter set are valid; - * returns other values if the parameter set has invalid, duplicate, or incorrect parameters. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet); - -/** - * @brief Checks whether a parameter set is of the valid size. - * - * @param paramSet Indicates the pointer to the parameter set to check. - * @param size Indicates the memory size occupied by the parameter set. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the parameter set is of the valid size; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size); - -/** - * @brief Checks whether two parameters are the same. - * - * @param baseParam Indicates the pointer to the first parameter. - * @param param Indicates the pointer to the second parameter. - * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the two parameters are the same; - * returns an error code otherwise. - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* NATIVE_HUKS_PARAM_H */ +/* + * Copyright (c) 2022 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 NATIVE_HUKS_PARAM_H +#define NATIVE_HUKS_PARAM_H + +/** + * @addtogroup HuksParamSetApi + * @{ + * + * @brief Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. + * The HUKS APIs can be used to perform parameter set lifecycle management, + * including initializing a parameter set, adding parameters to a parameter set, constructing + * a parameter set, and destroying a parameter set. + * They can also be used to obtain parameters, copy parameter sets, and check parameter validity. + * + * @syscap SystemCapability.Security.Huks + * @since 9 + * @version 1.0 + */ + +/** + * @file native_huks_param.h + * + * @brief Provides APIs for constructing, using, and destroying parameter sets. + * + * @since 9 + * @version 1.0 + */ + +#include "native_huks_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initializes a parameter set. + * + * @param paramSet Indicates the double pointer to the parameter set to initialize. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the initialization is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet); + +/** + * @brief Adds parameters to a parameter set. + * + * @param paramSet Indicates the pointer to the parameter set to which parameters are to be added. + * @param params Indicates the pointer to the array of parameters to add. + * @param paramCnt Indicates the number of parameters to add. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Param *params, uint32_t paramCnt); + +/** + * @brief Constructs a parameter set. + * + * @param paramSet Indicates the double pointer to the parameter set to construct. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet); + +/** + * @brief Destroys a parameter set. + * + * @param paramSet Indicates the double pointer to the parameter set to destroy. + * @since 9 + * @version 1.0 + */ +void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet); + +/** + * @brief Copies a parameter set (deep copy). + * + * @param fromParamSet Indicates the pointer to the parameter set to copy. + * @param fromParamSetSize Indicates the memory size occupied by the source parameter set. + * @param paramSet Indicates the double pointer to the new parameter set generated. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet, + uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet); + +/** + * @brief Obtains parameters from a parameter set. + * + * @param paramSet Indicates the pointer to the target parameter set. + * @param tag Indicates the value of the parameter to be obtained. + * @param param Indicates the double pointer to the parameter obtained. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the operation is successful, + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag, + struct OH_Huks_Param **param); + +/** + * @brief Refreshes data of the Blob type in a parameter set. + * + * @param paramSet Indicates the pointer to the target parameter set. + * @param isCopy Specifies whether to copy the data of the Blob type to the parameter set. + * If yes, the data of the Blob type will be copied to the parameter set. + * Otherwise, only the address of the Blob data will be refreshed. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if operation is successful; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy); + +/** + * @brief Checks whether the parameters in a parameter set are valid. + * + * @param paramSet Indicates the pointer to the parameter set to check. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the parameters in the parameter set are valid; + * returns other values if the parameter set has invalid, duplicate, or incorrect parameters. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet); + +/** + * @brief Checks whether a parameter set is of the valid size. + * + * @param paramSet Indicates the pointer to the parameter set to check. + * @param size Indicates the memory size occupied by the parameter set. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the parameter set is of the valid size; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size); + +/** + * @brief Checks whether two parameters are the same. + * + * @param baseParam Indicates the pointer to the first parameter. + * @param param Indicates the pointer to the second parameter. + * @return Returns {@link OH_Huks_ErrCode#OH_HUKS_SUCCESS} if the two parameters are the same; + * returns an error code otherwise. + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NATIVE_HUKS_PARAM_H */ diff --git a/security/huks/include/native_huks_type.h b/security/huks/include/native_huks_type.h index 9b51f56c9dae5511159e49dabf1c5901854fc51d..61cfaaa066fa9c6692b5b8b2866335332a4aa885 100644 --- a/security/huks/include/native_huks_type.h +++ b/security/huks/include/native_huks_type.h @@ -1,861 +1,861 @@ -/* - * Copyright (c) 2022-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. - */ - -#ifndef NATIVE_OH_HUKS_TYPE_H -#define NATIVE_OH_HUKS_TYPE_H - -/** - * @addtogroup HuksTypeApi - * @{ - * - * @brief Defines the macros, enumerated values, data structures, - * and error codes used by OpenHarmony Universal KeyStore (HUKS) APIs. - * - * @syscap SystemCapability.Security.Huks - * @since 9 - * @version 1.0 - */ - -/** - * @file native_huks_type.h - * - * @brief Defines the enumerated variables, structures, and macros used in the HUKS APIs. - * - * @since 9 - * @version 1.0 - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define OH_HUKS_AE_TAG_LEN 16 -#define OH_HUKS_BITS_PER_BYTE 8 -#define OH_HUKS_MAX_KEY_SIZE 2048 -#define OH_HUKS_AE_NONCE_LEN 12 -#define OH_HUKS_MAX_KEY_ALIAS_LEN 64 -#define OH_HUKS_MAX_PROCESS_NAME_LEN 50 -#define OH_HUKS_MAX_RANDOM_LEN 1024 -#define OH_HUKS_SIGNATURE_MIN_SIZE 64 -#define OH_HUKS_MAX_OUT_BLOB_SIZE (5 * 1024 * 1024) -#define OH_HUKS_WRAPPED_FORMAT_MAX_SIZE (1024 * 1024) -#define OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS 10 -#define TOKEN_CHALLENGE_LEN 32 -#define SHA256_SIGN_LEN 32 -#define TOKEN_SIZE 32 -#define MAX_AUTH_TIMEOUT_SECOND 60 -#define SECURE_SIGN_VERSION 0x01000001 - -/** - * @brief Enumerates the key purposes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyPurpose { - /** Used to encrypt the plaintext. */ - OH_HUKS_KEY_PURPOSE_ENCRYPT = 1, - /** Used to decrypt the cipher text. */ - OH_HUKS_KEY_PURPOSE_DECRYPT = 2, - /** Used to sign data. */ - OH_HUKS_KEY_PURPOSE_SIGN = 4, - /** Used to verify the signature. */ - OH_HUKS_KEY_PURPOSE_VERIFY = 8, - /** Used to derive a key. */ - OH_HUKS_KEY_PURPOSE_DERIVE = 16, - /** Used for an encrypted export. */ - OH_HUKS_KEY_PURPOSE_WRAP = 32, - /** Used for an encrypted import. */ - OH_HUKS_KEY_PURPOSE_UNWRAP = 64, - /** Used to generate a message authentication code (MAC). */ - OH_HUKS_KEY_PURPOSE_MAC = 128, - /** Used for key agreement. */ - OH_HUKS_KEY_PURPOSE_AGREE = 256, -}; - -/** - * @brief Enumerates the digest algorithms. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyDigest { - /** No digest algorithm. */ - OH_HUKS_DIGEST_NONE = 0, - /** MD5. */ - OH_HUKS_DIGEST_MD5 = 1, - /** SM3. */ - OH_HUKS_DIGEST_SM3 = 2, - /** SHA-1. */ - OH_HUKS_DIGEST_SHA1 = 10, - /** SHA-224. */ - OH_HUKS_DIGEST_SHA224 = 11, - /** SHA-256. */ - OH_HUKS_DIGEST_SHA256 = 12, - /** SHA-384. */ - OH_HUKS_DIGEST_SHA384 = 13, - /** SHA-512. */ - OH_HUKS_DIGEST_SHA512 = 14, -}; - -/** - * @brief Enumerates the padding algorithms. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyPadding { - /** No padding algorithm. */ - OH_HUKS_PADDING_NONE = 0, - /** Optimal Asymmetric Encryption Padding (OAEP). */ - OH_HUKS_PADDING_OAEP = 1, - /** Probabilistic Signature Scheme (PSS). */ - OH_HUKS_PADDING_PSS = 2, - /** Public Key Cryptography Standards (PKCS) #1 v1.5. */ - OH_HUKS_PADDING_PKCS1_V1_5 = 3, - /** PKCS #5. */ - OH_HUKS_PADDING_PKCS5 = 4, - /** PKCS #7. */ - OH_HUKS_PADDING_PKCS7 = 5, -}; - -/** - * @brief Enumerates the cipher modes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_CipherMode { - /** Electronic Code Block (ECB) mode. */ - OH_HUKS_MODE_ECB = 1, - /** Cipher Block Chaining (CBC) mode. */ - OH_HUKS_MODE_CBC = 2, - /** Counter (CTR) mode. */ - OH_HUKS_MODE_CTR = 3, - /** Output Feedback (OFB) mode. */ - OH_HUKS_MODE_OFB = 4, - /** Counter with CBC-MAC (CCM) mode. */ - OH_HUKS_MODE_CCM = 31, - /** Galois/Counter (GCM) mode. */ - OH_HUKS_MODE_GCM = 32, -}; - -/** - * @brief Enumerates the key sizes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeySize { - /** Rivest-Shamir-Adleman (RSA) key of 512 bits. */ - OH_HUKS_RSA_KEY_SIZE_512 = 512, - /** RSA key of 768 bits. */ - OH_HUKS_RSA_KEY_SIZE_768 = 768, - /** RSA key of 1024 bits. */ - OH_HUKS_RSA_KEY_SIZE_1024 = 1024, - /** RSA key of 2048 bits. */ - OH_HUKS_RSA_KEY_SIZE_2048 = 2048, - /** RSA key of 3072 bits. */ - OH_HUKS_RSA_KEY_SIZE_3072 = 3072, - /** RSA key of 4096 bits. */ - OH_HUKS_RSA_KEY_SIZE_4096 = 4096, - - /** Elliptic Curve Cryptography (ECC) key of 224 bits. */ - OH_HUKS_ECC_KEY_SIZE_224 = 224, - /** ECC key of 256 bits. */ - OH_HUKS_ECC_KEY_SIZE_256 = 256, - /** ECC key of 384 bits. */ - OH_HUKS_ECC_KEY_SIZE_384 = 384, - /** ECC key of 521 bits. */ - OH_HUKS_ECC_KEY_SIZE_521 = 521, - - /** Advanced Encryption Standard (AES) key of 128 bits. */ - OH_HUKS_AES_KEY_SIZE_128 = 128, - /** AES key of 192 bits. */ - OH_HUKS_AES_KEY_SIZE_192 = 192, - /** AES key of 256 bits. */ - OH_HUKS_AES_KEY_SIZE_256 = 256, - /** AES key of 512 bits. */ - OH_HUKS_AES_KEY_SIZE_512 = 512, - - /** Curve25519 key of 256 bits. */ - OH_HUKS_CURVE25519_KEY_SIZE_256 = 256, - - /** Diffie-Hellman (DH) key of 2048 bits. */ - OH_HUKS_DH_KEY_SIZE_2048 = 2048, - /** DH key of 3072 bits. */ - OH_HUKS_DH_KEY_SIZE_3072 = 3072, - /** DH key of 4096 bits. */ - OH_HUKS_DH_KEY_SIZE_4096 = 4096, - - /** ShangMi2 (SM2) key of 256 bits. */ - OH_HUKS_SM2_KEY_SIZE_256 = 256, - /** ShangMi4 (SM4) key of 128 bits. */ - OH_HUKS_SM4_KEY_SIZE_128 = 128, -}; - -/** - * @brief Enumerates the key algorithms. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyAlg { - /** RSA. */ - OH_HUKS_ALG_RSA = 1, - /** ECC. */ - OH_HUKS_ALG_ECC = 2, - /** DSA. */ - OH_HUKS_ALG_DSA = 3, - - /** AES. */ - OH_HUKS_ALG_AES = 20, - /** HMAC. */ - OH_HUKS_ALG_HMAC = 50, - /** HKDF. */ - OH_HUKS_ALG_HKDF = 51, - /** PBKDF2. */ - OH_HUKS_ALG_PBKDF2 = 52, - - /** ECDH. */ - OH_HUKS_ALG_ECDH = 100, - /** X25519. */ - OH_HUKS_ALG_X25519 = 101, - /** Ed25519. */ - OH_HUKS_ALG_ED25519 = 102, - /** DH. */ - OH_HUKS_ALG_DH = 103, - - /** SM2. */ - OH_HUKS_ALG_SM2 = 150, - /** SM3. */ - OH_HUKS_ALG_SM3 = 151, - /** SM4. */ - OH_HUKS_ALG_SM4 = 152, -}; - -/** - * @brief Enumerates the algorithm suites required for ciphertext imports. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_AlgSuite { - /** Key material format (Length-Value format), X25519 key agreement, and AES-256-GCM encryption and decryption. - * | x25519_plain_pubkey_length (4 Byte) | x25519_plain_pubkey | agreekey_aad_length (4 Byte) | agreekey_aad - * | agreekey_nonce_length (4 Byte) | agreekey_nonce | - * | agreekey_aead_tag_len (4 Byte) | agreekey_aead_tag | - * | kek_enc_data_length (4 Byte) | kek_enc_data | kek_aad_length (4 Byte) | kek_aad - * | kek_nonce_length (4 Byte) | kek_nonce | kek_aead_tag_len (4 Byte) | kek_aead_tag - * | key_material_size_len (4 Byte) | key_material_size | key_mat_enc_length (4 Byte) | key_mat_enc_data - */ - OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, - - /** Key material format (Length-Value format), ECDH-p256 key agreement, and AES-256-GCM encryption and decryption. - * | ECC_plain_pubkey_length (4 Byte) | ECC_plain_pubkey | agreekey_aad_length (4 Byte) | agreekey_aad - * | agreekey_nonce_length (4 Byte) | agreekey_nonce | - * | agreekey_aead_tag_len (4 Byte) | agreekey_aead_tag | - * | kek_enc_data_length (4 Byte) | kek_enc_data | kek_aad_length (4 Byte) | kek_aad - * | kek_nonce_length (4 Byte) | kek_nonce | kek_aead_tag_len (4 Byte) | kek_aead_tag - * | key_material_size_len (4 Byte) | key_material_size | key_mat_enc_length (4 Byte) | key_mat_enc_data - */ - OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2, -}; - -/** - * @brief Enumerates the key generation types. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyGenerateType { - /** Key generated by default. */ - OH_HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, - /** Derived key. */ - OH_HUKS_KEY_GENERATE_TYPE_DERIVE = 1, - /** Key obtained by key agreement. */ - OH_HUKS_KEY_GENERATE_TYPE_AGREE = 2, -}; - -/** - * @brief Enumerates the key generation modes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyFlag { - /** Import a public key using an API. */ - OH_HUKS_KEY_FLAG_IMPORT_KEY = 1, - /** Generate a key by using an API. */ - OH_HUKS_KEY_FLAG_GENERATE_KEY = 2, - /** Generate a key by using a key agreement API. */ - OH_HUKS_KEY_FLAG_AGREE_KEY = 3, - /** Derive a key by using an API. */ - OH_HUKS_KEY_FLAG_DERIVE_KEY = 4, -}; - -/** - * @brief Enumerates the key storage modes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_KeyStorageType { - /** The key is managed locally. */ - OH_HUKS_STORAGE_TEMP = 0, - /** The key is managed by the HUKS service. */ - OH_HUKS_STORAGE_PERSISTENT = 1, - /** The key is only used in huks. */ - OH_HUKS_STORAGE_ONLY_USED_IN_HUKS = 2, - /** The key can be allowed to export. */ - OH_HUKS_STORAGE_KEY_EXPORT_ALLOWED = 3, -}; - -/** - * @brief Enumerates the types of keys to import. By default, - * a public key is imported. This field is not required when a symmetric key is imported. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_ImportKeyType { - /** Public key. */ - OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, - /** Private key. */ - OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, - /** Public and private key pair. */ - OH_HUKS_KEY_TYPE_KEY_PAIR = 2, -}; - -/** - * @brief Enumerates the key storage modes. - * - * @since 10 - * @version 1.0 - */ -enum OH_Huks_RsaPssSaltLenType { - /** Salt length matches digest. */ - OH_HUKS_RSA_PSS_SALT_LEN_DIGEST = 0, - /** Set salt length to maximum possible, default type. */ - OH_HUKS_RSA_PSS_SALT_LEN_MAX = 1, -}; - -/** - * @brief Enumerates the error codes. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_ErrCode { - /** The operation is successful. */ - OH_HUKS_SUCCESS = 0, - /** Permission verification failed. */ - OH_HUKS_ERR_CODE_PERMISSION_FAIL = 201, - /** Invalid parameters are detected. */ - OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT = 401, - /** The API is not supported. */ - OH_HUKS_ERR_CODE_NOT_SUPPORTED_API = 801, - - /** The feature is not supported. */ - OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED = 12000001, - /** Key algorithm parameters are missing. */ - OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT = 12000002, - /** Invalid key algorithm parameters are detected. */ - OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT = 12000003, - /** Failed to operate the file. */ - OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL = 12000004, - /** The process communication failed. */ - OH_HUKS_ERR_CODE_COMMUNICATION_FAIL = 12000005, - /** Failed to operate the algorithm library. */ - OH_HUKS_ERR_CODE_CRYPTO_FAIL = 12000006, - /** Failed to access the key because the key has expired. */ - OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED = 12000007, - /** Failed to access the key because the authentication has failed. */ - OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED = 12000008, - /** Key access timed out. */ - OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT = 12000009, - /** The number of key operation sessions has reached the limit. */ - OH_HUKS_ERR_CODE_SESSION_LIMIT = 12000010, - /** The entity does not exist. */ - OH_HUKS_ERR_CODE_ITEM_NOT_EXIST = 12000011, - /** Internal error. */ - OH_HUKS_ERR_CODE_INTERNAL_ERROR = 12000012, - /** The authentication credential does not exist. */ - OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST = 12000013, -}; - -/** - * @brief Enumerates the tag types. - * @see OH_Huks_Param - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_TagType { - /** Invalid tag type. */ - OH_HUKS_TAG_TYPE_INVALID = 0 << 28, - /** int32_t. */ - OH_HUKS_TAG_TYPE_INT = 1 << 28, - /** uin32_t. */ - OH_HUKS_TAG_TYPE_UINT = 2 << 28, - /** uin64_t. */ - OH_HUKS_TAG_TYPE_ULONG = 3 << 28, - /** Boolean. */ - OH_HUKS_TAG_TYPE_BOOL = 4 << 28, - /** OH_Huks_Blob. */ - OH_HUKS_TAG_TYPE_BYTES = 5 << 28, -}; - -/** - * @brief Enumerates the user authentication types. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_UserAuthType { - /** Fingerprint authentication. */ - OH_HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 << 0, - /** Facial authentication. */ - OH_HUKS_USER_AUTH_TYPE_FACE = 1 << 1, - /** PIN authentication. */ - OH_HUKS_USER_AUTH_TYPE_PIN = 1 << 2, -}; - -/** - * @brief Enumerates the access control types. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_AuthAccessType { - /** The key is invalid after the password is cleared. */ - OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 << 0, - /** The key is invalid after a new biometric feature is enrolled. */ - OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 << 1, -}; - -/** - * @brief Enumerates the types of the challenges generated when a key is used. - * @see OH_Huks_ChallengePosition - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_ChallengeType { - /** Normal challenge, which is of 32 bytes by default. */ - OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, - /** Custom challenge, which supports only one authentication for multiple keys. - * The valid value of a custom challenge is of 8 bytes. - */ - OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, - /** Challenge is not required. */ - OH_HUKS_CHALLENGE_TYPE_NONE = 2, -}; - -/** - * @brief Enumerates the positions of the 8-byte valid value in a custom challenge generated. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_ChallengePosition { - /** Bytes 0 to 7. */ - OH_HUKS_CHALLENGE_POS_0 = 0, - /** Bytes 8 to 15. */ - OH_HUKS_CHALLENGE_POS_1, - /** Bytes 16 to 23. */ - OH_HUKS_CHALLENGE_POS_2, - /** Bytes 24 to 31. */ - OH_HUKS_CHALLENGE_POS_3, -}; - -/** - * @brief Enumerates the signature types of the keys generated or imported. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_SecureSignType { - /** - * The signature carries authentication information. This field is specified when a key - * is generated or imported. When the key is used to sign data, the data will be added with - * the authentication information and then be signed. - */ - OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1, -}; - -/** - * @brief Enumerates the tag values used in parameter sets. - * - * @since 9 - * @version 1.0 - */ -enum OH_Huks_Tag { - /** Tags for key parameters. The value range is 1 to 200. */ - /** Algorithm. */ - OH_HUKS_TAG_ALGORITHM = OH_HUKS_TAG_TYPE_UINT | 1, - /** Key purpose. */ - OH_HUKS_TAG_PURPOSE = OH_HUKS_TAG_TYPE_UINT | 2, - /** Key size. */ - OH_HUKS_TAG_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT | 3, - /** Digest algorithm. */ - OH_HUKS_TAG_DIGEST = OH_HUKS_TAG_TYPE_UINT | 4, - /** Padding algorithm. */ - OH_HUKS_TAG_PADDING = OH_HUKS_TAG_TYPE_UINT | 5, - /** Cipher mode. */ - OH_HUKS_TAG_BLOCK_MODE = OH_HUKS_TAG_TYPE_UINT | 6, - /** Key type. */ - OH_HUKS_TAG_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT | 7, - /** Associated authentication data. */ - OH_HUKS_TAG_ASSOCIATED_DATA = OH_HUKS_TAG_TYPE_BYTES | 8, - /** Field for key encryption and decryption. */ - OH_HUKS_TAG_NONCE = OH_HUKS_TAG_TYPE_BYTES | 9, - /** Initialized vector (IV). */ - OH_HUKS_TAG_IV = OH_HUKS_TAG_TYPE_BYTES | 10, - - /** Information generated during key derivation. */ - OH_HUKS_TAG_INFO = OH_HUKS_TAG_TYPE_BYTES | 11, - /** Salt value used for key derivation. */ - OH_HUKS_TAG_SALT = OH_HUKS_TAG_TYPE_BYTES | 12, - /** Number of iterations for key derivation. */ - OH_HUKS_TAG_ITERATION = OH_HUKS_TAG_TYPE_UINT | 14, - - /** Type of the generated key. For details, see {@link OH_Huks_KeyGenerateType}. */ - OH_HUKS_TAG_KEY_GENERATE_TYPE = OH_HUKS_TAG_TYPE_UINT | 15, - /** Algorithm used in key agreement. */ - OH_HUKS_TAG_AGREE_ALG = OH_HUKS_TAG_TYPE_UINT | 19, - /** Alias of the public key used for key agreement. */ - OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL | 20, - /** Alias of the private key used for key agreement. */ - OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 21, - /** Public key used for key agreement. */ - OH_HUKS_TAG_AGREE_PUBLIC_KEY = OH_HUKS_TAG_TYPE_BYTES | 22, - /** Alias of the key. */ - OH_HUKS_TAG_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 23, - /** Size of the derived key. */ - OH_HUKS_TAG_DERIVE_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT | 24, - /** Type of the key to import. For details, see {@link OH_Huks_ImportKeyType}. */ - OH_HUKS_TAG_IMPORT_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT | 25, - /** Algorithm suite required for encrypted imports. */ - OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE = OH_HUKS_TAG_TYPE_UINT | 26, - /** Storage mode of derived or agree keys. For details, see {@link OH_Huks_KeyStorageType}. */ - OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT | 29, - /** Type of rsa pss salt length. */ - OH_HUKS_TAG_RSA_PSS_SALT_LEN_TYPE = OH_HUKS_TAG_TYPE_UINT | 30, - - /** Tags for access control and user authentication. The value range is 301 to 500. */ - /** All users in the multi-user scenario. */ - OH_HUKS_TAG_ALL_USERS = OH_HUKS_TAG_TYPE_BOOL | 301, - /** Multi-user ID. */ - OH_HUKS_TAG_USER_ID = OH_HUKS_TAG_TYPE_UINT | 302, - /** Specifies whether key access control is required. */ - OH_HUKS_TAG_NO_AUTH_REQUIRED = OH_HUKS_TAG_TYPE_BOOL | 303, - /** User authentication type in key access control. */ - OH_HUKS_TAG_USER_AUTH_TYPE = OH_HUKS_TAG_TYPE_UINT | 304, - /** Timeout duration for key access. */ - OH_HUKS_TAG_AUTH_TIMEOUT = OH_HUKS_TAG_TYPE_UINT | 305, - /** Authentication token for the key. */ - OH_HUKS_TAG_AUTH_TOKEN = OH_HUKS_TAG_TYPE_BYTES | 306, - /** - * Access control type. For details, see {@link OH_Huks_AuthAccessType}. - * This parameter must be set together with the user authentication type. - */ - OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE = OH_HUKS_TAG_TYPE_UINT | 307, - /** Signature type for the key to be generated or imported. */ - OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE = OH_HUKS_TAG_TYPE_UINT | 308, - /** Challenge type. For details, see {@link OH_Huks_ChallengeType}. */ - OH_HUKS_TAG_CHALLENGE_TYPE = OH_HUKS_TAG_TYPE_UINT | 309, - /** - * Position of the 8-byte valid value in a custom challenge. - * For details, see {@link OH_Huks_ChallengePosition}. - */ - OH_HUKS_TAG_CHALLENGE_POS = OH_HUKS_TAG_TYPE_UINT | 310, - - /** Purpose of key authentication */ - OH_HUKS_TAG_KEY_AUTH_PURPOSE = OH_HUKS_TAG_TYPE_UINT | 311, - - /** Tags for key attestation. The value range is 501 to 600. */ - /** Challenge value used in the attestation. */ - OH_HUKS_TAG_ATTESTATION_CHALLENGE = OH_HUKS_TAG_TYPE_BYTES | 501, - /** Application ID used in the attestation. */ - OH_HUKS_TAG_ATTESTATION_APPLICATION_ID = OH_HUKS_TAG_TYPE_BYTES | 502, - /** Alias of the key. */ - OH_HUKS_TAG_ATTESTATION_ID_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 511, - /** Security level used in the attestation. */ - OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = OH_HUKS_TAG_TYPE_BYTES | 514, - /** Version information used in the attestation. */ - OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO = OH_HUKS_TAG_TYPE_BYTES | 515, - - /** - * 601 to 1000 are reserved for other tags. - * - * Extended tags. The value range is 1001 to 9999. - */ - /** Specifies whether it is a key alias. */ - OH_HUKS_TAG_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL | 1001, - /** Key storage mode. For details, see {@link OH_Huks_KeyStorageType}. */ - OH_HUKS_TAG_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT | 1002, - /** Specifies whether to allow the key to be wrapped. */ - OH_HUKS_TAG_IS_ALLOWED_WRAP = OH_HUKS_TAG_TYPE_BOOL | 1003, - /** Key wrap type. */ - OH_HUKS_TAG_KEY_WRAP_TYPE = OH_HUKS_TAG_TYPE_UINT | 1004, - /** Authentication ID. */ - OH_HUKS_TAG_KEY_AUTH_ID = OH_HUKS_TAG_TYPE_BYTES | 1005, - /** Role of the key. */ - OH_HUKS_TAG_KEY_ROLE = OH_HUKS_TAG_TYPE_UINT | 1006, - /** Key flag. For details, see {@link OH_Huks_KeyFlag}. */ - OH_HUKS_TAG_KEY_FLAG = OH_HUKS_TAG_TYPE_UINT | 1007, - /** Specifies whether this API is asynchronous. */ - OH_HUKS_TAG_IS_ASYNCHRONIZED = OH_HUKS_TAG_TYPE_UINT | 1008, - /** Key domain. */ - OH_HUKS_TAG_KEY_DOMAIN = OH_HUKS_TAG_TYPE_UINT | 1011, - - /** Authenticated Encryption. */ - OH_HUKS_TAG_AE_TAG = OH_HUKS_TAG_TYPE_BYTES | 10009, - - /** - * 11000 to 12000 are reserved. - * - * 20001 to N are reserved for other tags. - */ - /** Symmetric key data. */ - OH_HUKS_TAG_SYMMETRIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20001, - /** Public key data of the asymmetric key pair. */ - OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20002, - /** Private key data of the asymmetric key pair. */ - OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20003, -}; - -/** - * @brief Defines the return data, including the result code and message. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Result { - /** Result code. */ - int32_t errorCode; - /** Description of the result code. */ - const char *errorMsg; - /** Other data returned. */ - uint8_t *data; -}; - -/** - * @brief Defines the structure for storing data. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Blob { - /** Data size. */ - uint32_t size; - /** Pointer to the memory in which the data is stored. */ - uint8_t *data; -}; - -/** - * @brief Defines the parameter structure in a parameter set. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_Param { - /** Tag value. */ - uint32_t tag; - - union { - /** Parameter of the Boolean type. */ - bool boolParam; - /** Parameter of the int32_t type. */ - int32_t int32Param; - /** Parameter of the uint32_t type. */ - uint32_t uint32Param; - /** Parameter of the uint64_t type. */ - uint64_t uint64Param; - /** Parameter of the struct OH_Huks_Blob type. */ - struct OH_Huks_Blob blob; - }; -}; - -/** - * @brief Defines the structure of the parameter set. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_ParamSet { - /** Memory size of the parameter set. */ - uint32_t paramSetSize; - /** Number of parameters in the parameter set. */ - uint32_t paramsCnt; - /** Parameter array. */ - struct OH_Huks_Param params[]; -}; - -/** - * @brief Defines the structure of the certificate chain. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_CertChain { - /** Pointer to the certificate data. */ - struct OH_Huks_Blob *certs; - /** Number of certificates. */ - uint32_t certsCount; -}; - -/** - * @brief Defines the key information structure. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyInfo { - /** Alias of the key. */ - struct OH_Huks_Blob alias; - /** Pointer to the key parameter set. */ - struct OH_Huks_ParamSet *paramSet; -}; - -/** - * @brief Defines the structure of a public key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_PubKeyInfo { - /** Algorithm of the public key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the public key. */ - uint32_t keySize; - /** Length of the n or X value. */ - uint32_t nOrXSize; - /** Length of the e or Y value. */ - uint32_t eOrYSize; - /** Placeholder size. */ - uint32_t placeHolder; -}; - -/** - * @brief Defines the structure of an RSA key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyMaterialRsa { - /** Algorithm of the key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the key. */ - uint32_t keySize; - /** Length of the n value. */ - uint32_t nSize; - /** Length of the e value. */ - uint32_t eSize; - /** Length of the d value. */ - uint32_t dSize; -}; - -/** - * @brief Defines the structure of an ECC key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyMaterialEcc { - /** Algorithm of the key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the key. */ - uint32_t keySize; - /** Length of the x value. */ - uint32_t xSize; - /** Length of the y value. */ - uint32_t ySize; - /** Length of the z value. */ - uint32_t zSize; -}; - -/** - * @brief Defines the structure of a DSA key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyMaterialDsa { - /** Algorithm of the key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the key. */ - uint32_t keySize; - /** Length of the x value. */ - uint32_t xSize; - /** Length of the y value. */ - uint32_t ySize; - /** Length of the p value. */ - uint32_t pSize; - /** Length of the q value. */ - uint32_t qSize; - /** Length of the g value. */ - uint32_t gSize; -}; - -/** - * @brief Defines the structure of a DH key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyMaterialDh { - /** Algorithm of the key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the DH key. */ - uint32_t keySize; - /** Length of the public key. */ - uint32_t pubKeySize; - /** Length of the private key. */ - uint32_t priKeySize; - /** Reserved. */ - uint32_t reserved; -}; - -/** - * @brief Defines the structure of a 25519 key. - * - * @since 9 - * @version 1.0 - */ -struct OH_Huks_KeyMaterial25519 { - /** Algorithm of the key. */ - enum OH_Huks_KeyAlg keyAlg; - /** Length of the 25519 key. */ - uint32_t keySize; - /** Length of the public key. */ - uint32_t pubKeySize; - /** Length of the private key. */ - uint32_t priKeySize; - /** Reserved. */ - uint32_t reserved; -}; - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* NATIVE_OH_HUKS_TYPE_H */ +/* + * Copyright (c) 2022-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. + */ + +#ifndef NATIVE_OH_HUKS_TYPE_H +#define NATIVE_OH_HUKS_TYPE_H + +/** + * @addtogroup HuksTypeApi + * @{ + * + * @brief Defines the macros, enumerated values, data structures, + * and error codes used by OpenHarmony Universal KeyStore (HUKS) APIs. + * + * @syscap SystemCapability.Security.Huks + * @since 9 + * @version 1.0 + */ + +/** + * @file native_huks_type.h + * + * @brief Defines the enumerated variables, structures, and macros used in the HUKS APIs. + * + * @since 9 + * @version 1.0 + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define OH_HUKS_AE_TAG_LEN 16 +#define OH_HUKS_BITS_PER_BYTE 8 +#define OH_HUKS_MAX_KEY_SIZE 2048 +#define OH_HUKS_AE_NONCE_LEN 12 +#define OH_HUKS_MAX_KEY_ALIAS_LEN 64 +#define OH_HUKS_MAX_PROCESS_NAME_LEN 50 +#define OH_HUKS_MAX_RANDOM_LEN 1024 +#define OH_HUKS_SIGNATURE_MIN_SIZE 64 +#define OH_HUKS_MAX_OUT_BLOB_SIZE (5 * 1024 * 1024) +#define OH_HUKS_WRAPPED_FORMAT_MAX_SIZE (1024 * 1024) +#define OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS 10 +#define TOKEN_CHALLENGE_LEN 32 +#define SHA256_SIGN_LEN 32 +#define TOKEN_SIZE 32 +#define MAX_AUTH_TIMEOUT_SECOND 60 +#define SECURE_SIGN_VERSION 0x01000001 + +/** + * @brief Enumerates the key purposes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyPurpose { + /** Used to encrypt the plaintext. */ + OH_HUKS_KEY_PURPOSE_ENCRYPT = 1, + /** Used to decrypt the cipher text. */ + OH_HUKS_KEY_PURPOSE_DECRYPT = 2, + /** Used to sign data. */ + OH_HUKS_KEY_PURPOSE_SIGN = 4, + /** Used to verify the signature. */ + OH_HUKS_KEY_PURPOSE_VERIFY = 8, + /** Used to derive a key. */ + OH_HUKS_KEY_PURPOSE_DERIVE = 16, + /** Used for an encrypted export. */ + OH_HUKS_KEY_PURPOSE_WRAP = 32, + /** Used for an encrypted import. */ + OH_HUKS_KEY_PURPOSE_UNWRAP = 64, + /** Used to generate a message authentication code (MAC). */ + OH_HUKS_KEY_PURPOSE_MAC = 128, + /** Used for key agreement. */ + OH_HUKS_KEY_PURPOSE_AGREE = 256, +}; + +/** + * @brief Enumerates the digest algorithms. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyDigest { + /** No digest algorithm. */ + OH_HUKS_DIGEST_NONE = 0, + /** MD5. */ + OH_HUKS_DIGEST_MD5 = 1, + /** SM3. */ + OH_HUKS_DIGEST_SM3 = 2, + /** SHA-1. */ + OH_HUKS_DIGEST_SHA1 = 10, + /** SHA-224. */ + OH_HUKS_DIGEST_SHA224 = 11, + /** SHA-256. */ + OH_HUKS_DIGEST_SHA256 = 12, + /** SHA-384. */ + OH_HUKS_DIGEST_SHA384 = 13, + /** SHA-512. */ + OH_HUKS_DIGEST_SHA512 = 14, +}; + +/** + * @brief Enumerates the padding algorithms. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyPadding { + /** No padding algorithm. */ + OH_HUKS_PADDING_NONE = 0, + /** Optimal Asymmetric Encryption Padding (OAEP). */ + OH_HUKS_PADDING_OAEP = 1, + /** Probabilistic Signature Scheme (PSS). */ + OH_HUKS_PADDING_PSS = 2, + /** Public Key Cryptography Standards (PKCS) #1 v1.5. */ + OH_HUKS_PADDING_PKCS1_V1_5 = 3, + /** PKCS #5. */ + OH_HUKS_PADDING_PKCS5 = 4, + /** PKCS #7. */ + OH_HUKS_PADDING_PKCS7 = 5, +}; + +/** + * @brief Enumerates the cipher modes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_CipherMode { + /** Electronic Code Block (ECB) mode. */ + OH_HUKS_MODE_ECB = 1, + /** Cipher Block Chaining (CBC) mode. */ + OH_HUKS_MODE_CBC = 2, + /** Counter (CTR) mode. */ + OH_HUKS_MODE_CTR = 3, + /** Output Feedback (OFB) mode. */ + OH_HUKS_MODE_OFB = 4, + /** Counter with CBC-MAC (CCM) mode. */ + OH_HUKS_MODE_CCM = 31, + /** Galois/Counter (GCM) mode. */ + OH_HUKS_MODE_GCM = 32, +}; + +/** + * @brief Enumerates the key sizes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeySize { + /** Rivest-Shamir-Adleman (RSA) key of 512 bits. */ + OH_HUKS_RSA_KEY_SIZE_512 = 512, + /** RSA key of 768 bits. */ + OH_HUKS_RSA_KEY_SIZE_768 = 768, + /** RSA key of 1024 bits. */ + OH_HUKS_RSA_KEY_SIZE_1024 = 1024, + /** RSA key of 2048 bits. */ + OH_HUKS_RSA_KEY_SIZE_2048 = 2048, + /** RSA key of 3072 bits. */ + OH_HUKS_RSA_KEY_SIZE_3072 = 3072, + /** RSA key of 4096 bits. */ + OH_HUKS_RSA_KEY_SIZE_4096 = 4096, + + /** Elliptic Curve Cryptography (ECC) key of 224 bits. */ + OH_HUKS_ECC_KEY_SIZE_224 = 224, + /** ECC key of 256 bits. */ + OH_HUKS_ECC_KEY_SIZE_256 = 256, + /** ECC key of 384 bits. */ + OH_HUKS_ECC_KEY_SIZE_384 = 384, + /** ECC key of 521 bits. */ + OH_HUKS_ECC_KEY_SIZE_521 = 521, + + /** Advanced Encryption Standard (AES) key of 128 bits. */ + OH_HUKS_AES_KEY_SIZE_128 = 128, + /** AES key of 192 bits. */ + OH_HUKS_AES_KEY_SIZE_192 = 192, + /** AES key of 256 bits. */ + OH_HUKS_AES_KEY_SIZE_256 = 256, + /** AES key of 512 bits. */ + OH_HUKS_AES_KEY_SIZE_512 = 512, + + /** Curve25519 key of 256 bits. */ + OH_HUKS_CURVE25519_KEY_SIZE_256 = 256, + + /** Diffie-Hellman (DH) key of 2048 bits. */ + OH_HUKS_DH_KEY_SIZE_2048 = 2048, + /** DH key of 3072 bits. */ + OH_HUKS_DH_KEY_SIZE_3072 = 3072, + /** DH key of 4096 bits. */ + OH_HUKS_DH_KEY_SIZE_4096 = 4096, + + /** ShangMi2 (SM2) key of 256 bits. */ + OH_HUKS_SM2_KEY_SIZE_256 = 256, + /** ShangMi4 (SM4) key of 128 bits. */ + OH_HUKS_SM4_KEY_SIZE_128 = 128, +}; + +/** + * @brief Enumerates the key algorithms. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyAlg { + /** RSA. */ + OH_HUKS_ALG_RSA = 1, + /** ECC. */ + OH_HUKS_ALG_ECC = 2, + /** DSA. */ + OH_HUKS_ALG_DSA = 3, + + /** AES. */ + OH_HUKS_ALG_AES = 20, + /** HMAC. */ + OH_HUKS_ALG_HMAC = 50, + /** HKDF. */ + OH_HUKS_ALG_HKDF = 51, + /** PBKDF2. */ + OH_HUKS_ALG_PBKDF2 = 52, + + /** ECDH. */ + OH_HUKS_ALG_ECDH = 100, + /** X25519. */ + OH_HUKS_ALG_X25519 = 101, + /** Ed25519. */ + OH_HUKS_ALG_ED25519 = 102, + /** DH. */ + OH_HUKS_ALG_DH = 103, + + /** SM2. */ + OH_HUKS_ALG_SM2 = 150, + /** SM3. */ + OH_HUKS_ALG_SM3 = 151, + /** SM4. */ + OH_HUKS_ALG_SM4 = 152, +}; + +/** + * @brief Enumerates the algorithm suites required for ciphertext imports. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_AlgSuite { + /** Key material format (Length-Value format), X25519 key agreement, and AES-256-GCM encryption and decryption. + * | x25519_plain_pubkey_length (4 Byte) | x25519_plain_pubkey | agreekey_aad_length (4 Byte) | agreekey_aad + * | agreekey_nonce_length (4 Byte) | agreekey_nonce | + * | agreekey_aead_tag_len (4 Byte) | agreekey_aead_tag | + * | kek_enc_data_length (4 Byte) | kek_enc_data | kek_aad_length (4 Byte) | kek_aad + * | kek_nonce_length (4 Byte) | kek_nonce | kek_aead_tag_len (4 Byte) | kek_aead_tag + * | key_material_size_len (4 Byte) | key_material_size | key_mat_enc_length (4 Byte) | key_mat_enc_data + */ + OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, + + /** Key material format (Length-Value format), ECDH-p256 key agreement, and AES-256-GCM encryption and decryption. + * | ECC_plain_pubkey_length (4 Byte) | ECC_plain_pubkey | agreekey_aad_length (4 Byte) | agreekey_aad + * | agreekey_nonce_length (4 Byte) | agreekey_nonce | + * | agreekey_aead_tag_len (4 Byte) | agreekey_aead_tag | + * | kek_enc_data_length (4 Byte) | kek_enc_data | kek_aad_length (4 Byte) | kek_aad + * | kek_nonce_length (4 Byte) | kek_nonce | kek_aead_tag_len (4 Byte) | kek_aead_tag + * | key_material_size_len (4 Byte) | key_material_size | key_mat_enc_length (4 Byte) | key_mat_enc_data + */ + OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2, +}; + +/** + * @brief Enumerates the key generation types. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyGenerateType { + /** Key generated by default. */ + OH_HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, + /** Derived key. */ + OH_HUKS_KEY_GENERATE_TYPE_DERIVE = 1, + /** Key obtained by key agreement. */ + OH_HUKS_KEY_GENERATE_TYPE_AGREE = 2, +}; + +/** + * @brief Enumerates the key generation modes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyFlag { + /** Import a public key using an API. */ + OH_HUKS_KEY_FLAG_IMPORT_KEY = 1, + /** Generate a key by using an API. */ + OH_HUKS_KEY_FLAG_GENERATE_KEY = 2, + /** Generate a key by using a key agreement API. */ + OH_HUKS_KEY_FLAG_AGREE_KEY = 3, + /** Derive a key by using an API. */ + OH_HUKS_KEY_FLAG_DERIVE_KEY = 4, +}; + +/** + * @brief Enumerates the key storage modes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_KeyStorageType { + /** The key is managed locally. */ + OH_HUKS_STORAGE_TEMP = 0, + /** The key is managed by the HUKS service. */ + OH_HUKS_STORAGE_PERSISTENT = 1, + /** The key is only used in huks. */ + OH_HUKS_STORAGE_ONLY_USED_IN_HUKS = 2, + /** The key can be allowed to export. */ + OH_HUKS_STORAGE_KEY_EXPORT_ALLOWED = 3, +}; + +/** + * @brief Enumerates the types of keys to import. By default, + * a public key is imported. This field is not required when a symmetric key is imported. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_ImportKeyType { + /** Public key. */ + OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, + /** Private key. */ + OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, + /** Public and private key pair. */ + OH_HUKS_KEY_TYPE_KEY_PAIR = 2, +}; + +/** + * @brief Enumerates the key storage modes. + * + * @since 10 + * @version 1.0 + */ +enum OH_Huks_RsaPssSaltLenType { + /** Salt length matches digest. */ + OH_HUKS_RSA_PSS_SALT_LEN_DIGEST = 0, + /** Set salt length to maximum possible, default type. */ + OH_HUKS_RSA_PSS_SALT_LEN_MAX = 1, +}; + +/** + * @brief Enumerates the error codes. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_ErrCode { + /** The operation is successful. */ + OH_HUKS_SUCCESS = 0, + /** Permission verification failed. */ + OH_HUKS_ERR_CODE_PERMISSION_FAIL = 201, + /** Invalid parameters are detected. */ + OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT = 401, + /** The API is not supported. */ + OH_HUKS_ERR_CODE_NOT_SUPPORTED_API = 801, + + /** The feature is not supported. */ + OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED = 12000001, + /** Key algorithm parameters are missing. */ + OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT = 12000002, + /** Invalid key algorithm parameters are detected. */ + OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT = 12000003, + /** Failed to operate the file. */ + OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL = 12000004, + /** The process communication failed. */ + OH_HUKS_ERR_CODE_COMMUNICATION_FAIL = 12000005, + /** Failed to operate the algorithm library. */ + OH_HUKS_ERR_CODE_CRYPTO_FAIL = 12000006, + /** Failed to access the key because the key has expired. */ + OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED = 12000007, + /** Failed to access the key because the authentication has failed. */ + OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED = 12000008, + /** Key access timed out. */ + OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT = 12000009, + /** The number of key operation sessions has reached the limit. */ + OH_HUKS_ERR_CODE_SESSION_LIMIT = 12000010, + /** The entity does not exist. */ + OH_HUKS_ERR_CODE_ITEM_NOT_EXIST = 12000011, + /** Internal error. */ + OH_HUKS_ERR_CODE_INTERNAL_ERROR = 12000012, + /** The authentication credential does not exist. */ + OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST = 12000013, +}; + +/** + * @brief Enumerates the tag types. + * @see OH_Huks_Param + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_TagType { + /** Invalid tag type. */ + OH_HUKS_TAG_TYPE_INVALID = 0 << 28, + /** int32_t. */ + OH_HUKS_TAG_TYPE_INT = 1 << 28, + /** uin32_t. */ + OH_HUKS_TAG_TYPE_UINT = 2 << 28, + /** uin64_t. */ + OH_HUKS_TAG_TYPE_ULONG = 3 << 28, + /** Boolean. */ + OH_HUKS_TAG_TYPE_BOOL = 4 << 28, + /** OH_Huks_Blob. */ + OH_HUKS_TAG_TYPE_BYTES = 5 << 28, +}; + +/** + * @brief Enumerates the user authentication types. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_UserAuthType { + /** Fingerprint authentication. */ + OH_HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 << 0, + /** Facial authentication. */ + OH_HUKS_USER_AUTH_TYPE_FACE = 1 << 1, + /** PIN authentication. */ + OH_HUKS_USER_AUTH_TYPE_PIN = 1 << 2, +}; + +/** + * @brief Enumerates the access control types. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_AuthAccessType { + /** The key is invalid after the password is cleared. */ + OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 << 0, + /** The key is invalid after a new biometric feature is enrolled. */ + OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 << 1 +}; + +/** + * @brief Enumerates the types of the challenges generated when a key is used. + * @see OH_Huks_ChallengePosition + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_ChallengeType { + /** Normal challenge, which is of 32 bytes by default. */ + OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, + /** Custom challenge, which supports only one authentication for multiple keys. + * The valid value of a custom challenge is of 8 bytes. + */ + OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, + /** Challenge is not required. */ + OH_HUKS_CHALLENGE_TYPE_NONE = 2, +}; + +/** + * @brief Enumerates the positions of the 8-byte valid value in a custom challenge generated. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_ChallengePosition { + /** Bytes 0 to 7. */ + OH_HUKS_CHALLENGE_POS_0 = 0, + /** Bytes 8 to 15. */ + OH_HUKS_CHALLENGE_POS_1, + /** Bytes 16 to 23. */ + OH_HUKS_CHALLENGE_POS_2, + /** Bytes 24 to 31. */ + OH_HUKS_CHALLENGE_POS_3, +}; + +/** + * @brief Enumerates the signature types of the keys generated or imported. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_SecureSignType { + /** + * The signature carries authentication information. This field is specified when a key + * is generated or imported. When the key is used to sign data, the data will be added with + * the authentication information and then be signed. + */ + OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1, +}; + +/** + * @brief Enumerates the tag values used in parameter sets. + * + * @since 9 + * @version 1.0 + */ +enum OH_Huks_Tag { + /** Tags for key parameters. The value range is 1 to 200. */ + /** Algorithm. */ + OH_HUKS_TAG_ALGORITHM = OH_HUKS_TAG_TYPE_UINT | 1, + /** Key purpose. */ + OH_HUKS_TAG_PURPOSE = OH_HUKS_TAG_TYPE_UINT | 2, + /** Key size. */ + OH_HUKS_TAG_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT | 3, + /** Digest algorithm. */ + OH_HUKS_TAG_DIGEST = OH_HUKS_TAG_TYPE_UINT | 4, + /** Padding algorithm. */ + OH_HUKS_TAG_PADDING = OH_HUKS_TAG_TYPE_UINT | 5, + /** Cipher mode. */ + OH_HUKS_TAG_BLOCK_MODE = OH_HUKS_TAG_TYPE_UINT | 6, + /** Key type. */ + OH_HUKS_TAG_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT | 7, + /** Associated authentication data. */ + OH_HUKS_TAG_ASSOCIATED_DATA = OH_HUKS_TAG_TYPE_BYTES | 8, + /** Field for key encryption and decryption. */ + OH_HUKS_TAG_NONCE = OH_HUKS_TAG_TYPE_BYTES | 9, + /** Initialized vector (IV). */ + OH_HUKS_TAG_IV = OH_HUKS_TAG_TYPE_BYTES | 10, + + /** Information generated during key derivation. */ + OH_HUKS_TAG_INFO = OH_HUKS_TAG_TYPE_BYTES | 11, + /** Salt value used for key derivation. */ + OH_HUKS_TAG_SALT = OH_HUKS_TAG_TYPE_BYTES | 12, + /** Number of iterations for key derivation. */ + OH_HUKS_TAG_ITERATION = OH_HUKS_TAG_TYPE_UINT | 14, + + /** Type of the generated key. For details, see {@link OH_Huks_KeyGenerateType}. */ + OH_HUKS_TAG_KEY_GENERATE_TYPE = OH_HUKS_TAG_TYPE_UINT | 15, + /** Algorithm used in key agreement. */ + OH_HUKS_TAG_AGREE_ALG = OH_HUKS_TAG_TYPE_UINT | 19, + /** Alias of the public key used for key agreement. */ + OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL | 20, + /** Alias of the private key used for key agreement. */ + OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 21, + /** Public key used for key agreement. */ + OH_HUKS_TAG_AGREE_PUBLIC_KEY = OH_HUKS_TAG_TYPE_BYTES | 22, + /** Alias of the key. */ + OH_HUKS_TAG_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 23, + /** Size of the derived key. */ + OH_HUKS_TAG_DERIVE_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT | 24, + /** Type of the key to import. For details, see {@link OH_Huks_ImportKeyType}. */ + OH_HUKS_TAG_IMPORT_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT | 25, + /** Algorithm suite required for encrypted imports. */ + OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE = OH_HUKS_TAG_TYPE_UINT | 26, + /** Storage mode of derived or agree keys. For details, see {@link OH_Huks_KeyStorageType}. */ + OH_HUKS_TAG_DERIVED_AGREED_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT | 29, + /** Type of rsa pss salt length. */ + OH_HUKS_TAG_RSA_PSS_SALT_LEN_TYPE = OH_HUKS_TAG_TYPE_UINT | 30, + + /** Tags for access control and user authentication. The value range is 301 to 500. */ + /** All users in the multi-user scenario. */ + OH_HUKS_TAG_ALL_USERS = OH_HUKS_TAG_TYPE_BOOL | 301, + /** Multi-user ID. */ + OH_HUKS_TAG_USER_ID = OH_HUKS_TAG_TYPE_UINT | 302, + /** Specifies whether key access control is required. */ + OH_HUKS_TAG_NO_AUTH_REQUIRED = OH_HUKS_TAG_TYPE_BOOL | 303, + /** User authentication type in key access control. */ + OH_HUKS_TAG_USER_AUTH_TYPE = OH_HUKS_TAG_TYPE_UINT | 304, + /** Timeout duration for key access. */ + OH_HUKS_TAG_AUTH_TIMEOUT = OH_HUKS_TAG_TYPE_UINT | 305, + /** Authentication token for the key. */ + OH_HUKS_TAG_AUTH_TOKEN = OH_HUKS_TAG_TYPE_BYTES | 306, + /** + * Access control type. For details, see {@link OH_Huks_AuthAccessType}. + * This parameter must be set together with the user authentication type. + */ + OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE = OH_HUKS_TAG_TYPE_UINT | 307, + /** Signature type for the key to be generated or imported. */ + OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE = OH_HUKS_TAG_TYPE_UINT | 308, + /** Challenge type. For details, see {@link OH_Huks_ChallengeType}. */ + OH_HUKS_TAG_CHALLENGE_TYPE = OH_HUKS_TAG_TYPE_UINT | 309, + /** + * Position of the 8-byte valid value in a custom challenge. + * For details, see {@link OH_Huks_ChallengePosition}. + */ + OH_HUKS_TAG_CHALLENGE_POS = OH_HUKS_TAG_TYPE_UINT | 310, + + /** Purpose of key authentication */ + OH_HUKS_TAG_KEY_AUTH_PURPOSE = OH_HUKS_TAG_TYPE_UINT | 311, + + /** Tags for key attestation. The value range is 501 to 600. */ + /** Challenge value used in the attestation. */ + OH_HUKS_TAG_ATTESTATION_CHALLENGE = OH_HUKS_TAG_TYPE_BYTES | 501, + /** Application ID used in the attestation. */ + OH_HUKS_TAG_ATTESTATION_APPLICATION_ID = OH_HUKS_TAG_TYPE_BYTES | 502, + /** Alias of the key. */ + OH_HUKS_TAG_ATTESTATION_ID_ALIAS = OH_HUKS_TAG_TYPE_BYTES | 511, + /** Security level used in the attestation. */ + OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = OH_HUKS_TAG_TYPE_BYTES | 514, + /** Version information used in the attestation. */ + OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO = OH_HUKS_TAG_TYPE_BYTES | 515, + + /** + * 601 to 1000 are reserved for other tags. + * + * Extended tags. The value range is 1001 to 9999. + */ + /** Specifies whether it is a key alias. */ + OH_HUKS_TAG_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL | 1001, + /** Key storage mode. For details, see {@link OH_Huks_KeyStorageType}. */ + OH_HUKS_TAG_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT | 1002, + /** Specifies whether to allow the key to be wrapped. */ + OH_HUKS_TAG_IS_ALLOWED_WRAP = OH_HUKS_TAG_TYPE_BOOL | 1003, + /** Key wrap type. */ + OH_HUKS_TAG_KEY_WRAP_TYPE = OH_HUKS_TAG_TYPE_UINT | 1004, + /** Authentication ID. */ + OH_HUKS_TAG_KEY_AUTH_ID = OH_HUKS_TAG_TYPE_BYTES | 1005, + /** Role of the key. */ + OH_HUKS_TAG_KEY_ROLE = OH_HUKS_TAG_TYPE_UINT | 1006, + /** Key flag. For details, see {@link OH_Huks_KeyFlag}. */ + OH_HUKS_TAG_KEY_FLAG = OH_HUKS_TAG_TYPE_UINT | 1007, + /** Specifies whether this API is asynchronous. */ + OH_HUKS_TAG_IS_ASYNCHRONIZED = OH_HUKS_TAG_TYPE_UINT | 1008, + /** Key domain. */ + OH_HUKS_TAG_KEY_DOMAIN = OH_HUKS_TAG_TYPE_UINT | 1011, + + /** Authenticated Encryption. */ + OH_HUKS_TAG_AE_TAG = OH_HUKS_TAG_TYPE_BYTES | 10009, + + /** + * 11000 to 12000 are reserved. + * + * 20001 to N are reserved for other tags. + */ + /** Symmetric key data. */ + OH_HUKS_TAG_SYMMETRIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20001, + /** Public key data of the asymmetric key pair. */ + OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20002, + /** Private key data of the asymmetric key pair. */ + OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES | 20003, +}; + +/** + * @brief Defines the return data, including the result code and message. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Result { + /** Result code. */ + int32_t errorCode; + /** Description of the result code. */ + const char *errorMsg; + /** Other data returned. */ + uint8_t *data; +}; + +/** + * @brief Defines the structure for storing data. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Blob { + /** Data size. */ + uint32_t size; + /** Pointer to the memory in which the data is stored. */ + uint8_t *data; +}; + +/** + * @brief Defines the parameter structure in a parameter set. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_Param { + /** Tag value. */ + uint32_t tag; + + union { + /** Parameter of the Boolean type. */ + bool boolParam; + /** Parameter of the int32_t type. */ + int32_t int32Param; + /** Parameter of the uint32_t type. */ + uint32_t uint32Param; + /** Parameter of the uint64_t type. */ + uint64_t uint64Param; + /** Parameter of the struct OH_Huks_Blob type. */ + struct OH_Huks_Blob blob; + }; +}; + +/** + * @brief Defines the structure of the parameter set. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_ParamSet { + /** Memory size of the parameter set. */ + uint32_t paramSetSize; + /** Number of parameters in the parameter set. */ + uint32_t paramsCnt; + /** Parameter array. */ + struct OH_Huks_Param params[]; +}; + +/** + * @brief Defines the structure of the certificate chain. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_CertChain { + /** Pointer to the certificate data. */ + struct OH_Huks_Blob *certs; + /** Number of certificates. */ + uint32_t certsCount; +}; + +/** + * @brief Defines the key information structure. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyInfo { + /** Alias of the key. */ + struct OH_Huks_Blob alias; + /** Pointer to the key parameter set. */ + struct OH_Huks_ParamSet *paramSet; +}; + +/** + * @brief Defines the structure of a public key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_PubKeyInfo { + /** Algorithm of the public key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the public key. */ + uint32_t keySize; + /** Length of the n or X value. */ + uint32_t nOrXSize; + /** Length of the e or Y value. */ + uint32_t eOrYSize; + /** Placeholder size. */ + uint32_t placeHolder; +}; + +/** + * @brief Defines the structure of an RSA key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyMaterialRsa { + /** Algorithm of the key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the key. */ + uint32_t keySize; + /** Length of the n value. */ + uint32_t nSize; + /** Length of the e value. */ + uint32_t eSize; + /** Length of the d value. */ + uint32_t dSize; +}; + +/** + * @brief Defines the structure of an ECC key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyMaterialEcc { + /** Algorithm of the key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the key. */ + uint32_t keySize; + /** Length of the x value. */ + uint32_t xSize; + /** Length of the y value. */ + uint32_t ySize; + /** Length of the z value. */ + uint32_t zSize; +}; + +/** + * @brief Defines the structure of a DSA key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyMaterialDsa { + /** Algorithm of the key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the key. */ + uint32_t keySize; + /** Length of the x value. */ + uint32_t xSize; + /** Length of the y value. */ + uint32_t ySize; + /** Length of the p value. */ + uint32_t pSize; + /** Length of the q value. */ + uint32_t qSize; + /** Length of the g value. */ + uint32_t gSize; +}; + +/** + * @brief Defines the structure of a DH key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyMaterialDh { + /** Algorithm of the key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the DH key. */ + uint32_t keySize; + /** Length of the public key. */ + uint32_t pubKeySize; + /** Length of the private key. */ + uint32_t priKeySize; + /** Reserved. */ + uint32_t reserved; +}; + +/** + * @brief Defines the structure of a 25519 key. + * + * @since 9 + * @version 1.0 + */ +struct OH_Huks_KeyMaterial25519 { + /** Algorithm of the key. */ + enum OH_Huks_KeyAlg keyAlg; + /** Length of the 25519 key. */ + uint32_t keySize; + /** Length of the public key. */ + uint32_t pubKeySize; + /** Length of the private key. */ + uint32_t priKeySize; + /** Reserved. */ + uint32_t reserved; +}; + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* NATIVE_OH_HUKS_TYPE_H */ diff --git a/security/huks/libhuks.ndk.json b/security/huks/libhuks.ndk.json index a07592c0bea1c6ccaa40c94fc8f10ad7826cc55d..248c0ced32393e844d6b1ff80d337b4883125891 100644 --- a/security/huks/libhuks.ndk.json +++ b/security/huks/libhuks.ndk.json @@ -1,71 +1,71 @@ -[ - { - "name": "OH_Huks_GetSdkVersion" - }, - { - "name": "OH_Huks_GenerateKeyItem" - }, - { - "name": "OH_Huks_ImportKeyItem" - }, - { - "name": "OH_Huks_ImportWrappedKeyItem" - }, - { - "name": "OH_Huks_ExportPublicKeyItem" - }, - { - "name": "OH_Huks_DeleteKeyItem" - }, - { - "name": "OH_Huks_GetKeyItemParamSet" - }, - { - "name": "OH_Huks_IsKeyItemExist" - }, - { - "name": "OH_Huks_AttestKeyItem" - }, - { - "name": "OH_Huks_InitSession" - }, - { - "name": "OH_Huks_UpdateSession" - }, - { - "name": "OH_Huks_FinishSession" - }, - { - "name": "OH_Huks_AbortSession" - }, - { - "name": "OH_Huks_InitParamSet" - }, - { - "name": "OH_Huks_AddParams" - }, - { - "name": "OH_Huks_BuildParamSet" - }, - { - "name": "OH_Huks_FreeParamSet" - }, - { - "name": "OH_Huks_CopyParamSet" - }, - { - "name": "OH_Huks_GetParam" - }, - { - "name": "OH_Huks_FreshParamSet" - }, - { - "name": "OH_Huks_IsParamSetTagValid" - }, - { - "name": "OH_Huks_IsParamSetValid" - }, - { - "name": "OH_Huks_CheckParamMatch" - } +[ + { + "name": "OH_Huks_GetSdkVersion" + }, + { + "name": "OH_Huks_GenerateKeyItem" + }, + { + "name": "OH_Huks_ImportKeyItem" + }, + { + "name": "OH_Huks_ImportWrappedKeyItem" + }, + { + "name": "OH_Huks_ExportPublicKeyItem" + }, + { + "name": "OH_Huks_DeleteKeyItem" + }, + { + "name": "OH_Huks_GetKeyItemParamSet" + }, + { + "name": "OH_Huks_IsKeyItemExist" + }, + { + "name": "OH_Huks_AttestKeyItem" + }, + { + "name": "OH_Huks_InitSession" + }, + { + "name": "OH_Huks_UpdateSession" + }, + { + "name": "OH_Huks_FinishSession" + }, + { + "name": "OH_Huks_AbortSession" + }, + { + "name": "OH_Huks_InitParamSet" + }, + { + "name": "OH_Huks_AddParams" + }, + { + "name": "OH_Huks_BuildParamSet" + }, + { + "name": "OH_Huks_FreeParamSet" + }, + { + "name": "OH_Huks_CopyParamSet" + }, + { + "name": "OH_Huks_GetParam" + }, + { + "name": "OH_Huks_FreshParamSet" + }, + { + "name": "OH_Huks_IsParamSetTagValid" + }, + { + "name": "OH_Huks_IsParamSetValid" + }, + { + "name": "OH_Huks_CheckParamMatch" + } ] \ No newline at end of file diff --git a/security/huks/src/native_huks_api.c b/security/huks/src/native_huks_api.c index 2a6ab5cd2483427851ecb194915f55449d77285f..4de9a5b819fecb451af373c74b6ef6bc8bd2e0cc 100644 --- a/security/huks/src/native_huks_api.c +++ b/security/huks/src/native_huks_api.c @@ -1,126 +1,126 @@ -/* - * Copyright (c) 2022 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 "native_huks_api.h" - -#include "hks_api.h" -#include "hks_errcode_adapter.h" -#include "native_huks_api_adapter.h" - -static struct OH_Huks_Result ConvertApiResult(int32_t ret) -{ - struct HksResult result = HksConvertErrCode(ret); - return *((struct OH_Huks_Result *)(&result)); -} - -struct OH_Huks_Result OH_Huks_GetSdkVersion(struct OH_Huks_Blob *sdkVersion) -{ - int32_t result = HksGetSdkVersion((struct HksBlob *) sdkVersion); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_GenerateKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut) -{ - int32_t result = HksGenerateKey((const struct HksBlob *) keyAlias, - (const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_ImportKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *key) -{ - int32_t result = HksImportKey((const struct HksBlob *) keyAlias, - (const struct HksParamSet *) paramSet, (const struct HksBlob *) key); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_Blob *wrappingKeyAlias, const struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Blob *wrappedKeyData) -{ - int32_t result = HksImportWrappedKey((const struct HksBlob *) keyAlias, - (const struct HksBlob *) wrappingKeyAlias, (const struct HksParamSet *) paramSet, - (const struct HksBlob *) wrappedKeyData); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_ExportPublicKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *key) -{ - int32_t result = HksExportPublicKey((const struct HksBlob *) keyAlias, - (const struct HksParamSet *) paramSet, (struct HksBlob *) key); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_DeleteKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet) -{ - int32_t result = HksDeleteKey((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_GetKeyItemParamSet(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut) -{ - int32_t result = HksGetKeyParamSet((const struct HksBlob *) keyAlias, - (const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_IsKeyItemExist(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet) -{ - int32_t result = HksKeyExist((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_AttestKeyItem(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_CertChain *certChain) -{ - int32_t result = HuksAttestAdapter(keyAlias, paramSet, certChain); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_InitSession(const struct OH_Huks_Blob *keyAlias, - const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *handle, struct OH_Huks_Blob *token) -{ - int32_t result = HksInit((const struct HksBlob *) keyAlias, - (const struct HksParamSet *) paramSet, (struct HksBlob *) handle, (struct HksBlob *) token); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_UpdateSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) -{ - int32_t result = HksUpdate((const struct HksBlob *) handle, - (const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_FinishSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) -{ - int32_t result = HksFinish((const struct HksBlob *) handle, - (const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData); - return ConvertApiResult(result); -} - -struct OH_Huks_Result OH_Huks_AbortSession(const struct OH_Huks_Blob *handle, - const struct OH_Huks_ParamSet *paramSet) -{ - int32_t result = HksAbort((const struct HksBlob *) handle, (const struct HksParamSet *) paramSet); - return ConvertApiResult(result); -} +/* + * Copyright (c) 2022 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 "native_huks_api.h" + +#include "hks_api.h" +#include "hks_errcode_adapter.h" +#include "native_huks_api_adapter.h" + +static struct OH_Huks_Result ConvertApiResult(int32_t ret) +{ + struct HksResult result = HksConvertErrCode(ret); + return *((struct OH_Huks_Result *)(&result)); +} + +struct OH_Huks_Result OH_Huks_GetSdkVersion(struct OH_Huks_Blob *sdkVersion) +{ + int32_t result = HksGetSdkVersion((struct HksBlob *) sdkVersion); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_GenerateKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut) +{ + int32_t result = HksGenerateKey((const struct HksBlob *) keyAlias, + (const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_ImportKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *key) +{ + int32_t result = HksImportKey((const struct HksBlob *) keyAlias, + (const struct HksParamSet *) paramSet, (const struct HksBlob *) key); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_Blob *wrappingKeyAlias, const struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Blob *wrappedKeyData) +{ + int32_t result = HksImportWrappedKey((const struct HksBlob *) keyAlias, + (const struct HksBlob *) wrappingKeyAlias, (const struct HksParamSet *) paramSet, + (const struct HksBlob *) wrappedKeyData); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_ExportPublicKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *key) +{ + int32_t result = HksExportPublicKey((const struct HksBlob *) keyAlias, + (const struct HksParamSet *) paramSet, (struct HksBlob *) key); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_DeleteKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet) +{ + int32_t result = HksDeleteKey((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_GetKeyItemParamSet(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSetIn, struct OH_Huks_ParamSet *paramSetOut) +{ + int32_t result = HksGetKeyParamSet((const struct HksBlob *) keyAlias, + (const struct HksParamSet *) paramSetIn, (struct HksParamSet *) paramSetOut); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_IsKeyItemExist(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet) +{ + int32_t result = HksKeyExist((const struct HksBlob *) keyAlias, (const struct HksParamSet *) paramSet); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_AttestKeyItem(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_CertChain *certChain) +{ + int32_t result = HuksAttestAdapter(keyAlias, paramSet, certChain); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_InitSession(const struct OH_Huks_Blob *keyAlias, + const struct OH_Huks_ParamSet *paramSet, struct OH_Huks_Blob *handle, struct OH_Huks_Blob *token) +{ + int32_t result = HksInit((const struct HksBlob *) keyAlias, + (const struct HksParamSet *) paramSet, (struct HksBlob *) handle, (struct HksBlob *) token); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_UpdateSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) +{ + int32_t result = HksUpdate((const struct HksBlob *) handle, + (const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_FinishSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *outData) +{ + int32_t result = HksFinish((const struct HksBlob *) handle, + (const struct HksParamSet *) paramSet, (const struct HksBlob *) inData, (struct HksBlob *) outData); + return ConvertApiResult(result); +} + +struct OH_Huks_Result OH_Huks_AbortSession(const struct OH_Huks_Blob *handle, + const struct OH_Huks_ParamSet *paramSet) +{ + int32_t result = HksAbort((const struct HksBlob *) handle, (const struct HksParamSet *) paramSet); + return ConvertApiResult(result); +} diff --git a/security/huks/src/native_huks_api_adapter.c b/security/huks/src/native_huks_api_adapter.c index 792b6b50edd1313323730d8e5b7d42c278a07ada..2a6cd0d9cfac2738710e5a900311db4c08c37a63 100644 --- a/security/huks/src/native_huks_api_adapter.c +++ b/security/huks/src/native_huks_api_adapter.c @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2022 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 "hks_api.h" -#include "hks_param.h" - -#include "native_huks_api_adapter.h" -#include "native_huks_param.h" - -int32_t HuksAttestAdapter(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *paramSet, - struct OH_Huks_CertChain *certChain) -{ - int32_t ret; - struct HksParamSet *newParamSet = NULL; - do { - if (paramSet == NULL) { - ret = HKS_ERROR_NULL_POINTER; - break; - } - ret = HksCheckParamSet((struct HksParamSet *)paramSet, paramSet->paramSetSize); - if (ret != HKS_SUCCESS) { - break; - } - ret = HksInitParamSet(&newParamSet); - if (ret != HKS_SUCCESS) { - break; - } - ret = HksFreshParamSet((struct HksParamSet *)paramSet, false); - if (ret != HKS_SUCCESS) { - break; - } - ret = HksAddParams(newParamSet, (const struct HksParam *)paramSet->params, paramSet->paramsCnt); - if (ret != HKS_SUCCESS) { - break; - } - struct HksParam isBase64Param = { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true }; - ret = HksAddParams(newParamSet, &isBase64Param, 1); - if (ret != HKS_SUCCESS) { - break; - } - ret = HksBuildParamSet(&newParamSet); - if (ret != HKS_SUCCESS) { - break; - } - ret = HksAttestKey((const struct HksBlob *)keyAlias, (struct HksParamSet *)newParamSet, - (struct HksCertChain *)certChain); - } while (0); - HksFreeParamSet(&newParamSet); - return ret; +/* + * Copyright (c) 2022 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 "hks_api.h" +#include "hks_param.h" + +#include "native_huks_api_adapter.h" +#include "native_huks_param.h" + +int32_t HuksAttestAdapter(const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_ParamSet *paramSet, + struct OH_Huks_CertChain *certChain) +{ + int32_t ret; + struct HksParamSet *newParamSet = NULL; + do { + if (paramSet == NULL) { + ret = HKS_ERROR_NULL_POINTER; + break; + } + ret = HksCheckParamSet((struct HksParamSet *)paramSet, paramSet->paramSetSize); + if (ret != HKS_SUCCESS) { + break; + } + ret = HksInitParamSet(&newParamSet); + if (ret != HKS_SUCCESS) { + break; + } + ret = HksFreshParamSet((struct HksParamSet *)paramSet, false); + if (ret != HKS_SUCCESS) { + break; + } + ret = HksAddParams(newParamSet, (const struct HksParam *)paramSet->params, paramSet->paramsCnt); + if (ret != HKS_SUCCESS) { + break; + } + struct HksParam isBase64Param = { .tag = HKS_TAG_ATTESTATION_BASE64, .boolParam = true }; + ret = HksAddParams(newParamSet, &isBase64Param, 1); + if (ret != HKS_SUCCESS) { + break; + } + ret = HksBuildParamSet(&newParamSet); + if (ret != HKS_SUCCESS) { + break; + } + ret = HksAttestKey((const struct HksBlob *)keyAlias, (struct HksParamSet *)newParamSet, + (struct HksCertChain *)certChain); + } while (0); + HksFreeParamSet(&newParamSet); + return ret; } \ No newline at end of file diff --git a/security/huks/src/native_huks_param.c b/security/huks/src/native_huks_param.c index 9fab8b6c4ff09a1cc66d23e9c700360d74ff8826..3008ba10bae9388caf092edf1dbc4dd99bff0f89 100644 --- a/security/huks/src/native_huks_param.c +++ b/security/huks/src/native_huks_param.c @@ -1,89 +1,89 @@ -/* - * Copyright (c) 2022 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 "native_huks_param.h" - -#include "hks_param.h" -#include "hks_errcode_adapter.h" - -static struct OH_Huks_Result ConvertParamResult(int32_t ret) -{ - struct HksResult result = HksConvertErrCode(ret); - return *((struct OH_Huks_Result *)(&result)); -} - -struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet) -{ - int32_t result = HksInitParamSet((struct HksParamSet **) paramSet); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet, - const struct OH_Huks_Param *params, uint32_t paramCnt) -{ - int32_t result = HksAddParams((struct HksParamSet *) paramSet, - (const struct HksParam *) params, paramCnt); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet) -{ - int32_t result = HksBuildParamSet((struct HksParamSet **) paramSet); - return ConvertParamResult(result); -} - -void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet) -{ - HksFreeParamSet((struct HksParamSet **) paramSet); -} - -struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet, - uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet) -{ - int32_t result = HksGetParamSet((const struct HksParamSet *) fromParamSet, - fromParamSetSize, (struct HksParamSet **) paramSet); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag, - struct OH_Huks_Param **param) -{ - int32_t result = HksGetParam((const struct HksParamSet *) paramSet, tag, (struct HksParam **) param); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy) -{ - int32_t result = HksFreshParamSet((struct HksParamSet *) paramSet, isCopy); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet) -{ - int32_t result = HksCheckParamSetTag((const struct HksParamSet *) paramSet); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size) -{ - int32_t result = HksCheckParamSet((const struct HksParamSet *) paramSet, size); - return ConvertParamResult(result); -} - -struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param) -{ - int32_t result = HksCheckParamMatch((const struct HksParam *) baseParam, (const struct HksParam *) param); - return ConvertParamResult(result); -} +/* + * Copyright (c) 2022 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 "native_huks_param.h" + +#include "hks_param.h" +#include "hks_errcode_adapter.h" + +static struct OH_Huks_Result ConvertParamResult(int32_t ret) +{ + struct HksResult result = HksConvertErrCode(ret); + return *((struct OH_Huks_Result *)(&result)); +} + +struct OH_Huks_Result OH_Huks_InitParamSet(struct OH_Huks_ParamSet **paramSet) +{ + int32_t result = HksInitParamSet((struct HksParamSet **) paramSet); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_AddParams(struct OH_Huks_ParamSet *paramSet, + const struct OH_Huks_Param *params, uint32_t paramCnt) +{ + int32_t result = HksAddParams((struct HksParamSet *) paramSet, + (const struct HksParam *) params, paramCnt); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_BuildParamSet(struct OH_Huks_ParamSet **paramSet) +{ + int32_t result = HksBuildParamSet((struct HksParamSet **) paramSet); + return ConvertParamResult(result); +} + +void OH_Huks_FreeParamSet(struct OH_Huks_ParamSet **paramSet) +{ + HksFreeParamSet((struct HksParamSet **) paramSet); +} + +struct OH_Huks_Result OH_Huks_CopyParamSet(const struct OH_Huks_ParamSet *fromParamSet, + uint32_t fromParamSetSize, struct OH_Huks_ParamSet **paramSet) +{ + int32_t result = HksGetParamSet((const struct HksParamSet *) fromParamSet, + fromParamSetSize, (struct HksParamSet **) paramSet); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_GetParam(const struct OH_Huks_ParamSet *paramSet, uint32_t tag, + struct OH_Huks_Param **param) +{ + int32_t result = HksGetParam((const struct HksParamSet *) paramSet, tag, (struct HksParam **) param); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_FreshParamSet(struct OH_Huks_ParamSet *paramSet, bool isCopy) +{ + int32_t result = HksFreshParamSet((struct HksParamSet *) paramSet, isCopy); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_IsParamSetTagValid(const struct OH_Huks_ParamSet *paramSet) +{ + int32_t result = HksCheckParamSetTag((const struct HksParamSet *) paramSet); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_IsParamSetValid(const struct OH_Huks_ParamSet *paramSet, uint32_t size) +{ + int32_t result = HksCheckParamSet((const struct HksParamSet *) paramSet, size); + return ConvertParamResult(result); +} + +struct OH_Huks_Result OH_Huks_CheckParamMatch(const struct OH_Huks_Param *baseParam, const struct OH_Huks_Param *param) +{ + int32_t result = HksCheckParamMatch((const struct HksParam *) baseParam, (const struct HksParam *) param); + return ConvertParamResult(result); +} diff --git a/startup/init/syscap/BUILD.gn b/startup/init/syscap/BUILD.gn index d28cab6c0d542a72463e255c22a9acef653a5712..790d739f380b354137fb6792ebb8c0fec4ee6aa4 100644 --- a/startup/init/syscap/BUILD.gn +++ b/startup/init/syscap/BUILD.gn @@ -1,29 +1,29 @@ -# Copyright (c) 2022 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") - -ohos_ndk_library("libdeviceinfo_ndk") { - cflags = [ "-fstack-protector-all" ] - output_name = "deviceinfo_ndk" - ndk_description_file = "./libdeviceinfo.ndk.json" - min_compact_version = "1" -} - -ohos_ndk_headers("deviceinfo_header") { - dest_dir = "$ndk_headers_out_dir/" - sources = [ - "./include/deviceinfo.h", - "./include/syscap_ndk.h", - ] -} +# Copyright (c) 2022 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") + +ohos_ndk_library("libdeviceinfo_ndk") { + cflags = [ "-fstack-protector-all" ] + output_name = "deviceinfo_ndk" + ndk_description_file = "./libdeviceinfo.ndk.json" + min_compact_version = "1" +} + +ohos_ndk_headers("deviceinfo_header") { + dest_dir = "$ndk_headers_out_dir/" + sources = [ + "./include/deviceinfo.h", + "./include/syscap_ndk.h", + ] +} diff --git a/startup/init/syscap/include/deviceinfo.h b/startup/init/syscap/include/deviceinfo.h index cc1a504ffa0819117379ec6d27513cb97a207445..8761a01b3139e36978ce252c791fc3fe5a4e6ffc 100644 --- a/startup/init/syscap/include/deviceinfo.h +++ b/startup/init/syscap/include/deviceinfo.h @@ -1,230 +1,230 @@ -/* - * 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. - */ - -#ifndef DEVICEINFO_CSDK_H -#define DEVICEINFO_CSDK_H - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif - -/** - * Obtains the device type represented by a string, - * which can be {@code phone} (or {@code default} for phones), {@code wearable}, {@code liteWearable}, - * {@code tablet}, {@code tv}, {@code car}, or {@code smartVision}. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetDeviceType(void); - -/** - * Obtains the device manufacturer represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetManufacture(void); - -/** - * Obtains the device brand represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBrand(void); - -/** - * Obtains the external product series represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetMarketName(void); - -/** - * Obtains the product series represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetProductSeries(void); - -/** - * Obtains the product model represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetProductModel(void); - -/** - * Obtains the software model represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetSoftwareModel(void); - -/** - * Obtains the hardware model represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetHardwareModel(void); - -/** - * Obtains the bootloader version number represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBootloaderVersion(void); - -/** - * Obtains the application binary interface (Abi) list represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetAbiList(void); - -/** - * Obtains the security patch level represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetSecurityPatchTag(void); - -/** - * Obtains the product version represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetDisplayVersion(void); - -/** - * Obtains the incremental version represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetIncrementalVersion(void); - -/** - * Obtains the OS release type represented by a string. - * - *

The OS release category can be {@code Release}, {@code Beta}, or {@code Canary}. - * The specific release type may be {@code Release}, {@code Beta1}, or others alike. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetOsReleaseType(void); - -/** - * Obtains the OS version represented by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetOSFullName(void); - -/** - * Obtains the SDK API version number. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -int OH_GetSdkApiVersion(void); - -/** - * Obtains the first API version number. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -int OH_GetFirstApiVersion(void); - -/** - * Obtains the version ID by a string. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetVersionId(void); - -/** - * Obtains the build types of the same baseline code. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBuildType(void); - -/** - * Obtains the different build user of the same baseline code. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBuildUser(void); - -/** - * Obtains the different build host of the same baseline code. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBuildHost(void); - -/** - * Obtains the build time. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBuildTime(void); - -/** - * Obtains the version hash. - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetBuildRootHash(void); - -/** - * Obtains the Distribution OS name represented by a string. - * - *

Independent Software Vendor (ISV) may distribute OHOS with their own OS name. - * If ISV not specified, it will return an empty string - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetDistributionOSName(void); - -/** - * Obtains the ISV distribution OS version represented by a string. - * If ISV not specified, it will return the same value as OH_GetOSFullName - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetDistributionOSVersion(void); - -/** - * Obtains the ISV distribution OS api version represented by a integer. - * If ISV not specified, it will return the same value as OH_GetSdkApiVersion - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -int OH_GetDistributionOSApiVersion(void); - -/** - * Obtains the ISV distribution OS release type represented by a string. - * If ISV not specified, it will return the same value as OH_GetOsReleaseType - * @syscap SystemCapability.Startup.SystemInfo - * @since 10 - */ -const char *OH_GetDistributionOSReleaseType(void); - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif -#endif +/* + * 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. + */ + +#ifndef DEVICEINFO_CSDK_H +#define DEVICEINFO_CSDK_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +/** + * Obtains the device type represented by a string, + * which can be {@code phone} (or {@code default} for phones), {@code wearable}, {@code liteWearable}, + * {@code tablet}, {@code tv}, {@code car}, or {@code smartVision}. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetDeviceType(void); + +/** + * Obtains the device manufacturer represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetManufacture(void); + +/** + * Obtains the device brand represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBrand(void); + +/** + * Obtains the product name speaded in the market + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetMarketName(void); + +/** + * Obtains the product series represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetProductSeries(void); + +/** + * Obtains the product model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetProductModel(void); + +/** + * Obtains the software model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetSoftwareModel(void); + +/** + * Obtains the hardware model represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetHardwareModel(void); + +/** + * Obtains the bootloader version number represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBootloaderVersion(void); + +/** + * Obtains the application binary interface (Abi) list represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetAbiList(void); + +/** + * Obtains the security patch tag represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetSecurityPatchTag(void); + +/** + * Obtains the product version displayed for customer represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetDisplayVersion(void); + +/** + * Obtains the incremental version represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetIncrementalVersion(void); + +/** + * Obtains the OS release type represented by a string. + * + *

The OS release category can be {@code Release}, {@code Beta}, or {@code Canary}. + * The specific release type may be {@code Release}, {@code Beta1}, or others alike. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetOsReleaseType(void); + +/** + * Obtains the OS full version name represented by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetOSFullName(void); + +/** + * Obtains the SDK API version number. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +int OH_GetSdkApiVersion(void); + +/** + * Obtains the first API version number. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +int OH_GetFirstApiVersion(void); + +/** + * Obtains the version ID by a string. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetVersionId(void); + +/** + * Obtains the build type of the current running OS. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBuildType(void); + +/** + * Obtains the build user of the current running OS. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBuildUser(void); + +/** + * Obtains the build host of the current running OS. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBuildHost(void); + +/** + * Obtains the build time of the current running OS. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBuildTime(void); + +/** + * Obtains the version hash of the current running OS. + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetBuildRootHash(void); + +/** + * Obtains the Distribution OS name represented by a string. + * + *

Independent Software Vendor (ISV) may distribute OHOS with their own OS name. + * If ISV not specified, it will return an empty string + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetDistributionOSName(void); + +/** + * Obtains the ISV distribution OS version represented by a string. + * If ISV not specified, it will return the same value as OH_GetOSFullName + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetDistributionOSVersion(void); + +/** + * Obtains the ISV distribution OS api version represented by a integer. + * If ISV not specified, it will return the same value as OH_GetSdkApiVersion + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +int OH_GetDistributionOSApiVersion(void); + +/** + * Obtains the ISV distribution OS release type represented by a string. + * If ISV not specified, it will return the same value as OH_GetOsReleaseType + * @syscap SystemCapability.Startup.SystemInfo + * @since 10 + */ +const char *OH_GetDistributionOSReleaseType(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/startup/init/syscap/include/syscap_ndk.h b/startup/init/syscap/include/syscap_ndk.h index 070a6cb1e66afea5347295bf62258ac4b7fb7458..7d51520e3e76be6fba25f084b93de557b80e52c8 100644 --- a/startup/init/syscap/include/syscap_ndk.h +++ b/startup/init/syscap/include/syscap_ndk.h @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2022 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 SYSCAP_NDK_H -#define SYSCAP_NDK_H - -#include - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif - -bool canIUse(const char *cap); - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif +/* + * Copyright (c) 2022 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 SYSCAP_NDK_H +#define SYSCAP_NDK_H + +#include + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +bool canIUse(const char *cap); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif #endif \ No newline at end of file diff --git a/startup/init/syscap/init_sync.h b/startup/init/syscap/init_sync.h index ceeefbce390a32bf12cb49334c52fc475fced04c..b536a4da1eca773b685e092b4b17a077e908db65 100644 --- a/startup/init/syscap/init_sync.h +++ b/startup/init/syscap/init_sync.h @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2021 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 BASE_STARTUP_INITLITE_NOTIFY_H -#define BASE_STARTUP_INITLITE_NOTIFY_H - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif - -#define EVENT1 0xf -#define EVENT1_WAITTIME 10000 // 10s = 10*1000 * 1 tick(1ms) - -#define EVENT2 0xf0 -/* Define EVENT2_WAITTIME 0 means QS_STAGE2 is no used */ -#define EVENT2_WAITTIME 0 - -#define EVENT3 0xf00 -/* Define EVENT3_WAITTIME 0 means QS_STAGE3 is no used */ -#define EVENT3_WAITTIME 0 - -/* - * Notify the event to Init process. - * All processes can call. Usually called by the listened process. - * event: There needs to be a consensus between the listener(init process) and the notifier. - */ -extern int NotifyInit(unsigned long event); - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif - -#endif // BASE_STARTUP_INITLITE_NOTIFY_H +/* + * Copyright (c) 2021 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 BASE_STARTUP_INITLITE_NOTIFY_H +#define BASE_STARTUP_INITLITE_NOTIFY_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +#define EVENT1 0xf +#define EVENT1_WAITTIME 10000 // 10s = 10*1000 * 1 tick(1ms) + +#define EVENT2 0xf0 +/* Define EVENT2_WAITTIME 0 means QS_STAGE2 is no used */ +#define EVENT2_WAITTIME 0 + +#define EVENT3 0xf00 +/* Define EVENT3_WAITTIME 0 means QS_STAGE3 is no used */ +#define EVENT3_WAITTIME 0 + +/* + * Notify the event to Init process. + * All processes can call. Usually called by the listened process. + * event: There needs to be a consensus between the listener(init process) and the notifier. + */ +extern int NotifyInit(unsigned long event); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif // BASE_STARTUP_INITLITE_NOTIFY_H diff --git a/startup/init/syscap/libdeviceinfo.ndk.json b/startup/init/syscap/libdeviceinfo.ndk.json index dfed9279629410bcd503cf146c361860ba288421..42625ecd4502bcec1ccb34fc6039340469eea98e 100644 --- a/startup/init/syscap/libdeviceinfo.ndk.json +++ b/startup/init/syscap/libdeviceinfo.ndk.json @@ -1,30 +1,30 @@ -[ - {"name": "canIUse"}, - {"name": "OH_GetDeviceType"}, - {"name": "OH_GetManufacture"}, - {"name": "OH_GetBrand"}, - {"name": "OH_GetMarketName"}, - {"name": "OH_GetProductSeries"}, - {"name": "OH_GetProductModel"}, - {"name": "OH_GetSoftwareModel"}, - {"name": "OH_GetHardwareModel"}, - {"name": "OH_GetBootloaderVersion"}, - {"name": "OH_GetAbiList"}, - {"name": "OH_GetSecurityPatchTag"}, - {"name": "OH_GetDisplayVersion"}, - {"name": "OH_GetIncrementalVersion"}, - {"name": "OH_GetOsReleaseType"}, - {"name": "OH_GetOSFullName"}, - {"name": "OH_GetSdkApiVersion"}, - {"name": "OH_GetFirstApiVersion"}, - {"name": "OH_GetVersionId"}, - {"name": "OH_GetBuildType"}, - {"name": "OH_GetBuildUser"}, - {"name": "OH_GetBuildHost"}, - {"name": "OH_GetBuildTime"}, - {"name": "OH_GetBuildRootHash"}, - {"name": "OH_GetDistributionOSName"}, - {"name": "OH_GetDistributionOSVersion"}, - {"name": "OH_GetDistributionOSApiVersion"}, - {"name": "OH_GetDistributionOSReleaseType"} -] +[ + {"name": "canIUse"}, + {"name": "OH_GetDeviceType"}, + {"name": "OH_GetManufacture"}, + {"name": "OH_GetBrand"}, + {"name": "OH_GetMarketName"}, + {"name": "OH_GetProductSeries"}, + {"name": "OH_GetProductModel"}, + {"name": "OH_GetSoftwareModel"}, + {"name": "OH_GetHardwareModel"}, + {"name": "OH_GetBootloaderVersion"}, + {"name": "OH_GetAbiList"}, + {"name": "OH_GetSecurityPatchTag"}, + {"name": "OH_GetDisplayVersion"}, + {"name": "OH_GetIncrementalVersion"}, + {"name": "OH_GetOsReleaseType"}, + {"name": "OH_GetOSFullName"}, + {"name": "OH_GetSdkApiVersion"}, + {"name": "OH_GetFirstApiVersion"}, + {"name": "OH_GetVersionId"}, + {"name": "OH_GetBuildType"}, + {"name": "OH_GetBuildUser"}, + {"name": "OH_GetBuildHost"}, + {"name": "OH_GetBuildTime"}, + {"name": "OH_GetBuildRootHash"}, + {"name": "OH_GetDistributionOSName"}, + {"name": "OH_GetDistributionOSVersion"}, + {"name": "OH_GetDistributionOSApiVersion"}, + {"name": "OH_GetDistributionOSReleaseType"} +] diff --git a/third_party/libuv/BUILD.gn b/third_party/libuv/BUILD.gn index 6b4a49b2c5f1d99c61916366a3db19db305ca87a..965ddef7eb76bec00280546c89ff2fadd9062e96 100644 --- a/third_party/libuv/BUILD.gn +++ b/third_party/libuv/BUILD.gn @@ -1,375 +1,53 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -if (defined(ohos_lite)) { - import("//build/lite/config/component/lite_component.gni") - import("//build/lite/ndk/ndk.gni") - import("//third_party/libuv/libuv.gni") - - # This is the configuration needed to use libuv. - config("libuv_config") { - include_dirs = [ - "include", - "src", - "src/unix", - ] - cflags = [ - "-Wno-unused-parameter", - "-Wno-incompatible-pointer-types", - "-D_GNU_SOURCE", - "-D_POSIX_C_SOURCE=200112", - ] - - # Adding NDEBUG macro manually to avoid compilation - # error in debug version, FIX ME - # https://gitee.com/openharmony/build/pulls/1206/files - defines += [ "NDEBUG" ] - } - - # This is the configuration used to build libuv itself. - # It should not be needed outside of this library. - config("libuv_private_config") { - visibility = [ ":*" ] - include_dirs = [ - "include", - "src", - "src/unix", - ] - - # Adding NDEBUG macro manually to avoid compilation - # error in debug version, FIX ME - # https://gitee.com/openharmony/build/pulls/1206/files - defines += [ "NDEBUG" ] - } - - source_set("libuv_source") { - include_dirs = [ - "include", - "src", - "src/unix", - ] - - cflags = [ - "-Wno-unused-parameter", - "-Wno-incompatible-pointer-types", - "-D_GNU_SOURCE", - "-D_POSIX_C_SOURCE=200112", - "-U__linux__", - "-D__GNU__", - "-fPIC", - ] - - sources = [ - # common_source - "src/fs-poll.c", - "src/idna.c", - "src/inet.c", - "src/random.c", - "src/strscpy.c", - "src/threadpool.c", - "src/timer.c", - "src/uv-common.c", - "src/uv-data-getter-setters.c", - "src/version.c", - - # nonwin_srcs - "src/unix/async.c", - "src/unix/core.c", - "src/unix/dl.c", - "src/unix/epoll.c", - "src/unix/fs.c", - "src/unix/getaddrinfo.c", - "src/unix/getnameinfo.c", - "src/unix/loop-watcher.c", - "src/unix/loop.c", - "src/unix/no-fsevents.c", - "src/unix/pipe.c", - "src/unix/poll.c", - "src/unix/posix-hrtime.c", - "src/unix/posix-poll.c", - "src/unix/process.c", - "src/unix/random-devurandom.c", - "src/unix/signal.c", - "src/unix/stream.c", - "src/unix/tcp.c", - "src/unix/thread.c", - "src/unix/tty.c", - "src/unix/udp.c", - ] - } - - static_library("uv_static") { - deps = [ ":libuv_source" ] - public_configs = [ ":libuv_config" ] - } - - shared_library("uv") { - deps = [ ":libuv_source" ] - public_configs = [ ":libuv_config" ] - libs = [ - "pthread", - "dl", - ] - } -} else { - import("//build/ohos.gni") - import("//third_party/libuv/libuv.gni") - - common_source = [ - "src/fs-poll.c", - "src/idna.c", - "src/inet.c", - "src/random.c", - "src/strscpy.c", - "src/threadpool.c", - "src/timer.c", - "src/uv-common.c", - "src/uv-data-getter-setters.c", - "src/version.c", - ] - if (!is_mingw && !is_win) { - nonwin_srcs = [ - "src/unix/epoll.c", - "src/unix/async.c", - "src/unix/core.c", - "src/unix/dl.c", - "src/unix/fs.c", - "src/unix/getaddrinfo.c", - "src/unix/getnameinfo.c", - "src/unix/loop.c", - "src/unix/loop-watcher.c", - "src/unix/pipe.c", - "src/unix/poll.c", - "src/unix/process.c", - "src/unix/random-devurandom.c", - "src/unix/signal.c", - "src/unix/stream.c", - "src/unix/tcp.c", - "src/unix/thread.c", - "src/unix/tty.c", - "src/unix/udp.c", - ] - } - - # This is the configuration needed to use libuv. - config("libuv_config") { - include_dirs = [ - "include", - "src", - "src/unix", - ] - cflags = [ "-Wno-unused-parameter" ] - if (is_linux || is_ohos) { - cflags += [ - "-Wno-incompatible-pointer-types", - "-D_GNU_SOURCE", - "-D_POSIX_C_SOURCE=200112", - ] - - # Adding NDEBUG macro manually to avoid compilation - # error in debug version, FIX ME - # https://gitee.com/openharmony/build/pulls/1206/files - defines = [ "NDEBUG" ] - if (use_ffrt && is_ohos) { - defines += [ "USE_FFRT" ] - } - } else if (is_mingw || is_win) { - cflags += [ - "-Wno-missing-braces", - "-Wno-implicit-function-declaration", - "-Wno-error=return-type", - "-Wno-error=sign-compare", - "-Wno-error=unused-variable", - "-Wno-error=unknown-pragmas", - "-Wno-unused-variable", - ] - defines = [ - "WIN32_LEAN_AND_MEAN", - "_WIN32_WINNT=0x0600", - ] - - # Adding NDEBUG macro manually to avoid compilation - # error in debug version, FIX ME - # https://gitee.com/openharmony/build/pulls/1206/files - defines += [ "NDEBUG" ] - - libs = [ - "psapi", - "user32", - "advapi32", - "iphlpapi", - "userenv", - "ws2_32", - ] - } - } - - # This is the configuration used to build libuv itself. - # It should not be needed outside of this library. - config("libuv_private_config") { - visibility = [ ":*" ] - include_dirs = [ - "include", - "src", - "src/unix", - ] - - # Adding NDEBUG macro manually to avoid compilation - # error in debug version, FIX ME - # https://gitee.com/openharmony/build/pulls/1206/files - defines = [ "NDEBUG" ] - } - - ohos_source_set("libuv_source") { - configs = [ ":libuv_config" ] - sources = common_source - - if (is_mac || (defined(is_ios) && is_ios)) { - sources += nonwin_srcs + [ - "src/unix/bsd-ifaddrs.c", - "src/unix/kqueue.c", - "src/unix/random-getentropy.c", - "src/unix/darwin-proctitle.c", - "src/unix/darwin.c", - "src/unix/fsevents.c", - "src/unix/os390-proctitle.c", - ] - sources -= [ "src/unix/epoll.c" ] - } else if (is_mingw || is_win) { - sources += [ - "src/win/async.c", - "src/win/core.c", - "src/win/detect-wakeup.c", - "src/win/dl.c", - "src/win/error.c", - "src/win/fs-event.c", - "src/win/fs.c", - "src/win/getaddrinfo.c", - "src/win/getnameinfo.c", - "src/win/handle.c", - "src/win/loop-watcher.c", - "src/win/pipe.c", - "src/win/poll.c", - "src/win/process-stdio.c", - "src/win/process.c", - "src/win/signal.c", - "src/win/snprintf.c", - "src/win/stream.c", - "src/win/tcp.c", - "src/win/thread.c", - "src/win/tty.c", - "src/win/udp.c", - "src/win/util.c", - "src/win/winapi.c", - "src/win/winsock.c", - ] - } else if (is_ohos || (defined(is_android) && is_android)) { - sources += nonwin_srcs + [ - "src/unix/linux-core.c", - "src/unix/linux-inotify.c", - "src/unix/linux-syscalls.c", - "src/unix/procfs-exepath.c", - "src/unix/pthread-fixes.c", - "src/unix/random-getentropy.c", - "src/unix/random-getrandom.c", - "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", - ] - if (use_ffrt) { - external_deps = [ "ffrt:libffrt" ] - } - } else if (is_linux) { - sources += nonwin_srcs + [ - "src/unix/linux-core.c", - "src/unix/linux-inotify.c", - "src/unix/linux-syscalls.c", - "src/unix/procfs-exepath.c", - "src/unix/random-getrandom.c", - "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", - ] - } else { - sources += nonwin_srcs + [ - "src/unix/linux-core.c", - "src/unix/linux-inotify.c", - "src/unix/linux-syscalls.c", - "src/unix/procfs-exepath.c", - "src/unix/random-getrandom.c", - "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", - ] - } - subsystem_name = "thirdparty" - part_name = "libuv" - } - - ohos_static_library("uv_static") { - deps = [ ":libuv_source" ] - public_configs = [ ":libuv_config" ] - subsystem_name = "thirdparty" - part_name = "libuv" - } - ohos_shared_library("uv") { - deps = [ ":libuv_source" ] - public_configs = [ ":libuv_config" ] - subsystem_name = "thirdparty" - innerapi_tags = [ "platformsdk" ] - part_name = "libuv" - if (is_ohos) { - output_extension = "so" - } - install_images = [ - "system", - "updater", - ] - } -} - -ohos_ndk_library("libuv_ndk") { - ndk_description_file = "./libuv.ndk.json" - min_compact_version = "1" - output_name = "uv" - output_extension = "so" -} - -ohos_ndk_headers("libuv_header") { - dest_dir = "$ndk_headers_out_dir" - sources = [ "include/uv_ndk/uv.h" ] -} - -ohos_ndk_headers("libuv_uv_header") { - dest_dir = "$ndk_headers_out_dir/uv" - sources = [ - "include/uv/aix.h", - "include/uv/bsd.h", - "include/uv/darwin.h", - "include/uv/errno.h", - "include/uv/linux.h", - "include/uv/os390.h", - "include/uv/posix.h", - "include/uv/stdint-msvc2008.h", - "include/uv/sunos.h", - "include/uv/threadpool.h", - "include/uv/tree.h", - "include/uv/unix.h", - "include/uv/version.h", - "include/uv/win.h", - ] -} +# Copyright (c) 2021 Huawei Device Co., Ltd. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +import("//build/ohos.gni") + +ohos_ndk_library("libuv_ndk") { + ndk_description_file = "./libuv.ndk.json" + min_compact_version = "1" + output_name = "uv" + output_extension = "so" +} + +ohos_ndk_headers("libuv_header") { + dest_dir = "$ndk_headers_out_dir" + sources = [ "include/uv_ndk/uv.h" ] +} + +ohos_ndk_headers("libuv_uv_header") { + dest_dir = "$ndk_headers_out_dir/uv" + sources = [ + "include/uv/aix.h", + "include/uv/bsd.h", + "include/uv/darwin.h", + "include/uv/errno.h", + "include/uv/linux.h", + "include/uv/os390.h", + "include/uv/posix.h", + "include/uv/stdint-msvc2008.h", + "include/uv/sunos.h", + "include/uv/threadpool.h", + "include/uv/tree.h", + "include/uv/unix.h", + "include/uv/version.h", + "include/uv/win.h", + ] +} diff --git a/third_party/libuv/include/uv.h b/third_party/libuv/include/uv.h index bd5976730990435509cd96a35d75f06adc82c714..f17cae36f4ab2fb6a3968d4b31f5c1fd7dddaca6 100644 --- a/third_party/libuv/include/uv.h +++ b/third_party/libuv/include/uv.h @@ -1,1862 +1,1862 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) -#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */ -# define UV_EXTERN __global -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv/errno.h" -#include "uv/version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "uv/stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv/win.h" -#else -# include "uv/unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EOVERFLOW, "value too large for defined data type") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - XX(EREMOTEIO, "remote I/O error") \ - XX(ENOTTY, "inappropriate ioctl for device") \ - XX(EFTYPE, "inappropriate file type or format") \ - XX(EILSEQ, "illegal byte sequence") \ - XX(ESOCKTNOSUPPORT, "socket type not supported") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - XX(RANDOM, random) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_dir_s uv_dir_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; -typedef struct uv_random_s uv_random_t; - -/* None of the above. */ -typedef struct uv_env_item_s uv_env_item_t; -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; -typedef struct uv_utsname_s uv_utsname_t; -typedef struct uv_statfs_s uv_statfs_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL = 0, - UV_METRICS_IDLE_TIME -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN void uv_library_shutdown(void); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); -typedef void (*uv_random_cb)(uv_random_t* req, - int status, - void* buf, - size_t buflen); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); - -UV_EXTERN const char* uv_err_name(int err); -UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* reserved[6]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); -UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); -UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); -UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); -UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); - -UV_EXTERN size_t uv_req_size(uv_req_type type); -UV_EXTERN void* uv_req_get_data(const uv_req_t* req); -UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); -UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); -UV_EXTERN const char* uv_req_type_name(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - -UV_EXTERN int uv_pipe(uv_file fds[2], int read_flags, int write_flags); -UV_EXTERN int uv_socketpair(int type, - int protocol, - uv_os_sock_t socket_vector[2], - int flags0, - int flags1); - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); -UV_EXTERN int uv_try_write2(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4, - /* - * Indicates that the message was received by recvmmsg, so the buffer provided - * must not be freed by the recv_cb callback. - */ - UV_UDP_MMSG_CHUNK = 8, - /* - * Indicates that the buffer provided has been fully utilized by recvmmsg and - * that it should now be freed by the recv_cb callback. When this flag is set - * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. - */ - UV_UDP_MMSG_FREE = 16, - /* - * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle. - * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on - * Linux. This stops the Linux kernel from suppressing some ICMP error - * messages and enables full ICMP error reporting for faster failover. - * This flag is no-op on platforms other than Linux. - */ - UV_UDP_LINUX_RECVERR = 32, - /* - * Indicates that recvmmsg should be used, if available. - */ - UV_UDP_RECVMMSG = 256 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); - -UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - const char* source_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -typedef enum { - /* - * The console supports handling of virtual terminal sequences - * (Windows10 new console, ConEmu) - */ - UV_TTY_SUPPORTED, - /* The console cannot process the virtual terminal sequence. (Legacy - * console) - */ - UV_TTY_UNSUPPORTED -} uv_tty_vtermstate_t; - - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); -UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); -UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); -UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); -UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20, - - /* - * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the - * handle in non-blocking mode in the child. This may cause loss of data, - * if the child is not designed to handle to encounter this mode, - * but can also be significantly more efficient. - */ - UV_NONBLOCK_PIPE = 0x40, - UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess window that would normally be created. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), - /* - * Hide the subprocess GUI window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); -UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - -typedef enum { - uv_qos_background = 0, - uv_qos_utility = 1, - uv_qos_default = 2, - uv_qos_user_initiated = 3, -} uv_qos_t; - -UV_EXTERN int uv_queue_work_with_qos(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb, - uv_qos_t qos); - -struct uv_cpu_times_s { - uint64_t user; /* milliseconds */ - uint64_t nice; /* milliseconds */ - uint64_t sys; /* milliseconds */ - uint64_t idle; /* milliseconds */ - uint64_t irq; /* milliseconds */ -}; - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - unsigned long uid; - unsigned long gid; - char* shell; - char* homedir; -}; - -struct uv_utsname_s { - char sysname[256]; - char release[256]; - char version[256]; - char machine[256]; - /* This struct does not contain the nodename and domainname fields present in - the utsname type. domainname is a GNU extension. Both fields are referred - to as meaningless in the docs. */ -}; - -struct uv_statfs_s { - uint64_t f_type; - uint64_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_spare[4]; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); -UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - int64_t tv_sec; - int32_t tv_usec; -} uv_timeval64_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); -UV_EXTERN uv_pid_t uv_os_getpid(void); -UV_EXTERN uv_pid_t uv_os_getppid(void); - -#if defined(__PASE__) -/* On IBM i PASE, the highest process priority is -10 */ -# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ -# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ -# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ -# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ -# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ -# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ -#else -# define UV_PRIORITY_LOW 19 -# define UV_PRIORITY_BELOW_NORMAL 10 -# define UV_PRIORITY_NORMAL 0 -# define UV_PRIORITY_ABOVE_NORMAL -7 -# define UV_PRIORITY_HIGH -14 -# define UV_PRIORITY_HIGHEST -20 -#endif - -UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); -UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); - -UV_EXTERN unsigned int uv_available_parallelism(void); -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -struct uv_env_item_s { - char* name; - char* value; -}; - -UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); -UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -#ifdef MAXHOSTNAMELEN -# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) -#else - /* - Fallback for the maximum hostname size, including the null terminator. The - Windows gethostname() documentation states that 256 bytes will always be - large enough to hold the null-terminated hostname. - */ -# define UV_MAXHOSTNAMESIZE 256 -#endif - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - -UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); - -UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop); - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH, - UV_FS_COPYFILE, - UV_FS_LCHOWN, - UV_FS_OPENDIR, - UV_FS_READDIR, - UV_FS_CLOSEDIR, - UV_FS_STATFS, - UV_FS_MKSTEMP, - UV_FS_LUTIME -} uv_fs_type; - -struct uv_dir_s { - uv_dirent_t* dirents; - size_t nentries; - void* reserved[4]; - UV_DIR_PRIVATE_FIELDS -}; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); -UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); -UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*); -UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); -UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); -UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -/* - * This flag can be used with uv_fs_copyfile() to return an error if the - * destination already exists. - */ -#define UV_FS_COPYFILE_EXCL 0x0001 - -/* - * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. - * If copy-on-write is not supported, a fallback copy mechanism is used. - */ -#define UV_FS_COPYFILE_FICLONE 0x0002 - -/* - * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. - * If copy-on-write is not supported, an error is returned. - */ -#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 - -UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_opendir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, - uv_fs_t* req, - uv_dir_t* dir, - uv_fs_cb cb); -UV_EXTERN int uv_fs_closedir(uv_loop_t* loop, - uv_fs_t* req, - uv_dir_t* dir, - uv_fs_cb cb); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lutime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); -UV_EXTERN int uv_ip_name(const struct sockaddr* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - - -struct uv_random_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* private */ - int status; - void* buf; - size_t buflen; - uv_random_cb cb; - struct uv__work work_req; -}; - -UV_EXTERN int uv_random(uv_loop_t* loop, - uv_random_t* req, - void *buf, - size_t buflen, - unsigned flags, /* For future extension; must be 0. */ - uv_random_cb cb); - -#if defined(IF_NAMESIZE) -# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) -#elif defined(IFNAMSIZ) -# define UV_IF_NAMESIZE (IFNAMSIZ + 1) -#else -# define UV_IF_NAMESIZE (16 + 1) -#endif - -UV_EXTERN int uv_if_indextoname(unsigned int ifindex, - char* buffer, - size_t* size); -UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, - char* buffer, - size_t* size); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); -UV_EXTERN uint64_t uv_get_constrained_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); -UV_EXTERN void uv_sleep(unsigned int msec); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); - -typedef enum { - UV_THREAD_NO_FLAGS = 0x00, - UV_THREAD_HAS_STACK_SIZE = 0x01 -} uv_thread_create_flags; - -struct uv_thread_options_s { - unsigned int flags; - size_t stack_size; - /* More fields may be added at any time. */ -}; - -typedef struct uv_thread_options_s uv_thread_options_t; - -UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, - const uv_thread_options_t* params, - uv_thread_cb entry, - void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - union { - void* unused; - unsigned int count; - } active_reqs; - /* Internal storage for future extensions. */ - void* internal_fields; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - -UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); -UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS -#undef UV__ERR - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/* See https://github.com/libuv/libuv#documentation for documentation. */ + +#ifndef UV_H +#define UV_H +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) +#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." +#endif + +#ifdef _WIN32 + /* Windows - set up dll import/export decorators. */ +# if defined(BUILDING_UV_SHARED) + /* Building shared library. */ +# define UV_EXTERN __declspec(dllexport) +# elif defined(USING_UV_SHARED) + /* Using shared library. */ +# define UV_EXTERN __declspec(dllimport) +# else + /* Building static library. */ +# define UV_EXTERN /* nothing */ +# endif +#elif __GNUC__ >= 4 +# define UV_EXTERN __attribute__((visibility("default"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */ +# define UV_EXTERN __global +#else +# define UV_EXTERN /* nothing */ +#endif + +#include "uv/errno.h" +#include "uv/version.h" +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1600 +# include "uv/stdint-msvc2008.h" +#else +# include +#endif + +#if defined(_WIN32) +# include "uv/win.h" +#else +# include "uv/unix.h" +#endif + +/* Expand this list if necessary. */ +#define UV_ERRNO_MAP(XX) \ + XX(E2BIG, "argument list too long") \ + XX(EACCES, "permission denied") \ + XX(EADDRINUSE, "address already in use") \ + XX(EADDRNOTAVAIL, "address not available") \ + XX(EAFNOSUPPORT, "address family not supported") \ + XX(EAGAIN, "resource temporarily unavailable") \ + XX(EAI_ADDRFAMILY, "address family not supported") \ + XX(EAI_AGAIN, "temporary failure") \ + XX(EAI_BADFLAGS, "bad ai_flags value") \ + XX(EAI_BADHINTS, "invalid value for hints") \ + XX(EAI_CANCELED, "request canceled") \ + XX(EAI_FAIL, "permanent failure") \ + XX(EAI_FAMILY, "ai_family not supported") \ + XX(EAI_MEMORY, "out of memory") \ + XX(EAI_NODATA, "no address") \ + XX(EAI_NONAME, "unknown node or service") \ + XX(EAI_OVERFLOW, "argument buffer overflow") \ + XX(EAI_PROTOCOL, "resolved protocol is unknown") \ + XX(EAI_SERVICE, "service not available for socket type") \ + XX(EAI_SOCKTYPE, "socket type not supported") \ + XX(EALREADY, "connection already in progress") \ + XX(EBADF, "bad file descriptor") \ + XX(EBUSY, "resource busy or locked") \ + XX(ECANCELED, "operation canceled") \ + XX(ECHARSET, "invalid Unicode character") \ + XX(ECONNABORTED, "software caused connection abort") \ + XX(ECONNREFUSED, "connection refused") \ + XX(ECONNRESET, "connection reset by peer") \ + XX(EDESTADDRREQ, "destination address required") \ + XX(EEXIST, "file already exists") \ + XX(EFAULT, "bad address in system call argument") \ + XX(EFBIG, "file too large") \ + XX(EHOSTUNREACH, "host is unreachable") \ + XX(EINTR, "interrupted system call") \ + XX(EINVAL, "invalid argument") \ + XX(EIO, "i/o error") \ + XX(EISCONN, "socket is already connected") \ + XX(EISDIR, "illegal operation on a directory") \ + XX(ELOOP, "too many symbolic links encountered") \ + XX(EMFILE, "too many open files") \ + XX(EMSGSIZE, "message too long") \ + XX(ENAMETOOLONG, "name too long") \ + XX(ENETDOWN, "network is down") \ + XX(ENETUNREACH, "network is unreachable") \ + XX(ENFILE, "file table overflow") \ + XX(ENOBUFS, "no buffer space available") \ + XX(ENODEV, "no such device") \ + XX(ENOENT, "no such file or directory") \ + XX(ENOMEM, "not enough memory") \ + XX(ENONET, "machine is not on the network") \ + XX(ENOPROTOOPT, "protocol not available") \ + XX(ENOSPC, "no space left on device") \ + XX(ENOSYS, "function not implemented") \ + XX(ENOTCONN, "socket is not connected") \ + XX(ENOTDIR, "not a directory") \ + XX(ENOTEMPTY, "directory not empty") \ + XX(ENOTSOCK, "socket operation on non-socket") \ + XX(ENOTSUP, "operation not supported on socket") \ + XX(EOVERFLOW, "value too large for defined data type") \ + XX(EPERM, "operation not permitted") \ + XX(EPIPE, "broken pipe") \ + XX(EPROTO, "protocol error") \ + XX(EPROTONOSUPPORT, "protocol not supported") \ + XX(EPROTOTYPE, "protocol wrong type for socket") \ + XX(ERANGE, "result too large") \ + XX(EROFS, "read-only file system") \ + XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ + XX(ESPIPE, "invalid seek") \ + XX(ESRCH, "no such process") \ + XX(ETIMEDOUT, "connection timed out") \ + XX(ETXTBSY, "text file is busy") \ + XX(EXDEV, "cross-device link not permitted") \ + XX(UNKNOWN, "unknown error") \ + XX(EOF, "end of file") \ + XX(ENXIO, "no such device or address") \ + XX(EMLINK, "too many links") \ + XX(EHOSTDOWN, "host is down") \ + XX(EREMOTEIO, "remote I/O error") \ + XX(ENOTTY, "inappropriate ioctl for device") \ + XX(EFTYPE, "inappropriate file type or format") \ + XX(EILSEQ, "illegal byte sequence") \ + XX(ESOCKTNOSUPPORT, "socket type not supported") \ + +#define UV_HANDLE_TYPE_MAP(XX) \ + XX(ASYNC, async) \ + XX(CHECK, check) \ + XX(FS_EVENT, fs_event) \ + XX(FS_POLL, fs_poll) \ + XX(HANDLE, handle) \ + XX(IDLE, idle) \ + XX(NAMED_PIPE, pipe) \ + XX(POLL, poll) \ + XX(PREPARE, prepare) \ + XX(PROCESS, process) \ + XX(STREAM, stream) \ + XX(TCP, tcp) \ + XX(TIMER, timer) \ + XX(TTY, tty) \ + XX(UDP, udp) \ + XX(SIGNAL, signal) \ + +#define UV_REQ_TYPE_MAP(XX) \ + XX(REQ, req) \ + XX(CONNECT, connect) \ + XX(WRITE, write) \ + XX(SHUTDOWN, shutdown) \ + XX(UDP_SEND, udp_send) \ + XX(FS, fs) \ + XX(WORK, work) \ + XX(GETADDRINFO, getaddrinfo) \ + XX(GETNAMEINFO, getnameinfo) \ + XX(RANDOM, random) \ + +typedef enum { +#define XX(code, _) UV_ ## code = UV__ ## code, + UV_ERRNO_MAP(XX) +#undef XX + UV_ERRNO_MAX = UV__EOF - 1 +} uv_errno_t; + +typedef enum { + UV_UNKNOWN_HANDLE = 0, +#define XX(uc, lc) UV_##uc, + UV_HANDLE_TYPE_MAP(XX) +#undef XX + UV_FILE, + UV_HANDLE_TYPE_MAX +} uv_handle_type; + +typedef enum { + UV_UNKNOWN_REQ = 0, +#define XX(uc, lc) UV_##uc, + UV_REQ_TYPE_MAP(XX) +#undef XX + UV_REQ_TYPE_PRIVATE + UV_REQ_TYPE_MAX +} uv_req_type; + + +/* Handle types. */ +typedef struct uv_loop_s uv_loop_t; +typedef struct uv_handle_s uv_handle_t; +typedef struct uv_dir_s uv_dir_t; +typedef struct uv_stream_s uv_stream_t; +typedef struct uv_tcp_s uv_tcp_t; +typedef struct uv_udp_s uv_udp_t; +typedef struct uv_pipe_s uv_pipe_t; +typedef struct uv_tty_s uv_tty_t; +typedef struct uv_poll_s uv_poll_t; +typedef struct uv_timer_s uv_timer_t; +typedef struct uv_prepare_s uv_prepare_t; +typedef struct uv_check_s uv_check_t; +typedef struct uv_idle_s uv_idle_t; +typedef struct uv_async_s uv_async_t; +typedef struct uv_process_s uv_process_t; +typedef struct uv_fs_event_s uv_fs_event_t; +typedef struct uv_fs_poll_s uv_fs_poll_t; +typedef struct uv_signal_s uv_signal_t; + +/* Request types. */ +typedef struct uv_req_s uv_req_t; +typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; +typedef struct uv_getnameinfo_s uv_getnameinfo_t; +typedef struct uv_shutdown_s uv_shutdown_t; +typedef struct uv_write_s uv_write_t; +typedef struct uv_connect_s uv_connect_t; +typedef struct uv_udp_send_s uv_udp_send_t; +typedef struct uv_fs_s uv_fs_t; +typedef struct uv_work_s uv_work_t; +typedef struct uv_random_s uv_random_t; + +/* None of the above. */ +typedef struct uv_env_item_s uv_env_item_t; +typedef struct uv_cpu_info_s uv_cpu_info_t; +typedef struct uv_interface_address_s uv_interface_address_t; +typedef struct uv_dirent_s uv_dirent_t; +typedef struct uv_passwd_s uv_passwd_t; +typedef struct uv_utsname_s uv_utsname_t; +typedef struct uv_statfs_s uv_statfs_t; + +typedef enum { + UV_LOOP_BLOCK_SIGNAL = 0, + UV_METRICS_IDLE_TIME +} uv_loop_option; + +typedef enum { + UV_RUN_DEFAULT = 0, + UV_RUN_ONCE, + UV_RUN_NOWAIT +} uv_run_mode; + + +UV_EXTERN unsigned int uv_version(void); +UV_EXTERN const char* uv_version_string(void); + +typedef void* (*uv_malloc_func)(size_t size); +typedef void* (*uv_realloc_func)(void* ptr, size_t size); +typedef void* (*uv_calloc_func)(size_t count, size_t size); +typedef void (*uv_free_func)(void* ptr); + +UV_EXTERN void uv_library_shutdown(void); + +UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, + uv_realloc_func realloc_func, + uv_calloc_func calloc_func, + uv_free_func free_func); + +UV_EXTERN uv_loop_t* uv_default_loop(void); +UV_EXTERN int uv_loop_init(uv_loop_t* loop); +UV_EXTERN int uv_loop_close(uv_loop_t* loop); +/* + * NOTE: + * This function is DEPRECATED (to be removed after 0.12), users should + * allocate the loop manually and use uv_loop_init instead. + */ +UV_EXTERN uv_loop_t* uv_loop_new(void); +/* + * NOTE: + * This function is DEPRECATED (to be removed after 0.12). Users should use + * uv_loop_close and free the memory manually instead. + */ +UV_EXTERN void uv_loop_delete(uv_loop_t*); +UV_EXTERN size_t uv_loop_size(void); +UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); +UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); +UV_EXTERN int uv_loop_fork(uv_loop_t* loop); + +UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); +UV_EXTERN void uv_stop(uv_loop_t*); + +UV_EXTERN void uv_ref(uv_handle_t*); +UV_EXTERN void uv_unref(uv_handle_t*); +UV_EXTERN int uv_has_ref(const uv_handle_t*); + +UV_EXTERN void uv_update_time(uv_loop_t*); +UV_EXTERN uint64_t uv_now(const uv_loop_t*); + +UV_EXTERN int uv_backend_fd(const uv_loop_t*); +UV_EXTERN int uv_backend_timeout(const uv_loop_t*); + +typedef void (*uv_alloc_cb)(uv_handle_t* handle, + size_t suggested_size, + uv_buf_t* buf); +typedef void (*uv_read_cb)(uv_stream_t* stream, + ssize_t nread, + const uv_buf_t* buf); +typedef void (*uv_write_cb)(uv_write_t* req, int status); +typedef void (*uv_connect_cb)(uv_connect_t* req, int status); +typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); +typedef void (*uv_connection_cb)(uv_stream_t* server, int status); +typedef void (*uv_close_cb)(uv_handle_t* handle); +typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); +typedef void (*uv_timer_cb)(uv_timer_t* handle); +typedef void (*uv_async_cb)(uv_async_t* handle); +typedef void (*uv_prepare_cb)(uv_prepare_t* handle); +typedef void (*uv_check_cb)(uv_check_t* handle); +typedef void (*uv_idle_cb)(uv_idle_t* handle); +typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); +typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); +typedef void (*uv_fs_cb)(uv_fs_t* req); +typedef void (*uv_work_cb)(uv_work_t* req); +typedef void (*uv_after_work_cb)(uv_work_t* req, int status); +typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, + int status, + struct addrinfo* res); +typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, + int status, + const char* hostname, + const char* service); +typedef void (*uv_random_cb)(uv_random_t* req, + int status, + void* buf, + size_t buflen); + +typedef struct { + long tv_sec; + long tv_nsec; +} uv_timespec_t; + + +typedef struct { + uint64_t st_dev; + uint64_t st_mode; + uint64_t st_nlink; + uint64_t st_uid; + uint64_t st_gid; + uint64_t st_rdev; + uint64_t st_ino; + uint64_t st_size; + uint64_t st_blksize; + uint64_t st_blocks; + uint64_t st_flags; + uint64_t st_gen; + uv_timespec_t st_atim; + uv_timespec_t st_mtim; + uv_timespec_t st_ctim; + uv_timespec_t st_birthtim; +} uv_stat_t; + + +typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, + const char* filename, + int events, + int status); + +typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, + int status, + const uv_stat_t* prev, + const uv_stat_t* curr); + +typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); + + +typedef enum { + UV_LEAVE_GROUP = 0, + UV_JOIN_GROUP +} uv_membership; + + +UV_EXTERN int uv_translate_sys_error(int sys_errno); + +UV_EXTERN const char* uv_strerror(int err); +UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); + +UV_EXTERN const char* uv_err_name(int err); +UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); + + +#define UV_REQ_FIELDS \ + /* public */ \ + void* data; \ + /* read-only */ \ + uv_req_type type; \ + /* private */ \ + void* reserved[6]; \ + UV_REQ_PRIVATE_FIELDS \ + +/* Abstract base class of all requests. */ +struct uv_req_s { + UV_REQ_FIELDS +}; + + +/* Platform-specific request types. */ +UV_PRIVATE_REQ_TYPES + + +UV_EXTERN int uv_shutdown(uv_shutdown_t* req, + uv_stream_t* handle, + uv_shutdown_cb cb); + +struct uv_shutdown_s { + UV_REQ_FIELDS + uv_stream_t* handle; + uv_shutdown_cb cb; + UV_SHUTDOWN_PRIVATE_FIELDS +}; + + +#define UV_HANDLE_FIELDS \ + /* public */ \ + void* data; \ + /* read-only */ \ + uv_loop_t* loop; \ + uv_handle_type type; \ + /* private */ \ + uv_close_cb close_cb; \ + void* handle_queue[2]; \ + union { \ + int fd; \ + void* reserved[4]; \ + } u; \ + UV_HANDLE_PRIVATE_FIELDS \ + +/* The abstract base class of all handles. */ +struct uv_handle_s { + UV_HANDLE_FIELDS +}; + +UV_EXTERN size_t uv_handle_size(uv_handle_type type); +UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); +UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); +UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); +UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); +UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); + +UV_EXTERN size_t uv_req_size(uv_req_type type); +UV_EXTERN void* uv_req_get_data(const uv_req_t* req); +UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); +UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); +UV_EXTERN const char* uv_req_type_name(uv_req_type type); + +UV_EXTERN int uv_is_active(const uv_handle_t* handle); + +UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); + +/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ +UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); +UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); + +UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); + +UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); +UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); + +UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); + +UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); + +UV_EXTERN int uv_pipe(uv_file fds[2], int read_flags, int write_flags); +UV_EXTERN int uv_socketpair(int type, + int protocol, + uv_os_sock_t socket_vector[2], + int flags0, + int flags1); + +#define UV_STREAM_FIELDS \ + /* number of bytes queued for writing */ \ + size_t write_queue_size; \ + uv_alloc_cb alloc_cb; \ + uv_read_cb read_cb; \ + /* private */ \ + UV_STREAM_PRIVATE_FIELDS + +/* + * uv_stream_t is a subclass of uv_handle_t. + * + * uv_stream is an abstract class. + * + * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. + */ +struct uv_stream_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS +}; + +UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); + +UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); +UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); + +UV_EXTERN int uv_read_start(uv_stream_t*, + uv_alloc_cb alloc_cb, + uv_read_cb read_cb); +UV_EXTERN int uv_read_stop(uv_stream_t*); + +UV_EXTERN int uv_write(uv_write_t* req, + uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + uv_write_cb cb); +UV_EXTERN int uv_write2(uv_write_t* req, + uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + uv_stream_t* send_handle, + uv_write_cb cb); +UV_EXTERN int uv_try_write(uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs); +UV_EXTERN int uv_try_write2(uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + uv_stream_t* send_handle); + +/* uv_write_t is a subclass of uv_req_t. */ +struct uv_write_s { + UV_REQ_FIELDS + uv_write_cb cb; + uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ + uv_stream_t* handle; + UV_WRITE_PRIVATE_FIELDS +}; + + +UV_EXTERN int uv_is_readable(const uv_stream_t* handle); +UV_EXTERN int uv_is_writable(const uv_stream_t* handle); + +UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); + +UV_EXTERN int uv_is_closing(const uv_handle_t* handle); + + +/* + * uv_tcp_t is a subclass of uv_stream_t. + * + * Represents a TCP stream or TCP server. + */ +struct uv_tcp_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + UV_TCP_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); +UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); +UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); +UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); +UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, + int enable, + unsigned int delay); +UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); + +enum uv_tcp_flags { + /* Used with uv_tcp_bind, when an IPv6 address is used. */ + UV_TCP_IPV6ONLY = 1 +}; + +UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, + const struct sockaddr* addr, + unsigned int flags); +UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); +UV_EXTERN int uv_tcp_connect(uv_connect_t* req, + uv_tcp_t* handle, + const struct sockaddr* addr, + uv_connect_cb cb); + +/* uv_connect_t is a subclass of uv_req_t. */ +struct uv_connect_s { + UV_REQ_FIELDS + uv_connect_cb cb; + uv_stream_t* handle; + UV_CONNECT_PRIVATE_FIELDS +}; + + +/* + * UDP support. + */ + +enum uv_udp_flags { + /* Disables dual stack mode. */ + UV_UDP_IPV6ONLY = 1, + /* + * Indicates message was truncated because read buffer was too small. The + * remainder was discarded by the OS. Used in uv_udp_recv_cb. + */ + UV_UDP_PARTIAL = 2, + /* + * Indicates if SO_REUSEADDR will be set when binding the handle. + * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other + * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that + * multiple threads or processes can bind to the same address without error + * (provided they all set the flag) but only the last one to bind will receive + * any traffic, in effect "stealing" the port from the previous listener. + */ + UV_UDP_REUSEADDR = 4, + /* + * Indicates that the message was received by recvmmsg, so the buffer provided + * must not be freed by the recv_cb callback. + */ + UV_UDP_MMSG_CHUNK = 8, + /* + * Indicates that the buffer provided has been fully utilized by recvmmsg and + * that it should now be freed by the recv_cb callback. When this flag is set + * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. + */ + UV_UDP_MMSG_FREE = 16, + /* + * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle. + * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on + * Linux. This stops the Linux kernel from suppressing some ICMP error + * messages and enables full ICMP error reporting for faster failover. + * This flag is no-op on platforms other than Linux. + */ + UV_UDP_LINUX_RECVERR = 32, + /* + * Indicates that recvmmsg should be used, if available. + */ + UV_UDP_RECVMMSG = 256 +}; + +typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); +typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, + ssize_t nread, + const uv_buf_t* buf, + const struct sockaddr* addr, + unsigned flags); + +/* uv_udp_t is a subclass of uv_handle_t. */ +struct uv_udp_s { + UV_HANDLE_FIELDS + /* read-only */ + /* + * Number of bytes queued for sending. This field strictly shows how much + * information is currently queued. + */ + size_t send_queue_size; + /* + * Number of send requests currently in the queue awaiting to be processed. + */ + size_t send_queue_count; + UV_UDP_PRIVATE_FIELDS +}; + +/* uv_udp_send_t is a subclass of uv_req_t. */ +struct uv_udp_send_s { + UV_REQ_FIELDS + uv_udp_t* handle; + uv_udp_send_cb cb; + UV_UDP_SEND_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); +UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); +UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); +UV_EXTERN int uv_udp_bind(uv_udp_t* handle, + const struct sockaddr* addr, + unsigned int flags); +UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); + +UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, + const char* multicast_addr, + const char* interface_addr, + uv_membership membership); +UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, + const char* multicast_addr, + const char* interface_addr, + const char* source_addr, + uv_membership membership); +UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); +UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); +UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, + const char* interface_addr); +UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); +UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); +UV_EXTERN int uv_udp_send(uv_udp_send_t* req, + uv_udp_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + const struct sockaddr* addr, + uv_udp_send_cb send_cb); +UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + const struct sockaddr* addr); +UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, + uv_alloc_cb alloc_cb, + uv_udp_recv_cb recv_cb); +UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle); +UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); +UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); +UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); + + +/* + * uv_tty_t is a subclass of uv_stream_t. + * + * Representing a stream for the console. + */ +struct uv_tty_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + UV_TTY_PRIVATE_FIELDS +}; + +typedef enum { + /* Initial/normal terminal mode */ + UV_TTY_MODE_NORMAL, + /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ + UV_TTY_MODE_RAW, + /* Binary-safe I/O mode for IPC (Unix-only) */ + UV_TTY_MODE_IO +} uv_tty_mode_t; + +typedef enum { + /* + * The console supports handling of virtual terminal sequences + * (Windows10 new console, ConEmu) + */ + UV_TTY_SUPPORTED, + /* The console cannot process the virtual terminal sequence. (Legacy + * console) + */ + UV_TTY_UNSUPPORTED +} uv_tty_vtermstate_t; + + +UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); +UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); +UV_EXTERN int uv_tty_reset_mode(void); +UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); +UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); +UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); + +#ifdef __cplusplus +extern "C++" { + +inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { + return uv_tty_set_mode(handle, static_cast(mode)); +} + +} +#endif + +UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); + +/* + * uv_pipe_t is a subclass of uv_stream_t. + * + * Representing a pipe stream or pipe server. On Windows this is a Named + * Pipe. On Unix this is a Unix domain socket. + */ +struct uv_pipe_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + int ipc; /* non-zero if this pipe is used for passing handles */ + UV_PIPE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); +UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); +UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); +UV_EXTERN void uv_pipe_connect(uv_connect_t* req, + uv_pipe_t* handle, + const char* name, + uv_connect_cb cb); +UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, + char* buffer, + size_t* size); +UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, + char* buffer, + size_t* size); +UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); +UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); +UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); +UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); + + +struct uv_poll_s { + UV_HANDLE_FIELDS + uv_poll_cb poll_cb; + UV_POLL_PRIVATE_FIELDS +}; + +enum uv_poll_event { + UV_READABLE = 1, + UV_WRITABLE = 2, + UV_DISCONNECT = 4, + UV_PRIORITIZED = 8 +}; + +UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); +UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, + uv_poll_t* handle, + uv_os_sock_t socket); +UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); +UV_EXTERN int uv_poll_stop(uv_poll_t* handle); + + +struct uv_prepare_s { + UV_HANDLE_FIELDS + UV_PREPARE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); +UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); +UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); + + +struct uv_check_s { + UV_HANDLE_FIELDS + UV_CHECK_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); +UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); +UV_EXTERN int uv_check_stop(uv_check_t* check); + + +struct uv_idle_s { + UV_HANDLE_FIELDS + UV_IDLE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); +UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); +UV_EXTERN int uv_idle_stop(uv_idle_t* idle); + + +struct uv_async_s { + UV_HANDLE_FIELDS + UV_ASYNC_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_async_init(uv_loop_t*, + uv_async_t* async, + uv_async_cb async_cb); +UV_EXTERN int uv_async_send(uv_async_t* async); + + +/* + * uv_timer_t is a subclass of uv_handle_t. + * + * Used to get woken up at a specified time in the future. + */ +struct uv_timer_s { + UV_HANDLE_FIELDS + UV_TIMER_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); +UV_EXTERN int uv_timer_start(uv_timer_t* handle, + uv_timer_cb cb, + uint64_t timeout, + uint64_t repeat); +UV_EXTERN int uv_timer_stop(uv_timer_t* handle); +UV_EXTERN int uv_timer_again(uv_timer_t* handle); +UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); +UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); +UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle); + + +/* + * uv_getaddrinfo_t is a subclass of uv_req_t. + * + * Request object for uv_getaddrinfo. + */ +struct uv_getaddrinfo_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ + UV_GETADDRINFO_PRIVATE_FIELDS +}; + + +UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, + uv_getaddrinfo_t* req, + uv_getaddrinfo_cb getaddrinfo_cb, + const char* node, + const char* service, + const struct addrinfo* hints); +UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); + + +/* +* uv_getnameinfo_t is a subclass of uv_req_t. +* +* Request object for uv_getnameinfo. +*/ +struct uv_getnameinfo_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* host and service are marked as private, but they really aren't. */ + UV_GETNAMEINFO_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, + uv_getnameinfo_t* req, + uv_getnameinfo_cb getnameinfo_cb, + const struct sockaddr* addr, + int flags); + + +/* uv_spawn() options. */ +typedef enum { + UV_IGNORE = 0x00, + UV_CREATE_PIPE = 0x01, + UV_INHERIT_FD = 0x02, + UV_INHERIT_STREAM = 0x04, + + /* + * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE + * determine the direction of flow, from the child process' perspective. Both + * flags may be specified to create a duplex data stream. + */ + UV_READABLE_PIPE = 0x10, + UV_WRITABLE_PIPE = 0x20, + + /* + * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the + * handle in non-blocking mode in the child. This may cause loss of data, + * if the child is not designed to handle to encounter this mode, + * but can also be significantly more efficient. + */ + UV_NONBLOCK_PIPE = 0x40, + UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ +} uv_stdio_flags; + +typedef struct uv_stdio_container_s { + uv_stdio_flags flags; + + union { + uv_stream_t* stream; + int fd; + } data; +} uv_stdio_container_t; + +typedef struct uv_process_options_s { + uv_exit_cb exit_cb; /* Called after the process exits. */ + const char* file; /* Path to program to execute. */ + /* + * Command line arguments. args[0] should be the path to the program. On + * Windows this uses CreateProcess which concatenates the arguments into a + * string this can cause some strange errors. See the note at + * windows_verbatim_arguments. + */ + char** args; + /* + * This will be set as the environ variable in the subprocess. If this is + * NULL then the parents environ will be used. + */ + char** env; + /* + * If non-null this represents a directory the subprocess should execute + * in. Stands for current working directory. + */ + const char* cwd; + /* + * Various flags that control how uv_spawn() behaves. See the definition of + * `enum uv_process_flags` below. + */ + unsigned int flags; + /* + * The `stdio` field points to an array of uv_stdio_container_t structs that + * describe the file descriptors that will be made available to the child + * process. The convention is that stdio[0] points to stdin, fd 1 is used for + * stdout, and fd 2 is stderr. + * + * Note that on windows file descriptors greater than 2 are available to the + * child process only if the child processes uses the MSVCRT runtime. + */ + int stdio_count; + uv_stdio_container_t* stdio; + /* + * Libuv can change the child process' user/group id. This happens only when + * the appropriate bits are set in the flags fields. This is not supported on + * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. + */ + uv_uid_t uid; + uv_gid_t gid; +} uv_process_options_t; + +/* + * These are the flags that can be used for the uv_process_options.flags field. + */ +enum uv_process_flags { + /* + * Set the child process' user id. The user id is supplied in the `uid` field + * of the options struct. This does not work on windows; setting this flag + * will cause uv_spawn() to fail. + */ + UV_PROCESS_SETUID = (1 << 0), + /* + * Set the child process' group id. The user id is supplied in the `gid` + * field of the options struct. This does not work on windows; setting this + * flag will cause uv_spawn() to fail. + */ + UV_PROCESS_SETGID = (1 << 1), + /* + * Do not wrap any arguments in quotes, or perform any other escaping, when + * converting the argument list into a command line string. This option is + * only meaningful on Windows systems. On Unix it is silently ignored. + */ + UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), + /* + * Spawn the child process in a detached state - this will make it a process + * group leader, and will effectively enable the child to keep running after + * the parent exits. Note that the child process will still keep the + * parent's event loop alive unless the parent process calls uv_unref() on + * the child's process handle. + */ + UV_PROCESS_DETACHED = (1 << 3), + /* + * Hide the subprocess window that would normally be created. This option is + * only meaningful on Windows systems. On Unix it is silently ignored. + */ + UV_PROCESS_WINDOWS_HIDE = (1 << 4), + /* + * Hide the subprocess console window that would normally be created. This + * option is only meaningful on Windows systems. On Unix it is silently + * ignored. + */ + UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), + /* + * Hide the subprocess GUI window that would normally be created. This + * option is only meaningful on Windows systems. On Unix it is silently + * ignored. + */ + UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) +}; + +/* + * uv_process_t is a subclass of uv_handle_t. + */ +struct uv_process_s { + UV_HANDLE_FIELDS + uv_exit_cb exit_cb; + int pid; + UV_PROCESS_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_spawn(uv_loop_t* loop, + uv_process_t* handle, + const uv_process_options_t* options); +UV_EXTERN int uv_process_kill(uv_process_t*, int signum); +UV_EXTERN int uv_kill(int pid, int signum); +UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); + + +/* + * uv_work_t is a subclass of uv_req_t. + */ +struct uv_work_s { + UV_REQ_FIELDS + uv_loop_t* loop; + uv_work_cb work_cb; + uv_after_work_cb after_work_cb; + UV_WORK_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_queue_work(uv_loop_t* loop, + uv_work_t* req, + uv_work_cb work_cb, + uv_after_work_cb after_work_cb); + +UV_EXTERN int uv_cancel(uv_req_t* req); + +typedef enum { + uv_qos_background = 0, + uv_qos_utility = 1, + uv_qos_default = 2, + uv_qos_user_initiated = 3, +} uv_qos_t; + +UV_EXTERN int uv_queue_work_with_qos(uv_loop_t* loop, + uv_work_t* req, + uv_work_cb work_cb, + uv_after_work_cb after_work_cb, + uv_qos_t qos); + +struct uv_cpu_times_s { + uint64_t user; /* milliseconds */ + uint64_t nice; /* milliseconds */ + uint64_t sys; /* milliseconds */ + uint64_t idle; /* milliseconds */ + uint64_t irq; /* milliseconds */ +}; + +struct uv_cpu_info_s { + char* model; + int speed; + struct uv_cpu_times_s cpu_times; +}; + +struct uv_interface_address_s { + char* name; + char phys_addr[6]; + int is_internal; + union { + struct sockaddr_in address4; + struct sockaddr_in6 address6; + } address; + union { + struct sockaddr_in netmask4; + struct sockaddr_in6 netmask6; + } netmask; +}; + +struct uv_passwd_s { + char* username; + unsigned long uid; + unsigned long gid; + char* shell; + char* homedir; +}; + +struct uv_utsname_s { + char sysname[256]; + char release[256]; + char version[256]; + char machine[256]; + /* This struct does not contain the nodename and domainname fields present in + the utsname type. domainname is a GNU extension. Both fields are referred + to as meaningless in the docs. */ +}; + +struct uv_statfs_s { + uint64_t f_type; + uint64_t f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + uint64_t f_spare[4]; +}; + +typedef enum { + UV_DIRENT_UNKNOWN, + UV_DIRENT_FILE, + UV_DIRENT_DIR, + UV_DIRENT_LINK, + UV_DIRENT_FIFO, + UV_DIRENT_SOCKET, + UV_DIRENT_CHAR, + UV_DIRENT_BLOCK +} uv_dirent_type_t; + +struct uv_dirent_s { + const char* name; + uv_dirent_type_t type; +}; + +UV_EXTERN char** uv_setup_args(int argc, char** argv); +UV_EXTERN int uv_get_process_title(char* buffer, size_t size); +UV_EXTERN int uv_set_process_title(const char* title); +UV_EXTERN int uv_resident_set_memory(size_t* rss); +UV_EXTERN int uv_uptime(double* uptime); +UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); +UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); + +typedef struct { + long tv_sec; + long tv_usec; +} uv_timeval_t; + +typedef struct { + int64_t tv_sec; + int32_t tv_usec; +} uv_timeval64_t; + +typedef struct { + uv_timeval_t ru_utime; /* user CPU time used */ + uv_timeval_t ru_stime; /* system CPU time used */ + uint64_t ru_maxrss; /* maximum resident set size */ + uint64_t ru_ixrss; /* integral shared memory size */ + uint64_t ru_idrss; /* integral unshared data size */ + uint64_t ru_isrss; /* integral unshared stack size */ + uint64_t ru_minflt; /* page reclaims (soft page faults) */ + uint64_t ru_majflt; /* page faults (hard page faults) */ + uint64_t ru_nswap; /* swaps */ + uint64_t ru_inblock; /* block input operations */ + uint64_t ru_oublock; /* block output operations */ + uint64_t ru_msgsnd; /* IPC messages sent */ + uint64_t ru_msgrcv; /* IPC messages received */ + uint64_t ru_nsignals; /* signals received */ + uint64_t ru_nvcsw; /* voluntary context switches */ + uint64_t ru_nivcsw; /* involuntary context switches */ +} uv_rusage_t; + +UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); + +UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); +UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); +UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); +UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); +UV_EXTERN uv_pid_t uv_os_getpid(void); +UV_EXTERN uv_pid_t uv_os_getppid(void); + +#if defined(__PASE__) +/* On IBM i PASE, the highest process priority is -10 */ +# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ +# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ +# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ +# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ +# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ +# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ +#else +# define UV_PRIORITY_LOW 19 +# define UV_PRIORITY_BELOW_NORMAL 10 +# define UV_PRIORITY_NORMAL 0 +# define UV_PRIORITY_ABOVE_NORMAL -7 +# define UV_PRIORITY_HIGH -14 +# define UV_PRIORITY_HIGHEST -20 +#endif + +UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); +UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); + +UV_EXTERN unsigned int uv_available_parallelism(void); +UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); +UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); + +UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, + int* count); +UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, + int count); + +struct uv_env_item_s { + char* name; + char* value; +}; + +UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); +UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); +UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); +UV_EXTERN int uv_os_setenv(const char* name, const char* value); +UV_EXTERN int uv_os_unsetenv(const char* name); + +#ifdef MAXHOSTNAMELEN +# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) +#else + /* + Fallback for the maximum hostname size, including the null terminator. The + Windows gethostname() documentation states that 256 bytes will always be + large enough to hold the null-terminated hostname. + */ +# define UV_MAXHOSTNAMESIZE 256 +#endif + +UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); + +UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); + +UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop); + +typedef enum { + UV_FS_UNKNOWN = -1, + UV_FS_CUSTOM, + UV_FS_OPEN, + UV_FS_CLOSE, + UV_FS_READ, + UV_FS_WRITE, + UV_FS_SENDFILE, + UV_FS_STAT, + UV_FS_LSTAT, + UV_FS_FSTAT, + UV_FS_FTRUNCATE, + UV_FS_UTIME, + UV_FS_FUTIME, + UV_FS_ACCESS, + UV_FS_CHMOD, + UV_FS_FCHMOD, + UV_FS_FSYNC, + UV_FS_FDATASYNC, + UV_FS_UNLINK, + UV_FS_RMDIR, + UV_FS_MKDIR, + UV_FS_MKDTEMP, + UV_FS_RENAME, + UV_FS_SCANDIR, + UV_FS_LINK, + UV_FS_SYMLINK, + UV_FS_READLINK, + UV_FS_CHOWN, + UV_FS_FCHOWN, + UV_FS_REALPATH, + UV_FS_COPYFILE, + UV_FS_LCHOWN, + UV_FS_OPENDIR, + UV_FS_READDIR, + UV_FS_CLOSEDIR, + UV_FS_STATFS, + UV_FS_MKSTEMP, + UV_FS_LUTIME +} uv_fs_type; + +struct uv_dir_s { + uv_dirent_t* dirents; + size_t nentries; + void* reserved[4]; + UV_DIR_PRIVATE_FIELDS +}; + +/* uv_fs_t is a subclass of uv_req_t. */ +struct uv_fs_s { + UV_REQ_FIELDS + uv_fs_type fs_type; + uv_loop_t* loop; + uv_fs_cb cb; + ssize_t result; + void* ptr; + const char* path; + uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ + UV_FS_PRIVATE_FIELDS +}; + +UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); +UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); +UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*); +UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); +UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); +UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); + +UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); +UV_EXTERN int uv_fs_close(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_open(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_read(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t offset, + uv_fs_cb cb); +UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_write(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t offset, + uv_fs_cb cb); +/* + * This flag can be used with uv_fs_copyfile() to return an error if the + * destination already exists. + */ +#define UV_FS_COPYFILE_EXCL 0x0001 + +/* + * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. + * If copy-on-write is not supported, a fallback copy mechanism is used. + */ +#define UV_FS_COPYFILE_FICLONE 0x0002 + +/* + * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. + * If copy-on-write is not supported, an error is returned. + */ +#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 + +UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); +UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, + uv_dirent_t* ent); +UV_EXTERN int uv_fs_opendir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, + uv_fs_t* req, + uv_dir_t* dir, + uv_fs_cb cb); +UV_EXTERN int uv_fs_closedir(uv_loop_t* loop, + uv_fs_t* req, + uv_dir_t* dir, + uv_fs_cb cb); +UV_EXTERN int uv_fs_stat(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_rename(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int64_t offset, + uv_fs_cb cb); +UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, + uv_fs_t* req, + uv_file out_fd, + uv_file in_fd, + int64_t in_offset, + size_t length, + uv_fs_cb cb); +UV_EXTERN int uv_fs_access(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_utime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb); +UV_EXTERN int uv_fs_futime(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + double atime, + double mtime, + uv_fs_cb cb); +UV_EXTERN int uv_fs_lutime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb); +UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_link(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb); + +/* + * This flag can be used with uv_fs_symlink() on Windows to specify whether + * path argument points to a directory. + */ +#define UV_FS_SYMLINK_DIR 0x0001 + +/* + * This flag can be used with uv_fs_symlink() on Windows to specify whether + * the symlink is to be created using junction points. + */ +#define UV_FS_SYMLINK_JUNCTION 0x0002 + +UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_chown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); + + +enum uv_fs_event { + UV_RENAME = 1, + UV_CHANGE = 2 +}; + + +struct uv_fs_event_s { + UV_HANDLE_FIELDS + /* private */ + char* path; + UV_FS_EVENT_PRIVATE_FIELDS +}; + + +/* + * uv_fs_stat() based polling file watcher. + */ +struct uv_fs_poll_s { + UV_HANDLE_FIELDS + /* Private, don't touch. */ + void* poll_ctx; +}; + +UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); +UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, + uv_fs_poll_cb poll_cb, + const char* path, + unsigned int interval); +UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); +UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, + char* buffer, + size_t* size); + + +struct uv_signal_s { + UV_HANDLE_FIELDS + uv_signal_cb signal_cb; + int signum; + UV_SIGNAL_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); +UV_EXTERN int uv_signal_start(uv_signal_t* handle, + uv_signal_cb signal_cb, + int signum); +UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, + uv_signal_cb signal_cb, + int signum); +UV_EXTERN int uv_signal_stop(uv_signal_t* handle); + +UV_EXTERN void uv_loadavg(double avg[3]); + + +/* + * Flags to be passed to uv_fs_event_start(). + */ +enum uv_fs_event_flags { + /* + * By default, if the fs event watcher is given a directory name, we will + * watch for all events in that directory. This flags overrides this behavior + * and makes fs_event report only changes to the directory entry itself. This + * flag does not affect individual files watched. + * This flag is currently not implemented yet on any backend. + */ + UV_FS_EVENT_WATCH_ENTRY = 1, + + /* + * By default uv_fs_event will try to use a kernel interface such as inotify + * or kqueue to detect events. This may not work on remote filesystems such + * as NFS mounts. This flag makes fs_event fall back to calling stat() on a + * regular interval. + * This flag is currently not implemented yet on any backend. + */ + UV_FS_EVENT_STAT = 2, + + /* + * By default, event watcher, when watching directory, is not registering + * (is ignoring) changes in it's subdirectories. + * This flag will override this behaviour on platforms that support it. + */ + UV_FS_EVENT_RECURSIVE = 4 +}; + + +UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); +UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, + uv_fs_event_cb cb, + const char* path, + unsigned int flags); +UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); +UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, + char* buffer, + size_t* size); + +UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); +UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); + +UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); +UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); +UV_EXTERN int uv_ip_name(const struct sockaddr* src, char* dst, size_t size); + +UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); +UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); + + +struct uv_random_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* private */ + int status; + void* buf; + size_t buflen; + uv_random_cb cb; + struct uv__work work_req; +}; + +UV_EXTERN int uv_random(uv_loop_t* loop, + uv_random_t* req, + void *buf, + size_t buflen, + unsigned flags, /* For future extension; must be 0. */ + uv_random_cb cb); + +#if defined(IF_NAMESIZE) +# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) +#elif defined(IFNAMSIZ) +# define UV_IF_NAMESIZE (IFNAMSIZ + 1) +#else +# define UV_IF_NAMESIZE (16 + 1) +#endif + +UV_EXTERN int uv_if_indextoname(unsigned int ifindex, + char* buffer, + size_t* size); +UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, + char* buffer, + size_t* size); + +UV_EXTERN int uv_exepath(char* buffer, size_t* size); + +UV_EXTERN int uv_cwd(char* buffer, size_t* size); + +UV_EXTERN int uv_chdir(const char* dir); + +UV_EXTERN uint64_t uv_get_free_memory(void); +UV_EXTERN uint64_t uv_get_total_memory(void); +UV_EXTERN uint64_t uv_get_constrained_memory(void); + +UV_EXTERN uint64_t uv_hrtime(void); +UV_EXTERN void uv_sleep(unsigned int msec); + +UV_EXTERN void uv_disable_stdio_inheritance(void); + +UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); +UV_EXTERN void uv_dlclose(uv_lib_t* lib); +UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); +UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); + +UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); +UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); +UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); + +UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); +UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); +UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); + +UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); +UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); +UV_EXTERN void uv_sem_post(uv_sem_t* sem); +UV_EXTERN void uv_sem_wait(uv_sem_t* sem); +UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); + +UV_EXTERN int uv_cond_init(uv_cond_t* cond); +UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); +UV_EXTERN void uv_cond_signal(uv_cond_t* cond); +UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); + +UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); +UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); +UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); + +UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); +UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, + uint64_t timeout); + +UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); + +UV_EXTERN int uv_key_create(uv_key_t* key); +UV_EXTERN void uv_key_delete(uv_key_t* key); +UV_EXTERN void* uv_key_get(uv_key_t* key); +UV_EXTERN void uv_key_set(uv_key_t* key, void* value); + +UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); + +typedef void (*uv_thread_cb)(void* arg); + +UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); + +typedef enum { + UV_THREAD_NO_FLAGS = 0x00, + UV_THREAD_HAS_STACK_SIZE = 0x01 +} uv_thread_create_flags; + +struct uv_thread_options_s { + unsigned int flags; + size_t stack_size; + /* More fields may be added at any time. */ +}; + +typedef struct uv_thread_options_s uv_thread_options_t; + +UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, + const uv_thread_options_t* params, + uv_thread_cb entry, + void* arg); +UV_EXTERN uv_thread_t uv_thread_self(void); +UV_EXTERN int uv_thread_join(uv_thread_t *tid); +UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); + +/* The presence of these unions force similar struct layout. */ +#define XX(_, name) uv_ ## name ## _t name; +union uv_any_handle { + UV_HANDLE_TYPE_MAP(XX) +}; + +union uv_any_req { + UV_REQ_TYPE_MAP(XX) +}; +#undef XX + + +struct uv_loop_s { + /* User data - use this for whatever. */ + void* data; + /* Loop reference counting. */ + unsigned int active_handles; + void* handle_queue[2]; + union { + void* unused; + unsigned int count; + } active_reqs; + /* Internal storage for future extensions. */ + void* internal_fields; + /* Internal flag to signal loop stop. */ + unsigned int stop_flag; + UV_LOOP_PRIVATE_FIELDS +}; + +UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); +UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); + +/* Don't export the private CPP symbols. */ +#undef UV_HANDLE_TYPE_PRIVATE +#undef UV_REQ_TYPE_PRIVATE +#undef UV_REQ_PRIVATE_FIELDS +#undef UV_STREAM_PRIVATE_FIELDS +#undef UV_TCP_PRIVATE_FIELDS +#undef UV_PREPARE_PRIVATE_FIELDS +#undef UV_CHECK_PRIVATE_FIELDS +#undef UV_IDLE_PRIVATE_FIELDS +#undef UV_ASYNC_PRIVATE_FIELDS +#undef UV_TIMER_PRIVATE_FIELDS +#undef UV_GETADDRINFO_PRIVATE_FIELDS +#undef UV_GETNAMEINFO_PRIVATE_FIELDS +#undef UV_FS_REQ_PRIVATE_FIELDS +#undef UV_WORK_PRIVATE_FIELDS +#undef UV_FS_EVENT_PRIVATE_FIELDS +#undef UV_SIGNAL_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS +#undef UV__ERR + +#ifdef __cplusplus +} +#endif +#endif /* UV_H */ diff --git a/third_party/libuv/include/uv/aix.h b/third_party/libuv/include/uv/aix.h index 7dc992fa6d74b5db275847ace8ef9acfd8108c2f..93c16f29fb1e9254311c0e73be5ac0f601e93a88 100644 --- a/third_party/libuv/include/uv/aix.h +++ b/third_party/libuv/include/uv/aix.h @@ -1,32 +1,32 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char *dir_filename; \ - -#endif /* UV_AIX_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_AIX_H +#define UV_AIX_H + +#define UV_PLATFORM_LOOP_FIELDS \ + int fs_fd; \ + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + uv__io_t event_watcher; \ + char *dir_filename; \ + +#endif /* UV_AIX_H */ diff --git a/third_party/libuv/include/uv/bsd.h b/third_party/libuv/include/uv/bsd.h index 2d72b3d7711311144aae0fdfe73479b89f2aba2d..aacfb115daaf10da8fe3ddf456aaa0f8d397f786 100644 --- a/third_party/libuv/include/uv/bsd.h +++ b/third_party/libuv/include/uv/bsd.h @@ -1,34 +1,34 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_BSD_H -#define UV_BSD_H - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_BSD_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_BSD_H +#define UV_BSD_H + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + uv__io_t event_watcher; \ + +#define UV_IO_PRIVATE_PLATFORM_FIELDS \ + int rcount; \ + int wcount; \ + +#define UV_HAVE_KQUEUE 1 + +#endif /* UV_BSD_H */ diff --git a/third_party/libuv/include/uv/darwin.h b/third_party/libuv/include/uv/darwin.h index d226415820bb6a504f79b74dd7c7e460d4c403f5..bcf6db8c9fcd6add254b4754f262d2ebaab8328e 100644 --- a/third_party/libuv/include/uv/darwin.h +++ b/third_party/libuv/include/uv/darwin.h @@ -1,61 +1,61 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_DARWIN_H -#define UV_DARWIN_H - -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -# include -# define UV_PLATFORM_SEM_T semaphore_t -#endif - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_PLATFORM_LOOP_FIELDS \ - uv_thread_t cf_thread; \ - void* _cf_reserved; \ - void* cf_state; \ - uv_mutex_t cf_mutex; \ - uv_sem_t cf_sem; \ - void* cf_signals[2]; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* realpath; \ - int realpath_len; \ - int cf_flags; \ - uv_async_t* cf_cb; \ - void* cf_events[2]; \ - void* cf_member[2]; \ - int cf_error; \ - uv_mutex_t cf_mutex; \ - -#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - void* select; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_DARWIN_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_DARWIN_H +#define UV_DARWIN_H + +#if defined(__APPLE__) && defined(__MACH__) +# include +# include +# include +# include +# define UV_PLATFORM_SEM_T semaphore_t +#endif + +#define UV_IO_PRIVATE_PLATFORM_FIELDS \ + int rcount; \ + int wcount; \ + +#define UV_PLATFORM_LOOP_FIELDS \ + uv_thread_t cf_thread; \ + void* _cf_reserved; \ + void* cf_state; \ + uv_mutex_t cf_mutex; \ + uv_sem_t cf_sem; \ + void* cf_signals[2]; \ + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + uv__io_t event_watcher; \ + char* realpath; \ + int realpath_len; \ + int cf_flags; \ + uv_async_t* cf_cb; \ + void* cf_events[2]; \ + void* cf_member[2]; \ + int cf_error; \ + uv_mutex_t cf_mutex; \ + +#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ + void* select; \ + +#define UV_HAVE_KQUEUE 1 + +#endif /* UV_DARWIN_H */ diff --git a/third_party/libuv/include/uv/errno.h b/third_party/libuv/include/uv/errno.h index 71906b3f5e65e6718c230860ac58eaf64e0669ba..e11fe9be07a153f528a7cfff1a54a0e15be56b98 100644 --- a/third_party/libuv/include/uv/errno.h +++ b/third_party/libuv/include/uv/errno.h @@ -1,460 +1,460 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_ERRNO_H_ -#define UV_ERRNO_H_ - -#include -#if EDOM > 0 -# define UV__ERR(x) (-(x)) -#else -# define UV__ERR(x) (x) -#endif - -#define UV__EOF (-4095) -#define UV__UNKNOWN (-4094) - -#define UV__EAI_ADDRFAMILY (-3000) -#define UV__EAI_AGAIN (-3001) -#define UV__EAI_BADFLAGS (-3002) -#define UV__EAI_CANCELED (-3003) -#define UV__EAI_FAIL (-3004) -#define UV__EAI_FAMILY (-3005) -#define UV__EAI_MEMORY (-3006) -#define UV__EAI_NODATA (-3007) -#define UV__EAI_NONAME (-3008) -#define UV__EAI_OVERFLOW (-3009) -#define UV__EAI_SERVICE (-3010) -#define UV__EAI_SOCKTYPE (-3011) -#define UV__EAI_BADHINTS (-3013) -#define UV__EAI_PROTOCOL (-3014) - -/* Only map to the system errno on non-Windows platforms. It's apparently - * a fairly common practice for Windows programmers to redefine errno codes. - */ -#if defined(E2BIG) && !defined(_WIN32) -# define UV__E2BIG UV__ERR(E2BIG) -#else -# define UV__E2BIG (-4093) -#endif - -#if defined(EACCES) && !defined(_WIN32) -# define UV__EACCES UV__ERR(EACCES) -#else -# define UV__EACCES (-4092) -#endif - -#if defined(EADDRINUSE) && !defined(_WIN32) -# define UV__EADDRINUSE UV__ERR(EADDRINUSE) -#else -# define UV__EADDRINUSE (-4091) -#endif - -#if defined(EADDRNOTAVAIL) && !defined(_WIN32) -# define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL) -#else -# define UV__EADDRNOTAVAIL (-4090) -#endif - -#if defined(EAFNOSUPPORT) && !defined(_WIN32) -# define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT) -#else -# define UV__EAFNOSUPPORT (-4089) -#endif - -#if defined(EAGAIN) && !defined(_WIN32) -# define UV__EAGAIN UV__ERR(EAGAIN) -#else -# define UV__EAGAIN (-4088) -#endif - -#if defined(EALREADY) && !defined(_WIN32) -# define UV__EALREADY UV__ERR(EALREADY) -#else -# define UV__EALREADY (-4084) -#endif - -#if defined(EBADF) && !defined(_WIN32) -# define UV__EBADF UV__ERR(EBADF) -#else -# define UV__EBADF (-4083) -#endif - -#if defined(EBUSY) && !defined(_WIN32) -# define UV__EBUSY UV__ERR(EBUSY) -#else -# define UV__EBUSY (-4082) -#endif - -#if defined(ECANCELED) && !defined(_WIN32) -# define UV__ECANCELED UV__ERR(ECANCELED) -#else -# define UV__ECANCELED (-4081) -#endif - -#if defined(ECHARSET) && !defined(_WIN32) -# define UV__ECHARSET UV__ERR(ECHARSET) -#else -# define UV__ECHARSET (-4080) -#endif - -#if defined(ECONNABORTED) && !defined(_WIN32) -# define UV__ECONNABORTED UV__ERR(ECONNABORTED) -#else -# define UV__ECONNABORTED (-4079) -#endif - -#if defined(ECONNREFUSED) && !defined(_WIN32) -# define UV__ECONNREFUSED UV__ERR(ECONNREFUSED) -#else -# define UV__ECONNREFUSED (-4078) -#endif - -#if defined(ECONNRESET) && !defined(_WIN32) -# define UV__ECONNRESET UV__ERR(ECONNRESET) -#else -# define UV__ECONNRESET (-4077) -#endif - -#if defined(EDESTADDRREQ) && !defined(_WIN32) -# define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ) -#else -# define UV__EDESTADDRREQ (-4076) -#endif - -#if defined(EEXIST) && !defined(_WIN32) -# define UV__EEXIST UV__ERR(EEXIST) -#else -# define UV__EEXIST (-4075) -#endif - -#if defined(EFAULT) && !defined(_WIN32) -# define UV__EFAULT UV__ERR(EFAULT) -#else -# define UV__EFAULT (-4074) -#endif - -#if defined(EHOSTUNREACH) && !defined(_WIN32) -# define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH) -#else -# define UV__EHOSTUNREACH (-4073) -#endif - -#if defined(EINTR) && !defined(_WIN32) -# define UV__EINTR UV__ERR(EINTR) -#else -# define UV__EINTR (-4072) -#endif - -#if defined(EINVAL) && !defined(_WIN32) -# define UV__EINVAL UV__ERR(EINVAL) -#else -# define UV__EINVAL (-4071) -#endif - -#if defined(EIO) && !defined(_WIN32) -# define UV__EIO UV__ERR(EIO) -#else -# define UV__EIO (-4070) -#endif - -#if defined(EISCONN) && !defined(_WIN32) -# define UV__EISCONN UV__ERR(EISCONN) -#else -# define UV__EISCONN (-4069) -#endif - -#if defined(EISDIR) && !defined(_WIN32) -# define UV__EISDIR UV__ERR(EISDIR) -#else -# define UV__EISDIR (-4068) -#endif - -#if defined(ELOOP) && !defined(_WIN32) -# define UV__ELOOP UV__ERR(ELOOP) -#else -# define UV__ELOOP (-4067) -#endif - -#if defined(EMFILE) && !defined(_WIN32) -# define UV__EMFILE UV__ERR(EMFILE) -#else -# define UV__EMFILE (-4066) -#endif - -#if defined(EMSGSIZE) && !defined(_WIN32) -# define UV__EMSGSIZE UV__ERR(EMSGSIZE) -#else -# define UV__EMSGSIZE (-4065) -#endif - -#if defined(ENAMETOOLONG) && !defined(_WIN32) -# define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG) -#else -# define UV__ENAMETOOLONG (-4064) -#endif - -#if defined(ENETDOWN) && !defined(_WIN32) -# define UV__ENETDOWN UV__ERR(ENETDOWN) -#else -# define UV__ENETDOWN (-4063) -#endif - -#if defined(ENETUNREACH) && !defined(_WIN32) -# define UV__ENETUNREACH UV__ERR(ENETUNREACH) -#else -# define UV__ENETUNREACH (-4062) -#endif - -#if defined(ENFILE) && !defined(_WIN32) -# define UV__ENFILE UV__ERR(ENFILE) -#else -# define UV__ENFILE (-4061) -#endif - -#if defined(ENOBUFS) && !defined(_WIN32) -# define UV__ENOBUFS UV__ERR(ENOBUFS) -#else -# define UV__ENOBUFS (-4060) -#endif - -#if defined(ENODEV) && !defined(_WIN32) -# define UV__ENODEV UV__ERR(ENODEV) -#else -# define UV__ENODEV (-4059) -#endif - -#if defined(ENOENT) && !defined(_WIN32) -# define UV__ENOENT UV__ERR(ENOENT) -#else -# define UV__ENOENT (-4058) -#endif - -#if defined(ENOMEM) && !defined(_WIN32) -# define UV__ENOMEM UV__ERR(ENOMEM) -#else -# define UV__ENOMEM (-4057) -#endif - -#if defined(ENONET) && !defined(_WIN32) -# define UV__ENONET UV__ERR(ENONET) -#else -# define UV__ENONET (-4056) -#endif - -#if defined(ENOSPC) && !defined(_WIN32) -# define UV__ENOSPC UV__ERR(ENOSPC) -#else -# define UV__ENOSPC (-4055) -#endif - -#if defined(ENOSYS) && !defined(_WIN32) -# define UV__ENOSYS UV__ERR(ENOSYS) -#else -# define UV__ENOSYS (-4054) -#endif - -#if defined(ENOTCONN) && !defined(_WIN32) -# define UV__ENOTCONN UV__ERR(ENOTCONN) -#else -# define UV__ENOTCONN (-4053) -#endif - -#if defined(ENOTDIR) && !defined(_WIN32) -# define UV__ENOTDIR UV__ERR(ENOTDIR) -#else -# define UV__ENOTDIR (-4052) -#endif - -#if defined(ENOTEMPTY) && !defined(_WIN32) -# define UV__ENOTEMPTY UV__ERR(ENOTEMPTY) -#else -# define UV__ENOTEMPTY (-4051) -#endif - -#if defined(ENOTSOCK) && !defined(_WIN32) -# define UV__ENOTSOCK UV__ERR(ENOTSOCK) -#else -# define UV__ENOTSOCK (-4050) -#endif - -#if defined(ENOTSUP) && !defined(_WIN32) -# define UV__ENOTSUP UV__ERR(ENOTSUP) -#else -# define UV__ENOTSUP (-4049) -#endif - -#if defined(EPERM) && !defined(_WIN32) -# define UV__EPERM UV__ERR(EPERM) -#else -# define UV__EPERM (-4048) -#endif - -#if defined(EPIPE) && !defined(_WIN32) -# define UV__EPIPE UV__ERR(EPIPE) -#else -# define UV__EPIPE (-4047) -#endif - -#if defined(EPROTO) && !defined(_WIN32) -# define UV__EPROTO UV__ERR(EPROTO) -#else -# define UV__EPROTO (-4046) -#endif - -#if defined(EPROTONOSUPPORT) && !defined(_WIN32) -# define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT) -#else -# define UV__EPROTONOSUPPORT (-4045) -#endif - -#if defined(EPROTOTYPE) && !defined(_WIN32) -# define UV__EPROTOTYPE UV__ERR(EPROTOTYPE) -#else -# define UV__EPROTOTYPE (-4044) -#endif - -#if defined(EROFS) && !defined(_WIN32) -# define UV__EROFS UV__ERR(EROFS) -#else -# define UV__EROFS (-4043) -#endif - -#if defined(ESHUTDOWN) && !defined(_WIN32) -# define UV__ESHUTDOWN UV__ERR(ESHUTDOWN) -#else -# define UV__ESHUTDOWN (-4042) -#endif - -#if defined(ESPIPE) && !defined(_WIN32) -# define UV__ESPIPE UV__ERR(ESPIPE) -#else -# define UV__ESPIPE (-4041) -#endif - -#if defined(ESRCH) && !defined(_WIN32) -# define UV__ESRCH UV__ERR(ESRCH) -#else -# define UV__ESRCH (-4040) -#endif - -#if defined(ETIMEDOUT) && !defined(_WIN32) -# define UV__ETIMEDOUT UV__ERR(ETIMEDOUT) -#else -# define UV__ETIMEDOUT (-4039) -#endif - -#if defined(ETXTBSY) && !defined(_WIN32) -# define UV__ETXTBSY UV__ERR(ETXTBSY) -#else -# define UV__ETXTBSY (-4038) -#endif - -#if defined(EXDEV) && !defined(_WIN32) -# define UV__EXDEV UV__ERR(EXDEV) -#else -# define UV__EXDEV (-4037) -#endif - -#if defined(EFBIG) && !defined(_WIN32) -# define UV__EFBIG UV__ERR(EFBIG) -#else -# define UV__EFBIG (-4036) -#endif - -#if defined(ENOPROTOOPT) && !defined(_WIN32) -# define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT) -#else -# define UV__ENOPROTOOPT (-4035) -#endif - -#if defined(ERANGE) && !defined(_WIN32) -# define UV__ERANGE UV__ERR(ERANGE) -#else -# define UV__ERANGE (-4034) -#endif - -#if defined(ENXIO) && !defined(_WIN32) -# define UV__ENXIO UV__ERR(ENXIO) -#else -# define UV__ENXIO (-4033) -#endif - -#if defined(EMLINK) && !defined(_WIN32) -# define UV__EMLINK UV__ERR(EMLINK) -#else -# define UV__EMLINK (-4032) -#endif - -/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is - * defined. Fortunately, its value is always 64 so it's possible albeit - * icky to hard-code it. - */ -#if defined(EHOSTDOWN) && !defined(_WIN32) -# define UV__EHOSTDOWN UV__ERR(EHOSTDOWN) -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) -# define UV__EHOSTDOWN (-64) -#else -# define UV__EHOSTDOWN (-4031) -#endif - -#if defined(EREMOTEIO) && !defined(_WIN32) -# define UV__EREMOTEIO UV__ERR(EREMOTEIO) -#else -# define UV__EREMOTEIO (-4030) -#endif - -#if defined(ENOTTY) && !defined(_WIN32) -# define UV__ENOTTY UV__ERR(ENOTTY) -#else -# define UV__ENOTTY (-4029) -#endif - -#if defined(EFTYPE) && !defined(_WIN32) -# define UV__EFTYPE UV__ERR(EFTYPE) -#else -# define UV__EFTYPE (-4028) -#endif - -#if defined(EILSEQ) && !defined(_WIN32) -# define UV__EILSEQ UV__ERR(EILSEQ) -#else -# define UV__EILSEQ (-4027) -#endif - -#if defined(EOVERFLOW) && !defined(_WIN32) -# define UV__EOVERFLOW UV__ERR(EOVERFLOW) -#else -# define UV__EOVERFLOW (-4026) -#endif - -#if defined(ESOCKTNOSUPPORT) && !defined(_WIN32) -# define UV__ESOCKTNOSUPPORT UV__ERR(ESOCKTNOSUPPORT) -#else -# define UV__ESOCKTNOSUPPORT (-4025) -#endif - -#endif /* UV_ERRNO_H_ */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_ERRNO_H_ +#define UV_ERRNO_H_ + +#include +#if EDOM > 0 +# define UV__ERR(x) (-(x)) +#else +# define UV__ERR(x) (x) +#endif + +#define UV__EOF (-4095) +#define UV__UNKNOWN (-4094) + +#define UV__EAI_ADDRFAMILY (-3000) +#define UV__EAI_AGAIN (-3001) +#define UV__EAI_BADFLAGS (-3002) +#define UV__EAI_CANCELED (-3003) +#define UV__EAI_FAIL (-3004) +#define UV__EAI_FAMILY (-3005) +#define UV__EAI_MEMORY (-3006) +#define UV__EAI_NODATA (-3007) +#define UV__EAI_NONAME (-3008) +#define UV__EAI_OVERFLOW (-3009) +#define UV__EAI_SERVICE (-3010) +#define UV__EAI_SOCKTYPE (-3011) +#define UV__EAI_BADHINTS (-3013) +#define UV__EAI_PROTOCOL (-3014) + +/* Only map to the system errno on non-Windows platforms. It's apparently + * a fairly common practice for Windows programmers to redefine errno codes. + */ +#if defined(E2BIG) && !defined(_WIN32) +# define UV__E2BIG UV__ERR(E2BIG) +#else +# define UV__E2BIG (-4093) +#endif + +#if defined(EACCES) && !defined(_WIN32) +# define UV__EACCES UV__ERR(EACCES) +#else +# define UV__EACCES (-4092) +#endif + +#if defined(EADDRINUSE) && !defined(_WIN32) +# define UV__EADDRINUSE UV__ERR(EADDRINUSE) +#else +# define UV__EADDRINUSE (-4091) +#endif + +#if defined(EADDRNOTAVAIL) && !defined(_WIN32) +# define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL) +#else +# define UV__EADDRNOTAVAIL (-4090) +#endif + +#if defined(EAFNOSUPPORT) && !defined(_WIN32) +# define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT) +#else +# define UV__EAFNOSUPPORT (-4089) +#endif + +#if defined(EAGAIN) && !defined(_WIN32) +# define UV__EAGAIN UV__ERR(EAGAIN) +#else +# define UV__EAGAIN (-4088) +#endif + +#if defined(EALREADY) && !defined(_WIN32) +# define UV__EALREADY UV__ERR(EALREADY) +#else +# define UV__EALREADY (-4084) +#endif + +#if defined(EBADF) && !defined(_WIN32) +# define UV__EBADF UV__ERR(EBADF) +#else +# define UV__EBADF (-4083) +#endif + +#if defined(EBUSY) && !defined(_WIN32) +# define UV__EBUSY UV__ERR(EBUSY) +#else +# define UV__EBUSY (-4082) +#endif + +#if defined(ECANCELED) && !defined(_WIN32) +# define UV__ECANCELED UV__ERR(ECANCELED) +#else +# define UV__ECANCELED (-4081) +#endif + +#if defined(ECHARSET) && !defined(_WIN32) +# define UV__ECHARSET UV__ERR(ECHARSET) +#else +# define UV__ECHARSET (-4080) +#endif + +#if defined(ECONNABORTED) && !defined(_WIN32) +# define UV__ECONNABORTED UV__ERR(ECONNABORTED) +#else +# define UV__ECONNABORTED (-4079) +#endif + +#if defined(ECONNREFUSED) && !defined(_WIN32) +# define UV__ECONNREFUSED UV__ERR(ECONNREFUSED) +#else +# define UV__ECONNREFUSED (-4078) +#endif + +#if defined(ECONNRESET) && !defined(_WIN32) +# define UV__ECONNRESET UV__ERR(ECONNRESET) +#else +# define UV__ECONNRESET (-4077) +#endif + +#if defined(EDESTADDRREQ) && !defined(_WIN32) +# define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ) +#else +# define UV__EDESTADDRREQ (-4076) +#endif + +#if defined(EEXIST) && !defined(_WIN32) +# define UV__EEXIST UV__ERR(EEXIST) +#else +# define UV__EEXIST (-4075) +#endif + +#if defined(EFAULT) && !defined(_WIN32) +# define UV__EFAULT UV__ERR(EFAULT) +#else +# define UV__EFAULT (-4074) +#endif + +#if defined(EHOSTUNREACH) && !defined(_WIN32) +# define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH) +#else +# define UV__EHOSTUNREACH (-4073) +#endif + +#if defined(EINTR) && !defined(_WIN32) +# define UV__EINTR UV__ERR(EINTR) +#else +# define UV__EINTR (-4072) +#endif + +#if defined(EINVAL) && !defined(_WIN32) +# define UV__EINVAL UV__ERR(EINVAL) +#else +# define UV__EINVAL (-4071) +#endif + +#if defined(EIO) && !defined(_WIN32) +# define UV__EIO UV__ERR(EIO) +#else +# define UV__EIO (-4070) +#endif + +#if defined(EISCONN) && !defined(_WIN32) +# define UV__EISCONN UV__ERR(EISCONN) +#else +# define UV__EISCONN (-4069) +#endif + +#if defined(EISDIR) && !defined(_WIN32) +# define UV__EISDIR UV__ERR(EISDIR) +#else +# define UV__EISDIR (-4068) +#endif + +#if defined(ELOOP) && !defined(_WIN32) +# define UV__ELOOP UV__ERR(ELOOP) +#else +# define UV__ELOOP (-4067) +#endif + +#if defined(EMFILE) && !defined(_WIN32) +# define UV__EMFILE UV__ERR(EMFILE) +#else +# define UV__EMFILE (-4066) +#endif + +#if defined(EMSGSIZE) && !defined(_WIN32) +# define UV__EMSGSIZE UV__ERR(EMSGSIZE) +#else +# define UV__EMSGSIZE (-4065) +#endif + +#if defined(ENAMETOOLONG) && !defined(_WIN32) +# define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG) +#else +# define UV__ENAMETOOLONG (-4064) +#endif + +#if defined(ENETDOWN) && !defined(_WIN32) +# define UV__ENETDOWN UV__ERR(ENETDOWN) +#else +# define UV__ENETDOWN (-4063) +#endif + +#if defined(ENETUNREACH) && !defined(_WIN32) +# define UV__ENETUNREACH UV__ERR(ENETUNREACH) +#else +# define UV__ENETUNREACH (-4062) +#endif + +#if defined(ENFILE) && !defined(_WIN32) +# define UV__ENFILE UV__ERR(ENFILE) +#else +# define UV__ENFILE (-4061) +#endif + +#if defined(ENOBUFS) && !defined(_WIN32) +# define UV__ENOBUFS UV__ERR(ENOBUFS) +#else +# define UV__ENOBUFS (-4060) +#endif + +#if defined(ENODEV) && !defined(_WIN32) +# define UV__ENODEV UV__ERR(ENODEV) +#else +# define UV__ENODEV (-4059) +#endif + +#if defined(ENOENT) && !defined(_WIN32) +# define UV__ENOENT UV__ERR(ENOENT) +#else +# define UV__ENOENT (-4058) +#endif + +#if defined(ENOMEM) && !defined(_WIN32) +# define UV__ENOMEM UV__ERR(ENOMEM) +#else +# define UV__ENOMEM (-4057) +#endif + +#if defined(ENONET) && !defined(_WIN32) +# define UV__ENONET UV__ERR(ENONET) +#else +# define UV__ENONET (-4056) +#endif + +#if defined(ENOSPC) && !defined(_WIN32) +# define UV__ENOSPC UV__ERR(ENOSPC) +#else +# define UV__ENOSPC (-4055) +#endif + +#if defined(ENOSYS) && !defined(_WIN32) +# define UV__ENOSYS UV__ERR(ENOSYS) +#else +# define UV__ENOSYS (-4054) +#endif + +#if defined(ENOTCONN) && !defined(_WIN32) +# define UV__ENOTCONN UV__ERR(ENOTCONN) +#else +# define UV__ENOTCONN (-4053) +#endif + +#if defined(ENOTDIR) && !defined(_WIN32) +# define UV__ENOTDIR UV__ERR(ENOTDIR) +#else +# define UV__ENOTDIR (-4052) +#endif + +#if defined(ENOTEMPTY) && !defined(_WIN32) +# define UV__ENOTEMPTY UV__ERR(ENOTEMPTY) +#else +# define UV__ENOTEMPTY (-4051) +#endif + +#if defined(ENOTSOCK) && !defined(_WIN32) +# define UV__ENOTSOCK UV__ERR(ENOTSOCK) +#else +# define UV__ENOTSOCK (-4050) +#endif + +#if defined(ENOTSUP) && !defined(_WIN32) +# define UV__ENOTSUP UV__ERR(ENOTSUP) +#else +# define UV__ENOTSUP (-4049) +#endif + +#if defined(EPERM) && !defined(_WIN32) +# define UV__EPERM UV__ERR(EPERM) +#else +# define UV__EPERM (-4048) +#endif + +#if defined(EPIPE) && !defined(_WIN32) +# define UV__EPIPE UV__ERR(EPIPE) +#else +# define UV__EPIPE (-4047) +#endif + +#if defined(EPROTO) && !defined(_WIN32) +# define UV__EPROTO UV__ERR(EPROTO) +#else +# define UV__EPROTO (-4046) +#endif + +#if defined(EPROTONOSUPPORT) && !defined(_WIN32) +# define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT) +#else +# define UV__EPROTONOSUPPORT (-4045) +#endif + +#if defined(EPROTOTYPE) && !defined(_WIN32) +# define UV__EPROTOTYPE UV__ERR(EPROTOTYPE) +#else +# define UV__EPROTOTYPE (-4044) +#endif + +#if defined(EROFS) && !defined(_WIN32) +# define UV__EROFS UV__ERR(EROFS) +#else +# define UV__EROFS (-4043) +#endif + +#if defined(ESHUTDOWN) && !defined(_WIN32) +# define UV__ESHUTDOWN UV__ERR(ESHUTDOWN) +#else +# define UV__ESHUTDOWN (-4042) +#endif + +#if defined(ESPIPE) && !defined(_WIN32) +# define UV__ESPIPE UV__ERR(ESPIPE) +#else +# define UV__ESPIPE (-4041) +#endif + +#if defined(ESRCH) && !defined(_WIN32) +# define UV__ESRCH UV__ERR(ESRCH) +#else +# define UV__ESRCH (-4040) +#endif + +#if defined(ETIMEDOUT) && !defined(_WIN32) +# define UV__ETIMEDOUT UV__ERR(ETIMEDOUT) +#else +# define UV__ETIMEDOUT (-4039) +#endif + +#if defined(ETXTBSY) && !defined(_WIN32) +# define UV__ETXTBSY UV__ERR(ETXTBSY) +#else +# define UV__ETXTBSY (-4038) +#endif + +#if defined(EXDEV) && !defined(_WIN32) +# define UV__EXDEV UV__ERR(EXDEV) +#else +# define UV__EXDEV (-4037) +#endif + +#if defined(EFBIG) && !defined(_WIN32) +# define UV__EFBIG UV__ERR(EFBIG) +#else +# define UV__EFBIG (-4036) +#endif + +#if defined(ENOPROTOOPT) && !defined(_WIN32) +# define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT) +#else +# define UV__ENOPROTOOPT (-4035) +#endif + +#if defined(ERANGE) && !defined(_WIN32) +# define UV__ERANGE UV__ERR(ERANGE) +#else +# define UV__ERANGE (-4034) +#endif + +#if defined(ENXIO) && !defined(_WIN32) +# define UV__ENXIO UV__ERR(ENXIO) +#else +# define UV__ENXIO (-4033) +#endif + +#if defined(EMLINK) && !defined(_WIN32) +# define UV__EMLINK UV__ERR(EMLINK) +#else +# define UV__EMLINK (-4032) +#endif + +/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is + * defined. Fortunately, its value is always 64 so it's possible albeit + * icky to hard-code it. + */ +#if defined(EHOSTDOWN) && !defined(_WIN32) +# define UV__EHOSTDOWN UV__ERR(EHOSTDOWN) +#elif defined(__APPLE__) || \ + defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || \ + defined(__OpenBSD__) +# define UV__EHOSTDOWN (-64) +#else +# define UV__EHOSTDOWN (-4031) +#endif + +#if defined(EREMOTEIO) && !defined(_WIN32) +# define UV__EREMOTEIO UV__ERR(EREMOTEIO) +#else +# define UV__EREMOTEIO (-4030) +#endif + +#if defined(ENOTTY) && !defined(_WIN32) +# define UV__ENOTTY UV__ERR(ENOTTY) +#else +# define UV__ENOTTY (-4029) +#endif + +#if defined(EFTYPE) && !defined(_WIN32) +# define UV__EFTYPE UV__ERR(EFTYPE) +#else +# define UV__EFTYPE (-4028) +#endif + +#if defined(EILSEQ) && !defined(_WIN32) +# define UV__EILSEQ UV__ERR(EILSEQ) +#else +# define UV__EILSEQ (-4027) +#endif + +#if defined(EOVERFLOW) && !defined(_WIN32) +# define UV__EOVERFLOW UV__ERR(EOVERFLOW) +#else +# define UV__EOVERFLOW (-4026) +#endif + +#if defined(ESOCKTNOSUPPORT) && !defined(_WIN32) +# define UV__ESOCKTNOSUPPORT UV__ERR(ESOCKTNOSUPPORT) +#else +# define UV__ESOCKTNOSUPPORT (-4025) +#endif + +#endif /* UV_ERRNO_H_ */ diff --git a/third_party/libuv/include/uv/linux.h b/third_party/libuv/include/uv/linux.h index 9b38405a190d323c92882d92db23ef762a570a96..839b12d904b19cda1923a3ff62d3aee2788942c6 100644 --- a/third_party/libuv/include/uv/linux.h +++ b/third_party/libuv/include/uv/linux.h @@ -1,34 +1,34 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_LINUX_H -#define UV_LINUX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - void* watchers[2]; \ - int wd; \ - -#endif /* UV_LINUX_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_LINUX_H +#define UV_LINUX_H + +#define UV_PLATFORM_LOOP_FIELDS \ + uv__io_t inotify_read_watcher; \ + void* inotify_watchers; \ + int inotify_fd; \ + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + void* watchers[2]; \ + int wd; \ + +#endif /* UV_LINUX_H */ diff --git a/third_party/libuv/include/uv/os390.h b/third_party/libuv/include/uv/os390.h index 0267d74cbd02c93d34c02bbc2750932a7e842898..988fed1ae1623e365e6b8e852237805e9c66d58a 100644 --- a/third_party/libuv/include/uv/os390.h +++ b/third_party/libuv/include/uv/os390.h @@ -1,33 +1,33 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T long - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - char rfis_rftok[8]; \ - -#endif /* UV_MVS_H */ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_MVS_H +#define UV_MVS_H + +#define UV_PLATFORM_SEM_T long + +#define UV_PLATFORM_LOOP_FIELDS \ + void* ep; \ + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + char rfis_rftok[8]; \ + +#endif /* UV_MVS_H */ diff --git a/third_party/libuv/include/uv/posix.h b/third_party/libuv/include/uv/posix.h index 9a96634db0e3a585c75905bbbfc49ebe5c63e2df..0103c660d2482ecb349a3c6ee2344d5481d77e27 100644 --- a/third_party/libuv/include/uv/posix.h +++ b/third_party/libuv/include/uv/posix.h @@ -1,31 +1,31 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ - -#endif /* UV_POSIX_H */ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_POSIX_H +#define UV_POSIX_H + +#define UV_PLATFORM_LOOP_FIELDS \ + struct pollfd* poll_fds; \ + size_t poll_fds_used; \ + size_t poll_fds_size; \ + unsigned char poll_fds_iterating; \ + +#endif /* UV_POSIX_H */ diff --git a/third_party/libuv/include/uv/stdint-msvc2008.h b/third_party/libuv/include/uv/stdint-msvc2008.h index d02608a5972642c7b7a13b987f21e2502a5af3ea..59d067302fcfe1f5ec82cd7534f89c18167dd895 100644 --- a/third_party/libuv/include/uv/stdint-msvc2008.h +++ b/third_party/libuv/include/uv/stdint-msvc2008.h @@ -1,247 +1,247 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff --git a/third_party/libuv/include/uv/sunos.h b/third_party/libuv/include/uv/sunos.h index 042166424e50b7de043fe869bec40cc27ce7d136..b6500081528343fb5685775ad2b5a43f173e7b62 100644 --- a/third_party/libuv/include/uv/sunos.h +++ b/third_party/libuv/include/uv/sunos.h @@ -1,44 +1,44 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_SUNOS_H -#define UV_SUNOS_H - -#include -#include - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; \ - -#if defined(PORT_SOURCE_FILE) - -# define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; \ - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_SUNOS_H +#define UV_SUNOS_H + +#include +#include + +/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, + * add the fs_event fields even when this version of SunOS doesn't support + * file watching. + */ +#define UV_PLATFORM_LOOP_FIELDS \ + uv__io_t fs_event_watcher; \ + int fs_fd; \ + +#if defined(PORT_SOURCE_FILE) + +# define UV_PLATFORM_FS_EVENT_FIELDS \ + file_obj_t fo; \ + int fd; \ + +#endif /* defined(PORT_SOURCE_FILE) */ + +#endif /* UV_SUNOS_H */ diff --git a/third_party/libuv/include/uv/threadpool.h b/third_party/libuv/include/uv/threadpool.h index 9708ebdd5301a9cf1f9da856b4b12b89ef6fd683..0e36a276a2c7838c458985cd35a93ceeeb84ff1d 100644 --- a/third_party/libuv/include/uv/threadpool.h +++ b/third_party/libuv/include/uv/threadpool.h @@ -1,37 +1,37 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/* + * This file is private to libuv. It provides common functionality to both + * Windows and Unix backends. + */ + +#ifndef UV_THREADPOOL_H_ +#define UV_THREADPOOL_H_ + +struct uv__work { + void (*work)(struct uv__work *w); + void (*done)(struct uv__work *w, int status); + struct uv_loop_s* loop; + void* wq[2]; +}; + +#endif /* UV_THREADPOOL_H_ */ diff --git a/third_party/libuv/include/uv/tree.h b/third_party/libuv/include/uv/tree.h index 2b28835fdedef241914447b60016744dd078dbad..2418505b24d939a1b3254acf03a66af8d3314e77 100644 --- a/third_party/libuv/include/uv/tree.h +++ b/third_party/libuv/include/uv/tree.h @@ -1,768 +1,768 @@ -/*- - * Copyright 2002 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UV_TREE_H_ -#define UV_TREE_H_ - -#ifndef UV__UNUSED -# if __GNUC__ -# define UV__UNUSED __attribute__((unused)) -# else -# define UV__UNUSED -# endif -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - for (;;) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ - struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old) \ - RB_LEFT(RB_PARENT(old, field), field) = elm; \ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm; \ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* UV_TREE_H_ */ +/*- + * Copyright 2002 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UV_TREE_H_ +#define UV_TREE_H_ + +#ifndef UV__UNUSED +# if __GNUC__ +# define UV__UNUSED __attribute__((unused)) +# else +# define UV__UNUSED +# endif +#endif + +/* + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * + * A red-black tree is a binary search tree with the node color as an + * extra attribute. It fulfills a set of conditions: + * - every search path from the root to a leaf consists of the + * same number of black nodes, + * - each red node (except for the root) has a black parent, + * - each leaf node is black. + * + * Every operation on a red-black tree is bounded as O(lg n). + * The maximum height of a red-black tree is 2lg (n+1). + */ + +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ + \ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ + __left = __right = &__node; \ + \ + while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + \ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ + __left = __right = &__node; \ + \ + for (;;) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + +/* Macros that define a red-black tree */ +#define RB_HEAD(name, type) \ +struct name { \ + struct type *rbh_root; /* root of the tree */ \ +} + +#define RB_INITIALIZER(root) \ + { NULL } + +#define RB_INIT(root) do { \ + (root)->rbh_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define RB_BLACK 0 +#define RB_RED 1 +#define RB_ENTRY(type) \ +struct { \ + struct type *rbe_left; /* left element */ \ + struct type *rbe_right; /* right element */ \ + struct type *rbe_parent; /* parent element */ \ + int rbe_color; /* node color */ \ +} + +#define RB_LEFT(elm, field) (elm)->field.rbe_left +#define RB_RIGHT(elm, field) (elm)->field.rbe_right +#define RB_PARENT(elm, field) (elm)->field.rbe_parent +#define RB_COLOR(elm, field) (elm)->field.rbe_color +#define RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (RB_ROOT(head) == NULL) + +#define RB_SET(elm, parent, field) do { \ + RB_PARENT(elm, field) = parent; \ + RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ + RB_COLOR(elm, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#define RB_SET_BLACKRED(black, red, field) do { \ + RB_COLOR(black, field) = RB_BLACK; \ + RB_COLOR(red, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#ifndef RB_AUGMENT +#define RB_AUGMENT(x) do {} while (0) +#endif + +#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ + (tmp) = RB_RIGHT(elm, field); \ + if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ + RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_LEFT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ + (tmp) = RB_LEFT(elm, field); \ + if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ + RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_RIGHT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ +#define RB_PROTOTYPE(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) +#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) +#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ +attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ +attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ +attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ +attr struct type *name##_RB_INSERT(struct name *, struct type *); \ +attr struct type *name##_RB_FIND(struct name *, struct type *); \ +attr struct type *name##_RB_NFIND(struct name *, struct type *); \ +attr struct type *name##_RB_NEXT(struct type *); \ +attr struct type *name##_RB_PREV(struct type *); \ +attr struct type *name##_RB_MINMAX(struct name *, int); \ + \ + +/* Main rb operation. + * Moves node close to the key of elm to top + */ +#define RB_GENERATE(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp,) +#define RB_GENERATE_STATIC(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) +#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ +attr void \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *gparent, *tmp; \ + while ((parent = RB_PARENT(elm, field)) != NULL && \ + RB_COLOR(parent, field) == RB_RED) { \ + gparent = RB_PARENT(parent, field); \ + if (parent == RB_LEFT(gparent, field)) { \ + tmp = RB_RIGHT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field); \ + elm = gparent; \ + continue; \ + } \ + if (RB_RIGHT(parent, field) == elm) { \ + RB_ROTATE_LEFT(head, parent, tmp, field); \ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_RIGHT(head, gparent, tmp, field); \ + } else { \ + tmp = RB_LEFT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field); \ + elm = gparent; \ + continue; \ + } \ + if (RB_LEFT(parent, field) == elm) { \ + RB_ROTATE_RIGHT(head, parent, tmp, field); \ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_LEFT(head, gparent, tmp, field); \ + } \ + } \ + RB_COLOR(head->rbh_root, field) = RB_BLACK; \ +} \ + \ +attr void \ +name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ + struct type *elm) \ +{ \ + struct type *tmp; \ + while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ + elm != RB_ROOT(head)) { \ + if (RB_LEFT(parent, field) == elm) { \ + tmp = RB_RIGHT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_LEFT(head, parent, tmp, field); \ + tmp = RB_RIGHT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ + struct type *oleft; \ + if ((oleft = RB_LEFT(tmp, field)) \ + != NULL) \ + RB_COLOR(oleft, field) = RB_BLACK; \ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_RIGHT(head, tmp, oleft, field); \ + tmp = RB_RIGHT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_RIGHT(tmp, field)) \ + RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ + RB_ROTATE_LEFT(head, parent, tmp, field); \ + elm = RB_ROOT(head); \ + break; \ + } \ + } else { \ + tmp = RB_LEFT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_RIGHT(head, parent, tmp, field); \ + tmp = RB_LEFT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ + struct type *oright; \ + if ((oright = RB_RIGHT(tmp, field)) \ + != NULL) \ + RB_COLOR(oright, field) = RB_BLACK; \ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_LEFT(head, tmp, oright, field); \ + tmp = RB_LEFT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_LEFT(tmp, field)) \ + RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ + RB_ROTATE_RIGHT(head, parent, tmp, field); \ + elm = RB_ROOT(head); \ + break; \ + } \ + } \ + } \ + if (elm) \ + RB_COLOR(elm, field) = RB_BLACK; \ +} \ + \ +attr struct type * \ +name##_RB_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *child, *parent, *old = elm; \ + int color; \ + if (RB_LEFT(elm, field) == NULL) \ + child = RB_RIGHT(elm, field); \ + else if (RB_RIGHT(elm, field) == NULL) \ + child = RB_LEFT(elm, field); \ + else { \ + struct type *left; \ + elm = RB_RIGHT(elm, field); \ + while ((left = RB_LEFT(elm, field)) != NULL) \ + elm = left; \ + child = RB_RIGHT(elm, field); \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ + if (RB_PARENT(elm, field) == old) \ + parent = elm; \ + (elm)->field = (old)->field; \ + if (RB_PARENT(old, field)) { \ + if (RB_LEFT(RB_PARENT(old, field), field) == old) \ + RB_LEFT(RB_PARENT(old, field), field) = elm; \ + else \ + RB_RIGHT(RB_PARENT(old, field), field) = elm; \ + RB_AUGMENT(RB_PARENT(old, field)); \ + } else \ + RB_ROOT(head) = elm; \ + RB_PARENT(RB_LEFT(old, field), field) = elm; \ + if (RB_RIGHT(old, field)) \ + RB_PARENT(RB_RIGHT(old, field), field) = elm; \ + if (parent) { \ + left = parent; \ + do { \ + RB_AUGMENT(left); \ + } while ((left = RB_PARENT(left, field)) != NULL); \ + } \ + goto color; \ + } \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ +color: \ + if (color == RB_BLACK) \ + name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ +} \ + \ +/* Inserts a node into the RB tree */ \ +attr struct type * \ +name##_RB_INSERT(struct name *head, struct type *elm) \ +{ \ + struct type *tmp; \ + struct type *parent = NULL; \ + int comp = 0; \ + tmp = RB_ROOT(head); \ + while (tmp) { \ + parent = tmp; \ + comp = (cmp)(elm, parent); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + RB_SET(elm, parent, field); \ + if (parent != NULL) { \ + if (comp < 0) \ + RB_LEFT(parent, field) = elm; \ + else \ + RB_RIGHT(parent, field) = elm; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = elm; \ + name##_RB_INSERT_COLOR(head, elm); \ + return (NULL); \ +} \ + \ +/* Finds the node with the same key as elm */ \ +attr struct type * \ +name##_RB_FIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (NULL); \ +} \ + \ +/* Finds the first node greater than or equal to the search key */ \ +attr struct type * \ +name##_RB_NFIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *res = NULL; \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) { \ + res = tmp; \ + tmp = RB_LEFT(tmp, field); \ + } \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (res); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_NEXT(struct type *elm) \ +{ \ + if (RB_RIGHT(elm, field)) { \ + elm = RB_RIGHT(elm, field); \ + while (RB_LEFT(elm, field)) \ + elm = RB_LEFT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_PREV(struct type *elm) \ +{ \ + if (RB_LEFT(elm, field)) { \ + elm = RB_LEFT(elm, field); \ + while (RB_RIGHT(elm, field)) \ + elm = RB_RIGHT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +attr struct type * \ +name##_RB_MINMAX(struct name *head, int val) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *parent = NULL; \ + while (tmp) { \ + parent = tmp; \ + if (val < 0) \ + tmp = RB_LEFT(tmp, field); \ + else \ + tmp = RB_RIGHT(tmp, field); \ + } \ + return (parent); \ +} + +#define RB_NEGINF -1 +#define RB_INF 1 + +#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) +#define RB_FIND(name, x, y) name##_RB_FIND(x, y) +#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) +#define RB_NEXT(name, x, y) name##_RB_NEXT(y) +#define RB_PREV(name, x, y) name##_RB_PREV(y) +#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) +#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) + +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(x)) + +#define RB_FOREACH_FROM(x, name, y) \ + for ((x) = (y); \ + ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_SAFE(x, name, head, y) \ + for ((x) = RB_MIN(name, head); \ + ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_REVERSE(x, name, head) \ + for ((x) = RB_MAX(name, head); \ + (x) != NULL; \ + (x) = name##_RB_PREV(x)) + +#define RB_FOREACH_REVERSE_FROM(x, name, y) \ + for ((x) = (y); \ + ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ + (x) = (y)) + +#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ + for ((x) = RB_MAX(name, head); \ + ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ + (x) = (y)) + +#endif /* UV_TREE_H_ */ diff --git a/third_party/libuv/include/uv/unix.h b/third_party/libuv/include/uv/unix.h index ea37d78768654eef98e10982a6b6ddce934bbbbf..4d0645c2fe433ae7dd5808b7eeb8b267af52f497 100644 --- a/third_party/libuv/include/uv/unix.h +++ b/third_party/libuv/include/uv/unix.h @@ -1,505 +1,505 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_UNIX_H -#define UV_UNIX_H - -#include -#include -#include -#include - -#include -#include -#include -#include -#include /* MAXHOSTNAMELEN on Solaris */ - -#include -#include - -#if !defined(__MVS__) -#include -#include /* MAXHOSTNAMELEN on Linux and the BSDs */ -#endif -#include -#include - -#include "uv/threadpool.h" - -#if defined(__linux__) -# include "uv/linux.h" -#elif defined (__MVS__) -# include "uv/os390.h" -#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */ -# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */ -#elif defined(_AIX) -# include "uv/aix.h" -#elif defined(__sun) -# include "uv/sunos.h" -#elif defined(__APPLE__) -# include "uv/darwin.h" -#elif defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# include "uv/bsd.h" -#elif defined(__CYGWIN__) || \ - defined(__MSYS__) || \ - defined(__HAIKU__) || \ - defined(__QNX__) || \ - defined(__GNU__) -# include "uv/posix.h" -#endif - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -# define NI_MAXSERV 32 -#endif - -#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS -# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -struct uv__io_s; -struct uv_loop_s; - -typedef void (*uv__io_cb)(struct uv_loop_s* loop, - struct uv__io_s* w, - unsigned int events); -typedef struct uv__io_s uv__io_t; - -struct uv__io_s { - uv__io_cb cb; - void* pending_queue[2]; - void* watcher_queue[2]; - unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ - unsigned int events; /* Current event mask. */ - int fd; - UV_IO_PRIVATE_PLATFORM_FIELDS -}; - -#ifndef UV_PLATFORM_SEM_T -# define UV_PLATFORM_SEM_T sem_t -#endif - -#ifndef UV_PLATFORM_LOOP_FIELDS -# define UV_PLATFORM_LOOP_FIELDS /* empty */ -#endif - -#ifndef UV_PLATFORM_FS_EVENT_FIELDS -# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ -#endif - -#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS -# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -/* Note: May be cast to struct iovec. See writev(2). */ -typedef struct uv_buf_t { - char* base; - size_t len; -} uv_buf_t; - -typedef int uv_file; -typedef int uv_os_sock_t; -typedef int uv_os_fd_t; -typedef pid_t uv_pid_t; - -#define UV_ONCE_INIT PTHREAD_ONCE_INIT - -typedef pthread_once_t uv_once_t; -typedef pthread_t uv_thread_t; -typedef pthread_mutex_t uv_mutex_t; -typedef pthread_rwlock_t uv_rwlock_t; -typedef UV_PLATFORM_SEM_T uv_sem_t; -typedef pthread_cond_t uv_cond_t; -typedef pthread_key_t uv_key_t; - -/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */ -#if defined(_AIX) || \ - defined(__OpenBSD__) || \ - !defined(PTHREAD_BARRIER_SERIAL_THREAD) -/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */ -struct _uv_barrier { - uv_mutex_t mutex; - uv_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -}; - -typedef struct { - struct _uv_barrier* b; -# if defined(PTHREAD_BARRIER_SERIAL_THREAD) - /* TODO(bnoordhuis) Remove padding in v2. */ - char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)]; -# endif -} uv_barrier_t; -#else -typedef pthread_barrier_t uv_barrier_t; -#endif - -/* Platform-specific definitions for uv_spawn support. */ -typedef gid_t uv_gid_t; -typedef uid_t uv_uid_t; - -typedef struct dirent uv__dirent_t; - -#define UV_DIR_PRIVATE_FIELDS \ - DIR* dir; - -#if defined(DT_UNKNOWN) -# define HAVE_DIRENT_TYPES -# if defined(DT_REG) -# define UV__DT_FILE DT_REG -# else -# define UV__DT_FILE -1 -# endif -# if defined(DT_DIR) -# define UV__DT_DIR DT_DIR -# else -# define UV__DT_DIR -2 -# endif -# if defined(DT_LNK) -# define UV__DT_LINK DT_LNK -# else -# define UV__DT_LINK -3 -# endif -# if defined(DT_FIFO) -# define UV__DT_FIFO DT_FIFO -# else -# define UV__DT_FIFO -4 -# endif -# if defined(DT_SOCK) -# define UV__DT_SOCKET DT_SOCK -# else -# define UV__DT_SOCKET -5 -# endif -# if defined(DT_CHR) -# define UV__DT_CHAR DT_CHR -# else -# define UV__DT_CHAR -6 -# endif -# if defined(DT_BLK) -# define UV__DT_BLOCK DT_BLK -# else -# define UV__DT_BLOCK -7 -# endif -#endif - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC /* empty */ - -typedef struct { - void* handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - unsigned long flags; \ - int backend_fd; \ - void* pending_queue[2]; \ - void* watcher_queue[2]; \ - uv__io_t** watchers; \ - unsigned int nwatchers; \ - unsigned int nfds; \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; \ - uv_rwlock_t cloexec_lock; \ - uv_handle_t* closing_handles; \ - void* process_handles[2]; \ - void* prepare_handles[2]; \ - void* check_handles[2]; \ - void* idle_handles[2]; \ - void* async_handles[2]; \ - void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ - uv__io_t async_io_watcher; \ - int async_wfd; \ - struct { \ - void* min; \ - unsigned int nelts; \ - } timer_heap; \ - uint64_t timer_counter; \ - uint64_t time; \ - int signal_pipefd[2]; \ - uv__io_t signal_io_watcher; \ - uv_signal_t child_watcher; \ - int emfile_fd; \ - UV_PLATFORM_LOOP_FIELDS \ - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#define UV_REQ_PRIVATE_FIELDS /* empty */ - -#define UV_PRIVATE_REQ_TYPES /* empty */ - -#define UV_WRITE_PRIVATE_FIELDS \ - void* queue[2]; \ - unsigned int write_index; \ - uv_buf_t* bufs; \ - unsigned int nbufs; \ - int error; \ - uv_buf_t bufsml[4]; \ - -#define UV_CONNECT_PRIVATE_FIELDS \ - void* queue[2]; \ - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - void* queue[2]; \ - struct sockaddr_storage addr; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[4]; \ - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* next_closing; \ - unsigned int flags; \ - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - void* queued_fds; \ - UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - -#define UV_TCP_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_PRIVATE_FIELDS \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - -#define UV_PIPE_PRIVATE_FIELDS \ - const char* pipe_fname; /* strdup'ed */ - -#define UV_POLL_PRIVATE_FIELDS \ - uv__io_t io_watcher; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ - void* queue[2]; \ - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ - void* queue[2]; \ - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ - void* queue[2]; \ - -#define UV_ASYNC_PRIVATE_FIELDS \ - uv_async_cb async_cb; \ - void* queue[2]; \ - int pending; \ - -#define UV_TIMER_PRIVATE_FIELDS \ - uv_timer_cb timer_cb; \ - void* heap_node[3]; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - void* queue[2]; \ - int status; \ - -#define UV_FS_PRIVATE_FIELDS \ - const char *new_path; \ - uv_file file; \ - int flags; \ - mode_t mode; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - off_t off; \ - uv_uid_t uid; \ - uv_gid_t gid; \ - double atime; \ - double mtime; \ - struct uv__work work_req; \ - uv_buf_t bufsml[4]; \ - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ - int mode; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - /* RB_ENTRY(uv_signal_s) tree_entry; */ \ - struct { \ - struct uv_signal_s* rbe_left; \ - struct uv_signal_s* rbe_right; \ - struct uv_signal_s* rbe_parent; \ - int rbe_color; \ - } tree_entry; \ - /* Use two counters here so we don have to fiddle with atomics. */ \ - unsigned int caught_signals; \ - unsigned int dispatched_signals; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - UV_PLATFORM_FS_EVENT_FIELDS \ - -/* fs open() flags supported on this platform: */ -#if defined(O_APPEND) -# define UV_FS_O_APPEND O_APPEND -#else -# define UV_FS_O_APPEND 0 -#endif -#if defined(O_CREAT) -# define UV_FS_O_CREAT O_CREAT -#else -# define UV_FS_O_CREAT 0 -#endif - -#if defined(__linux__) && defined(__arm__) -# define UV_FS_O_DIRECT 0x10000 -#elif defined(__linux__) && defined(__m68k__) -# define UV_FS_O_DIRECT 0x10000 -#elif defined(__linux__) && defined(__mips__) -# define UV_FS_O_DIRECT 0x08000 -#elif defined(__linux__) && defined(__powerpc__) -# define UV_FS_O_DIRECT 0x20000 -#elif defined(__linux__) && defined(__s390x__) -# define UV_FS_O_DIRECT 0x04000 -#elif defined(__linux__) && defined(__x86_64__) -# define UV_FS_O_DIRECT 0x04000 -#elif defined(O_DIRECT) -# define UV_FS_O_DIRECT O_DIRECT -#else -# define UV_FS_O_DIRECT 0 -#endif - -#if defined(O_DIRECTORY) -# define UV_FS_O_DIRECTORY O_DIRECTORY -#else -# define UV_FS_O_DIRECTORY 0 -#endif -#if defined(O_DSYNC) -# define UV_FS_O_DSYNC O_DSYNC -#else -# define UV_FS_O_DSYNC 0 -#endif -#if defined(O_EXCL) -# define UV_FS_O_EXCL O_EXCL -#else -# define UV_FS_O_EXCL 0 -#endif -#if defined(O_EXLOCK) -# define UV_FS_O_EXLOCK O_EXLOCK -#else -# define UV_FS_O_EXLOCK 0 -#endif -#if defined(O_NOATIME) -# define UV_FS_O_NOATIME O_NOATIME -#else -# define UV_FS_O_NOATIME 0 -#endif -#if defined(O_NOCTTY) -# define UV_FS_O_NOCTTY O_NOCTTY -#else -# define UV_FS_O_NOCTTY 0 -#endif -#if defined(O_NOFOLLOW) -# define UV_FS_O_NOFOLLOW O_NOFOLLOW -#else -# define UV_FS_O_NOFOLLOW 0 -#endif -#if defined(O_NONBLOCK) -# define UV_FS_O_NONBLOCK O_NONBLOCK -#else -# define UV_FS_O_NONBLOCK 0 -#endif -#if defined(O_RDONLY) -# define UV_FS_O_RDONLY O_RDONLY -#else -# define UV_FS_O_RDONLY 0 -#endif -#if defined(O_RDWR) -# define UV_FS_O_RDWR O_RDWR -#else -# define UV_FS_O_RDWR 0 -#endif -#if defined(O_SYMLINK) -# define UV_FS_O_SYMLINK O_SYMLINK -#else -# define UV_FS_O_SYMLINK 0 -#endif -#if defined(O_SYNC) -# define UV_FS_O_SYNC O_SYNC -#else -# define UV_FS_O_SYNC 0 -#endif -#if defined(O_TRUNC) -# define UV_FS_O_TRUNC O_TRUNC -#else -# define UV_FS_O_TRUNC 0 -#endif -#if defined(O_WRONLY) -# define UV_FS_O_WRONLY O_WRONLY -#else -# define UV_FS_O_WRONLY 0 -#endif - -/* fs open() flags supported on other platforms: */ -#define UV_FS_O_FILEMAP 0 -#define UV_FS_O_RANDOM 0 -#define UV_FS_O_SHORT_LIVED 0 -#define UV_FS_O_SEQUENTIAL 0 -#define UV_FS_O_TEMPORARY 0 - -#endif /* UV_UNIX_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_UNIX_H +#define UV_UNIX_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include /* MAXHOSTNAMELEN on Solaris */ + +#include +#include + +#if !defined(__MVS__) +#include +#include /* MAXHOSTNAMELEN on Linux and the BSDs */ +#endif +#include +#include + +#include "uv/threadpool.h" + +#if defined(__linux__) +# include "uv/linux.h" +#elif defined (__MVS__) +# include "uv/os390.h" +#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */ +# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */ +#elif defined(_AIX) +# include "uv/aix.h" +#elif defined(__sun) +# include "uv/sunos.h" +#elif defined(__APPLE__) +# include "uv/darwin.h" +#elif defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__FreeBSD_kernel__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) +# include "uv/bsd.h" +#elif defined(__CYGWIN__) || \ + defined(__MSYS__) || \ + defined(__HAIKU__) || \ + defined(__QNX__) || \ + defined(__GNU__) +# include "uv/posix.h" +#endif + +#ifndef NI_MAXHOST +# define NI_MAXHOST 1025 +#endif + +#ifndef NI_MAXSERV +# define NI_MAXSERV 32 +#endif + +#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS +# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ +#endif + +struct uv__io_s; +struct uv_loop_s; + +typedef void (*uv__io_cb)(struct uv_loop_s* loop, + struct uv__io_s* w, + unsigned int events); +typedef struct uv__io_s uv__io_t; + +struct uv__io_s { + uv__io_cb cb; + void* pending_queue[2]; + void* watcher_queue[2]; + unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ + unsigned int events; /* Current event mask. */ + int fd; + UV_IO_PRIVATE_PLATFORM_FIELDS +}; + +#ifndef UV_PLATFORM_SEM_T +# define UV_PLATFORM_SEM_T sem_t +#endif + +#ifndef UV_PLATFORM_LOOP_FIELDS +# define UV_PLATFORM_LOOP_FIELDS /* empty */ +#endif + +#ifndef UV_PLATFORM_FS_EVENT_FIELDS +# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ +#endif + +#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS +# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ +#endif + +/* Note: May be cast to struct iovec. See writev(2). */ +typedef struct uv_buf_t { + char* base; + size_t len; +} uv_buf_t; + +typedef int uv_file; +typedef int uv_os_sock_t; +typedef int uv_os_fd_t; +typedef pid_t uv_pid_t; + +#define UV_ONCE_INIT PTHREAD_ONCE_INIT + +typedef pthread_once_t uv_once_t; +typedef pthread_t uv_thread_t; +typedef pthread_mutex_t uv_mutex_t; +typedef pthread_rwlock_t uv_rwlock_t; +typedef UV_PLATFORM_SEM_T uv_sem_t; +typedef pthread_cond_t uv_cond_t; +typedef pthread_key_t uv_key_t; + +/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */ +#if defined(_AIX) || \ + defined(__OpenBSD__) || \ + !defined(PTHREAD_BARRIER_SERIAL_THREAD) +/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */ +struct _uv_barrier { + uv_mutex_t mutex; + uv_cond_t cond; + unsigned threshold; + unsigned in; + unsigned out; +}; + +typedef struct { + struct _uv_barrier* b; +# if defined(PTHREAD_BARRIER_SERIAL_THREAD) + /* TODO(bnoordhuis) Remove padding in v2. */ + char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)]; +# endif +} uv_barrier_t; +#else +typedef pthread_barrier_t uv_barrier_t; +#endif + +/* Platform-specific definitions for uv_spawn support. */ +typedef gid_t uv_gid_t; +typedef uid_t uv_uid_t; + +typedef struct dirent uv__dirent_t; + +#define UV_DIR_PRIVATE_FIELDS \ + DIR* dir; + +#if defined(DT_UNKNOWN) +# define HAVE_DIRENT_TYPES +# if defined(DT_REG) +# define UV__DT_FILE DT_REG +# else +# define UV__DT_FILE -1 +# endif +# if defined(DT_DIR) +# define UV__DT_DIR DT_DIR +# else +# define UV__DT_DIR -2 +# endif +# if defined(DT_LNK) +# define UV__DT_LINK DT_LNK +# else +# define UV__DT_LINK -3 +# endif +# if defined(DT_FIFO) +# define UV__DT_FIFO DT_FIFO +# else +# define UV__DT_FIFO -4 +# endif +# if defined(DT_SOCK) +# define UV__DT_SOCKET DT_SOCK +# else +# define UV__DT_SOCKET -5 +# endif +# if defined(DT_CHR) +# define UV__DT_CHAR DT_CHR +# else +# define UV__DT_CHAR -6 +# endif +# if defined(DT_BLK) +# define UV__DT_BLOCK DT_BLK +# else +# define UV__DT_BLOCK -7 +# endif +#endif + +/* Platform-specific definitions for uv_dlopen support. */ +#define UV_DYNAMIC /* empty */ + +typedef struct { + void* handle; + char* errmsg; +} uv_lib_t; + +#define UV_LOOP_PRIVATE_FIELDS \ + unsigned long flags; \ + int backend_fd; \ + void* pending_queue[2]; \ + void* watcher_queue[2]; \ + uv__io_t** watchers; \ + unsigned int nwatchers; \ + unsigned int nfds; \ + void* wq[2]; \ + uv_mutex_t wq_mutex; \ + uv_async_t wq_async; \ + uv_rwlock_t cloexec_lock; \ + uv_handle_t* closing_handles; \ + void* process_handles[2]; \ + void* prepare_handles[2]; \ + void* check_handles[2]; \ + void* idle_handles[2]; \ + void* async_handles[2]; \ + void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ + uv__io_t async_io_watcher; \ + int async_wfd; \ + struct { \ + void* min; \ + unsigned int nelts; \ + } timer_heap; \ + uint64_t timer_counter; \ + uint64_t time; \ + int signal_pipefd[2]; \ + uv__io_t signal_io_watcher; \ + uv_signal_t child_watcher; \ + int emfile_fd; \ + UV_PLATFORM_LOOP_FIELDS \ + +#define UV_REQ_TYPE_PRIVATE /* empty */ + +#define UV_REQ_PRIVATE_FIELDS /* empty */ + +#define UV_PRIVATE_REQ_TYPES /* empty */ + +#define UV_WRITE_PRIVATE_FIELDS \ + void* queue[2]; \ + unsigned int write_index; \ + uv_buf_t* bufs; \ + unsigned int nbufs; \ + int error; \ + uv_buf_t bufsml[4]; \ + +#define UV_CONNECT_PRIVATE_FIELDS \ + void* queue[2]; \ + +#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ + +#define UV_UDP_SEND_PRIVATE_FIELDS \ + void* queue[2]; \ + struct sockaddr_storage addr; \ + unsigned int nbufs; \ + uv_buf_t* bufs; \ + ssize_t status; \ + uv_udp_send_cb send_cb; \ + uv_buf_t bufsml[4]; \ + +#define UV_HANDLE_PRIVATE_FIELDS \ + uv_handle_t* next_closing; \ + unsigned int flags; \ + +#define UV_STREAM_PRIVATE_FIELDS \ + uv_connect_t *connect_req; \ + uv_shutdown_t *shutdown_req; \ + uv__io_t io_watcher; \ + void* write_queue[2]; \ + void* write_completed_queue[2]; \ + uv_connection_cb connection_cb; \ + int delayed_error; \ + int accepted_fd; \ + void* queued_fds; \ + UV_STREAM_PRIVATE_PLATFORM_FIELDS \ + +#define UV_TCP_PRIVATE_FIELDS /* empty */ + +#define UV_UDP_PRIVATE_FIELDS \ + uv_alloc_cb alloc_cb; \ + uv_udp_recv_cb recv_cb; \ + uv__io_t io_watcher; \ + void* write_queue[2]; \ + void* write_completed_queue[2]; \ + +#define UV_PIPE_PRIVATE_FIELDS \ + const char* pipe_fname; /* strdup'ed */ + +#define UV_POLL_PRIVATE_FIELDS \ + uv__io_t io_watcher; + +#define UV_PREPARE_PRIVATE_FIELDS \ + uv_prepare_cb prepare_cb; \ + void* queue[2]; \ + +#define UV_CHECK_PRIVATE_FIELDS \ + uv_check_cb check_cb; \ + void* queue[2]; \ + +#define UV_IDLE_PRIVATE_FIELDS \ + uv_idle_cb idle_cb; \ + void* queue[2]; \ + +#define UV_ASYNC_PRIVATE_FIELDS \ + uv_async_cb async_cb; \ + void* queue[2]; \ + int pending; \ + +#define UV_TIMER_PRIVATE_FIELDS \ + uv_timer_cb timer_cb; \ + void* heap_node[3]; \ + uint64_t timeout; \ + uint64_t repeat; \ + uint64_t start_id; + +#define UV_GETADDRINFO_PRIVATE_FIELDS \ + struct uv__work work_req; \ + uv_getaddrinfo_cb cb; \ + struct addrinfo* hints; \ + char* hostname; \ + char* service; \ + struct addrinfo* addrinfo; \ + int retcode; + +#define UV_GETNAMEINFO_PRIVATE_FIELDS \ + struct uv__work work_req; \ + uv_getnameinfo_cb getnameinfo_cb; \ + struct sockaddr_storage storage; \ + int flags; \ + char host[NI_MAXHOST]; \ + char service[NI_MAXSERV]; \ + int retcode; + +#define UV_PROCESS_PRIVATE_FIELDS \ + void* queue[2]; \ + int status; \ + +#define UV_FS_PRIVATE_FIELDS \ + const char *new_path; \ + uv_file file; \ + int flags; \ + mode_t mode; \ + unsigned int nbufs; \ + uv_buf_t* bufs; \ + off_t off; \ + uv_uid_t uid; \ + uv_gid_t gid; \ + double atime; \ + double mtime; \ + struct uv__work work_req; \ + uv_buf_t bufsml[4]; \ + +#define UV_WORK_PRIVATE_FIELDS \ + struct uv__work work_req; + +#define UV_TTY_PRIVATE_FIELDS \ + struct termios orig_termios; \ + int mode; + +#define UV_SIGNAL_PRIVATE_FIELDS \ + /* RB_ENTRY(uv_signal_s) tree_entry; */ \ + struct { \ + struct uv_signal_s* rbe_left; \ + struct uv_signal_s* rbe_right; \ + struct uv_signal_s* rbe_parent; \ + int rbe_color; \ + } tree_entry; \ + /* Use two counters here so we don have to fiddle with atomics. */ \ + unsigned int caught_signals; \ + unsigned int dispatched_signals; + +#define UV_FS_EVENT_PRIVATE_FIELDS \ + uv_fs_event_cb cb; \ + UV_PLATFORM_FS_EVENT_FIELDS \ + +/* fs open() flags supported on this platform: */ +#if defined(O_APPEND) +# define UV_FS_O_APPEND O_APPEND +#else +# define UV_FS_O_APPEND 0 +#endif +#if defined(O_CREAT) +# define UV_FS_O_CREAT O_CREAT +#else +# define UV_FS_O_CREAT 0 +#endif + +#if defined(__linux__) && defined(__arm__) +# define UV_FS_O_DIRECT 0x10000 +#elif defined(__linux__) && defined(__m68k__) +# define UV_FS_O_DIRECT 0x10000 +#elif defined(__linux__) && defined(__mips__) +# define UV_FS_O_DIRECT 0x08000 +#elif defined(__linux__) && defined(__powerpc__) +# define UV_FS_O_DIRECT 0x20000 +#elif defined(__linux__) && defined(__s390x__) +# define UV_FS_O_DIRECT 0x04000 +#elif defined(__linux__) && defined(__x86_64__) +# define UV_FS_O_DIRECT 0x04000 +#elif defined(O_DIRECT) +# define UV_FS_O_DIRECT O_DIRECT +#else +# define UV_FS_O_DIRECT 0 +#endif + +#if defined(O_DIRECTORY) +# define UV_FS_O_DIRECTORY O_DIRECTORY +#else +# define UV_FS_O_DIRECTORY 0 +#endif +#if defined(O_DSYNC) +# define UV_FS_O_DSYNC O_DSYNC +#else +# define UV_FS_O_DSYNC 0 +#endif +#if defined(O_EXCL) +# define UV_FS_O_EXCL O_EXCL +#else +# define UV_FS_O_EXCL 0 +#endif +#if defined(O_EXLOCK) +# define UV_FS_O_EXLOCK O_EXLOCK +#else +# define UV_FS_O_EXLOCK 0 +#endif +#if defined(O_NOATIME) +# define UV_FS_O_NOATIME O_NOATIME +#else +# define UV_FS_O_NOATIME 0 +#endif +#if defined(O_NOCTTY) +# define UV_FS_O_NOCTTY O_NOCTTY +#else +# define UV_FS_O_NOCTTY 0 +#endif +#if defined(O_NOFOLLOW) +# define UV_FS_O_NOFOLLOW O_NOFOLLOW +#else +# define UV_FS_O_NOFOLLOW 0 +#endif +#if defined(O_NONBLOCK) +# define UV_FS_O_NONBLOCK O_NONBLOCK +#else +# define UV_FS_O_NONBLOCK 0 +#endif +#if defined(O_RDONLY) +# define UV_FS_O_RDONLY O_RDONLY +#else +# define UV_FS_O_RDONLY 0 +#endif +#if defined(O_RDWR) +# define UV_FS_O_RDWR O_RDWR +#else +# define UV_FS_O_RDWR 0 +#endif +#if defined(O_SYMLINK) +# define UV_FS_O_SYMLINK O_SYMLINK +#else +# define UV_FS_O_SYMLINK 0 +#endif +#if defined(O_SYNC) +# define UV_FS_O_SYNC O_SYNC +#else +# define UV_FS_O_SYNC 0 +#endif +#if defined(O_TRUNC) +# define UV_FS_O_TRUNC O_TRUNC +#else +# define UV_FS_O_TRUNC 0 +#endif +#if defined(O_WRONLY) +# define UV_FS_O_WRONLY O_WRONLY +#else +# define UV_FS_O_WRONLY 0 +#endif + +/* fs open() flags supported on other platforms: */ +#define UV_FS_O_FILEMAP 0 +#define UV_FS_O_RANDOM 0 +#define UV_FS_O_SHORT_LIVED 0 +#define UV_FS_O_SEQUENTIAL 0 +#define UV_FS_O_TEMPORARY 0 + +#endif /* UV_UNIX_H */ diff --git a/third_party/libuv/include/uv/version.h b/third_party/libuv/include/uv/version.h index 56ac1bf41d6d3c20439b0c71dd6d81a20481c120..8db0ec20e929d8d8d0c741360215d0d1051ffb1c 100644 --- a/third_party/libuv/include/uv/version.h +++ b/third_party/libuv/include/uv/version.h @@ -1,43 +1,43 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_VERSION_H -#define UV_VERSION_H - - /* - * Versions with the same major number are ABI stable. API is allowed to - * evolve between minor releases, but only in a backwards compatible way. - * Make sure you update the -soname directives in configure.ac - * whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but - * not UV_VERSION_PATCH.) - */ - -#define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 44 -#define UV_VERSION_PATCH 1 -#define UV_VERSION_IS_RELEASE 1 -#define UV_VERSION_SUFFIX "" - -#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ - (UV_VERSION_MINOR << 8) | \ - (UV_VERSION_PATCH)) - -#endif /* UV_VERSION_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UV_VERSION_H +#define UV_VERSION_H + + /* + * Versions with the same major number are ABI stable. API is allowed to + * evolve between minor releases, but only in a backwards compatible way. + * Make sure you update the -soname directives in configure.ac + * whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but + * not UV_VERSION_PATCH.) + */ + +#define UV_VERSION_MAJOR 1 +#define UV_VERSION_MINOR 44 +#define UV_VERSION_PATCH 1 +#define UV_VERSION_IS_RELEASE 1 +#define UV_VERSION_SUFFIX "" + +#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ + (UV_VERSION_MINOR << 8) | \ + (UV_VERSION_PATCH)) + +#endif /* UV_VERSION_H */ diff --git a/third_party/libuv/include/uv/win.h b/third_party/libuv/include/uv/win.h index 62be4b04ea81286bcff9a2f1dc7fee7f0df5c0bc..1063fb43f3f0df387d61f90ea6eead1c28d04c62 100644 --- a/third_party/libuv/include/uv/win.h +++ b/third_party/libuv/include/uv/win.h @@ -1,691 +1,691 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0600 -#endif - -#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define SSIZE_MAX INTPTR_MAX -# define _SSIZE_T_ -# define _SSIZE_T_DEFINED -#endif - -#include - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct pollfd { - SOCKET fd; - short events; - short revents; -} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; -#endif - -#ifndef LOCALE_INVARIANT -# define LOCALE_INVARIANT 0x007f -#endif - -#include -// Disable the typedef in mstcpip.h of MinGW. -#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID -#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID -#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID -#include -#undef _TCP_INITIAL_RTO_PARAMETERS -#undef TCP_INITIAL_RTO_PARAMETERS -#undef PTCP_INITIAL_RTO_PARAMETERS -#include - -#include -#include -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "uv/stdint-msvc2008.h" -#else -# include -#endif - -#include "uv/tree.h" -#include "uv/threadpool.h" - -#define MAX_PIPENAME_LEN 256 - -#ifndef S_IFLNK -# define S_IFLNK 0xA000 -#endif - -/* Additional signals supported by uv_signal and or uv_kill. The CRT defines - * the following signals already: - * - * #define SIGINT 2 - * #define SIGILL 4 - * #define SIGABRT_COMPAT 6 - * #define SIGFPE 8 - * #define SIGSEGV 11 - * #define SIGTERM 15 - * #define SIGBREAK 21 - * #define SIGABRT 22 - * - * The additional signals have values that are common on other Unix - * variants (Linux and Darwin) - */ -#define SIGHUP 1 -#define SIGKILL 9 -#define SIGWINCH 28 - -/* Redefine NSIG to take SIGWINCH into consideration */ -#if defined(NSIG) && NSIG <= SIGWINCH -# undef NSIG -#endif -#ifndef NSIG -# define NSIG SIGWINCH + 1 -#endif - -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like - * platforms. However MinGW doesn't define it, so we do. */ -#ifndef SIGABRT_COMPAT -# define SIGABRT_COMPAT 6 -#endif - -/* - * Guids and typedefs for winsock extension functions - * Mingw32 doesn't have these :-( - */ -#ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ - {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} - -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ - {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} - -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - - typedef BOOL (PASCAL *LPFN_ACCEPTEX) - (SOCKET sListenSocket, - SOCKET sAcceptSocket, - PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPDWORD lpdwBytesReceived, - LPOVERLAPPED lpOverlapped); - - typedef BOOL (PASCAL *LPFN_CONNECTEX) - (SOCKET s, - const struct sockaddr* name, - int namelen, - PVOID lpSendBuffer, - DWORD dwSendDataLength, - LPDWORD lpdwBytesSent, - LPOVERLAPPED lpOverlapped); - - typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) - (PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPSOCKADDR* LocalSockaddr, - LPINT LocalSockaddrLength, - LPSOCKADDR* RemoteSockaddr, - LPINT RemoteSockaddrLength); - - typedef BOOL (PASCAL *LPFN_DISCONNECTEX) - (SOCKET hSocket, - LPOVERLAPPED lpOverlapped, - DWORD dwFlags, - DWORD reserved); - - typedef BOOL (PASCAL *LPFN_TRANSMITFILE) - (SOCKET hSocket, - HANDLE hFile, - DWORD nNumberOfBytesToWrite, - DWORD nNumberOfBytesPerSend, - LPOVERLAPPED lpOverlapped, - LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, - DWORD dwFlags); - - typedef PVOID RTL_SRWLOCK; - typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif - -typedef int (WSAAPI* LPFN_WSARECV) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -typedef int (WSAAPI* LPFN_WSARECVFROM) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - struct sockaddr* addr, - LPINT addr_len, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -#ifndef _NTDEF_ - typedef LONG NTSTATUS; - typedef NTSTATUS *PNTSTATUS; -#endif - -#ifndef RTL_CONDITION_VARIABLE_INIT - typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; -#endif - -typedef struct _AFD_POLL_HANDLE_INFO { - HANDLE Handle; - ULONG Events; - NTSTATUS Status; -} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; - -typedef struct _AFD_POLL_INFO { - LARGE_INTEGER Timeout; - ULONG NumberOfHandles; - ULONG Exclusive; - AFD_POLL_HANDLE_INFO Handles[1]; -} AFD_POLL_INFO, *PAFD_POLL_INFO; - -#define UV_MSAFD_PROVIDER_COUNT 4 - - -/** - * It should be possible to cast uv_buf_t[] to WSABUF[] - * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx - */ -typedef struct uv_buf_t { - ULONG len; - char* base; -} uv_buf_t; - -typedef int uv_file; -typedef SOCKET uv_os_sock_t; -typedef HANDLE uv_os_fd_t; -typedef int uv_pid_t; - -typedef HANDLE uv_thread_t; - -typedef HANDLE uv_sem_t; - -typedef CRITICAL_SECTION uv_mutex_t; - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -typedef union { - CONDITION_VARIABLE cond_var; - struct { - unsigned int waiters_count; - CRITICAL_SECTION waiters_count_lock; - HANDLE signal_event; - HANDLE broadcast_event; - } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ -} uv_cond_t; - -typedef struct { - SRWLOCK read_write_lock_; - /* TODO: retained for ABI compatibility; remove me in v2.x */ -#ifdef _WIN64 - unsigned char padding_[72]; -#else - unsigned char padding_[44]; -#endif -} uv_rwlock_t; - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -typedef struct { - DWORD tls_index; -} uv_key_t; - -#define UV_ONCE_INIT { 0, NULL } - -typedef struct uv_once_s { - unsigned char ran; - HANDLE event; -} uv_once_t; - -/* Platform-specific definitions for uv_spawn support. */ -typedef unsigned char uv_uid_t; -typedef unsigned char uv_gid_t; - -typedef struct uv__dirent_s { - int d_type; - char d_name[1]; -} uv__dirent_t; - -#define UV_DIR_PRIVATE_FIELDS \ - HANDLE dir_handle; \ - WIN32_FIND_DATAW find_data; \ - BOOL need_find_call; - -#define HAVE_DIRENT_TYPES -#define UV__DT_DIR UV_DIRENT_DIR -#define UV__DT_FILE UV_DIRENT_FILE -#define UV__DT_LINK UV_DIRENT_LINK -#define UV__DT_FIFO UV_DIRENT_FIFO -#define UV__DT_SOCKET UV_DIRENT_SOCKET -#define UV__DT_CHAR UV_DIRENT_CHAR -#define UV__DT_BLOCK UV_DIRENT_BLOCK - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC FAR WINAPI -typedef struct { - HMODULE handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - /* The loop's I/O completion port */ \ - HANDLE iocp; \ - /* The current time according to the event loop. in msecs. */ \ - uint64_t time; \ - /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ - /* is empty, tail_ is NULL. If there is only one item, */ \ - /* tail_->next_req == tail_ */ \ - uv_req_t* pending_reqs_tail; \ - /* Head of a single-linked list of closed handles */ \ - uv_handle_t* endgame_handles; \ - /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \ - void* timer_heap; \ - /* Lists of active loop (prepare / check / idle) watchers */ \ - uv_prepare_t* prepare_handles; \ - uv_check_t* check_handles; \ - uv_idle_t* idle_handles; \ - /* This pointer will refer to the prepare/check/idle handle whose */ \ - /* callback is scheduled to be called next. This is needed to allow */ \ - /* safe removal from one of the lists above while that list being */ \ - /* iterated over. */ \ - uv_prepare_t* next_prepare_handle; \ - uv_check_t* next_check_handle; \ - uv_idle_t* next_idle_handle; \ - /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ - /* Counter to keep track of active tcp streams */ \ - unsigned int active_tcp_streams; \ - /* Counter to keep track of active udp streams */ \ - unsigned int active_udp_streams; \ - /* Counter to started timer */ \ - uint64_t timer_counter; \ - /* Threadpool */ \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; - -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, \ - UV_SIGNAL_REQ, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - } io; \ - } u; \ - struct uv_req_s* next_req; - -#define UV_WRITE_PRIVATE_FIELDS \ - int coalesced; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ - HANDLE wait_handle; - -#define UV_CONNECT_PRIVATE_FIELDS \ - /* empty */ - -#define UV_SHUTDOWN_PRIVATE_FIELDS \ - /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - /* empty */ - -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - } uv_read_t; - -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ - uv_shutdown_t* shutdown_req; - -#define uv_stream_server_fields \ - uv_connection_cb connection_cb; - -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields } conn; \ - struct { uv_stream_server_fields } serv; \ - } stream; - -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ - LPFN_ACCEPTEX func_acceptex; - -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ - LPFN_CONNECTEX func_connectex; - -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int delayed_error; \ - union { \ - struct { uv_tcp_server_fields } serv; \ - struct { uv_tcp_connection_fields } conn; \ - } tcp; - -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ - LPFN_WSARECVFROM func_wsarecvfrom; - -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ - uv_pipe_accept_t* pending_accepts; - -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ - DWORD ipc_remote_pid; \ - union { \ - uint32_t payload_remaining; \ - uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ - } ipc_data_frame; \ - void* ipc_xfer_queue[2]; \ - int ipc_xfer_queue_length; \ - uv_write_t* non_overlapped_writes_tail; \ - CRITICAL_SECTION readfile_thread_lock; \ - volatile HANDLE readfile_thread_handle; - -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - WCHAR* name; \ - union { \ - struct { uv_pipe_server_fields } serv; \ - struct { uv_pipe_connection_fields } conn; \ - } pipe; - -/* TODO: put the parser states in an union - TTY handles are always half-duplex - * so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - union { \ - struct { \ - /* Used for readable TTY handles */ \ - /* TODO: remove me in v2.x. */ \ - HANDLE unused_; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - /* Fields used for translating win keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - WCHAR last_utf16_high_surrogate; \ - INPUT_RECORD last_input_record; \ - } rd; \ - struct { \ - /* Used for writable TTY handles */ \ - /* utf8-to-utf16 conversion state */ \ - unsigned int utf8_codepoint; \ - unsigned char utf8_bytes_left; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned short ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; \ - } wr; \ - } tty; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ - unsigned char events; - -#define UV_TIMER_PRIVATE_FIELDS \ - void* heap_node[3]; \ - int unused; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; \ - uv_timer_cb timer_cb; - -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ - char volatile async_sent; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ - uv_prepare_cb prepare_cb; - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ - uv_check_cb check_cb; - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ - uv_idle_cb idle_cb; - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ - unsigned int flags; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - WCHAR* node; \ - WCHAR* service; \ - /* The addrinfoW field is used to store a pointer to the hints, and */ \ - /* later on to store the result of GetAddrInfoW. The final result will */ \ - /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ - struct addrinfoW* addrinfow; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - volatile char exit_cb_pending; - -#define UV_FS_PRIVATE_FIELDS \ - struct uv__work work_req; \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - } file; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - int64_t offset; \ - uv_buf_t bufsml[4]; \ - } info; \ - struct { \ - double atime; \ - double mtime; \ - } time; \ - } fs; - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - struct uv_fs_event_req_s { \ - UV_REQ_FIELDS \ - } req; \ - HANDLE dir_handle; \ - int req_pending; \ - uv_fs_event_cb cb; \ - WCHAR* filew; \ - WCHAR* short_filew; \ - WCHAR* dirw; \ - char* buffer; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - RB_ENTRY(uv_signal_s) tree_entry; \ - struct uv_req_s signal_req; \ - unsigned long pending_signum; - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif - -/* fs open() flags supported on this platform: */ -#define UV_FS_O_APPEND _O_APPEND -#define UV_FS_O_CREAT _O_CREAT -#define UV_FS_O_EXCL _O_EXCL -#define UV_FS_O_FILEMAP 0x20000000 -#define UV_FS_O_RANDOM _O_RANDOM -#define UV_FS_O_RDONLY _O_RDONLY -#define UV_FS_O_RDWR _O_RDWR -#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL -#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED -#define UV_FS_O_TEMPORARY _O_TEMPORARY -#define UV_FS_O_TRUNC _O_TRUNC -#define UV_FS_O_WRONLY _O_WRONLY - -/* fs open() flags supported on other platforms (or mapped on this platform): */ -#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */ -#define UV_FS_O_DIRECTORY 0 -#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */ -#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */ -#define UV_FS_O_NOATIME 0 -#define UV_FS_O_NOCTTY 0 -#define UV_FS_O_NOFOLLOW 0 -#define UV_FS_O_NONBLOCK 0 -#define UV_FS_O_SYMLINK 0 -#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +#endif + +#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) +typedef intptr_t ssize_t; +# define SSIZE_MAX INTPTR_MAX +# define _SSIZE_T_ +# define _SSIZE_T_DEFINED +#endif + +#include + +#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) +typedef struct pollfd { + SOCKET fd; + short events; + short revents; +} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; +#endif + +#ifndef LOCALE_INVARIANT +# define LOCALE_INVARIANT 0x007f +#endif + +#include +// Disable the typedef in mstcpip.h of MinGW. +#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID +#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID +#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID +#include +#undef _TCP_INITIAL_RTO_PARAMETERS +#undef TCP_INITIAL_RTO_PARAMETERS +#undef PTCP_INITIAL_RTO_PARAMETERS +#include + +#include +#include +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1600 +# include "uv/stdint-msvc2008.h" +#else +# include +#endif + +#include "uv/tree.h" +#include "uv/threadpool.h" + +#define MAX_PIPENAME_LEN 256 + +#ifndef S_IFLNK +# define S_IFLNK 0xA000 +#endif + +/* Additional signals supported by uv_signal and or uv_kill. The CRT defines + * the following signals already: + * + * #define SIGINT 2 + * #define SIGILL 4 + * #define SIGABRT_COMPAT 6 + * #define SIGFPE 8 + * #define SIGSEGV 11 + * #define SIGTERM 15 + * #define SIGBREAK 21 + * #define SIGABRT 22 + * + * The additional signals have values that are common on other Unix + * variants (Linux and Darwin) + */ +#define SIGHUP 1 +#define SIGKILL 9 +#define SIGWINCH 28 + +/* Redefine NSIG to take SIGWINCH into consideration */ +#if defined(NSIG) && NSIG <= SIGWINCH +# undef NSIG +#endif +#ifndef NSIG +# define NSIG SIGWINCH + 1 +#endif + +/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like + * platforms. However MinGW doesn't define it, so we do. */ +#ifndef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif + +/* + * Guids and typedefs for winsock extension functions + * Mingw32 doesn't have these :-( + */ +#ifndef WSAID_ACCEPTEX +# define WSAID_ACCEPTEX \ + {0xb5367df1, 0xcbac, 0x11cf, \ + {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} + +# define WSAID_CONNECTEX \ + {0x25a207b9, 0xddf3, 0x4660, \ + {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} + +# define WSAID_GETACCEPTEXSOCKADDRS \ + {0xb5367df2, 0xcbac, 0x11cf, \ + {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} + +# define WSAID_DISCONNECTEX \ + {0x7fda2e11, 0x8630, 0x436f, \ + {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} + +# define WSAID_TRANSMITFILE \ + {0xb5367df0, 0xcbac, 0x11cf, \ + {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} + + typedef BOOL (PASCAL *LPFN_ACCEPTEX) + (SOCKET sListenSocket, + SOCKET sAcceptSocket, + PVOID lpOutputBuffer, + DWORD dwReceiveDataLength, + DWORD dwLocalAddressLength, + DWORD dwRemoteAddressLength, + LPDWORD lpdwBytesReceived, + LPOVERLAPPED lpOverlapped); + + typedef BOOL (PASCAL *LPFN_CONNECTEX) + (SOCKET s, + const struct sockaddr* name, + int namelen, + PVOID lpSendBuffer, + DWORD dwSendDataLength, + LPDWORD lpdwBytesSent, + LPOVERLAPPED lpOverlapped); + + typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) + (PVOID lpOutputBuffer, + DWORD dwReceiveDataLength, + DWORD dwLocalAddressLength, + DWORD dwRemoteAddressLength, + LPSOCKADDR* LocalSockaddr, + LPINT LocalSockaddrLength, + LPSOCKADDR* RemoteSockaddr, + LPINT RemoteSockaddrLength); + + typedef BOOL (PASCAL *LPFN_DISCONNECTEX) + (SOCKET hSocket, + LPOVERLAPPED lpOverlapped, + DWORD dwFlags, + DWORD reserved); + + typedef BOOL (PASCAL *LPFN_TRANSMITFILE) + (SOCKET hSocket, + HANDLE hFile, + DWORD nNumberOfBytesToWrite, + DWORD nNumberOfBytesPerSend, + LPOVERLAPPED lpOverlapped, + LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, + DWORD dwFlags); + + typedef PVOID RTL_SRWLOCK; + typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; +#endif + +typedef int (WSAAPI* LPFN_WSARECV) + (SOCKET socket, + LPWSABUF buffers, + DWORD buffer_count, + LPDWORD bytes, + LPDWORD flags, + LPWSAOVERLAPPED overlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); + +typedef int (WSAAPI* LPFN_WSARECVFROM) + (SOCKET socket, + LPWSABUF buffers, + DWORD buffer_count, + LPDWORD bytes, + LPDWORD flags, + struct sockaddr* addr, + LPINT addr_len, + LPWSAOVERLAPPED overlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); + +#ifndef _NTDEF_ + typedef LONG NTSTATUS; + typedef NTSTATUS *PNTSTATUS; +#endif + +#ifndef RTL_CONDITION_VARIABLE_INIT + typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; +#endif + +typedef struct _AFD_POLL_HANDLE_INFO { + HANDLE Handle; + ULONG Events; + NTSTATUS Status; +} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; + +typedef struct _AFD_POLL_INFO { + LARGE_INTEGER Timeout; + ULONG NumberOfHandles; + ULONG Exclusive; + AFD_POLL_HANDLE_INFO Handles[1]; +} AFD_POLL_INFO, *PAFD_POLL_INFO; + +#define UV_MSAFD_PROVIDER_COUNT 4 + + +/** + * It should be possible to cast uv_buf_t[] to WSABUF[] + * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx + */ +typedef struct uv_buf_t { + ULONG len; + char* base; +} uv_buf_t; + +typedef int uv_file; +typedef SOCKET uv_os_sock_t; +typedef HANDLE uv_os_fd_t; +typedef int uv_pid_t; + +typedef HANDLE uv_thread_t; + +typedef HANDLE uv_sem_t; + +typedef CRITICAL_SECTION uv_mutex_t; + +/* This condition variable implementation is based on the SetEvent solution + * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html + * We could not use the SignalObjectAndWait solution (section 3.4) because + * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and + * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. + */ + +typedef union { + CONDITION_VARIABLE cond_var; + struct { + unsigned int waiters_count; + CRITICAL_SECTION waiters_count_lock; + HANDLE signal_event; + HANDLE broadcast_event; + } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ +} uv_cond_t; + +typedef struct { + SRWLOCK read_write_lock_; + /* TODO: retained for ABI compatibility; remove me in v2.x */ +#ifdef _WIN64 + unsigned char padding_[72]; +#else + unsigned char padding_[44]; +#endif +} uv_rwlock_t; + +typedef struct { + unsigned int n; + unsigned int count; + uv_mutex_t mutex; + uv_sem_t turnstile1; + uv_sem_t turnstile2; +} uv_barrier_t; + +typedef struct { + DWORD tls_index; +} uv_key_t; + +#define UV_ONCE_INIT { 0, NULL } + +typedef struct uv_once_s { + unsigned char ran; + HANDLE event; +} uv_once_t; + +/* Platform-specific definitions for uv_spawn support. */ +typedef unsigned char uv_uid_t; +typedef unsigned char uv_gid_t; + +typedef struct uv__dirent_s { + int d_type; + char d_name[1]; +} uv__dirent_t; + +#define UV_DIR_PRIVATE_FIELDS \ + HANDLE dir_handle; \ + WIN32_FIND_DATAW find_data; \ + BOOL need_find_call; + +#define HAVE_DIRENT_TYPES +#define UV__DT_DIR UV_DIRENT_DIR +#define UV__DT_FILE UV_DIRENT_FILE +#define UV__DT_LINK UV_DIRENT_LINK +#define UV__DT_FIFO UV_DIRENT_FIFO +#define UV__DT_SOCKET UV_DIRENT_SOCKET +#define UV__DT_CHAR UV_DIRENT_CHAR +#define UV__DT_BLOCK UV_DIRENT_BLOCK + +/* Platform-specific definitions for uv_dlopen support. */ +#define UV_DYNAMIC FAR WINAPI +typedef struct { + HMODULE handle; + char* errmsg; +} uv_lib_t; + +#define UV_LOOP_PRIVATE_FIELDS \ + /* The loop's I/O completion port */ \ + HANDLE iocp; \ + /* The current time according to the event loop. in msecs. */ \ + uint64_t time; \ + /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ + /* is empty, tail_ is NULL. If there is only one item, */ \ + /* tail_->next_req == tail_ */ \ + uv_req_t* pending_reqs_tail; \ + /* Head of a single-linked list of closed handles */ \ + uv_handle_t* endgame_handles; \ + /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \ + void* timer_heap; \ + /* Lists of active loop (prepare / check / idle) watchers */ \ + uv_prepare_t* prepare_handles; \ + uv_check_t* check_handles; \ + uv_idle_t* idle_handles; \ + /* This pointer will refer to the prepare/check/idle handle whose */ \ + /* callback is scheduled to be called next. This is needed to allow */ \ + /* safe removal from one of the lists above while that list being */ \ + /* iterated over. */ \ + uv_prepare_t* next_prepare_handle; \ + uv_check_t* next_check_handle; \ + uv_idle_t* next_idle_handle; \ + /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ + SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ + /* Counter to keep track of active tcp streams */ \ + unsigned int active_tcp_streams; \ + /* Counter to keep track of active udp streams */ \ + unsigned int active_udp_streams; \ + /* Counter to started timer */ \ + uint64_t timer_counter; \ + /* Threadpool */ \ + void* wq[2]; \ + uv_mutex_t wq_mutex; \ + uv_async_t wq_async; + +#define UV_REQ_TYPE_PRIVATE \ + /* TODO: remove the req suffix */ \ + UV_ACCEPT, \ + UV_FS_EVENT_REQ, \ + UV_POLL_REQ, \ + UV_PROCESS_EXIT, \ + UV_READ, \ + UV_UDP_RECV, \ + UV_WAKEUP, \ + UV_SIGNAL_REQ, + +#define UV_REQ_PRIVATE_FIELDS \ + union { \ + /* Used by I/O operations */ \ + struct { \ + OVERLAPPED overlapped; \ + size_t queued_bytes; \ + } io; \ + } u; \ + struct uv_req_s* next_req; + +#define UV_WRITE_PRIVATE_FIELDS \ + int coalesced; \ + uv_buf_t write_buffer; \ + HANDLE event_handle; \ + HANDLE wait_handle; + +#define UV_CONNECT_PRIVATE_FIELDS \ + /* empty */ + +#define UV_SHUTDOWN_PRIVATE_FIELDS \ + /* empty */ + +#define UV_UDP_SEND_PRIVATE_FIELDS \ + /* empty */ + +#define UV_PRIVATE_REQ_TYPES \ + typedef struct uv_pipe_accept_s { \ + UV_REQ_FIELDS \ + HANDLE pipeHandle; \ + struct uv_pipe_accept_s* next_pending; \ + } uv_pipe_accept_t; \ + \ + typedef struct uv_tcp_accept_s { \ + UV_REQ_FIELDS \ + SOCKET accept_socket; \ + char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ + HANDLE event_handle; \ + HANDLE wait_handle; \ + struct uv_tcp_accept_s* next_pending; \ + } uv_tcp_accept_t; \ + \ + typedef struct uv_read_s { \ + UV_REQ_FIELDS \ + HANDLE event_handle; \ + HANDLE wait_handle; \ + } uv_read_t; + +#define uv_stream_connection_fields \ + unsigned int write_reqs_pending; \ + uv_shutdown_t* shutdown_req; + +#define uv_stream_server_fields \ + uv_connection_cb connection_cb; + +#define UV_STREAM_PRIVATE_FIELDS \ + unsigned int reqs_pending; \ + int activecnt; \ + uv_read_t read_req; \ + union { \ + struct { uv_stream_connection_fields } conn; \ + struct { uv_stream_server_fields } serv; \ + } stream; + +#define uv_tcp_server_fields \ + uv_tcp_accept_t* accept_reqs; \ + unsigned int processed_accepts; \ + uv_tcp_accept_t* pending_accepts; \ + LPFN_ACCEPTEX func_acceptex; + +#define uv_tcp_connection_fields \ + uv_buf_t read_buffer; \ + LPFN_CONNECTEX func_connectex; + +#define UV_TCP_PRIVATE_FIELDS \ + SOCKET socket; \ + int delayed_error; \ + union { \ + struct { uv_tcp_server_fields } serv; \ + struct { uv_tcp_connection_fields } conn; \ + } tcp; + +#define UV_UDP_PRIVATE_FIELDS \ + SOCKET socket; \ + unsigned int reqs_pending; \ + int activecnt; \ + uv_req_t recv_req; \ + uv_buf_t recv_buffer; \ + struct sockaddr_storage recv_from; \ + int recv_from_len; \ + uv_udp_recv_cb recv_cb; \ + uv_alloc_cb alloc_cb; \ + LPFN_WSARECV func_wsarecv; \ + LPFN_WSARECVFROM func_wsarecvfrom; + +#define uv_pipe_server_fields \ + int pending_instances; \ + uv_pipe_accept_t* accept_reqs; \ + uv_pipe_accept_t* pending_accepts; + +#define uv_pipe_connection_fields \ + uv_timer_t* eof_timer; \ + uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ + DWORD ipc_remote_pid; \ + union { \ + uint32_t payload_remaining; \ + uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ + } ipc_data_frame; \ + void* ipc_xfer_queue[2]; \ + int ipc_xfer_queue_length; \ + uv_write_t* non_overlapped_writes_tail; \ + CRITICAL_SECTION readfile_thread_lock; \ + volatile HANDLE readfile_thread_handle; + +#define UV_PIPE_PRIVATE_FIELDS \ + HANDLE handle; \ + WCHAR* name; \ + union { \ + struct { uv_pipe_server_fields } serv; \ + struct { uv_pipe_connection_fields } conn; \ + } pipe; + +/* TODO: put the parser states in an union - TTY handles are always half-duplex + * so read-state can safely overlap write-state. */ +#define UV_TTY_PRIVATE_FIELDS \ + HANDLE handle; \ + union { \ + struct { \ + /* Used for readable TTY handles */ \ + /* TODO: remove me in v2.x. */ \ + HANDLE unused_; \ + uv_buf_t read_line_buffer; \ + HANDLE read_raw_wait; \ + /* Fields used for translating win keystrokes into vt100 characters */ \ + char last_key[8]; \ + unsigned char last_key_offset; \ + unsigned char last_key_len; \ + WCHAR last_utf16_high_surrogate; \ + INPUT_RECORD last_input_record; \ + } rd; \ + struct { \ + /* Used for writable TTY handles */ \ + /* utf8-to-utf16 conversion state */ \ + unsigned int utf8_codepoint; \ + unsigned char utf8_bytes_left; \ + /* eol conversion state */ \ + unsigned char previous_eol; \ + /* ansi parser state */ \ + unsigned short ansi_parser_state; \ + unsigned char ansi_csi_argc; \ + unsigned short ansi_csi_argv[4]; \ + COORD saved_position; \ + WORD saved_attributes; \ + } wr; \ + } tty; + +#define UV_POLL_PRIVATE_FIELDS \ + SOCKET socket; \ + /* Used in fast mode */ \ + SOCKET peer_socket; \ + AFD_POLL_INFO afd_poll_info_1; \ + AFD_POLL_INFO afd_poll_info_2; \ + /* Used in fast and slow mode. */ \ + uv_req_t poll_req_1; \ + uv_req_t poll_req_2; \ + unsigned char submitted_events_1; \ + unsigned char submitted_events_2; \ + unsigned char mask_events_1; \ + unsigned char mask_events_2; \ + unsigned char events; + +#define UV_TIMER_PRIVATE_FIELDS \ + void* heap_node[3]; \ + int unused; \ + uint64_t timeout; \ + uint64_t repeat; \ + uint64_t start_id; \ + uv_timer_cb timer_cb; + +#define UV_ASYNC_PRIVATE_FIELDS \ + struct uv_req_s async_req; \ + uv_async_cb async_cb; \ + /* char to avoid alignment issues */ \ + char volatile async_sent; + +#define UV_PREPARE_PRIVATE_FIELDS \ + uv_prepare_t* prepare_prev; \ + uv_prepare_t* prepare_next; \ + uv_prepare_cb prepare_cb; + +#define UV_CHECK_PRIVATE_FIELDS \ + uv_check_t* check_prev; \ + uv_check_t* check_next; \ + uv_check_cb check_cb; + +#define UV_IDLE_PRIVATE_FIELDS \ + uv_idle_t* idle_prev; \ + uv_idle_t* idle_next; \ + uv_idle_cb idle_cb; + +#define UV_HANDLE_PRIVATE_FIELDS \ + uv_handle_t* endgame_next; \ + unsigned int flags; + +#define UV_GETADDRINFO_PRIVATE_FIELDS \ + struct uv__work work_req; \ + uv_getaddrinfo_cb getaddrinfo_cb; \ + void* alloc; \ + WCHAR* node; \ + WCHAR* service; \ + /* The addrinfoW field is used to store a pointer to the hints, and */ \ + /* later on to store the result of GetAddrInfoW. The final result will */ \ + /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ + struct addrinfoW* addrinfow; \ + struct addrinfo* addrinfo; \ + int retcode; + +#define UV_GETNAMEINFO_PRIVATE_FIELDS \ + struct uv__work work_req; \ + uv_getnameinfo_cb getnameinfo_cb; \ + struct sockaddr_storage storage; \ + int flags; \ + char host[NI_MAXHOST]; \ + char service[NI_MAXSERV]; \ + int retcode; + +#define UV_PROCESS_PRIVATE_FIELDS \ + struct uv_process_exit_s { \ + UV_REQ_FIELDS \ + } exit_req; \ + BYTE* child_stdio_buffer; \ + int exit_signal; \ + HANDLE wait_handle; \ + HANDLE process_handle; \ + volatile char exit_cb_pending; + +#define UV_FS_PRIVATE_FIELDS \ + struct uv__work work_req; \ + int flags; \ + DWORD sys_errno_; \ + union { \ + /* TODO: remove me in 0.9. */ \ + WCHAR* pathw; \ + int fd; \ + } file; \ + union { \ + struct { \ + int mode; \ + WCHAR* new_pathw; \ + int file_flags; \ + int fd_out; \ + unsigned int nbufs; \ + uv_buf_t* bufs; \ + int64_t offset; \ + uv_buf_t bufsml[4]; \ + } info; \ + struct { \ + double atime; \ + double mtime; \ + } time; \ + } fs; + +#define UV_WORK_PRIVATE_FIELDS \ + struct uv__work work_req; + +#define UV_FS_EVENT_PRIVATE_FIELDS \ + struct uv_fs_event_req_s { \ + UV_REQ_FIELDS \ + } req; \ + HANDLE dir_handle; \ + int req_pending; \ + uv_fs_event_cb cb; \ + WCHAR* filew; \ + WCHAR* short_filew; \ + WCHAR* dirw; \ + char* buffer; + +#define UV_SIGNAL_PRIVATE_FIELDS \ + RB_ENTRY(uv_signal_s) tree_entry; \ + struct uv_req_s signal_req; \ + unsigned long pending_signum; + +#ifndef F_OK +#define F_OK 0 +#endif +#ifndef R_OK +#define R_OK 4 +#endif +#ifndef W_OK +#define W_OK 2 +#endif +#ifndef X_OK +#define X_OK 1 +#endif + +/* fs open() flags supported on this platform: */ +#define UV_FS_O_APPEND _O_APPEND +#define UV_FS_O_CREAT _O_CREAT +#define UV_FS_O_EXCL _O_EXCL +#define UV_FS_O_FILEMAP 0x20000000 +#define UV_FS_O_RANDOM _O_RANDOM +#define UV_FS_O_RDONLY _O_RDONLY +#define UV_FS_O_RDWR _O_RDWR +#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL +#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED +#define UV_FS_O_TEMPORARY _O_TEMPORARY +#define UV_FS_O_TRUNC _O_TRUNC +#define UV_FS_O_WRONLY _O_WRONLY + +/* fs open() flags supported on other platforms (or mapped on this platform): */ +#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */ +#define UV_FS_O_DIRECTORY 0 +#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */ +#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */ +#define UV_FS_O_NOATIME 0 +#define UV_FS_O_NOCTTY 0 +#define UV_FS_O_NOFOLLOW 0 +#define UV_FS_O_NONBLOCK 0 +#define UV_FS_O_SYMLINK 0 +#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */ diff --git a/third_party/libuv/include/uv_ndk/uv.h b/third_party/libuv/include/uv_ndk/uv.h index d1b0ada672d5bce0b2e8f6ab94a9a4e143a2120a..afc2f5a5261592486cde51f6059680376cab33b8 100644 --- a/third_party/libuv/include/uv_ndk/uv.h +++ b/third_party/libuv/include/uv_ndk/uv.h @@ -1,1826 +1,1826 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) -#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */ -# define UV_EXTERN __global -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv/errno.h" -#include "uv/version.h" -#include -#include - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "uv/stdint-msvc2008.h" -#else -# include -#endif - -#if defined(_WIN32) -# include "uv/win.h" -#else -# include "uv/unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EOVERFLOW, "value too large for defined data type") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - XX(EREMOTEIO, "remote I/O error") \ - XX(ENOTTY, "inappropriate ioctl for device") \ - XX(EFTYPE, "inappropriate file type or format") \ - XX(EILSEQ, "illegal byte sequence") \ - XX(ESOCKTNOSUPPORT, "socket type not supported") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - XX(RANDOM, random) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_dir_s uv_dir_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; -typedef struct uv_random_s uv_random_t; - -/* None of the above. */ -typedef struct uv_env_item_s uv_env_item_t; -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; -typedef struct uv_utsname_s uv_utsname_t; -typedef struct uv_statfs_s uv_statfs_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL = 0, - UV_METRICS_IDLE_TIME -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); -typedef void (*uv_random_cb)(uv_random_t* req, - int status, - void* buf, - size_t buflen); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); - -UV_EXTERN const char* uv_err_name(int err); -UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* reserved[6]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); -UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); -UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); -UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); -UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); - -UV_EXTERN size_t uv_req_size(uv_req_type type); -UV_EXTERN void* uv_req_get_data(const uv_req_t* req); -UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); -UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); -UV_EXTERN const char* uv_req_type_name(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4, - /* - * Indicates that the message was received by recvmmsg, so the buffer provided - * must not be freed by the recv_cb callback. - */ - UV_UDP_MMSG_CHUNK = 8, - /* - * Indicates that the buffer provided has been fully utilized by recvmmsg and - * that it should now be freed by the recv_cb callback. When this flag is set - * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. - */ - UV_UDP_MMSG_FREE = 16, - /* - * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle. - * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on - * Linux. This stops the Linux kernel from suppressing some ICMP error - * messages and enables full ICMP error reporting for faster failover. - * This flag is no-op on platforms other than Linux. - */ - UV_UDP_LINUX_RECVERR = 32, - /* - * Indicates that recvmmsg should be used, if available. - */ - UV_UDP_RECVMMSG = 256 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); - -UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - const char* source_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); -UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -typedef enum { - /* - * The console supports handling of virtual terminal sequences - * (Windows10 new console, ConEmu) - */ - UV_TTY_SUPPORTED, - /* The console cannot process the virtual terminal sequence. (Legacy - * console) - */ - UV_TTY_UNSUPPORTED -} uv_tty_vtermstate_t; - - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); -UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); -UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); -UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4, - UV_PRIORITIZED = 8 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20, - - /* - * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the - * handle in non-blocking mode in the child. This may cause loss of data, - * if the child is not designed to handle to encounter this mode, - * but can also be significantly more efficient. - */ - UV_NONBLOCK_PIPE = 0x40, - UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess window that would normally be created. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), - /* - * Hide the subprocess GUI window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); -UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_times_s { - uint64_t user; /* milliseconds */ - uint64_t nice; /* milliseconds */ - uint64_t sys; /* milliseconds */ - uint64_t idle; /* milliseconds */ - uint64_t irq; /* milliseconds */ -}; - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - unsigned long uid; - unsigned long gid; - char* shell; - char* homedir; -}; - -struct uv_utsname_s { - char sysname[256]; - char release[256]; - char version[256]; - char machine[256]; - /* This struct does not contain the nodename and domainname fields present in - the utsname type. domainname is a GNU extension. Both fields are referred - to as meaningless in the docs. */ -}; - -struct uv_statfs_s { - uint64_t f_type; - uint64_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_spare[4]; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); -UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - int64_t tv_sec; - int32_t tv_usec; -} uv_timeval64_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); -UV_EXTERN uv_pid_t uv_os_getpid(void); -UV_EXTERN uv_pid_t uv_os_getppid(void); - -#if defined(__PASE__) -/* On IBM i PASE, the highest process priority is -10 */ -# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ -# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ -# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ -# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ -# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ -# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ -#else -# define UV_PRIORITY_LOW 19 -# define UV_PRIORITY_BELOW_NORMAL 10 -# define UV_PRIORITY_NORMAL 0 -# define UV_PRIORITY_ABOVE_NORMAL -7 -# define UV_PRIORITY_HIGH -14 -# define UV_PRIORITY_HIGHEST -20 -#endif - -UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); -UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -struct uv_env_item_s { - char* name; - char* value; -}; - -UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); -UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -#ifdef MAXHOSTNAMELEN -# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) -#else - /* - Fallback for the maximum hostname size, including the null terminator. The - Windows gethostname() documentation states that 256 bytes will always be - large enough to hold the null-terminated hostname. - */ -# define UV_MAXHOSTNAMESIZE 256 -#endif - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - -UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH, - UV_FS_COPYFILE, - UV_FS_LCHOWN, - UV_FS_OPENDIR, - UV_FS_READDIR, - UV_FS_CLOSEDIR, - UV_FS_STATFS, - UV_FS_MKSTEMP, - UV_FS_LUTIME -} uv_fs_type; - -struct uv_dir_s { - uv_dirent_t* dirents; - size_t nentries; - void* reserved[4]; - UV_DIR_PRIVATE_FIELDS -}; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); -UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); -UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); -UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); -UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -/* - * This flag can be used with uv_fs_copyfile() to return an error if the - * destination already exists. - */ -#define UV_FS_COPYFILE_EXCL 0x0001 - -/* - * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. - * If copy-on-write is not supported, a fallback copy mechanism is used. - */ -#define UV_FS_COPYFILE_FICLONE 0x0002 - -/* - * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. - * If copy-on-write is not supported, an error is returned. - */ -#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 - -UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_opendir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, - uv_fs_t* req, - uv_dir_t* dir, - uv_fs_cb cb); -UV_EXTERN int uv_fs_closedir(uv_loop_t* loop, - uv_fs_t* req, - uv_dir_t* dir, - uv_fs_cb cb); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - - -struct uv_random_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* private */ - int status; - void* buf; - size_t buflen; - uv_random_cb cb; - struct uv__work work_req; -}; - -UV_EXTERN int uv_random(uv_loop_t* loop, - uv_random_t* req, - void *buf, - size_t buflen, - unsigned flags, /* For future extension; must be 0. */ - uv_random_cb cb); - -#if defined(IF_NAMESIZE) -# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) -#elif defined(IFNAMSIZ) -# define UV_IF_NAMESIZE (IFNAMSIZ + 1) -#else -# define UV_IF_NAMESIZE (16 + 1) -#endif - -UV_EXTERN int uv_if_indextoname(unsigned int ifindex, - char* buffer, - size_t* size); -UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, - char* buffer, - size_t* size); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); -UV_EXTERN uint64_t uv_get_constrained_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); -UV_EXTERN void uv_sleep(unsigned int msec); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); - -typedef enum { - UV_THREAD_NO_FLAGS = 0x00, - UV_THREAD_HAS_STACK_SIZE = 0x01 -} uv_thread_create_flags; - -struct uv_thread_options_s { - unsigned int flags; - size_t stack_size; - /* More fields may be added at any time. */ -}; - -typedef struct uv_thread_options_s uv_thread_options_t; - -UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, - const uv_thread_options_t* params, - uv_thread_cb entry, - void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - union { - void* unused; - unsigned int count; - } active_reqs; - /* Internal storage for future extensions. */ - void* internal_fields; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - -UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); -UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS -#undef UV__ERR - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/* See https://github.com/libuv/libuv#documentation for documentation. */ + +#ifndef UV_H +#define UV_H +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) +#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." +#endif + +#ifdef _WIN32 + /* Windows - set up dll import/export decorators. */ +# if defined(BUILDING_UV_SHARED) + /* Building shared library. */ +# define UV_EXTERN __declspec(dllexport) +# elif defined(USING_UV_SHARED) + /* Using shared library. */ +# define UV_EXTERN __declspec(dllimport) +# else + /* Building static library. */ +# define UV_EXTERN /* nothing */ +# endif +#elif __GNUC__ >= 4 +# define UV_EXTERN __attribute__((visibility("default"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */ +# define UV_EXTERN __global +#else +# define UV_EXTERN /* nothing */ +#endif + +#include "uv/errno.h" +#include "uv/version.h" +#include +#include + +#if defined(_MSC_VER) && _MSC_VER < 1600 +# include "uv/stdint-msvc2008.h" +#else +# include +#endif + +#if defined(_WIN32) +# include "uv/win.h" +#else +# include "uv/unix.h" +#endif + +/* Expand this list if necessary. */ +#define UV_ERRNO_MAP(XX) \ + XX(E2BIG, "argument list too long") \ + XX(EACCES, "permission denied") \ + XX(EADDRINUSE, "address already in use") \ + XX(EADDRNOTAVAIL, "address not available") \ + XX(EAFNOSUPPORT, "address family not supported") \ + XX(EAGAIN, "resource temporarily unavailable") \ + XX(EAI_ADDRFAMILY, "address family not supported") \ + XX(EAI_AGAIN, "temporary failure") \ + XX(EAI_BADFLAGS, "bad ai_flags value") \ + XX(EAI_BADHINTS, "invalid value for hints") \ + XX(EAI_CANCELED, "request canceled") \ + XX(EAI_FAIL, "permanent failure") \ + XX(EAI_FAMILY, "ai_family not supported") \ + XX(EAI_MEMORY, "out of memory") \ + XX(EAI_NODATA, "no address") \ + XX(EAI_NONAME, "unknown node or service") \ + XX(EAI_OVERFLOW, "argument buffer overflow") \ + XX(EAI_PROTOCOL, "resolved protocol is unknown") \ + XX(EAI_SERVICE, "service not available for socket type") \ + XX(EAI_SOCKTYPE, "socket type not supported") \ + XX(EALREADY, "connection already in progress") \ + XX(EBADF, "bad file descriptor") \ + XX(EBUSY, "resource busy or locked") \ + XX(ECANCELED, "operation canceled") \ + XX(ECHARSET, "invalid Unicode character") \ + XX(ECONNABORTED, "software caused connection abort") \ + XX(ECONNREFUSED, "connection refused") \ + XX(ECONNRESET, "connection reset by peer") \ + XX(EDESTADDRREQ, "destination address required") \ + XX(EEXIST, "file already exists") \ + XX(EFAULT, "bad address in system call argument") \ + XX(EFBIG, "file too large") \ + XX(EHOSTUNREACH, "host is unreachable") \ + XX(EINTR, "interrupted system call") \ + XX(EINVAL, "invalid argument") \ + XX(EIO, "i/o error") \ + XX(EISCONN, "socket is already connected") \ + XX(EISDIR, "illegal operation on a directory") \ + XX(ELOOP, "too many symbolic links encountered") \ + XX(EMFILE, "too many open files") \ + XX(EMSGSIZE, "message too long") \ + XX(ENAMETOOLONG, "name too long") \ + XX(ENETDOWN, "network is down") \ + XX(ENETUNREACH, "network is unreachable") \ + XX(ENFILE, "file table overflow") \ + XX(ENOBUFS, "no buffer space available") \ + XX(ENODEV, "no such device") \ + XX(ENOENT, "no such file or directory") \ + XX(ENOMEM, "not enough memory") \ + XX(ENONET, "machine is not on the network") \ + XX(ENOPROTOOPT, "protocol not available") \ + XX(ENOSPC, "no space left on device") \ + XX(ENOSYS, "function not implemented") \ + XX(ENOTCONN, "socket is not connected") \ + XX(ENOTDIR, "not a directory") \ + XX(ENOTEMPTY, "directory not empty") \ + XX(ENOTSOCK, "socket operation on non-socket") \ + XX(ENOTSUP, "operation not supported on socket") \ + XX(EOVERFLOW, "value too large for defined data type") \ + XX(EPERM, "operation not permitted") \ + XX(EPIPE, "broken pipe") \ + XX(EPROTO, "protocol error") \ + XX(EPROTONOSUPPORT, "protocol not supported") \ + XX(EPROTOTYPE, "protocol wrong type for socket") \ + XX(ERANGE, "result too large") \ + XX(EROFS, "read-only file system") \ + XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ + XX(ESPIPE, "invalid seek") \ + XX(ESRCH, "no such process") \ + XX(ETIMEDOUT, "connection timed out") \ + XX(ETXTBSY, "text file is busy") \ + XX(EXDEV, "cross-device link not permitted") \ + XX(UNKNOWN, "unknown error") \ + XX(EOF, "end of file") \ + XX(ENXIO, "no such device or address") \ + XX(EMLINK, "too many links") \ + XX(EHOSTDOWN, "host is down") \ + XX(EREMOTEIO, "remote I/O error") \ + XX(ENOTTY, "inappropriate ioctl for device") \ + XX(EFTYPE, "inappropriate file type or format") \ + XX(EILSEQ, "illegal byte sequence") \ + XX(ESOCKTNOSUPPORT, "socket type not supported") \ + +#define UV_HANDLE_TYPE_MAP(XX) \ + XX(ASYNC, async) \ + XX(CHECK, check) \ + XX(FS_EVENT, fs_event) \ + XX(FS_POLL, fs_poll) \ + XX(HANDLE, handle) \ + XX(IDLE, idle) \ + XX(NAMED_PIPE, pipe) \ + XX(POLL, poll) \ + XX(PREPARE, prepare) \ + XX(PROCESS, process) \ + XX(STREAM, stream) \ + XX(TCP, tcp) \ + XX(TIMER, timer) \ + XX(TTY, tty) \ + XX(UDP, udp) \ + XX(SIGNAL, signal) \ + +#define UV_REQ_TYPE_MAP(XX) \ + XX(REQ, req) \ + XX(CONNECT, connect) \ + XX(WRITE, write) \ + XX(SHUTDOWN, shutdown) \ + XX(UDP_SEND, udp_send) \ + XX(FS, fs) \ + XX(WORK, work) \ + XX(GETADDRINFO, getaddrinfo) \ + XX(GETNAMEINFO, getnameinfo) \ + XX(RANDOM, random) \ + +typedef enum { +#define XX(code, _) UV_ ## code = UV__ ## code, + UV_ERRNO_MAP(XX) +#undef XX + UV_ERRNO_MAX = UV__EOF - 1 +} uv_errno_t; + +typedef enum { + UV_UNKNOWN_HANDLE = 0, +#define XX(uc, lc) UV_##uc, + UV_HANDLE_TYPE_MAP(XX) +#undef XX + UV_FILE, + UV_HANDLE_TYPE_MAX +} uv_handle_type; + +typedef enum { + UV_UNKNOWN_REQ = 0, +#define XX(uc, lc) UV_##uc, + UV_REQ_TYPE_MAP(XX) +#undef XX + UV_REQ_TYPE_PRIVATE + UV_REQ_TYPE_MAX +} uv_req_type; + + +/* Handle types. */ +typedef struct uv_loop_s uv_loop_t; +typedef struct uv_handle_s uv_handle_t; +typedef struct uv_dir_s uv_dir_t; +typedef struct uv_stream_s uv_stream_t; +typedef struct uv_tcp_s uv_tcp_t; +typedef struct uv_udp_s uv_udp_t; +typedef struct uv_pipe_s uv_pipe_t; +typedef struct uv_tty_s uv_tty_t; +typedef struct uv_poll_s uv_poll_t; +typedef struct uv_timer_s uv_timer_t; +typedef struct uv_prepare_s uv_prepare_t; +typedef struct uv_check_s uv_check_t; +typedef struct uv_idle_s uv_idle_t; +typedef struct uv_async_s uv_async_t; +typedef struct uv_process_s uv_process_t; +typedef struct uv_fs_event_s uv_fs_event_t; +typedef struct uv_fs_poll_s uv_fs_poll_t; +typedef struct uv_signal_s uv_signal_t; + +/* Request types. */ +typedef struct uv_req_s uv_req_t; +typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; +typedef struct uv_getnameinfo_s uv_getnameinfo_t; +typedef struct uv_shutdown_s uv_shutdown_t; +typedef struct uv_write_s uv_write_t; +typedef struct uv_connect_s uv_connect_t; +typedef struct uv_udp_send_s uv_udp_send_t; +typedef struct uv_fs_s uv_fs_t; +typedef struct uv_work_s uv_work_t; +typedef struct uv_random_s uv_random_t; + +/* None of the above. */ +typedef struct uv_env_item_s uv_env_item_t; +typedef struct uv_cpu_info_s uv_cpu_info_t; +typedef struct uv_interface_address_s uv_interface_address_t; +typedef struct uv_dirent_s uv_dirent_t; +typedef struct uv_passwd_s uv_passwd_t; +typedef struct uv_utsname_s uv_utsname_t; +typedef struct uv_statfs_s uv_statfs_t; + +typedef enum { + UV_LOOP_BLOCK_SIGNAL = 0, + UV_METRICS_IDLE_TIME +} uv_loop_option; + +typedef enum { + UV_RUN_DEFAULT = 0, + UV_RUN_ONCE, + UV_RUN_NOWAIT +} uv_run_mode; + + +UV_EXTERN unsigned int uv_version(void); +UV_EXTERN const char* uv_version_string(void); + +typedef void* (*uv_malloc_func)(size_t size); +typedef void* (*uv_realloc_func)(void* ptr, size_t size); +typedef void* (*uv_calloc_func)(size_t count, size_t size); +typedef void (*uv_free_func)(void* ptr); + +UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, + uv_realloc_func realloc_func, + uv_calloc_func calloc_func, + uv_free_func free_func); + +UV_EXTERN uv_loop_t* uv_default_loop(void); +UV_EXTERN int uv_loop_init(uv_loop_t* loop); +UV_EXTERN int uv_loop_close(uv_loop_t* loop); +/* + * NOTE: + * This function is DEPRECATED (to be removed after 0.12), users should + * allocate the loop manually and use uv_loop_init instead. + */ +UV_EXTERN uv_loop_t* uv_loop_new(void); +/* + * NOTE: + * This function is DEPRECATED (to be removed after 0.12). Users should use + * uv_loop_close and free the memory manually instead. + */ +UV_EXTERN void uv_loop_delete(uv_loop_t*); +UV_EXTERN size_t uv_loop_size(void); +UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); +UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); +UV_EXTERN int uv_loop_fork(uv_loop_t* loop); + +UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); +UV_EXTERN void uv_stop(uv_loop_t*); + +UV_EXTERN void uv_ref(uv_handle_t*); +UV_EXTERN void uv_unref(uv_handle_t*); +UV_EXTERN int uv_has_ref(const uv_handle_t*); + +UV_EXTERN void uv_update_time(uv_loop_t*); +UV_EXTERN uint64_t uv_now(const uv_loop_t*); + +UV_EXTERN int uv_backend_fd(const uv_loop_t*); +UV_EXTERN int uv_backend_timeout(const uv_loop_t*); + +typedef void (*uv_alloc_cb)(uv_handle_t* handle, + size_t suggested_size, + uv_buf_t* buf); +typedef void (*uv_read_cb)(uv_stream_t* stream, + ssize_t nread, + const uv_buf_t* buf); +typedef void (*uv_write_cb)(uv_write_t* req, int status); +typedef void (*uv_connect_cb)(uv_connect_t* req, int status); +typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); +typedef void (*uv_connection_cb)(uv_stream_t* server, int status); +typedef void (*uv_close_cb)(uv_handle_t* handle); +typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); +typedef void (*uv_timer_cb)(uv_timer_t* handle); +typedef void (*uv_async_cb)(uv_async_t* handle); +typedef void (*uv_prepare_cb)(uv_prepare_t* handle); +typedef void (*uv_check_cb)(uv_check_t* handle); +typedef void (*uv_idle_cb)(uv_idle_t* handle); +typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); +typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); +typedef void (*uv_fs_cb)(uv_fs_t* req); +typedef void (*uv_work_cb)(uv_work_t* req); +typedef void (*uv_after_work_cb)(uv_work_t* req, int status); +typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, + int status, + struct addrinfo* res); +typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, + int status, + const char* hostname, + const char* service); +typedef void (*uv_random_cb)(uv_random_t* req, + int status, + void* buf, + size_t buflen); + +typedef struct { + long tv_sec; + long tv_nsec; +} uv_timespec_t; + + +typedef struct { + uint64_t st_dev; + uint64_t st_mode; + uint64_t st_nlink; + uint64_t st_uid; + uint64_t st_gid; + uint64_t st_rdev; + uint64_t st_ino; + uint64_t st_size; + uint64_t st_blksize; + uint64_t st_blocks; + uint64_t st_flags; + uint64_t st_gen; + uv_timespec_t st_atim; + uv_timespec_t st_mtim; + uv_timespec_t st_ctim; + uv_timespec_t st_birthtim; +} uv_stat_t; + + +typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, + const char* filename, + int events, + int status); + +typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, + int status, + const uv_stat_t* prev, + const uv_stat_t* curr); + +typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); + + +typedef enum { + UV_LEAVE_GROUP = 0, + UV_JOIN_GROUP +} uv_membership; + + +UV_EXTERN int uv_translate_sys_error(int sys_errno); + +UV_EXTERN const char* uv_strerror(int err); +UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen); + +UV_EXTERN const char* uv_err_name(int err); +UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen); + + +#define UV_REQ_FIELDS \ + /* public */ \ + void* data; \ + /* read-only */ \ + uv_req_type type; \ + /* private */ \ + void* reserved[6]; \ + UV_REQ_PRIVATE_FIELDS \ + +/* Abstract base class of all requests. */ +struct uv_req_s { + UV_REQ_FIELDS +}; + + +/* Platform-specific request types. */ +UV_PRIVATE_REQ_TYPES + + +UV_EXTERN int uv_shutdown(uv_shutdown_t* req, + uv_stream_t* handle, + uv_shutdown_cb cb); + +struct uv_shutdown_s { + UV_REQ_FIELDS + uv_stream_t* handle; + uv_shutdown_cb cb; + UV_SHUTDOWN_PRIVATE_FIELDS +}; + + +#define UV_HANDLE_FIELDS \ + /* public */ \ + void* data; \ + /* read-only */ \ + uv_loop_t* loop; \ + uv_handle_type type; \ + /* private */ \ + uv_close_cb close_cb; \ + void* handle_queue[2]; \ + union { \ + int fd; \ + void* reserved[4]; \ + } u; \ + UV_HANDLE_PRIVATE_FIELDS \ + +/* The abstract base class of all handles. */ +struct uv_handle_s { + UV_HANDLE_FIELDS +}; + +UV_EXTERN size_t uv_handle_size(uv_handle_type type); +UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle); +UV_EXTERN const char* uv_handle_type_name(uv_handle_type type); +UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle); +UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle); +UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data); + +UV_EXTERN size_t uv_req_size(uv_req_type type); +UV_EXTERN void* uv_req_get_data(const uv_req_t* req); +UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data); +UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req); +UV_EXTERN const char* uv_req_type_name(uv_req_type type); + +UV_EXTERN int uv_is_active(const uv_handle_t* handle); + +UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); + +/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ +UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); +UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); + +UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); + +UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); +UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); + +UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); + +UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); + + +#define UV_STREAM_FIELDS \ + /* number of bytes queued for writing */ \ + size_t write_queue_size; \ + uv_alloc_cb alloc_cb; \ + uv_read_cb read_cb; \ + /* private */ \ + UV_STREAM_PRIVATE_FIELDS + +/* + * uv_stream_t is a subclass of uv_handle_t. + * + * uv_stream is an abstract class. + * + * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. + */ +struct uv_stream_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS +}; + +UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream); + +UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); +UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); + +UV_EXTERN int uv_read_start(uv_stream_t*, + uv_alloc_cb alloc_cb, + uv_read_cb read_cb); +UV_EXTERN int uv_read_stop(uv_stream_t*); + +UV_EXTERN int uv_write(uv_write_t* req, + uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + uv_write_cb cb); +UV_EXTERN int uv_write2(uv_write_t* req, + uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + uv_stream_t* send_handle, + uv_write_cb cb); +UV_EXTERN int uv_try_write(uv_stream_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs); + +/* uv_write_t is a subclass of uv_req_t. */ +struct uv_write_s { + UV_REQ_FIELDS + uv_write_cb cb; + uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */ + uv_stream_t* handle; + UV_WRITE_PRIVATE_FIELDS +}; + + +UV_EXTERN int uv_is_readable(const uv_stream_t* handle); +UV_EXTERN int uv_is_writable(const uv_stream_t* handle); + +UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); + +UV_EXTERN int uv_is_closing(const uv_handle_t* handle); + + +/* + * uv_tcp_t is a subclass of uv_stream_t. + * + * Represents a TCP stream or TCP server. + */ +struct uv_tcp_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + UV_TCP_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); +UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); +UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); +UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); +UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, + int enable, + unsigned int delay); +UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); + +enum uv_tcp_flags { + /* Used with uv_tcp_bind, when an IPv6 address is used. */ + UV_TCP_IPV6ONLY = 1 +}; + +UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, + const struct sockaddr* addr, + unsigned int flags); +UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); +UV_EXTERN int uv_tcp_connect(uv_connect_t* req, + uv_tcp_t* handle, + const struct sockaddr* addr, + uv_connect_cb cb); + +/* uv_connect_t is a subclass of uv_req_t. */ +struct uv_connect_s { + UV_REQ_FIELDS + uv_connect_cb cb; + uv_stream_t* handle; + UV_CONNECT_PRIVATE_FIELDS +}; + + +/* + * UDP support. + */ + +enum uv_udp_flags { + /* Disables dual stack mode. */ + UV_UDP_IPV6ONLY = 1, + /* + * Indicates message was truncated because read buffer was too small. The + * remainder was discarded by the OS. Used in uv_udp_recv_cb. + */ + UV_UDP_PARTIAL = 2, + /* + * Indicates if SO_REUSEADDR will be set when binding the handle. + * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other + * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that + * multiple threads or processes can bind to the same address without error + * (provided they all set the flag) but only the last one to bind will receive + * any traffic, in effect "stealing" the port from the previous listener. + */ + UV_UDP_REUSEADDR = 4, + /* + * Indicates that the message was received by recvmmsg, so the buffer provided + * must not be freed by the recv_cb callback. + */ + UV_UDP_MMSG_CHUNK = 8, + /* + * Indicates that the buffer provided has been fully utilized by recvmmsg and + * that it should now be freed by the recv_cb callback. When this flag is set + * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. + */ + UV_UDP_MMSG_FREE = 16, + /* + * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle. + * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on + * Linux. This stops the Linux kernel from suppressing some ICMP error + * messages and enables full ICMP error reporting for faster failover. + * This flag is no-op on platforms other than Linux. + */ + UV_UDP_LINUX_RECVERR = 32, + /* + * Indicates that recvmmsg should be used, if available. + */ + UV_UDP_RECVMMSG = 256 +}; + +typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); +typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, + ssize_t nread, + const uv_buf_t* buf, + const struct sockaddr* addr, + unsigned flags); + +/* uv_udp_t is a subclass of uv_handle_t. */ +struct uv_udp_s { + UV_HANDLE_FIELDS + /* read-only */ + /* + * Number of bytes queued for sending. This field strictly shows how much + * information is currently queued. + */ + size_t send_queue_size; + /* + * Number of send requests currently in the queue awaiting to be processed. + */ + size_t send_queue_count; + UV_UDP_PRIVATE_FIELDS +}; + +/* uv_udp_send_t is a subclass of uv_req_t. */ +struct uv_udp_send_s { + UV_REQ_FIELDS + uv_udp_t* handle; + uv_udp_send_cb cb; + UV_UDP_SEND_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); +UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); +UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); +UV_EXTERN int uv_udp_bind(uv_udp_t* handle, + const struct sockaddr* addr, + unsigned int flags); +UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr); + +UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, + struct sockaddr* name, + int* namelen); +UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, + const char* multicast_addr, + const char* interface_addr, + uv_membership membership); +UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, + const char* multicast_addr, + const char* interface_addr, + const char* source_addr, + uv_membership membership); +UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); +UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); +UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, + const char* interface_addr); +UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); +UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); +UV_EXTERN int uv_udp_send(uv_udp_send_t* req, + uv_udp_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + const struct sockaddr* addr, + uv_udp_send_cb send_cb); +UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, + const uv_buf_t bufs[], + unsigned int nbufs, + const struct sockaddr* addr); +UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, + uv_alloc_cb alloc_cb, + uv_udp_recv_cb recv_cb); +UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); +UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); +UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); + + +/* + * uv_tty_t is a subclass of uv_stream_t. + * + * Representing a stream for the console. + */ +struct uv_tty_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + UV_TTY_PRIVATE_FIELDS +}; + +typedef enum { + /* Initial/normal terminal mode */ + UV_TTY_MODE_NORMAL, + /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ + UV_TTY_MODE_RAW, + /* Binary-safe I/O mode for IPC (Unix-only) */ + UV_TTY_MODE_IO +} uv_tty_mode_t; + +typedef enum { + /* + * The console supports handling of virtual terminal sequences + * (Windows10 new console, ConEmu) + */ + UV_TTY_SUPPORTED, + /* The console cannot process the virtual terminal sequence. (Legacy + * console) + */ + UV_TTY_UNSUPPORTED +} uv_tty_vtermstate_t; + + +UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); +UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); +UV_EXTERN int uv_tty_reset_mode(void); +UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); +UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); +UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); + +#ifdef __cplusplus +extern "C++" { + +inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { + return uv_tty_set_mode(handle, static_cast(mode)); +} + +} +#endif + +UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); + +/* + * uv_pipe_t is a subclass of uv_stream_t. + * + * Representing a pipe stream or pipe server. On Windows this is a Named + * Pipe. On Unix this is a Unix domain socket. + */ +struct uv_pipe_s { + UV_HANDLE_FIELDS + UV_STREAM_FIELDS + int ipc; /* non-zero if this pipe is used for passing handles */ + UV_PIPE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); +UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); +UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); +UV_EXTERN void uv_pipe_connect(uv_connect_t* req, + uv_pipe_t* handle, + const char* name, + uv_connect_cb cb); +UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, + char* buffer, + size_t* size); +UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, + char* buffer, + size_t* size); +UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); +UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); +UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); +UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags); + + +struct uv_poll_s { + UV_HANDLE_FIELDS + uv_poll_cb poll_cb; + UV_POLL_PRIVATE_FIELDS +}; + +enum uv_poll_event { + UV_READABLE = 1, + UV_WRITABLE = 2, + UV_DISCONNECT = 4, + UV_PRIORITIZED = 8 +}; + +UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); +UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, + uv_poll_t* handle, + uv_os_sock_t socket); +UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); +UV_EXTERN int uv_poll_stop(uv_poll_t* handle); + + +struct uv_prepare_s { + UV_HANDLE_FIELDS + UV_PREPARE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); +UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); +UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); + + +struct uv_check_s { + UV_HANDLE_FIELDS + UV_CHECK_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); +UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); +UV_EXTERN int uv_check_stop(uv_check_t* check); + + +struct uv_idle_s { + UV_HANDLE_FIELDS + UV_IDLE_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); +UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); +UV_EXTERN int uv_idle_stop(uv_idle_t* idle); + + +struct uv_async_s { + UV_HANDLE_FIELDS + UV_ASYNC_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_async_init(uv_loop_t*, + uv_async_t* async, + uv_async_cb async_cb); +UV_EXTERN int uv_async_send(uv_async_t* async); + + +/* + * uv_timer_t is a subclass of uv_handle_t. + * + * Used to get woken up at a specified time in the future. + */ +struct uv_timer_s { + UV_HANDLE_FIELDS + UV_TIMER_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); +UV_EXTERN int uv_timer_start(uv_timer_t* handle, + uv_timer_cb cb, + uint64_t timeout, + uint64_t repeat); +UV_EXTERN int uv_timer_stop(uv_timer_t* handle); +UV_EXTERN int uv_timer_again(uv_timer_t* handle); +UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); +UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); + + +/* + * uv_getaddrinfo_t is a subclass of uv_req_t. + * + * Request object for uv_getaddrinfo. + */ +struct uv_getaddrinfo_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ + UV_GETADDRINFO_PRIVATE_FIELDS +}; + + +UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, + uv_getaddrinfo_t* req, + uv_getaddrinfo_cb getaddrinfo_cb, + const char* node, + const char* service, + const struct addrinfo* hints); +UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); + + +/* +* uv_getnameinfo_t is a subclass of uv_req_t. +* +* Request object for uv_getnameinfo. +*/ +struct uv_getnameinfo_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* host and service are marked as private, but they really aren't. */ + UV_GETNAMEINFO_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, + uv_getnameinfo_t* req, + uv_getnameinfo_cb getnameinfo_cb, + const struct sockaddr* addr, + int flags); + + +/* uv_spawn() options. */ +typedef enum { + UV_IGNORE = 0x00, + UV_CREATE_PIPE = 0x01, + UV_INHERIT_FD = 0x02, + UV_INHERIT_STREAM = 0x04, + + /* + * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE + * determine the direction of flow, from the child process' perspective. Both + * flags may be specified to create a duplex data stream. + */ + UV_READABLE_PIPE = 0x10, + UV_WRITABLE_PIPE = 0x20, + + /* + * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the + * handle in non-blocking mode in the child. This may cause loss of data, + * if the child is not designed to handle to encounter this mode, + * but can also be significantly more efficient. + */ + UV_NONBLOCK_PIPE = 0x40, + UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */ +} uv_stdio_flags; + +typedef struct uv_stdio_container_s { + uv_stdio_flags flags; + + union { + uv_stream_t* stream; + int fd; + } data; +} uv_stdio_container_t; + +typedef struct uv_process_options_s { + uv_exit_cb exit_cb; /* Called after the process exits. */ + const char* file; /* Path to program to execute. */ + /* + * Command line arguments. args[0] should be the path to the program. On + * Windows this uses CreateProcess which concatenates the arguments into a + * string this can cause some strange errors. See the note at + * windows_verbatim_arguments. + */ + char** args; + /* + * This will be set as the environ variable in the subprocess. If this is + * NULL then the parents environ will be used. + */ + char** env; + /* + * If non-null this represents a directory the subprocess should execute + * in. Stands for current working directory. + */ + const char* cwd; + /* + * Various flags that control how uv_spawn() behaves. See the definition of + * `enum uv_process_flags` below. + */ + unsigned int flags; + /* + * The `stdio` field points to an array of uv_stdio_container_t structs that + * describe the file descriptors that will be made available to the child + * process. The convention is that stdio[0] points to stdin, fd 1 is used for + * stdout, and fd 2 is stderr. + * + * Note that on windows file descriptors greater than 2 are available to the + * child process only if the child processes uses the MSVCRT runtime. + */ + int stdio_count; + uv_stdio_container_t* stdio; + /* + * Libuv can change the child process' user/group id. This happens only when + * the appropriate bits are set in the flags fields. This is not supported on + * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. + */ + uv_uid_t uid; + uv_gid_t gid; +} uv_process_options_t; + +/* + * These are the flags that can be used for the uv_process_options.flags field. + */ +enum uv_process_flags { + /* + * Set the child process' user id. The user id is supplied in the `uid` field + * of the options struct. This does not work on windows; setting this flag + * will cause uv_spawn() to fail. + */ + UV_PROCESS_SETUID = (1 << 0), + /* + * Set the child process' group id. The user id is supplied in the `gid` + * field of the options struct. This does not work on windows; setting this + * flag will cause uv_spawn() to fail. + */ + UV_PROCESS_SETGID = (1 << 1), + /* + * Do not wrap any arguments in quotes, or perform any other escaping, when + * converting the argument list into a command line string. This option is + * only meaningful on Windows systems. On Unix it is silently ignored. + */ + UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), + /* + * Spawn the child process in a detached state - this will make it a process + * group leader, and will effectively enable the child to keep running after + * the parent exits. Note that the child process will still keep the + * parent's event loop alive unless the parent process calls uv_unref() on + * the child's process handle. + */ + UV_PROCESS_DETACHED = (1 << 3), + /* + * Hide the subprocess window that would normally be created. This option is + * only meaningful on Windows systems. On Unix it is silently ignored. + */ + UV_PROCESS_WINDOWS_HIDE = (1 << 4), + /* + * Hide the subprocess console window that would normally be created. This + * option is only meaningful on Windows systems. On Unix it is silently + * ignored. + */ + UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5), + /* + * Hide the subprocess GUI window that would normally be created. This + * option is only meaningful on Windows systems. On Unix it is silently + * ignored. + */ + UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6) +}; + +/* + * uv_process_t is a subclass of uv_handle_t. + */ +struct uv_process_s { + UV_HANDLE_FIELDS + uv_exit_cb exit_cb; + int pid; + UV_PROCESS_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_spawn(uv_loop_t* loop, + uv_process_t* handle, + const uv_process_options_t* options); +UV_EXTERN int uv_process_kill(uv_process_t*, int signum); +UV_EXTERN int uv_kill(int pid, int signum); +UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*); + + +/* + * uv_work_t is a subclass of uv_req_t. + */ +struct uv_work_s { + UV_REQ_FIELDS + uv_loop_t* loop; + uv_work_cb work_cb; + uv_after_work_cb after_work_cb; + UV_WORK_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_queue_work(uv_loop_t* loop, + uv_work_t* req, + uv_work_cb work_cb, + uv_after_work_cb after_work_cb); + +UV_EXTERN int uv_cancel(uv_req_t* req); + + +struct uv_cpu_times_s { + uint64_t user; /* milliseconds */ + uint64_t nice; /* milliseconds */ + uint64_t sys; /* milliseconds */ + uint64_t idle; /* milliseconds */ + uint64_t irq; /* milliseconds */ +}; + +struct uv_cpu_info_s { + char* model; + int speed; + struct uv_cpu_times_s cpu_times; +}; + +struct uv_interface_address_s { + char* name; + char phys_addr[6]; + int is_internal; + union { + struct sockaddr_in address4; + struct sockaddr_in6 address6; + } address; + union { + struct sockaddr_in netmask4; + struct sockaddr_in6 netmask6; + } netmask; +}; + +struct uv_passwd_s { + char* username; + unsigned long uid; + unsigned long gid; + char* shell; + char* homedir; +}; + +struct uv_utsname_s { + char sysname[256]; + char release[256]; + char version[256]; + char machine[256]; + /* This struct does not contain the nodename and domainname fields present in + the utsname type. domainname is a GNU extension. Both fields are referred + to as meaningless in the docs. */ +}; + +struct uv_statfs_s { + uint64_t f_type; + uint64_t f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + uint64_t f_spare[4]; +}; + +typedef enum { + UV_DIRENT_UNKNOWN, + UV_DIRENT_FILE, + UV_DIRENT_DIR, + UV_DIRENT_LINK, + UV_DIRENT_FIFO, + UV_DIRENT_SOCKET, + UV_DIRENT_CHAR, + UV_DIRENT_BLOCK +} uv_dirent_type_t; + +struct uv_dirent_s { + const char* name; + uv_dirent_type_t type; +}; + +UV_EXTERN char** uv_setup_args(int argc, char** argv); +UV_EXTERN int uv_get_process_title(char* buffer, size_t size); +UV_EXTERN int uv_set_process_title(const char* title); +UV_EXTERN int uv_resident_set_memory(size_t* rss); +UV_EXTERN int uv_uptime(double* uptime); +UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); +UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd); + +typedef struct { + long tv_sec; + long tv_usec; +} uv_timeval_t; + +typedef struct { + int64_t tv_sec; + int32_t tv_usec; +} uv_timeval64_t; + +typedef struct { + uv_timeval_t ru_utime; /* user CPU time used */ + uv_timeval_t ru_stime; /* system CPU time used */ + uint64_t ru_maxrss; /* maximum resident set size */ + uint64_t ru_ixrss; /* integral shared memory size */ + uint64_t ru_idrss; /* integral unshared data size */ + uint64_t ru_isrss; /* integral unshared stack size */ + uint64_t ru_minflt; /* page reclaims (soft page faults) */ + uint64_t ru_majflt; /* page faults (hard page faults) */ + uint64_t ru_nswap; /* swaps */ + uint64_t ru_inblock; /* block input operations */ + uint64_t ru_oublock; /* block output operations */ + uint64_t ru_msgsnd; /* IPC messages sent */ + uint64_t ru_msgrcv; /* IPC messages received */ + uint64_t ru_nsignals; /* signals received */ + uint64_t ru_nvcsw; /* voluntary context switches */ + uint64_t ru_nivcsw; /* involuntary context switches */ +} uv_rusage_t; + +UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); + +UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); +UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); +UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); +UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); +UV_EXTERN uv_pid_t uv_os_getpid(void); +UV_EXTERN uv_pid_t uv_os_getppid(void); + +#if defined(__PASE__) +/* On IBM i PASE, the highest process priority is -10 */ +# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ +# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ +# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ +# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ +# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ +# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ +#else +# define UV_PRIORITY_LOW 19 +# define UV_PRIORITY_BELOW_NORMAL 10 +# define UV_PRIORITY_NORMAL 0 +# define UV_PRIORITY_ABOVE_NORMAL -7 +# define UV_PRIORITY_HIGH -14 +# define UV_PRIORITY_HIGHEST -20 +#endif + +UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); +UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); + +UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); +UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); + +UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, + int* count); +UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, + int count); + +struct uv_env_item_s { + char* name; + char* value; +}; + +UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); +UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); +UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); +UV_EXTERN int uv_os_setenv(const char* name, const char* value); +UV_EXTERN int uv_os_unsetenv(const char* name); + +#ifdef MAXHOSTNAMELEN +# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1) +#else + /* + Fallback for the maximum hostname size, including the null terminator. The + Windows gethostname() documentation states that 256 bytes will always be + large enough to hold the null-terminated hostname. + */ +# define UV_MAXHOSTNAMESIZE 256 +#endif + +UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); + +UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); + + +typedef enum { + UV_FS_UNKNOWN = -1, + UV_FS_CUSTOM, + UV_FS_OPEN, + UV_FS_CLOSE, + UV_FS_READ, + UV_FS_WRITE, + UV_FS_SENDFILE, + UV_FS_STAT, + UV_FS_LSTAT, + UV_FS_FSTAT, + UV_FS_FTRUNCATE, + UV_FS_UTIME, + UV_FS_FUTIME, + UV_FS_ACCESS, + UV_FS_CHMOD, + UV_FS_FCHMOD, + UV_FS_FSYNC, + UV_FS_FDATASYNC, + UV_FS_UNLINK, + UV_FS_RMDIR, + UV_FS_MKDIR, + UV_FS_MKDTEMP, + UV_FS_RENAME, + UV_FS_SCANDIR, + UV_FS_LINK, + UV_FS_SYMLINK, + UV_FS_READLINK, + UV_FS_CHOWN, + UV_FS_FCHOWN, + UV_FS_REALPATH, + UV_FS_COPYFILE, + UV_FS_LCHOWN, + UV_FS_OPENDIR, + UV_FS_READDIR, + UV_FS_CLOSEDIR, + UV_FS_STATFS, + UV_FS_MKSTEMP, + UV_FS_LUTIME +} uv_fs_type; + +struct uv_dir_s { + uv_dirent_t* dirents; + size_t nentries; + void* reserved[4]; + UV_DIR_PRIVATE_FIELDS +}; + +/* uv_fs_t is a subclass of uv_req_t. */ +struct uv_fs_s { + UV_REQ_FIELDS + uv_fs_type fs_type; + uv_loop_t* loop; + uv_fs_cb cb; + ssize_t result; + void* ptr; + const char* path; + uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ + UV_FS_PRIVATE_FIELDS +}; + +UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); +UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); +UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); +UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); +UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); + +UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); +UV_EXTERN int uv_fs_close(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_open(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_read(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t offset, + uv_fs_cb cb); +UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_write(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + const uv_buf_t bufs[], + unsigned int nbufs, + int64_t offset, + uv_fs_cb cb); +/* + * This flag can be used with uv_fs_copyfile() to return an error if the + * destination already exists. + */ +#define UV_FS_COPYFILE_EXCL 0x0001 + +/* + * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. + * If copy-on-write is not supported, a fallback copy mechanism is used. + */ +#define UV_FS_COPYFILE_FICLONE 0x0002 + +/* + * This flag can be used with uv_fs_copyfile() to attempt to create a reflink. + * If copy-on-write is not supported, an error is returned. + */ +#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004 + +UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); +UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); +UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, + uv_dirent_t* ent); +UV_EXTERN int uv_fs_opendir(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_readdir(uv_loop_t* loop, + uv_fs_t* req, + uv_dir_t* dir, + uv_fs_cb cb); +UV_EXTERN int uv_fs_closedir(uv_loop_t* loop, + uv_fs_t* req, + uv_dir_t* dir, + uv_fs_cb cb); +UV_EXTERN int uv_fs_stat(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_rename(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_fs_cb cb); +UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int64_t offset, + uv_fs_cb cb); +UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, + uv_fs_t* req, + uv_file out_fd, + uv_file in_fd, + int64_t in_offset, + size_t length, + uv_fs_cb cb); +UV_EXTERN int uv_fs_access(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_utime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb); +UV_EXTERN int uv_fs_futime(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + double atime, + double mtime, + uv_fs_cb cb); +UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_link(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + uv_fs_cb cb); + +/* + * This flag can be used with uv_fs_symlink() on Windows to specify whether + * path argument points to a directory. + */ +#define UV_FS_SYMLINK_DIR 0x0001 + +/* + * This flag can be used with uv_fs_symlink() on Windows to specify whether + * the symlink is to be created using junction points. + */ +#define UV_FS_SYMLINK_JUNCTION 0x0002 + +UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + const char* new_path, + int flags, + uv_fs_cb cb); +UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + int mode, + uv_fs_cb cb); +UV_EXTERN int uv_fs_chown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, + uv_fs_t* req, + uv_file file, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_uid_t uid, + uv_gid_t gid, + uv_fs_cb cb); +UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); + + +enum uv_fs_event { + UV_RENAME = 1, + UV_CHANGE = 2 +}; + + +struct uv_fs_event_s { + UV_HANDLE_FIELDS + /* private */ + char* path; + UV_FS_EVENT_PRIVATE_FIELDS +}; + + +/* + * uv_fs_stat() based polling file watcher. + */ +struct uv_fs_poll_s { + UV_HANDLE_FIELDS + /* Private, don't touch. */ + void* poll_ctx; +}; + +UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); +UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, + uv_fs_poll_cb poll_cb, + const char* path, + unsigned int interval); +UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); +UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, + char* buffer, + size_t* size); + + +struct uv_signal_s { + UV_HANDLE_FIELDS + uv_signal_cb signal_cb; + int signum; + UV_SIGNAL_PRIVATE_FIELDS +}; + +UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); +UV_EXTERN int uv_signal_start(uv_signal_t* handle, + uv_signal_cb signal_cb, + int signum); +UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, + uv_signal_cb signal_cb, + int signum); +UV_EXTERN int uv_signal_stop(uv_signal_t* handle); + +UV_EXTERN void uv_loadavg(double avg[3]); + + +/* + * Flags to be passed to uv_fs_event_start(). + */ +enum uv_fs_event_flags { + /* + * By default, if the fs event watcher is given a directory name, we will + * watch for all events in that directory. This flags overrides this behavior + * and makes fs_event report only changes to the directory entry itself. This + * flag does not affect individual files watched. + * This flag is currently not implemented yet on any backend. + */ + UV_FS_EVENT_WATCH_ENTRY = 1, + + /* + * By default uv_fs_event will try to use a kernel interface such as inotify + * or kqueue to detect events. This may not work on remote filesystems such + * as NFS mounts. This flag makes fs_event fall back to calling stat() on a + * regular interval. + * This flag is currently not implemented yet on any backend. + */ + UV_FS_EVENT_STAT = 2, + + /* + * By default, event watcher, when watching directory, is not registering + * (is ignoring) changes in it's subdirectories. + * This flag will override this behaviour on platforms that support it. + */ + UV_FS_EVENT_RECURSIVE = 4 +}; + + +UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); +UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, + uv_fs_event_cb cb, + const char* path, + unsigned int flags); +UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); +UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, + char* buffer, + size_t* size); + +UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); +UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); + +UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); +UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); + +UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); +UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); + + +struct uv_random_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* private */ + int status; + void* buf; + size_t buflen; + uv_random_cb cb; + struct uv__work work_req; +}; + +UV_EXTERN int uv_random(uv_loop_t* loop, + uv_random_t* req, + void *buf, + size_t buflen, + unsigned flags, /* For future extension; must be 0. */ + uv_random_cb cb); + +#if defined(IF_NAMESIZE) +# define UV_IF_NAMESIZE (IF_NAMESIZE + 1) +#elif defined(IFNAMSIZ) +# define UV_IF_NAMESIZE (IFNAMSIZ + 1) +#else +# define UV_IF_NAMESIZE (16 + 1) +#endif + +UV_EXTERN int uv_if_indextoname(unsigned int ifindex, + char* buffer, + size_t* size); +UV_EXTERN int uv_if_indextoiid(unsigned int ifindex, + char* buffer, + size_t* size); + +UV_EXTERN int uv_exepath(char* buffer, size_t* size); + +UV_EXTERN int uv_cwd(char* buffer, size_t* size); + +UV_EXTERN int uv_chdir(const char* dir); + +UV_EXTERN uint64_t uv_get_free_memory(void); +UV_EXTERN uint64_t uv_get_total_memory(void); +UV_EXTERN uint64_t uv_get_constrained_memory(void); + +UV_EXTERN uint64_t uv_hrtime(void); +UV_EXTERN void uv_sleep(unsigned int msec); + +UV_EXTERN void uv_disable_stdio_inheritance(void); + +UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); +UV_EXTERN void uv_dlclose(uv_lib_t* lib); +UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); +UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); + +UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); +UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); +UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); +UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); + +UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); +UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); +UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); +UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); + +UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); +UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); +UV_EXTERN void uv_sem_post(uv_sem_t* sem); +UV_EXTERN void uv_sem_wait(uv_sem_t* sem); +UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); + +UV_EXTERN int uv_cond_init(uv_cond_t* cond); +UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); +UV_EXTERN void uv_cond_signal(uv_cond_t* cond); +UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); + +UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); +UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); +UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); + +UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); +UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, + uv_mutex_t* mutex, + uint64_t timeout); + +UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); + +UV_EXTERN int uv_key_create(uv_key_t* key); +UV_EXTERN void uv_key_delete(uv_key_t* key); +UV_EXTERN void* uv_key_get(uv_key_t* key); +UV_EXTERN void uv_key_set(uv_key_t* key, void* value); + +UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv); + +typedef void (*uv_thread_cb)(void* arg); + +UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); + +typedef enum { + UV_THREAD_NO_FLAGS = 0x00, + UV_THREAD_HAS_STACK_SIZE = 0x01 +} uv_thread_create_flags; + +struct uv_thread_options_s { + unsigned int flags; + size_t stack_size; + /* More fields may be added at any time. */ +}; + +typedef struct uv_thread_options_s uv_thread_options_t; + +UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid, + const uv_thread_options_t* params, + uv_thread_cb entry, + void* arg); +UV_EXTERN uv_thread_t uv_thread_self(void); +UV_EXTERN int uv_thread_join(uv_thread_t *tid); +UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); + +/* The presence of these unions force similar struct layout. */ +#define XX(_, name) uv_ ## name ## _t name; +union uv_any_handle { + UV_HANDLE_TYPE_MAP(XX) +}; + +union uv_any_req { + UV_REQ_TYPE_MAP(XX) +}; +#undef XX + + +struct uv_loop_s { + /* User data - use this for whatever. */ + void* data; + /* Loop reference counting. */ + unsigned int active_handles; + void* handle_queue[2]; + union { + void* unused; + unsigned int count; + } active_reqs; + /* Internal storage for future extensions. */ + void* internal_fields; + /* Internal flag to signal loop stop. */ + unsigned int stop_flag; + UV_LOOP_PRIVATE_FIELDS +}; + +UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); +UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); + +/* Don't export the private CPP symbols. */ +#undef UV_HANDLE_TYPE_PRIVATE +#undef UV_REQ_TYPE_PRIVATE +#undef UV_REQ_PRIVATE_FIELDS +#undef UV_STREAM_PRIVATE_FIELDS +#undef UV_TCP_PRIVATE_FIELDS +#undef UV_PREPARE_PRIVATE_FIELDS +#undef UV_CHECK_PRIVATE_FIELDS +#undef UV_IDLE_PRIVATE_FIELDS +#undef UV_ASYNC_PRIVATE_FIELDS +#undef UV_TIMER_PRIVATE_FIELDS +#undef UV_GETADDRINFO_PRIVATE_FIELDS +#undef UV_GETNAMEINFO_PRIVATE_FIELDS +#undef UV_FS_REQ_PRIVATE_FIELDS +#undef UV_WORK_PRIVATE_FIELDS +#undef UV_FS_EVENT_PRIVATE_FIELDS +#undef UV_SIGNAL_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS +#undef UV__ERR + +#ifdef __cplusplus +} +#endif +#endif /* UV_H */ diff --git a/third_party/libuv/libuv.ndk.json b/third_party/libuv/libuv.ndk.json index aeff061feeb2d620d78d62283890ab0ecc1f7516..d0b5caff9240c16ac28af07d75caca8f2806442b 100644 --- a/third_party/libuv/libuv.ndk.json +++ b/third_party/libuv/libuv.ndk.json @@ -1,284 +1,284 @@ -[ - {"name":"uv_version"}, - {"name":"uv_version_string"}, - {"name":"uv_replace_allocator"}, - {"name":"uv_default_loop"}, - {"name":"uv_loop_init"}, - {"name":"uv_loop_close"}, - {"name":"uv_loop_new"}, - {"name":"uv_loop_delete"}, - {"name":"uv_loop_size"}, - {"name":"uv_loop_alive"}, - {"name":"uv_loop_configure"}, - {"name":"uv_loop_fork"}, - {"name":"uv_run"}, - {"name":"uv_stop"}, - {"name":"uv_ref"}, - {"name":"uv_unref"}, - {"name":"uv_has_ref"}, - {"name":"uv_update_time"}, - {"name":"uv_now"}, - {"name":"uv_backend_fd"}, - {"name":"uv_backend_timeout"}, - {"name":"uv_translate_sys_error"}, - {"name":"uv_strerror"}, - {"name":"uv_strerror_r"}, - {"name":"uv_err_name"}, - {"name":"uv_err_name_r"}, - {"name":"uv_shutdown"}, - {"name":"uv_handle_size"}, - {"name":"uv_handle_get_type"}, - {"name":"uv_handle_type_name"}, - {"name":"uv_handle_get_data"}, - {"name":"uv_handle_get_loop"}, - {"name":"uv_handle_set_data"}, - {"name":"uv_req_size"}, - {"name":"uv_req_get_data"}, - {"name":"uv_req_set_data"}, - {"name":"uv_req_get_type"}, - {"name":"uv_req_type_name"}, - {"name":"uv_is_active"}, - {"name":"uv_walk"}, - {"name":"uv_print_all_handles"}, - {"name":"uv_print_active_handles"}, - {"name":"uv_close"}, - {"name":"uv_send_buffer_size"}, - {"name":"uv_recv_buffer_size"}, - {"name":"uv_fileno"}, - {"name":"uv_buf_init"}, - {"name":"uv_stream_get_write_queue_size"}, - {"name":"uv_listen"}, - {"name":"uv_accept"}, - {"name":"uv_read_start"}, - {"name":"uv_read_stop"}, - {"name":"uv_write"}, - {"name":"uv_write2"}, - {"name":"uv_try_write"}, - {"name":"uv_is_readable"}, - {"name":"uv_is_writable"}, - {"name":"uv_stream_set_blocking"}, - {"name":"uv_is_closing"}, - {"name":"uv_tcp_init"}, - {"name":"uv_tcp_init_ex"}, - {"name":"uv_tcp_open"}, - {"name":"uv_tcp_nodelay"}, - {"name":"uv_tcp_keepalive"}, - {"name":"uv_tcp_simultaneous_accepts"}, - {"name":"uv_tcp_bind"}, - {"name":"uv_tcp_getsockname"}, - {"name":"uv_tcp_getpeername"}, - {"name":"uv_tcp_close_reset"}, - {"name":"uv_tcp_connect"}, - {"name":"uv_udp_init"}, - {"name":"uv_udp_init_ex"}, - {"name":"uv_udp_open"}, - {"name":"uv_udp_bind"}, - {"name":"uv_udp_connect"}, - {"name":"uv_udp_getpeername"}, - {"name":"uv_udp_getsockname"}, - {"name":"uv_udp_set_membership"}, - {"name":"uv_udp_set_source_membership"}, - {"name":"uv_udp_set_multicast_loop"}, - {"name":"uv_udp_set_multicast_ttl"}, - {"name":"uv_udp_set_multicast_interface"}, - {"name":"uv_udp_set_broadcast"}, - {"name":"uv_udp_set_ttl"}, - {"name":"uv_udp_send"}, - {"name":"uv_udp_try_send"}, - {"name":"uv_udp_recv_start"}, - {"name":"uv_udp_recv_stop"}, - {"name":"uv_udp_get_send_queue_size"}, - {"name":"uv_udp_get_send_queue_count"}, - {"name":"uv_tty_init"}, - {"name":"uv_tty_set_mode"}, - {"name":"uv_tty_reset_mode"}, - {"name":"uv_tty_get_winsize"}, - {"name":"uv_tty_set_vterm_state"}, - {"name":"uv_tty_get_vterm_state"}, - {"name":"uv_guess_handle"}, - {"name":"uv_pipe_init"}, - {"name":"uv_pipe_open"}, - {"name":"uv_pipe_bind"}, - {"name":"uv_pipe_connect"}, - {"name":"uv_pipe_getsockname"}, - {"name":"uv_pipe_getpeername"}, - {"name":"uv_pipe_pending_instances"}, - {"name":"uv_pipe_pending_count"}, - {"name":"uv_pipe_pending_type"}, - {"name":"uv_pipe_chmod"}, - {"name":"uv_poll_init"}, - {"name":"uv_poll_init_socket"}, - {"name":"uv_poll_start"}, - {"name":"uv_poll_stop"}, - {"name":"uv_prepare_init"}, - {"name":"uv_prepare_start"}, - {"name":"uv_prepare_stop"}, - {"name":"uv_check_init"}, - {"name":"uv_check_start"}, - {"name":"uv_check_stop"}, - {"name":"uv_idle_init"}, - {"name":"uv_idle_start"}, - {"name":"uv_idle_stop"}, - {"name":"uv_async_init"}, - {"name":"uv_async_send"}, - {"name":"uv_timer_init"}, - {"name":"uv_timer_start"}, - {"name":"uv_timer_stop"}, - {"name":"uv_timer_again"}, - {"name":"uv_timer_set_repeat"}, - {"name":"uv_timer_get_repeat"}, - {"name":"uv_getaddrinfo"}, - {"name":"uv_freeaddrinfo"}, - {"name":"uv_getnameinfo"}, - {"name":"uv_spawn"}, - {"name":"uv_process_kill"}, - {"name":"uv_kill"}, - {"name":"uv_process_get_pid"}, - {"name":"uv_queue_work"}, - {"name":"uv_cancel"}, - {"name":"uv_setup_args"}, - {"name":"uv_get_process_title"}, - {"name":"uv_set_process_title"}, - {"name":"uv_resident_set_memory"}, - {"name":"uv_uptime"}, - {"name":"uv_get_osfhandle"}, - {"name":"uv_open_osfhandle"}, - {"name":"uv_getrusage"}, - {"name":"uv_os_homedir"}, - {"name":"uv_os_tmpdir"}, - {"name":"uv_os_get_passwd"}, - {"name":"uv_os_free_passwd"}, - {"name":"uv_os_getpid"}, - {"name":"uv_os_getppid"}, - {"name":"uv_os_getpriority"}, - {"name":"uv_os_setpriority"}, - {"name":"uv_cpu_info"}, - {"name":"uv_free_cpu_info"}, - {"name":"uv_interface_addresses"}, - {"name":"uv_free_interface_addresses"}, - {"name":"uv_os_environ"}, - {"name":"uv_os_free_environ"}, - {"name":"uv_os_getenv"}, - {"name":"uv_os_setenv"}, - {"name":"uv_os_unsetenv"}, - {"name":"uv_os_gethostname"}, - {"name":"uv_os_uname"}, - {"name":"uv_fs_get_type"}, - {"name":"uv_fs_get_result"}, - {"name":"uv_fs_get_ptr"}, - {"name":"uv_fs_get_path"}, - {"name":"uv_fs_get_statbuf"}, - {"name":"uv_fs_req_cleanup"}, - {"name":"uv_fs_close"}, - {"name":"uv_fs_open"}, - {"name":"uv_fs_read"}, - {"name":"uv_fs_unlink"}, - {"name":"uv_fs_write"}, - {"name":"uv_fs_copyfile"}, - {"name":"uv_fs_mkdir"}, - {"name":"uv_fs_mkdtemp"}, - {"name":"uv_fs_mkstemp"}, - {"name":"uv_fs_rmdir"}, - {"name":"uv_fs_scandir"}, - {"name":"uv_fs_scandir_next"}, - {"name":"uv_fs_opendir"}, - {"name":"uv_fs_readdir"}, - {"name":"uv_fs_closedir"}, - {"name":"uv_fs_stat"}, - {"name":"uv_fs_fstat"}, - {"name":"uv_fs_rename"}, - {"name":"uv_fs_fsync"}, - {"name":"uv_fs_fdatasync"}, - {"name":"uv_fs_ftruncate"}, - {"name":"uv_fs_sendfile"}, - {"name":"uv_fs_access"}, - {"name":"uv_fs_chmod"}, - {"name":"uv_fs_utime"}, - {"name":"uv_fs_futime"}, - {"name":"uv_fs_lstat"}, - {"name":"uv_fs_link"}, - {"name":"uv_fs_symlink"}, - {"name":"uv_fs_readlink"}, - {"name":"uv_fs_realpath"}, - {"name":"uv_fs_fchmod"}, - {"name":"uv_fs_chown"}, - {"name":"uv_fs_fchown"}, - {"name":"uv_fs_lchown"}, - {"name":"uv_fs_statfs"}, - {"name":"uv_fs_poll_init"}, - {"name":"uv_fs_poll_start"}, - {"name":"uv_fs_poll_stop"}, - {"name":"uv_fs_poll_getpath"}, - {"name":"uv_signal_init"}, - {"name":"uv_signal_start"}, - {"name":"uv_signal_start_oneshot"}, - {"name":"uv_signal_stop"}, - {"name":"uv_loadavg"}, - {"name":"uv_fs_event_init"}, - {"name":"uv_fs_event_start"}, - {"name":"uv_fs_event_stop"}, - {"name":"uv_fs_event_getpath"}, - {"name":"uv_ip4_addr"}, - {"name":"uv_ip6_addr"}, - {"name":"uv_ip4_name"}, - {"name":"uv_ip6_name"}, - {"name":"uv_inet_ntop"}, - {"name":"uv_inet_pton"}, - {"name":"uv_random"}, - {"name":"uv_if_indextoname"}, - {"name":"uv_if_indextoiid"}, - {"name":"uv_exepath"}, - {"name":"uv_cwd"}, - {"name":"uv_chdir"}, - {"name":"uv_get_free_memory"}, - {"name":"uv_get_total_memory"}, - {"name":"uv_get_constrained_memory"}, - {"name":"uv_hrtime"}, - {"name":"uv_sleep"}, - {"name":"uv_disable_stdio_inheritance"}, - {"name":"uv_dlopen"}, - {"name":"uv_dlclose"}, - {"name":"uv_dlsym"}, - {"name":"uv_dlerror"}, - {"name":"uv_mutex_init"}, - {"name":"uv_mutex_init_recursive"}, - {"name":"uv_mutex_destroy"}, - {"name":"uv_mutex_lock"}, - {"name":"uv_mutex_trylock"}, - {"name":"uv_mutex_unlock"}, - {"name":"uv_rwlock_init"}, - {"name":"uv_rwlock_destroy"}, - {"name":"uv_rwlock_rdlock"}, - {"name":"uv_rwlock_tryrdlock"}, - {"name":"uv_rwlock_rdunlock"}, - {"name":"uv_rwlock_wrlock"}, - {"name":"uv_rwlock_trywrlock"}, - {"name":"uv_rwlock_wrunlock"}, - {"name":"uv_sem_init"}, - {"name":"uv_sem_destroy"}, - {"name":"uv_sem_post"}, - {"name":"uv_sem_wait"}, - {"name":"uv_sem_trywait"}, - {"name":"uv_cond_init"}, - {"name":"uv_cond_destroy"}, - {"name":"uv_cond_signal"}, - {"name":"uv_cond_broadcast"}, - {"name":"uv_barrier_init"}, - {"name":"uv_barrier_destroy"}, - {"name":"uv_barrier_wait"}, - {"name":"uv_cond_wait"}, - {"name":"uv_cond_timedwait"}, - {"name":"uv_once"}, - {"name":"uv_key_create"}, - {"name":"uv_key_delete"}, - {"name":"uv_key_get"}, - {"name":"uv_key_set"}, - {"name":"uv_gettimeofday"}, - {"name":"uv_thread_create"}, - {"name":"uv_thread_create_ex"}, - {"name":"uv_thread_self"}, - {"name":"uv_thread_join"}, - {"name":"uv_thread_equal"}, - {"name":"uv_loop_get_data"}, - {"name":"uv_loop_set_data"} -] +[ + {"name":"uv_version"}, + {"name":"uv_version_string"}, + {"name":"uv_replace_allocator"}, + {"name":"uv_default_loop"}, + {"name":"uv_loop_init"}, + {"name":"uv_loop_close"}, + {"name":"uv_loop_new"}, + {"name":"uv_loop_delete"}, + {"name":"uv_loop_size"}, + {"name":"uv_loop_alive"}, + {"name":"uv_loop_configure"}, + {"name":"uv_loop_fork"}, + {"name":"uv_run"}, + {"name":"uv_stop"}, + {"name":"uv_ref"}, + {"name":"uv_unref"}, + {"name":"uv_has_ref"}, + {"name":"uv_update_time"}, + {"name":"uv_now"}, + {"name":"uv_backend_fd"}, + {"name":"uv_backend_timeout"}, + {"name":"uv_translate_sys_error"}, + {"name":"uv_strerror"}, + {"name":"uv_strerror_r"}, + {"name":"uv_err_name"}, + {"name":"uv_err_name_r"}, + {"name":"uv_shutdown"}, + {"name":"uv_handle_size"}, + {"name":"uv_handle_get_type"}, + {"name":"uv_handle_type_name"}, + {"name":"uv_handle_get_data"}, + {"name":"uv_handle_get_loop"}, + {"name":"uv_handle_set_data"}, + {"name":"uv_req_size"}, + {"name":"uv_req_get_data"}, + {"name":"uv_req_set_data"}, + {"name":"uv_req_get_type"}, + {"name":"uv_req_type_name"}, + {"name":"uv_is_active"}, + {"name":"uv_walk"}, + {"name":"uv_print_all_handles"}, + {"name":"uv_print_active_handles"}, + {"name":"uv_close"}, + {"name":"uv_send_buffer_size"}, + {"name":"uv_recv_buffer_size"}, + {"name":"uv_fileno"}, + {"name":"uv_buf_init"}, + {"name":"uv_stream_get_write_queue_size"}, + {"name":"uv_listen"}, + {"name":"uv_accept"}, + {"name":"uv_read_start"}, + {"name":"uv_read_stop"}, + {"name":"uv_write"}, + {"name":"uv_write2"}, + {"name":"uv_try_write"}, + {"name":"uv_is_readable"}, + {"name":"uv_is_writable"}, + {"name":"uv_stream_set_blocking"}, + {"name":"uv_is_closing"}, + {"name":"uv_tcp_init"}, + {"name":"uv_tcp_init_ex"}, + {"name":"uv_tcp_open"}, + {"name":"uv_tcp_nodelay"}, + {"name":"uv_tcp_keepalive"}, + {"name":"uv_tcp_simultaneous_accepts"}, + {"name":"uv_tcp_bind"}, + {"name":"uv_tcp_getsockname"}, + {"name":"uv_tcp_getpeername"}, + {"name":"uv_tcp_close_reset"}, + {"name":"uv_tcp_connect"}, + {"name":"uv_udp_init"}, + {"name":"uv_udp_init_ex"}, + {"name":"uv_udp_open"}, + {"name":"uv_udp_bind"}, + {"name":"uv_udp_connect"}, + {"name":"uv_udp_getpeername"}, + {"name":"uv_udp_getsockname"}, + {"name":"uv_udp_set_membership"}, + {"name":"uv_udp_set_source_membership"}, + {"name":"uv_udp_set_multicast_loop"}, + {"name":"uv_udp_set_multicast_ttl"}, + {"name":"uv_udp_set_multicast_interface"}, + {"name":"uv_udp_set_broadcast"}, + {"name":"uv_udp_set_ttl"}, + {"name":"uv_udp_send"}, + {"name":"uv_udp_try_send"}, + {"name":"uv_udp_recv_start"}, + {"name":"uv_udp_recv_stop"}, + {"name":"uv_udp_get_send_queue_size"}, + {"name":"uv_udp_get_send_queue_count"}, + {"name":"uv_tty_init"}, + {"name":"uv_tty_set_mode"}, + {"name":"uv_tty_reset_mode"}, + {"name":"uv_tty_get_winsize"}, + {"name":"uv_tty_set_vterm_state"}, + {"name":"uv_tty_get_vterm_state"}, + {"name":"uv_guess_handle"}, + {"name":"uv_pipe_init"}, + {"name":"uv_pipe_open"}, + {"name":"uv_pipe_bind"}, + {"name":"uv_pipe_connect"}, + {"name":"uv_pipe_getsockname"}, + {"name":"uv_pipe_getpeername"}, + {"name":"uv_pipe_pending_instances"}, + {"name":"uv_pipe_pending_count"}, + {"name":"uv_pipe_pending_type"}, + {"name":"uv_pipe_chmod"}, + {"name":"uv_poll_init"}, + {"name":"uv_poll_init_socket"}, + {"name":"uv_poll_start"}, + {"name":"uv_poll_stop"}, + {"name":"uv_prepare_init"}, + {"name":"uv_prepare_start"}, + {"name":"uv_prepare_stop"}, + {"name":"uv_check_init"}, + {"name":"uv_check_start"}, + {"name":"uv_check_stop"}, + {"name":"uv_idle_init"}, + {"name":"uv_idle_start"}, + {"name":"uv_idle_stop"}, + {"name":"uv_async_init"}, + {"name":"uv_async_send"}, + {"name":"uv_timer_init"}, + {"name":"uv_timer_start"}, + {"name":"uv_timer_stop"}, + {"name":"uv_timer_again"}, + {"name":"uv_timer_set_repeat"}, + {"name":"uv_timer_get_repeat"}, + {"name":"uv_getaddrinfo"}, + {"name":"uv_freeaddrinfo"}, + {"name":"uv_getnameinfo"}, + {"name":"uv_spawn"}, + {"name":"uv_process_kill"}, + {"name":"uv_kill"}, + {"name":"uv_process_get_pid"}, + {"name":"uv_queue_work"}, + {"name":"uv_cancel"}, + {"name":"uv_setup_args"}, + {"name":"uv_get_process_title"}, + {"name":"uv_set_process_title"}, + {"name":"uv_resident_set_memory"}, + {"name":"uv_uptime"}, + {"name":"uv_get_osfhandle"}, + {"name":"uv_open_osfhandle"}, + {"name":"uv_getrusage"}, + {"name":"uv_os_homedir"}, + {"name":"uv_os_tmpdir"}, + {"name":"uv_os_get_passwd"}, + {"name":"uv_os_free_passwd"}, + {"name":"uv_os_getpid"}, + {"name":"uv_os_getppid"}, + {"name":"uv_os_getpriority"}, + {"name":"uv_os_setpriority"}, + {"name":"uv_cpu_info"}, + {"name":"uv_free_cpu_info"}, + {"name":"uv_interface_addresses"}, + {"name":"uv_free_interface_addresses"}, + {"name":"uv_os_environ"}, + {"name":"uv_os_free_environ"}, + {"name":"uv_os_getenv"}, + {"name":"uv_os_setenv"}, + {"name":"uv_os_unsetenv"}, + {"name":"uv_os_gethostname"}, + {"name":"uv_os_uname"}, + {"name":"uv_fs_get_type"}, + {"name":"uv_fs_get_result"}, + {"name":"uv_fs_get_ptr"}, + {"name":"uv_fs_get_path"}, + {"name":"uv_fs_get_statbuf"}, + {"name":"uv_fs_req_cleanup"}, + {"name":"uv_fs_close"}, + {"name":"uv_fs_open"}, + {"name":"uv_fs_read"}, + {"name":"uv_fs_unlink"}, + {"name":"uv_fs_write"}, + {"name":"uv_fs_copyfile"}, + {"name":"uv_fs_mkdir"}, + {"name":"uv_fs_mkdtemp"}, + {"name":"uv_fs_mkstemp"}, + {"name":"uv_fs_rmdir"}, + {"name":"uv_fs_scandir"}, + {"name":"uv_fs_scandir_next"}, + {"name":"uv_fs_opendir"}, + {"name":"uv_fs_readdir"}, + {"name":"uv_fs_closedir"}, + {"name":"uv_fs_stat"}, + {"name":"uv_fs_fstat"}, + {"name":"uv_fs_rename"}, + {"name":"uv_fs_fsync"}, + {"name":"uv_fs_fdatasync"}, + {"name":"uv_fs_ftruncate"}, + {"name":"uv_fs_sendfile"}, + {"name":"uv_fs_access"}, + {"name":"uv_fs_chmod"}, + {"name":"uv_fs_utime"}, + {"name":"uv_fs_futime"}, + {"name":"uv_fs_lstat"}, + {"name":"uv_fs_link"}, + {"name":"uv_fs_symlink"}, + {"name":"uv_fs_readlink"}, + {"name":"uv_fs_realpath"}, + {"name":"uv_fs_fchmod"}, + {"name":"uv_fs_chown"}, + {"name":"uv_fs_fchown"}, + {"name":"uv_fs_lchown"}, + {"name":"uv_fs_statfs"}, + {"name":"uv_fs_poll_init"}, + {"name":"uv_fs_poll_start"}, + {"name":"uv_fs_poll_stop"}, + {"name":"uv_fs_poll_getpath"}, + {"name":"uv_signal_init"}, + {"name":"uv_signal_start"}, + {"name":"uv_signal_start_oneshot"}, + {"name":"uv_signal_stop"}, + {"name":"uv_loadavg"}, + {"name":"uv_fs_event_init"}, + {"name":"uv_fs_event_start"}, + {"name":"uv_fs_event_stop"}, + {"name":"uv_fs_event_getpath"}, + {"name":"uv_ip4_addr"}, + {"name":"uv_ip6_addr"}, + {"name":"uv_ip4_name"}, + {"name":"uv_ip6_name"}, + {"name":"uv_inet_ntop"}, + {"name":"uv_inet_pton"}, + {"name":"uv_random"}, + {"name":"uv_if_indextoname"}, + {"name":"uv_if_indextoiid"}, + {"name":"uv_exepath"}, + {"name":"uv_cwd"}, + {"name":"uv_chdir"}, + {"name":"uv_get_free_memory"}, + {"name":"uv_get_total_memory"}, + {"name":"uv_get_constrained_memory"}, + {"name":"uv_hrtime"}, + {"name":"uv_sleep"}, + {"name":"uv_disable_stdio_inheritance"}, + {"name":"uv_dlopen"}, + {"name":"uv_dlclose"}, + {"name":"uv_dlsym"}, + {"name":"uv_dlerror"}, + {"name":"uv_mutex_init"}, + {"name":"uv_mutex_init_recursive"}, + {"name":"uv_mutex_destroy"}, + {"name":"uv_mutex_lock"}, + {"name":"uv_mutex_trylock"}, + {"name":"uv_mutex_unlock"}, + {"name":"uv_rwlock_init"}, + {"name":"uv_rwlock_destroy"}, + {"name":"uv_rwlock_rdlock"}, + {"name":"uv_rwlock_tryrdlock"}, + {"name":"uv_rwlock_rdunlock"}, + {"name":"uv_rwlock_wrlock"}, + {"name":"uv_rwlock_trywrlock"}, + {"name":"uv_rwlock_wrunlock"}, + {"name":"uv_sem_init"}, + {"name":"uv_sem_destroy"}, + {"name":"uv_sem_post"}, + {"name":"uv_sem_wait"}, + {"name":"uv_sem_trywait"}, + {"name":"uv_cond_init"}, + {"name":"uv_cond_destroy"}, + {"name":"uv_cond_signal"}, + {"name":"uv_cond_broadcast"}, + {"name":"uv_barrier_init"}, + {"name":"uv_barrier_destroy"}, + {"name":"uv_barrier_wait"}, + {"name":"uv_cond_wait"}, + {"name":"uv_cond_timedwait"}, + {"name":"uv_once"}, + {"name":"uv_key_create"}, + {"name":"uv_key_delete"}, + {"name":"uv_key_get"}, + {"name":"uv_key_set"}, + {"name":"uv_gettimeofday"}, + {"name":"uv_thread_create"}, + {"name":"uv_thread_create_ex"}, + {"name":"uv_thread_self"}, + {"name":"uv_thread_join"}, + {"name":"uv_thread_equal"}, + {"name":"uv_loop_get_data"}, + {"name":"uv_loop_set_data"} +] diff --git a/third_party/mindspore/BUILD.gn b/third_party/mindspore/kits/BUILD.gn similarity index 96% rename from third_party/mindspore/BUILD.gn rename to third_party/mindspore/kits/BUILD.gn index de586fbb605c45f2df311b7bca74d72d43db90af..294ac2da5c08d371f8a9fefaf660143a2b70e6c7 100644 --- a/third_party/mindspore/BUILD.gn +++ b/third_party/mindspore/kits/BUILD.gn @@ -1,37 +1,37 @@ -# Copyright 2022 Huawei Technologies 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") - -ohos_ndk_headers("mindspore_header") { - dest_dir = "$ndk_headers_out_dir/mindspore" - sources = [ - "context.h", - "data_type.h", - "format.h", - "model.h", - "status.h", - "tensor.h", - "types.h", - ] -} - -ohos_ndk_library("mindspore_lib") { - output_name = "mindspore_lite_ndk" - output_extension = "so" - ndk_description_file = "./mindspore_lib.ndk.json" - system_capability = "SystemCapability.Ai.MindSpore" - min_compact_version = "9" -} +# Copyright 2022 Huawei Technologies 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") + +ohos_ndk_headers("mindspore_header") { + dest_dir = "$ndk_headers_out_dir/mindspore" + sources = [ + "context.h", + "data_type.h", + "format.h", + "model.h", + "status.h", + "tensor.h", + "types.h", + ] +} + +ohos_ndk_library("mindspore_lib") { + output_name = "mindspore_lite_ndk" + output_extension = "so" + ndk_description_file = "./mindspore_lib.ndk.json" + system_capability = "SystemCapability.Ai.MindSpore" + min_compact_version = "9" +} diff --git a/third_party/mindspore/context.h b/third_party/mindspore/kits/context.h similarity index 93% rename from third_party/mindspore/context.h rename to third_party/mindspore/kits/context.h index 0e5ff02311f9e8c5985d492820b38079a3de448e..354443992c74ceb1401ed7b450a60168fd559b16 100644 --- a/third_party/mindspore/context.h +++ b/third_party/mindspore/kits/context.h @@ -1,338 +1,357 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_CONTEXT_C_H -#define MINDSPORE_INCLUDE_C_API_CONTEXT_C_H - -#include -#include -#include -#include "mindspore/types.h" -#include "mindspore/status.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *OH_AI_ContextHandle; -typedef void *OH_AI_DeviceInfoHandle; - -/** - * @brief Create a context object. - * @return Context object handle. - * @since 9 - */ -OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate(); - -/** - * @brief Destroy the context object. - * @param context Context object handle address. - * @since 9 - */ -OH_AI_API void OH_AI_ContextDestroy(OH_AI_ContextHandle *context); - -/** - * @brief Set the number of threads at runtime. - * @param context Context object handle. - * @param thread_num the number of threads at runtime. - * @since 9 - */ -OH_AI_API void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num); - -/** - * @brief Obtain the current thread number setting. - * @param context Context object handle. - * @return The current thread number setting. - * @since 9 - */ -OH_AI_API int32_t OH_AI_ContextGetThreadNum(const OH_AI_ContextHandle context); - -/** - * @brief Set the thread affinity to CPU cores. - * @param context Context object handle. - * @param mode: 0: no affinities, 1: big cores first, 2: little cores first - * @since 9 - */ -OH_AI_API void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode); - -/** - * @brief Obtain the thread affinity of CPU cores. - * @param context Context object handle. - * @return Thread affinity to CPU cores. 0: no affinities, 1: big cores first, 2: little cores first - * @since 9 - */ -OH_AI_API int OH_AI_ContextGetThreadAffinityMode(const OH_AI_ContextHandle context); - -/** - * @brief Set the thread lists to CPU cores. - * - * If core_list and mode are set by OH_AI_ContextSetThreadAffinityMode at the same time, - * the core_list is effective, but the mode is not effective. \n - * - * @param context Context object handle. - * @param core_list: a array of thread core lists. - * @param core_num The number of core. - * @since 9 - */ -OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList(OH_AI_ContextHandle context, const int32_t *core_list, - size_t core_num); - -/** - * @brief Obtain the thread lists of CPU cores. - * @param context Context object handle. - * @param core_num The number of core. - * @return a array of thread core lists. - * @since 9 - */ -OH_AI_API const int32_t *OH_AI_ContextGetThreadAffinityCoreList(const OH_AI_ContextHandle context, size_t *core_num); - -/** - * @brief Set the status whether to perform model inference or training in parallel. - * @param context Context object handle. - * @param is_parallel: true, parallel; false, not in parallel. - * @since 9 - */ -OH_AI_API void OH_AI_ContextSetEnableParallel(OH_AI_ContextHandle context, bool is_parallel); - -/** - * @brief Obtain the status whether to perform model inference or training in parallel. - * @param context Context object handle. - * @return Bool value that indicates whether in parallel. - * @since 9 - */ - OH_AI_API bool OH_AI_ContextGetEnableParallel(const OH_AI_ContextHandle context); - -/** - * @brief Add device info to context object. - * @param context Context object handle. - * @param device_info Device info object handle. - * @since 9 - */ -OH_AI_API void OH_AI_ContextAddDeviceInfo(OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Create a device info object. - * @param device_info Device info object handle. - * @return Device info object handle. - * @since 9 - */ -OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type); - -/** - * @brief Destroy the device info object. - * @param device_info Device info object handle address. - * @since 9 - */ -OH_AI_API void OH_AI_DeviceInfoDestroy(OH_AI_DeviceInfoHandle *device_info); - -/** - * @brief Set provider's name. - * @param device_info Device info object handle. - * @param provider define the provider's name. - * @since 9 - */ -OH_AI_API void OH_AI_DeviceInfoSetProvider(OH_AI_DeviceInfoHandle device_info, const char *provider); - -/** - * @brief Obtain provider's name - * @param device_info Device info object handle. - * @return provider's name. - * @since 9 - */ -OH_AI_API const char *OH_AI_DeviceInfoGetProvider(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Set provider's device type. - * @param device_info Device info object handle. - * @param device define the provider's device type. EG: CPU. - * @since 9 - */ -OH_AI_API void OH_AI_DeviceInfoSetProviderDevice(OH_AI_DeviceInfoHandle device_info, const char *device); - -/** - * @brief Obtain provider's device type. - * @param device_info Device info object handle. - * @return provider's device type. - * @since 9 - */ -OH_AI_API const char *OH_AI_DeviceInfoGetProviderDevice(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Obtain the device type of the device info. - * @param device_info Device info object handle. - * @return Device Type of the device info. - * @since 9 - */ -OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Set enables to perform the float16 inference, Only valid for CPU/GPU. - * @param device_info Device info object handle. - * @param is_fp16 Enable float16 inference or not. - * @since 9 - */ -OH_AI_API void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16); - -/** - * @brief Obtain enables to perform the float16 inference, Only valid for CPU/GPU. - * @param device_info Device info object handle. - * @return Whether enable float16 inference. - * @since 9 - */ -OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Set the NPU frequency, Only valid for NPU. - * @param device_info Device info object handle. - * @param frequency Can be set to 1 (low power consumption), 2 (balanced), 3 (high performance), 4 (extreme - * performance), default as 3. - * @since 9 - */ -OH_AI_API void OH_AI_DeviceInfoSetFrequency(OH_AI_DeviceInfoHandle device_info, int frequency); - -/** - * @brief Obtain the NPU frequency, Only valid for NPU. - * @param device_info Device info object handle. - * @return NPU frequency - * @since 9 - */ -OH_AI_API int OH_AI_DeviceInfoGetFrequency(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Obtain the all device descriptions in NNRT. - * @param num Number of NNRT device description. - * @return NNRT device description array. - * @since 10 - */ -OH_AI_API NNRTDeviceDesc *OH_AI_GetAllNNRTDeviceDescs(size_t *num); - -/** - * @brief Obtain the specified element in NNRt device description array. - * @param descs NNRT device description array. - * @param index Element index. - * @return NNRT device description. - * @since 10 - */ -OH_AI_API NNRTDeviceDesc *OH_AI_GetElementOfNNRTDeviceDescs(NNRTDeviceDesc *descs, size_t index); - -/** - * @brief Destroy the NNRT device descriptions returned by OH_AI_NNRTGetAllDeviceDescs(). - * @param desc NNRT device description array. - * @since 10 - */ -OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs(NNRTDeviceDesc **desc); - -/** - * @brief Obtain the device id in NNRT device description. - * @param desc pointer to the NNRT device description instance. - * @return NNRT device id. - * @since 10 - */ -OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); - -/** - * @brief Obtain the device name in NNRT device description. - * @param desc pointer to the NNRT device description instance. - * @return NNRT device name. - * @since 10 - */ -OH_AI_API const char *OH_AI_GetNameFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); - -/** - * @brief Obtain the device type in NNRT device description. - * @param desc pointer to the NNRT device description instance. - * @return NNRT device type. - * @since 10 - */ -OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); - -/** - * @brief Create the NNRT device info by exactly matching the specific device name. - * @param name NNRt device name. - * @return Device info object handle. - * @since 10 - */ -OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName(const char *name); - -/** - * @brief Create the NNRT device info by finding the first device with the specific device type. - * @param name NNRt device type. - * @return Device info object handle. - * @since 10 - */ -OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType(OH_AI_NNRTDeviceType type); - -/** - * @brief Set the NNRT device id, Only valid for NNRT. - * @param device_info Device info object handle. - * @param device_id NNRT device id. - * @since 10 - */ -OH_AI_API void OH_AI_DeviceInfoSetDeviceId(OH_AI_DeviceInfoHandle device_info, size_t device_id); - -/** - * @brief Obtain the NNRT device id, Only valid for NNRT. - * @param device_info Device info object handle. - * @return NNRT device id. - * @since 10 - */ -OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Set the NNRT performance mode, Only valid for NNRT. - * @param device_info Device info object handle. - * @param device_id NNRT performance mode. - * @since 10 - */ -OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode(OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode); - -/** - * @brief Obtain the NNRT performance mode, Only valid for NNRT. - * @param device_info Device info object handle. - * @return NNRT performance mode. - * @since 10 - */ -OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Set the NNRT priority, Only valid for NNRT. - * @param device_info Device info object handle. - * @param device_id NNRT priority. - * @since 10 - */ -OH_AI_API void OH_AI_DeviceInfoSetPriority(OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority); - -/** - * @brief Obtain the NNRT priority, Only valid for NNRT. - * @param device_info Device info object handle. - * @return NNRT priority. - * @since 10 - */ -OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority(const OH_AI_DeviceInfoHandle device_info); - -/** - * @brief Add extension of key/value format to device info, Only valid for NNRT. - * @param device_info Device info object handle. - * @param name The content of key as a C string. - * @param value The pointer to the value, which is a byte array. - * @param value_size The size of the value, which is a byte array. - * @return OH_AI_STATUS_SUCCESS if success, or detail error code if failed. - * @since 10 - */ -OH_AI_API OH_AI_Status OH_AI_DeviceInfoAddExtension(OH_AI_DeviceInfoHandle device_info, const char *name, const char *value, size_t value_size); -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_CONTEXT_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file context.h + * + * @brief 提供了Context相关的接口,可以配置运行时信息。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_CONTEXT_C_H +#define MINDSPORE_INCLUDE_C_API_CONTEXT_C_H + +#include +#include +#include +#include "mindspore/types.h" +#include "mindspore/status.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *OH_AI_ContextHandle; +typedef void *OH_AI_DeviceInfoHandle; + +/** + * @brief Create a context object. + * @return Context object handle. + * @since 9 + */ +OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate(); + +/** + * @brief Destroy the context object. + * @param context Context object handle address. + * @since 9 + */ +OH_AI_API void OH_AI_ContextDestroy(OH_AI_ContextHandle *context); + +/** + * @brief Set the number of threads at runtime. + * @param context Context object handle. + * @param thread_num the number of threads at runtime. + * @since 9 + */ +OH_AI_API void OH_AI_ContextSetThreadNum(OH_AI_ContextHandle context, int32_t thread_num); + +/** + * @brief Obtain the current thread number setting. + * @param context Context object handle. + * @return The current thread number setting. + * @since 9 + */ +OH_AI_API int32_t OH_AI_ContextGetThreadNum(const OH_AI_ContextHandle context); + +/** + * @brief Set the thread affinity to CPU cores. + * @param context Context object handle. + * @param mode: 0: no affinities, 1: big cores first, 2: little cores first + * @since 9 + */ +OH_AI_API void OH_AI_ContextSetThreadAffinityMode(OH_AI_ContextHandle context, int mode); + +/** + * @brief Obtain the thread affinity of CPU cores. + * @param context Context object handle. + * @return Thread affinity to CPU cores. 0: no affinities, 1: big cores first, 2: little cores first + * @since 9 + */ +OH_AI_API int OH_AI_ContextGetThreadAffinityMode(const OH_AI_ContextHandle context); + +/** + * @brief Set the thread lists to CPU cores. + * + * If core_list and mode are set by OH_AI_ContextSetThreadAffinityMode at the same time, + * the core_list is effective, but the mode is not effective. \n + * + * @param context Context object handle. + * @param core_list: a array of thread core lists. + * @param core_num The number of core. + * @since 9 + */ +OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList(OH_AI_ContextHandle context, const int32_t *core_list, + size_t core_num); + +/** + * @brief Obtain the thread lists of CPU cores. + * @param context Context object handle. + * @param core_num The number of core. + * @return a array of thread core lists. + * @since 9 + */ +OH_AI_API const int32_t *OH_AI_ContextGetThreadAffinityCoreList(const OH_AI_ContextHandle context, size_t *core_num); + +/** + * @brief Set the status whether to perform model inference or training in parallel. + * @param context Context object handle. + * @param is_parallel: true, parallel; false, not in parallel. + * @since 9 + */ +OH_AI_API void OH_AI_ContextSetEnableParallel(OH_AI_ContextHandle context, bool is_parallel); + +/** + * @brief Obtain the status whether to perform model inference or training in parallel. + * @param context Context object handle. + * @return Bool value that indicates whether in parallel. + * @since 9 + */ +OH_AI_API bool OH_AI_ContextGetEnableParallel(const OH_AI_ContextHandle context); + +/** + * @brief Add device info to context object. + * @param context Context object handle. + * @param device_info Device info object handle. + * @since 9 + */ +OH_AI_API void OH_AI_ContextAddDeviceInfo(OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Create a device info object. + * @param device_info Device info object handle. + * @return Device info object handle. + * @since 9 + */ +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate(OH_AI_DeviceType device_type); + +/** + * @brief Destroy the device info object. + * @param device_info Device info object handle address. + * @since 9 + */ +OH_AI_API void OH_AI_DeviceInfoDestroy(OH_AI_DeviceInfoHandle *device_info); + +/** + * @brief Set provider's name. + * @param device_info Device info object handle. + * @param provider define the provider's name. + * @since 9 + */ +OH_AI_API void OH_AI_DeviceInfoSetProvider(OH_AI_DeviceInfoHandle device_info, const char *provider); + +/** + * @brief Obtain provider's name + * @param device_info Device info object handle. + * @return provider's name. + * @since 9 + */ +OH_AI_API const char *OH_AI_DeviceInfoGetProvider(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Set provider's device type. + * @param device_info Device info object handle. + * @param device define the provider's device type. EG: CPU. + * @since 9 + */ +OH_AI_API void OH_AI_DeviceInfoSetProviderDevice(OH_AI_DeviceInfoHandle device_info, const char *device); + +/** + * @brief Obtain provider's device type. + * @param device_info Device info object handle. + * @return provider's device type. + * @since 9 + */ +OH_AI_API const char *OH_AI_DeviceInfoGetProviderDevice(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Obtain the device type of the device info. + * @param device_info Device info object handle. + * @return Device Type of the device info. + * @since 9 + */ +OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Set enables to perform the float16 inference, Only valid for CPU/GPU. + * @param device_info Device info object handle. + * @param is_fp16 Enable float16 inference or not. + * @since 9 + */ +OH_AI_API void OH_AI_DeviceInfoSetEnableFP16(OH_AI_DeviceInfoHandle device_info, bool is_fp16); + +/** + * @brief Obtain enables to perform the float16 inference, Only valid for CPU/GPU. + * @param device_info Device info object handle. + * @return Whether enable float16 inference. + * @since 9 + */ +OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Set the NPU frequency, Only valid for NPU. + * @param device_info Device info object handle. + * @param frequency Can be set to 1 (low power consumption), 2 (balanced), 3 (high performance), 4 (extreme + * performance), default as 3. + * @since 9 + */ +OH_AI_API void OH_AI_DeviceInfoSetFrequency(OH_AI_DeviceInfoHandle device_info, int frequency); + +/** + * @brief Obtain the NPU frequency, Only valid for NPU. + * @param device_info Device info object handle. + * @return NPU frequency + * @since 9 + */ +OH_AI_API int OH_AI_DeviceInfoGetFrequency(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Obtain the all device descriptions in NNRT. + * @param num Number of NNRT device description. + * @return NNRT device description array. + * @since 10 + */ +OH_AI_API NNRTDeviceDesc *OH_AI_GetAllNNRTDeviceDescs(size_t *num); + +/** + * @brief Obtain the specified element in NNRt device description array. + * @param descs NNRT device description array. + * @param index Element index. + * @return NNRT device description. + * @since 10 + */ +OH_AI_API NNRTDeviceDesc *OH_AI_GetElementOfNNRTDeviceDescs(NNRTDeviceDesc *descs, size_t index); + +/** + * @brief Destroy the NNRT device descriptions returned by OH_AI_NNRTGetAllDeviceDescs(). + * @param desc NNRT device description array. + * @since 10 + */ +OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs(NNRTDeviceDesc **desc); + +/** + * @brief Obtain the device id in NNRT device description. + * @param desc pointer to the NNRT device description instance. + * @return NNRT device id. + * @since 10 + */ +OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); + +/** + * @brief Obtain the device name in NNRT device description. + * @param desc pointer to the NNRT device description instance. + * @return NNRT device name. + * @since 10 + */ +OH_AI_API const char *OH_AI_GetNameFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); + +/** + * @brief Obtain the device type in NNRT device description. + * @param desc pointer to the NNRT device description instance. + * @return NNRT device type. + * @since 10 + */ +OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc(const NNRTDeviceDesc *desc); + +/** + * @brief Create the NNRT device info by exactly matching the specific device name. + * @param name NNRt device name. + * @return Device info object handle. + * @since 10 + */ +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName(const char *name); + +/** + * @brief Create the NNRT device info by finding the first device with the specific device type. + * @param name NNRt device type. + * @return Device info object handle. + * @since 10 + */ +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType(OH_AI_NNRTDeviceType type); + +/** + * @brief Set the NNRT device id, Only valid for NNRT. + * @param device_info Device info object handle. + * @param device_id NNRT device id. + * @since 10 + */ +OH_AI_API void OH_AI_DeviceInfoSetDeviceId(OH_AI_DeviceInfoHandle device_info, size_t device_id); + +/** + * @brief Obtain the NNRT device id, Only valid for NNRT. + * @param device_info Device info object handle. + * @return NNRT device id. + * @since 10 + */ +OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Set the NNRT performance mode, Only valid for NNRT. + * @param device_info Device info object handle. + * @param device_id NNRT performance mode. + * @since 10 + */ +OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode(OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode); + +/** + * @brief Obtain the NNRT performance mode, Only valid for NNRT. + * @param device_info Device info object handle. + * @return NNRT performance mode. + * @since 10 + */ +OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Set the NNRT priority, Only valid for NNRT. + * @param device_info Device info object handle. + * @param device_id NNRT priority. + * @since 10 + */ +OH_AI_API void OH_AI_DeviceInfoSetPriority(OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority); + +/** + * @brief Obtain the NNRT priority, Only valid for NNRT. + * @param device_info Device info object handle. + * @return NNRT priority. + * @since 10 + */ +OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority(const OH_AI_DeviceInfoHandle device_info); + +/** + * @brief Add extension of key/value format to device info, Only valid for NNRT. + * @param device_info Device info object handle. + * @param name The content of key as a C string. + * @param value The pointer to the value, which is a byte array. + * @param value_size The size of the value, which is a byte array. + * @return OH_AI_STATUS_SUCCESS if success, or detail error code if failed. + * @since 10 + */ +OH_AI_API OH_AI_Status OH_AI_DeviceInfoAddExtension(OH_AI_DeviceInfoHandle device_info, const char *name, const char *value, size_t value_size); +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_CONTEXT_C_H diff --git a/third_party/mindspore/data_type.h b/third_party/mindspore/kits/data_type.h similarity index 82% rename from third_party/mindspore/data_type.h rename to third_party/mindspore/kits/data_type.h index 124ed17b3cdeca57eafa9b1e945160bf6fefc30b..087662bf19908de8f98687c3862c1212de6f1174 100644 --- a/third_party/mindspore/data_type.h +++ b/third_party/mindspore/kits/data_type.h @@ -1,52 +1,71 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H -#define MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum OH_AI_DataType { - OH_AI_DATATYPE_UNKNOWN = 0, - OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, - OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, - OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14, - OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, - OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29, - OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30, - OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32, - OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, - OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, - OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, - OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37, - OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, - OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39, - OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, - OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42, - OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, - OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, - OH_AI_DATATYPE_NUMBERTYPE_END = 46, - // add new enum here - OH_AI_DataTypeInvalid = INT32_MAX, -} OH_AI_DataType; - -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file data_type.h + * + * @brief 声明了张量的数据的类型。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H +#define MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum OH_AI_DataType { + OH_AI_DATATYPE_UNKNOWN = 0, + OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, + OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, + OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14, + OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, + OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29, + OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30, + OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32, + OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, + OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, + OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, + OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37, + OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, + OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39, + OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, + OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42, + OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, + OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, + OH_AI_DATATYPE_NUMBERTYPE_END = 46, + // add new enum here + OH_AI_DataTypeInvalid = INT32_MAX, +} OH_AI_DataType; + +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_DATA_TYPE_C_H diff --git a/third_party/mindspore/format.h b/third_party/mindspore/kits/format.h similarity index 78% rename from third_party/mindspore/format.h rename to third_party/mindspore/kits/format.h index 36b355fe6eead8465cf82b26972196b8d93f9a72..0dad64d3e75b18906f2fb12e921847297c98d3d5 100644 --- a/third_party/mindspore/format.h +++ b/third_party/mindspore/kits/format.h @@ -1,46 +1,65 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_FORMAT_C_H -#define MINDSPORE_INCLUDE_C_API_FORMAT_C_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum OH_AI_Format { - OH_AI_FORMAT_NCHW = 0, - OH_AI_FORMAT_NHWC = 1, - OH_AI_FORMAT_NHWC4 = 2, - OH_AI_FORMAT_HWKC = 3, - OH_AI_FORMAT_HWCK = 4, - OH_AI_FORMAT_KCHW = 5, - OH_AI_FORMAT_CKHW = 6, - OH_AI_FORMAT_KHWC = 7, - OH_AI_FORMAT_CHWK = 8, - OH_AI_FORMAT_HW = 9, - OH_AI_FORMAT_HW4 = 10, - OH_AI_FORMAT_NC = 11, - OH_AI_FORMAT_NC4 = 12, - OH_AI_FORMAT_NC4HW4 = 13, - OH_AI_FORMAT_NCDHW = 15, - OH_AI_FORMAT_NWC = 16, - OH_AI_FORMAT_NCW = 17 -} OH_AI_Format; - -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_FORMAT_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file format.h + * + * @brief 提供张量数据的排列格式。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_FORMAT_C_H +#define MINDSPORE_INCLUDE_C_API_FORMAT_C_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum OH_AI_Format { + OH_AI_FORMAT_NCHW = 0, + OH_AI_FORMAT_NHWC = 1, + OH_AI_FORMAT_NHWC4 = 2, + OH_AI_FORMAT_HWKC = 3, + OH_AI_FORMAT_HWCK = 4, + OH_AI_FORMAT_KCHW = 5, + OH_AI_FORMAT_CKHW = 6, + OH_AI_FORMAT_KHWC = 7, + OH_AI_FORMAT_CHWK = 8, + OH_AI_FORMAT_HW = 9, + OH_AI_FORMAT_HW4 = 10, + OH_AI_FORMAT_NC = 11, + OH_AI_FORMAT_NC4 = 12, + OH_AI_FORMAT_NC4HW4 = 13, + OH_AI_FORMAT_NCDHW = 15, + OH_AI_FORMAT_NWC = 16, + OH_AI_FORMAT_NCW = 17 +} OH_AI_Format; + +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_FORMAT_C_H diff --git a/third_party/mindspore/kits/mindspore_lib.ndk.json b/third_party/mindspore/kits/mindspore_lib.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..b46cc4d4b2ac5eb35344f0f8152fb1c0b63e3a3f --- /dev/null +++ b/third_party/mindspore/kits/mindspore_lib.ndk.json @@ -0,0 +1,254 @@ +[ + { + "first_introduced": "9", + "name": "OH_AI_ContextCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadAffinityMode" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadAffinityMode" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadAffinityCoreList" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadAffinityCoreList" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetEnableParallel" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetEnableParallel" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextAddDeviceInfo" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetProvider" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetProvider" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetProviderDevice" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetProviderDevice" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetDeviceType" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetEnableFP16" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetEnableFP16" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetFrequency" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetFrequency" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelBuild" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelBuildFromFile" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelResize" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelPredict" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetInputs" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetOutputs" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetInputByTensorName" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetOutputByTensorName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorClone" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetDataType" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetDataType" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetShape" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetShape" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetFormat" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetFormat" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetMutableData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetElementNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetDataSize" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetAllNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_DestroyAllNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetDeviceIdFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetNameFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetTypeFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_CreateNNRTDeviceInfoByName" + }, + { + "first_introduced": "10", + "name": "OH_AI_CreateNNRTDeviceInfoByType" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetDeviceId" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoGetDeviceId" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetPerformanceMode" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoGetPerformanceMode" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetPriority" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetElementOfNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoAddExtension" + }, + { + "first_introduced": "10", + "name": "OH_AI_TensorSetUserData" + } +] diff --git a/third_party/mindspore/model.h b/third_party/mindspore/kits/model.h similarity index 91% rename from third_party/mindspore/model.h rename to third_party/mindspore/kits/model.h index 870b9be3a7c0506a14880bb2aa2c32bf9b958da4..8ae46faf479320a0a252b5614dc96c64ad23325c 100644 --- a/third_party/mindspore/model.h +++ b/third_party/mindspore/kits/model.h @@ -1,150 +1,169 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_MODEL_C_H -#define MINDSPORE_INCLUDE_C_API_MODEL_C_H - -#include "mindspore/tensor.h" -#include "mindspore/context.h" -#include "mindspore/status.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *OH_AI_ModelHandle; - -typedef struct OH_AI_TensorHandleArray { - size_t handle_num; - OH_AI_TensorHandle *handle_list; -} OH_AI_TensorHandleArray; - -#define OH_AI_MAX_SHAPE_NUM 32 -typedef struct OH_AI_ShapeInfo { - size_t shape_num; - int64_t shape[OH_AI_MAX_SHAPE_NUM]; -} OH_AI_ShapeInfo; - -typedef struct OH_AI_CallBackParam { - char *node_name; - char *node_type; -} OH_AI_CallBackParam; - -typedef bool (*OH_AI_KernelCallBack)(const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, - const OH_AI_CallBackParam kernel_Info); - -/** - * @brief Create a model object. - * @return Model object handle. - * @since 9 - */ -OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate(); - -/** - * @brief Destroy the model object. - * @param model Model object handle address. - * @since 9 - */ -OH_AI_API void OH_AI_ModelDestroy(OH_AI_ModelHandle *model); - -/** - * @brief Build the model from model file buffer so that it can run on a device. - * @param model Model object handle. - * @param model_data Define the buffer read from a model file. - * @param data_size Define bytes number of model file buffer. - * @param model_type Define The type of model file. - * @param model_context Define the context used to store options during execution. - * @return OH_AI_Status. - * @since 9 - */ -OH_AI_API OH_AI_Status OH_AI_ModelBuild(OH_AI_ModelHandle model, const void *model_data, size_t data_size, - OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); - -/** - * @brief Load and build the model from model path so that it can run on a device. - * @param model Model object handle. - * @param model_path Define the model file path. - * @param model_type Define The type of model file. - * @param model_context Define the context used to store options during execution. - * @return OH_AI_Status. - * @since 9 - */ -OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile(OH_AI_ModelHandle model, const char *model_path, - OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); - -/** - * @brief Resizes the shapes of inputs. - * @param model Model object handle. - * @param inputs The array that includes all input tensor handles. - * @param shape_infos Defines the new shapes of inputs, should be consistent with inputs. - * @param shape_info_num The num of shape_infos. - * @return OH_AI_Status. - * @since 9 - */ -OH_AI_API OH_AI_Status OH_AI_ModelResize(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, - OH_AI_ShapeInfo *shape_infos, size_t shape_info_num); - -/** - * @brief Inference model. - * @param model Model object handle. - * @param inputs The array that includes all input tensor handles. - * @param outputs The array that includes all output tensor handles. - * @param before CallBack before predict. - * @param after CallBack after predict. - * @return OH_AI_Status. - * @since 9 - */ -OH_AI_API OH_AI_Status OH_AI_ModelPredict(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, - OH_AI_TensorHandleArray *outputs, const OH_AI_KernelCallBack before, - const OH_AI_KernelCallBack after); - -/** - * @brief Obtains all input tensor handles of the model. - * @param model Model object handle. - * @return The array that includes all input tensor handles. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs(const OH_AI_ModelHandle model); - -/** - * @brief Obtains all output tensor handles of the model. - * @param model Model object handle. - * @return The array that includes all output tensor handles. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs(const OH_AI_ModelHandle model); - -/** - * @brief Obtains the input tensor handle of the model by name. - * @param model Model object handle. - * @param tensor_name The name of tensor. - * @return The input tensor handle with the given name, if the name is not found, an NULL is returned. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); - -/** - * @brief Obtains the output tensor handle of the model by name. - * @param model Model object handle. - * @param tensor_name The name of tensor. - * @return The output tensor handle with the given name, if the name is not found, an NULL is returned. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); - -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_MODEL_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file model.h + * + * @brief 提供了模型相关接口,可以用于模型创建、模型推理等。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_MODEL_C_H +#define MINDSPORE_INCLUDE_C_API_MODEL_C_H + +#include "mindspore/tensor.h" +#include "mindspore/context.h" +#include "mindspore/status.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *OH_AI_ModelHandle; + +typedef struct OH_AI_TensorHandleArray { + size_t handle_num; + OH_AI_TensorHandle *handle_list; +} OH_AI_TensorHandleArray; + +#define OH_AI_MAX_SHAPE_NUM 32 +typedef struct OH_AI_ShapeInfo { + size_t shape_num; + int64_t shape[OH_AI_MAX_SHAPE_NUM]; +} OH_AI_ShapeInfo; + +typedef struct OH_AI_CallBackParam { + char *node_name; + char *node_type; +} OH_AI_CallBackParam; + +typedef bool (*OH_AI_KernelCallBack)(const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, + const OH_AI_CallBackParam kernel_Info); + +/** + * @brief Create a model object. + * @return Model object handle. + * @since 9 + */ +OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate(); + +/** + * @brief Destroy the model object. + * @param model Model object handle address. + * @since 9 + */ +OH_AI_API void OH_AI_ModelDestroy(OH_AI_ModelHandle *model); + +/** + * @brief Build the model from model file buffer so that it can run on a device. + * @param model Model object handle. + * @param model_data Define the buffer read from a model file. + * @param data_size Define bytes number of model file buffer. + * @param model_type Define The type of model file. + * @param model_context Define the context used to store options during execution. + * @return OH_AI_Status. + * @since 9 + */ +OH_AI_API OH_AI_Status OH_AI_ModelBuild(OH_AI_ModelHandle model, const void *model_data, size_t data_size, + OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); + +/** + * @brief Load and build the model from model path so that it can run on a device. + * @param model Model object handle. + * @param model_path Define the model file path. + * @param model_type Define The type of model file. + * @param model_context Define the context used to store options during execution. + * @return OH_AI_Status. + * @since 9 + */ +OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile(OH_AI_ModelHandle model, const char *model_path, + OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context); + +/** + * @brief Resizes the shapes of inputs. + * @param model Model object handle. + * @param inputs The array that includes all input tensor handles. + * @param shape_infos Defines the new shapes of inputs, should be consistent with inputs. + * @param shape_info_num The num of shape_infos. + * @return OH_AI_Status. + * @since 9 + */ +OH_AI_API OH_AI_Status OH_AI_ModelResize(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, + OH_AI_ShapeInfo *shape_infos, size_t shape_info_num); + +/** + * @brief Inference model. + * @param model Model object handle. + * @param inputs The array that includes all input tensor handles. + * @param outputs The array that includes all output tensor handles. + * @param before CallBack before predict. + * @param after CallBack after predict. + * @return OH_AI_Status. + * @since 9 + */ +OH_AI_API OH_AI_Status OH_AI_ModelPredict(OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, + OH_AI_TensorHandleArray *outputs, const OH_AI_KernelCallBack before, + const OH_AI_KernelCallBack after); + +/** + * @brief Obtains all input tensor handles of the model. + * @param model Model object handle. + * @return The array that includes all input tensor handles. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs(const OH_AI_ModelHandle model); + +/** + * @brief Obtains all output tensor handles of the model. + * @param model Model object handle. + * @return The array that includes all output tensor handles. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs(const OH_AI_ModelHandle model); + +/** + * @brief Obtains the input tensor handle of the model by name. + * @param model Model object handle. + * @param tensor_name The name of tensor. + * @return The input tensor handle with the given name, if the name is not found, an NULL is returned. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); + +/** + * @brief Obtains the output tensor handle of the model by name. + * @param model Model object handle. + * @param tensor_name The name of tensor. + * @return The output tensor handle with the given name, if the name is not found, an NULL is returned. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName(const OH_AI_ModelHandle model, const char *tensor_name); + +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_MODEL_C_H diff --git a/third_party/mindspore/status.h b/third_party/mindspore/kits/status.h similarity index 90% rename from third_party/mindspore/status.h rename to third_party/mindspore/kits/status.h index 102c7962a11294d75580d481305d702ee003e3e3..9481c78e6df8fa9e7aa1d9c34b79c6741bc414ac 100644 --- a/third_party/mindspore/status.h +++ b/third_party/mindspore/kits/status.h @@ -1,80 +1,99 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_STATUS_C_H -#define MINDSPORE_INCLUDE_C_API_STATUS_C_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum OH_AI_CompCode { - OH_AI_COMPCODE_CORE = 0x00000000u, - OH_AI_COMPCODE_MD = 0x10000000u, - OH_AI_COMPCODE_ME = 0x20000000u, - OH_AI_COMPCODE_MC = 0x30000000u, - OH_AI_COMPCODE_LITE = 0xF0000000u, -}; - -typedef enum OH_AI_Status { - OH_AI_STATUS_SUCCESS = 0, - // Core - OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE | 0x1, - - // Lite // Common error code, range: [-1, -100) - OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -1), /**< Common error code. */ - OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -2), /**< NULL pointer returned.*/ - OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -3), /**< Invalid parameter.*/ - OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -4), /**< No change. */ - OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -5), /**< No error but exit. */ - OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -6), /**< Fail to create memory. */ - OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -7), /**< Fail to support. */ - OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -8), /**< Error occur in thread pool. */ - OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -9), /**< Object is not initialized. */ - - // Executor error code, range: [-100,-200) - OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -100), /**< Failed to check range. */ - OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR = - OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -101), /**< Failed to check input tensor. */ - OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -102), /**< Exist executor running. */ - - // Graph error code, range: [-200,-300) - OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -200), /**< Failed to verify graph file. */ - - // Node error code, range: [-300,-400) - OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -300), /**< Failed to find operator. */ - OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -301), /**< Invalid operator name. */ - OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -302), /**< Invalid operator attr. */ - OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE = - OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -303), /**< Failed to execution operator. */ - - // Tensor error code, range: [-400,-500) - OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -400), /**< Failed to checking tensor format. */ - - // InferShape error code, range: [-500,-600) - OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -500), /**< Failed to infer shape. */ - OH_AI_STATUS_LITE_INFER_INVALID = - OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -501), /**< Invalid infer shape before runtime. */ - - // User input param error code, range: [-600, 700) - OH_AI_STATUS_LITE_INPUT_PARAM_INVALID = - OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -600), /**< Invalid input param by user. */ -} OH_AI_Status; -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_STATUS_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file status.h + * + * @brief 提供了Mindspore Lite运行时的状态码。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_STATUS_C_H +#define MINDSPORE_INCLUDE_C_API_STATUS_C_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum OH_AI_CompCode { + OH_AI_COMPCODE_CORE = 0x00000000u, + OH_AI_COMPCODE_MD = 0x10000000u, + OH_AI_COMPCODE_ME = 0x20000000u, + OH_AI_COMPCODE_MC = 0x30000000u, + OH_AI_COMPCODE_LITE = 0xF0000000u, +}; + +typedef enum OH_AI_Status { + OH_AI_STATUS_SUCCESS = 0, + // Core + OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE | 0x1, + + // Lite // Common error code, range: [-1, -100) + OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -1), /**< Common error code. */ + OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -2), /**< NULL pointer returned.*/ + OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -3), /**< Invalid parameter.*/ + OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -4), /**< No change. */ + OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -5), /**< No error but exit. */ + OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -6), /**< Fail to create memory. */ + OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -7), /**< Fail to support. */ + OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -8), /**< Error occur in thread pool. */ + OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -9), /**< Object is not initialized. */ + + // Executor error code, range: [-100,-200) + OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -100), /**< Failed to check range. */ + OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR = + OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -101), /**< Failed to check input tensor. */ + OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -102), /**< Exist executor running. */ + + // Graph error code, range: [-200,-300) + OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -200), /**< Failed to verify graph file. */ + + // Node error code, range: [-300,-400) + OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -300), /**< Failed to find operator. */ + OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -301), /**< Invalid operator name. */ + OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -302), /**< Invalid operator attr. */ + OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE = + OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -303), /**< Failed to execution operator. */ + + // Tensor error code, range: [-400,-500) + OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -400), /**< Failed to checking tensor format. */ + + // InferShape error code, range: [-500,-600) + OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -500), /**< Failed to infer shape. */ + OH_AI_STATUS_LITE_INFER_INVALID = + OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -501), /**< Invalid infer shape before runtime. */ + + // User input param error code, range: [-600, 700) + OH_AI_STATUS_LITE_INPUT_PARAM_INVALID = + OH_AI_COMPCODE_LITE | (0x0FFFFFFF & -600), /**< Invalid input param by user. */ +} OH_AI_Status; +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_STATUS_C_H diff --git a/third_party/mindspore/tensor.h b/third_party/mindspore/kits/tensor.h similarity index 91% rename from third_party/mindspore/tensor.h rename to third_party/mindspore/kits/tensor.h index ab936299f53cf3238ffbbe3b819ed26a466179fe..b0ff5fea1d54ab7f1df4032f7bdfcafc3af18535 100644 --- a/third_party/mindspore/tensor.h +++ b/third_party/mindspore/kits/tensor.h @@ -1,185 +1,204 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_TENSOE_C_H -#define MINDSPORE_INCLUDE_C_API_TENSOE_C_H - -#include -#include "mindspore/status.h" -#include "mindspore/types.h" -#include "mindspore/data_type.h" -#include "mindspore/format.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *OH_AI_TensorHandle; - -/** - * @brief Create a tensor object. - * @param name The name of the tensor. - * @param type The data type of the tensor. - * @param shape The shape of the tensor. - * @param shape_num The num of the shape. - * @param data The data pointer that points to allocated memory. - * @param data_len The length of the memory, in bytes. - * @return Tensor object handle. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate(const char *name, OH_AI_DataType type, const int64_t *shape, - size_t shape_num, const void *data, size_t data_len); - -/** - * @brief Destroy the tensor object. - * @param tensor Tensor object handle address. - * @since 9 - */ -OH_AI_API void OH_AI_TensorDestroy(OH_AI_TensorHandle *tensor); - -/** - * @brief Obtain a deep copy of the tensor. - * @param tensor Tensor object handle. - * @return Tensor object handle. - * @since 9 - */ -OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone(OH_AI_TensorHandle tensor); - -/** - * @brief Set the name for the tensor. - * @param tensor Tensor object handle. - * @param name The name of the tensor. - * @since 9 - */ -OH_AI_API void OH_AI_TensorSetName(OH_AI_TensorHandle tensor, const char *name); - -/** - * @brief Obtain the name of the tensor. - * @param tensor Tensor object handle. - * @return The name of the tensor. - * @since 9 - */ -OH_AI_API const char *OH_AI_TensorGetName(const OH_AI_TensorHandle tensor); - -/** - * @brief Set the data type for the tensor. - * @param tensor Tensor object handle. - * @param type The data type of the tensor. - * @since 9 - */ -OH_AI_API void OH_AI_TensorSetDataType(OH_AI_TensorHandle tensor, OH_AI_DataType type); - -/** - * @brief Obtain the data type of the tensor. - * @param tensor Tensor object handle. - * @return The date type of the tensor. - * @since 9 - */ -OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType(const OH_AI_TensorHandle tensor); - -/** - * @brief Set the shape for the tensor. - * @param tensor Tensor object handle. - * @param shape The shape array. - * @param shape_num Dimension of shape. - * @since 9 - */ -OH_AI_API void OH_AI_TensorSetShape(OH_AI_TensorHandle tensor, const int64_t *shape, size_t shape_num); - -/** - * @brief Obtain the shape of the tensor. - * @param tensor Tensor object handle. - * @param shape_num Dimension of shape. - * @return The shape array of the tensor. - * @since 9 - */ -OH_AI_API const int64_t *OH_AI_TensorGetShape(const OH_AI_TensorHandle tensor, size_t *shape_num); - -/** - * @brief Set the format for the tensor. - * @param tensor Tensor object handle. - * @param format The format of the tensor. - * @since 9 - */ -OH_AI_API void OH_AI_TensorSetFormat(OH_AI_TensorHandle tensor, OH_AI_Format format); - -/** - * @brief Obtain the format of the tensor. - * @param tensor Tensor object handle. - * @return The format of the tensor. - * @since 9 - */ -OH_AI_API OH_AI_Format OH_AI_TensorGetFormat(const OH_AI_TensorHandle tensor); - -/** - * @brief Obtain the data for the tensor. - * @param tensor Tensor object handle. - * @param data A pointer to the data of the tensor. - * @since 9 - */ -OH_AI_API void OH_AI_TensorSetData(OH_AI_TensorHandle tensor, void *data); - -/** - * @brief Obtain the data pointer of the tensor. - * @param tensor Tensor object handle. - * @return The data pointer of the tensor. - * @since 9 - */ -OH_AI_API const void *OH_AI_TensorGetData(const OH_AI_TensorHandle tensor); - -/** - * @brief Obtain the mutable data pointer of the tensor. If the internal data is empty, it will allocate memory. - * @param tensor Tensor object handle. - * @return The data pointer of the tensor. - * @since 9 - */ -OH_AI_API void *OH_AI_TensorGetMutableData(const OH_AI_TensorHandle tensor); - -/** - * @brief Obtain the element number of the tensor. - * @param tensor Tensor object handle. - * @return The element number of the tensor. - * @since 9 - */ -OH_AI_API int64_t OH_AI_TensorGetElementNum(const OH_AI_TensorHandle tensor); - -/** - * @brief Obtain the data size fo the tensor. - * @param tensor Tensor object handle. - * @return The data size of the tensor. - * @since 9 - */ -OH_AI_API size_t OH_AI_TensorGetDataSize(const OH_AI_TensorHandle tensor); - -/** - * @brief Set the data for the tensor with user-allocated data buffer. - * - * The main purpose of this interface is providing a way of using memory already allocated by user as the Model's - * input, but not which allocated inside the Model object. It can reduce one copy. \n - * Note: The tensor won't free the data provided by invoker. Invoker has the responsibility to free it. And this - * free action should not be preformed before destruction of the tensor. \n - * - * @param tensor Tensor object handle. - * @param data A pointer to the user data buffer. - * @param data the byte size of the user data buffer. - * @return OH_AI_STATUS_SUCCESS if success, or detail error code if failed. - * @since 10 - */ -OH_AI_API OH_AI_Status OH_AI_TensorSetUserData(OH_AI_TensorHandle tensor, void *data, size_t data_size); - -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_TENSOE_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file tensor.h + * + * @brief 提供了张量相关的接口,可用于创建和修改张量信息。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_TENSOE_C_H +#define MINDSPORE_INCLUDE_C_API_TENSOE_C_H + +#include +#include "mindspore/status.h" +#include "mindspore/types.h" +#include "mindspore/data_type.h" +#include "mindspore/format.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *OH_AI_TensorHandle; + +/** + * @brief Create a tensor object. + * @param name The name of the tensor. + * @param type The data type of the tensor. + * @param shape The shape of the tensor. + * @param shape_num The num of the shape. + * @param data The data pointer that points to allocated memory. + * @param data_len The length of the memory, in bytes. + * @return Tensor object handle. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate(const char *name, OH_AI_DataType type, const int64_t *shape, + size_t shape_num, const void *data, size_t data_len); + +/** + * @brief Destroy the tensor object. + * @param tensor Tensor object handle address. + * @since 9 + */ +OH_AI_API void OH_AI_TensorDestroy(OH_AI_TensorHandle *tensor); + +/** + * @brief Obtain a deep copy of the tensor. + * @param tensor Tensor object handle. + * @return Tensor object handle. + * @since 9 + */ +OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone(OH_AI_TensorHandle tensor); + +/** + * @brief Set the name for the tensor. + * @param tensor Tensor object handle. + * @param name The name of the tensor. + * @since 9 + */ +OH_AI_API void OH_AI_TensorSetName(OH_AI_TensorHandle tensor, const char *name); + +/** + * @brief Obtain the name of the tensor. + * @param tensor Tensor object handle. + * @return The name of the tensor. + * @since 9 + */ +OH_AI_API const char *OH_AI_TensorGetName(const OH_AI_TensorHandle tensor); + +/** + * @brief Set the data type for the tensor. + * @param tensor Tensor object handle. + * @param type The data type of the tensor. + * @since 9 + */ +OH_AI_API void OH_AI_TensorSetDataType(OH_AI_TensorHandle tensor, OH_AI_DataType type); + +/** + * @brief Obtain the data type of the tensor. + * @param tensor Tensor object handle. + * @return The date type of the tensor. + * @since 9 + */ +OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType(const OH_AI_TensorHandle tensor); + +/** + * @brief Set the shape for the tensor. + * @param tensor Tensor object handle. + * @param shape The shape array. + * @param shape_num Dimension of shape. + * @since 9 + */ +OH_AI_API void OH_AI_TensorSetShape(OH_AI_TensorHandle tensor, const int64_t *shape, size_t shape_num); + +/** + * @brief Obtain the shape of the tensor. + * @param tensor Tensor object handle. + * @param shape_num Dimension of shape. + * @return The shape array of the tensor. + * @since 9 + */ +OH_AI_API const int64_t *OH_AI_TensorGetShape(const OH_AI_TensorHandle tensor, size_t *shape_num); + +/** + * @brief Set the format for the tensor. + * @param tensor Tensor object handle. + * @param format The format of the tensor. + * @since 9 + */ +OH_AI_API void OH_AI_TensorSetFormat(OH_AI_TensorHandle tensor, OH_AI_Format format); + +/** + * @brief Obtain the format of the tensor. + * @param tensor Tensor object handle. + * @return The format of the tensor. + * @since 9 + */ +OH_AI_API OH_AI_Format OH_AI_TensorGetFormat(const OH_AI_TensorHandle tensor); + +/** + * @brief Obtain the data for the tensor. + * @param tensor Tensor object handle. + * @param data A pointer to the data of the tensor. + * @since 9 + */ +OH_AI_API void OH_AI_TensorSetData(OH_AI_TensorHandle tensor, void *data); + +/** + * @brief Obtain the data pointer of the tensor. + * @param tensor Tensor object handle. + * @return The data pointer of the tensor. + * @since 9 + */ +OH_AI_API const void *OH_AI_TensorGetData(const OH_AI_TensorHandle tensor); + +/** + * @brief Obtain the mutable data pointer of the tensor. If the internal data is empty, it will allocate memory. + * @param tensor Tensor object handle. + * @return The data pointer of the tensor. + * @since 9 + */ +OH_AI_API void *OH_AI_TensorGetMutableData(const OH_AI_TensorHandle tensor); + +/** + * @brief Obtain the element number of the tensor. + * @param tensor Tensor object handle. + * @return The element number of the tensor. + * @since 9 + */ +OH_AI_API int64_t OH_AI_TensorGetElementNum(const OH_AI_TensorHandle tensor); + +/** + * @brief Obtain the data size fo the tensor. + * @param tensor Tensor object handle. + * @return The data size of the tensor. + * @since 9 + */ +OH_AI_API size_t OH_AI_TensorGetDataSize(const OH_AI_TensorHandle tensor); + +/** + * @brief Set the data for the tensor with user-allocated data buffer. + * + * The main purpose of this interface is providing a way of using memory already allocated by user as the Model's + * input, but not which allocated inside the Model object. It can reduce one copy. \n + * Note: The tensor won't free the data provided by invoker. Invoker has the responsibility to free it. And this + * free action should not be preformed before destruction of the tensor. \n + * + * @param tensor Tensor object handle. + * @param data A pointer to the user data buffer. + * @param data the byte size of the user data buffer. + * @return OH_AI_STATUS_SUCCESS if success, or detail error code if failed. + * @since 10 + */ +OH_AI_API OH_AI_Status OH_AI_TensorSetUserData(OH_AI_TensorHandle tensor, void *data, size_t data_size); + +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_TENSOE_C_H diff --git a/third_party/mindspore/types.h b/third_party/mindspore/kits/types.h similarity index 84% rename from third_party/mindspore/types.h rename to third_party/mindspore/kits/types.h index d38660b0dac183a4aed6771085d094c27a221953..715ae02ce0e6130f5c788965c777eb774cbf2823 100644 --- a/third_party/mindspore/types.h +++ b/third_party/mindspore/kits/types.h @@ -1,86 +1,105 @@ -/** - * Copyright 2021 Huawei Technologies 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 MINDSPORE_INCLUDE_C_API_TYPES_C_H -#define MINDSPORE_INCLUDE_C_API_TYPES_C_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef OH_AI_API -#ifdef _WIN32 -#define OH_AI_API __declspec(dllexport) -#else -#define OH_AI_API __attribute__((visibility("default"))) -#endif -#endif - -typedef enum OH_AI_ModelType { - OH_AI_MODELTYPE_MINDIR = 0, - // insert new data type here - OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF -} OH_AI_ModelType; - -typedef enum OH_AI_DeviceType { - OH_AI_DEVICETYPE_CPU = 0, - OH_AI_DEVICETYPE_GPU, - OH_AI_DEVICETYPE_KIRIN_NPU, - // add new type here - // ohos-only device range: [60, 80) - OH_AI_DEVICETYPE_NNRT = 60, - OH_AI_DEVICETYPE_INVALID = 100, -} OH_AI_DeviceType; - -typedef enum OH_AI_NNRTDeviceType { - /** Devices that are not CPU, GPU, or dedicated accelerator */ - OH_AI_NNRTDEVICE_OTHERS = 0, - /** CPU device */ - OH_AI_NNRTDEVICE_CPU = 1, - /** GPU device */ - OH_AI_NNRTDEVICE_GPU = 2, - /** Dedicated hardware accelerator */ - OH_AI_NNRTDEVICE_ACCELERATOR = 3, -} OH_AI_NNRTDeviceType; - -typedef enum OH_AI_PerformanceMode { - /** No performance mode preference */ - OH_AI_PERFORMANCE_NONE = 0, - /** Low power consumption mode*/ - OH_AI_PERFORMANCE_LOW = 1, - /** Medium performance mode */ - OH_AI_PERFORMANCE_MEDIUM = 2, - /** High performance mode */ - OH_AI_PERFORMANCE_HIGH = 3, - /** Ultimate performance mode */ - OH_AI_PERFORMANCE_EXTREME = 4 -} OH_AI_PerformanceMode; - -typedef enum OH_AI_Priority { - /** No priority preference */ - OH_AI_PRIORITY_NONE = 0, - /** Low priority */ - OH_AI_PRIORITY_LOW = 1, - /** Medium priority */ - OH_AI_PRIORITY_MEDIUM = 2, - /** High priority */ - OH_AI_PRIORITY_HIGH = 3 -} OH_AI_Priority; - -typedef struct NNRTDeviceDesc NNRTDeviceDesc; -#ifdef __cplusplus -} -#endif -#endif // MINDSPORE_INCLUDE_C_API_TYPES_C_H +/** + * Copyright 2021 Huawei Technologies 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 MindSpore + * @{ + * + * @brief 提供MindSpore Lite的模型推理相关接口。 + * + * @Syscap SystemCapability.Ai.MindSpore + * @since 9 + */ + +/** + * @file types.h + * + * @brief 提供了MindSpore Lite支持的模型文件类型和设备类型。 + * + * @library libmindspore_lite_ndk.so + * @since 9 + */ +#ifndef MINDSPORE_INCLUDE_C_API_TYPES_C_H +#define MINDSPORE_INCLUDE_C_API_TYPES_C_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef OH_AI_API +#ifdef _WIN32 +#define OH_AI_API __declspec(dllexport) +#else +#define OH_AI_API __attribute__((visibility("default"))) +#endif +#endif + +typedef enum OH_AI_ModelType { + OH_AI_MODELTYPE_MINDIR = 0, + // insert new data type here + OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF +} OH_AI_ModelType; + +typedef enum OH_AI_DeviceType { + OH_AI_DEVICETYPE_CPU = 0, + OH_AI_DEVICETYPE_GPU, + OH_AI_DEVICETYPE_KIRIN_NPU, + // add new type here + // ohos-only device range: [60, 80) + OH_AI_DEVICETYPE_NNRT = 60, + OH_AI_DEVICETYPE_INVALID = 100, +} OH_AI_DeviceType; + +typedef enum OH_AI_NNRTDeviceType { + /** Devices that are not CPU, GPU, or dedicated accelerator */ + OH_AI_NNRTDEVICE_OTHERS = 0, + /** CPU device */ + OH_AI_NNRTDEVICE_CPU = 1, + /** GPU device */ + OH_AI_NNRTDEVICE_GPU = 2, + /** Dedicated hardware accelerator */ + OH_AI_NNRTDEVICE_ACCELERATOR = 3, +} OH_AI_NNRTDeviceType; + +typedef enum OH_AI_PerformanceMode { + /** No performance mode preference */ + OH_AI_PERFORMANCE_NONE = 0, + /** Low power consumption mode*/ + OH_AI_PERFORMANCE_LOW = 1, + /** Medium performance mode */ + OH_AI_PERFORMANCE_MEDIUM = 2, + /** High performance mode */ + OH_AI_PERFORMANCE_HIGH = 3, + /** Ultimate performance mode */ + OH_AI_PERFORMANCE_EXTREME = 4 +} OH_AI_PerformanceMode; + +typedef enum OH_AI_Priority { + /** No priority preference */ + OH_AI_PRIORITY_NONE = 0, + /** Low priority */ + OH_AI_PRIORITY_LOW = 1, + /** Medium priority */ + OH_AI_PRIORITY_MEDIUM = 2, + /** High priority */ + OH_AI_PRIORITY_HIGH = 3 +} OH_AI_Priority; + +typedef struct NNRTDeviceDesc NNRTDeviceDesc; +#ifdef __cplusplus +} +#endif +#endif // MINDSPORE_INCLUDE_C_API_TYPES_C_H diff --git a/third_party/mindspore/mindspore_lib.ndk.json b/third_party/mindspore/mindspore_lib.ndk.json index c4c8193e90024f1b9c0ea022e42ac90205dc7685..b46cc4d4b2ac5eb35344f0f8152fb1c0b63e3a3f 100644 --- a/third_party/mindspore/mindspore_lib.ndk.json +++ b/third_party/mindspore/mindspore_lib.ndk.json @@ -1,254 +1,254 @@ -[ - { - "first_introduced": "9", - "name": "OH_AI_ContextCreate" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextDestroy" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextSetThreadNum" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextGetThreadNum" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextSetThreadAffinityMode" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextGetThreadAffinityMode" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextSetThreadAffinityCoreList" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextGetThreadAffinityCoreList" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextSetEnableParallel" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextGetEnableParallel" - }, - { - "first_introduced": "9", - "name": "OH_AI_ContextAddDeviceInfo" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoCreate" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoDestroy" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoSetProvider" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoGetProvider" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoSetProviderDevice" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoGetProviderDevice" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoGetDeviceType" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoSetEnableFP16" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoGetEnableFP16" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoSetFrequency" - }, - { - "first_introduced": "9", - "name": "OH_AI_DeviceInfoGetFrequency" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelCreate" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelDestroy" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelBuild" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelBuildFromFile" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelResize" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelPredict" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelGetInputs" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelGetOutputs" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelGetInputByTensorName" - }, - { - "first_introduced": "9", - "name": "OH_AI_ModelGetOutputByTensorName" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorCreate" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorDestroy" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorClone" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorSetName" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetName" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorSetDataType" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetDataType" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorSetShape" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetShape" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorSetFormat" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetFormat" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorSetData" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetData" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetMutableData" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetElementNum" - }, - { - "first_introduced": "9", - "name": "OH_AI_TensorGetDataSize" - }, - { - "first_introduced": "10", - "name": "OH_AI_GetAllNNRTDeviceDescs" - }, - { - "first_introduced": "10", - "name": "OH_AI_DestroyAllNNRTDeviceDescs" - }, - { - "first_introduced": "10", - "name": "OH_AI_GetDeviceIdFromNNRTDeviceDesc" - }, - { - "first_introduced": "10", - "name": "OH_AI_GetNameFromNNRTDeviceDesc" - }, - { - "first_introduced": "10", - "name": "OH_AI_GetTypeFromNNRTDeviceDesc" - }, - { - "first_introduced": "10", - "name": "OH_AI_CreateNNRTDeviceInfoByName" - }, - { - "first_introduced": "10", - "name": "OH_AI_CreateNNRTDeviceInfoByType" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoSetDeviceId" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoGetDeviceId" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoSetPerformanceMode" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoGetPerformanceMode" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoSetPriority" - }, - { - "first_introduced": "10", - "name": "OH_AI_GetElementOfNNRTDeviceDescs" - }, - { - "first_introduced": "10", - "name": "OH_AI_DeviceInfoAddExtension" - }, - { - "first_introduced": "10", - "name": "OH_AI_TensorSetUserData" - } -] +[ + { + "first_introduced": "9", + "name": "OH_AI_ContextCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadAffinityMode" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadAffinityMode" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetThreadAffinityCoreList" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetThreadAffinityCoreList" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextSetEnableParallel" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextGetEnableParallel" + }, + { + "first_introduced": "9", + "name": "OH_AI_ContextAddDeviceInfo" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetProvider" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetProvider" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetProviderDevice" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetProviderDevice" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetDeviceType" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetEnableFP16" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetEnableFP16" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoSetFrequency" + }, + { + "first_introduced": "9", + "name": "OH_AI_DeviceInfoGetFrequency" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelBuild" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelBuildFromFile" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelResize" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelPredict" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetInputs" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetOutputs" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetInputByTensorName" + }, + { + "first_introduced": "9", + "name": "OH_AI_ModelGetOutputByTensorName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorCreate" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorDestroy" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorClone" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetName" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetDataType" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetDataType" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetShape" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetShape" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetFormat" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetFormat" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorSetData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetMutableData" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetElementNum" + }, + { + "first_introduced": "9", + "name": "OH_AI_TensorGetDataSize" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetAllNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_DestroyAllNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetDeviceIdFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetNameFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetTypeFromNNRTDeviceDesc" + }, + { + "first_introduced": "10", + "name": "OH_AI_CreateNNRTDeviceInfoByName" + }, + { + "first_introduced": "10", + "name": "OH_AI_CreateNNRTDeviceInfoByType" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetDeviceId" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoGetDeviceId" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetPerformanceMode" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoGetPerformanceMode" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoSetPriority" + }, + { + "first_introduced": "10", + "name": "OH_AI_GetElementOfNNRTDeviceDescs" + }, + { + "first_introduced": "10", + "name": "OH_AI_DeviceInfoAddExtension" + }, + { + "first_introduced": "10", + "name": "OH_AI_TensorSetUserData" + } +] diff --git a/third_party/musl/ndk_musl_include/aio.h b/third_party/musl/ndk_musl_include/aio.h index 0368ada8ac284cce688ebcee5ee046026b2ced5c..eb89d91698b859db92944f6aa94f4d694f6e95bb 100644 --- a/third_party/musl/ndk_musl_include/aio.h +++ b/third_party/musl/ndk_musl_include/aio.h @@ -44,10 +44,6 @@ struct aiocb { #define off64_t off_t #endif -#if _REDIR_TIME64 -__REDIR(aio_suspend, __aio_suspend_time64); -#endif - #ifdef __cplusplus } #endif diff --git a/third_party/musl/ndk_musl_include/langinfo.h b/third_party/musl/ndk_musl_include/langinfo.h index 1246117381a8c334568785bd57bc99c0643c8952..7c93f17c7f0fef63c6c444913205423f81952519 100644 --- a/third_party/musl/ndk_musl_include/langinfo.h +++ b/third_party/musl/ndk_musl_include/langinfo.h @@ -1,18 +1,3 @@ -/** - * Copyright (c) 2022 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 _LANGINFO_H #define _LANGINFO_H diff --git a/third_party/musl/ndk_musl_include/malloc.h b/third_party/musl/ndk_musl_include/malloc.h index 86cd9501f2c8715eae3b756f34b6740bbc3ed3c2..4817d5a5ebf8ad655c947b290d2771779043beb0 100644 --- a/third_party/musl/ndk_musl_include/malloc.h +++ b/third_party/musl/ndk_musl_include/malloc.h @@ -9,16 +9,22 @@ extern "C" { #include -#define M_SET_THREAD_CACHE -1001 +#define M_SET_THREAD_CACHE (-1001) #define M_THREAD_CACHE_ENABLE 1 #define M_THREAD_CACHE_DISABLE 0 -#define M_FLUSH_THREAD_CACHE -1002 +#define M_FLUSH_THREAD_CACHE (-1002) -#define M_DELAYED_FREE -1003 +#define M_DELAYED_FREE (-1003) #define M_DELAYED_FREE_ENABLE 1 #define M_DELAYED_FREE_DISABLE 0 +#define M_OHOS_CONFIG (-1004) +#define M_DISABLE_OPT_TCACHE 100 +#define M_ENABLE_OPT_TCACHE 101 +#define M_TCACHE_PERFORMANCE_MODE 102 +#define M_TCACHE_NORMAL_MODE 103 + void *malloc (size_t); void *calloc (size_t, size_t); void *realloc (void *, size_t); diff --git a/third_party/musl/ndk_musl_include/mqueue.h b/third_party/musl/ndk_musl_include/mqueue.h index 4616f0763d93116a3ebc4bd3c1a9d7bc4ccde730..59c8de63a8df769963460ed5f3a99cfa0afa7c9b 100644 --- a/third_party/musl/ndk_musl_include/mqueue.h +++ b/third_party/musl/ndk_musl_include/mqueue.h @@ -19,11 +19,6 @@ struct mq_attr { }; struct sigevent; -#if _REDIR_TIME64 -__REDIR(mq_timedreceive, __mq_timedreceive_time64); -__REDIR(mq_timedsend, __mq_timedsend_time64); -#endif - #ifdef __cplusplus } #endif diff --git a/third_party/musl/ndk_musl_include/pthread.h b/third_party/musl/ndk_musl_include/pthread.h index 33e6a3edaefda5b2faef01a0c29834f256bf5b6b..4567237558006ea2324af35debad1402813977ea 100644 --- a/third_party/musl/ndk_musl_include/pthread.h +++ b/third_party/musl/ndk_musl_include/pthread.h @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2022 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 _PTHREAD_H #define _PTHREAD_H #ifdef __cplusplus diff --git a/third_party/musl/ndk_musl_include/sys/reboot.h b/third_party/musl/ndk_musl_include/sys/reboot.h index 3f4b7ceca1a22b5107cdc10f866a2abd740b4544..88bb1a9c194f6e831b7448a07552b42127c244e3 100644 --- a/third_party/musl/ndk_musl_include/sys/reboot.h +++ b/third_party/musl/ndk_musl_include/sys/reboot.h @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2022 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 _SYS_REBOOT_H #define _SYS_REBOOT_H #ifdef __cplusplus diff --git a/third_party/musl/ndk_script/copy_musl_sysroot.sh b/third_party/musl/ndk_script/copy_musl_sysroot.sh old mode 100755 new mode 100644 diff --git a/third_party/musl/ndk_script/copy_ndk_musl_headers.sh b/third_party/musl/ndk_script/copy_ndk_musl_headers.sh old mode 100755 new mode 100644 diff --git a/third_party/musl/ndk_script/toolchain.sh b/third_party/musl/ndk_script/toolchain.sh old mode 100755 new mode 100644 diff --git a/third_party/node/BUILD.gn b/third_party/node/BUILD.gn index 254f38555d0f37183f6a5736d43a277d625376fc..d91c9f9f54f96ed14619b99fe81e51eacf9857bb 100644 --- a/third_party/node/BUILD.gn +++ b/third_party/node/BUILD.gn @@ -1,24 +1,24 @@ -# Copyright (c) 2022 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") - -ohos_ndk_headers("node_header") { - dest_dir = "$ndk_headers_out_dir" - sources = [ - "//third_party/node/src/js_native_api.h", - "//third_party/node/src/js_native_api_types.h", - "//third_party/node/src/node_api.h", - "//third_party/node/src/node_api_types.h", - ] -} +# Copyright (c) 2022 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") + +ohos_ndk_headers("node_header") { + dest_dir = "$ndk_headers_out_dir" + sources = [ + "//third_party/node/src/js_native_api.h", + "//third_party/node/src/js_native_api_types.h", + "//third_party/node/src/node_api.h", + "//third_party/node/src/node_api_types.h", + ] +} diff --git a/third_party/node/src/js_native_api.h b/third_party/node/src/js_native_api.h index e804d1d45d236519d248e3d40fa0a6c2a6d378ec..47e1c40d1da80ae4189626cdce8ccb1c1df23519 100644 --- a/third_party/node/src/js_native_api.h +++ b/third_party/node/src/js_native_api.h @@ -1,561 +1,561 @@ -#ifndef SRC_JS_NATIVE_API_H_ -#define SRC_JS_NATIVE_API_H_ - -// This file needs to be compatible with C compilers. -#include // NOLINT(modernize-deprecated-headers) -#include // NOLINT(modernize-deprecated-headers) - -// Use INT_MAX, this should only be consumed by the pre-processor anyway. -#define NAPI_VERSION_EXPERIMENTAL 2147483647 -#ifndef NAPI_VERSION -#ifdef NAPI_EXPERIMENTAL -#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL -#else -// The baseline version for N-API. -// The NAPI_VERSION controls which version will be used by default when -// compilling a native addon. If the addon developer specifically wants to use -// functions available in a new version of N-API that is not yet ported in all -// LTS versions, they can set NAPI_VERSION knowing that they have specifically -// depended on that version. -#define NAPI_VERSION 8 -#endif -#endif - -#include "js_native_api_types.h" - -// If you need __declspec(dllimport), either include instead, or -// define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line. -#ifndef NAPI_EXTERN - #ifdef _WIN32 - #define NAPI_EXTERN __declspec(dllexport) - #elif defined(__wasm32__) - #define NAPI_EXTERN __attribute__((visibility("default"))) \ - __attribute__((__import_module__("napi"))) - #else - #define NAPI_EXTERN __attribute__((visibility("default"))) - #endif -#endif - -#define NAPI_AUTO_LENGTH SIZE_MAX - -#ifdef __cplusplus -#define EXTERN_C_START extern "C" { -#define EXTERN_C_END } -#else -#define EXTERN_C_START -#define EXTERN_C_END -#endif - -EXTERN_C_START - -NAPI_EXTERN napi_status -napi_get_last_error_info(napi_env env, - const napi_extended_error_info** result); - -// Getters for defined singletons -NAPI_EXTERN napi_status napi_get_undefined(napi_env env, napi_value* result); -NAPI_EXTERN napi_status napi_get_null(napi_env env, napi_value* result); -NAPI_EXTERN napi_status napi_get_global(napi_env env, napi_value* result); -NAPI_EXTERN napi_status napi_get_boolean(napi_env env, - bool value, - napi_value* result); - -// Methods to create Primitive types/Objects -NAPI_EXTERN napi_status napi_create_object(napi_env env, napi_value* result); -NAPI_EXTERN napi_status napi_create_array(napi_env env, napi_value* result); -NAPI_EXTERN napi_status napi_create_array_with_length(napi_env env, - size_t length, - napi_value* result); -NAPI_EXTERN napi_status napi_create_double(napi_env env, - double value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_int32(napi_env env, - int32_t value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_uint32(napi_env env, - uint32_t value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_int64(napi_env env, - int64_t value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env, - const char* str, - size_t length, - napi_value* result); -NAPI_EXTERN napi_status napi_create_string_utf8(napi_env env, - const char* str, - size_t length, - napi_value* result); -NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env, - const char16_t* str, - size_t length, - napi_value* result); -NAPI_EXTERN napi_status napi_create_symbol(napi_env env, - napi_value description, - napi_value* result); -NAPI_EXTERN napi_status napi_create_function(napi_env env, - const char* utf8name, - size_t length, - napi_callback cb, - void* data, - napi_value* result); -NAPI_EXTERN napi_status napi_create_error(napi_env env, - napi_value code, - napi_value msg, - napi_value* result); -NAPI_EXTERN napi_status napi_create_type_error(napi_env env, - napi_value code, - napi_value msg, - napi_value* result); -NAPI_EXTERN napi_status napi_create_range_error(napi_env env, - napi_value code, - napi_value msg, - napi_value* result); - -// Methods to get the native napi_value from Primitive type -NAPI_EXTERN napi_status napi_typeof(napi_env env, - napi_value value, - napi_valuetype* result); -NAPI_EXTERN napi_status napi_get_value_double(napi_env env, - napi_value value, - double* result); -NAPI_EXTERN napi_status napi_get_value_int32(napi_env env, - napi_value value, - int32_t* result); -NAPI_EXTERN napi_status napi_get_value_uint32(napi_env env, - napi_value value, - uint32_t* result); -NAPI_EXTERN napi_status napi_get_value_int64(napi_env env, - napi_value value, - int64_t* result); -NAPI_EXTERN napi_status napi_get_value_bool(napi_env env, - napi_value value, - bool* result); - -// Copies LATIN-1 encoded bytes from a string into a buffer. -NAPI_EXTERN napi_status napi_get_value_string_latin1(napi_env env, - napi_value value, - char* buf, - size_t bufsize, - size_t* result); - -// Copies UTF-8 encoded bytes from a string into a buffer. -NAPI_EXTERN napi_status napi_get_value_string_utf8(napi_env env, - napi_value value, - char* buf, - size_t bufsize, - size_t* result); - -// Copies UTF-16 encoded bytes from a string into a buffer. -NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env, - napi_value value, - char16_t* buf, - size_t bufsize, - size_t* result); - -// Methods to coerce values -// These APIs may execute user scripts -NAPI_EXTERN napi_status napi_coerce_to_bool(napi_env env, - napi_value value, - napi_value* result); -NAPI_EXTERN napi_status napi_coerce_to_number(napi_env env, - napi_value value, - napi_value* result); -NAPI_EXTERN napi_status napi_coerce_to_object(napi_env env, - napi_value value, - napi_value* result); -NAPI_EXTERN napi_status napi_coerce_to_string(napi_env env, - napi_value value, - napi_value* result); - -// Methods to work with Objects -NAPI_EXTERN napi_status napi_get_prototype(napi_env env, - napi_value object, - napi_value* result); -NAPI_EXTERN napi_status napi_get_property_names(napi_env env, - napi_value object, - napi_value* result); -NAPI_EXTERN napi_status napi_set_property(napi_env env, - napi_value object, - napi_value key, - napi_value value); -NAPI_EXTERN napi_status napi_has_property(napi_env env, - napi_value object, - napi_value key, - bool* result); -NAPI_EXTERN napi_status napi_get_property(napi_env env, - napi_value object, - napi_value key, - napi_value* result); -NAPI_EXTERN napi_status napi_delete_property(napi_env env, - napi_value object, - napi_value key, - bool* result); -NAPI_EXTERN napi_status napi_has_own_property(napi_env env, - napi_value object, - napi_value key, - bool* result); -NAPI_EXTERN napi_status napi_set_named_property(napi_env env, - napi_value object, - const char* utf8name, - napi_value value); -NAPI_EXTERN napi_status napi_has_named_property(napi_env env, - napi_value object, - const char* utf8name, - bool* result); -NAPI_EXTERN napi_status napi_get_named_property(napi_env env, - napi_value object, - const char* utf8name, - napi_value* result); -NAPI_EXTERN napi_status napi_set_element(napi_env env, - napi_value object, - uint32_t index, - napi_value value); -NAPI_EXTERN napi_status napi_has_element(napi_env env, - napi_value object, - uint32_t index, - bool* result); -NAPI_EXTERN napi_status napi_get_element(napi_env env, - napi_value object, - uint32_t index, - napi_value* result); -NAPI_EXTERN napi_status napi_delete_element(napi_env env, - napi_value object, - uint32_t index, - bool* result); -NAPI_EXTERN napi_status -napi_define_properties(napi_env env, - napi_value object, - size_t property_count, - const napi_property_descriptor* properties); - -// Methods to work with Arrays -NAPI_EXTERN napi_status napi_is_array(napi_env env, - napi_value value, - bool* result); -NAPI_EXTERN napi_status napi_get_array_length(napi_env env, - napi_value value, - uint32_t* result); - -// Methods to compare values -NAPI_EXTERN napi_status napi_strict_equals(napi_env env, - napi_value lhs, - napi_value rhs, - bool* result); - -// Methods to work with Functions -NAPI_EXTERN napi_status napi_call_function(napi_env env, - napi_value recv, - napi_value func, - size_t argc, - const napi_value* argv, - napi_value* result); -NAPI_EXTERN napi_status napi_new_instance(napi_env env, - napi_value constructor, - size_t argc, - const napi_value* argv, - napi_value* result); -NAPI_EXTERN napi_status napi_instanceof(napi_env env, - napi_value object, - napi_value constructor, - bool* result); - -// Methods to work with napi_callbacks - -// Gets all callback info in a single call. (Ugly, but faster.) -NAPI_EXTERN napi_status napi_get_cb_info( - napi_env env, // [in] NAPI environment handle - napi_callback_info cbinfo, // [in] Opaque callback-info handle - size_t* argc, // [in-out] Specifies the size of the provided argv array - // and receives the actual count of args. - napi_value* argv, // [out] Array of values - napi_value* this_arg, // [out] Receives the JS 'this' arg for the call - void** data); // [out] Receives the data pointer for the callback. - -NAPI_EXTERN napi_status napi_get_new_target(napi_env env, - napi_callback_info cbinfo, - napi_value* result); -NAPI_EXTERN napi_status -napi_define_class(napi_env env, - const char* utf8name, - size_t length, - napi_callback constructor, - void* data, - size_t property_count, - const napi_property_descriptor* properties, - napi_value* result); - -// Methods to work with external data objects -NAPI_EXTERN napi_status napi_wrap(napi_env env, - napi_value js_object, - void* native_object, - napi_finalize finalize_cb, - void* finalize_hint, - napi_ref* result); -NAPI_EXTERN napi_status napi_unwrap(napi_env env, - napi_value js_object, - void** result); -NAPI_EXTERN napi_status napi_remove_wrap(napi_env env, - napi_value js_object, - void** result); -NAPI_EXTERN napi_status napi_create_external(napi_env env, - void* data, - napi_finalize finalize_cb, - void* finalize_hint, - napi_value* result); -NAPI_EXTERN napi_status napi_get_value_external(napi_env env, - napi_value value, - void** result); - -// Methods to control object lifespan - -// Set initial_refcount to 0 for a weak reference, >0 for a strong reference. -NAPI_EXTERN napi_status napi_create_reference(napi_env env, - napi_value value, - uint32_t initial_refcount, - napi_ref* result); - -// Deletes a reference. The referenced value is released, and may -// be GC'd unless there are other references to it. -NAPI_EXTERN napi_status napi_delete_reference(napi_env env, napi_ref ref); - -// Increments the reference count, optionally returning the resulting count. -// After this call the reference will be a strong reference because its -// refcount is >0, and the referenced object is effectively "pinned". -// Calling this when the refcount is 0 and the object is unavailable -// results in an error. -NAPI_EXTERN napi_status napi_reference_ref(napi_env env, - napi_ref ref, - uint32_t* result); - -// Decrements the reference count, optionally returning the resulting count. -// If the result is 0 the reference is now weak and the object may be GC'd -// at any time if there are no other references. Calling this when the -// refcount is already 0 results in an error. -NAPI_EXTERN napi_status napi_reference_unref(napi_env env, - napi_ref ref, - uint32_t* result); - -// Attempts to get a referenced value. If the reference is weak, -// the value might no longer be available, in that case the call -// is still successful but the result is NULL. -NAPI_EXTERN napi_status napi_get_reference_value(napi_env env, - napi_ref ref, - napi_value* result); - -NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, - napi_handle_scope* result); -NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, - napi_handle_scope scope); -NAPI_EXTERN napi_status -napi_open_escapable_handle_scope(napi_env env, - napi_escapable_handle_scope* result); -NAPI_EXTERN napi_status -napi_close_escapable_handle_scope(napi_env env, - napi_escapable_handle_scope scope); - -NAPI_EXTERN napi_status napi_escape_handle(napi_env env, - napi_escapable_handle_scope scope, - napi_value escapee, - napi_value* result); - -// Methods to support error handling -NAPI_EXTERN napi_status napi_throw(napi_env env, napi_value error); -NAPI_EXTERN napi_status napi_throw_error(napi_env env, - const char* code, - const char* msg); -NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, - const char* code, - const char* msg); -NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, - const char* code, - const char* msg); -NAPI_EXTERN napi_status napi_is_error(napi_env env, - napi_value value, - bool* result); - -// Methods to support catching exceptions -NAPI_EXTERN napi_status napi_is_exception_pending(napi_env env, bool* result); -NAPI_EXTERN napi_status napi_get_and_clear_last_exception(napi_env env, - napi_value* result); - -// Methods to work with array buffers and typed arrays -NAPI_EXTERN napi_status napi_is_arraybuffer(napi_env env, - napi_value value, - bool* result); -NAPI_EXTERN napi_status napi_create_arraybuffer(napi_env env, - size_t byte_length, - void** data, - napi_value* result); -NAPI_EXTERN napi_status -napi_create_external_arraybuffer(napi_env env, - void* external_data, - size_t byte_length, - napi_finalize finalize_cb, - void* finalize_hint, - napi_value* result); -NAPI_EXTERN napi_status napi_get_arraybuffer_info(napi_env env, - napi_value arraybuffer, - void** data, - size_t* byte_length); -NAPI_EXTERN napi_status napi_is_typedarray(napi_env env, - napi_value value, - bool* result); -NAPI_EXTERN napi_status napi_create_typedarray(napi_env env, - napi_typedarray_type type, - size_t length, - napi_value arraybuffer, - size_t byte_offset, - napi_value* result); -NAPI_EXTERN napi_status napi_get_typedarray_info(napi_env env, - napi_value typedarray, - napi_typedarray_type* type, - size_t* length, - void** data, - napi_value* arraybuffer, - size_t* byte_offset); - -NAPI_EXTERN napi_status napi_create_dataview(napi_env env, - size_t length, - napi_value arraybuffer, - size_t byte_offset, - napi_value* result); -NAPI_EXTERN napi_status napi_is_dataview(napi_env env, - napi_value value, - bool* result); -NAPI_EXTERN napi_status napi_get_dataview_info(napi_env env, - napi_value dataview, - size_t* bytelength, - void** data, - napi_value* arraybuffer, - size_t* byte_offset); - -// version management -NAPI_EXTERN napi_status napi_get_version(napi_env env, uint32_t* result); - -// Promises -NAPI_EXTERN napi_status napi_create_promise(napi_env env, - napi_deferred* deferred, - napi_value* promise); -NAPI_EXTERN napi_status napi_resolve_deferred(napi_env env, - napi_deferred deferred, - napi_value resolution); -NAPI_EXTERN napi_status napi_reject_deferred(napi_env env, - napi_deferred deferred, - napi_value rejection); -NAPI_EXTERN napi_status napi_is_promise(napi_env env, - napi_value value, - bool* is_promise); - -// Running a script -NAPI_EXTERN napi_status napi_run_script(napi_env env, - napi_value script, - napi_value* result); - -// Memory management -NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env, - int64_t change_in_bytes, - int64_t* adjusted_value); - -#if NAPI_VERSION >= 5 - -// Dates -NAPI_EXTERN napi_status napi_create_date(napi_env env, - double time, - napi_value* result); - -NAPI_EXTERN napi_status napi_is_date(napi_env env, - napi_value value, - bool* is_date); - -NAPI_EXTERN napi_status napi_get_date_value(napi_env env, - napi_value value, - double* result); - -// Add finalizer for pointer -NAPI_EXTERN napi_status napi_add_finalizer(napi_env env, - napi_value js_object, - void* native_object, - napi_finalize finalize_cb, - void* finalize_hint, - napi_ref* result); - -#endif // NAPI_VERSION >= 5 - -#if NAPI_VERSION >= 6 - -// BigInt -NAPI_EXTERN napi_status napi_create_bigint_int64(napi_env env, - int64_t value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_bigint_uint64(napi_env env, - uint64_t value, - napi_value* result); -NAPI_EXTERN napi_status napi_create_bigint_words(napi_env env, - int sign_bit, - size_t word_count, - const uint64_t* words, - napi_value* result); -NAPI_EXTERN napi_status napi_get_value_bigint_int64(napi_env env, - napi_value value, - int64_t* result, - bool* lossless); -NAPI_EXTERN napi_status napi_get_value_bigint_uint64(napi_env env, - napi_value value, - uint64_t* result, - bool* lossless); -NAPI_EXTERN napi_status napi_get_value_bigint_words(napi_env env, - napi_value value, - int* sign_bit, - size_t* word_count, - uint64_t* words); - -// Object -NAPI_EXTERN napi_status -napi_get_all_property_names(napi_env env, - napi_value object, - napi_key_collection_mode key_mode, - napi_key_filter key_filter, - napi_key_conversion key_conversion, - napi_value* result); - -// Instance data -NAPI_EXTERN napi_status napi_set_instance_data(napi_env env, - void* data, - napi_finalize finalize_cb, - void* finalize_hint); - -NAPI_EXTERN napi_status napi_get_instance_data(napi_env env, - void** data); -#endif // NAPI_VERSION >= 6 - -#if NAPI_VERSION >= 7 -// ArrayBuffer detaching -NAPI_EXTERN napi_status napi_detach_arraybuffer(napi_env env, - napi_value arraybuffer); - -NAPI_EXTERN napi_status napi_is_detached_arraybuffer(napi_env env, - napi_value value, - bool* result); -#endif // NAPI_VERSION >= 7 - -#if NAPI_VERSION >= 8 -// Type tagging -NAPI_EXTERN napi_status napi_type_tag_object(napi_env env, - napi_value value, - const napi_type_tag* type_tag); - -NAPI_EXTERN napi_status -napi_check_object_type_tag(napi_env env, - napi_value value, - const napi_type_tag* type_tag, - bool* result); -NAPI_EXTERN napi_status napi_object_freeze(napi_env env, - napi_value object); -NAPI_EXTERN napi_status napi_object_seal(napi_env env, - napi_value object); -#endif // NAPI_VERSION >= 8 - -EXTERN_C_END - -#endif // SRC_JS_NATIVE_API_H_ +#ifndef SRC_JS_NATIVE_API_H_ +#define SRC_JS_NATIVE_API_H_ + +// This file needs to be compatible with C compilers. +#include // NOLINT(modernize-deprecated-headers) +#include // NOLINT(modernize-deprecated-headers) + +// Use INT_MAX, this should only be consumed by the pre-processor anyway. +#define NAPI_VERSION_EXPERIMENTAL 2147483647 +#ifndef NAPI_VERSION +#ifdef NAPI_EXPERIMENTAL +#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL +#else +// The baseline version for N-API. +// The NAPI_VERSION controls which version will be used by default when +// compilling a native addon. If the addon developer specifically wants to use +// functions available in a new version of N-API that is not yet ported in all +// LTS versions, they can set NAPI_VERSION knowing that they have specifically +// depended on that version. +#define NAPI_VERSION 8 +#endif +#endif + +#include "js_native_api_types.h" + +// If you need __declspec(dllimport), either include instead, or +// define NAPI_EXTERN as __declspec(dllimport) on the compiler's command line. +#ifndef NAPI_EXTERN + #ifdef _WIN32 + #define NAPI_EXTERN __declspec(dllexport) + #elif defined(__wasm32__) + #define NAPI_EXTERN __attribute__((visibility("default"))) \ + __attribute__((__import_module__("napi"))) + #else + #define NAPI_EXTERN __attribute__((visibility("default"))) + #endif +#endif + +#define NAPI_AUTO_LENGTH SIZE_MAX + +#ifdef __cplusplus +#define EXTERN_C_START extern "C" { +#define EXTERN_C_END } +#else +#define EXTERN_C_START +#define EXTERN_C_END +#endif + +EXTERN_C_START + +NAPI_EXTERN napi_status +napi_get_last_error_info(napi_env env, + const napi_extended_error_info** result); + +// Getters for defined singletons +NAPI_EXTERN napi_status napi_get_undefined(napi_env env, napi_value* result); +NAPI_EXTERN napi_status napi_get_null(napi_env env, napi_value* result); +NAPI_EXTERN napi_status napi_get_global(napi_env env, napi_value* result); +NAPI_EXTERN napi_status napi_get_boolean(napi_env env, + bool value, + napi_value* result); + +// Methods to create Primitive types/Objects +NAPI_EXTERN napi_status napi_create_object(napi_env env, napi_value* result); +NAPI_EXTERN napi_status napi_create_array(napi_env env, napi_value* result); +NAPI_EXTERN napi_status napi_create_array_with_length(napi_env env, + size_t length, + napi_value* result); +NAPI_EXTERN napi_status napi_create_double(napi_env env, + double value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_int32(napi_env env, + int32_t value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_uint32(napi_env env, + uint32_t value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_int64(napi_env env, + int64_t value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_string_latin1(napi_env env, + const char* str, + size_t length, + napi_value* result); +NAPI_EXTERN napi_status napi_create_string_utf8(napi_env env, + const char* str, + size_t length, + napi_value* result); +NAPI_EXTERN napi_status napi_create_string_utf16(napi_env env, + const char16_t* str, + size_t length, + napi_value* result); +NAPI_EXTERN napi_status napi_create_symbol(napi_env env, + napi_value description, + napi_value* result); +NAPI_EXTERN napi_status napi_create_function(napi_env env, + const char* utf8name, + size_t length, + napi_callback cb, + void* data, + napi_value* result); +NAPI_EXTERN napi_status napi_create_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result); +NAPI_EXTERN napi_status napi_create_type_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result); +NAPI_EXTERN napi_status napi_create_range_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result); + +// Methods to get the native napi_value from Primitive type +NAPI_EXTERN napi_status napi_typeof(napi_env env, + napi_value value, + napi_valuetype* result); +NAPI_EXTERN napi_status napi_get_value_double(napi_env env, + napi_value value, + double* result); +NAPI_EXTERN napi_status napi_get_value_int32(napi_env env, + napi_value value, + int32_t* result); +NAPI_EXTERN napi_status napi_get_value_uint32(napi_env env, + napi_value value, + uint32_t* result); +NAPI_EXTERN napi_status napi_get_value_int64(napi_env env, + napi_value value, + int64_t* result); +NAPI_EXTERN napi_status napi_get_value_bool(napi_env env, + napi_value value, + bool* result); + +// Copies LATIN-1 encoded bytes from a string into a buffer. +NAPI_EXTERN napi_status napi_get_value_string_latin1(napi_env env, + napi_value value, + char* buf, + size_t bufsize, + size_t* result); + +// Copies UTF-8 encoded bytes from a string into a buffer. +NAPI_EXTERN napi_status napi_get_value_string_utf8(napi_env env, + napi_value value, + char* buf, + size_t bufsize, + size_t* result); + +// Copies UTF-16 encoded bytes from a string into a buffer. +NAPI_EXTERN napi_status napi_get_value_string_utf16(napi_env env, + napi_value value, + char16_t* buf, + size_t bufsize, + size_t* result); + +// Methods to coerce values +// These APIs may execute user scripts +NAPI_EXTERN napi_status napi_coerce_to_bool(napi_env env, + napi_value value, + napi_value* result); +NAPI_EXTERN napi_status napi_coerce_to_number(napi_env env, + napi_value value, + napi_value* result); +NAPI_EXTERN napi_status napi_coerce_to_object(napi_env env, + napi_value value, + napi_value* result); +NAPI_EXTERN napi_status napi_coerce_to_string(napi_env env, + napi_value value, + napi_value* result); + +// Methods to work with Objects +NAPI_EXTERN napi_status napi_get_prototype(napi_env env, + napi_value object, + napi_value* result); +NAPI_EXTERN napi_status napi_get_property_names(napi_env env, + napi_value object, + napi_value* result); +NAPI_EXTERN napi_status napi_set_property(napi_env env, + napi_value object, + napi_value key, + napi_value value); +NAPI_EXTERN napi_status napi_has_property(napi_env env, + napi_value object, + napi_value key, + bool* result); +NAPI_EXTERN napi_status napi_get_property(napi_env env, + napi_value object, + napi_value key, + napi_value* result); +NAPI_EXTERN napi_status napi_delete_property(napi_env env, + napi_value object, + napi_value key, + bool* result); +NAPI_EXTERN napi_status napi_has_own_property(napi_env env, + napi_value object, + napi_value key, + bool* result); +NAPI_EXTERN napi_status napi_set_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value value); +NAPI_EXTERN napi_status napi_has_named_property(napi_env env, + napi_value object, + const char* utf8name, + bool* result); +NAPI_EXTERN napi_status napi_get_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value* result); +NAPI_EXTERN napi_status napi_set_element(napi_env env, + napi_value object, + uint32_t index, + napi_value value); +NAPI_EXTERN napi_status napi_has_element(napi_env env, + napi_value object, + uint32_t index, + bool* result); +NAPI_EXTERN napi_status napi_get_element(napi_env env, + napi_value object, + uint32_t index, + napi_value* result); +NAPI_EXTERN napi_status napi_delete_element(napi_env env, + napi_value object, + uint32_t index, + bool* result); +NAPI_EXTERN napi_status +napi_define_properties(napi_env env, + napi_value object, + size_t property_count, + const napi_property_descriptor* properties); + +// Methods to work with Arrays +NAPI_EXTERN napi_status napi_is_array(napi_env env, + napi_value value, + bool* result); +NAPI_EXTERN napi_status napi_get_array_length(napi_env env, + napi_value value, + uint32_t* result); + +// Methods to compare values +NAPI_EXTERN napi_status napi_strict_equals(napi_env env, + napi_value lhs, + napi_value rhs, + bool* result); + +// Methods to work with Functions +NAPI_EXTERN napi_status napi_call_function(napi_env env, + napi_value recv, + napi_value func, + size_t argc, + const napi_value* argv, + napi_value* result); +NAPI_EXTERN napi_status napi_new_instance(napi_env env, + napi_value constructor, + size_t argc, + const napi_value* argv, + napi_value* result); +NAPI_EXTERN napi_status napi_instanceof(napi_env env, + napi_value object, + napi_value constructor, + bool* result); + +// Methods to work with napi_callbacks + +// Gets all callback info in a single call. (Ugly, but faster.) +NAPI_EXTERN napi_status napi_get_cb_info( + napi_env env, // [in] NAPI environment handle + napi_callback_info cbinfo, // [in] Opaque callback-info handle + size_t* argc, // [in-out] Specifies the size of the provided argv array + // and receives the actual count of args. + napi_value* argv, // [out] Array of values + napi_value* this_arg, // [out] Receives the JS 'this' arg for the call + void** data); // [out] Receives the data pointer for the callback. + +NAPI_EXTERN napi_status napi_get_new_target(napi_env env, + napi_callback_info cbinfo, + napi_value* result); +NAPI_EXTERN napi_status +napi_define_class(napi_env env, + const char* utf8name, + size_t length, + napi_callback constructor, + void* data, + size_t property_count, + const napi_property_descriptor* properties, + napi_value* result); + +// Methods to work with external data objects +NAPI_EXTERN napi_status napi_wrap(napi_env env, + napi_value js_object, + void* native_object, + napi_finalize finalize_cb, + void* finalize_hint, + napi_ref* result); +NAPI_EXTERN napi_status napi_unwrap(napi_env env, + napi_value js_object, + void** result); +NAPI_EXTERN napi_status napi_remove_wrap(napi_env env, + napi_value js_object, + void** result); +NAPI_EXTERN napi_status napi_create_external(napi_env env, + void* data, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result); +NAPI_EXTERN napi_status napi_get_value_external(napi_env env, + napi_value value, + void** result); + +// Methods to control object lifespan + +// Set initial_refcount to 0 for a weak reference, >0 for a strong reference. +NAPI_EXTERN napi_status napi_create_reference(napi_env env, + napi_value value, + uint32_t initial_refcount, + napi_ref* result); + +// Deletes a reference. The referenced value is released, and may +// be GC'd unless there are other references to it. +NAPI_EXTERN napi_status napi_delete_reference(napi_env env, napi_ref ref); + +// Increments the reference count, optionally returning the resulting count. +// After this call the reference will be a strong reference because its +// refcount is >0, and the referenced object is effectively "pinned". +// Calling this when the refcount is 0 and the object is unavailable +// results in an error. +NAPI_EXTERN napi_status napi_reference_ref(napi_env env, + napi_ref ref, + uint32_t* result); + +// Decrements the reference count, optionally returning the resulting count. +// If the result is 0 the reference is now weak and the object may be GC'd +// at any time if there are no other references. Calling this when the +// refcount is already 0 results in an error. +NAPI_EXTERN napi_status napi_reference_unref(napi_env env, + napi_ref ref, + uint32_t* result); + +// Attempts to get a referenced value. If the reference is weak, +// the value might no longer be available, in that case the call +// is still successful but the result is NULL. +NAPI_EXTERN napi_status napi_get_reference_value(napi_env env, + napi_ref ref, + napi_value* result); + +NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, + napi_handle_scope* result); +NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, + napi_handle_scope scope); +NAPI_EXTERN napi_status +napi_open_escapable_handle_scope(napi_env env, + napi_escapable_handle_scope* result); +NAPI_EXTERN napi_status +napi_close_escapable_handle_scope(napi_env env, + napi_escapable_handle_scope scope); + +NAPI_EXTERN napi_status napi_escape_handle(napi_env env, + napi_escapable_handle_scope scope, + napi_value escapee, + napi_value* result); + +// Methods to support error handling +NAPI_EXTERN napi_status napi_throw(napi_env env, napi_value error); +NAPI_EXTERN napi_status napi_throw_error(napi_env env, + const char* code, + const char* msg); +NAPI_EXTERN napi_status napi_throw_type_error(napi_env env, + const char* code, + const char* msg); +NAPI_EXTERN napi_status napi_throw_range_error(napi_env env, + const char* code, + const char* msg); +NAPI_EXTERN napi_status napi_is_error(napi_env env, + napi_value value, + bool* result); + +// Methods to support catching exceptions +NAPI_EXTERN napi_status napi_is_exception_pending(napi_env env, bool* result); +NAPI_EXTERN napi_status napi_get_and_clear_last_exception(napi_env env, + napi_value* result); + +// Methods to work with array buffers and typed arrays +NAPI_EXTERN napi_status napi_is_arraybuffer(napi_env env, + napi_value value, + bool* result); +NAPI_EXTERN napi_status napi_create_arraybuffer(napi_env env, + size_t byte_length, + void** data, + napi_value* result); +NAPI_EXTERN napi_status +napi_create_external_arraybuffer(napi_env env, + void* external_data, + size_t byte_length, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result); +NAPI_EXTERN napi_status napi_get_arraybuffer_info(napi_env env, + napi_value arraybuffer, + void** data, + size_t* byte_length); +NAPI_EXTERN napi_status napi_is_typedarray(napi_env env, + napi_value value, + bool* result); +NAPI_EXTERN napi_status napi_create_typedarray(napi_env env, + napi_typedarray_type type, + size_t length, + napi_value arraybuffer, + size_t byte_offset, + napi_value* result); +NAPI_EXTERN napi_status napi_get_typedarray_info(napi_env env, + napi_value typedarray, + napi_typedarray_type* type, + size_t* length, + void** data, + napi_value* arraybuffer, + size_t* byte_offset); + +NAPI_EXTERN napi_status napi_create_dataview(napi_env env, + size_t length, + napi_value arraybuffer, + size_t byte_offset, + napi_value* result); +NAPI_EXTERN napi_status napi_is_dataview(napi_env env, + napi_value value, + bool* result); +NAPI_EXTERN napi_status napi_get_dataview_info(napi_env env, + napi_value dataview, + size_t* bytelength, + void** data, + napi_value* arraybuffer, + size_t* byte_offset); + +// version management +NAPI_EXTERN napi_status napi_get_version(napi_env env, uint32_t* result); + +// Promises +NAPI_EXTERN napi_status napi_create_promise(napi_env env, + napi_deferred* deferred, + napi_value* promise); +NAPI_EXTERN napi_status napi_resolve_deferred(napi_env env, + napi_deferred deferred, + napi_value resolution); +NAPI_EXTERN napi_status napi_reject_deferred(napi_env env, + napi_deferred deferred, + napi_value rejection); +NAPI_EXTERN napi_status napi_is_promise(napi_env env, + napi_value value, + bool* is_promise); + +// Running a script +NAPI_EXTERN napi_status napi_run_script(napi_env env, + napi_value script, + napi_value* result); + +// Memory management +NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env, + int64_t change_in_bytes, + int64_t* adjusted_value); + +#if NAPI_VERSION >= 5 + +// Dates +NAPI_EXTERN napi_status napi_create_date(napi_env env, + double time, + napi_value* result); + +NAPI_EXTERN napi_status napi_is_date(napi_env env, + napi_value value, + bool* is_date); + +NAPI_EXTERN napi_status napi_get_date_value(napi_env env, + napi_value value, + double* result); + +// Add finalizer for pointer +NAPI_EXTERN napi_status napi_add_finalizer(napi_env env, + napi_value js_object, + void* native_object, + napi_finalize finalize_cb, + void* finalize_hint, + napi_ref* result); + +#endif // NAPI_VERSION >= 5 + +#if NAPI_VERSION >= 6 + +// BigInt +NAPI_EXTERN napi_status napi_create_bigint_int64(napi_env env, + int64_t value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_bigint_uint64(napi_env env, + uint64_t value, + napi_value* result); +NAPI_EXTERN napi_status napi_create_bigint_words(napi_env env, + int sign_bit, + size_t word_count, + const uint64_t* words, + napi_value* result); +NAPI_EXTERN napi_status napi_get_value_bigint_int64(napi_env env, + napi_value value, + int64_t* result, + bool* lossless); +NAPI_EXTERN napi_status napi_get_value_bigint_uint64(napi_env env, + napi_value value, + uint64_t* result, + bool* lossless); +NAPI_EXTERN napi_status napi_get_value_bigint_words(napi_env env, + napi_value value, + int* sign_bit, + size_t* word_count, + uint64_t* words); + +// Object +NAPI_EXTERN napi_status +napi_get_all_property_names(napi_env env, + napi_value object, + napi_key_collection_mode key_mode, + napi_key_filter key_filter, + napi_key_conversion key_conversion, + napi_value* result); + +// Instance data +NAPI_EXTERN napi_status napi_set_instance_data(napi_env env, + void* data, + napi_finalize finalize_cb, + void* finalize_hint); + +NAPI_EXTERN napi_status napi_get_instance_data(napi_env env, + void** data); +#endif // NAPI_VERSION >= 6 + +#if NAPI_VERSION >= 7 +// ArrayBuffer detaching +NAPI_EXTERN napi_status napi_detach_arraybuffer(napi_env env, + napi_value arraybuffer); + +NAPI_EXTERN napi_status napi_is_detached_arraybuffer(napi_env env, + napi_value value, + bool* result); +#endif // NAPI_VERSION >= 7 + +#if NAPI_VERSION >= 8 +// Type tagging +NAPI_EXTERN napi_status napi_type_tag_object(napi_env env, + napi_value value, + const napi_type_tag* type_tag); + +NAPI_EXTERN napi_status +napi_check_object_type_tag(napi_env env, + napi_value value, + const napi_type_tag* type_tag, + bool* result); +NAPI_EXTERN napi_status napi_object_freeze(napi_env env, + napi_value object); +NAPI_EXTERN napi_status napi_object_seal(napi_env env, + napi_value object); +#endif // NAPI_VERSION >= 8 + +EXTERN_C_END + +#endif // SRC_JS_NATIVE_API_H_ diff --git a/third_party/node/src/js_native_api_types.h b/third_party/node/src/js_native_api_types.h index 6aba06629b31543c13698dbb02b82db309587c4a..429147aae251475aff5964931c8fe3f3676406bb 100644 --- a/third_party/node/src/js_native_api_types.h +++ b/third_party/node/src/js_native_api_types.h @@ -1,160 +1,160 @@ -#ifndef SRC_JS_NATIVE_API_TYPES_H_ -#define SRC_JS_NATIVE_API_TYPES_H_ - -// This file needs to be compatible with C compilers. -// This is a public include file, and these includes have essentially -// became part of it's API. -#include // NOLINT(modernize-deprecated-headers) -#include // NOLINT(modernize-deprecated-headers) - -#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900) - typedef uint16_t char16_t; -#endif - -// JSVM API types are all opaque pointers for ABI stability -// typedef undefined structs instead of void* for compile time type safety -typedef struct napi_env__* napi_env; -typedef struct napi_value__* napi_value; -typedef struct napi_ref__* napi_ref; -typedef struct napi_handle_scope__* napi_handle_scope; -typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope; -typedef struct napi_callback_info__* napi_callback_info; -typedef struct napi_deferred__* napi_deferred; - -typedef enum { - napi_default = 0, - napi_writable = 1 << 0, - napi_enumerable = 1 << 1, - napi_configurable = 1 << 2, - - // Used with napi_define_class to distinguish static properties - // from instance properties. Ignored by napi_define_properties. - napi_static = 1 << 10, - -#if NAPI_VERSION >= 8 - // Default for class methods. - napi_default_method = napi_writable | napi_configurable, - - // Default for object properties, like in JS obj[prop]. - napi_default_jsproperty = napi_writable | - napi_enumerable | - napi_configurable, -#endif // NAPI_VERSION >= 8 -} napi_property_attributes; - -typedef enum { - // ES6 types (corresponds to typeof) - napi_undefined, - napi_null, - napi_boolean, - napi_number, - napi_string, - napi_symbol, - napi_object, - napi_function, - napi_external, - napi_bigint, -} napi_valuetype; - -typedef enum { - napi_int8_array, - napi_uint8_array, - napi_uint8_clamped_array, - napi_int16_array, - napi_uint16_array, - napi_int32_array, - napi_uint32_array, - napi_float32_array, - napi_float64_array, - napi_bigint64_array, - napi_biguint64_array, -} napi_typedarray_type; - -typedef enum { - napi_ok, - napi_invalid_arg, - napi_object_expected, - napi_string_expected, - napi_name_expected, - napi_function_expected, - napi_number_expected, - napi_boolean_expected, - napi_array_expected, - napi_generic_failure, - napi_pending_exception, - napi_cancelled, - napi_escape_called_twice, - napi_handle_scope_mismatch, - napi_callback_scope_mismatch, - napi_queue_full, - napi_closing, - napi_bigint_expected, - napi_date_expected, - napi_arraybuffer_expected, - napi_detachable_arraybuffer_expected, - napi_would_deadlock // unused -} napi_status; -// Note: when adding a new enum value to `napi_status`, please also update -// * `const int last_status` in the definition of `napi_get_last_error_info()' -// in file js_native_api_v8.cc. -// * `const char* error_messages[]` in file js_native_api_v8.cc with a brief -// message explaining the error. -// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly -// added value(s). - -typedef napi_value (*napi_callback)(napi_env env, - napi_callback_info info); -typedef void (*napi_finalize)(napi_env env, - void* finalize_data, - void* finalize_hint); - -typedef struct { - // One of utf8name or name should be NULL. - const char* utf8name; - napi_value name; - - napi_callback method; - napi_callback getter; - napi_callback setter; - napi_value value; - - napi_property_attributes attributes; - void* data; -} napi_property_descriptor; - -typedef struct { - const char* error_message; - void* engine_reserved; - uint32_t engine_error_code; - napi_status error_code; -} napi_extended_error_info; - -#if NAPI_VERSION >= 6 -typedef enum { - napi_key_include_prototypes, - napi_key_own_only -} napi_key_collection_mode; - -typedef enum { - napi_key_all_properties = 0, - napi_key_writable = 1, - napi_key_enumerable = 1 << 1, - napi_key_configurable = 1 << 2, - napi_key_skip_strings = 1 << 3, - napi_key_skip_symbols = 1 << 4 -} napi_key_filter; - -typedef enum { - napi_key_keep_numbers, - napi_key_numbers_to_strings -} napi_key_conversion; -#endif // NAPI_VERSION >= 6 - -#if NAPI_VERSION >= 8 -typedef struct { - uint64_t lower; - uint64_t upper; -} napi_type_tag; -#endif // NAPI_VERSION >= 8 - -#endif // SRC_JS_NATIVE_API_TYPES_H_ +#ifndef SRC_JS_NATIVE_API_TYPES_H_ +#define SRC_JS_NATIVE_API_TYPES_H_ + +// This file needs to be compatible with C compilers. +// This is a public include file, and these includes have essentially +// became part of it's API. +#include // NOLINT(modernize-deprecated-headers) +#include // NOLINT(modernize-deprecated-headers) + +#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900) + typedef uint16_t char16_t; +#endif + +// JSVM API types are all opaque pointers for ABI stability +// typedef undefined structs instead of void* for compile time type safety +typedef struct napi_env__* napi_env; +typedef struct napi_value__* napi_value; +typedef struct napi_ref__* napi_ref; +typedef struct napi_handle_scope__* napi_handle_scope; +typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope; +typedef struct napi_callback_info__* napi_callback_info; +typedef struct napi_deferred__* napi_deferred; + +typedef enum { + napi_default = 0, + napi_writable = 1 << 0, + napi_enumerable = 1 << 1, + napi_configurable = 1 << 2, + + // Used with napi_define_class to distinguish static properties + // from instance properties. Ignored by napi_define_properties. + napi_static = 1 << 10, + +#if NAPI_VERSION >= 8 + // Default for class methods. + napi_default_method = napi_writable | napi_configurable, + + // Default for object properties, like in JS obj[prop]. + napi_default_jsproperty = napi_writable | + napi_enumerable | + napi_configurable, +#endif // NAPI_VERSION >= 8 +} napi_property_attributes; + +typedef enum { + // ES6 types (corresponds to typeof) + napi_undefined, + napi_null, + napi_boolean, + napi_number, + napi_string, + napi_symbol, + napi_object, + napi_function, + napi_external, + napi_bigint, +} napi_valuetype; + +typedef enum { + napi_int8_array, + napi_uint8_array, + napi_uint8_clamped_array, + napi_int16_array, + napi_uint16_array, + napi_int32_array, + napi_uint32_array, + napi_float32_array, + napi_float64_array, + napi_bigint64_array, + napi_biguint64_array, +} napi_typedarray_type; + +typedef enum { + napi_ok, + napi_invalid_arg, + napi_object_expected, + napi_string_expected, + napi_name_expected, + napi_function_expected, + napi_number_expected, + napi_boolean_expected, + napi_array_expected, + napi_generic_failure, + napi_pending_exception, + napi_cancelled, + napi_escape_called_twice, + napi_handle_scope_mismatch, + napi_callback_scope_mismatch, + napi_queue_full, + napi_closing, + napi_bigint_expected, + napi_date_expected, + napi_arraybuffer_expected, + napi_detachable_arraybuffer_expected, + napi_would_deadlock // unused +} napi_status; +// Note: when adding a new enum value to `napi_status`, please also update +// * `const int last_status` in the definition of `napi_get_last_error_info()' +// in file js_native_api_v8.cc. +// * `const char* error_messages[]` in file js_native_api_v8.cc with a brief +// message explaining the error. +// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly +// added value(s). + +typedef napi_value (*napi_callback)(napi_env env, + napi_callback_info info); +typedef void (*napi_finalize)(napi_env env, + void* finalize_data, + void* finalize_hint); + +typedef struct { + // One of utf8name or name should be NULL. + const char* utf8name; + napi_value name; + + napi_callback method; + napi_callback getter; + napi_callback setter; + napi_value value; + + napi_property_attributes attributes; + void* data; +} napi_property_descriptor; + +typedef struct { + const char* error_message; + void* engine_reserved; + uint32_t engine_error_code; + napi_status error_code; +} napi_extended_error_info; + +#if NAPI_VERSION >= 6 +typedef enum { + napi_key_include_prototypes, + napi_key_own_only +} napi_key_collection_mode; + +typedef enum { + napi_key_all_properties = 0, + napi_key_writable = 1, + napi_key_enumerable = 1 << 1, + napi_key_configurable = 1 << 2, + napi_key_skip_strings = 1 << 3, + napi_key_skip_symbols = 1 << 4 +} napi_key_filter; + +typedef enum { + napi_key_keep_numbers, + napi_key_numbers_to_strings +} napi_key_conversion; +#endif // NAPI_VERSION >= 6 + +#if NAPI_VERSION >= 8 +typedef struct { + uint64_t lower; + uint64_t upper; +} napi_type_tag; +#endif // NAPI_VERSION >= 8 + +#endif // SRC_JS_NATIVE_API_TYPES_H_ diff --git a/third_party/node/src/node_api.h b/third_party/node/src/node_api.h index 1772c67c15afb2d2712b1900a584f627852e3d7e..9dc2c15ba5af7f4c52928b280d7609f89ec4fc59 100644 --- a/third_party/node/src/node_api.h +++ b/third_party/node/src/node_api.h @@ -1,275 +1,275 @@ -#ifndef SRC_NODE_API_H_ -#define SRC_NODE_API_H_ - -#ifdef BUILDING_NODE_EXTENSION - #ifdef _WIN32 - // Building native module against node - #define NAPI_EXTERN __declspec(dllimport) - #elif defined(__wasm32__) - #define NAPI_EXTERN __attribute__((__import_module__("napi"))) - #endif -#endif -#include "js_native_api.h" -#include "node_api_types.h" - -struct uv_loop_s; // Forward declaration. - -#ifdef _WIN32 -# define NAPI_MODULE_EXPORT __declspec(dllexport) -#else -# define NAPI_MODULE_EXPORT __attribute__((visibility("default"))) -#endif - -#if defined(__GNUC__) -# define NAPI_NO_RETURN __attribute__((noreturn)) -#elif defined(_WIN32) -# define NAPI_NO_RETURN __declspec(noreturn) -#else -# define NAPI_NO_RETURN -#endif - -typedef napi_value (*napi_addon_register_func)(napi_env env, - napi_value exports); - -typedef struct napi_module { - int nm_version; - unsigned int nm_flags; - const char* nm_filename; - napi_addon_register_func nm_register_func; - const char* nm_modname; - void* nm_priv; - void* reserved[4]; -} napi_module; - -#define NAPI_MODULE_VERSION 1 - -#if defined(_MSC_VER) -#pragma section(".CRT$XCU", read) -#define NAPI_C_CTOR(fn) \ - static void __cdecl fn(void); \ - __declspec(dllexport, allocate(".CRT$XCU")) void(__cdecl * fn##_)(void) = \ - fn; \ - static void __cdecl fn(void) -#else -#define NAPI_C_CTOR(fn) \ - static void fn(void) __attribute__((constructor)); \ - static void fn(void) -#endif - -#define NAPI_MODULE_X(modname, regfunc, priv, flags) \ - EXTERN_C_START \ - static napi_module _module = \ - { \ - NAPI_MODULE_VERSION, \ - flags, \ - __FILE__, \ - regfunc, \ - #modname, \ - priv, \ - {0}, \ - }; \ - NAPI_C_CTOR(_register_ ## modname) { \ - napi_module_register(&_module); \ - } \ - EXTERN_C_END - -#define NAPI_MODULE_INITIALIZER_X(base, version) \ - NAPI_MODULE_INITIALIZER_X_HELPER(base, version) -#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version - -#ifdef __wasm32__ -#define NAPI_WASM_INITIALIZER \ - NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION) -#define NAPI_MODULE(modname, regfunc) \ - EXTERN_C_START \ - NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \ - napi_value exports) { \ - return regfunc(env, exports); \ - } \ - EXTERN_C_END -#else -#define NAPI_MODULE(modname, regfunc) \ - NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) -#endif - -#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v - -#define NAPI_MODULE_INITIALIZER \ - NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \ - NAPI_MODULE_VERSION) - -#define NAPI_MODULE_INIT() \ - EXTERN_C_START \ - NAPI_MODULE_EXPORT napi_value \ - NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports); \ - EXTERN_C_END \ - NAPI_MODULE(NODE_GYP_MODULE_NAME, NAPI_MODULE_INITIALIZER) \ - napi_value NAPI_MODULE_INITIALIZER(napi_env env, \ - napi_value exports) - -EXTERN_C_START - -NAPI_EXTERN void napi_module_register(napi_module* mod); - -NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location, - size_t location_len, - const char* message, - size_t message_len); - -// Methods for custom handling of async operations -NAPI_EXTERN napi_status napi_async_init(napi_env env, - napi_value async_resource, - napi_value async_resource_name, - napi_async_context* result); - -NAPI_EXTERN napi_status napi_async_destroy(napi_env env, - napi_async_context async_context); - -NAPI_EXTERN napi_status napi_make_callback(napi_env env, - napi_async_context async_context, - napi_value recv, - napi_value func, - size_t argc, - const napi_value* argv, - napi_value* result); - -// Methods to provide node::Buffer functionality with napi types -NAPI_EXTERN napi_status napi_create_buffer(napi_env env, - size_t length, - void** data, - napi_value* result); -NAPI_EXTERN napi_status napi_create_external_buffer(napi_env env, - size_t length, - void* data, - napi_finalize finalize_cb, - void* finalize_hint, - napi_value* result); -NAPI_EXTERN napi_status napi_create_buffer_copy(napi_env env, - size_t length, - const void* data, - void** result_data, - napi_value* result); -NAPI_EXTERN napi_status napi_is_buffer(napi_env env, - napi_value value, - bool* result); -NAPI_EXTERN napi_status napi_get_buffer_info(napi_env env, - napi_value value, - void** data, - size_t* length); - -// Methods to manage simple async operations -NAPI_EXTERN -napi_status napi_create_async_work(napi_env env, - napi_value async_resource, - napi_value async_resource_name, - napi_async_execute_callback execute, - napi_async_complete_callback complete, - void* data, - napi_async_work* result); -NAPI_EXTERN napi_status napi_delete_async_work(napi_env env, - napi_async_work work); -NAPI_EXTERN napi_status napi_queue_async_work(napi_env env, - napi_async_work work); -NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env, - napi_async_work work); - -// version management -NAPI_EXTERN -napi_status napi_get_node_version(napi_env env, - const napi_node_version** version); - -#if NAPI_VERSION >= 2 - -// Return the current libuv event loop for a given environment -NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, - struct uv_loop_s** loop); - -#endif // NAPI_VERSION >= 2 - -#if NAPI_VERSION >= 3 - -NAPI_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err); - -NAPI_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, - void (*fun)(void* arg), - void* arg); - -NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, - void (*fun)(void* arg), - void* arg); - -NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, - napi_value resource_object, - napi_async_context context, - napi_callback_scope* result); - -NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, - napi_callback_scope scope); - -#endif // NAPI_VERSION >= 3 - -#if NAPI_VERSION >= 4 - -#ifndef __wasm32__ -// Calling into JS from other threads -NAPI_EXTERN napi_status -napi_create_threadsafe_function(napi_env env, - napi_value func, - napi_value async_resource, - napi_value async_resource_name, - size_t max_queue_size, - size_t initial_thread_count, - void* thread_finalize_data, - napi_finalize thread_finalize_cb, - void* context, - napi_threadsafe_function_call_js call_js_cb, - napi_threadsafe_function* result); - -NAPI_EXTERN napi_status -napi_get_threadsafe_function_context(napi_threadsafe_function func, - void** result); - -NAPI_EXTERN napi_status -napi_call_threadsafe_function(napi_threadsafe_function func, - void* data, - napi_threadsafe_function_call_mode is_blocking); - -NAPI_EXTERN napi_status -napi_acquire_threadsafe_function(napi_threadsafe_function func); - -NAPI_EXTERN napi_status -napi_release_threadsafe_function(napi_threadsafe_function func, - napi_threadsafe_function_release_mode mode); - -NAPI_EXTERN napi_status -napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); - -NAPI_EXTERN napi_status -napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); -#endif // __wasm32__ - -#endif // NAPI_VERSION >= 4 - -#if NAPI_VERSION >= 8 - -NAPI_EXTERN napi_status napi_add_async_cleanup_hook( - napi_env env, - napi_async_cleanup_hook hook, - void* arg, - napi_async_cleanup_hook_handle* remove_handle); - -NAPI_EXTERN napi_status napi_remove_async_cleanup_hook( - napi_async_cleanup_hook_handle remove_handle); - -#endif // NAPI_VERSION >= 8 - -#ifdef NAPI_EXPERIMENTAL - -NAPI_EXTERN napi_status -node_api_get_module_file_name(napi_env env, const char** result); - -#endif // NAPI_EXPERIMENTAL - -EXTERN_C_END - -#endif // SRC_NODE_API_H_ +#ifndef SRC_NODE_API_H_ +#define SRC_NODE_API_H_ + +#ifdef BUILDING_NODE_EXTENSION + #ifdef _WIN32 + // Building native module against node + #define NAPI_EXTERN __declspec(dllimport) + #elif defined(__wasm32__) + #define NAPI_EXTERN __attribute__((__import_module__("napi"))) + #endif +#endif +#include "js_native_api.h" +#include "node_api_types.h" + +struct uv_loop_s; // Forward declaration. + +#ifdef _WIN32 +# define NAPI_MODULE_EXPORT __declspec(dllexport) +#else +# define NAPI_MODULE_EXPORT __attribute__((visibility("default"))) +#endif + +#if defined(__GNUC__) +# define NAPI_NO_RETURN __attribute__((noreturn)) +#elif defined(_WIN32) +# define NAPI_NO_RETURN __declspec(noreturn) +#else +# define NAPI_NO_RETURN +#endif + +typedef napi_value (*napi_addon_register_func)(napi_env env, + napi_value exports); + +typedef struct napi_module { + int nm_version; + unsigned int nm_flags; + const char* nm_filename; + napi_addon_register_func nm_register_func; + const char* nm_modname; + void* nm_priv; + void* reserved[4]; +} napi_module; + +#define NAPI_MODULE_VERSION 1 + +#if defined(_MSC_VER) +#pragma section(".CRT$XCU", read) +#define NAPI_C_CTOR(fn) \ + static void __cdecl fn(void); \ + __declspec(dllexport, allocate(".CRT$XCU")) void(__cdecl * fn##_)(void) = \ + fn; \ + static void __cdecl fn(void) +#else +#define NAPI_C_CTOR(fn) \ + static void fn(void) __attribute__((constructor)); \ + static void fn(void) +#endif + +#define NAPI_MODULE_X(modname, regfunc, priv, flags) \ + EXTERN_C_START \ + static napi_module _module = \ + { \ + NAPI_MODULE_VERSION, \ + flags, \ + __FILE__, \ + regfunc, \ + #modname, \ + priv, \ + {0}, \ + }; \ + NAPI_C_CTOR(_register_ ## modname) { \ + napi_module_register(&_module); \ + } \ + EXTERN_C_END + +#define NAPI_MODULE_INITIALIZER_X(base, version) \ + NAPI_MODULE_INITIALIZER_X_HELPER(base, version) +#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version + +#ifdef __wasm32__ +#define NAPI_WASM_INITIALIZER \ + NAPI_MODULE_INITIALIZER_X(napi_register_wasm_v, NAPI_MODULE_VERSION) +#define NAPI_MODULE(modname, regfunc) \ + EXTERN_C_START \ + NAPI_MODULE_EXPORT napi_value NAPI_WASM_INITIALIZER(napi_env env, \ + napi_value exports) { \ + return regfunc(env, exports); \ + } \ + EXTERN_C_END +#else +#define NAPI_MODULE(modname, regfunc) \ + NAPI_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage) +#endif + +#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v + +#define NAPI_MODULE_INITIALIZER \ + NAPI_MODULE_INITIALIZER_X(NAPI_MODULE_INITIALIZER_BASE, \ + NAPI_MODULE_VERSION) + +#define NAPI_MODULE_INIT() \ + EXTERN_C_START \ + NAPI_MODULE_EXPORT napi_value \ + NAPI_MODULE_INITIALIZER(napi_env env, napi_value exports); \ + EXTERN_C_END \ + NAPI_MODULE(NODE_GYP_MODULE_NAME, NAPI_MODULE_INITIALIZER) \ + napi_value NAPI_MODULE_INITIALIZER(napi_env env, \ + napi_value exports) + +EXTERN_C_START + +NAPI_EXTERN void napi_module_register(napi_module* mod); + +NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location, + size_t location_len, + const char* message, + size_t message_len); + +// Methods for custom handling of async operations +NAPI_EXTERN napi_status napi_async_init(napi_env env, + napi_value async_resource, + napi_value async_resource_name, + napi_async_context* result); + +NAPI_EXTERN napi_status napi_async_destroy(napi_env env, + napi_async_context async_context); + +NAPI_EXTERN napi_status napi_make_callback(napi_env env, + napi_async_context async_context, + napi_value recv, + napi_value func, + size_t argc, + const napi_value* argv, + napi_value* result); + +// Methods to provide node::Buffer functionality with napi types +NAPI_EXTERN napi_status napi_create_buffer(napi_env env, + size_t length, + void** data, + napi_value* result); +NAPI_EXTERN napi_status napi_create_external_buffer(napi_env env, + size_t length, + void* data, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result); +NAPI_EXTERN napi_status napi_create_buffer_copy(napi_env env, + size_t length, + const void* data, + void** result_data, + napi_value* result); +NAPI_EXTERN napi_status napi_is_buffer(napi_env env, + napi_value value, + bool* result); +NAPI_EXTERN napi_status napi_get_buffer_info(napi_env env, + napi_value value, + void** data, + size_t* length); + +// Methods to manage simple async operations +NAPI_EXTERN +napi_status napi_create_async_work(napi_env env, + napi_value async_resource, + napi_value async_resource_name, + napi_async_execute_callback execute, + napi_async_complete_callback complete, + void* data, + napi_async_work* result); +NAPI_EXTERN napi_status napi_delete_async_work(napi_env env, + napi_async_work work); +NAPI_EXTERN napi_status napi_queue_async_work(napi_env env, + napi_async_work work); +NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env, + napi_async_work work); + +// version management +NAPI_EXTERN +napi_status napi_get_node_version(napi_env env, + const napi_node_version** version); + +#if NAPI_VERSION >= 2 + +// Return the current libuv event loop for a given environment +NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env, + struct uv_loop_s** loop); + +#endif // NAPI_VERSION >= 2 + +#if NAPI_VERSION >= 3 + +NAPI_EXTERN napi_status napi_fatal_exception(napi_env env, napi_value err); + +NAPI_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); + +NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); + +NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, + napi_value resource_object, + napi_async_context context, + napi_callback_scope* result); + +NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, + napi_callback_scope scope); + +#endif // NAPI_VERSION >= 3 + +#if NAPI_VERSION >= 4 + +#ifndef __wasm32__ +// Calling into JS from other threads +NAPI_EXTERN napi_status +napi_create_threadsafe_function(napi_env env, + napi_value func, + napi_value async_resource, + napi_value async_resource_name, + size_t max_queue_size, + size_t initial_thread_count, + void* thread_finalize_data, + napi_finalize thread_finalize_cb, + void* context, + napi_threadsafe_function_call_js call_js_cb, + napi_threadsafe_function* result); + +NAPI_EXTERN napi_status +napi_get_threadsafe_function_context(napi_threadsafe_function func, + void** result); + +NAPI_EXTERN napi_status +napi_call_threadsafe_function(napi_threadsafe_function func, + void* data, + napi_threadsafe_function_call_mode is_blocking); + +NAPI_EXTERN napi_status +napi_acquire_threadsafe_function(napi_threadsafe_function func); + +NAPI_EXTERN napi_status +napi_release_threadsafe_function(napi_threadsafe_function func, + napi_threadsafe_function_release_mode mode); + +NAPI_EXTERN napi_status +napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func); + +NAPI_EXTERN napi_status +napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func); +#endif // __wasm32__ + +#endif // NAPI_VERSION >= 4 + +#if NAPI_VERSION >= 8 + +NAPI_EXTERN napi_status napi_add_async_cleanup_hook( + napi_env env, + napi_async_cleanup_hook hook, + void* arg, + napi_async_cleanup_hook_handle* remove_handle); + +NAPI_EXTERN napi_status napi_remove_async_cleanup_hook( + napi_async_cleanup_hook_handle remove_handle); + +#endif // NAPI_VERSION >= 8 + +#ifdef NAPI_EXPERIMENTAL + +NAPI_EXTERN napi_status +node_api_get_module_file_name(napi_env env, const char** result); + +#endif // NAPI_EXPERIMENTAL + +EXTERN_C_END + +#endif // SRC_NODE_API_H_ diff --git a/third_party/node/src/node_api_types.h b/third_party/node/src/node_api_types.h index 58ffc61b3a5f51b71f33f6dd904d61da12089f3b..43a7b9ded727bf40674619c16249e6fd418152a4 100644 --- a/third_party/node/src/node_api_types.h +++ b/third_party/node/src/node_api_types.h @@ -1,50 +1,50 @@ -#ifndef SRC_NODE_API_TYPES_H_ -#define SRC_NODE_API_TYPES_H_ - -#include "js_native_api_types.h" - -typedef struct napi_callback_scope__* napi_callback_scope; -typedef struct napi_async_context__* napi_async_context; -typedef struct napi_async_work__* napi_async_work; -#if NAPI_VERSION >= 4 -typedef struct napi_threadsafe_function__* napi_threadsafe_function; -#endif // NAPI_VERSION >= 4 - -#if NAPI_VERSION >= 4 -typedef enum { - napi_tsfn_release, - napi_tsfn_abort -} napi_threadsafe_function_release_mode; - -typedef enum { - napi_tsfn_nonblocking, - napi_tsfn_blocking -} napi_threadsafe_function_call_mode; -#endif // NAPI_VERSION >= 4 - -typedef void (*napi_async_execute_callback)(napi_env env, - void* data); -typedef void (*napi_async_complete_callback)(napi_env env, - napi_status status, - void* data); -#if NAPI_VERSION >= 4 -typedef void (*napi_threadsafe_function_call_js)(napi_env env, - napi_value js_callback, - void* context, - void* data); -#endif // NAPI_VERSION >= 4 - -typedef struct { - uint32_t major; - uint32_t minor; - uint32_t patch; - const char* release; -} napi_node_version; - -#if NAPI_VERSION >= 8 -typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle; -typedef void (*napi_async_cleanup_hook)(napi_async_cleanup_hook_handle handle, - void* data); -#endif // NAPI_VERSION >= 8 - -#endif // SRC_NODE_API_TYPES_H_ +#ifndef SRC_NODE_API_TYPES_H_ +#define SRC_NODE_API_TYPES_H_ + +#include "js_native_api_types.h" + +typedef struct napi_callback_scope__* napi_callback_scope; +typedef struct napi_async_context__* napi_async_context; +typedef struct napi_async_work__* napi_async_work; +#if NAPI_VERSION >= 4 +typedef struct napi_threadsafe_function__* napi_threadsafe_function; +#endif // NAPI_VERSION >= 4 + +#if NAPI_VERSION >= 4 +typedef enum { + napi_tsfn_release, + napi_tsfn_abort +} napi_threadsafe_function_release_mode; + +typedef enum { + napi_tsfn_nonblocking, + napi_tsfn_blocking +} napi_threadsafe_function_call_mode; +#endif // NAPI_VERSION >= 4 + +typedef void (*napi_async_execute_callback)(napi_env env, + void* data); +typedef void (*napi_async_complete_callback)(napi_env env, + napi_status status, + void* data); +#if NAPI_VERSION >= 4 +typedef void (*napi_threadsafe_function_call_js)(napi_env env, + napi_value js_callback, + void* context, + void* data); +#endif // NAPI_VERSION >= 4 + +typedef struct { + uint32_t major; + uint32_t minor; + uint32_t patch; + const char* release; +} napi_node_version; + +#if NAPI_VERSION >= 8 +typedef struct napi_async_cleanup_hook_handle__* napi_async_cleanup_hook_handle; +typedef void (*napi_async_cleanup_hook)(napi_async_cleanup_hook_handle handle, + void* data); +#endif // NAPI_VERSION >= 8 + +#endif // SRC_NODE_API_TYPES_H_ diff --git a/third_party/openGLES/GLES3/gl3.h b/third_party/openGLES/GLES3/gl3.h index a31743e0b35eff6aad2c73e51a82ea8346b9cc93..eb823e1e1f30a0b522a5d8d5550b2488858ffedd 100644 --- a/third_party/openGLES/GLES3/gl3.h +++ b/third_party/openGLES/GLES3/gl3.h @@ -25,7 +25,7 @@ extern "C" { #define GL_GLES_PROTOTYPES 1 #endif -/* Generated on date 20210107 */ +/* Generated on date 20230220 */ /* Generated C header for: * API: gles2 diff --git a/third_party/openSLES/BUILD.gn b/third_party/openSLES/BUILD.gn index 9a1e8993079b00af5eda1808cb0d985c1473139e..cc68a30a6a1c1ef8c2a2f7d912900cb5eb100537 100644 --- a/third_party/openSLES/BUILD.gn +++ b/third_party/openSLES/BUILD.gn @@ -1,43 +1,43 @@ -# Copyright (c) 2022 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/ndk/ndk.gni") - -config("libSLES_public_config") { - include_dirs = [ "api" ] -} - -group("libSLES") { - public_configs = [ ":libSLES_public_config" ] -} - -ohos_ndk_headers("sles_header") { - dest_dir = "$ndk_headers_out_dir/SLES" - sources = [ - "api/1.0.1/OpenSLES.h", - "api/1.0.1/OpenSLES_OpenHarmony.h", - "api/1.0.1/OpenSLES_Platform.h", - ] -} - -ohos_ndk_library("libOpenSLES_ndk") { - output_name = "OpenSLES" - output_extension = "so" - ndk_description_file = "./openSLES.ndk.json" - system_capability = "SystemCapability.Multimedia.Audio.Core" - system_capability_headers = [ - "SLES/OpenSLES.h", - "SLES/OpenSLES_Platform.h", - "SLES/OpenSLES_OpenHarmony.h", - ] -} +# Copyright (c) 2022 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/ndk/ndk.gni") + +config("libSLES_public_config") { + include_dirs = [ "api" ] +} + +group("libSLES") { + public_configs = [ ":libSLES_public_config" ] +} + +ohos_ndk_headers("sles_header") { + dest_dir = "$ndk_headers_out_dir/SLES" + sources = [ + "api/1.0.1/OpenSLES.h", + "api/1.0.1/OpenSLES_OpenHarmony.h", + "api/1.0.1/OpenSLES_Platform.h", + ] +} + +ohos_ndk_library("libOpenSLES_ndk") { + output_name = "OpenSLES" + output_extension = "so" + ndk_description_file = "./openSLES.ndk.json" + system_capability = "SystemCapability.Multimedia.Audio.Core" + system_capability_headers = [ + "SLES/OpenSLES.h", + "SLES/OpenSLES_Platform.h", + "SLES/OpenSLES_OpenHarmony.h", + ] +} diff --git a/third_party/openSLES/api/1.0.1/OpenSLES.h b/third_party/openSLES/api/1.0.1/OpenSLES.h index 7dbdbd32fdcd03e2a230f7b456e6c8671fa2314d..b4f319f52c8d3e279ac9a48a66929ae70cdd038e 100644 --- a/third_party/openSLES/api/1.0.1/OpenSLES.h +++ b/third_party/openSLES/api/1.0.1/OpenSLES.h @@ -1,2774 +1,2774 @@ -/* - * Copyright (c) 2007-2009 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES.h - OpenSL ES version 1.0.1 - * - */ - -/****************************************************************************/ -/* NOTE: This file is a standard OpenSL ES header file and should not be */ -/* modified in any way. */ -/****************************************************************************/ - -#ifndef OPENSL_ES_H_ -#define OPENSL_ES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "OpenSLES_Platform.h" - - -/*****************************************************************************/ -/* Common types, structures, and defines */ -/*****************************************************************************/ - -#ifndef _KHRONOS_KEYS_ -#define _KHRONOS_KEYS_ - -#define KHRONOS_TITLE "KhronosTitle" -#define KHRONOS_ALBUM "KhronosAlbum" -#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" -#define KHRONOS_ARTIST "KhronosArtist" -#define KHRONOS_GENRE "KhronosGenre" -#define KHRONOS_YEAR "KhronosYear" -#define KHRONOS_COMMENT "KhronosComment" -#define KHRONOS_ARTIST_URL "KhronosArtistURL" -#define KHRONOS_CONTENT_URL "KhronosContentURL" -#define KHRONOS_RATING "KhronosRating" -#define KHRONOS_ALBUM_ART "KhronosAlbumArt" -#define KHRONOS_COPYRIGHT "KhronosCopyright" - -#endif - - -/* remap common types to SL types for clarity */ -typedef sl_int8_t SLint8; /* 8 bit signed integer */ -typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ -typedef sl_int16_t SLint16; /* 16 bit signed integer */ -typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ -typedef sl_int32_t SLint32; /* 32 bit signed integer */ -typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ - -typedef SLuint32 SLboolean; -#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) -#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) - -typedef SLuint8 SLchar; /* UTF-8 is to be used */ -typedef SLint16 SLmillibel; -typedef SLuint32 SLmillisecond; -typedef SLuint32 SLmilliHertz; -typedef SLint32 SLmillimeter; -typedef SLint32 SLmillidegree; -typedef SLint16 SLpermille; -typedef SLuint32 SLmicrosecond; -typedef SLuint32 SLresult; - -#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) -#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) - -#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) -#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) - -/** Interface ID defined as a UUID */ -typedef const struct SLInterfaceID_ { - SLuint32 time_low; - SLuint16 time_mid; - SLuint16 time_hi_and_version; - SLuint16 clock_seq; - SLuint8 node[6]; -} * SLInterfaceID; - -/* Forward declaration for the object interface */ -struct SLObjectItf_; - -typedef const struct SLObjectItf_ * const * SLObjectItf; - -/* Objects ID's */ - -#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) -#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) -#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) -#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) -#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) -#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) -#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) -#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) -#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) -#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) - - -/* SL Profiles */ - -#define SL_PROFILES_PHONE ((SLuint16) 0x0001) -#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) -#define SL_PROFILES_GAME ((SLuint16) 0x0004) - -/* Types of voices supported by the system */ - -#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) -#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) -#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) -#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) - -/* Convenient macros representing various different priority levels, for use with the SetPriority method */ - -#define SL_PRIORITY_LOWEST ((SLint32) (-0x7FFFFFFF-1)) -#define SL_PRIORITY_VERYLOW ((SLint32) -0x60000000) -#define SL_PRIORITY_LOW ((SLint32) -0x40000000) -#define SL_PRIORITY_BELOWNORMAL ((SLint32) -0x20000000) -#define SL_PRIORITY_NORMAL ((SLint32) 0x00000000) -#define SL_PRIORITY_ABOVENORMAL ((SLint32) 0x20000000) -#define SL_PRIORITY_HIGH ((SLint32) 0x40000000) -#define SL_PRIORITY_VERYHIGH ((SLint32) 0x60000000) -#define SL_PRIORITY_HIGHEST ((SLint32) 0x7FFFFFFF) - - -/** These macros list the various sample formats that are possible on audio input and output devices. */ - -#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) -#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) -#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) -#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) -#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) -#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) - - -/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ - -#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) -#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) -#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) -#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) -#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) -#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) -#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) -#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) -#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) -#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) -#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) -#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) -#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) - -#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) -#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) -#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) -#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) -#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) -#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) -#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) -#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) -#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) -#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) -#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) -#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) -#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) -#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) -#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) -#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) -#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) -#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) - - -/*****************************************************************************/ -/* Errors */ -/* */ -/*****************************************************************************/ - -#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) -#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) -#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) -#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) -#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) -#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) -#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) -#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) -#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) -#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) -#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) -#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) -#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) -#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) -#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) -#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) -#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) - - -/* Object state definitions */ - -#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) -#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) -#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) - -/* Object event definitions */ - -#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) -#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) -#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) -#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) - - -/*****************************************************************************/ -/* Interface definitions */ -/*****************************************************************************/ - -/** NULL Interface */ - -extern const SLInterfaceID SL_IID_NULL; - -/*---------------------------------------------------------------------------*/ -/* Data Source and Data Sink Structures */ -/*---------------------------------------------------------------------------*/ - -/** Data locator macros */ -#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) -#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) -#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) -#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) -#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) -#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) -#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) -#define SL_DATALOCATOR_RESERVED8 ((SLuint32) 0x00000008) - - - -/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ -typedef struct SLDataLocator_URI_ { - SLuint32 locatorType; - SLchar * URI; -} SLDataLocator_URI; - -/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ -typedef struct SLDataLocator_Address_ { - SLuint32 locatorType; - void *pAddress; - SLuint32 length; -} SLDataLocator_Address; - -/** IODevice-types */ -#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) -#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) -#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) -#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) -#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) - -/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ -typedef struct SLDataLocator_IODevice_ { - SLuint32 locatorType; - SLuint32 deviceType; - SLuint32 deviceID; - SLObjectItf device; -} SLDataLocator_IODevice; - -/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ -typedef struct SLDataLocator_OutputMix { - SLuint32 locatorType; - SLObjectItf outputMix; -} SLDataLocator_OutputMix; - - -/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ -typedef struct SLDataLocator_BufferQueue { - SLuint32 locatorType; - SLuint32 numBuffers; -} SLDataLocator_BufferQueue; - -/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ -typedef struct SLDataLocator_MIDIBufferQueue { - SLuint32 locatorType; - SLuint32 tpqn; - SLuint32 numBuffers; -} SLDataLocator_MIDIBufferQueue; - -/** Data format defines */ -#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) -#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) -#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) - - -/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ -typedef struct SLDataFormat_MIME_ { - SLuint32 formatType; - SLchar * mimeType; - SLuint32 containerType; -} SLDataFormat_MIME; - -/* Byte order of a block of 16- or 32-bit data */ -#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) -#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) - -/* Container type */ -#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) -#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) -#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) -#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) -#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) -#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) -#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) -#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) -#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) -#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) -#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) -#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) -#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) -#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) -#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) -#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) -#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) -#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) -#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) -#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) -#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) -#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) -#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) -#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) -#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) -#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) -#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) -#define SL_CONTAINERTYPE_OGG ((SLuint32) 0x0000001D) - - -/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ -typedef struct SLDataFormat_PCM_ { - SLuint32 formatType; - SLuint32 numChannels; - SLuint32 samplesPerSec; - SLuint32 bitsPerSample; - SLuint32 containerSize; - SLuint32 channelMask; - SLuint32 endianness; -} SLDataFormat_PCM; - -typedef struct SLDataSource_ { - void *pLocator; - void *pFormat; -} SLDataSource; - - -typedef struct SLDataSink_ { - void *pLocator; - void *pFormat; -} SLDataSink; - - - - - - -/*---------------------------------------------------------------------------*/ -/* Standard Object Interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_OBJECT; - -/** Object callback */ - - -typedef void (SLAPIENTRY *slObjectCallback) ( - SLObjectItf caller, - const void * pContext, - SLuint32 event, - SLresult result, - SLuint32 param, - void *pInterface -); - - -struct SLObjectItf_ { - SLresult (*Realize) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*Resume) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*GetState) ( - SLObjectItf self, - SLuint32 * pState - ); - SLresult (*GetInterface) ( - SLObjectItf self, - const SLInterfaceID iid, - void * pInterface - ); - SLresult (*RegisterCallback) ( - SLObjectItf self, - slObjectCallback callback, - void * pContext - ); - void (*AbortAsyncOperation) ( - SLObjectItf self - ); - void (*Destroy) ( - SLObjectItf self - ); - SLresult (*SetPriority) ( - SLObjectItf self, - SLint32 priority, - SLboolean preemptable - ); - SLresult (*GetPriority) ( - SLObjectItf self, - SLint32 *pPriority, - SLboolean *pPreemptable - ); - SLresult (*SetLossOfControlInterfaces) ( - SLObjectItf self, - SLint16 numInterfaces, - SLInterfaceID * pInterfaceIDs, - SLboolean enabled - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio IO Device capabilities interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) -#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) -#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) -#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) -#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) - - -#define SL_DEVCONNECTION_INTEGRATED ((SLint16) 0x0001) -#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLint16) 0x0100) -#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLint16) 0x0200) -#define SL_DEVCONNECTION_NETWORK ((SLint16) 0x0400) - - -#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) -#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) -#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) -#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) -#define SL_DEVLOCATION_REMOTE ((SLuint16) 0x0005) -/* Note: SL_DEVLOCATION_RESLTE is deprecated, use SL_DEVLOCATION_REMOTE instead. */ -#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) - - -#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) -#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) -#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) - - -typedef struct SLAudioInputDescriptor_ { - SLchar *deviceName; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *samplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioInputDescriptor; - - -typedef struct SLAudioOutputDescriptor_ { - SLchar *pDeviceName; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *samplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioOutputDescriptor; - - - -extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; - -struct SLAudioIODeviceCapabilitiesItf_; -typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; - - -typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLint32 numInputs, - SLboolean isNew -); - - -typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLint32 numOutputs, - SLboolean isNew -); - -typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLboolean isOutput, - SLint32 numDevices -); - - -struct SLAudioIODeviceCapabilitiesItf_ { - SLresult (*GetAvailableAudioInputs)( - SLAudioIODeviceCapabilitiesItf self, - SLint32 *pNumInputs, - SLuint32 *pInputDeviceIDs - ); - SLresult (*QueryAudioInputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioInputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioInputsChangedCallback callback, - void *pContext - ); - SLresult (*GetAvailableAudioOutputs)( - SLAudioIODeviceCapabilitiesItf self, - SLint32 *pNumOutputs, - SLuint32 *pOutputDeviceIDs - ); - SLresult (*QueryAudioOutputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioOutputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioOutputsChangedCallback callback, - void *pContext - ); - SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slDefaultDeviceIDMapChangedCallback callback, - void *pContext - ); - SLresult (*GetAssociatedAudioInputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLint32 *pNumAudioInputs, - SLuint32 *pAudioInputDeviceIDs - ); - SLresult (*GetAssociatedAudioOutputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLint32 *pNumAudioOutputs, - SLuint32 *pAudioOutputDeviceIDs - ); - SLresult (*GetDefaultAudioDevices) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 defaultDeviceID, - SLint32 *pNumAudioDevices, - SLuint32 *pAudioDeviceIDs - ); - SLresult (*QuerySampleFormatsSupported)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLmilliHertz samplingRate, - SLint32 *pSampleFormats, - SLint32 *pNumOfSampleFormats - ); -}; - - - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the LED array IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLLEDDescriptor_ { - SLuint8 ledCount; - SLuint8 primaryLED; - SLuint32 colorMask; -} SLLEDDescriptor; - - -/*---------------------------------------------------------------------------*/ -/* LED Array interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLHSL_ { - SLmillidegree hue; - SLpermille saturation; - SLpermille lightness; -} SLHSL; - - -extern const SLInterfaceID SL_IID_LED; - -struct SLLEDArrayItf_; -typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; - -struct SLLEDArrayItf_ { - SLresult (*ActivateLEDArray) ( - SLLEDArrayItf self, - SLuint32 lightMask - ); - SLresult (*IsLEDArrayActivated) ( - SLLEDArrayItf self, - SLuint32 *lightMask - ); - SLresult (*SetColor) ( - SLLEDArrayItf self, - SLuint8 index, - const SLHSL *color - ); - SLresult (*GetColor) ( - SLLEDArrayItf self, - SLuint8 index, - SLHSL *color - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the Vibra IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVibraDescriptor_ { - SLboolean supportsFrequency; - SLboolean supportsIntensity; - SLmilliHertz minFrequency; - SLmilliHertz maxFrequency; -} SLVibraDescriptor; - - - -/*---------------------------------------------------------------------------*/ -/* Vibra interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VIBRA; - - -struct SLVibraItf_; -typedef const struct SLVibraItf_ * const * SLVibraItf; - -struct SLVibraItf_ { - SLresult (*Vibrate) ( - SLVibraItf self, - SLboolean vibrate - ); - SLresult (*IsVibrating) ( - SLVibraItf self, - SLboolean *pVibrating - ); - SLresult (*SetFrequency) ( - SLVibraItf self, - SLmilliHertz frequency - ); - SLresult (*GetFrequency) ( - SLVibraItf self, - SLmilliHertz *pFrequency - ); - SLresult (*SetIntensity) ( - SLVibraItf self, - SLpermille intensity - ); - SLresult (*GetIntensity) ( - SLVibraItf self, - SLpermille *pIntensity - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data extraction related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) -#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) -#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) -#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) -#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) -#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) -#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) -#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) -#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) -#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) -#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) -#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) -#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) -#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) -#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) -#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) -#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) -#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) -#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) -#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) -#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) -#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) -#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) -#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) -#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) -#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) -#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) -#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) -#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) -#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) -#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) -#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) - - -#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) -#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) -#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) - - -typedef struct SLMetadataInfo_ { - SLuint32 size; - SLuint32 encoding; - SLchar langCountry[16]; - SLuint8 data[1]; -} SLMetadataInfo; - -extern const SLInterfaceID SL_IID_METADATAEXTRACTION; - -struct SLMetadataExtractionItf_; -typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; - - -struct SLMetadataExtractionItf_ { - SLresult (*GetItemCount) ( - SLMetadataExtractionItf self, - SLuint32 *pItemCount - ); - SLresult (*GetKeySize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pKeySize - ); - SLresult (*GetKey) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 keySize, - SLMetadataInfo *pKey - ); - SLresult (*GetValueSize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pValueSize - ); - SLresult (*GetValue) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 valueSize, - SLMetadataInfo *pValue - ); - SLresult (*AddKeyFilter) ( - SLMetadataExtractionItf self, - SLuint32 keySize, - const void *pKey, - SLuint32 keyEncoding, - const SLchar *pValueLangCountry, - SLuint32 valueEncoding, - SLuint8 filterMask - ); - SLresult (*ClearKeyFilter) ( - SLMetadataExtractionItf self - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data traversal related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) -#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) - - -#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) -#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) -#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) - -#define SL_NODE_PARENT 0xFFFFFFFF - -extern const SLInterfaceID SL_IID_METADATATRAVERSAL; - -struct SLMetadataTraversalItf_; -typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; - -struct SLMetadataTraversalItf_ { - SLresult (*SetMode) ( - SLMetadataTraversalItf self, - SLuint32 mode - ); - SLresult (*GetChildCount) ( - SLMetadataTraversalItf self, - SLuint32 *pCount - ); - SLresult (*GetChildMIMETypeSize) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLuint32 *pSize - ); - SLresult (*GetChildInfo) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLint32 *pNodeID, - SLuint32 *pType, - SLuint32 size, - SLchar *pMimeType - ); - SLresult (*SetActiveNode) ( - SLMetadataTraversalItf self, - SLuint32 index - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Dynamic Source types and interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_DYNAMICSOURCE; - -struct SLDynamicSourceItf_; -typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; - -struct SLDynamicSourceItf_ { - SLresult (*SetSource) ( - SLDynamicSourceItf self, - SLDataSource *pDataSource - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Output Mix interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_OUTPUTMIX; - -struct SLOutputMixItf_; -typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; - -typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( - SLOutputMixItf caller, - void *pContext -); - - -struct SLOutputMixItf_ { - SLresult (*GetDestinationOutputDeviceIDs) ( - SLOutputMixItf self, - SLint32 *pNumDevices, - SLuint32 *pDeviceIDs - ); - SLresult (*RegisterDeviceChangeCallback) ( - SLOutputMixItf self, - slMixDeviceChangeCallback callback, - void *pContext - ); - SLresult (*ReRoute)( - SLOutputMixItf self, - SLint32 numOutputDevices, - SLuint32 *pOutputDeviceIDs - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Playback interface */ -/*---------------------------------------------------------------------------*/ - -/** Playback states */ -#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) - -/** Play events **/ -#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) -#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) - -#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) - - -extern const SLInterfaceID SL_IID_PLAY; - -/** Playback interface methods */ - -struct SLPlayItf_; -typedef const struct SLPlayItf_ * const * SLPlayItf; - -typedef void (SLAPIENTRY *slPlayCallback) ( - SLPlayItf caller, - void *pContext, - SLuint32 event -); - -struct SLPlayItf_ { - SLresult (*SetPlayState) ( - SLPlayItf self, - SLuint32 state - ); - SLresult (*GetPlayState) ( - SLPlayItf self, - SLuint32 *pState - ); - SLresult (*GetDuration) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*GetPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLPlayItf self, - slPlayCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLPlayItf self - ); - SLresult (*GetMarkerPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Prefetch status interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) -#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) - -#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) -#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) -#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) - - -extern const SLInterfaceID SL_IID_PREFETCHSTATUS; - - -/** Prefetch status interface methods */ - -struct SLPrefetchStatusItf_; -typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; - -typedef void (SLAPIENTRY *slPrefetchCallback) ( - SLPrefetchStatusItf caller, - void *pContext, - SLuint32 event -); - -struct SLPrefetchStatusItf_ { - SLresult (*GetPrefetchStatus) ( - SLPrefetchStatusItf self, - SLuint32 *pStatus - ); - SLresult (*GetFillLevel) ( - SLPrefetchStatusItf self, - SLpermille *pLevel - ); - SLresult (*RegisterCallback) ( - SLPrefetchStatusItf self, - slPrefetchCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille period - ); - SLresult (*GetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille *pPeriod - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Playback Rate interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) -#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) -#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) -#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) -#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) -#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) - - -extern const SLInterfaceID SL_IID_PLAYBACKRATE; - -struct SLPlaybackRateItf_; -typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; - -struct SLPlaybackRateItf_ { - SLresult (*SetRate)( - SLPlaybackRateItf self, - SLpermille rate - ); - SLresult (*GetRate)( - SLPlaybackRateItf self, - SLpermille *pRate - ); - SLresult (*SetPropertyConstraints)( - SLPlaybackRateItf self, - SLuint32 constraints - ); - SLresult (*GetProperties)( - SLPlaybackRateItf self, - SLuint32 *pProperties - ); - SLresult (*GetCapabilitiesOfRate)( - SLPlaybackRateItf self, - SLpermille rate, - SLuint32 *pCapabilities - ); - SLresult (*GetRateRange) ( - SLPlaybackRateItf self, - SLuint8 index, - SLpermille *pMinRate, - SLpermille *pMaxRate, - SLpermille *pStepSize, - SLuint32 *pCapabilities - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Seek Interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_SEEKMODE_FAST ((SLuint32) 0x0001) -#define SL_SEEKMODE_ACCURATE ((SLuint32) 0x0002) - -extern const SLInterfaceID SL_IID_SEEK; - -struct SLSeekItf_; -typedef const struct SLSeekItf_ * const * SLSeekItf; - -struct SLSeekItf_ { - SLresult (*SetPosition)( - SLSeekItf self, - SLmillisecond pos, - SLuint32 seekMode - ); - SLresult (*SetLoop)( - SLSeekItf self, - SLboolean loopEnable, - SLmillisecond startPos, - SLmillisecond endPos - ); - SLresult (*GetLoop)( - SLSeekItf self, - SLboolean *pLoopEnabled, - SLmillisecond *pStartPos, - SLmillisecond *pEndPos - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Standard Recording Interface */ -/*---------------------------------------------------------------------------*/ - -/** Recording states */ -#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) - - -/** Record event **/ -#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) -#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) -/* Note: SL_RECORDEVENT_BUFFER_INSUFFICIENT is deprecated, use SL_RECORDEVENT_BUFFER_FULL instead. */ -#define SL_RECORDEVENT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000020) -#define SL_RECORDEVENT_BUFFER_FULL ((SLuint32) 0x00000020) - - -extern const SLInterfaceID SL_IID_RECORD; - -struct SLRecordItf_; -typedef const struct SLRecordItf_ * const * SLRecordItf; - -typedef void (SLAPIENTRY *slRecordCallback) ( - SLRecordItf caller, - void *pContext, - SLuint32 event -); - -/** Recording interface methods */ -struct SLRecordItf_ { - SLresult (*SetRecordState) ( - SLRecordItf self, - SLuint32 state - ); - SLresult (*GetRecordState) ( - SLRecordItf self, - SLuint32 *pState - ); - SLresult (*SetDurationLimit) ( - SLRecordItf self, - SLmillisecond msec - ); - SLresult (*GetPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLRecordItf self, - slRecordCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLRecordItf self - ); - SLresult (*GetMarkerPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Equalizer interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) - -extern const SLInterfaceID SL_IID_EQUALIZER; - -struct SLEqualizerItf_; -typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; - -struct SLEqualizerItf_ { - SLresult (*SetEnabled)( - SLEqualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLEqualizerItf self, - SLboolean *pEnabled - ); - SLresult (*GetNumberOfBands)( - SLEqualizerItf self, - SLuint16 *pAmount - ); - SLresult (*GetBandLevelRange)( - SLEqualizerItf self, - SLmillibel *pMin, - SLmillibel *pMax - ); - SLresult (*SetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel level - ); - SLresult (*GetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel *pLevel - ); - SLresult (*GetCenterFreq)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pCenter - ); - SLresult (*GetBandFreqRange)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pMin, - SLmilliHertz *pMax - ); - SLresult (*GetBand)( - SLEqualizerItf self, - SLmilliHertz frequency, - SLuint16 *pBand - ); - SLresult (*GetCurrentPreset)( - SLEqualizerItf self, - SLuint16 *pPreset - ); - SLresult (*UsePreset)( - SLEqualizerItf self, - SLuint16 index - ); - SLresult (*GetNumberOfPresets)( - SLEqualizerItf self, - SLuint16 *pNumPresets - ); - SLresult (*GetPresetName)( - SLEqualizerItf self, - SLuint16 index, - const SLchar ** ppName - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Volume Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_VOLUME; - -struct SLVolumeItf_; -typedef const struct SLVolumeItf_ * const * SLVolumeItf; - -struct SLVolumeItf_ { - SLresult (*SetVolumeLevel) ( - SLVolumeItf self, - SLmillibel level - ); - SLresult (*GetVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pLevel - ); - SLresult (*GetMaxVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pMaxLevel - ); - SLresult (*SetMute) ( - SLVolumeItf self, - SLboolean mute - ); - SLresult (*GetMute) ( - SLVolumeItf self, - SLboolean *pMute - ); - SLresult (*EnableStereoPosition) ( - SLVolumeItf self, - SLboolean enable - ); - SLresult (*IsEnabledStereoPosition) ( - SLVolumeItf self, - SLboolean *pEnable - ); - SLresult (*SetStereoPosition) ( - SLVolumeItf self, - SLpermille stereoPosition - ); - SLresult (*GetStereoPosition) ( - SLVolumeItf self, - SLpermille *pStereoPosition - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Device Volume Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_DEVICEVOLUME; - -struct SLDeviceVolumeItf_; -typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; - -struct SLDeviceVolumeItf_ { - SLresult (*GetVolumeScale) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pMinValue, - SLint32 *pMaxValue, - SLboolean *pIsMillibelScale - ); - SLresult (*SetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 volume - ); - SLresult (*GetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pVolume - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Buffer Queue Interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_BUFFERQUEUE; - -struct SLBufferQueueItf_; -typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; - -typedef void (SLAPIENTRY *slBufferQueueCallback)( - SLBufferQueueItf caller, - void *pContext -); - -/** Buffer queue state **/ - -typedef struct SLBufferQueueState_ { - SLuint32 count; - SLuint32 playIndex; -} SLBufferQueueState; - - -struct SLBufferQueueItf_ { - SLresult (*Enqueue) ( - SLBufferQueueItf self, - const void *pBuffer, - SLuint32 size - ); - SLresult (*Clear) ( - SLBufferQueueItf self - ); - SLresult (*GetState) ( - SLBufferQueueItf self, - SLBufferQueueState *pState - ); - SLresult (*RegisterCallback) ( - SLBufferQueueItf self, - slBufferQueueCallback callback, - void* pContext - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* PresetReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) -#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) -#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) -#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) -#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) -#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) -#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) - - -extern const SLInterfaceID SL_IID_PRESETREVERB; - -struct SLPresetReverbItf_; -typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; - -struct SLPresetReverbItf_ { - SLresult (*SetPreset) ( - SLPresetReverbItf self, - SLuint16 preset - ); - SLresult (*GetPreset) ( - SLPresetReverbItf self, - SLuint16 *pPreset - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* EnvironmentalReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ - { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ - { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ - { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ - { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ - { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ - { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ - { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ - { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ - { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ - { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ - { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ - { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ - { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ - { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ - { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ - { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ - { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ - { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ - { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ - { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ - { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ - { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ - { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ - { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ - { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ - { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ - { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ - { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ - { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ - { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } - - -typedef struct SLEnvironmentalReverbSettings_ { - SLmillibel roomLevel; - SLmillibel roomHFLevel; - SLmillisecond decayTime; - SLpermille decayHFRatio; - SLmillibel reflectionsLevel; - SLmillisecond reflectionsDelay; - SLmillibel reverbLevel; - SLmillisecond reverbDelay; - SLpermille diffusion; - SLpermille density; -} SLEnvironmentalReverbSettings; - - - - -extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; - - -struct SLEnvironmentalReverbItf_; -typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; - -struct SLEnvironmentalReverbItf_ { - SLresult (*SetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel room - ); - SLresult (*GetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoom - ); - SLresult (*SetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel roomHF - ); - SLresult (*GetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoomHF - ); - SLresult (*SetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond decayTime - ); - SLresult (*GetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pDecayTime - ); - SLresult (*SetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille decayHFRatio - ); - SLresult (*GetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille *pDecayHFRatio - ); - SLresult (*SetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reflectionsLevel - ); - SLresult (*GetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReflectionsLevel - ); - SLresult (*SetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reflectionsDelay - ); - SLresult (*GetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReflectionsDelay - ); - SLresult (*SetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reverbLevel - ); - SLresult (*GetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReverbLevel - ); - SLresult (*SetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reverbDelay - ); - SLresult (*GetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReverbDelay - ); - SLresult (*SetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille diffusion - ); - SLresult (*GetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille *pDiffusion - ); - SLresult (*SetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille density - ); - SLresult (*GetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille *pDensity - ); - SLresult (*SetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - const SLEnvironmentalReverbSettings *pProperties - ); - SLresult (*GetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - SLEnvironmentalReverbSettings *pProperties - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Effects Send Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_EFFECTSEND; - -struct SLEffectSendItf_; -typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; - -struct SLEffectSendItf_ { - SLresult (*EnableEffectSend) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLboolean enable, - SLmillibel initialLevel - ); - SLresult (*IsEnabled) ( - SLEffectSendItf self, - const void * pAuxEffect, - SLboolean *pEnable - ); - SLresult (*SetDirectLevel) ( - SLEffectSendItf self, - SLmillibel directLevel - ); - SLresult (*GetDirectLevel) ( - SLEffectSendItf self, - SLmillibel *pDirectLevel - ); - SLresult (*SetSendLevel) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel sendLevel - ); - SLresult (*GetSendLevel)( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel *pSendLevel - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Grouping Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DGROUPING; - - -struct SL3DGroupingItf_ ; -typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; - -struct SL3DGroupingItf_ { - SLresult (*Set3DGroup) ( - SL3DGroupingItf self, - SLObjectItf group - ); - SLresult (*Get3DGroup) ( - SL3DGroupingItf self, - SLObjectItf *pGroup - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Commit Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DCOMMIT; - -struct SL3DCommitItf_; -typedef const struct SL3DCommitItf_* const * SL3DCommitItf; - -struct SL3DCommitItf_ { - SLresult (*Commit) ( - SL3DCommitItf self - ); - SLresult (*SetDeferred) ( - SL3DCommitItf self, - SLboolean deferred - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Location Interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVec3D_ { - SLint32 x; - SLint32 y; - SLint32 z; -} SLVec3D; - -extern const SLInterfaceID SL_IID_3DLOCATION; - -struct SL3DLocationItf_; -typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; - -struct SL3DLocationItf_ { - SLresult (*SetLocationCartesian) ( - SL3DLocationItf self, - const SLVec3D *pLocation - ); - SLresult (*SetLocationSpherical) ( - SL3DLocationItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter distance - ); - SLresult (*Move) ( - SL3DLocationItf self, - const SLVec3D *pMovement - ); - SLresult (*GetLocationCartesian) ( - SL3DLocationItf self, - SLVec3D *pLocation - ); - SLresult (*SetOrientationVectors) ( - SL3DLocationItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*SetOrientationAngles) ( - SL3DLocationItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*Rotate) ( - SL3DLocationItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DLocationItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Doppler Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DDOPPLER; - -struct SL3DDopplerItf_; -typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; - -struct SL3DDopplerItf_ { - SLresult (*SetVelocityCartesian) ( - SL3DDopplerItf self, - const SLVec3D *pVelocity - ); - SLresult (*SetVelocitySpherical) ( - SL3DDopplerItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter speed - ); - SLresult (*GetVelocityCartesian) ( - SL3DDopplerItf self, - SLVec3D *pVelocity - ); - SLresult (*SetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille dopplerFactor - ); - SLresult (*GetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille *pDopplerFactor - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Source Interface and associated defines */ -/* --------------------------------------------------------------------------*/ - -#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) -#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) - - -extern const SLInterfaceID SL_IID_3DSOURCE; - -struct SL3DSourceItf_; -typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; - -struct SL3DSourceItf_ { - SLresult (*SetHeadRelative) ( - SL3DSourceItf self, - SLboolean headRelative - ); - SLresult (*GetHeadRelative) ( - SL3DSourceItf self, - SLboolean *pHeadRelative - ); - SLresult (*SetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter minDistance, - SLmillimeter maxDistance - ); - SLresult (*GetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter *pMinDistance, - SLmillimeter *pMaxDistance - ); - SLresult (*SetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean mute - ); - SLresult (*GetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean *pMute - ); - SLresult (*SetRolloffFactor) ( - SL3DSourceItf self, - SLpermille rolloffFactor - ); - SLresult (*GetRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRolloffFactor - ); - SLresult (*SetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille roomRolloffFactor - ); - SLresult (*GetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRoomRolloffFactor - ); - SLresult (*SetRolloffModel) ( - SL3DSourceItf self, - SLuint8 model - ); - SLresult (*GetRolloffModel) ( - SL3DSourceItf self, - SLuint8 *pModel - ); - SLresult (*SetCone) ( - SL3DSourceItf self, - SLmillidegree innerAngle, - SLmillidegree outerAngle, - SLmillibel outerLevel - ); - SLresult (*GetCone) ( - SL3DSourceItf self, - SLmillidegree *pInnerAngle, - SLmillidegree *pOuterAngle, - SLmillibel *pOuterLevel - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Macroscopic Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_3DMACROSCOPIC; - -struct SL3DMacroscopicItf_; -typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; - -struct SL3DMacroscopicItf_ { - SLresult (*SetSize) ( - SL3DMacroscopicItf self, - SLmillimeter width, - SLmillimeter height, - SLmillimeter depth - ); - SLresult (*GetSize) ( - SL3DMacroscopicItf self, - SLmillimeter *pWidth, - SLmillimeter *pHeight, - SLmillimeter *pDepth - ); - SLresult (*SetOrientationAngles) ( - SL3DMacroscopicItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*SetOrientationVectors) ( - SL3DMacroscopicItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*Rotate) ( - SL3DMacroscopicItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DMacroscopicItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Mute Solo Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MUTESOLO; - -struct SLMuteSoloItf_; -typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; - -struct SLMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pSolo - ); - SLresult (*GetNumChannels) ( - SLMuteSoloItf self, - SLuint8 *pNumChannels - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Dynamic Interface Management Interface and associated types and macros */ -/* --------------------------------------------------------------------------*/ - -#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) - - - - -extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; - -struct SLDynamicInterfaceManagementItf_; -typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; - -typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( - SLDynamicInterfaceManagementItf caller, - void * pContext, - SLuint32 event, - SLresult result, - const SLInterfaceID iid -); - - -struct SLDynamicInterfaceManagementItf_ { - SLresult (*AddInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RemoveInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid - ); - SLresult (*ResumeInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RegisterCallback) ( - SLDynamicInterfaceManagementItf self, - slDynamicInterfaceManagementCallback callback, - void * pContext - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Midi Message Interface and associated types */ -/* --------------------------------------------------------------------------*/ - -#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) -#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) -#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) -#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) -#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) -#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) -#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) - - -extern const SLInterfaceID SL_IID_MIDIMESSAGE; - -struct SLMIDIMessageItf_; -typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; - -typedef void (SLAPIENTRY *slMetaEventCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 type, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -typedef void (SLAPIENTRY *slMIDIMessageCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 statusByte, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -struct SLMIDIMessageItf_ { - SLresult (*SendMessage) ( - SLMIDIMessageItf self, - const SLuint8 *data, - SLuint32 length - ); - SLresult (*RegisterMetaEventCallback) ( - SLMIDIMessageItf self, - slMetaEventCallback callback, - void *pContext - ); - SLresult (*RegisterMIDIMessageCallback) ( - SLMIDIMessageItf self, - slMIDIMessageCallback callback, - void *pContext - ); - SLresult (*AddMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self, - SLuint32 messageType - ); - SLresult (*ClearMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Mute Solo interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDIMUTESOLO; - -struct SLMIDIMuteSoloItf_; -typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; - -struct SLMIDIMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pSolo - ); - SLresult (*GetTrackCount) ( - SLMIDIMuteSoloItf self, - SLuint16 *pCount - ); - SLresult (*SetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean mute - ); - SLresult (*GetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pMute - ); - SLresult (*SetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean solo - ); - SLresult (*GetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pSolo - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Tempo interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDITEMPO; - -struct SLMIDITempoItf_; -typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; - -struct SLMIDITempoItf_ { - SLresult (*SetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 tpqn - ); - SLresult (*GetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 *pTpqn - ); - SLresult (*SetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond uspqn - ); - SLresult (*GetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond *uspqn - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Time interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDITIME; - -struct SLMIDITimeItf_; -typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; - -struct SLMIDITimeItf_ { - SLresult (*GetDuration) ( - SLMIDITimeItf self, - SLuint32 *pDuration - ); - SLresult (*SetPosition) ( - SLMIDITimeItf self, - SLuint32 position - ); - SLresult (*GetPosition) ( - SLMIDITimeItf self, - SLuint32 *pPosition - ); - SLresult (*SetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 startTick, - SLuint32 numTicks - ); - SLresult (*GetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 *pStartTick, - SLuint32 *pNumTicks - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Decoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/*Audio Codec related defines*/ - -#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) -#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) - -#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) -#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) -#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) -#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) -#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) -#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) -#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) -#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) - -#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) - -#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) -#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) -#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) -#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) - -#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) - -#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) - -#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) -#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) -#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) - -#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) -#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) - -#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) -#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) - -#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) - -#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) - -typedef struct SLAudioCodecDescriptor_ { - SLuint32 maxChannels; - SLuint32 minBitsPerSample; - SLuint32 maxBitsPerSample; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *pSampleRatesSupported; - SLuint32 numSampleRatesSupported; - SLuint32 minBitRate; - SLuint32 maxBitRate; - SLboolean isBitrateRangeContinuous; - SLuint32 *pBitratesSupported; - SLuint32 numBitratesSupported; - SLuint32 profileSetting; - SLuint32 modeSetting; -} SLAudioCodecDescriptor; - -/*Structure used to retrieve the profile and level settings supported by an audio encoder */ - -typedef struct SLAudioCodecProfileMode_ { - SLuint32 profileSetting; - SLuint32 modeSetting; -} SLAudioCodecProfileMode; - -extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; - -struct SLAudioDecoderCapabilitiesItf_; -typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; - -struct SLAudioDecoderCapabilitiesItf_ { - SLresult (*GetAudioDecoders) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 * pNumDecoders , - SLuint32 *pDecoderIds - ); - SLresult (*GetAudioDecoderCapabilities) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 decoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor *pDescriptor - ); -}; - - - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/* Structure used when setting audio encoding parameters */ - -typedef struct SLAudioEncoderSettings_ { - SLuint32 encoderId; - SLuint32 channelsIn; - SLuint32 channelsOut; - SLmilliHertz sampleRate; - SLuint32 bitRate; - SLuint32 bitsPerSample; - SLuint32 rateControl; - SLuint32 profileSetting; - SLuint32 levelSetting; - SLuint32 channelMode; - SLuint32 streamFormat; - SLuint32 encodeOptions; - SLuint32 blockAlignment; -} SLAudioEncoderSettings; - -extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; - -struct SLAudioEncoderCapabilitiesItf_; -typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; - -struct SLAudioEncoderCapabilitiesItf_ { - SLresult (*GetAudioEncoders) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 *pNumEncoders , - SLuint32 *pEncoderIds - ); - SLresult (*GetAudioEncoderCapabilities) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 encoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor * pDescriptor - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_AUDIOENCODER; - -struct SLAudioEncoderItf_; -typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; - -struct SLAudioEncoderItf_ { - SLresult (*SetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); - SLresult (*GetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Bass Boost Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_BASSBOOST; - -struct SLBassBoostItf_; -typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; - -struct SLBassBoostItf_ { - SLresult (*SetEnabled)( - SLBassBoostItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLBassBoostItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLBassBoostItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLBassBoostItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLBassBoostItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Pitch Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_PITCH; - -struct SLPitchItf_; -typedef const struct SLPitchItf_ * const * SLPitchItf; - -struct SLPitchItf_ { - SLresult (*SetPitch) ( - SLPitchItf self, - SLpermille pitch - ); - SLresult (*GetPitch) ( - SLPitchItf self, - SLpermille *pPitch - ); - SLresult (*GetPitchCapabilities) ( - SLPitchItf self, - SLpermille *pMinPitch, - SLpermille *pMaxPitch - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Rate Pitch Interface */ -/* RatePitchItf is an interface for controlling the rate a sound is played */ -/* back. A change in rate will cause a change in pitch. */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_RATEPITCH; - -struct SLRatePitchItf_; -typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; - -struct SLRatePitchItf_ { - SLresult (*SetRate) ( - SLRatePitchItf self, - SLpermille rate - ); - SLresult (*GetRate) ( - SLRatePitchItf self, - SLpermille *pRate - ); - SLresult (*GetRatePitchCapabilities) ( - SLRatePitchItf self, - SLpermille *pMinRate, - SLpermille *pMaxRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Virtualizer Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VIRTUALIZER; - -struct SLVirtualizerItf_; -typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; - -struct SLVirtualizerItf_ { - SLresult (*SetEnabled)( - SLVirtualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLVirtualizerItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLVirtualizerItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLVirtualizerItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLVirtualizerItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Visualization Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VISUALIZATION; - -struct SLVisualizationItf_; -typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; - -typedef void (SLAPIENTRY *slVisualizationCallback) ( - void *pContext, - const SLuint8 waveform[], - const SLuint8 fft[], - SLmilliHertz samplerate -); - -struct SLVisualizationItf_{ - SLresult (*RegisterVisualizationCallback)( - SLVisualizationItf self, - slVisualizationCallback callback, - void *pContext, - SLmilliHertz rate - ); - SLresult (*GetMaxRate)( - SLVisualizationItf self, - SLmilliHertz* pRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_ENGINE; - -struct SLEngineItf_; -typedef const struct SLEngineItf_ * const * SLEngineItf; - - -struct SLEngineItf_ { - - SLresult (*CreateLEDDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateVibraDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - SLDataSource *pAudioSrc, - SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioRecorder) ( - SLEngineItf self, - SLObjectItf * pRecorder, - SLDataSource *pAudioSrc, - SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMidiPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - SLDataSource *pMIDISrc, - SLDataSource *pBankSrc, - SLDataSink *pAudioOutput, - SLDataSink *pVibra, - SLDataSink *pLEDArray, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateListener) ( - SLEngineItf self, - SLObjectItf * pListener, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*Create3DGroup) ( - SLEngineItf self, - SLObjectItf * pGroup, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateOutputMix) ( - SLEngineItf self, - SLObjectItf * pMix, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMetadataExtractor) ( - SLEngineItf self, - SLObjectItf * pMetadataExtractor, - SLDataSource * pDataSource, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateExtensionObject) ( - SLEngineItf self, - SLObjectItf * pObject, - void * pParameters, - SLuint32 objectID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*QueryNumSupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 * pNumSupportedInterfaces - ); - SLresult (*QuerySupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 index, - SLInterfaceID * pInterfaceId - ); - SLresult (*QueryNumSupportedExtensions) ( - SLEngineItf self, - SLuint32 * pNumExtensions - ); - SLresult (*QuerySupportedExtension) ( - SLEngineItf self, - SLuint32 index, - SLchar * pExtensionName, - SLint16 * pNameLength - ); - SLresult (*IsExtensionSupported) ( - SLEngineItf self, - const SLchar * pExtensionName, - SLboolean * pSupported - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; - -struct SLEngineCapabilitiesItf_; -typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; - -struct SLEngineCapabilitiesItf_ { - SLresult (*QuerySupportedProfiles) ( - SLEngineCapabilitiesItf self, - SLuint16 *pProfilesSupported - ); - SLresult (*QueryAvailableVoices) ( - SLEngineCapabilitiesItf self, - SLuint16 voiceType, - SLint16 *pNumMaxVoices, - SLboolean *pIsAbsoluteMax, - SLint16 *pNumFreeVoices - ); - SLresult (*QueryNumberOfMIDISynthesizers) ( - SLEngineCapabilitiesItf self, - SLint16 *pNumMIDIsynthesizers - ); - SLresult (*QueryAPIVersion) ( - SLEngineCapabilitiesItf self, - SLint16 *pMajor, - SLint16 *pMinor, - SLint16 *pStep - ); - SLresult (*QueryLEDCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pLEDDeviceID, - SLLEDDescriptor *pDescriptor - ); - SLresult (*QueryVibraCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pVibraDeviceID, - SLVibraDescriptor *pDescriptor - ); - SLresult (*IsThreadSafe) ( - SLEngineCapabilitiesItf self, - SLboolean *pIsThreadSafe - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Thread Sync Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_THREADSYNC; - -struct SLThreadSyncItf_; -typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; - - -struct SLThreadSyncItf_ { - SLresult (*EnterCriticalSection) ( - SLThreadSyncItf self - ); - SLresult (*ExitCriticalSection) ( - SLThreadSyncItf self - ); -}; - - -/*****************************************************************************/ -/* SL engine constructor */ -/*****************************************************************************/ - -#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) -#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) - -typedef struct SLEngineOption_ { - SLuint32 feature; - SLuint32 data; -} SLEngineOption; - - -SLresult SLAPIENTRY slCreateEngine( - SLObjectItf *pEngine, - SLuint32 numOptions, - const SLEngineOption *pEngineOptions, - SLuint32 numInterfaces, - const SLInterfaceID *pInterfaceIds, - const SLboolean * pInterfaceRequired -); - -SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( - SLuint32 * pNumSupportedInterfaces -); - -SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( - SLuint32 index, - SLInterfaceID * pInterfaceId -); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* OPENSL_ES_H_ */ +/* + * Copyright (c) 2007-2009 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES.h - OpenSL ES version 1.0.1 + * + */ + +/****************************************************************************/ +/* NOTE: This file is a standard OpenSL ES header file and should not be */ +/* modified in any way. */ +/****************************************************************************/ + +#ifndef OPENSL_ES_H_ +#define OPENSL_ES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "OpenSLES_Platform.h" + + +/*****************************************************************************/ +/* Common types, structures, and defines */ +/*****************************************************************************/ + +#ifndef _KHRONOS_KEYS_ +#define _KHRONOS_KEYS_ + +#define KHRONOS_TITLE "KhronosTitle" +#define KHRONOS_ALBUM "KhronosAlbum" +#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" +#define KHRONOS_ARTIST "KhronosArtist" +#define KHRONOS_GENRE "KhronosGenre" +#define KHRONOS_YEAR "KhronosYear" +#define KHRONOS_COMMENT "KhronosComment" +#define KHRONOS_ARTIST_URL "KhronosArtistURL" +#define KHRONOS_CONTENT_URL "KhronosContentURL" +#define KHRONOS_RATING "KhronosRating" +#define KHRONOS_ALBUM_ART "KhronosAlbumArt" +#define KHRONOS_COPYRIGHT "KhronosCopyright" + +#endif + + +/* remap common types to SL types for clarity */ +typedef sl_int8_t SLint8; /* 8 bit signed integer */ +typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ +typedef sl_int16_t SLint16; /* 16 bit signed integer */ +typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ +typedef sl_int32_t SLint32; /* 32 bit signed integer */ +typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ + +typedef SLuint32 SLboolean; +#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) +#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) + +typedef SLuint8 SLchar; /* UTF-8 is to be used */ +typedef SLint16 SLmillibel; +typedef SLuint32 SLmillisecond; +typedef SLuint32 SLmilliHertz; +typedef SLint32 SLmillimeter; +typedef SLint32 SLmillidegree; +typedef SLint16 SLpermille; +typedef SLuint32 SLmicrosecond; +typedef SLuint32 SLresult; + +#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) +#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) + +#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) +#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) + +/** Interface ID defined as a UUID */ +typedef const struct SLInterfaceID_ { + SLuint32 time_low; + SLuint16 time_mid; + SLuint16 time_hi_and_version; + SLuint16 clock_seq; + SLuint8 node[6]; +} * SLInterfaceID; + +/* Forward declaration for the object interface */ +struct SLObjectItf_; + +typedef const struct SLObjectItf_ * const * SLObjectItf; + +/* Objects ID's */ + +#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) +#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) +#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) +#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) +#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) +#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) +#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) +#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) +#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) +#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) + + +/* SL Profiles */ + +#define SL_PROFILES_PHONE ((SLuint16) 0x0001) +#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) +#define SL_PROFILES_GAME ((SLuint16) 0x0004) + +/* Types of voices supported by the system */ + +#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) +#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) +#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) +#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) + +/* Convenient macros representing various different priority levels, for use with the SetPriority method */ + +#define SL_PRIORITY_LOWEST ((SLint32) (-0x7FFFFFFF-1)) +#define SL_PRIORITY_VERYLOW ((SLint32) -0x60000000) +#define SL_PRIORITY_LOW ((SLint32) -0x40000000) +#define SL_PRIORITY_BELOWNORMAL ((SLint32) -0x20000000) +#define SL_PRIORITY_NORMAL ((SLint32) 0x00000000) +#define SL_PRIORITY_ABOVENORMAL ((SLint32) 0x20000000) +#define SL_PRIORITY_HIGH ((SLint32) 0x40000000) +#define SL_PRIORITY_VERYHIGH ((SLint32) 0x60000000) +#define SL_PRIORITY_HIGHEST ((SLint32) 0x7FFFFFFF) + + +/** These macros list the various sample formats that are possible on audio input and output devices. */ + +#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) +#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) +#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) +#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) +#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) +#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) + + +/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ + +#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) +#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) +#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) +#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) +#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) +#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) +#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) +#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) +#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) +#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) +#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) +#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) +#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) + +#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) +#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) +#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) +#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) +#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) +#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) +#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) +#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) +#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) +#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) +#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) +#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) +#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) +#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) +#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) +#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) +#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) +#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) + + +/*****************************************************************************/ +/* Errors */ +/* */ +/*****************************************************************************/ + +#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) +#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) +#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) +#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) +#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) +#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) +#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) +#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) +#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) +#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) +#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) +#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) +#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) +#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) +#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) +#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) +#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) + + +/* Object state definitions */ + +#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) +#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) +#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) + +/* Object event definitions */ + +#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) +#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) +#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) +#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) + + +/*****************************************************************************/ +/* Interface definitions */ +/*****************************************************************************/ + +/** NULL Interface */ + +extern const SLInterfaceID SL_IID_NULL; + +/*---------------------------------------------------------------------------*/ +/* Data Source and Data Sink Structures */ +/*---------------------------------------------------------------------------*/ + +/** Data locator macros */ +#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) +#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) +#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) +#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) +#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) +#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) +#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) +#define SL_DATALOCATOR_RESERVED8 ((SLuint32) 0x00000008) + + + +/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ +typedef struct SLDataLocator_URI_ { + SLuint32 locatorType; + SLchar * URI; +} SLDataLocator_URI; + +/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ +typedef struct SLDataLocator_Address_ { + SLuint32 locatorType; + void *pAddress; + SLuint32 length; +} SLDataLocator_Address; + +/** IODevice-types */ +#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) +#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) +#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) +#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) +#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) + +/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ +typedef struct SLDataLocator_IODevice_ { + SLuint32 locatorType; + SLuint32 deviceType; + SLuint32 deviceID; + SLObjectItf device; +} SLDataLocator_IODevice; + +/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ +typedef struct SLDataLocator_OutputMix { + SLuint32 locatorType; + SLObjectItf outputMix; +} SLDataLocator_OutputMix; + + +/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ +typedef struct SLDataLocator_BufferQueue { + SLuint32 locatorType; + SLuint32 numBuffers; +} SLDataLocator_BufferQueue; + +/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ +typedef struct SLDataLocator_MIDIBufferQueue { + SLuint32 locatorType; + SLuint32 tpqn; + SLuint32 numBuffers; +} SLDataLocator_MIDIBufferQueue; + +/** Data format defines */ +#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) +#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) +#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) + + +/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ +typedef struct SLDataFormat_MIME_ { + SLuint32 formatType; + SLchar * mimeType; + SLuint32 containerType; +} SLDataFormat_MIME; + +/* Byte order of a block of 16- or 32-bit data */ +#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) +#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) + +/* Container type */ +#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) +#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) +#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) +#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) +#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) +#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) +#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) +#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) +#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) +#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) +#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) +#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) +#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) +#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) +#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) +#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) +#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) +#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) +#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) +#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) +#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) +#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) +#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) +#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) +#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) +#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) +#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) +#define SL_CONTAINERTYPE_OGG ((SLuint32) 0x0000001D) + + +/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ +typedef struct SLDataFormat_PCM_ { + SLuint32 formatType; + SLuint32 numChannels; + SLuint32 samplesPerSec; + SLuint32 bitsPerSample; + SLuint32 containerSize; + SLuint32 channelMask; + SLuint32 endianness; +} SLDataFormat_PCM; + +typedef struct SLDataSource_ { + void *pLocator; + void *pFormat; +} SLDataSource; + + +typedef struct SLDataSink_ { + void *pLocator; + void *pFormat; +} SLDataSink; + + + + + + +/*---------------------------------------------------------------------------*/ +/* Standard Object Interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OBJECT; + +/** Object callback */ + + +typedef void (SLAPIENTRY *slObjectCallback) ( + SLObjectItf caller, + const void * pContext, + SLuint32 event, + SLresult result, + SLuint32 param, + void *pInterface +); + + +struct SLObjectItf_ { + SLresult (*Realize) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*Resume) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*GetState) ( + SLObjectItf self, + SLuint32 * pState + ); + SLresult (*GetInterface) ( + SLObjectItf self, + const SLInterfaceID iid, + void * pInterface + ); + SLresult (*RegisterCallback) ( + SLObjectItf self, + slObjectCallback callback, + void * pContext + ); + void (*AbortAsyncOperation) ( + SLObjectItf self + ); + void (*Destroy) ( + SLObjectItf self + ); + SLresult (*SetPriority) ( + SLObjectItf self, + SLint32 priority, + SLboolean preemptable + ); + SLresult (*GetPriority) ( + SLObjectItf self, + SLint32 *pPriority, + SLboolean *pPreemptable + ); + SLresult (*SetLossOfControlInterfaces) ( + SLObjectItf self, + SLint16 numInterfaces, + SLInterfaceID * pInterfaceIDs, + SLboolean enabled + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio IO Device capabilities interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) +#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) +#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) +#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) +#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) + + +#define SL_DEVCONNECTION_INTEGRATED ((SLint16) 0x0001) +#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLint16) 0x0100) +#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLint16) 0x0200) +#define SL_DEVCONNECTION_NETWORK ((SLint16) 0x0400) + + +#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) +#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) +#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) +#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) +#define SL_DEVLOCATION_REMOTE ((SLuint16) 0x0005) +/* Note: SL_DEVLOCATION_RESLTE is deprecated, use SL_DEVLOCATION_REMOTE instead. */ +#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) + + +#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) +#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) +#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) + + +typedef struct SLAudioInputDescriptor_ { + SLchar *deviceName; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *samplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioInputDescriptor; + + +typedef struct SLAudioOutputDescriptor_ { + SLchar *pDeviceName; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *samplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioOutputDescriptor; + + + +extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; + +struct SLAudioIODeviceCapabilitiesItf_; +typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; + + +typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLint32 numInputs, + SLboolean isNew +); + + +typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLint32 numOutputs, + SLboolean isNew +); + +typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLboolean isOutput, + SLint32 numDevices +); + + +struct SLAudioIODeviceCapabilitiesItf_ { + SLresult (*GetAvailableAudioInputs)( + SLAudioIODeviceCapabilitiesItf self, + SLint32 *pNumInputs, + SLuint32 *pInputDeviceIDs + ); + SLresult (*QueryAudioInputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioInputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioInputsChangedCallback callback, + void *pContext + ); + SLresult (*GetAvailableAudioOutputs)( + SLAudioIODeviceCapabilitiesItf self, + SLint32 *pNumOutputs, + SLuint32 *pOutputDeviceIDs + ); + SLresult (*QueryAudioOutputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioOutputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioOutputsChangedCallback callback, + void *pContext + ); + SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slDefaultDeviceIDMapChangedCallback callback, + void *pContext + ); + SLresult (*GetAssociatedAudioInputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLint32 *pNumAudioInputs, + SLuint32 *pAudioInputDeviceIDs + ); + SLresult (*GetAssociatedAudioOutputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLint32 *pNumAudioOutputs, + SLuint32 *pAudioOutputDeviceIDs + ); + SLresult (*GetDefaultAudioDevices) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 defaultDeviceID, + SLint32 *pNumAudioDevices, + SLuint32 *pAudioDeviceIDs + ); + SLresult (*QuerySampleFormatsSupported)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLmilliHertz samplingRate, + SLint32 *pSampleFormats, + SLint32 *pNumOfSampleFormats + ); +}; + + + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the LED array IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLLEDDescriptor_ { + SLuint8 ledCount; + SLuint8 primaryLED; + SLuint32 colorMask; +} SLLEDDescriptor; + + +/*---------------------------------------------------------------------------*/ +/* LED Array interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLHSL_ { + SLmillidegree hue; + SLpermille saturation; + SLpermille lightness; +} SLHSL; + + +extern const SLInterfaceID SL_IID_LED; + +struct SLLEDArrayItf_; +typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; + +struct SLLEDArrayItf_ { + SLresult (*ActivateLEDArray) ( + SLLEDArrayItf self, + SLuint32 lightMask + ); + SLresult (*IsLEDArrayActivated) ( + SLLEDArrayItf self, + SLuint32 *lightMask + ); + SLresult (*SetColor) ( + SLLEDArrayItf self, + SLuint8 index, + const SLHSL *color + ); + SLresult (*GetColor) ( + SLLEDArrayItf self, + SLuint8 index, + SLHSL *color + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the Vibra IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVibraDescriptor_ { + SLboolean supportsFrequency; + SLboolean supportsIntensity; + SLmilliHertz minFrequency; + SLmilliHertz maxFrequency; +} SLVibraDescriptor; + + + +/*---------------------------------------------------------------------------*/ +/* Vibra interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VIBRA; + + +struct SLVibraItf_; +typedef const struct SLVibraItf_ * const * SLVibraItf; + +struct SLVibraItf_ { + SLresult (*Vibrate) ( + SLVibraItf self, + SLboolean vibrate + ); + SLresult (*IsVibrating) ( + SLVibraItf self, + SLboolean *pVibrating + ); + SLresult (*SetFrequency) ( + SLVibraItf self, + SLmilliHertz frequency + ); + SLresult (*GetFrequency) ( + SLVibraItf self, + SLmilliHertz *pFrequency + ); + SLresult (*SetIntensity) ( + SLVibraItf self, + SLpermille intensity + ); + SLresult (*GetIntensity) ( + SLVibraItf self, + SLpermille *pIntensity + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data extraction related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) +#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) +#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) +#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) +#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) +#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) +#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) +#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) +#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) +#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) +#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) +#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) +#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) +#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) +#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) +#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) +#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) +#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) +#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) +#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) +#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) +#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) +#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) +#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) +#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) +#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) +#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) +#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) +#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) +#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) +#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) +#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) + + +#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) +#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) +#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) + + +typedef struct SLMetadataInfo_ { + SLuint32 size; + SLuint32 encoding; + SLchar langCountry[16]; + SLuint8 data[1]; +} SLMetadataInfo; + +extern const SLInterfaceID SL_IID_METADATAEXTRACTION; + +struct SLMetadataExtractionItf_; +typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; + + +struct SLMetadataExtractionItf_ { + SLresult (*GetItemCount) ( + SLMetadataExtractionItf self, + SLuint32 *pItemCount + ); + SLresult (*GetKeySize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pKeySize + ); + SLresult (*GetKey) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 keySize, + SLMetadataInfo *pKey + ); + SLresult (*GetValueSize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pValueSize + ); + SLresult (*GetValue) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 valueSize, + SLMetadataInfo *pValue + ); + SLresult (*AddKeyFilter) ( + SLMetadataExtractionItf self, + SLuint32 keySize, + const void *pKey, + SLuint32 keyEncoding, + const SLchar *pValueLangCountry, + SLuint32 valueEncoding, + SLuint8 filterMask + ); + SLresult (*ClearKeyFilter) ( + SLMetadataExtractionItf self + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data traversal related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) +#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) + + +#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) +#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) +#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) + +#define SL_NODE_PARENT 0xFFFFFFFF + +extern const SLInterfaceID SL_IID_METADATATRAVERSAL; + +struct SLMetadataTraversalItf_; +typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; + +struct SLMetadataTraversalItf_ { + SLresult (*SetMode) ( + SLMetadataTraversalItf self, + SLuint32 mode + ); + SLresult (*GetChildCount) ( + SLMetadataTraversalItf self, + SLuint32 *pCount + ); + SLresult (*GetChildMIMETypeSize) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLuint32 *pSize + ); + SLresult (*GetChildInfo) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLint32 *pNodeID, + SLuint32 *pType, + SLuint32 size, + SLchar *pMimeType + ); + SLresult (*SetActiveNode) ( + SLMetadataTraversalItf self, + SLuint32 index + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Dynamic Source types and interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_DYNAMICSOURCE; + +struct SLDynamicSourceItf_; +typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; + +struct SLDynamicSourceItf_ { + SLresult (*SetSource) ( + SLDynamicSourceItf self, + SLDataSource *pDataSource + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Output Mix interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OUTPUTMIX; + +struct SLOutputMixItf_; +typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; + +typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( + SLOutputMixItf caller, + void *pContext +); + + +struct SLOutputMixItf_ { + SLresult (*GetDestinationOutputDeviceIDs) ( + SLOutputMixItf self, + SLint32 *pNumDevices, + SLuint32 *pDeviceIDs + ); + SLresult (*RegisterDeviceChangeCallback) ( + SLOutputMixItf self, + slMixDeviceChangeCallback callback, + void *pContext + ); + SLresult (*ReRoute)( + SLOutputMixItf self, + SLint32 numOutputDevices, + SLuint32 *pOutputDeviceIDs + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Playback interface */ +/*---------------------------------------------------------------------------*/ + +/** Playback states */ +#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) + +/** Play events **/ +#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) +#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) + +#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) + + +extern const SLInterfaceID SL_IID_PLAY; + +/** Playback interface methods */ + +struct SLPlayItf_; +typedef const struct SLPlayItf_ * const * SLPlayItf; + +typedef void (SLAPIENTRY *slPlayCallback) ( + SLPlayItf caller, + void *pContext, + SLuint32 event +); + +struct SLPlayItf_ { + SLresult (*SetPlayState) ( + SLPlayItf self, + SLuint32 state + ); + SLresult (*GetPlayState) ( + SLPlayItf self, + SLuint32 *pState + ); + SLresult (*GetDuration) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*GetPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLPlayItf self, + slPlayCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLPlayItf self + ); + SLresult (*GetMarkerPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Prefetch status interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) +#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) + +#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) +#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) +#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) + + +extern const SLInterfaceID SL_IID_PREFETCHSTATUS; + + +/** Prefetch status interface methods */ + +struct SLPrefetchStatusItf_; +typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; + +typedef void (SLAPIENTRY *slPrefetchCallback) ( + SLPrefetchStatusItf caller, + void *pContext, + SLuint32 event +); + +struct SLPrefetchStatusItf_ { + SLresult (*GetPrefetchStatus) ( + SLPrefetchStatusItf self, + SLuint32 *pStatus + ); + SLresult (*GetFillLevel) ( + SLPrefetchStatusItf self, + SLpermille *pLevel + ); + SLresult (*RegisterCallback) ( + SLPrefetchStatusItf self, + slPrefetchCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille period + ); + SLresult (*GetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille *pPeriod + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Playback Rate interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) +#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) +#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) +#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) +#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) +#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) + + +extern const SLInterfaceID SL_IID_PLAYBACKRATE; + +struct SLPlaybackRateItf_; +typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; + +struct SLPlaybackRateItf_ { + SLresult (*SetRate)( + SLPlaybackRateItf self, + SLpermille rate + ); + SLresult (*GetRate)( + SLPlaybackRateItf self, + SLpermille *pRate + ); + SLresult (*SetPropertyConstraints)( + SLPlaybackRateItf self, + SLuint32 constraints + ); + SLresult (*GetProperties)( + SLPlaybackRateItf self, + SLuint32 *pProperties + ); + SLresult (*GetCapabilitiesOfRate)( + SLPlaybackRateItf self, + SLpermille rate, + SLuint32 *pCapabilities + ); + SLresult (*GetRateRange) ( + SLPlaybackRateItf self, + SLuint8 index, + SLpermille *pMinRate, + SLpermille *pMaxRate, + SLpermille *pStepSize, + SLuint32 *pCapabilities + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Seek Interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_SEEKMODE_FAST ((SLuint32) 0x0001) +#define SL_SEEKMODE_ACCURATE ((SLuint32) 0x0002) + +extern const SLInterfaceID SL_IID_SEEK; + +struct SLSeekItf_; +typedef const struct SLSeekItf_ * const * SLSeekItf; + +struct SLSeekItf_ { + SLresult (*SetPosition)( + SLSeekItf self, + SLmillisecond pos, + SLuint32 seekMode + ); + SLresult (*SetLoop)( + SLSeekItf self, + SLboolean loopEnable, + SLmillisecond startPos, + SLmillisecond endPos + ); + SLresult (*GetLoop)( + SLSeekItf self, + SLboolean *pLoopEnabled, + SLmillisecond *pStartPos, + SLmillisecond *pEndPos + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Standard Recording Interface */ +/*---------------------------------------------------------------------------*/ + +/** Recording states */ +#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) + + +/** Record event **/ +#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) +#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) +/* Note: SL_RECORDEVENT_BUFFER_INSUFFICIENT is deprecated, use SL_RECORDEVENT_BUFFER_FULL instead. */ +#define SL_RECORDEVENT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000020) +#define SL_RECORDEVENT_BUFFER_FULL ((SLuint32) 0x00000020) + + +extern const SLInterfaceID SL_IID_RECORD; + +struct SLRecordItf_; +typedef const struct SLRecordItf_ * const * SLRecordItf; + +typedef void (SLAPIENTRY *slRecordCallback) ( + SLRecordItf caller, + void *pContext, + SLuint32 event +); + +/** Recording interface methods */ +struct SLRecordItf_ { + SLresult (*SetRecordState) ( + SLRecordItf self, + SLuint32 state + ); + SLresult (*GetRecordState) ( + SLRecordItf self, + SLuint32 *pState + ); + SLresult (*SetDurationLimit) ( + SLRecordItf self, + SLmillisecond msec + ); + SLresult (*GetPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLRecordItf self, + slRecordCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLRecordItf self + ); + SLresult (*GetMarkerPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Equalizer interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) + +extern const SLInterfaceID SL_IID_EQUALIZER; + +struct SLEqualizerItf_; +typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; + +struct SLEqualizerItf_ { + SLresult (*SetEnabled)( + SLEqualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLEqualizerItf self, + SLboolean *pEnabled + ); + SLresult (*GetNumberOfBands)( + SLEqualizerItf self, + SLuint16 *pAmount + ); + SLresult (*GetBandLevelRange)( + SLEqualizerItf self, + SLmillibel *pMin, + SLmillibel *pMax + ); + SLresult (*SetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel level + ); + SLresult (*GetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel *pLevel + ); + SLresult (*GetCenterFreq)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pCenter + ); + SLresult (*GetBandFreqRange)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pMin, + SLmilliHertz *pMax + ); + SLresult (*GetBand)( + SLEqualizerItf self, + SLmilliHertz frequency, + SLuint16 *pBand + ); + SLresult (*GetCurrentPreset)( + SLEqualizerItf self, + SLuint16 *pPreset + ); + SLresult (*UsePreset)( + SLEqualizerItf self, + SLuint16 index + ); + SLresult (*GetNumberOfPresets)( + SLEqualizerItf self, + SLuint16 *pNumPresets + ); + SLresult (*GetPresetName)( + SLEqualizerItf self, + SLuint16 index, + const SLchar ** ppName + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Volume Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_VOLUME; + +struct SLVolumeItf_; +typedef const struct SLVolumeItf_ * const * SLVolumeItf; + +struct SLVolumeItf_ { + SLresult (*SetVolumeLevel) ( + SLVolumeItf self, + SLmillibel level + ); + SLresult (*GetVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pLevel + ); + SLresult (*GetMaxVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pMaxLevel + ); + SLresult (*SetMute) ( + SLVolumeItf self, + SLboolean mute + ); + SLresult (*GetMute) ( + SLVolumeItf self, + SLboolean *pMute + ); + SLresult (*EnableStereoPosition) ( + SLVolumeItf self, + SLboolean enable + ); + SLresult (*IsEnabledStereoPosition) ( + SLVolumeItf self, + SLboolean *pEnable + ); + SLresult (*SetStereoPosition) ( + SLVolumeItf self, + SLpermille stereoPosition + ); + SLresult (*GetStereoPosition) ( + SLVolumeItf self, + SLpermille *pStereoPosition + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Device Volume Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_DEVICEVOLUME; + +struct SLDeviceVolumeItf_; +typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; + +struct SLDeviceVolumeItf_ { + SLresult (*GetVolumeScale) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pMinValue, + SLint32 *pMaxValue, + SLboolean *pIsMillibelScale + ); + SLresult (*SetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 volume + ); + SLresult (*GetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pVolume + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Buffer Queue Interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_BUFFERQUEUE; + +struct SLBufferQueueItf_; +typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; + +typedef void (SLAPIENTRY *slBufferQueueCallback)( + SLBufferQueueItf caller, + void *pContext +); + +/** Buffer queue state **/ + +typedef struct SLBufferQueueState_ { + SLuint32 count; + SLuint32 playIndex; +} SLBufferQueueState; + + +struct SLBufferQueueItf_ { + SLresult (*Enqueue) ( + SLBufferQueueItf self, + const void *pBuffer, + SLuint32 size + ); + SLresult (*Clear) ( + SLBufferQueueItf self + ); + SLresult (*GetState) ( + SLBufferQueueItf self, + SLBufferQueueState *pState + ); + SLresult (*RegisterCallback) ( + SLBufferQueueItf self, + slBufferQueueCallback callback, + void* pContext + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* PresetReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) +#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) +#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) +#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) +#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) +#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) +#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) + + +extern const SLInterfaceID SL_IID_PRESETREVERB; + +struct SLPresetReverbItf_; +typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; + +struct SLPresetReverbItf_ { + SLresult (*SetPreset) ( + SLPresetReverbItf self, + SLuint16 preset + ); + SLresult (*GetPreset) ( + SLPresetReverbItf self, + SLuint16 *pPreset + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* EnvironmentalReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ + { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ + { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ + { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ + { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ + { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ + { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ + { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ + { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ + { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ + { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ + { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ + { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ + { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ + { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ + { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ + { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ + { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ + { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ + { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ + { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ + { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ + { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ + { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ + { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ + { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ + { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ + { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ + { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ + { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ + { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } + + +typedef struct SLEnvironmentalReverbSettings_ { + SLmillibel roomLevel; + SLmillibel roomHFLevel; + SLmillisecond decayTime; + SLpermille decayHFRatio; + SLmillibel reflectionsLevel; + SLmillisecond reflectionsDelay; + SLmillibel reverbLevel; + SLmillisecond reverbDelay; + SLpermille diffusion; + SLpermille density; +} SLEnvironmentalReverbSettings; + + + + +extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; + + +struct SLEnvironmentalReverbItf_; +typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; + +struct SLEnvironmentalReverbItf_ { + SLresult (*SetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel room + ); + SLresult (*GetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoom + ); + SLresult (*SetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel roomHF + ); + SLresult (*GetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoomHF + ); + SLresult (*SetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond decayTime + ); + SLresult (*GetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pDecayTime + ); + SLresult (*SetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille decayHFRatio + ); + SLresult (*GetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille *pDecayHFRatio + ); + SLresult (*SetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reflectionsLevel + ); + SLresult (*GetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReflectionsLevel + ); + SLresult (*SetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reflectionsDelay + ); + SLresult (*GetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReflectionsDelay + ); + SLresult (*SetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reverbLevel + ); + SLresult (*GetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReverbLevel + ); + SLresult (*SetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reverbDelay + ); + SLresult (*GetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReverbDelay + ); + SLresult (*SetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille diffusion + ); + SLresult (*GetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille *pDiffusion + ); + SLresult (*SetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille density + ); + SLresult (*GetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille *pDensity + ); + SLresult (*SetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + const SLEnvironmentalReverbSettings *pProperties + ); + SLresult (*GetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + SLEnvironmentalReverbSettings *pProperties + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Effects Send Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_EFFECTSEND; + +struct SLEffectSendItf_; +typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; + +struct SLEffectSendItf_ { + SLresult (*EnableEffectSend) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLboolean enable, + SLmillibel initialLevel + ); + SLresult (*IsEnabled) ( + SLEffectSendItf self, + const void * pAuxEffect, + SLboolean *pEnable + ); + SLresult (*SetDirectLevel) ( + SLEffectSendItf self, + SLmillibel directLevel + ); + SLresult (*GetDirectLevel) ( + SLEffectSendItf self, + SLmillibel *pDirectLevel + ); + SLresult (*SetSendLevel) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel sendLevel + ); + SLresult (*GetSendLevel)( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel *pSendLevel + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Grouping Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DGROUPING; + + +struct SL3DGroupingItf_ ; +typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; + +struct SL3DGroupingItf_ { + SLresult (*Set3DGroup) ( + SL3DGroupingItf self, + SLObjectItf group + ); + SLresult (*Get3DGroup) ( + SL3DGroupingItf self, + SLObjectItf *pGroup + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Commit Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DCOMMIT; + +struct SL3DCommitItf_; +typedef const struct SL3DCommitItf_* const * SL3DCommitItf; + +struct SL3DCommitItf_ { + SLresult (*Commit) ( + SL3DCommitItf self + ); + SLresult (*SetDeferred) ( + SL3DCommitItf self, + SLboolean deferred + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Location Interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVec3D_ { + SLint32 x; + SLint32 y; + SLint32 z; +} SLVec3D; + +extern const SLInterfaceID SL_IID_3DLOCATION; + +struct SL3DLocationItf_; +typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; + +struct SL3DLocationItf_ { + SLresult (*SetLocationCartesian) ( + SL3DLocationItf self, + const SLVec3D *pLocation + ); + SLresult (*SetLocationSpherical) ( + SL3DLocationItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter distance + ); + SLresult (*Move) ( + SL3DLocationItf self, + const SLVec3D *pMovement + ); + SLresult (*GetLocationCartesian) ( + SL3DLocationItf self, + SLVec3D *pLocation + ); + SLresult (*SetOrientationVectors) ( + SL3DLocationItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*SetOrientationAngles) ( + SL3DLocationItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*Rotate) ( + SL3DLocationItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DLocationItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Doppler Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DDOPPLER; + +struct SL3DDopplerItf_; +typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; + +struct SL3DDopplerItf_ { + SLresult (*SetVelocityCartesian) ( + SL3DDopplerItf self, + const SLVec3D *pVelocity + ); + SLresult (*SetVelocitySpherical) ( + SL3DDopplerItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter speed + ); + SLresult (*GetVelocityCartesian) ( + SL3DDopplerItf self, + SLVec3D *pVelocity + ); + SLresult (*SetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille dopplerFactor + ); + SLresult (*GetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille *pDopplerFactor + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Source Interface and associated defines */ +/* --------------------------------------------------------------------------*/ + +#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) +#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) + + +extern const SLInterfaceID SL_IID_3DSOURCE; + +struct SL3DSourceItf_; +typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; + +struct SL3DSourceItf_ { + SLresult (*SetHeadRelative) ( + SL3DSourceItf self, + SLboolean headRelative + ); + SLresult (*GetHeadRelative) ( + SL3DSourceItf self, + SLboolean *pHeadRelative + ); + SLresult (*SetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter minDistance, + SLmillimeter maxDistance + ); + SLresult (*GetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter *pMinDistance, + SLmillimeter *pMaxDistance + ); + SLresult (*SetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean mute + ); + SLresult (*GetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean *pMute + ); + SLresult (*SetRolloffFactor) ( + SL3DSourceItf self, + SLpermille rolloffFactor + ); + SLresult (*GetRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRolloffFactor + ); + SLresult (*SetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille roomRolloffFactor + ); + SLresult (*GetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRoomRolloffFactor + ); + SLresult (*SetRolloffModel) ( + SL3DSourceItf self, + SLuint8 model + ); + SLresult (*GetRolloffModel) ( + SL3DSourceItf self, + SLuint8 *pModel + ); + SLresult (*SetCone) ( + SL3DSourceItf self, + SLmillidegree innerAngle, + SLmillidegree outerAngle, + SLmillibel outerLevel + ); + SLresult (*GetCone) ( + SL3DSourceItf self, + SLmillidegree *pInnerAngle, + SLmillidegree *pOuterAngle, + SLmillibel *pOuterLevel + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Macroscopic Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_3DMACROSCOPIC; + +struct SL3DMacroscopicItf_; +typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; + +struct SL3DMacroscopicItf_ { + SLresult (*SetSize) ( + SL3DMacroscopicItf self, + SLmillimeter width, + SLmillimeter height, + SLmillimeter depth + ); + SLresult (*GetSize) ( + SL3DMacroscopicItf self, + SLmillimeter *pWidth, + SLmillimeter *pHeight, + SLmillimeter *pDepth + ); + SLresult (*SetOrientationAngles) ( + SL3DMacroscopicItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*SetOrientationVectors) ( + SL3DMacroscopicItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*Rotate) ( + SL3DMacroscopicItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DMacroscopicItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Mute Solo Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MUTESOLO; + +struct SLMuteSoloItf_; +typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; + +struct SLMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pSolo + ); + SLresult (*GetNumChannels) ( + SLMuteSoloItf self, + SLuint8 *pNumChannels + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Dynamic Interface Management Interface and associated types and macros */ +/* --------------------------------------------------------------------------*/ + +#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) + + + + +extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; + +struct SLDynamicInterfaceManagementItf_; +typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; + +typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( + SLDynamicInterfaceManagementItf caller, + void * pContext, + SLuint32 event, + SLresult result, + const SLInterfaceID iid +); + + +struct SLDynamicInterfaceManagementItf_ { + SLresult (*AddInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RemoveInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid + ); + SLresult (*ResumeInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RegisterCallback) ( + SLDynamicInterfaceManagementItf self, + slDynamicInterfaceManagementCallback callback, + void * pContext + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Midi Message Interface and associated types */ +/* --------------------------------------------------------------------------*/ + +#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) +#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) +#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) +#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) +#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) +#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) +#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) + + +extern const SLInterfaceID SL_IID_MIDIMESSAGE; + +struct SLMIDIMessageItf_; +typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; + +typedef void (SLAPIENTRY *slMetaEventCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 type, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +typedef void (SLAPIENTRY *slMIDIMessageCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 statusByte, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +struct SLMIDIMessageItf_ { + SLresult (*SendMessage) ( + SLMIDIMessageItf self, + const SLuint8 *data, + SLuint32 length + ); + SLresult (*RegisterMetaEventCallback) ( + SLMIDIMessageItf self, + slMetaEventCallback callback, + void *pContext + ); + SLresult (*RegisterMIDIMessageCallback) ( + SLMIDIMessageItf self, + slMIDIMessageCallback callback, + void *pContext + ); + SLresult (*AddMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self, + SLuint32 messageType + ); + SLresult (*ClearMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Mute Solo interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDIMUTESOLO; + +struct SLMIDIMuteSoloItf_; +typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; + +struct SLMIDIMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pSolo + ); + SLresult (*GetTrackCount) ( + SLMIDIMuteSoloItf self, + SLuint16 *pCount + ); + SLresult (*SetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean mute + ); + SLresult (*GetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pMute + ); + SLresult (*SetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean solo + ); + SLresult (*GetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pSolo + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Tempo interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDITEMPO; + +struct SLMIDITempoItf_; +typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; + +struct SLMIDITempoItf_ { + SLresult (*SetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 tpqn + ); + SLresult (*GetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 *pTpqn + ); + SLresult (*SetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond uspqn + ); + SLresult (*GetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond *uspqn + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Time interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDITIME; + +struct SLMIDITimeItf_; +typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; + +struct SLMIDITimeItf_ { + SLresult (*GetDuration) ( + SLMIDITimeItf self, + SLuint32 *pDuration + ); + SLresult (*SetPosition) ( + SLMIDITimeItf self, + SLuint32 position + ); + SLresult (*GetPosition) ( + SLMIDITimeItf self, + SLuint32 *pPosition + ); + SLresult (*SetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 startTick, + SLuint32 numTicks + ); + SLresult (*GetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 *pStartTick, + SLuint32 *pNumTicks + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Decoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/*Audio Codec related defines*/ + +#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) +#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) + +#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) +#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) +#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) +#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) +#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) +#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) +#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) +#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) + +#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) + +#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) +#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) +#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) +#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) + +#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) + +#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) + +#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) +#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) +#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) + +#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) +#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) + +#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) +#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) + +#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) + +#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) + +typedef struct SLAudioCodecDescriptor_ { + SLuint32 maxChannels; + SLuint32 minBitsPerSample; + SLuint32 maxBitsPerSample; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *pSampleRatesSupported; + SLuint32 numSampleRatesSupported; + SLuint32 minBitRate; + SLuint32 maxBitRate; + SLboolean isBitrateRangeContinuous; + SLuint32 *pBitratesSupported; + SLuint32 numBitratesSupported; + SLuint32 profileSetting; + SLuint32 modeSetting; +} SLAudioCodecDescriptor; + +/*Structure used to retrieve the profile and level settings supported by an audio encoder */ + +typedef struct SLAudioCodecProfileMode_ { + SLuint32 profileSetting; + SLuint32 modeSetting; +} SLAudioCodecProfileMode; + +extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; + +struct SLAudioDecoderCapabilitiesItf_; +typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; + +struct SLAudioDecoderCapabilitiesItf_ { + SLresult (*GetAudioDecoders) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 * pNumDecoders , + SLuint32 *pDecoderIds + ); + SLresult (*GetAudioDecoderCapabilities) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 decoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor *pDescriptor + ); +}; + + + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/* Structure used when setting audio encoding parameters */ + +typedef struct SLAudioEncoderSettings_ { + SLuint32 encoderId; + SLuint32 channelsIn; + SLuint32 channelsOut; + SLmilliHertz sampleRate; + SLuint32 bitRate; + SLuint32 bitsPerSample; + SLuint32 rateControl; + SLuint32 profileSetting; + SLuint32 levelSetting; + SLuint32 channelMode; + SLuint32 streamFormat; + SLuint32 encodeOptions; + SLuint32 blockAlignment; +} SLAudioEncoderSettings; + +extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; + +struct SLAudioEncoderCapabilitiesItf_; +typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; + +struct SLAudioEncoderCapabilitiesItf_ { + SLresult (*GetAudioEncoders) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 *pNumEncoders , + SLuint32 *pEncoderIds + ); + SLresult (*GetAudioEncoderCapabilities) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 encoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor * pDescriptor + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_AUDIOENCODER; + +struct SLAudioEncoderItf_; +typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; + +struct SLAudioEncoderItf_ { + SLresult (*SetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); + SLresult (*GetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Bass Boost Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_BASSBOOST; + +struct SLBassBoostItf_; +typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; + +struct SLBassBoostItf_ { + SLresult (*SetEnabled)( + SLBassBoostItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLBassBoostItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLBassBoostItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLBassBoostItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLBassBoostItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Pitch Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_PITCH; + +struct SLPitchItf_; +typedef const struct SLPitchItf_ * const * SLPitchItf; + +struct SLPitchItf_ { + SLresult (*SetPitch) ( + SLPitchItf self, + SLpermille pitch + ); + SLresult (*GetPitch) ( + SLPitchItf self, + SLpermille *pPitch + ); + SLresult (*GetPitchCapabilities) ( + SLPitchItf self, + SLpermille *pMinPitch, + SLpermille *pMaxPitch + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Rate Pitch Interface */ +/* RatePitchItf is an interface for controlling the rate a sound is played */ +/* back. A change in rate will cause a change in pitch. */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_RATEPITCH; + +struct SLRatePitchItf_; +typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; + +struct SLRatePitchItf_ { + SLresult (*SetRate) ( + SLRatePitchItf self, + SLpermille rate + ); + SLresult (*GetRate) ( + SLRatePitchItf self, + SLpermille *pRate + ); + SLresult (*GetRatePitchCapabilities) ( + SLRatePitchItf self, + SLpermille *pMinRate, + SLpermille *pMaxRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Virtualizer Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VIRTUALIZER; + +struct SLVirtualizerItf_; +typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; + +struct SLVirtualizerItf_ { + SLresult (*SetEnabled)( + SLVirtualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLVirtualizerItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLVirtualizerItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLVirtualizerItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLVirtualizerItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Visualization Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VISUALIZATION; + +struct SLVisualizationItf_; +typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; + +typedef void (SLAPIENTRY *slVisualizationCallback) ( + void *pContext, + const SLuint8 waveform[], + const SLuint8 fft[], + SLmilliHertz samplerate +); + +struct SLVisualizationItf_{ + SLresult (*RegisterVisualizationCallback)( + SLVisualizationItf self, + slVisualizationCallback callback, + void *pContext, + SLmilliHertz rate + ); + SLresult (*GetMaxRate)( + SLVisualizationItf self, + SLmilliHertz* pRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_ENGINE; + +struct SLEngineItf_; +typedef const struct SLEngineItf_ * const * SLEngineItf; + + +struct SLEngineItf_ { + + SLresult (*CreateLEDDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateVibraDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + SLDataSource *pAudioSrc, + SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioRecorder) ( + SLEngineItf self, + SLObjectItf * pRecorder, + SLDataSource *pAudioSrc, + SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMidiPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + SLDataSource *pMIDISrc, + SLDataSource *pBankSrc, + SLDataSink *pAudioOutput, + SLDataSink *pVibra, + SLDataSink *pLEDArray, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateListener) ( + SLEngineItf self, + SLObjectItf * pListener, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*Create3DGroup) ( + SLEngineItf self, + SLObjectItf * pGroup, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateOutputMix) ( + SLEngineItf self, + SLObjectItf * pMix, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMetadataExtractor) ( + SLEngineItf self, + SLObjectItf * pMetadataExtractor, + SLDataSource * pDataSource, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateExtensionObject) ( + SLEngineItf self, + SLObjectItf * pObject, + void * pParameters, + SLuint32 objectID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*QueryNumSupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 * pNumSupportedInterfaces + ); + SLresult (*QuerySupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 index, + SLInterfaceID * pInterfaceId + ); + SLresult (*QueryNumSupportedExtensions) ( + SLEngineItf self, + SLuint32 * pNumExtensions + ); + SLresult (*QuerySupportedExtension) ( + SLEngineItf self, + SLuint32 index, + SLchar * pExtensionName, + SLint16 * pNameLength + ); + SLresult (*IsExtensionSupported) ( + SLEngineItf self, + const SLchar * pExtensionName, + SLboolean * pSupported + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; + +struct SLEngineCapabilitiesItf_; +typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; + +struct SLEngineCapabilitiesItf_ { + SLresult (*QuerySupportedProfiles) ( + SLEngineCapabilitiesItf self, + SLuint16 *pProfilesSupported + ); + SLresult (*QueryAvailableVoices) ( + SLEngineCapabilitiesItf self, + SLuint16 voiceType, + SLint16 *pNumMaxVoices, + SLboolean *pIsAbsoluteMax, + SLint16 *pNumFreeVoices + ); + SLresult (*QueryNumberOfMIDISynthesizers) ( + SLEngineCapabilitiesItf self, + SLint16 *pNumMIDIsynthesizers + ); + SLresult (*QueryAPIVersion) ( + SLEngineCapabilitiesItf self, + SLint16 *pMajor, + SLint16 *pMinor, + SLint16 *pStep + ); + SLresult (*QueryLEDCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pLEDDeviceID, + SLLEDDescriptor *pDescriptor + ); + SLresult (*QueryVibraCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pVibraDeviceID, + SLVibraDescriptor *pDescriptor + ); + SLresult (*IsThreadSafe) ( + SLEngineCapabilitiesItf self, + SLboolean *pIsThreadSafe + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Thread Sync Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_THREADSYNC; + +struct SLThreadSyncItf_; +typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; + + +struct SLThreadSyncItf_ { + SLresult (*EnterCriticalSection) ( + SLThreadSyncItf self + ); + SLresult (*ExitCriticalSection) ( + SLThreadSyncItf self + ); +}; + + +/*****************************************************************************/ +/* SL engine constructor */ +/*****************************************************************************/ + +#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) +#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) + +typedef struct SLEngineOption_ { + SLuint32 feature; + SLuint32 data; +} SLEngineOption; + + +SLresult SLAPIENTRY slCreateEngine( + SLObjectItf *pEngine, + SLuint32 numOptions, + const SLEngineOption *pEngineOptions, + SLuint32 numInterfaces, + const SLInterfaceID *pInterfaceIds, + const SLboolean * pInterfaceRequired +); + +SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( + SLuint32 * pNumSupportedInterfaces +); + +SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( + SLuint32 index, + SLInterfaceID * pInterfaceId +); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* OPENSL_ES_H_ */ diff --git a/third_party/openSLES/api/1.0.1/OpenSLES_OpenHarmony.h b/third_party/openSLES/api/1.0.1/OpenSLES_OpenHarmony.h index 8feed06a4c447e1b8f3d5f29baf11949f9db8646..89dce45e7ba0c16d4c5d822e77991d3c713cc4c6 100644 --- a/third_party/openSLES/api/1.0.1/OpenSLES_OpenHarmony.h +++ b/third_party/openSLES/api/1.0.1/OpenSLES_OpenHarmony.h @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2022 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 OPENSLES_OPENHARMONY_H -#define OPENSLES_OPENHARMONY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "OpenSLES.h" -#include "OpenSLES_Platform.h" - -/*---------------------------------------------------------------------------*/ -/* OH Buffer Queue Interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_OH_BUFFERQUEUE; - -struct SLOHBufferQueueItf_; -typedef const struct SLOHBufferQueueItf_ * const * SLOHBufferQueueItf; - -typedef void (SLAPIENTRY *SlOHBufferQueueCallback)( - SLOHBufferQueueItf caller, - void *pContext, - SLuint32 size -); - -/** OH Buffer queue state **/ - -typedef struct SLOHBufferQueueState_ { - SLuint32 count; - SLuint32 index; -} SLOHBufferQueueState; - - -struct SLOHBufferQueueItf_ { - SLresult (*Enqueue) ( - SLOHBufferQueueItf self, - const void *buffer, - SLuint32 size - ); - SLresult (*Clear) ( - SLOHBufferQueueItf self - ); - SLresult (*GetState) ( - SLOHBufferQueueItf self, - SLOHBufferQueueState *state - ); - SLresult (*GetBuffer) ( - SLOHBufferQueueItf self, - SLuint8** buffer, - SLuint32* size - ); - SLresult (*RegisterCallback) ( - SLOHBufferQueueItf self, - SlOHBufferQueueCallback callback, - void* pContext - ); -}; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* OPENSLES_OPENHARMONY_H */ +/* + * Copyright (c) 2022 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 OPENSLES_OPENHARMONY_H +#define OPENSLES_OPENHARMONY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "OpenSLES.h" +#include "OpenSLES_Platform.h" + +/*---------------------------------------------------------------------------*/ +/* OH Buffer Queue Interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OH_BUFFERQUEUE; + +struct SLOHBufferQueueItf_; +typedef const struct SLOHBufferQueueItf_ * const * SLOHBufferQueueItf; + +typedef void (SLAPIENTRY *SlOHBufferQueueCallback)( + SLOHBufferQueueItf caller, + void *pContext, + SLuint32 size +); + +/** OH Buffer queue state **/ + +typedef struct SLOHBufferQueueState_ { + SLuint32 count; + SLuint32 index; +} SLOHBufferQueueState; + + +struct SLOHBufferQueueItf_ { + SLresult (*Enqueue) ( + SLOHBufferQueueItf self, + const void *buffer, + SLuint32 size + ); + SLresult (*Clear) ( + SLOHBufferQueueItf self + ); + SLresult (*GetState) ( + SLOHBufferQueueItf self, + SLOHBufferQueueState *state + ); + SLresult (*GetBuffer) ( + SLOHBufferQueueItf self, + SLuint8** buffer, + SLuint32* size + ); + SLresult (*RegisterCallback) ( + SLOHBufferQueueItf self, + SlOHBufferQueueCallback callback, + void* pContext + ); +}; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* OPENSLES_OPENHARMONY_H */ diff --git a/third_party/openSLES/api/1.0.1/OpenSLES_Platform.h b/third_party/openSLES/api/1.0.1/OpenSLES_Platform.h index afce98a1e369acfd9e3a12f13aa0af76779a3207..657e39af0f3580645f947132c5ea07a65ac70abc 100644 --- a/third_party/openSLES/api/1.0.1/OpenSLES_Platform.h +++ b/third_party/openSLES/api/1.0.1/OpenSLES_Platform.h @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2007-2009 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES_Platform.h - OpenSL ES version 1.0 - * - */ - -/****************************************************************************/ -/* NOTE: This file contains definitions for the base types and the */ -/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ -/* the correct definitions specific to the platform being used. */ -/****************************************************************************/ - -#ifndef _OPENSLES_PLATFORM_H_ -#define _OPENSLES_PLATFORM_H_ - -typedef unsigned char sl_uint8_t; -typedef signed char sl_int8_t; -typedef unsigned short sl_uint16_t; -typedef signed short sl_int16_t; -typedef unsigned long sl_uint32_t; -typedef signed long sl_int32_t; - -#ifndef SLAPIENTRY -#define SLAPIENTRY /* override per-platform */ -#endif - -#endif /* _OPENSLES_PLATFORM_H_ */ +/* + * Copyright (c) 2007-2009 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES_Platform.h - OpenSL ES version 1.0 + * + */ + +/****************************************************************************/ +/* NOTE: This file contains definitions for the base types and the */ +/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ +/* the correct definitions specific to the platform being used. */ +/****************************************************************************/ + +#ifndef _OPENSLES_PLATFORM_H_ +#define _OPENSLES_PLATFORM_H_ + +typedef unsigned char sl_uint8_t; +typedef signed char sl_int8_t; +typedef unsigned short sl_uint16_t; +typedef signed short sl_int16_t; +typedef unsigned long sl_uint32_t; +typedef signed long sl_int32_t; + +#ifndef SLAPIENTRY +#define SLAPIENTRY /* override per-platform */ +#endif + +#endif /* _OPENSLES_PLATFORM_H_ */ diff --git a/third_party/openSLES/api/1.0.1/README.txt b/third_party/openSLES/api/1.0.1/README.txt index 7ed9498ee7b6a335d00273c3554b5cc4d771018c..848ce5ab92552eb36b0bdc8a942848561133b205 100644 --- a/third_party/openSLES/api/1.0.1/README.txt +++ b/third_party/openSLES/api/1.0.1/README.txt @@ -1,2 +1,2 @@ -When building applications using the OpenSL-ES API you should compile and link the OpenSLES_IID.c file into your project. This file contains unique interface IDs for all OpenSL-ES API interfaces. These IDs have +When building applications using the OpenSL-ES API you should compile and link the OpenSLES_IID.c file into your project. This file contains unique interface IDs for all OpenSL-ES API interfaces. These IDs have have been automatically generated. Application developers should not edit these interface IDs. \ No newline at end of file diff --git a/third_party/openSLES/api/1.0/OpenSLES.h b/third_party/openSLES/api/1.0/OpenSLES.h index 7d028334f4f829fd1e7ff2cbff582da91901eaf9..21a25b9747e46bec998e9a61dd23451c7becb4c2 100644 --- a/third_party/openSLES/api/1.0/OpenSLES.h +++ b/third_party/openSLES/api/1.0/OpenSLES.h @@ -1,2768 +1,2768 @@ -/* - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES.h - OpenSL ES version 1.0 - * - */ - -/****************************************************************************/ -/* NOTE: This file is a standard OpenSL ES header file and should not be */ -/* modified in any way. */ -/****************************************************************************/ - -#ifndef OPENSL_ES_H_ -#define OPENSL_ES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "OpenSLES_Platform.h" - - -/*****************************************************************************/ -/* Common types, structures, and defines */ -/*****************************************************************************/ - -#ifndef _KHRONOS_KEYS_ -#define _KHRONOS_KEYS_ - -#define KHRONOS_TITLE "KhronosTitle" -#define KHRONOS_ALBUM "KhronosAlbum" -#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" -#define KHRONOS_ARTIST "KhronosArtist" -#define KHRONOS_GENRE "KhronosGenre" -#define KHRONOS_YEAR "KhronosYear" -#define KHRONOS_COMMENT "KhronosComment" -#define KHRONOS_ARTIST_URL "KhronosArtistURL" -#define KHRONOS_CONTENT_URL "KhronosContentURL" -#define KHRONOS_RATING "KhronosRating" -#define KHRONOS_ALBUM_ART "KhronosAlbumArt" -#define KHRONOS_COPYRIGHT "KhronosCopyright" - -#endif - - -/* remap common types to SL types for clarity */ -typedef sl_int8_t SLint8; /* 8 bit signed integer */ -typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ -typedef sl_int16_t SLint16; /* 16 bit signed integer */ -typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ -typedef sl_int32_t SLint32; /* 32 bit signed integer */ -typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ - -typedef SLuint32 SLboolean; -#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) -#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) - -typedef SLuint8 SLchar; /* UTF-8 is to be used */ -typedef SLint16 SLmillibel; -typedef SLuint32 SLmillisecond; -typedef SLuint32 SLmilliHertz; -typedef SLint32 SLmillimeter; -typedef SLint32 SLmillidegree; -typedef SLint16 SLpermille; -typedef SLuint32 SLmicrosecond; -typedef SLuint32 SLresult; - -#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) -#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) - -#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) -#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) - -/** Interface ID defined as a UUID */ -typedef const struct SLInterfaceID_ { - SLuint32 time_low; - SLuint16 time_mid; - SLuint16 time_hi_and_version; - SLuint16 clock_seq; - SLuint8 node[6]; -} * SLInterfaceID; - -/* Forward declaration for the object interface */ -struct SLObjectItf_; - -typedef const struct SLObjectItf_ * const * SLObjectItf; - -/* Objects ID's */ - -#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) -#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) -#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) -#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) -#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) -#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) -#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) -#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) -#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) -#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) - - -/* SL Profiles */ - -#define SL_PROFILES_PHONE ((SLuint16) 0x0001) -#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) -#define SL_PROFILES_GAME ((SLuint16) 0x0004) - -/* Types of voices supported by the system */ - -#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) -#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) -#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) -#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) - -/* Convenient macros representing various different priority levels, for use with the SetPriority method */ - -#define SL_PRIORITY_LOWEST ((SLint32) (-0x7FFFFFFF-1)) -#define SL_PRIORITY_VERYLOW ((SLint32) -0x60000000) -#define SL_PRIORITY_LOW ((SLint32) -0x40000000) -#define SL_PRIORITY_BELOWNORMAL ((SLint32) -0x20000000) -#define SL_PRIORITY_NORMAL ((SLint32) 0x00000000) -#define SL_PRIORITY_ABOVENORMAL ((SLint32) 0x20000000) -#define SL_PRIORITY_HIGH ((SLint32) 0x40000000) -#define SL_PRIORITY_VERYHIGH ((SLint32) 0x60000000) -#define SL_PRIORITY_HIGHEST ((SLint32) 0x7FFFFFFF) - - -/** These macros list the various sample formats that are possible on audio input and output devices. */ - -#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) -#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) -#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) -#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) -#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) -#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) - - -/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ - -#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) -#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) -#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) -#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) -#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) -#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) -#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) -#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) -#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) -#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) -#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) -#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) -#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) - -#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) -#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) -#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) -#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) -#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) -#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) -#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) -#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) -#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) -#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) -#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) -#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) -#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) -#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) -#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) -#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) -#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) -#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) - - -/*****************************************************************************/ -/* Errors */ -/* */ -/*****************************************************************************/ - -#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) -#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) -#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) -#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) -#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) -#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) -#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) -#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) -#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) -#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) -#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) -#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) -#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) -#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) -#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) -#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) -#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) - - -/* Object state definitions */ - -#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) -#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) -#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) - -/* Object event definitions */ - -#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) -#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) -#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) -#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) - - -/*****************************************************************************/ -/* Interface definitions */ -/*****************************************************************************/ - -/** NULL Interface */ - -extern const SLInterfaceID SL_IID_NULL; - -/*---------------------------------------------------------------------------*/ -/* Data Source and Data Sink Structures */ -/*---------------------------------------------------------------------------*/ - -/** Data locator macros */ -#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) -#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) -#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) -#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) -#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) -#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) -#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) -#define SL_DATALOCATOR_RESERVED8 ((SLuint32) 0x00000008) - - - -/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ -typedef struct SLDataLocator_URI_ { - SLuint32 locatorType; - SLchar * URI; -} SLDataLocator_URI; - -/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ -typedef struct SLDataLocator_Address_ { - SLuint32 locatorType; - void *pAddress; - SLuint32 length; -} SLDataLocator_Address; - -/** IODevice-types */ -#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) -#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) -#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) -#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) -#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) - -/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ -typedef struct SLDataLocator_IODevice_ { - SLuint32 locatorType; - SLuint32 deviceType; - SLuint32 deviceID; - SLObjectItf device; -} SLDataLocator_IODevice; - -/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ -typedef struct SLDataLocator_OutputMix { - SLuint32 locatorType; - SLObjectItf outputMix; -} SLDataLocator_OutputMix; - - -/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ -typedef struct SLDataLocator_BufferQueue { - SLuint32 locatorType; - SLuint32 numBuffers; -} SLDataLocator_BufferQueue; - -/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ -typedef struct SLDataLocator_MIDIBufferQueue { - SLuint32 locatorType; - SLuint32 tpqn; - SLuint32 numBuffers; -} SLDataLocator_MIDIBufferQueue; - -/** Data format defines */ -#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) -#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) -#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) - - -/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ -typedef struct SLDataFormat_MIME_ { - SLuint32 formatType; - SLchar * mimeType; - SLuint32 containerType; -} SLDataFormat_MIME; - -/* Byte order of a block of 16- or 32-bit data */ -#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) -#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) - -/* Container type */ -#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) -#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) -#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) -#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) -#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) -#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) -#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) -#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) -#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) -#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) -#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) -#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) -#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) -#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) -#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) -#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) -#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) -#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) -#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) -#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) -#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) -#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) -#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) -#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) -#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) -#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) -#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) - - -/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ -typedef struct SLDataFormat_PCM_ { - SLuint32 formatType; - SLuint32 numChannels; - SLuint32 samplesPerSec; - SLuint32 bitsPerSample; - SLuint32 containerSize; - SLuint32 channelMask; - SLuint32 endianness; -} SLDataFormat_PCM; - -typedef struct SLDataSource_ { - void *pLocator; - void *pFormat; -} SLDataSource; - - -typedef struct SLDataSink_ { - void *pLocator; - void *pFormat; -} SLDataSink; - - - - - - -/*---------------------------------------------------------------------------*/ -/* Standard Object Interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_OBJECT; - -/** Object callback */ - - -typedef void (SLAPIENTRY *slObjectCallback) ( - SLObjectItf caller, - const void * pContext, - SLuint32 event, - SLresult result, - SLuint32 param, - void *pInterface -); - - -struct SLObjectItf_ { - SLresult (*Realize) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*Resume) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*GetState) ( - SLObjectItf self, - SLuint32 * pState - ); - SLresult (*GetInterface) ( - SLObjectItf self, - const SLInterfaceID iid, - void * pInterface - ); - SLresult (*RegisterCallback) ( - SLObjectItf self, - slObjectCallback callback, - void * pContext - ); - void (*AbortAsyncOperation) ( - SLObjectItf self - ); - void (*Destroy) ( - SLObjectItf self - ); - SLresult (*SetPriority) ( - SLObjectItf self, - SLint32 priority, - SLboolean preemptable - ); - SLresult (*GetPriority) ( - SLObjectItf self, - SLint32 *pPriority, - SLboolean *pPreemptable - ); - SLresult (*SetLossOfControlInterfaces) ( - SLObjectItf self, - SLint16 numInterfaces, - SLInterfaceID * pInterfaceIDs, - SLboolean enabled - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio IO Device capabilities interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) -#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) -#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) -#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) -#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) - - -#define SL_DEVCONNECTION_INTEGRATED ((SLuint16) 0x0001) -#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLuint16) 0x0100) -#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLuint16) 0x0200) -#define SL_DEVCONNECTION_NETWORK ((SLuint16) 0x0400) - - -#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) -#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) -#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) -#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) -#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) - - -#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) -#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) -#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) - - -typedef struct SLAudioInputDescriptor_ { - SLchar *deviceName; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *samplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioInputDescriptor; - - -typedef struct SLAudioOutputDescriptor_ { - SLchar *pDeviceName; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *samplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioOutputDescriptor; - - - -extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; - -struct SLAudioIODeviceCapabilitiesItf_; -typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; - - -typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLint32 numInputs, - SLboolean isNew -); - - -typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLint32 numOutputs, - SLboolean isNew -); - -typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLboolean isOutput, - SLint32 numDevices -); - - -struct SLAudioIODeviceCapabilitiesItf_ { - SLresult (*GetAvailableAudioInputs)( - SLAudioIODeviceCapabilitiesItf self, - SLint32 *pNumInputs, - SLuint32 *pInputDeviceIDs - ); - SLresult (*QueryAudioInputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioInputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioInputsChangedCallback callback, - void *pContext - ); - SLresult (*GetAvailableAudioOutputs)( - SLAudioIODeviceCapabilitiesItf self, - SLint32 *pNumOutputs, - SLuint32 *pOutputDeviceIDs - ); - SLresult (*QueryAudioOutputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioOutputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioOutputsChangedCallback callback, - void *pContext - ); - SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slDefaultDeviceIDMapChangedCallback callback, - void *pContext - ); - SLresult (*GetAssociatedAudioInputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLint32 *pNumAudioInputs, - SLuint32 *pAudioInputDeviceIDs - ); - SLresult (*GetAssociatedAudioOutputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLint32 *pNumAudioOutputs, - SLuint32 *pAudioOutputDeviceIDs - ); - SLresult (*GetDefaultAudioDevices) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 defaultDeviceID, - SLint32 *pNumAudioDevices, - SLuint32 *pAudioDeviceIDs - ); - SLresult (*QuerySampleFormatsSupported)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLmilliHertz samplingRate, - SLint32 *pSampleFormats, - SLint32 *pNumOfSampleFormats - ); -}; - - - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the LED array IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLLEDDescriptor_ { - SLuint8 ledCount; - SLuint8 primaryLED; - SLuint32 colorMask; -} SLLEDDescriptor; - - -/*---------------------------------------------------------------------------*/ -/* LED Array interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLHSL_ { - SLmillidegree hue; - SLpermille saturation; - SLpermille lightness; -} SLHSL; - - -extern const SLInterfaceID SL_IID_LED; - -struct SLLEDArrayItf_; -typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; - -struct SLLEDArrayItf_ { - SLresult (*ActivateLEDArray) ( - SLLEDArrayItf self, - SLuint32 lightMask - ); - SLresult (*IsLEDArrayActivated) ( - SLLEDArrayItf self, - SLuint32 *lightMask - ); - SLresult (*SetColor) ( - SLLEDArrayItf self, - SLuint8 index, - const SLHSL *color - ); - SLresult (*GetColor) ( - SLLEDArrayItf self, - SLuint8 index, - SLHSL *color - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the Vibra IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVibraDescriptor_ { - SLboolean supportsFrequency; - SLboolean supportsIntensity; - SLmilliHertz minFrequency; - SLmilliHertz maxFrequency; -} SLVibraDescriptor; - - - -/*---------------------------------------------------------------------------*/ -/* Vibra interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VIBRA; - - -struct SLVibraItf_; -typedef const struct SLVibraItf_ * const * SLVibraItf; - -struct SLVibraItf_ { - SLresult (*Vibrate) ( - SLVibraItf self, - SLboolean vibrate - ); - SLresult (*IsVibrating) ( - SLVibraItf self, - SLboolean *pVibrating - ); - SLresult (*SetFrequency) ( - SLVibraItf self, - SLmilliHertz frequency - ); - SLresult (*GetFrequency) ( - SLVibraItf self, - SLmilliHertz *pFrequency - ); - SLresult (*SetIntensity) ( - SLVibraItf self, - SLpermille intensity - ); - SLresult (*GetIntensity) ( - SLVibraItf self, - SLpermille *pIntensity - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data extraction related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) -#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) -#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) -#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) -#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) -#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) -#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) -#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) -#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) -#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) -#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) -#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) -#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) -#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) -#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) -#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) -#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) -#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) -#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) -#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) -#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) -#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) -#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) -#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) -#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) -#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) -#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) -#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) -#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) -#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) -#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) -#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) - - -#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) -#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) -#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) - - -typedef struct SLMetadataInfo_ { - SLuint32 size; - SLuint32 encoding; - SLchar langCountry[16]; - SLuint8 data[1]; -} SLMetadataInfo; - -extern const SLInterfaceID SL_IID_METADATAEXTRACTION; - -struct SLMetadataExtractionItf_; -typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; - - -struct SLMetadataExtractionItf_ { - SLresult (*GetItemCount) ( - SLMetadataExtractionItf self, - SLuint32 *pItemCount - ); - SLresult (*GetKeySize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pKeySize - ); - SLresult (*GetKey) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 keySize, - SLMetadataInfo *pKey - ); - SLresult (*GetValueSize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pValueSize - ); - SLresult (*GetValue) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 valueSize, - SLMetadataInfo *pValue - ); - SLresult (*AddKeyFilter) ( - SLMetadataExtractionItf self, - SLuint32 keySize, - const void *pKey, - SLuint32 keyEncoding, - const SLchar *pValueLangCountry, - SLuint32 valueEncoding, - SLuint8 filterMask - ); - SLresult (*ClearKeyFilter) ( - SLMetadataExtractionItf self - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data traversal related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) -#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) - - -#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) -#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) -#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) - -#define SL_NODE_PARENT 0xFFFFFFFF - -extern const SLInterfaceID SL_IID_METADATATRAVERSAL; - -struct SLMetadataTraversalItf_; -typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; - -struct SLMetadataTraversalItf_ { - SLresult (*SetMode) ( - SLMetadataTraversalItf self, - SLuint32 mode - ); - SLresult (*GetChildCount) ( - SLMetadataTraversalItf self, - SLuint32 *pCount - ); - SLresult (*GetChildMIMETypeSize) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLuint32 *pSize - ); - SLresult (*GetChildInfo) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLint32 *pNodeID, - SLuint32 *pType, - SLuint32 size, - SLchar *pMimeType - ); - SLresult (*SetActiveNode) ( - SLMetadataTraversalItf self, - SLuint32 index - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Dynamic Source types and interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_DYNAMICSOURCE; - -struct SLDynamicSourceItf_; -typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; - -struct SLDynamicSourceItf_ { - SLresult (*SetSource) ( - SLDynamicSourceItf self, - SLDataSource *pDataSource - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Output Mix interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_OUTPUTMIX; - -struct SLOutputMixItf_; -typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; - -typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( - SLOutputMixItf caller, - void *pContext -); - - -struct SLOutputMixItf_ { - SLresult (*GetDestinationOutputDeviceIDs) ( - SLOutputMixItf self, - SLint32 *pNumDevices, - SLuint32 *pDeviceIDs - ); - SLresult (*RegisterDeviceChangeCallback) ( - SLOutputMixItf self, - slMixDeviceChangeCallback callback, - void *pContext - ); - SLresult (*ReRoute)( - SLOutputMixItf self, - SLint32 numOutputDevices, - SLuint32 *pOutputDeviceIDs - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Playback interface */ -/*---------------------------------------------------------------------------*/ - -/** Playback states */ -#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) - -/** Play events **/ -#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) -#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) - -#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) - - -extern const SLInterfaceID SL_IID_PLAY; - -/** Playback interface methods */ - -struct SLPlayItf_; -typedef const struct SLPlayItf_ * const * SLPlayItf; - -typedef void (SLAPIENTRY *slPlayCallback) ( - SLPlayItf caller, - void *pContext, - SLuint32 event -); - -struct SLPlayItf_ { - SLresult (*SetPlayState) ( - SLPlayItf self, - SLuint32 state - ); - SLresult (*GetPlayState) ( - SLPlayItf self, - SLuint32 *pState - ); - SLresult (*GetDuration) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*GetPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLPlayItf self, - slPlayCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLPlayItf self - ); - SLresult (*GetMarkerPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Prefetch status interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) -#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) - -#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) -#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) -#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) - - -extern const SLInterfaceID SL_IID_PREFETCHSTATUS; - - -/** Prefetch status interface methods */ - -struct SLPrefetchStatusItf_; -typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; - -typedef void (SLAPIENTRY *slPrefetchCallback) ( - SLPrefetchStatusItf caller, - void *pContext, - SLuint32 event -); - -struct SLPrefetchStatusItf_ { - SLresult (*GetPrefetchStatus) ( - SLPrefetchStatusItf self, - SLuint32 *pStatus - ); - SLresult (*GetFillLevel) ( - SLPrefetchStatusItf self, - SLpermille *pLevel - ); - SLresult (*RegisterCallback) ( - SLPrefetchStatusItf self, - slPrefetchCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille period - ); - SLresult (*GetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille *pPeriod - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Playback Rate interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) -#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) -#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) -#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) -#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) -#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) - - -extern const SLInterfaceID SL_IID_PLAYBACKRATE; - -struct SLPlaybackRateItf_; -typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; - -struct SLPlaybackRateItf_ { - SLresult (*SetRate)( - SLPlaybackRateItf self, - SLpermille rate - ); - SLresult (*GetRate)( - SLPlaybackRateItf self, - SLpermille *pRate - ); - SLresult (*SetPropertyConstraints)( - SLPlaybackRateItf self, - SLuint32 constraints - ); - SLresult (*GetProperties)( - SLPlaybackRateItf self, - SLuint32 *pProperties - ); - SLresult (*GetCapabilitiesOfRate)( - SLPlaybackRateItf self, - SLpermille rate, - SLuint32 *pCapabilities - ); - SLresult (*GetRateRange) ( - SLPlaybackRateItf self, - SLuint8 index, - SLpermille *pMinRate, - SLpermille *pMaxRate, - SLpermille *pStepSize, - SLuint32 *pCapabilities - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Seek Interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_SEEKMODE_FAST ((SLuint16) 0x0001) -#define SL_SEEKMODE_ACCURATE ((SLuint16) 0x0002) - -extern const SLInterfaceID SL_IID_SEEK; - -struct SLSeekItf_; -typedef const struct SLSeekItf_ * const * SLSeekItf; - -struct SLSeekItf_ { - SLresult (*SetPosition)( - SLSeekItf self, - SLmillisecond pos, - SLuint32 seekMode - ); - SLresult (*SetLoop)( - SLSeekItf self, - SLboolean loopEnable, - SLmillisecond startPos, - SLmillisecond endPos - ); - SLresult (*GetLoop)( - SLSeekItf self, - SLboolean *pLoopEnabled, - SLmillisecond *pStartPos, - SLmillisecond *pEndPos - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Standard Recording Interface */ -/*---------------------------------------------------------------------------*/ - -/** Recording states */ -#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) - - -/** Record event **/ -#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) -#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) - - -extern const SLInterfaceID SL_IID_RECORD; - -struct SLRecordItf_; -typedef const struct SLRecordItf_ * const * SLRecordItf; - -typedef void (SLAPIENTRY *slRecordCallback) ( - SLRecordItf caller, - void *pContext, - SLuint32 event -); - -/** Recording interface methods */ -struct SLRecordItf_ { - SLresult (*SetRecordState) ( - SLRecordItf self, - SLuint32 state - ); - SLresult (*GetRecordState) ( - SLRecordItf self, - SLuint32 *pState - ); - SLresult (*SetDurationLimit) ( - SLRecordItf self, - SLmillisecond msec - ); - SLresult (*GetPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLRecordItf self, - slRecordCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLRecordItf self - ); - SLresult (*GetMarkerPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Equalizer interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) - -extern const SLInterfaceID SL_IID_EQUALIZER; - -struct SLEqualizerItf_; -typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; - -struct SLEqualizerItf_ { - SLresult (*SetEnabled)( - SLEqualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLEqualizerItf self, - SLboolean *pEnabled - ); - SLresult (*GetNumberOfBands)( - SLEqualizerItf self, - SLuint16 *pAmount - ); - SLresult (*GetBandLevelRange)( - SLEqualizerItf self, - SLmillibel *pMin, - SLmillibel *pMax - ); - SLresult (*SetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel level - ); - SLresult (*GetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel *pLevel - ); - SLresult (*GetCenterFreq)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pCenter - ); - SLresult (*GetBandFreqRange)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pMin, - SLmilliHertz *pMax - ); - SLresult (*GetBand)( - SLEqualizerItf self, - SLmilliHertz frequency, - SLuint16 *pBand - ); - SLresult (*GetCurrentPreset)( - SLEqualizerItf self, - SLuint16 *pPreset - ); - SLresult (*UsePreset)( - SLEqualizerItf self, - SLuint16 index - ); - SLresult (*GetNumberOfPresets)( - SLEqualizerItf self, - SLuint16 *pNumPresets - ); - SLresult (*GetPresetName)( - SLEqualizerItf self, - SLuint16 index, - const SLchar ** ppName - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Volume Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_VOLUME; - -struct SLVolumeItf_; -typedef const struct SLVolumeItf_ * const * SLVolumeItf; - -struct SLVolumeItf_ { - SLresult (*SetVolumeLevel) ( - SLVolumeItf self, - SLmillibel level - ); - SLresult (*GetVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pLevel - ); - SLresult (*GetMaxVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pMaxLevel - ); - SLresult (*SetMute) ( - SLVolumeItf self, - SLboolean mute - ); - SLresult (*GetMute) ( - SLVolumeItf self, - SLboolean *pMute - ); - SLresult (*EnableStereoPosition) ( - SLVolumeItf self, - SLboolean enable - ); - SLresult (*IsEnabledStereoPosition) ( - SLVolumeItf self, - SLboolean *pEnable - ); - SLresult (*SetStereoPosition) ( - SLVolumeItf self, - SLpermille stereoPosition - ); - SLresult (*GetStereoPosition) ( - SLVolumeItf self, - SLpermille *pStereoPosition - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Device Volume Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_DEVICEVOLUME; - -struct SLDeviceVolumeItf_; -typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; - -struct SLDeviceVolumeItf_ { - SLresult (*GetVolumeScale) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pMinValue, - SLint32 *pMaxValue, - SLboolean *pIsMillibelScale - ); - SLresult (*SetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 volume - ); - SLresult (*GetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pVolume - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Buffer Queue Interface */ -/*---------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_BUFFERQUEUE; - -struct SLBufferQueueItf_; -typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; - -typedef void (SLAPIENTRY *slBufferQueueCallback)( - SLBufferQueueItf caller, - void *pContext -); - -/** Buffer queue state **/ - -typedef struct SLBufferQueueState_ { - SLuint32 count; - SLuint32 playIndex; -} SLBufferQueueState; - - -struct SLBufferQueueItf_ { - SLresult (*Enqueue) ( - SLBufferQueueItf self, - const void *pBuffer, - SLuint32 size - ); - SLresult (*Clear) ( - SLBufferQueueItf self - ); - SLresult (*GetState) ( - SLBufferQueueItf self, - SLBufferQueueState *pState - ); - SLresult (*RegisterCallback) ( - SLBufferQueueItf self, - slBufferQueueCallback callback, - void* pContext - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* PresetReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) -#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) -#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) -#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) -#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) -#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) -#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) - - -extern const SLInterfaceID SL_IID_PRESETREVERB; - -struct SLPresetReverbItf_; -typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; - -struct SLPresetReverbItf_ { - SLresult (*SetPreset) ( - SLPresetReverbItf self, - SLuint16 preset - ); - SLresult (*GetPreset) ( - SLPresetReverbItf self, - SLuint16 *pPreset - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* EnvironmentalReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ - { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ - { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ - { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ - { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ - { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ - { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ - { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ - { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ - { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ - { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ - { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ - { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ - { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ - { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ - { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ - { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ - { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ - { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ - { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ - { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ - { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ - { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ - { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ - { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ - { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ - { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ - { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ - { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ - { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ - { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } - - -typedef struct SLEnvironmentalReverbSettings_ { - SLmillibel roomLevel; - SLmillibel roomHFLevel; - SLmillisecond decayTime; - SLpermille decayHFRatio; - SLmillibel reflectionsLevel; - SLmillisecond reflectionsDelay; - SLmillibel reverbLevel; - SLmillisecond reverbDelay; - SLpermille diffusion; - SLpermille density; -} SLEnvironmentalReverbSettings; - - - - -extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; - - -struct SLEnvironmentalReverbItf_; -typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; - -struct SLEnvironmentalReverbItf_ { - SLresult (*SetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel room - ); - SLresult (*GetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoom - ); - SLresult (*SetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel roomHF - ); - SLresult (*GetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoomHF - ); - SLresult (*SetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond decayTime - ); - SLresult (*GetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pDecayTime - ); - SLresult (*SetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille decayHFRatio - ); - SLresult (*GetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille *pDecayHFRatio - ); - SLresult (*SetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reflectionsLevel - ); - SLresult (*GetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReflectionsLevel - ); - SLresult (*SetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reflectionsDelay - ); - SLresult (*GetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReflectionsDelay - ); - SLresult (*SetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reverbLevel - ); - SLresult (*GetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReverbLevel - ); - SLresult (*SetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reverbDelay - ); - SLresult (*GetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReverbDelay - ); - SLresult (*SetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille diffusion - ); - SLresult (*GetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille *pDiffusion - ); - SLresult (*SetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille density - ); - SLresult (*GetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille *pDensity - ); - SLresult (*SetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - const SLEnvironmentalReverbSettings *pProperties - ); - SLresult (*GetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - SLEnvironmentalReverbSettings *pProperties - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Effects Send Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_EFFECTSEND; - -struct SLEffectSendItf_; -typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; - -struct SLEffectSendItf_ { - SLresult (*EnableEffectSend) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLboolean enable, - SLmillibel initialLevel - ); - SLresult (*IsEnabled) ( - SLEffectSendItf self, - const void * pAuxEffect, - SLboolean *pEnable - ); - SLresult (*SetDirectLevel) ( - SLEffectSendItf self, - SLmillibel directLevel - ); - SLresult (*GetDirectLevel) ( - SLEffectSendItf self, - SLmillibel *pDirectLevel - ); - SLresult (*SetSendLevel) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel sendLevel - ); - SLresult (*GetSendLevel)( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel *pSendLevel - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Grouping Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DGROUPING; - - -struct SL3DGroupingItf_ ; -typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; - -struct SL3DGroupingItf_ { - SLresult (*Set3DGroup) ( - SL3DGroupingItf self, - SLObjectItf group - ); - SLresult (*Get3DGroup) ( - SL3DGroupingItf self, - SLObjectItf *pGroup - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Commit Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DCOMMIT; - -struct SL3DCommitItf_; -typedef const struct SL3DCommitItf_* const * SL3DCommitItf; - -struct SL3DCommitItf_ { - SLresult (*Commit) ( - SL3DCommitItf self - ); - SLresult (*SetDeferred) ( - SL3DCommitItf self, - SLboolean deferred - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Location Interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVec3D_ { - SLint32 x; - SLint32 y; - SLint32 z; -} SLVec3D; - -extern const SLInterfaceID SL_IID_3DLOCATION; - -struct SL3DLocationItf_; -typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; - -struct SL3DLocationItf_ { - SLresult (*SetLocationCartesian) ( - SL3DLocationItf self, - const SLVec3D *pLocation - ); - SLresult (*SetLocationSpherical) ( - SL3DLocationItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter distance - ); - SLresult (*Move) ( - SL3DLocationItf self, - const SLVec3D *pMovement - ); - SLresult (*GetLocationCartesian) ( - SL3DLocationItf self, - SLVec3D *pLocation - ); - SLresult (*SetOrientationVectors) ( - SL3DLocationItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*SetOrientationAngles) ( - SL3DLocationItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*Rotate) ( - SL3DLocationItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DLocationItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Doppler Interface */ -/*---------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_3DDOPPLER; - -struct SL3DDopplerItf_; -typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; - -struct SL3DDopplerItf_ { - SLresult (*SetVelocityCartesian) ( - SL3DDopplerItf self, - const SLVec3D *pVelocity - ); - SLresult (*SetVelocitySpherical) ( - SL3DDopplerItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter speed - ); - SLresult (*GetVelocityCartesian) ( - SL3DDopplerItf self, - SLVec3D *pVelocity - ); - SLresult (*SetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille dopplerFactor - ); - SLresult (*GetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille *pDopplerFactor - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Source Interface and associated defines */ -/* --------------------------------------------------------------------------*/ - -#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) -#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) - - -extern const SLInterfaceID SL_IID_3DSOURCE; - -struct SL3DSourceItf_; -typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; - -struct SL3DSourceItf_ { - SLresult (*SetHeadRelative) ( - SL3DSourceItf self, - SLboolean headRelative - ); - SLresult (*GetHeadRelative) ( - SL3DSourceItf self, - SLboolean *pHeadRelative - ); - SLresult (*SetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter minDistance, - SLmillimeter maxDistance - ); - SLresult (*GetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter *pMinDistance, - SLmillimeter *pMaxDistance - ); - SLresult (*SetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean mute - ); - SLresult (*GetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean *pMute - ); - SLresult (*SetRolloffFactor) ( - SL3DSourceItf self, - SLpermille rolloffFactor - ); - SLresult (*GetRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRolloffFactor - ); - SLresult (*SetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille roomRolloffFactor - ); - SLresult (*GetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRoomRolloffFactor - ); - SLresult (*SetRolloffModel) ( - SL3DSourceItf self, - SLuint8 model - ); - SLresult (*GetRolloffModel) ( - SL3DSourceItf self, - SLuint8 *pModel - ); - SLresult (*SetCone) ( - SL3DSourceItf self, - SLmillidegree innerAngle, - SLmillidegree outerAngle, - SLmillibel outerLevel - ); - SLresult (*GetCone) ( - SL3DSourceItf self, - SLmillidegree *pInnerAngle, - SLmillidegree *pOuterAngle, - SLmillibel *pOuterLevel - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Macroscopic Interface */ -/* --------------------------------------------------------------------------*/ - -extern const SLInterfaceID SL_IID_3DMACROSCOPIC; - -struct SL3DMacroscopicItf_; -typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; - -struct SL3DMacroscopicItf_ { - SLresult (*SetSize) ( - SL3DMacroscopicItf self, - SLmillimeter width, - SLmillimeter height, - SLmillimeter depth - ); - SLresult (*GetSize) ( - SL3DMacroscopicItf self, - SLmillimeter *pWidth, - SLmillimeter *pHeight, - SLmillimeter *pDepth - ); - SLresult (*SetOrientationAngles) ( - SL3DMacroscopicItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*SetOrientationVectors) ( - SL3DMacroscopicItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*Rotate) ( - SL3DMacroscopicItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DMacroscopicItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Mute Solo Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MUTESOLO; - -struct SLMuteSoloItf_; -typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; - -struct SLMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pSolo - ); - SLresult (*GetNumChannels) ( - SLMuteSoloItf self, - SLuint8 *pNumChannels - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Dynamic Interface Management Interface and associated types and macros */ -/* --------------------------------------------------------------------------*/ - -#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) - - - - -extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; - -struct SLDynamicInterfaceManagementItf_; -typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; - -typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( - SLDynamicInterfaceManagementItf caller, - void * pContext, - SLuint32 event, - SLresult result, - const SLInterfaceID iid -); - - -struct SLDynamicInterfaceManagementItf_ { - SLresult (*AddInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RemoveInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid - ); - SLresult (*ResumeInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RegisterCallback) ( - SLDynamicInterfaceManagementItf self, - slDynamicInterfaceManagementCallback callback, - void * pContext - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Midi Message Interface and associated types */ -/* --------------------------------------------------------------------------*/ - -#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) -#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) -#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) -#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) -#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) -#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) -#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) - - -extern const SLInterfaceID SL_IID_MIDIMESSAGE; - -struct SLMIDIMessageItf_; -typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; - -typedef void (SLAPIENTRY *slMetaEventCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 type, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -typedef void (SLAPIENTRY *slMIDIMessageCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 statusByte, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -struct SLMIDIMessageItf_ { - SLresult (*SendMessage) ( - SLMIDIMessageItf self, - const SLuint8 *data, - SLuint32 length - ); - SLresult (*RegisterMetaEventCallback) ( - SLMIDIMessageItf self, - slMetaEventCallback callback, - void *pContext - ); - SLresult (*RegisterMIDIMessageCallback) ( - SLMIDIMessageItf self, - slMIDIMessageCallback callback, - void *pContext - ); - SLresult (*AddMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self, - SLuint32 messageType - ); - SLresult (*ClearMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Mute Solo interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDIMUTESOLO; - -struct SLMIDIMuteSoloItf_; -typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; - -struct SLMIDIMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pSolo - ); - SLresult (*GetTrackCount) ( - SLMIDIMuteSoloItf self, - SLuint16 *pCount - ); - SLresult (*SetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean mute - ); - SLresult (*GetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pMute - ); - SLresult (*SetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean solo - ); - SLresult (*GetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pSolo - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Tempo interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDITEMPO; - -struct SLMIDITempoItf_; -typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; - -struct SLMIDITempoItf_ { - SLresult (*SetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 tpqn - ); - SLresult (*GetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 *pTpqn - ); - SLresult (*SetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond uspqn - ); - SLresult (*GetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond *uspqn - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Time interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_MIDITIME; - -struct SLMIDITimeItf_; -typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; - -struct SLMIDITimeItf_ { - SLresult (*GetDuration) ( - SLMIDITimeItf self, - SLuint32 *pDuration - ); - SLresult (*SetPosition) ( - SLMIDITimeItf self, - SLuint32 position - ); - SLresult (*GetPosition) ( - SLMIDITimeItf self, - SLuint32 *pPosition - ); - SLresult (*SetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 startTick, - SLuint32 numTicks - ); - SLresult (*GetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 *pStartTick, - SLuint32 *pNumTicks - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Decoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/*Audio Codec related defines*/ - -#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) -#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) - -#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) -#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) -#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) -#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) -#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) -#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) -#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) -#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) - -#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) - -#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) -#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) -#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) -#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) - -#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) - -#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) - -#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) -#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) -#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) - -#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) -#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) - -#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) -#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) - -#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) - -#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) - -typedef struct SLAudioCodecDescriptor_ { - SLuint32 maxChannels; - SLuint32 minBitsPerSample; - SLuint32 maxBitsPerSample; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *pSampleRatesSupported; - SLuint32 numSampleRatesSupported; - SLuint32 minBitRate; - SLuint32 maxBitRate; - SLboolean isBitrateRangeContinuous; - SLuint32 *pBitratesSupported; - SLuint32 numBitratesSupported; - SLuint32 profileSetting; - SLuint32 modeSetting; -} SLAudioCodecDescriptor; - -/*Structure used to retrieve the profile and level settings supported by an audio encoder */ - -typedef struct SLAudioCodecProfileMode_ { - SLuint32 profileSetting; - SLuint32 modeSetting; -} SLAudioCodecProfileMode; - -extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; - -struct SLAudioDecoderCapabilitiesItf_; -typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; - -struct SLAudioDecoderCapabilitiesItf_ { - SLresult (*GetAudioDecoders) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 * pNumDecoders , - SLuint32 *pDecoderIds - ); - SLresult (*GetAudioDecoderCapabilities) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 decoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor *pDescriptor - ); -}; - - - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/* Structure used when setting audio encoding parameters */ - -typedef struct SLAudioEncoderSettings_ { - SLuint32 encoderId; - SLuint32 channelsIn; - SLuint32 channelsOut; - SLmilliHertz sampleRate; - SLuint32 bitRate; - SLuint32 bitsPerSample; - SLuint32 rateControl; - SLuint32 profileSetting; - SLuint32 levelSetting; - SLuint32 channelMode; - SLuint32 streamFormat; - SLuint32 encodeOptions; - SLuint32 blockAlignment; -} SLAudioEncoderSettings; - -extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; - -struct SLAudioEncoderCapabilitiesItf_; -typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; - -struct SLAudioEncoderCapabilitiesItf_ { - SLresult (*GetAudioEncoders) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 *pNumEncoders , - SLuint32 *pEncoderIds - ); - SLresult (*GetAudioEncoderCapabilities) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 encoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor * pDescriptor - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_AUDIOENCODER; - -struct SLAudioEncoderItf_; -typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; - -struct SLAudioEncoderItf_ { - SLresult (*SetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); - SLresult (*GetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Bass Boost Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_BASSBOOST; - -struct SLBassBoostItf_; -typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; - -struct SLBassBoostItf_ { - SLresult (*SetEnabled)( - SLBassBoostItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLBassBoostItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLBassBoostItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLBassBoostItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLBassBoostItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Pitch Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_PITCH; - -struct SLPitchItf_; -typedef const struct SLPitchItf_ * const * SLPitchItf; - -struct SLPitchItf_ { - SLresult (*SetPitch) ( - SLPitchItf self, - SLpermille pitch - ); - SLresult (*GetPitch) ( - SLPitchItf self, - SLpermille *pPitch - ); - SLresult (*GetPitchCapabilities) ( - SLPitchItf self, - SLpermille *pMinPitch, - SLpermille *pMaxPitch - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Rate Pitch Interface */ -/* RatePitchItf is an interface for controlling the rate a sound is played */ -/* back. A change in rate will cause a change in pitch. */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_RATEPITCH; - -struct SLRatePitchItf_; -typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; - -struct SLRatePitchItf_ { - SLresult (*SetRate) ( - SLRatePitchItf self, - SLpermille rate - ); - SLresult (*GetRate) ( - SLRatePitchItf self, - SLpermille *pRate - ); - SLresult (*GetRatePitchCapabilities) ( - SLRatePitchItf self, - SLpermille *pMinRate, - SLpermille *pMaxRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Virtualizer Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VIRTUALIZER; - -struct SLVirtualizerItf_; -typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; - -struct SLVirtualizerItf_ { - SLresult (*SetEnabled)( - SLVirtualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLVirtualizerItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLVirtualizerItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLVirtualizerItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLVirtualizerItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Visualization Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_VISUALIZATION; - -struct SLVisualizationItf_; -typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; - -typedef void (SLAPIENTRY *slVisualizationCallback) ( - void *pContext, - const SLuint8 waveform[], - const SLuint8 fft[], - SLmilliHertz samplerate -); - -struct SLVisualizationItf_{ - SLresult (*RegisterVisualizationCallback)( - SLVisualizationItf self, - slVisualizationCallback callback, - void *pContext, - SLmilliHertz rate - ); - SLresult (*GetMaxRate)( - SLVisualizationItf self, - SLmilliHertz* pRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_ENGINE; - -struct SLEngineItf_; -typedef const struct SLEngineItf_ * const * SLEngineItf; - - -struct SLEngineItf_ { - - SLresult (*CreateLEDDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateVibraDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - SLDataSource *pAudioSrc, - SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioRecorder) ( - SLEngineItf self, - SLObjectItf * pRecorder, - SLDataSource *pAudioSrc, - SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMidiPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - SLDataSource *pMIDISrc, - SLDataSource *pBankSrc, - SLDataSink *pAudioOutput, - SLDataSink *pVibra, - SLDataSink *pLEDArray, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateListener) ( - SLEngineItf self, - SLObjectItf * pListener, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*Create3DGroup) ( - SLEngineItf self, - SLObjectItf * pGroup, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateOutputMix) ( - SLEngineItf self, - SLObjectItf * pMix, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMetadataExtractor) ( - SLEngineItf self, - SLObjectItf * pMetadataExtractor, - SLDataSource * pDataSource, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateExtensionObject) ( - SLEngineItf self, - SLObjectItf * pObject, - void * pParameters, - SLuint32 objectID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*QueryNumSupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 * pNumSupportedInterfaces - ); - SLresult (*QuerySupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 index, - SLInterfaceID * pInterfaceId - ); - SLresult (*QueryNumSupportedExtensions) ( - SLEngineItf self, - SLuint32 * pNumExtensions - ); - SLresult (*QuerySupportedExtension) ( - SLEngineItf self, - SLuint32 index, - SLchar * pExtensionName, - SLint16 * pNameLength - ); - SLresult (*IsExtensionSupported) ( - SLEngineItf self, - const SLchar * pExtensionName, - SLboolean * pSupported - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; - -struct SLEngineCapabilitiesItf_; -typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; - -struct SLEngineCapabilitiesItf_ { - SLresult (*QuerySupportedProfiles) ( - SLEngineCapabilitiesItf self, - SLuint16 *pProfilesSupported - ); - SLresult (*QueryAvailableVoices) ( - SLEngineCapabilitiesItf self, - SLuint16 voiceType, - SLint16 *pNumMaxVoices, - SLboolean *pIsAbsoluteMax, - SLint16 *pNumFreeVoices - ); - SLresult (*QueryNumberOfMIDISynthesizers) ( - SLEngineCapabilitiesItf self, - SLint16 *pNumMIDIsynthesizers - ); - SLresult (*QueryAPIVersion) ( - SLEngineCapabilitiesItf self, - SLint16 *pMajor, - SLint16 *pMinor, - SLint16 *pStep - ); - SLresult (*QueryLEDCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pLEDDeviceID, - SLLEDDescriptor *pDescriptor - ); - SLresult (*QueryVibraCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pVibraDeviceID, - SLVibraDescriptor *pDescriptor - ); - SLresult (*IsThreadSafe) ( - SLEngineCapabilitiesItf self, - SLboolean *pIsThreadSafe - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Thread Sync Interface */ -/* --------------------------------------------------------------------------*/ - - -extern const SLInterfaceID SL_IID_THREADSYNC; - -struct SLThreadSyncItf_; -typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; - - -struct SLThreadSyncItf_ { - SLresult (*EnterCriticalSection) ( - SLThreadSyncItf self - ); - SLresult (*ExitCriticalSection) ( - SLThreadSyncItf self - ); -}; - - -/*****************************************************************************/ -/* SL engine constructor */ -/*****************************************************************************/ - -#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) -#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) - -typedef struct SLEngineOption_ { - SLuint32 feature; - SLuint32 data; -} SLEngineOption; - - -SLresult SLAPIENTRY slCreateEngine( - SLObjectItf *pEngine, - SLuint32 numOptions, - const SLEngineOption *pEngineOptions, - SLuint32 numInterfaces, - const SLInterfaceID *pInterfaceIds, - const SLboolean * pInterfaceRequired -); - -SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( - SLuint32 * pNumSupportedInterfaces -); - -SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( - SLuint32 index, - SLInterfaceID * pInterfaceId -); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* OPENSL_ES_H_ */ +/* + * Copyright (c) 2008 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES.h - OpenSL ES version 1.0 + * + */ + +/****************************************************************************/ +/* NOTE: This file is a standard OpenSL ES header file and should not be */ +/* modified in any way. */ +/****************************************************************************/ + +#ifndef OPENSL_ES_H_ +#define OPENSL_ES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "OpenSLES_Platform.h" + + +/*****************************************************************************/ +/* Common types, structures, and defines */ +/*****************************************************************************/ + +#ifndef _KHRONOS_KEYS_ +#define _KHRONOS_KEYS_ + +#define KHRONOS_TITLE "KhronosTitle" +#define KHRONOS_ALBUM "KhronosAlbum" +#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" +#define KHRONOS_ARTIST "KhronosArtist" +#define KHRONOS_GENRE "KhronosGenre" +#define KHRONOS_YEAR "KhronosYear" +#define KHRONOS_COMMENT "KhronosComment" +#define KHRONOS_ARTIST_URL "KhronosArtistURL" +#define KHRONOS_CONTENT_URL "KhronosContentURL" +#define KHRONOS_RATING "KhronosRating" +#define KHRONOS_ALBUM_ART "KhronosAlbumArt" +#define KHRONOS_COPYRIGHT "KhronosCopyright" + +#endif + + +/* remap common types to SL types for clarity */ +typedef sl_int8_t SLint8; /* 8 bit signed integer */ +typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ +typedef sl_int16_t SLint16; /* 16 bit signed integer */ +typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ +typedef sl_int32_t SLint32; /* 32 bit signed integer */ +typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ + +typedef SLuint32 SLboolean; +#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) +#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) + +typedef SLuint8 SLchar; /* UTF-8 is to be used */ +typedef SLint16 SLmillibel; +typedef SLuint32 SLmillisecond; +typedef SLuint32 SLmilliHertz; +typedef SLint32 SLmillimeter; +typedef SLint32 SLmillidegree; +typedef SLint16 SLpermille; +typedef SLuint32 SLmicrosecond; +typedef SLuint32 SLresult; + +#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) +#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) + +#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) +#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) + +/** Interface ID defined as a UUID */ +typedef const struct SLInterfaceID_ { + SLuint32 time_low; + SLuint16 time_mid; + SLuint16 time_hi_and_version; + SLuint16 clock_seq; + SLuint8 node[6]; +} * SLInterfaceID; + +/* Forward declaration for the object interface */ +struct SLObjectItf_; + +typedef const struct SLObjectItf_ * const * SLObjectItf; + +/* Objects ID's */ + +#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) +#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) +#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) +#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) +#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) +#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) +#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) +#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) +#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) +#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) + + +/* SL Profiles */ + +#define SL_PROFILES_PHONE ((SLuint16) 0x0001) +#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) +#define SL_PROFILES_GAME ((SLuint16) 0x0004) + +/* Types of voices supported by the system */ + +#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) +#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) +#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) +#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) + +/* Convenient macros representing various different priority levels, for use with the SetPriority method */ + +#define SL_PRIORITY_LOWEST ((SLint32) (-0x7FFFFFFF-1)) +#define SL_PRIORITY_VERYLOW ((SLint32) -0x60000000) +#define SL_PRIORITY_LOW ((SLint32) -0x40000000) +#define SL_PRIORITY_BELOWNORMAL ((SLint32) -0x20000000) +#define SL_PRIORITY_NORMAL ((SLint32) 0x00000000) +#define SL_PRIORITY_ABOVENORMAL ((SLint32) 0x20000000) +#define SL_PRIORITY_HIGH ((SLint32) 0x40000000) +#define SL_PRIORITY_VERYHIGH ((SLint32) 0x60000000) +#define SL_PRIORITY_HIGHEST ((SLint32) 0x7FFFFFFF) + + +/** These macros list the various sample formats that are possible on audio input and output devices. */ + +#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) +#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) +#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) +#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) +#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) +#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) + + +/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ + +#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) +#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) +#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) +#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) +#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) +#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) +#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) +#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) +#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) +#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) +#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) +#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) +#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) + +#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) +#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) +#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) +#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) +#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) +#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) +#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) +#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) +#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) +#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) +#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) +#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) +#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) +#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) +#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) +#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) +#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) +#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) + + +/*****************************************************************************/ +/* Errors */ +/* */ +/*****************************************************************************/ + +#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) +#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) +#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) +#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) +#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) +#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) +#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) +#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) +#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) +#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) +#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) +#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) +#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) +#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) +#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) +#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) +#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) + + +/* Object state definitions */ + +#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) +#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) +#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) + +/* Object event definitions */ + +#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) +#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) +#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) +#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) + + +/*****************************************************************************/ +/* Interface definitions */ +/*****************************************************************************/ + +/** NULL Interface */ + +extern const SLInterfaceID SL_IID_NULL; + +/*---------------------------------------------------------------------------*/ +/* Data Source and Data Sink Structures */ +/*---------------------------------------------------------------------------*/ + +/** Data locator macros */ +#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) +#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) +#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) +#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) +#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) +#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) +#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) +#define SL_DATALOCATOR_RESERVED8 ((SLuint32) 0x00000008) + + + +/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ +typedef struct SLDataLocator_URI_ { + SLuint32 locatorType; + SLchar * URI; +} SLDataLocator_URI; + +/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ +typedef struct SLDataLocator_Address_ { + SLuint32 locatorType; + void *pAddress; + SLuint32 length; +} SLDataLocator_Address; + +/** IODevice-types */ +#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) +#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) +#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) +#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) +#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) + +/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ +typedef struct SLDataLocator_IODevice_ { + SLuint32 locatorType; + SLuint32 deviceType; + SLuint32 deviceID; + SLObjectItf device; +} SLDataLocator_IODevice; + +/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ +typedef struct SLDataLocator_OutputMix { + SLuint32 locatorType; + SLObjectItf outputMix; +} SLDataLocator_OutputMix; + + +/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ +typedef struct SLDataLocator_BufferQueue { + SLuint32 locatorType; + SLuint32 numBuffers; +} SLDataLocator_BufferQueue; + +/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ +typedef struct SLDataLocator_MIDIBufferQueue { + SLuint32 locatorType; + SLuint32 tpqn; + SLuint32 numBuffers; +} SLDataLocator_MIDIBufferQueue; + +/** Data format defines */ +#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) +#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) +#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) + + +/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ +typedef struct SLDataFormat_MIME_ { + SLuint32 formatType; + SLchar * mimeType; + SLuint32 containerType; +} SLDataFormat_MIME; + +/* Byte order of a block of 16- or 32-bit data */ +#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) +#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) + +/* Container type */ +#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) +#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) +#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) +#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) +#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) +#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) +#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) +#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) +#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) +#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) +#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) +#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) +#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) +#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) +#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) +#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) +#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) +#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) +#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) +#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) +#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) +#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) +#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) +#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) +#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) +#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) +#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) + + +/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ +typedef struct SLDataFormat_PCM_ { + SLuint32 formatType; + SLuint32 numChannels; + SLuint32 samplesPerSec; + SLuint32 bitsPerSample; + SLuint32 containerSize; + SLuint32 channelMask; + SLuint32 endianness; +} SLDataFormat_PCM; + +typedef struct SLDataSource_ { + void *pLocator; + void *pFormat; +} SLDataSource; + + +typedef struct SLDataSink_ { + void *pLocator; + void *pFormat; +} SLDataSink; + + + + + + +/*---------------------------------------------------------------------------*/ +/* Standard Object Interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OBJECT; + +/** Object callback */ + + +typedef void (SLAPIENTRY *slObjectCallback) ( + SLObjectItf caller, + const void * pContext, + SLuint32 event, + SLresult result, + SLuint32 param, + void *pInterface +); + + +struct SLObjectItf_ { + SLresult (*Realize) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*Resume) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*GetState) ( + SLObjectItf self, + SLuint32 * pState + ); + SLresult (*GetInterface) ( + SLObjectItf self, + const SLInterfaceID iid, + void * pInterface + ); + SLresult (*RegisterCallback) ( + SLObjectItf self, + slObjectCallback callback, + void * pContext + ); + void (*AbortAsyncOperation) ( + SLObjectItf self + ); + void (*Destroy) ( + SLObjectItf self + ); + SLresult (*SetPriority) ( + SLObjectItf self, + SLint32 priority, + SLboolean preemptable + ); + SLresult (*GetPriority) ( + SLObjectItf self, + SLint32 *pPriority, + SLboolean *pPreemptable + ); + SLresult (*SetLossOfControlInterfaces) ( + SLObjectItf self, + SLint16 numInterfaces, + SLInterfaceID * pInterfaceIDs, + SLboolean enabled + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio IO Device capabilities interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) +#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) +#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) +#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) +#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) + + +#define SL_DEVCONNECTION_INTEGRATED ((SLuint16) 0x0001) +#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLuint16) 0x0100) +#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLuint16) 0x0200) +#define SL_DEVCONNECTION_NETWORK ((SLuint16) 0x0400) + + +#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) +#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) +#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) +#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) +#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) + + +#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) +#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) +#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) + + +typedef struct SLAudioInputDescriptor_ { + SLchar *deviceName; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *samplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioInputDescriptor; + + +typedef struct SLAudioOutputDescriptor_ { + SLchar *pDeviceName; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *samplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioOutputDescriptor; + + + +extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; + +struct SLAudioIODeviceCapabilitiesItf_; +typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; + + +typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLint32 numInputs, + SLboolean isNew +); + + +typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLint32 numOutputs, + SLboolean isNew +); + +typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLboolean isOutput, + SLint32 numDevices +); + + +struct SLAudioIODeviceCapabilitiesItf_ { + SLresult (*GetAvailableAudioInputs)( + SLAudioIODeviceCapabilitiesItf self, + SLint32 *pNumInputs, + SLuint32 *pInputDeviceIDs + ); + SLresult (*QueryAudioInputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioInputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioInputsChangedCallback callback, + void *pContext + ); + SLresult (*GetAvailableAudioOutputs)( + SLAudioIODeviceCapabilitiesItf self, + SLint32 *pNumOutputs, + SLuint32 *pOutputDeviceIDs + ); + SLresult (*QueryAudioOutputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioOutputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioOutputsChangedCallback callback, + void *pContext + ); + SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slDefaultDeviceIDMapChangedCallback callback, + void *pContext + ); + SLresult (*GetAssociatedAudioInputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLint32 *pNumAudioInputs, + SLuint32 *pAudioInputDeviceIDs + ); + SLresult (*GetAssociatedAudioOutputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLint32 *pNumAudioOutputs, + SLuint32 *pAudioOutputDeviceIDs + ); + SLresult (*GetDefaultAudioDevices) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 defaultDeviceID, + SLint32 *pNumAudioDevices, + SLuint32 *pAudioDeviceIDs + ); + SLresult (*QuerySampleFormatsSupported)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLmilliHertz samplingRate, + SLint32 *pSampleFormats, + SLint32 *pNumOfSampleFormats + ); +}; + + + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the LED array IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLLEDDescriptor_ { + SLuint8 ledCount; + SLuint8 primaryLED; + SLuint32 colorMask; +} SLLEDDescriptor; + + +/*---------------------------------------------------------------------------*/ +/* LED Array interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLHSL_ { + SLmillidegree hue; + SLpermille saturation; + SLpermille lightness; +} SLHSL; + + +extern const SLInterfaceID SL_IID_LED; + +struct SLLEDArrayItf_; +typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; + +struct SLLEDArrayItf_ { + SLresult (*ActivateLEDArray) ( + SLLEDArrayItf self, + SLuint32 lightMask + ); + SLresult (*IsLEDArrayActivated) ( + SLLEDArrayItf self, + SLuint32 *lightMask + ); + SLresult (*SetColor) ( + SLLEDArrayItf self, + SLuint8 index, + const SLHSL *color + ); + SLresult (*GetColor) ( + SLLEDArrayItf self, + SLuint8 index, + SLHSL *color + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the Vibra IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVibraDescriptor_ { + SLboolean supportsFrequency; + SLboolean supportsIntensity; + SLmilliHertz minFrequency; + SLmilliHertz maxFrequency; +} SLVibraDescriptor; + + + +/*---------------------------------------------------------------------------*/ +/* Vibra interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VIBRA; + + +struct SLVibraItf_; +typedef const struct SLVibraItf_ * const * SLVibraItf; + +struct SLVibraItf_ { + SLresult (*Vibrate) ( + SLVibraItf self, + SLboolean vibrate + ); + SLresult (*IsVibrating) ( + SLVibraItf self, + SLboolean *pVibrating + ); + SLresult (*SetFrequency) ( + SLVibraItf self, + SLmilliHertz frequency + ); + SLresult (*GetFrequency) ( + SLVibraItf self, + SLmilliHertz *pFrequency + ); + SLresult (*SetIntensity) ( + SLVibraItf self, + SLpermille intensity + ); + SLresult (*GetIntensity) ( + SLVibraItf self, + SLpermille *pIntensity + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data extraction related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) +#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) +#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) +#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) +#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) +#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) +#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) +#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) +#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) +#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) +#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) +#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) +#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) +#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) +#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) +#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) +#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) +#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) +#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) +#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) +#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) +#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) +#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) +#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) +#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) +#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) +#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) +#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) +#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) +#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) +#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) +#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) + + +#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) +#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) +#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) + + +typedef struct SLMetadataInfo_ { + SLuint32 size; + SLuint32 encoding; + SLchar langCountry[16]; + SLuint8 data[1]; +} SLMetadataInfo; + +extern const SLInterfaceID SL_IID_METADATAEXTRACTION; + +struct SLMetadataExtractionItf_; +typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; + + +struct SLMetadataExtractionItf_ { + SLresult (*GetItemCount) ( + SLMetadataExtractionItf self, + SLuint32 *pItemCount + ); + SLresult (*GetKeySize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pKeySize + ); + SLresult (*GetKey) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 keySize, + SLMetadataInfo *pKey + ); + SLresult (*GetValueSize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pValueSize + ); + SLresult (*GetValue) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 valueSize, + SLMetadataInfo *pValue + ); + SLresult (*AddKeyFilter) ( + SLMetadataExtractionItf self, + SLuint32 keySize, + const void *pKey, + SLuint32 keyEncoding, + const SLchar *pValueLangCountry, + SLuint32 valueEncoding, + SLuint8 filterMask + ); + SLresult (*ClearKeyFilter) ( + SLMetadataExtractionItf self + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data traversal related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) +#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) + + +#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) +#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) +#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) + +#define SL_NODE_PARENT 0xFFFFFFFF + +extern const SLInterfaceID SL_IID_METADATATRAVERSAL; + +struct SLMetadataTraversalItf_; +typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; + +struct SLMetadataTraversalItf_ { + SLresult (*SetMode) ( + SLMetadataTraversalItf self, + SLuint32 mode + ); + SLresult (*GetChildCount) ( + SLMetadataTraversalItf self, + SLuint32 *pCount + ); + SLresult (*GetChildMIMETypeSize) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLuint32 *pSize + ); + SLresult (*GetChildInfo) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLint32 *pNodeID, + SLuint32 *pType, + SLuint32 size, + SLchar *pMimeType + ); + SLresult (*SetActiveNode) ( + SLMetadataTraversalItf self, + SLuint32 index + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Dynamic Source types and interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_DYNAMICSOURCE; + +struct SLDynamicSourceItf_; +typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; + +struct SLDynamicSourceItf_ { + SLresult (*SetSource) ( + SLDynamicSourceItf self, + SLDataSource *pDataSource + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Output Mix interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OUTPUTMIX; + +struct SLOutputMixItf_; +typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; + +typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( + SLOutputMixItf caller, + void *pContext +); + + +struct SLOutputMixItf_ { + SLresult (*GetDestinationOutputDeviceIDs) ( + SLOutputMixItf self, + SLint32 *pNumDevices, + SLuint32 *pDeviceIDs + ); + SLresult (*RegisterDeviceChangeCallback) ( + SLOutputMixItf self, + slMixDeviceChangeCallback callback, + void *pContext + ); + SLresult (*ReRoute)( + SLOutputMixItf self, + SLint32 numOutputDevices, + SLuint32 *pOutputDeviceIDs + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Playback interface */ +/*---------------------------------------------------------------------------*/ + +/** Playback states */ +#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) + +/** Play events **/ +#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) +#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) + +#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) + + +extern const SLInterfaceID SL_IID_PLAY; + +/** Playback interface methods */ + +struct SLPlayItf_; +typedef const struct SLPlayItf_ * const * SLPlayItf; + +typedef void (SLAPIENTRY *slPlayCallback) ( + SLPlayItf caller, + void *pContext, + SLuint32 event +); + +struct SLPlayItf_ { + SLresult (*SetPlayState) ( + SLPlayItf self, + SLuint32 state + ); + SLresult (*GetPlayState) ( + SLPlayItf self, + SLuint32 *pState + ); + SLresult (*GetDuration) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*GetPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLPlayItf self, + slPlayCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLPlayItf self + ); + SLresult (*GetMarkerPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Prefetch status interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) +#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) + +#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) +#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) +#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) + + +extern const SLInterfaceID SL_IID_PREFETCHSTATUS; + + +/** Prefetch status interface methods */ + +struct SLPrefetchStatusItf_; +typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; + +typedef void (SLAPIENTRY *slPrefetchCallback) ( + SLPrefetchStatusItf caller, + void *pContext, + SLuint32 event +); + +struct SLPrefetchStatusItf_ { + SLresult (*GetPrefetchStatus) ( + SLPrefetchStatusItf self, + SLuint32 *pStatus + ); + SLresult (*GetFillLevel) ( + SLPrefetchStatusItf self, + SLpermille *pLevel + ); + SLresult (*RegisterCallback) ( + SLPrefetchStatusItf self, + slPrefetchCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille period + ); + SLresult (*GetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille *pPeriod + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Playback Rate interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) +#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) +#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) +#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) +#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) +#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) + + +extern const SLInterfaceID SL_IID_PLAYBACKRATE; + +struct SLPlaybackRateItf_; +typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; + +struct SLPlaybackRateItf_ { + SLresult (*SetRate)( + SLPlaybackRateItf self, + SLpermille rate + ); + SLresult (*GetRate)( + SLPlaybackRateItf self, + SLpermille *pRate + ); + SLresult (*SetPropertyConstraints)( + SLPlaybackRateItf self, + SLuint32 constraints + ); + SLresult (*GetProperties)( + SLPlaybackRateItf self, + SLuint32 *pProperties + ); + SLresult (*GetCapabilitiesOfRate)( + SLPlaybackRateItf self, + SLpermille rate, + SLuint32 *pCapabilities + ); + SLresult (*GetRateRange) ( + SLPlaybackRateItf self, + SLuint8 index, + SLpermille *pMinRate, + SLpermille *pMaxRate, + SLpermille *pStepSize, + SLuint32 *pCapabilities + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Seek Interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_SEEKMODE_FAST ((SLuint16) 0x0001) +#define SL_SEEKMODE_ACCURATE ((SLuint16) 0x0002) + +extern const SLInterfaceID SL_IID_SEEK; + +struct SLSeekItf_; +typedef const struct SLSeekItf_ * const * SLSeekItf; + +struct SLSeekItf_ { + SLresult (*SetPosition)( + SLSeekItf self, + SLmillisecond pos, + SLuint32 seekMode + ); + SLresult (*SetLoop)( + SLSeekItf self, + SLboolean loopEnable, + SLmillisecond startPos, + SLmillisecond endPos + ); + SLresult (*GetLoop)( + SLSeekItf self, + SLboolean *pLoopEnabled, + SLmillisecond *pStartPos, + SLmillisecond *pEndPos + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Standard Recording Interface */ +/*---------------------------------------------------------------------------*/ + +/** Recording states */ +#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) + + +/** Record event **/ +#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) +#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) + + +extern const SLInterfaceID SL_IID_RECORD; + +struct SLRecordItf_; +typedef const struct SLRecordItf_ * const * SLRecordItf; + +typedef void (SLAPIENTRY *slRecordCallback) ( + SLRecordItf caller, + void *pContext, + SLuint32 event +); + +/** Recording interface methods */ +struct SLRecordItf_ { + SLresult (*SetRecordState) ( + SLRecordItf self, + SLuint32 state + ); + SLresult (*GetRecordState) ( + SLRecordItf self, + SLuint32 *pState + ); + SLresult (*SetDurationLimit) ( + SLRecordItf self, + SLmillisecond msec + ); + SLresult (*GetPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLRecordItf self, + slRecordCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLRecordItf self + ); + SLresult (*GetMarkerPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Equalizer interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) + +extern const SLInterfaceID SL_IID_EQUALIZER; + +struct SLEqualizerItf_; +typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; + +struct SLEqualizerItf_ { + SLresult (*SetEnabled)( + SLEqualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLEqualizerItf self, + SLboolean *pEnabled + ); + SLresult (*GetNumberOfBands)( + SLEqualizerItf self, + SLuint16 *pAmount + ); + SLresult (*GetBandLevelRange)( + SLEqualizerItf self, + SLmillibel *pMin, + SLmillibel *pMax + ); + SLresult (*SetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel level + ); + SLresult (*GetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel *pLevel + ); + SLresult (*GetCenterFreq)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pCenter + ); + SLresult (*GetBandFreqRange)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pMin, + SLmilliHertz *pMax + ); + SLresult (*GetBand)( + SLEqualizerItf self, + SLmilliHertz frequency, + SLuint16 *pBand + ); + SLresult (*GetCurrentPreset)( + SLEqualizerItf self, + SLuint16 *pPreset + ); + SLresult (*UsePreset)( + SLEqualizerItf self, + SLuint16 index + ); + SLresult (*GetNumberOfPresets)( + SLEqualizerItf self, + SLuint16 *pNumPresets + ); + SLresult (*GetPresetName)( + SLEqualizerItf self, + SLuint16 index, + const SLchar ** ppName + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Volume Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_VOLUME; + +struct SLVolumeItf_; +typedef const struct SLVolumeItf_ * const * SLVolumeItf; + +struct SLVolumeItf_ { + SLresult (*SetVolumeLevel) ( + SLVolumeItf self, + SLmillibel level + ); + SLresult (*GetVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pLevel + ); + SLresult (*GetMaxVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pMaxLevel + ); + SLresult (*SetMute) ( + SLVolumeItf self, + SLboolean mute + ); + SLresult (*GetMute) ( + SLVolumeItf self, + SLboolean *pMute + ); + SLresult (*EnableStereoPosition) ( + SLVolumeItf self, + SLboolean enable + ); + SLresult (*IsEnabledStereoPosition) ( + SLVolumeItf self, + SLboolean *pEnable + ); + SLresult (*SetStereoPosition) ( + SLVolumeItf self, + SLpermille stereoPosition + ); + SLresult (*GetStereoPosition) ( + SLVolumeItf self, + SLpermille *pStereoPosition + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Device Volume Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_DEVICEVOLUME; + +struct SLDeviceVolumeItf_; +typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; + +struct SLDeviceVolumeItf_ { + SLresult (*GetVolumeScale) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pMinValue, + SLint32 *pMaxValue, + SLboolean *pIsMillibelScale + ); + SLresult (*SetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 volume + ); + SLresult (*GetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pVolume + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Buffer Queue Interface */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_BUFFERQUEUE; + +struct SLBufferQueueItf_; +typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; + +typedef void (SLAPIENTRY *slBufferQueueCallback)( + SLBufferQueueItf caller, + void *pContext +); + +/** Buffer queue state **/ + +typedef struct SLBufferQueueState_ { + SLuint32 count; + SLuint32 playIndex; +} SLBufferQueueState; + + +struct SLBufferQueueItf_ { + SLresult (*Enqueue) ( + SLBufferQueueItf self, + const void *pBuffer, + SLuint32 size + ); + SLresult (*Clear) ( + SLBufferQueueItf self + ); + SLresult (*GetState) ( + SLBufferQueueItf self, + SLBufferQueueState *pState + ); + SLresult (*RegisterCallback) ( + SLBufferQueueItf self, + slBufferQueueCallback callback, + void* pContext + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* PresetReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) +#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) +#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) +#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) +#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) +#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) +#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) + + +extern const SLInterfaceID SL_IID_PRESETREVERB; + +struct SLPresetReverbItf_; +typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; + +struct SLPresetReverbItf_ { + SLresult (*SetPreset) ( + SLPresetReverbItf self, + SLuint16 preset + ); + SLresult (*GetPreset) ( + SLPresetReverbItf self, + SLuint16 *pPreset + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* EnvironmentalReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ + { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ + { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ + { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ + { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ + { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ + { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ + { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ + { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ + { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ + { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ + { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ + { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ + { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ + { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ + { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ + { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ + { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ + { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ + { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ + { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ + { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ + { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ + { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ + { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ + { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ + { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ + { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ + { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ + { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ + { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } + + +typedef struct SLEnvironmentalReverbSettings_ { + SLmillibel roomLevel; + SLmillibel roomHFLevel; + SLmillisecond decayTime; + SLpermille decayHFRatio; + SLmillibel reflectionsLevel; + SLmillisecond reflectionsDelay; + SLmillibel reverbLevel; + SLmillisecond reverbDelay; + SLpermille diffusion; + SLpermille density; +} SLEnvironmentalReverbSettings; + + + + +extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; + + +struct SLEnvironmentalReverbItf_; +typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; + +struct SLEnvironmentalReverbItf_ { + SLresult (*SetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel room + ); + SLresult (*GetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoom + ); + SLresult (*SetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel roomHF + ); + SLresult (*GetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoomHF + ); + SLresult (*SetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond decayTime + ); + SLresult (*GetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pDecayTime + ); + SLresult (*SetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille decayHFRatio + ); + SLresult (*GetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille *pDecayHFRatio + ); + SLresult (*SetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reflectionsLevel + ); + SLresult (*GetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReflectionsLevel + ); + SLresult (*SetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reflectionsDelay + ); + SLresult (*GetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReflectionsDelay + ); + SLresult (*SetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reverbLevel + ); + SLresult (*GetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReverbLevel + ); + SLresult (*SetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reverbDelay + ); + SLresult (*GetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReverbDelay + ); + SLresult (*SetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille diffusion + ); + SLresult (*GetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille *pDiffusion + ); + SLresult (*SetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille density + ); + SLresult (*GetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille *pDensity + ); + SLresult (*SetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + const SLEnvironmentalReverbSettings *pProperties + ); + SLresult (*GetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + SLEnvironmentalReverbSettings *pProperties + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Effects Send Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_EFFECTSEND; + +struct SLEffectSendItf_; +typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; + +struct SLEffectSendItf_ { + SLresult (*EnableEffectSend) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLboolean enable, + SLmillibel initialLevel + ); + SLresult (*IsEnabled) ( + SLEffectSendItf self, + const void * pAuxEffect, + SLboolean *pEnable + ); + SLresult (*SetDirectLevel) ( + SLEffectSendItf self, + SLmillibel directLevel + ); + SLresult (*GetDirectLevel) ( + SLEffectSendItf self, + SLmillibel *pDirectLevel + ); + SLresult (*SetSendLevel) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel sendLevel + ); + SLresult (*GetSendLevel)( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel *pSendLevel + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Grouping Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DGROUPING; + + +struct SL3DGroupingItf_ ; +typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; + +struct SL3DGroupingItf_ { + SLresult (*Set3DGroup) ( + SL3DGroupingItf self, + SLObjectItf group + ); + SLresult (*Get3DGroup) ( + SL3DGroupingItf self, + SLObjectItf *pGroup + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Commit Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DCOMMIT; + +struct SL3DCommitItf_; +typedef const struct SL3DCommitItf_* const * SL3DCommitItf; + +struct SL3DCommitItf_ { + SLresult (*Commit) ( + SL3DCommitItf self + ); + SLresult (*SetDeferred) ( + SL3DCommitItf self, + SLboolean deferred + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Location Interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVec3D_ { + SLint32 x; + SLint32 y; + SLint32 z; +} SLVec3D; + +extern const SLInterfaceID SL_IID_3DLOCATION; + +struct SL3DLocationItf_; +typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; + +struct SL3DLocationItf_ { + SLresult (*SetLocationCartesian) ( + SL3DLocationItf self, + const SLVec3D *pLocation + ); + SLresult (*SetLocationSpherical) ( + SL3DLocationItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter distance + ); + SLresult (*Move) ( + SL3DLocationItf self, + const SLVec3D *pMovement + ); + SLresult (*GetLocationCartesian) ( + SL3DLocationItf self, + SLVec3D *pLocation + ); + SLresult (*SetOrientationVectors) ( + SL3DLocationItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*SetOrientationAngles) ( + SL3DLocationItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*Rotate) ( + SL3DLocationItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DLocationItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Doppler Interface */ +/*---------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_3DDOPPLER; + +struct SL3DDopplerItf_; +typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; + +struct SL3DDopplerItf_ { + SLresult (*SetVelocityCartesian) ( + SL3DDopplerItf self, + const SLVec3D *pVelocity + ); + SLresult (*SetVelocitySpherical) ( + SL3DDopplerItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter speed + ); + SLresult (*GetVelocityCartesian) ( + SL3DDopplerItf self, + SLVec3D *pVelocity + ); + SLresult (*SetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille dopplerFactor + ); + SLresult (*GetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille *pDopplerFactor + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Source Interface and associated defines */ +/* --------------------------------------------------------------------------*/ + +#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) +#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) + + +extern const SLInterfaceID SL_IID_3DSOURCE; + +struct SL3DSourceItf_; +typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; + +struct SL3DSourceItf_ { + SLresult (*SetHeadRelative) ( + SL3DSourceItf self, + SLboolean headRelative + ); + SLresult (*GetHeadRelative) ( + SL3DSourceItf self, + SLboolean *pHeadRelative + ); + SLresult (*SetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter minDistance, + SLmillimeter maxDistance + ); + SLresult (*GetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter *pMinDistance, + SLmillimeter *pMaxDistance + ); + SLresult (*SetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean mute + ); + SLresult (*GetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean *pMute + ); + SLresult (*SetRolloffFactor) ( + SL3DSourceItf self, + SLpermille rolloffFactor + ); + SLresult (*GetRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRolloffFactor + ); + SLresult (*SetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille roomRolloffFactor + ); + SLresult (*GetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRoomRolloffFactor + ); + SLresult (*SetRolloffModel) ( + SL3DSourceItf self, + SLuint8 model + ); + SLresult (*GetRolloffModel) ( + SL3DSourceItf self, + SLuint8 *pModel + ); + SLresult (*SetCone) ( + SL3DSourceItf self, + SLmillidegree innerAngle, + SLmillidegree outerAngle, + SLmillibel outerLevel + ); + SLresult (*GetCone) ( + SL3DSourceItf self, + SLmillidegree *pInnerAngle, + SLmillidegree *pOuterAngle, + SLmillibel *pOuterLevel + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Macroscopic Interface */ +/* --------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_3DMACROSCOPIC; + +struct SL3DMacroscopicItf_; +typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; + +struct SL3DMacroscopicItf_ { + SLresult (*SetSize) ( + SL3DMacroscopicItf self, + SLmillimeter width, + SLmillimeter height, + SLmillimeter depth + ); + SLresult (*GetSize) ( + SL3DMacroscopicItf self, + SLmillimeter *pWidth, + SLmillimeter *pHeight, + SLmillimeter *pDepth + ); + SLresult (*SetOrientationAngles) ( + SL3DMacroscopicItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*SetOrientationVectors) ( + SL3DMacroscopicItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*Rotate) ( + SL3DMacroscopicItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DMacroscopicItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Mute Solo Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MUTESOLO; + +struct SLMuteSoloItf_; +typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; + +struct SLMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pSolo + ); + SLresult (*GetNumChannels) ( + SLMuteSoloItf self, + SLuint8 *pNumChannels + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Dynamic Interface Management Interface and associated types and macros */ +/* --------------------------------------------------------------------------*/ + +#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) + + + + +extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; + +struct SLDynamicInterfaceManagementItf_; +typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; + +typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( + SLDynamicInterfaceManagementItf caller, + void * pContext, + SLuint32 event, + SLresult result, + const SLInterfaceID iid +); + + +struct SLDynamicInterfaceManagementItf_ { + SLresult (*AddInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RemoveInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid + ); + SLresult (*ResumeInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RegisterCallback) ( + SLDynamicInterfaceManagementItf self, + slDynamicInterfaceManagementCallback callback, + void * pContext + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Midi Message Interface and associated types */ +/* --------------------------------------------------------------------------*/ + +#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) +#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) +#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) +#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) +#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) +#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) +#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) + + +extern const SLInterfaceID SL_IID_MIDIMESSAGE; + +struct SLMIDIMessageItf_; +typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; + +typedef void (SLAPIENTRY *slMetaEventCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 type, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +typedef void (SLAPIENTRY *slMIDIMessageCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 statusByte, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +struct SLMIDIMessageItf_ { + SLresult (*SendMessage) ( + SLMIDIMessageItf self, + const SLuint8 *data, + SLuint32 length + ); + SLresult (*RegisterMetaEventCallback) ( + SLMIDIMessageItf self, + slMetaEventCallback callback, + void *pContext + ); + SLresult (*RegisterMIDIMessageCallback) ( + SLMIDIMessageItf self, + slMIDIMessageCallback callback, + void *pContext + ); + SLresult (*AddMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self, + SLuint32 messageType + ); + SLresult (*ClearMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Mute Solo interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDIMUTESOLO; + +struct SLMIDIMuteSoloItf_; +typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; + +struct SLMIDIMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pSolo + ); + SLresult (*GetTrackCount) ( + SLMIDIMuteSoloItf self, + SLuint16 *pCount + ); + SLresult (*SetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean mute + ); + SLresult (*GetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pMute + ); + SLresult (*SetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean solo + ); + SLresult (*GetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pSolo + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Tempo interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDITEMPO; + +struct SLMIDITempoItf_; +typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; + +struct SLMIDITempoItf_ { + SLresult (*SetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 tpqn + ); + SLresult (*GetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 *pTpqn + ); + SLresult (*SetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond uspqn + ); + SLresult (*GetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond *uspqn + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Time interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_MIDITIME; + +struct SLMIDITimeItf_; +typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; + +struct SLMIDITimeItf_ { + SLresult (*GetDuration) ( + SLMIDITimeItf self, + SLuint32 *pDuration + ); + SLresult (*SetPosition) ( + SLMIDITimeItf self, + SLuint32 position + ); + SLresult (*GetPosition) ( + SLMIDITimeItf self, + SLuint32 *pPosition + ); + SLresult (*SetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 startTick, + SLuint32 numTicks + ); + SLresult (*GetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 *pStartTick, + SLuint32 *pNumTicks + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Decoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/*Audio Codec related defines*/ + +#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) +#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) + +#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) +#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) +#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) +#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) +#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) +#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) +#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) +#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) + +#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) + +#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) +#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) +#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) +#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) + +#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) + +#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) + +#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) +#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) +#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) + +#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) +#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) + +#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) +#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) + +#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) + +#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) + +typedef struct SLAudioCodecDescriptor_ { + SLuint32 maxChannels; + SLuint32 minBitsPerSample; + SLuint32 maxBitsPerSample; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *pSampleRatesSupported; + SLuint32 numSampleRatesSupported; + SLuint32 minBitRate; + SLuint32 maxBitRate; + SLboolean isBitrateRangeContinuous; + SLuint32 *pBitratesSupported; + SLuint32 numBitratesSupported; + SLuint32 profileSetting; + SLuint32 modeSetting; +} SLAudioCodecDescriptor; + +/*Structure used to retrieve the profile and level settings supported by an audio encoder */ + +typedef struct SLAudioCodecProfileMode_ { + SLuint32 profileSetting; + SLuint32 modeSetting; +} SLAudioCodecProfileMode; + +extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; + +struct SLAudioDecoderCapabilitiesItf_; +typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; + +struct SLAudioDecoderCapabilitiesItf_ { + SLresult (*GetAudioDecoders) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 * pNumDecoders , + SLuint32 *pDecoderIds + ); + SLresult (*GetAudioDecoderCapabilities) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 decoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor *pDescriptor + ); +}; + + + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/* Structure used when setting audio encoding parameters */ + +typedef struct SLAudioEncoderSettings_ { + SLuint32 encoderId; + SLuint32 channelsIn; + SLuint32 channelsOut; + SLmilliHertz sampleRate; + SLuint32 bitRate; + SLuint32 bitsPerSample; + SLuint32 rateControl; + SLuint32 profileSetting; + SLuint32 levelSetting; + SLuint32 channelMode; + SLuint32 streamFormat; + SLuint32 encodeOptions; + SLuint32 blockAlignment; +} SLAudioEncoderSettings; + +extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; + +struct SLAudioEncoderCapabilitiesItf_; +typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; + +struct SLAudioEncoderCapabilitiesItf_ { + SLresult (*GetAudioEncoders) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 *pNumEncoders , + SLuint32 *pEncoderIds + ); + SLresult (*GetAudioEncoderCapabilities) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 encoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor * pDescriptor + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_AUDIOENCODER; + +struct SLAudioEncoderItf_; +typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; + +struct SLAudioEncoderItf_ { + SLresult (*SetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); + SLresult (*GetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Bass Boost Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_BASSBOOST; + +struct SLBassBoostItf_; +typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; + +struct SLBassBoostItf_ { + SLresult (*SetEnabled)( + SLBassBoostItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLBassBoostItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLBassBoostItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLBassBoostItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLBassBoostItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Pitch Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_PITCH; + +struct SLPitchItf_; +typedef const struct SLPitchItf_ * const * SLPitchItf; + +struct SLPitchItf_ { + SLresult (*SetPitch) ( + SLPitchItf self, + SLpermille pitch + ); + SLresult (*GetPitch) ( + SLPitchItf self, + SLpermille *pPitch + ); + SLresult (*GetPitchCapabilities) ( + SLPitchItf self, + SLpermille *pMinPitch, + SLpermille *pMaxPitch + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Rate Pitch Interface */ +/* RatePitchItf is an interface for controlling the rate a sound is played */ +/* back. A change in rate will cause a change in pitch. */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_RATEPITCH; + +struct SLRatePitchItf_; +typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; + +struct SLRatePitchItf_ { + SLresult (*SetRate) ( + SLRatePitchItf self, + SLpermille rate + ); + SLresult (*GetRate) ( + SLRatePitchItf self, + SLpermille *pRate + ); + SLresult (*GetRatePitchCapabilities) ( + SLRatePitchItf self, + SLpermille *pMinRate, + SLpermille *pMaxRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Virtualizer Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VIRTUALIZER; + +struct SLVirtualizerItf_; +typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; + +struct SLVirtualizerItf_ { + SLresult (*SetEnabled)( + SLVirtualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLVirtualizerItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLVirtualizerItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLVirtualizerItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLVirtualizerItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Visualization Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_VISUALIZATION; + +struct SLVisualizationItf_; +typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; + +typedef void (SLAPIENTRY *slVisualizationCallback) ( + void *pContext, + const SLuint8 waveform[], + const SLuint8 fft[], + SLmilliHertz samplerate +); + +struct SLVisualizationItf_{ + SLresult (*RegisterVisualizationCallback)( + SLVisualizationItf self, + slVisualizationCallback callback, + void *pContext, + SLmilliHertz rate + ); + SLresult (*GetMaxRate)( + SLVisualizationItf self, + SLmilliHertz* pRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_ENGINE; + +struct SLEngineItf_; +typedef const struct SLEngineItf_ * const * SLEngineItf; + + +struct SLEngineItf_ { + + SLresult (*CreateLEDDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateVibraDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + SLDataSource *pAudioSrc, + SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioRecorder) ( + SLEngineItf self, + SLObjectItf * pRecorder, + SLDataSource *pAudioSrc, + SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMidiPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + SLDataSource *pMIDISrc, + SLDataSource *pBankSrc, + SLDataSink *pAudioOutput, + SLDataSink *pVibra, + SLDataSink *pLEDArray, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateListener) ( + SLEngineItf self, + SLObjectItf * pListener, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*Create3DGroup) ( + SLEngineItf self, + SLObjectItf * pGroup, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateOutputMix) ( + SLEngineItf self, + SLObjectItf * pMix, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMetadataExtractor) ( + SLEngineItf self, + SLObjectItf * pMetadataExtractor, + SLDataSource * pDataSource, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateExtensionObject) ( + SLEngineItf self, + SLObjectItf * pObject, + void * pParameters, + SLuint32 objectID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*QueryNumSupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 * pNumSupportedInterfaces + ); + SLresult (*QuerySupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 index, + SLInterfaceID * pInterfaceId + ); + SLresult (*QueryNumSupportedExtensions) ( + SLEngineItf self, + SLuint32 * pNumExtensions + ); + SLresult (*QuerySupportedExtension) ( + SLEngineItf self, + SLuint32 index, + SLchar * pExtensionName, + SLint16 * pNameLength + ); + SLresult (*IsExtensionSupported) ( + SLEngineItf self, + const SLchar * pExtensionName, + SLboolean * pSupported + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; + +struct SLEngineCapabilitiesItf_; +typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; + +struct SLEngineCapabilitiesItf_ { + SLresult (*QuerySupportedProfiles) ( + SLEngineCapabilitiesItf self, + SLuint16 *pProfilesSupported + ); + SLresult (*QueryAvailableVoices) ( + SLEngineCapabilitiesItf self, + SLuint16 voiceType, + SLint16 *pNumMaxVoices, + SLboolean *pIsAbsoluteMax, + SLint16 *pNumFreeVoices + ); + SLresult (*QueryNumberOfMIDISynthesizers) ( + SLEngineCapabilitiesItf self, + SLint16 *pNumMIDIsynthesizers + ); + SLresult (*QueryAPIVersion) ( + SLEngineCapabilitiesItf self, + SLint16 *pMajor, + SLint16 *pMinor, + SLint16 *pStep + ); + SLresult (*QueryLEDCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pLEDDeviceID, + SLLEDDescriptor *pDescriptor + ); + SLresult (*QueryVibraCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pVibraDeviceID, + SLVibraDescriptor *pDescriptor + ); + SLresult (*IsThreadSafe) ( + SLEngineCapabilitiesItf self, + SLboolean *pIsThreadSafe + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Thread Sync Interface */ +/* --------------------------------------------------------------------------*/ + + +extern const SLInterfaceID SL_IID_THREADSYNC; + +struct SLThreadSyncItf_; +typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; + + +struct SLThreadSyncItf_ { + SLresult (*EnterCriticalSection) ( + SLThreadSyncItf self + ); + SLresult (*ExitCriticalSection) ( + SLThreadSyncItf self + ); +}; + + +/*****************************************************************************/ +/* SL engine constructor */ +/*****************************************************************************/ + +#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) +#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) + +typedef struct SLEngineOption_ { + SLuint32 feature; + SLuint32 data; +} SLEngineOption; + + +SLresult SLAPIENTRY slCreateEngine( + SLObjectItf *pEngine, + SLuint32 numOptions, + const SLEngineOption *pEngineOptions, + SLuint32 numInterfaces, + const SLInterfaceID *pInterfaceIds, + const SLboolean * pInterfaceRequired +); + +SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( + SLuint32 * pNumSupportedInterfaces +); + +SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( + SLuint32 index, + SLInterfaceID * pInterfaceId +); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* OPENSL_ES_H_ */ diff --git a/third_party/openSLES/api/1.0/OpenSLES_Platform.h b/third_party/openSLES/api/1.0/OpenSLES_Platform.h index fdf43afd2979355b5f67738d7a7f4b644b861db1..e2c1e7045c3738f3b99257426f72ed130bbd7ab5 100644 --- a/third_party/openSLES/api/1.0/OpenSLES_Platform.h +++ b/third_party/openSLES/api/1.0/OpenSLES_Platform.h @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES_Platform.h - OpenSL ES version 1.0 - * - */ - -/****************************************************************************/ -/* NOTE: This file contains definitions for the base types and the */ -/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ -/* the correct definitions specific to the platform being used. */ -/****************************************************************************/ - -#ifndef _OPENSLES_PLATFORM_H_ -#define _OPENSLES_PLATFORM_H_ - -typedef unsigned char sl_uint8_t; -typedef signed char sl_int8_t; -typedef unsigned short sl_uint16_t; -typedef signed short sl_int16_t; -typedef unsigned long sl_uint32_t; -typedef signed long sl_int32_t; - -#ifndef SLAPIENTRY -#define SLAPIENTRY /* override per-platform */ -#endif - -#endif /* _OPENSLES_PLATFORM_H_ */ +/* + * Copyright (c) 2008 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES_Platform.h - OpenSL ES version 1.0 + * + */ + +/****************************************************************************/ +/* NOTE: This file contains definitions for the base types and the */ +/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ +/* the correct definitions specific to the platform being used. */ +/****************************************************************************/ + +#ifndef _OPENSLES_PLATFORM_H_ +#define _OPENSLES_PLATFORM_H_ + +typedef unsigned char sl_uint8_t; +typedef signed char sl_int8_t; +typedef unsigned short sl_uint16_t; +typedef signed short sl_int16_t; +typedef unsigned long sl_uint32_t; +typedef signed long sl_int32_t; + +#ifndef SLAPIENTRY +#define SLAPIENTRY /* override per-platform */ +#endif + +#endif /* _OPENSLES_PLATFORM_H_ */ diff --git a/third_party/openSLES/api/1.0/README.txt b/third_party/openSLES/api/1.0/README.txt index 7ed9498ee7b6a335d00273c3554b5cc4d771018c..848ce5ab92552eb36b0bdc8a942848561133b205 100644 --- a/third_party/openSLES/api/1.0/README.txt +++ b/third_party/openSLES/api/1.0/README.txt @@ -1,2 +1,2 @@ -When building applications using the OpenSL-ES API you should compile and link the OpenSLES_IID.c file into your project. This file contains unique interface IDs for all OpenSL-ES API interfaces. These IDs have +When building applications using the OpenSL-ES API you should compile and link the OpenSLES_IID.c file into your project. This file contains unique interface IDs for all OpenSL-ES API interfaces. These IDs have have been automatically generated. Application developers should not edit these interface IDs. \ No newline at end of file diff --git a/third_party/openSLES/api/1.1/OpenSLES.h b/third_party/openSLES/api/1.1/OpenSLES.h index 4d5de1ad0ac7b6764ef9201aadf34dae55f91719..d1342874478fd5624b02d0e53c85ea9b51bc1395 100644 --- a/third_party/openSLES/api/1.1/OpenSLES.h +++ b/third_party/openSLES/api/1.1/OpenSLES.h @@ -1,2974 +1,2974 @@ -/* - * Copyright (c) 2007-2011 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES.h - OpenSL ES version 1.1 - * - */ - -/****************************************************************************/ -/* NOTE: This file is a standard OpenSL ES header file and should not be */ -/* modified in any way. */ -/****************************************************************************/ - -#ifndef OPENSL_ES_H_ -#define OPENSL_ES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "OpenSLES_Platform.h" - - -/*****************************************************************************/ -/* Common types, structures, and defines */ -/*****************************************************************************/ - -#ifndef _KHRONOS_KEYS_ -#define _KHRONOS_KEYS_ - -#define KHRONOS_TITLE "KhronosTitle" -#define KHRONOS_ALBUM "KhronosAlbum" -#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" -#define KHRONOS_ARTIST "KhronosArtist" -#define KHRONOS_GENRE "KhronosGenre" -#define KHRONOS_YEAR "KhronosYear" -#define KHRONOS_COMMENT "KhronosComment" -#define KHRONOS_ARTIST_URL "KhronosArtistURL" -#define KHRONOS_CONTENT_URL "KhronosContentURL" -#define KHRONOS_RATING "KhronosRating" -#define KHRONOS_ALBUM_ART "KhronosAlbumArt" -#define KHRONOS_COPYRIGHT "KhronosCopyright" - -#endif - - -/* remap common types to SL types for clarity */ -typedef sl_char_t SLchar; /* UTF-8 is to be used */ -typedef sl_int8_t SLint8; /* 8 bit signed integer */ -typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ -typedef sl_int16_t SLint16; /* 16 bit signed integer */ -typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ -typedef sl_int32_t SLint32; /* 32 bit signed integer */ -typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ -typedef sl_float32_t SLfloat32; /* 32 bit floating point */ -typedef sl_float64_t Slfloat64; /* 64 bit floating point */ - - -typedef SLuint32 SLboolean; -#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) -#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) - -typedef SLint16 SLmillibel; -typedef SLuint32 SLmillisecond; -typedef SLuint32 SLmilliHertz; -typedef SLint32 SLmillimeter; -typedef SLint32 SLmillidegree; -typedef SLint16 SLpermille; -typedef SLuint32 SLmicrosecond; -typedef SLuint32 SLresult; - -#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) -#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) - -#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) -#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) - -/** Interface ID defined as a UUID */ -typedef const struct SLInterfaceID_ { - SLuint32 time_low; - SLuint16 time_mid; - SLuint16 time_hi_and_version; - SLuint16 clock_seq; - SLuint8 node[6]; -} * SLInterfaceID; - -/* Forward declaration for the object interface */ -struct SLObjectItf_; - -typedef const struct SLObjectItf_ * const * SLObjectItf; - -/* Objects ID's */ - -#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) -#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) -#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) -#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) -#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) -#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) -#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) -#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) -#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) -#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) - - -/* SL Profiles */ - -#define SL_PROFILES_PHONE ((SLuint16) 0x0001) -#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) -#define SL_PROFILES_GAME ((SLuint16) 0x0004) - -/* Types of voices supported by the system */ - -#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) -#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) -#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) -#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) - -/* Convenient macros representing various different priority levels, for use with the SetPriority method */ - -#define SL_PRIORITY_LOWEST ((SLuint32) 0xFFFFFFFF) -#define SL_PRIORITY_VERYLOW ((SLuint32) 0xE0000000) -#define SL_PRIORITY_LOW ((SLuint32) 0xC0000000) -#define SL_PRIORITY_BELOWNORMAL ((SLuint32) 0xA0000000) -#define SL_PRIORITY_NORMAL ((SLuint32) 0x7FFFFFFF) -#define SL_PRIORITY_ABOVENORMAL ((SLuint32) 0x60000000) -#define SL_PRIORITY_HIGH ((SLuint32) 0x40000000) -#define SL_PRIORITY_VERYHIGH ((SLuint32) 0x20000000) -#define SL_PRIORITY_HIGHEST ((SLuint32) 0x00000000) - -/** These macros list types of PCM data **/ -#define SL_PCM_REPRESENTATION_SIGNED_INT ((SLuint32) 0x00000001) -#define SL_PCM_REPRESENTATION_UNSIGNED_INT ((SLuint32) 0x00000002) -#define SL_PCM_REPRESENTATION_FLOAT ((SLuint32) 0x00000003) - -/** These macros list the various sample formats that are possible on audio input and output devices. */ - -#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) -#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) -#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) -#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) -#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) -#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) -#define SL_PCMSAMPLEFORMAT_FIXED_64 ((SLuint16) 0x0040) - -/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ - -#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) -#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) -#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) -#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) -#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) -#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) -#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) -#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) -#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) -#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) -#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) -#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) -#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) - -#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) -#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) -#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) -#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) -#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) -#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) -#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) -#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) -#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) -#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) -#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) -#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) -#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) -#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) -#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) -#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) -#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) -#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) - - -/*****************************************************************************/ -/* Errors */ -/* */ -/*****************************************************************************/ - -#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) -#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) -#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) -#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) -#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) -#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) -#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) -#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) -#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) -#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) -#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) -#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) -#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) -#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) -#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) -#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) -#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) -#define SL_RESULT_READONLY ((SLuint32) 0x00000011) -#define SL_RESULT_ENGINEOPTION_UNSUPPORTED ((SLuint32) 0x00000012) -#define SL_RESULT_SOURCE_SINK_INCOMPATIBLE ((SLuint32) 0x00000013) - -/* Object state definitions */ - -#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) -#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) -#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) - -/* Object event definitions */ - -#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) -#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) -#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) -#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) - - -/*****************************************************************************/ -/* Interface definitions */ -/*****************************************************************************/ - -/** NULL Interface */ - -SL_API extern const SLInterfaceID SL_IID_NULL; - -/*---------------------------------------------------------------------------*/ -/* Data Source and Data Sink Structures */ -/*---------------------------------------------------------------------------*/ - -/** Data locator macros */ -#define SL_DATALOCATOR_NULL ((SLuint32) 0x00000000) -#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) -#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) -#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) -#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) -#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) -#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) -#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) -#define SL_DATALOCATOR_MEDIAOBJECT ((SLuint32) 0x00000008) -#define SL_DATALOCATOR_CONTENTPIPE ((SLuint32) 0x00000009) - - -/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ -typedef struct SLDataLocator_URI_ { - SLuint32 locatorType; - const SLchar * pURI; -} SLDataLocator_URI; - -/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ -typedef struct SLDataLocator_Address_ { - SLuint32 locatorType; - void *pAddress; - SLuint32 length; -} SLDataLocator_Address; - -/** IODevice-types */ -#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) -#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) -#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) -#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) -#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) -#define SL_IODEVICE_AUDIOOUTPUT ((SLuint32) 0x00000006) - -/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ -typedef struct SLDataLocator_IODevice_ { - SLuint32 locatorType; - SLuint32 deviceType; - SLuint32 deviceID; - SLObjectItf device; -} SLDataLocator_IODevice; - -/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ -typedef struct SLDataLocator_OutputMix_ { - SLuint32 locatorType; - SLObjectItf outputMix; -} SLDataLocator_OutputMix; - - -/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ -typedef struct SLDataLocator_BufferQueue_ { - SLuint32 locatorType; - SLuint32 numBuffers; -} SLDataLocator_BufferQueue; - -/** ContentPipe-based data locator definition where locatorType must be SL_DATALOCATOR_CONTENTPIPE */ -typedef struct SLDataLocator_ContentPipe_ { - SLuint32 locatorType; - void * pContentPipe; - const SLchar * pURI; -} SLDataLocator_ContentPipe; - -/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ -typedef struct SLDataLocator_MIDIBufferQueue_ { - SLuint32 locatorType; - SLuint32 tpqn; - SLuint32 numBuffers; -} SLDataLocator_MIDIBufferQueue; - -/** Data format defines */ -#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) -#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) -#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) -#define SL_DATAFORMAT_PCM_EX ((SLuint32) 0x00000004) - - -/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ -typedef struct SLDataFormat_MIME_ { - SLuint32 formatType; - const SLchar * pMimeType; - SLuint32 containerType; -} SLDataFormat_MIME; - -/* Byte order of a block of 16- or 32-bit data */ -#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) -#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) - -#ifdef SL_BYTEORDER_NATIVEBIGENDIAN -#define SL_BYTEORDER_NATIVE SL_BYTEORDER_BIGENDIAN -#else -#define SL_BYTEORDER_NATIVE SL_BYTEORDER_LITTLEENDIAN -#endif - -/* Container type */ -#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) -#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) -#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) -#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) -#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) -#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) -#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) -#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) -#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) -#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) -#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) -#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) -#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) -#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) -#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) -#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) -#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) -#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) -#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) -#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) -#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) -#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) -#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) -#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) -#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) -#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) -#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) -#define SL_CONTAINERTYPE_OGG ((SLuint32) 0x0000001D) - - -/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ -/* SLDataFormat_PCM IS DEPRECATED. Use SLDataFormat_PCM_EX instead. */ -typedef struct SLDataFormat_PCM_ { - SLuint32 formatType; - SLuint32 numChannels; - SLuint32 samplesPerSec; - SLuint32 bitsPerSample; - SLuint32 containerSize; - SLuint32 channelMask; - SLuint32 endianness; -} SLDataFormat_PCM; - -/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM_EX*/ -typedef struct SLDataFormat_PCM_EX_ { - SLuint32 formatType; - SLuint32 numChannels; - SLuint32 sampleRate; - SLuint32 bitsPerSample; - SLuint32 containerSize; - SLuint32 channelMask; - SLuint32 endianness; - SLuint32 representation; -} SLDataFormat_PCM_EX; - -/** MediaObject-type-based data format definition where formatType must be SL_DATAFORMAT_MEDIAOBJECT*/ -typedef struct SLDataLocator_MediaObject_ { - SLuint32 locatorType; - SLObjectItf mediaObject; -} SLDataLocator_MediaObject; - -/** NULL-type-based data format definition where formatType must be SL_DATAFORMAT_NULL*/ -typedef struct SLDataLocator_Null_ { - SLuint32 locatorType; -} SLDataLocator_Null; - - -typedef struct SLDataSource_ { - void *pLocator; - void *pFormat; -} SLDataSource; - - -typedef struct SLDataSink_ { - void *pLocator; - void *pFormat; -} SLDataSink; - -/*---------------------------------------------------------------------------*/ -/* Standard Object Interface */ -/*---------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_OBJECT; - -/** Object callback */ - - -typedef void (SLAPIENTRY *slObjectCallback) ( - SLObjectItf caller, - const void * pContext, - SLuint32 event, - SLresult result, - SLuint32 param, - void *pInterface -); - - -struct SLObjectItf_ { - SLresult (*Realize) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*Resume) ( - SLObjectItf self, - SLboolean async - ); - SLresult (*GetState) ( - SLObjectItf self, - SLuint32 * pState - ); - SLresult (*GetInterface) ( - SLObjectItf self, - const SLInterfaceID iid, - void * pInterface - ); - SLresult (*RegisterCallback) ( - SLObjectItf self, - slObjectCallback callback, - void * pContext - ); - void (*AbortAsyncOperation) ( - SLObjectItf self - ); - void (*Destroy) ( - SLObjectItf self - ); - SLresult (*SetPriority) ( - SLObjectItf self, - SLuint32 priority - ); - SLresult (*GetPriority) ( - SLObjectItf self, - SLuint32 *pPriority - ); - SLresult (*SetLossOfControlInterfaces) ( - SLObjectItf self, - SLuint16 numInterfaces, - const SLInterfaceID * pInterfaceIDs, - SLboolean enabled - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio IO Device capabilities interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) -#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) -#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) -#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) -#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) - - -#define SL_DEVCONNECTION_INTEGRATED ((SLint16) 0x0001) -#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLint16) 0x0100) -#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLint16) 0x0200) -#define SL_DEVCONNECTION_NETWORK ((SLint16) 0x0400) - - -#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) -#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) -#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) -#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) -#define SL_DEVLOCATION_REMOTE ((SLuint16) 0x0005) -/* Note: SL_DEVLOCATION_RESLTE is deprecated, use SL_DEVLOCATION_REMOTE instead. */ -#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) - - -#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) -#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) -#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) - - -typedef struct SLAudioInputDescriptor_ { - SLchar *pDeviceName; - SLint16 deviceNameLength; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *pSamplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioInputDescriptor; - - -typedef struct SLAudioOutputDescriptor_ { - SLchar *pDeviceName; - SLint16 deviceNameLength; - SLint16 deviceConnection; - SLint16 deviceScope; - SLint16 deviceLocation; - SLboolean isForTelephony; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *pSamplingRatesSupported; - SLint16 numOfSamplingRatesSupported; - SLint16 maxChannels; -} SLAudioOutputDescriptor; - - - -SL_API extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; - -struct SLAudioIODeviceCapabilitiesItf_; -typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; - - -typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLuint32 numInputs, - SLboolean isNew -); - - -typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLuint32 deviceID, - SLuint32 numOutputs, - SLboolean isNew -); - -typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf caller, - void *pContext, - SLboolean isOutput, - SLuint32 numDevices -); - - -struct SLAudioIODeviceCapabilitiesItf_ { - SLresult (*GetAvailableAudioInputs)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 *pNumInputs, - SLuint32 *pInputDeviceIDs - ); - SLresult (*QueryAudioInputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioInputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioInputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioInputsChangedCallback callback, - void *pContext - ); - SLresult (*GetAvailableAudioOutputs)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 *pNumOutputs, - SLuint32 *pOutputDeviceIDs - ); - SLresult (*QueryAudioOutputCapabilities)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLAudioOutputDescriptor *pDescriptor - ); - SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slAvailableAudioOutputsChangedCallback callback, - void *pContext - ); - SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( - SLAudioIODeviceCapabilitiesItf self, - slDefaultDeviceIDMapChangedCallback callback, - void *pContext - ); - SLresult (*GetAssociatedAudioInputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLuint32 *pNumAudioInputs, - SLuint32 *pAudioInputDeviceIDs - ); - SLresult (*GetAssociatedAudioOutputs) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLuint32 *pNumAudioOutputs, - SLuint32 *pAudioOutputDeviceIDs - ); - SLresult (*GetDefaultAudioDevices) ( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 defaultDeviceID, - SLuint32 *pNumAudioDevices, - SLuint32 *pAudioDeviceIDs - ); - SLresult (*QuerySampleFormatsSupported)( - SLAudioIODeviceCapabilitiesItf self, - SLuint32 deviceId, - SLmilliHertz samplingRate, - SLint32 *pSampleFormats, - SLuint32 *pNumOfSampleFormats - ); -}; - - - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the LED array IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLLEDDescriptor_ { - SLuint8 ledCount; - SLuint8 primaryLED; - SLuint32 colorMask; -} SLLEDDescriptor; - - -/*---------------------------------------------------------------------------*/ -/* LED Array interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLHSL_ { - SLmillidegree hue; - SLpermille saturation; - SLpermille lightness; -} SLHSL; - - -SL_API extern const SLInterfaceID SL_IID_LED; - -struct SLLEDArrayItf_; -typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; - -struct SLLEDArrayItf_ { - SLresult (*ActivateLEDArray) ( - SLLEDArrayItf self, - SLuint32 lightMask - ); - SLresult (*IsLEDArrayActivated) ( - SLLEDArrayItf self, - SLuint32 *lightMask - ); - SLresult (*SetColor) ( - SLLEDArrayItf self, - SLuint8 index, - const SLHSL *color - ); - SLresult (*GetColor) ( - SLLEDArrayItf self, - SLuint8 index, - SLHSL *color - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Capabilities of the Vibra IODevice */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVibraDescriptor_ { - SLboolean supportsFrequency; - SLboolean supportsIntensity; - SLmilliHertz minFrequency; - SLmilliHertz maxFrequency; -} SLVibraDescriptor; - - - -/*---------------------------------------------------------------------------*/ -/* Vibra interface */ -/*---------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_VIBRA; - - -struct SLVibraItf_; -typedef const struct SLVibraItf_ * const * SLVibraItf; - -struct SLVibraItf_ { - SLresult (*Vibrate) ( - SLVibraItf self, - SLboolean vibrate - ); - SLresult (*IsVibrating) ( - SLVibraItf self, - SLboolean *pVibrating - ); - SLresult (*SetFrequency) ( - SLVibraItf self, - SLmilliHertz frequency - ); - SLresult (*GetFrequency) ( - SLVibraItf self, - SLmilliHertz *pFrequency - ); - SLresult (*SetIntensity) ( - SLVibraItf self, - SLpermille intensity - ); - SLresult (*GetIntensity) ( - SLVibraItf self, - SLpermille *pIntensity - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data extraction related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) -#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) -#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) -#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) -#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) -#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) -#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) -#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) -#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) -#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) -#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) -#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) -#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) -#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) -#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) -#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) -#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) -#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) -#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) -#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) -#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) -#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) -#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) -#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) -#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) -#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) -#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) -#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) -#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) -#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) -#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) -#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) -#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) - - -#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) -#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) -#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) - - -typedef struct SLMetadataInfo_ { - SLuint32 size; - SLuint32 encoding; - SLchar langCountry[16]; - SLuint8 data[1]; -} SLMetadataInfo; - -SL_API extern const SLInterfaceID SL_IID_METADATAEXTRACTION; - -struct SLMetadataExtractionItf_; -typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; - - -struct SLMetadataExtractionItf_ { - SLresult (*GetItemCount) ( - SLMetadataExtractionItf self, - SLuint32 *pItemCount - ); - SLresult (*GetKeySize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pKeySize - ); - SLresult (*GetKey) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 keySize, - SLMetadataInfo *pKey - ); - SLresult (*GetValueSize) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 *pValueSize - ); - SLresult (*GetValue) ( - SLMetadataExtractionItf self, - SLuint32 index, - SLuint32 valueSize, - SLMetadataInfo *pValue - ); - SLresult (*AddKeyFilter) ( - SLMetadataExtractionItf self, - SLuint32 keySize, - const void *pKey, - SLuint32 keyEncoding, - const SLchar *pValueLangCountry, - SLuint32 valueEncoding, - SLuint8 filterMask - ); - SLresult (*ClearKeyFilter) ( - SLMetadataExtractionItf self - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Meta data message related types and interface */ -/*---------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_METADATAMESSAGE; - -struct SLMetadataMessageItf_; -typedef const struct SLMetadataMessageItf_ * const * SLMetadataMessageItf; - -typedef void (SLAPIENTRY *slMetadataCallback) ( - SLMetadataMessageItf caller, - void *pContext, - SLuint32 index -); - -struct SLMetadataMessageItf_ { - SLresult (*RegisterMetadataCallback) ( - SLMetadataMessageItf self, - slMetadataCallback callback, - void *pContext - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Meta data traversal related types and interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) -#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) - - -#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) -#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) -#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) -#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) - -#define SL_NODE_PARENT 0xFFFFFFFF - -SL_API extern const SLInterfaceID SL_IID_METADATATRAVERSAL; - -struct SLMetadataTraversalItf_; -typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; - -struct SLMetadataTraversalItf_ { - SLresult (*SetMode) ( - SLMetadataTraversalItf self, - SLuint32 mode - ); - SLresult (*GetChildCount) ( - SLMetadataTraversalItf self, - SLuint32 *pCount - ); - SLresult (*GetChildMIMETypeSize) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLuint32 *pSize - ); - SLresult (*GetChildInfo) ( - SLMetadataTraversalItf self, - SLuint32 index, - SLint32 *pNodeID, - SLuint32 *pType, - SLuint32 size, - SLchar *pMimeType - ); - SLresult (*SetActiveNode) ( - SLMetadataTraversalItf self, - SLuint32 index - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Dynamic Source types and interface */ -/*---------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_DYNAMICSOURCE; - -struct SLDynamicSourceItf_; -typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; - -struct SLDynamicSourceItf_ { - SLresult (*SetSource) ( - SLDynamicSourceItf self, - const SLDataSource *pDataSource - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Dynamic Source/Sink Change Interface */ -/*---------------------------------------------------------------------------*/ -SL_API extern const SLInterfaceID SL_IID_DYNAMICSOURCESINKCHANGE; - -struct SLDynamicSourceSinkChangeItf_; -typedef const struct SLDynamicSourceSinkChangeItf_ * const * SLDynamicSourceSinkChangeItf; - -typedef void (SLAPIENTRY *slSourceChangeCallback)( - SLDynamicSourceSinkChangeItf caller, - void *pContext, - SLuint32 resultCode, - const SLDataSource *pExistingDataSource, - const SLDataSource *pNewDataSource -); - -typedef void (SLAPIENTRY *slSinkChangeCallback)( - SLDynamicSourceSinkChangeItf caller, - void *pContext, - SLuint32 resultCode, - const SLDataSource *pExistingDataSink, - const SLDataSource *pNewDataSink -); - -struct SLDynamicSourceSinkChangeItf_ { - SLresult (*ChangeSource) ( - SLDynamicSourceSinkChangeItf self, - const SLDataSource * pExistingDataSource, - const SLDataSource * pNewDataSource, - SLboolean async - ); - SLresult (*ChangeSink) ( - SLDynamicSourceSinkChangeItf self, - const SLDataSink * pExistingDataSink, - const SLDataSink * pNewDataSink, - SLboolean async - ); - SLresult (*RegisterSourceChangeCallback) ( - SLDynamicSourceSinkChangeItf self, - slSourceChangeCallback callback, - void * pContext - ); - SLresult (*RegisterSinkChangeCallback) ( - SLDynamicSourceSinkChangeItf self, - slSinkChangeCallback callback, - void * pContext - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Output Mix interface */ -/*---------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_OUTPUTMIX; - -struct SLOutputMixItf_; -typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; - -typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( - SLOutputMixItf caller, - void *pContext -); - - -struct SLOutputMixItf_ { - SLresult (*GetDestinationOutputDeviceIDs) ( - SLOutputMixItf self, - SLint32 *pNumDevices, - SLuint32 *pDeviceIDs - ); - SLresult (*RegisterDeviceChangeCallback) ( - SLOutputMixItf self, - slMixDeviceChangeCallback callback, - void *pContext - ); - SLresult (*ReRoute)( - SLOutputMixItf self, - SLint32 numOutputDevices, - SLuint32 *pOutputDeviceIDs - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Playback interface */ -/*---------------------------------------------------------------------------*/ - -/** Playback states */ -#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) - -/** Play events **/ -#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) -#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) -#define SL_PLAYEVENT_DURATIONUPDATED ((SLuint32) 0x00000020) - -#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) - - -SL_API extern const SLInterfaceID SL_IID_PLAY; - -/** Playback interface methods */ - -struct SLPlayItf_; -typedef const struct SLPlayItf_ * const * SLPlayItf; - -typedef void (SLAPIENTRY *slPlayCallback) ( - SLPlayItf caller, - void *pContext, - SLuint32 event -); - -struct SLPlayItf_ { - SLresult (*SetPlayState) ( - SLPlayItf self, - SLuint32 state - ); - SLresult (*GetPlayState) ( - SLPlayItf self, - SLuint32 *pState - ); - SLresult (*GetDuration) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*GetPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLPlayItf self, - slPlayCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPlayItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLPlayItf self - ); - SLresult (*GetMarkerPosition) ( - SLPlayItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLPlayItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Prefetch status interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) -#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) -#define SL_PREFETCHEVENT_ERROR ((SLuint32) 0x00000003) -#define SL_PREFETCHEVENT_ERROR_UNRECOVERABLE ((SLuint32) 0x00000004) - - -#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) -#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) -#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) - - -SL_API extern const SLInterfaceID SL_IID_PREFETCHSTATUS; - - -/** Prefetch status interface methods */ - -struct SLPrefetchStatusItf_; -typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; - -typedef void (SLAPIENTRY *slPrefetchCallback) ( - SLPrefetchStatusItf caller, - void *pContext, - SLuint32 event -); - -struct SLPrefetchStatusItf_ { - SLresult (*GetPrefetchStatus) ( - SLPrefetchStatusItf self, - SLuint32 *pStatus - ); - SLresult (*GetFillLevel) ( - SLPrefetchStatusItf self, - SLpermille *pLevel - ); - SLresult (*RegisterCallback) ( - SLPrefetchStatusItf self, - slPrefetchCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLPrefetchStatusItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille period - ); - SLresult (*GetFillUpdatePeriod) ( - SLPrefetchStatusItf self, - SLpermille *pPeriod - ); - SLresult (*GetError) ( - SLPrefetchStatusItf self, - SLresult *pResult - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Playback Rate interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) -#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) -#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) -#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) -#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) -#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) - - -SL_API extern const SLInterfaceID SL_IID_PLAYBACKRATE; - -struct SLPlaybackRateItf_; -typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; - -struct SLPlaybackRateItf_ { - SLresult (*SetRate)( - SLPlaybackRateItf self, - SLpermille rate - ); - SLresult (*GetRate)( - SLPlaybackRateItf self, - SLpermille *pRate - ); - SLresult (*SetPropertyConstraints)( - SLPlaybackRateItf self, - SLuint32 constraints - ); - SLresult (*GetProperties)( - SLPlaybackRateItf self, - SLuint32 *pProperties - ); - SLresult (*GetCapabilitiesOfRate)( - SLPlaybackRateItf self, - SLpermille rate, - SLuint32 *pCapabilities - ); - SLresult (*GetRateRange) ( - SLPlaybackRateItf self, - SLuint8 index, - SLpermille *pMinRate, - SLpermille *pMaxRate, - SLpermille *pStepSize, - SLuint32 *pCapabilities - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Seek Interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_SEEKMODE_FAST ((SLuint32) 0x0001) -#define SL_SEEKMODE_ACCURATE ((SLuint32) 0x0002) - -SL_API extern const SLInterfaceID SL_IID_SEEK; - -struct SLSeekItf_; -typedef const struct SLSeekItf_ * const * SLSeekItf; - -struct SLSeekItf_ { - SLresult (*SetPosition)( - SLSeekItf self, - SLmillisecond pos, - SLuint32 seekMode - ); - SLresult (*SetLoop)( - SLSeekItf self, - SLboolean loopEnable, - SLmillisecond startPos, - SLmillisecond endPos - ); - SLresult (*GetLoop)( - SLSeekItf self, - SLboolean *pLoopEnabled, - SLmillisecond *pStartPos, - SLmillisecond *pEndPos - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Standard Recording Interface */ -/*---------------------------------------------------------------------------*/ - -/** Recording states */ -#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) -#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) -#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) - - -/** Record event **/ -#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) -#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) -#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) -#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) -#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) -/* Note: SL_RECORDEVENT_BUFFER_INSUFFICIENT is deprecated, use SL_RECORDEVENT_BUFFER_FULL instead. */ -#define SL_RECORDEVENT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000020) -#define SL_RECORDEVENT_BUFFER_FULL ((SLuint32) 0x00000020) -#define SL_RECORDEVENT_BUFFERQUEUE_STARVED ((SLuint32) 0x00000040) - - -SL_API extern const SLInterfaceID SL_IID_RECORD; - -struct SLRecordItf_; -typedef const struct SLRecordItf_ * const * SLRecordItf; - -typedef void (SLAPIENTRY *slRecordCallback) ( - SLRecordItf caller, - void *pContext, - SLuint32 event -); - -/** Recording interface methods */ -struct SLRecordItf_ { - SLresult (*SetRecordState) ( - SLRecordItf self, - SLuint32 state - ); - SLresult (*GetRecordState) ( - SLRecordItf self, - SLuint32 *pState - ); - SLresult (*SetDurationLimit) ( - SLRecordItf self, - SLmillisecond msec - ); - SLresult (*GetPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*RegisterCallback) ( - SLRecordItf self, - slRecordCallback callback, - void *pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLRecordItf self, - SLuint32 *pEventFlags - ); - SLresult (*SetMarkerPosition) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*ClearMarkerPosition) ( - SLRecordItf self - ); - SLresult (*GetMarkerPosition) ( - SLRecordItf self, - SLmillisecond *pMsec - ); - SLresult (*SetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond mSec - ); - SLresult (*GetPositionUpdatePeriod) ( - SLRecordItf self, - SLmillisecond *pMsec - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Equalizer interface */ -/*---------------------------------------------------------------------------*/ - -#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) - -SL_API extern const SLInterfaceID SL_IID_EQUALIZER; - -struct SLEqualizerItf_; -typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; - -struct SLEqualizerItf_ { - SLresult (*SetEnabled)( - SLEqualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLEqualizerItf self, - SLboolean *pEnabled - ); - SLresult (*GetNumberOfBands)( - SLEqualizerItf self, - SLuint16 *pAmount - ); - SLresult (*GetBandLevelRange)( - SLEqualizerItf self, - SLmillibel *pMin, - SLmillibel *pMax - ); - SLresult (*SetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel level - ); - SLresult (*GetBandLevel)( - SLEqualizerItf self, - SLuint16 band, - SLmillibel *pLevel - ); - SLresult (*GetCenterFreq)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pCenter - ); - SLresult (*GetBandFreqRange)( - SLEqualizerItf self, - SLuint16 band, - SLmilliHertz *pMin, - SLmilliHertz *pMax - ); - SLresult (*GetBand)( - SLEqualizerItf self, - SLmilliHertz frequency, - SLuint16 *pBand - ); - SLresult (*GetCurrentPreset)( - SLEqualizerItf self, - SLuint16 *pPreset - ); - SLresult (*UsePreset)( - SLEqualizerItf self, - SLuint16 index - ); - SLresult (*GetNumberOfPresets)( - SLEqualizerItf self, - SLuint16 *pNumPresets - ); - SLresult (*GetPresetName)( - SLEqualizerItf self, - SLuint16 index, - SLuint16 * pSize, - SLchar * pName - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Volume Interface */ -/* --------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_VOLUME; - -struct SLVolumeItf_; -typedef const struct SLVolumeItf_ * const * SLVolumeItf; - -struct SLVolumeItf_ { - SLresult (*SetVolumeLevel) ( - SLVolumeItf self, - SLmillibel level - ); - SLresult (*GetVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pLevel - ); - SLresult (*GetMaxVolumeLevel) ( - SLVolumeItf self, - SLmillibel *pMaxLevel - ); - SLresult (*SetMute) ( - SLVolumeItf self, - SLboolean mute - ); - SLresult (*GetMute) ( - SLVolumeItf self, - SLboolean *pMute - ); - SLresult (*EnableStereoPosition) ( - SLVolumeItf self, - SLboolean enable - ); - SLresult (*IsEnabledStereoPosition) ( - SLVolumeItf self, - SLboolean *pEnable - ); - SLresult (*SetStereoPosition) ( - SLVolumeItf self, - SLpermille stereoPosition - ); - SLresult (*GetStereoPosition) ( - SLVolumeItf self, - SLpermille *pStereoPosition - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Device Volume Interface */ -/* --------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_DEVICEVOLUME; - -struct SLDeviceVolumeItf_; -typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; - -struct SLDeviceVolumeItf_ { - SLresult (*GetVolumeScale) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pMinValue, - SLint32 *pMaxValue, - SLboolean *pIsMillibelScale - ); - SLresult (*SetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 volume - ); - SLresult (*GetVolume) ( - SLDeviceVolumeItf self, - SLuint32 deviceID, - SLint32 *pVolume - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Buffer Queue Interface */ -/*---------------------------------------------------------------------------*/ -/** Flags for buffer queue events */ -#define SL_BUFFERQUEUEEVENT_PROCESSED ((SLuint32) 0x00000001) -#define SL_BUFFERQUEUEEVENT_UNREALIZED ((SLuint32) 0x00000002) -#define SL_BUFFERQUEUEEVENT_CLEARED ((SLuint32) 0x00000004) -#define SL_BUFFERQUEUEEVENT_STOPPED ((SLuint32) 0x00000008) -#define SL_BUFFERQUEUEEVENT_ERROR ((SLuint32) 0x00000010) -#define SL_BUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020) - -SL_API extern const SLInterfaceID SL_IID_BUFFERQUEUE; - -struct SLBufferQueueItf_; -typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; - -typedef void (SLAPIENTRY *slBufferQueueCallback) ( - SLBufferQueueItf caller, - SLuint32 eventFlags, - const void *pBuffer, - SLuint32 bufferSize, - SLuint32 dataUsed, - void *pContext -); - - -/** Buffer queue state **/ - -typedef struct SLBufferQueueState_ { - SLuint32 count; - SLuint32 index; -} SLBufferQueueState; - - -struct SLBufferQueueItf_ { - SLresult (*Enqueue) ( - SLBufferQueueItf self, - const void *pBuffer, - SLuint32 size, - SLboolean isLastBuffer - ); - SLresult (*Clear) ( - SLBufferQueueItf self - ); - SLresult (*GetState) ( - SLBufferQueueItf self, - SLBufferQueueState *pState - ); - SLresult (*RegisterCallback) ( - SLBufferQueueItf self, - slBufferQueueCallback callback, - void* pContext - ); - SLresult (*SetCallbackEventsMask) ( - SLBufferQueueItf self, - SLuint32 eventFlags - ); - SLresult (*GetCallbackEventsMask) ( - SLBufferQueueItf self, - SLuint32 *pEventFlags - ); - -}; - -/*---------------------------------------------------------------------------*/ -/* ConfigExtension */ -/*---------------------------------------------------------------------------*/ -SL_API extern const SLInterfaceID SL_IID_CONFIGEXTENSION; - -struct SLConfigExtensionsItf_; -typedef const struct SLConfigExtensionsItf_ - * const * SLConfigExtensionsItf; - -struct SLConfigExtensionsItf_ { - SLresult (*SetConfiguration) ( - SLConfigExtensionsItf self, - const SLchar * pConfigKey, - SLuint32 valueSize, - const void * pConfigValue - ); - SLresult (*GetConfiguration) ( - SLConfigExtensionsItf self, - const SLchar * pConfigKey, - SLuint32 * pValueSize, - void * pConfigValue - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* PresetReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) -#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) -#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) -#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) -#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) -#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) -#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) - - -SL_API extern const SLInterfaceID SL_IID_PRESETREVERB; - -struct SLPresetReverbItf_; -typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; - -struct SLPresetReverbItf_ { - SLresult (*SetPreset) ( - SLPresetReverbItf self, - SLuint16 preset - ); - SLresult (*GetPreset) ( - SLPresetReverbItf self, - SLuint16 *pPreset - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* EnvironmentalReverb */ -/*---------------------------------------------------------------------------*/ - -#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ - { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ - { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ - { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ - { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ - { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ - { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ - { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ - { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ - { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ - { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ - { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ - { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ - { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ - { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ - { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ - { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ - { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ - { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ - { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ - { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ - { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ - { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ - { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } -#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ - { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ - { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ - { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ - { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ - { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ - { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } -#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ - { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } - - -typedef struct SLEnvironmentalReverbSettings_ { - SLmillibel roomLevel; - SLmillibel roomHFLevel; - SLmillisecond decayTime; - SLpermille decayHFRatio; - SLmillibel reflectionsLevel; - SLmillisecond reflectionsDelay; - SLmillibel reverbLevel; - SLmillisecond reverbDelay; - SLpermille diffusion; - SLpermille density; -} SLEnvironmentalReverbSettings; - - - - -SL_API extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; - - -struct SLEnvironmentalReverbItf_; -typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; - -struct SLEnvironmentalReverbItf_ { - SLresult (*SetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel room - ); - SLresult (*GetRoomLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoom - ); - SLresult (*SetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel roomHF - ); - SLresult (*GetRoomHFLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pRoomHF - ); - SLresult (*SetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond decayTime - ); - SLresult (*GetDecayTime) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pDecayTime - ); - SLresult (*SetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille decayHFRatio - ); - SLresult (*GetDecayHFRatio) ( - SLEnvironmentalReverbItf self, - SLpermille *pDecayHFRatio - ); - SLresult (*SetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reflectionsLevel - ); - SLresult (*GetReflectionsLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReflectionsLevel - ); - SLresult (*SetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reflectionsDelay - ); - SLresult (*GetReflectionsDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReflectionsDelay - ); - SLresult (*SetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel reverbLevel - ); - SLresult (*GetReverbLevel) ( - SLEnvironmentalReverbItf self, - SLmillibel *pReverbLevel - ); - SLresult (*SetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond reverbDelay - ); - SLresult (*GetReverbDelay) ( - SLEnvironmentalReverbItf self, - SLmillisecond *pReverbDelay - ); - SLresult (*SetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille diffusion - ); - SLresult (*GetDiffusion) ( - SLEnvironmentalReverbItf self, - SLpermille *pDiffusion - ); - SLresult (*SetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille density - ); - SLresult (*GetDensity) ( - SLEnvironmentalReverbItf self, - SLpermille *pDensity - ); - SLresult (*SetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - const SLEnvironmentalReverbSettings *pProperties - ); - SLresult (*GetEnvironmentalReverbProperties) ( - SLEnvironmentalReverbItf self, - SLEnvironmentalReverbSettings *pProperties - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Effects Send Interface */ -/*---------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_EFFECTSEND; - -struct SLEffectSendItf_; -typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; - -struct SLEffectSendItf_ { - SLresult (*EnableEffectSend) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLboolean enable, - SLmillibel initialLevel - ); - SLresult (*IsEnabled) ( - SLEffectSendItf self, - const void * pAuxEffect, - SLboolean *pEnable - ); - SLresult (*SetDirectLevel) ( - SLEffectSendItf self, - SLmillibel directLevel - ); - SLresult (*GetDirectLevel) ( - SLEffectSendItf self, - SLmillibel *pDirectLevel - ); - SLresult (*SetSendLevel) ( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel sendLevel - ); - SLresult (*GetSendLevel)( - SLEffectSendItf self, - const void *pAuxEffect, - SLmillibel *pSendLevel - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Grouping Interface */ -/*---------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_3DGROUPING; - - -struct SL3DGroupingItf_ ; -typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; - -struct SL3DGroupingItf_ { - SLresult (*Set3DGroup) ( - SL3DGroupingItf self, - SLObjectItf group - ); - SLresult (*Get3DGroup) ( - SL3DGroupingItf self, - SLObjectItf *pGroup - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Hint Interface */ -/*---------------------------------------------------------------------------*/ -#define SL_3DHINT_OFF ((SLuint16) 0x0000) -#define SL_3DHINT_QUALITY_LOWEST ((SLuint16) 0x0001) -#define SL_3DHINT_QUALITY_LOW ((SLuint16) 0x4000) -#define SL_3DHINT_QUALITY_MEDIUM ((SLuint16) 0x8000) -#define SL_3DHINT_QUALITY_HIGH ((SLuint16) 0xC000) -#define SL_3DHINT_QUALITY_HIGHEST ((SLuint16) 0xFFFF) - -SL_API extern const SLInterfaceID SL_IID_3DHINT; - -struct SL3DHintItf_; -typedef const struct SL3DHintItf_ * const * SL3DHintItf; - -struct SL3DHintItf_ { - SLresult (*SetRenderHint) ( - SL3DHintItf self, - SLuint16 qualityHint - ); - SLresult (*GetRenderHint) ( - SL3DHintItf self, - SLuint16 *pQualityHint - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Commit Interface */ -/*---------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_3DCOMMIT; - -struct SL3DCommitItf_; -typedef const struct SL3DCommitItf_* const * SL3DCommitItf; - -struct SL3DCommitItf_ { - SLresult (*Commit) ( - SL3DCommitItf self - ); - SLresult (*SetDeferred) ( - SL3DCommitItf self, - SLboolean deferred - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Location Interface */ -/*---------------------------------------------------------------------------*/ - -typedef struct SLVec3D_ { - SLint32 x; - SLint32 y; - SLint32 z; -} SLVec3D; - -SL_API extern const SLInterfaceID SL_IID_3DLOCATION; - -struct SL3DLocationItf_; -typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; - -struct SL3DLocationItf_ { - SLresult (*SetLocationCartesian) ( - SL3DLocationItf self, - const SLVec3D *pLocation - ); - SLresult (*SetLocationSpherical) ( - SL3DLocationItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter distance - ); - SLresult (*Move) ( - SL3DLocationItf self, - const SLVec3D *pMovement - ); - SLresult (*GetLocationCartesian) ( - SL3DLocationItf self, - SLVec3D *pLocation - ); - SLresult (*SetOrientationVectors) ( - SL3DLocationItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*SetOrientationAngles) ( - SL3DLocationItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*Rotate) ( - SL3DLocationItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DLocationItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* 3D Doppler Interface */ -/*---------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_3DDOPPLER; - -struct SL3DDopplerItf_; -typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; - -struct SL3DDopplerItf_ { - SLresult (*SetVelocityCartesian) ( - SL3DDopplerItf self, - const SLVec3D *pVelocity - ); - SLresult (*SetVelocitySpherical) ( - SL3DDopplerItf self, - SLmillidegree azimuth, - SLmillidegree elevation, - SLmillimeter speed - ); - SLresult (*GetVelocityCartesian) ( - SL3DDopplerItf self, - SLVec3D *pVelocity - ); - SLresult (*SetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille dopplerFactor - ); - SLresult (*GetDopplerFactor) ( - SL3DDopplerItf self, - SLpermille *pDopplerFactor - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Source Interface and associated defines */ -/* --------------------------------------------------------------------------*/ - -#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) -#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) - - -SL_API extern const SLInterfaceID SL_IID_3DSOURCE; - -struct SL3DSourceItf_; -typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; - -struct SL3DSourceItf_ { - SLresult (*SetHeadRelative) ( - SL3DSourceItf self, - SLboolean headRelative - ); - SLresult (*GetHeadRelative) ( - SL3DSourceItf self, - SLboolean *pHeadRelative - ); - SLresult (*SetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter minDistance, - SLmillimeter maxDistance - ); - SLresult (*GetRolloffDistances) ( - SL3DSourceItf self, - SLmillimeter *pMinDistance, - SLmillimeter *pMaxDistance - ); - SLresult (*SetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean mute - ); - SLresult (*GetRolloffMaxDistanceMute) ( - SL3DSourceItf self, - SLboolean *pMute - ); - SLresult (*SetRolloffFactor) ( - SL3DSourceItf self, - SLpermille rolloffFactor - ); - SLresult (*GetRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRolloffFactor - ); - SLresult (*SetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille roomRolloffFactor - ); - SLresult (*GetRoomRolloffFactor) ( - SL3DSourceItf self, - SLpermille *pRoomRolloffFactor - ); - SLresult (*SetRolloffModel) ( - SL3DSourceItf self, - SLuint8 model - ); - SLresult (*GetRolloffModel) ( - SL3DSourceItf self, - SLuint8 *pModel - ); - SLresult (*SetCone) ( - SL3DSourceItf self, - SLmillidegree innerAngle, - SLmillidegree outerAngle, - SLmillibel outerLevel - ); - SLresult (*GetCone) ( - SL3DSourceItf self, - SLmillidegree *pInnerAngle, - SLmillidegree *pOuterAngle, - SLmillibel *pOuterLevel - ); -}; - -/*---------------------------------------------------------------------------*/ -/* 3D Macroscopic Interface */ -/* --------------------------------------------------------------------------*/ - -SL_API extern const SLInterfaceID SL_IID_3DMACROSCOPIC; - -struct SL3DMacroscopicItf_; -typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; - -struct SL3DMacroscopicItf_ { - SLresult (*SetSize) ( - SL3DMacroscopicItf self, - SLmillimeter width, - SLmillimeter height, - SLmillimeter depth - ); - SLresult (*GetSize) ( - SL3DMacroscopicItf self, - SLmillimeter *pWidth, - SLmillimeter *pHeight, - SLmillimeter *pDepth - ); - SLresult (*SetOrientationAngles) ( - SL3DMacroscopicItf self, - SLmillidegree heading, - SLmillidegree pitch, - SLmillidegree roll - ); - SLresult (*SetOrientationVectors) ( - SL3DMacroscopicItf self, - const SLVec3D *pFront, - const SLVec3D *pAbove - ); - SLresult (*Rotate) ( - SL3DMacroscopicItf self, - SLmillidegree theta, - const SLVec3D *pAxis - ); - SLresult (*GetOrientationVectors) ( - SL3DMacroscopicItf self, - SLVec3D *pFront, - SLVec3D *pUp - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Mute Solo Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_MUTESOLO; - -struct SLMuteSoloItf_; -typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; - -struct SLMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMuteSoloItf self, - SLuint8 chan, - SLboolean *pSolo - ); - SLresult (*GetNumChannels) ( - SLMuteSoloItf self, - SLuint8 *pNumChannels - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Dynamic Interface Management Interface and associated types and macros */ -/* --------------------------------------------------------------------------*/ - -#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) -#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) -#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) - - - - -SL_API extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; - -struct SLDynamicInterfaceManagementItf_; -typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; - -typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( - SLDynamicInterfaceManagementItf caller, - void * pContext, - SLuint32 event, - SLresult result, - const SLInterfaceID iid -); - - -struct SLDynamicInterfaceManagementItf_ { - SLresult (*AddInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RemoveInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid - ); - SLresult (*ResumeInterface) ( - SLDynamicInterfaceManagementItf self, - const SLInterfaceID iid, - SLboolean async - ); - SLresult (*RegisterCallback) ( - SLDynamicInterfaceManagementItf self, - slDynamicInterfaceManagementCallback callback, - void * pContext - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Midi Message Interface and associated types */ -/* --------------------------------------------------------------------------*/ - -#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) -#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) -#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) -#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) -#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) -#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) -#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) - - -SL_API extern const SLInterfaceID SL_IID_MIDIMESSAGE; - -struct SLMIDIMessageItf_; -typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; - -typedef void (SLAPIENTRY *slMetaEventCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 type, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -typedef void (SLAPIENTRY *slMIDIMessageCallback) ( - SLMIDIMessageItf caller, - void *pContext, - SLuint8 statusByte, - SLuint32 length, - const SLuint8 *pData, - SLuint32 tick, - SLuint16 track -); - -struct SLMIDIMessageItf_ { - SLresult (*SendMessage) ( - SLMIDIMessageItf self, - const SLuint8 *pData, - SLuint32 length - ); - SLresult (*RegisterMetaEventCallback) ( - SLMIDIMessageItf self, - slMetaEventCallback callback, - void *pContext - ); - SLresult (*RegisterMIDIMessageCallback) ( - SLMIDIMessageItf self, - slMIDIMessageCallback callback, - void *pContext - ); - SLresult (*AddMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self, - SLuint32 messageType - ); - SLresult (*ClearMIDIMessageCallbackFilter) ( - SLMIDIMessageItf self - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Mute Solo interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_MIDIMUTESOLO; - -struct SLMIDIMuteSoloItf_; -typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; - -struct SLMIDIMuteSoloItf_ { - SLresult (*SetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean mute - ); - SLresult (*GetChannelMute) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pMute - ); - SLresult (*SetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean solo - ); - SLresult (*GetChannelSolo) ( - SLMIDIMuteSoloItf self, - SLuint8 channel, - SLboolean *pSolo - ); - SLresult (*GetTrackCount) ( - SLMIDIMuteSoloItf self, - SLuint16 *pCount - ); - SLresult (*SetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean mute - ); - SLresult (*GetTrackMute) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pMute - ); - SLresult (*SetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean solo - ); - SLresult (*GetTrackSolo) ( - SLMIDIMuteSoloItf self, - SLuint16 track, - SLboolean *pSolo - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Tempo interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_MIDITEMPO; - -struct SLMIDITempoItf_; -typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; - -struct SLMIDITempoItf_ { - SLresult (*SetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 tpqn - ); - SLresult (*GetTicksPerQuarterNote) ( - SLMIDITempoItf self, - SLuint32 *pTpqn - ); - SLresult (*SetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond uspqn - ); - SLresult (*GetMicrosecondsPerQuarterNote) ( - SLMIDITempoItf self, - SLmicrosecond *uspqn - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Midi Time interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_MIDITIME; - -struct SLMIDITimeItf_; -typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; - -struct SLMIDITimeItf_ { - SLresult (*GetDuration) ( - SLMIDITimeItf self, - SLuint32 *pDuration - ); - SLresult (*SetPosition) ( - SLMIDITimeItf self, - SLuint32 position - ); - SLresult (*GetPosition) ( - SLMIDITimeItf self, - SLuint32 *pPosition - ); - SLresult (*SetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 startTick, - SLuint32 numTicks - ); - SLresult (*GetLoopPoints) ( - SLMIDITimeItf self, - SLuint32 *pStartTick, - SLuint32 *pNumTicks - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Decoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/*Audio Codec related defines*/ -#define SL_AUDIOSTREAMFORMAT_UNDEFINED ((SLuint32) 0x00000000) - -#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) -#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) - -#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) -#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) -#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) -#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) -#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) -#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) -#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) -#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) -#define SL_AUDIOCODEC_VORBIS ((SLuint32) 0x00000009) - -#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) - -#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) -#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) -#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) -#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) - -#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) - -#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) - -#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) - -#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) -#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) -#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) - -#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) -#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) -#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) -#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) -#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) -#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) -#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) - -#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) -#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) -#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) -#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) - -#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) -#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) -#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) -#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) -#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) - -#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) - -#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) -#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) -#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) -#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) - -typedef struct SLAudioCodecDescriptor_ { - SLuint32 maxChannels; - SLuint32 minBitsPerSample; - SLuint32 maxBitsPerSample; - SLmilliHertz minSampleRate; - SLmilliHertz maxSampleRate; - SLboolean isFreqRangeContinuous; - SLmilliHertz *pSampleRatesSupported; - SLuint32 numSampleRatesSupported; - SLuint32 minBitRate; - SLuint32 maxBitRate; - SLboolean isBitrateRangeContinuous; - SLuint32 *pBitratesSupported; - SLuint32 numBitratesSupported; - SLuint32 profileSetting; - SLuint32 modeSetting; - SLuint32 streamFormat; -} SLAudioCodecDescriptor; - -SL_API extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; - -struct SLAudioDecoderCapabilitiesItf_; -typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; - -struct SLAudioDecoderCapabilitiesItf_ { - SLresult (*GetAudioDecoders) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 * pNumDecoders , - SLuint32 *pDecoderIds - ); - SLresult (*GetAudioDecoderCapabilities) ( - SLAudioDecoderCapabilitiesItf self, - SLuint32 decoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor *pDescriptor - ); -}; - - - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - -/* Structure used when setting audio encoding parameters */ - -typedef struct SLAudioEncoderSettings_ { - SLuint32 encoderId; - SLuint32 channelsIn; - SLuint32 channelsOut; - SLmilliHertz sampleRate; - SLuint32 bitRate; - SLuint32 bitsPerSample; - SLuint32 rateControl; - SLuint32 profileSetting; - SLuint32 levelSetting; - SLuint32 channelMode; - SLuint32 streamFormat; - SLuint32 encodeOptions; - SLuint32 blockAlignment; -} SLAudioEncoderSettings; - -SL_API extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; - -struct SLAudioEncoderCapabilitiesItf_; -typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; - -struct SLAudioEncoderCapabilitiesItf_ { - SLresult (*GetAudioEncoders) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 *pNumEncoders , - SLuint32 *pEncoderIds - ); - SLresult (*GetAudioEncoderCapabilities) ( - SLAudioEncoderCapabilitiesItf self, - SLuint32 encoderId, - SLuint32 *pIndex, - SLAudioCodecDescriptor * pDescriptor - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Audio Encoder Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_AUDIOENCODER; - -struct SLAudioEncoderItf_; -typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; - -struct SLAudioEncoderItf_ { - SLresult (*SetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); - SLresult (*GetEncoderSettings) ( - SLAudioEncoderItf self, - SLAudioEncoderSettings *pSettings - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Bass Boost Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_BASSBOOST; - -struct SLBassBoostItf_; -typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; - -struct SLBassBoostItf_ { - SLresult (*SetEnabled)( - SLBassBoostItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLBassBoostItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLBassBoostItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLBassBoostItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLBassBoostItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Pitch Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_PITCH; - -struct SLPitchItf_; -typedef const struct SLPitchItf_ * const * SLPitchItf; - -struct SLPitchItf_ { - SLresult (*SetPitch) ( - SLPitchItf self, - SLpermille pitch - ); - SLresult (*GetPitch) ( - SLPitchItf self, - SLpermille *pPitch - ); - SLresult (*GetPitchCapabilities) ( - SLPitchItf self, - SLpermille *pMinPitch, - SLpermille *pMaxPitch - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Rate Pitch Interface */ -/* RatePitchItf is an interface for controlling the rate a sound is played */ -/* back. A change in rate will cause a change in pitch. */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_RATEPITCH; - -struct SLRatePitchItf_; -typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; - -struct SLRatePitchItf_ { - SLresult (*SetRate) ( - SLRatePitchItf self, - SLpermille rate - ); - SLresult (*GetRate) ( - SLRatePitchItf self, - SLpermille *pRate - ); - SLresult (*GetRatePitchCapabilities) ( - SLRatePitchItf self, - SLpermille *pMinRate, - SLpermille *pMaxRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Virtualizer Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_VIRTUALIZER; - -struct SLVirtualizerItf_; -typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; - -struct SLVirtualizerItf_ { - SLresult (*SetEnabled)( - SLVirtualizerItf self, - SLboolean enabled - ); - SLresult (*IsEnabled)( - SLVirtualizerItf self, - SLboolean *pEnabled - ); - SLresult (*SetStrength)( - SLVirtualizerItf self, - SLpermille strength - ); - SLresult (*GetRoundedStrength)( - SLVirtualizerItf self, - SLpermille *pStrength - ); - SLresult (*IsStrengthSupported)( - SLVirtualizerItf self, - SLboolean *pSupported - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Visualization Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_VISUALIZATION; - -struct SLVisualizationItf_; -typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; - -typedef void (SLAPIENTRY *slVisualizationCallback) ( - void *pContext, - const SLuint8 waveform[], - const SLuint8 fft[], - SLmilliHertz samplerate -); - -struct SLVisualizationItf_{ - SLresult (*RegisterVisualizationCallback)( - SLVisualizationItf self, - slVisualizationCallback callback, - void *pContext, - SLmilliHertz rate - ); - SLresult (*GetMaxRate)( - SLVisualizationItf self, - SLmilliHertz* pRate - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_ENGINE; - -struct SLEngineItf_; -typedef const struct SLEngineItf_ * const * SLEngineItf; - - -struct SLEngineItf_ { - - SLresult (*CreateLEDDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateVibraDevice) ( - SLEngineItf self, - SLObjectItf * pDevice, - SLuint32 deviceID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - const SLDataSource *pAudioSrc, - const SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateAudioRecorder) ( - SLEngineItf self, - SLObjectItf * pRecorder, - const SLDataSource *pAudioSrc, - const SLDataSink *pAudioSnk, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMidiPlayer) ( - SLEngineItf self, - SLObjectItf * pPlayer, - const SLDataSource *pMIDISrc, - const SLDataSource *pBankSrc, - const SLDataSink *pAudioOutput, - const SLDataSink *pVibra, - const SLDataSink *pLEDArray, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateListener) ( - SLEngineItf self, - SLObjectItf * pListener, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*Create3DGroup) ( - SLEngineItf self, - SLObjectItf * pGroup, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateOutputMix) ( - SLEngineItf self, - SLObjectItf * pMix, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateMetadataExtractor) ( - SLEngineItf self, - SLObjectItf * pMetadataExtractor, - const SLDataSource * pDataSource, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*CreateExtensionObject) ( - SLEngineItf self, - SLObjectItf * pObject, - void * pParameters, - SLuint32 objectID, - SLuint32 numInterfaces, - const SLInterfaceID * pInterfaceIds, - const SLboolean * pInterfaceRequired - ); - SLresult (*QueryNumSupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 * pNumSupportedInterfaces - ); - SLresult (*QuerySupportedInterfaces) ( - SLEngineItf self, - SLuint32 objectID, - SLuint32 index, - SLInterfaceID * pInterfaceId - ); - SLresult (*QueryNumSupportedExtensions) ( - SLEngineItf self, - SLuint32 * pNumExtensions - ); - SLresult (*QuerySupportedExtension) ( - SLEngineItf self, - SLuint32 index, - SLchar * pExtensionName, - SLuint16 * pNameLength - ); - SLresult (*IsExtensionSupported) ( - SLEngineItf self, - const SLchar * pExtensionName, - SLboolean * pSupported - ); -}; - - -/*---------------------------------------------------------------------------*/ -/* Engine Capabilities Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; - -struct SLEngineCapabilitiesItf_; -typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; - -struct SLEngineCapabilitiesItf_ { - SLresult (*QuerySupportedProfiles) ( - SLEngineCapabilitiesItf self, - SLuint16 *pProfilesSupported - ); - SLresult (*QueryAvailableVoices) ( - SLEngineCapabilitiesItf self, - SLuint16 voiceType, - SLuint16 *pNumMaxVoices, - SLboolean *pIsAbsoluteMax, - SLuint16 *pNumFreeVoices - ); - SLresult (*QueryNumberOfMIDISynthesizers) ( - SLEngineCapabilitiesItf self, - SLuint16 *pNumMIDIsynthesizers - ); - SLresult (*QueryAPIVersion) ( - SLEngineCapabilitiesItf self, - SLuint16 *pMajor, - SLuint16 *pMinor, - SLuint16 *pStep - ); - SLresult (*QueryLEDCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pLEDDeviceID, - SLLEDDescriptor *pDescriptor - ); - SLresult (*QueryVibraCapabilities) ( - SLEngineCapabilitiesItf self, - SLuint32 *pIndex, - SLuint32 *pVibraDeviceID, - SLVibraDescriptor *pDescriptor - ); - SLresult (*IsThreadSafe) ( - SLEngineCapabilitiesItf self, - SLboolean *pIsThreadSafe - ); -}; - -/*---------------------------------------------------------------------------*/ -/* Thread Sync Interface */ -/* --------------------------------------------------------------------------*/ - - -SL_API extern const SLInterfaceID SL_IID_THREADSYNC; - -struct SLThreadSyncItf_; -typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; - - -struct SLThreadSyncItf_ { - SLresult (*EnterCriticalSection) ( - SLThreadSyncItf self - ); - SLresult (*ExitCriticalSection) ( - SLThreadSyncItf self - ); -}; - - -/*****************************************************************************/ -/* SL engine constructor */ -/*****************************************************************************/ - -#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) -#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) -#define SL_ENGINEOPTION_MAJORVERSION ((SLuint32) 0x00000003) -#define SL_ENGINEOPTION_MINORVERSION ((SLuint32) 0x00000004) -#define SL_ENGINEOPTION_STEPVERSION ((SLuint32) 0x00000005) - - -typedef struct SLEngineOption_ { - SLuint32 feature; - SLuint32 data; -} SLEngineOption; - - -SL_API SLresult SLAPIENTRY slCreateEngine( - SLObjectItf *pEngine, - SLuint32 numOptions, - const SLEngineOption *pEngineOptions, - SLuint32 numInterfaces, - const SLInterfaceID *pInterfaceIds, - const SLboolean * pInterfaceRequired -); - -SL_API SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( - SLuint32 * pNumSupportedInterfaces -); - -SL_API SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( - SLuint32 index, - SLInterfaceID * pInterfaceId -); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* OPENSL_ES_H_ */ +/* + * Copyright (c) 2007-2011 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES.h - OpenSL ES version 1.1 + * + */ + +/****************************************************************************/ +/* NOTE: This file is a standard OpenSL ES header file and should not be */ +/* modified in any way. */ +/****************************************************************************/ + +#ifndef OPENSL_ES_H_ +#define OPENSL_ES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "OpenSLES_Platform.h" + + +/*****************************************************************************/ +/* Common types, structures, and defines */ +/*****************************************************************************/ + +#ifndef _KHRONOS_KEYS_ +#define _KHRONOS_KEYS_ + +#define KHRONOS_TITLE "KhronosTitle" +#define KHRONOS_ALBUM "KhronosAlbum" +#define KHRONOS_TRACK_NUMBER "KhronosTrackNumber" +#define KHRONOS_ARTIST "KhronosArtist" +#define KHRONOS_GENRE "KhronosGenre" +#define KHRONOS_YEAR "KhronosYear" +#define KHRONOS_COMMENT "KhronosComment" +#define KHRONOS_ARTIST_URL "KhronosArtistURL" +#define KHRONOS_CONTENT_URL "KhronosContentURL" +#define KHRONOS_RATING "KhronosRating" +#define KHRONOS_ALBUM_ART "KhronosAlbumArt" +#define KHRONOS_COPYRIGHT "KhronosCopyright" + +#endif + + +/* remap common types to SL types for clarity */ +typedef sl_char_t SLchar; /* UTF-8 is to be used */ +typedef sl_int8_t SLint8; /* 8 bit signed integer */ +typedef sl_uint8_t SLuint8; /* 8 bit unsigned integer */ +typedef sl_int16_t SLint16; /* 16 bit signed integer */ +typedef sl_uint16_t SLuint16; /* 16 bit unsigned integer */ +typedef sl_int32_t SLint32; /* 32 bit signed integer */ +typedef sl_uint32_t SLuint32; /* 32 bit unsigned integer */ +typedef sl_float32_t SLfloat32; /* 32 bit floating point */ +typedef sl_float64_t Slfloat64; /* 64 bit floating point */ + + +typedef SLuint32 SLboolean; +#define SL_BOOLEAN_FALSE ((SLboolean) 0x00000000) +#define SL_BOOLEAN_TRUE ((SLboolean) 0x00000001) + +typedef SLint16 SLmillibel; +typedef SLuint32 SLmillisecond; +typedef SLuint32 SLmilliHertz; +typedef SLint32 SLmillimeter; +typedef SLint32 SLmillidegree; +typedef SLint16 SLpermille; +typedef SLuint32 SLmicrosecond; +typedef SLuint32 SLresult; + +#define SL_MILLIBEL_MAX ((SLmillibel) 0x7FFF) +#define SL_MILLIBEL_MIN ((SLmillibel) (-SL_MILLIBEL_MAX-1)) + +#define SL_MILLIHERTZ_MAX ((SLmilliHertz) 0xFFFFFFFF) +#define SL_MILLIMETER_MAX ((SLmillimeter) 0x7FFFFFFF) + +/** Interface ID defined as a UUID */ +typedef const struct SLInterfaceID_ { + SLuint32 time_low; + SLuint16 time_mid; + SLuint16 time_hi_and_version; + SLuint16 clock_seq; + SLuint8 node[6]; +} * SLInterfaceID; + +/* Forward declaration for the object interface */ +struct SLObjectItf_; + +typedef const struct SLObjectItf_ * const * SLObjectItf; + +/* Objects ID's */ + +#define SL_OBJECTID_ENGINE ((SLuint32) 0x00001001) +#define SL_OBJECTID_LEDDEVICE ((SLuint32) 0x00001002) +#define SL_OBJECTID_VIBRADEVICE ((SLuint32) 0x00001003) +#define SL_OBJECTID_AUDIOPLAYER ((SLuint32) 0x00001004) +#define SL_OBJECTID_AUDIORECORDER ((SLuint32) 0x00001005) +#define SL_OBJECTID_MIDIPLAYER ((SLuint32) 0x00001006) +#define SL_OBJECTID_LISTENER ((SLuint32) 0x00001007) +#define SL_OBJECTID_3DGROUP ((SLuint32) 0x00001008) +#define SL_OBJECTID_OUTPUTMIX ((SLuint32) 0x00001009) +#define SL_OBJECTID_METADATAEXTRACTOR ((SLuint32) 0x0000100A) + + +/* SL Profiles */ + +#define SL_PROFILES_PHONE ((SLuint16) 0x0001) +#define SL_PROFILES_MUSIC ((SLuint16) 0x0002) +#define SL_PROFILES_GAME ((SLuint16) 0x0004) + +/* Types of voices supported by the system */ + +#define SL_VOICETYPE_2D_AUDIO ((SLuint16) 0x0001) +#define SL_VOICETYPE_MIDI ((SLuint16) 0x0002) +#define SL_VOICETYPE_3D_AUDIO ((SLuint16) 0x0004) +#define SL_VOICETYPE_3D_MIDIOUTPUT ((SLuint16) 0x0008) + +/* Convenient macros representing various different priority levels, for use with the SetPriority method */ + +#define SL_PRIORITY_LOWEST ((SLuint32) 0xFFFFFFFF) +#define SL_PRIORITY_VERYLOW ((SLuint32) 0xE0000000) +#define SL_PRIORITY_LOW ((SLuint32) 0xC0000000) +#define SL_PRIORITY_BELOWNORMAL ((SLuint32) 0xA0000000) +#define SL_PRIORITY_NORMAL ((SLuint32) 0x7FFFFFFF) +#define SL_PRIORITY_ABOVENORMAL ((SLuint32) 0x60000000) +#define SL_PRIORITY_HIGH ((SLuint32) 0x40000000) +#define SL_PRIORITY_VERYHIGH ((SLuint32) 0x20000000) +#define SL_PRIORITY_HIGHEST ((SLuint32) 0x00000000) + +/** These macros list types of PCM data **/ +#define SL_PCM_REPRESENTATION_SIGNED_INT ((SLuint32) 0x00000001) +#define SL_PCM_REPRESENTATION_UNSIGNED_INT ((SLuint32) 0x00000002) +#define SL_PCM_REPRESENTATION_FLOAT ((SLuint32) 0x00000003) + +/** These macros list the various sample formats that are possible on audio input and output devices. */ + +#define SL_PCMSAMPLEFORMAT_FIXED_8 ((SLuint16) 0x0008) +#define SL_PCMSAMPLEFORMAT_FIXED_16 ((SLuint16) 0x0010) +#define SL_PCMSAMPLEFORMAT_FIXED_20 ((SLuint16) 0x0014) +#define SL_PCMSAMPLEFORMAT_FIXED_24 ((SLuint16) 0x0018) +#define SL_PCMSAMPLEFORMAT_FIXED_28 ((SLuint16) 0x001C) +#define SL_PCMSAMPLEFORMAT_FIXED_32 ((SLuint16) 0x0020) +#define SL_PCMSAMPLEFORMAT_FIXED_64 ((SLuint16) 0x0040) + +/** These macros specify the commonly used sampling rates (in milliHertz) supported by most audio I/O devices. */ + +#define SL_SAMPLINGRATE_8 ((SLuint32) 8000000) +#define SL_SAMPLINGRATE_11_025 ((SLuint32) 11025000) +#define SL_SAMPLINGRATE_12 ((SLuint32) 12000000) +#define SL_SAMPLINGRATE_16 ((SLuint32) 16000000) +#define SL_SAMPLINGRATE_22_05 ((SLuint32) 22050000) +#define SL_SAMPLINGRATE_24 ((SLuint32) 24000000) +#define SL_SAMPLINGRATE_32 ((SLuint32) 32000000) +#define SL_SAMPLINGRATE_44_1 ((SLuint32) 44100000) +#define SL_SAMPLINGRATE_48 ((SLuint32) 48000000) +#define SL_SAMPLINGRATE_64 ((SLuint32) 64000000) +#define SL_SAMPLINGRATE_88_2 ((SLuint32) 88200000) +#define SL_SAMPLINGRATE_96 ((SLuint32) 96000000) +#define SL_SAMPLINGRATE_192 ((SLuint32) 192000000) + +#define SL_SPEAKER_FRONT_LEFT ((SLuint32) 0x00000001) +#define SL_SPEAKER_FRONT_RIGHT ((SLuint32) 0x00000002) +#define SL_SPEAKER_FRONT_CENTER ((SLuint32) 0x00000004) +#define SL_SPEAKER_LOW_FREQUENCY ((SLuint32) 0x00000008) +#define SL_SPEAKER_BACK_LEFT ((SLuint32) 0x00000010) +#define SL_SPEAKER_BACK_RIGHT ((SLuint32) 0x00000020) +#define SL_SPEAKER_FRONT_LEFT_OF_CENTER ((SLuint32) 0x00000040) +#define SL_SPEAKER_FRONT_RIGHT_OF_CENTER ((SLuint32) 0x00000080) +#define SL_SPEAKER_BACK_CENTER ((SLuint32) 0x00000100) +#define SL_SPEAKER_SIDE_LEFT ((SLuint32) 0x00000200) +#define SL_SPEAKER_SIDE_RIGHT ((SLuint32) 0x00000400) +#define SL_SPEAKER_TOP_CENTER ((SLuint32) 0x00000800) +#define SL_SPEAKER_TOP_FRONT_LEFT ((SLuint32) 0x00001000) +#define SL_SPEAKER_TOP_FRONT_CENTER ((SLuint32) 0x00002000) +#define SL_SPEAKER_TOP_FRONT_RIGHT ((SLuint32) 0x00004000) +#define SL_SPEAKER_TOP_BACK_LEFT ((SLuint32) 0x00008000) +#define SL_SPEAKER_TOP_BACK_CENTER ((SLuint32) 0x00010000) +#define SL_SPEAKER_TOP_BACK_RIGHT ((SLuint32) 0x00020000) + + +/*****************************************************************************/ +/* Errors */ +/* */ +/*****************************************************************************/ + +#define SL_RESULT_SUCCESS ((SLuint32) 0x00000000) +#define SL_RESULT_PRECONDITIONS_VIOLATED ((SLuint32) 0x00000001) +#define SL_RESULT_PARAMETER_INVALID ((SLuint32) 0x00000002) +#define SL_RESULT_MEMORY_FAILURE ((SLuint32) 0x00000003) +#define SL_RESULT_RESOURCE_ERROR ((SLuint32) 0x00000004) +#define SL_RESULT_RESOURCE_LOST ((SLuint32) 0x00000005) +#define SL_RESULT_IO_ERROR ((SLuint32) 0x00000006) +#define SL_RESULT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000007) +#define SL_RESULT_CONTENT_CORRUPTED ((SLuint32) 0x00000008) +#define SL_RESULT_CONTENT_UNSUPPORTED ((SLuint32) 0x00000009) +#define SL_RESULT_CONTENT_NOT_FOUND ((SLuint32) 0x0000000A) +#define SL_RESULT_PERMISSION_DENIED ((SLuint32) 0x0000000B) +#define SL_RESULT_FEATURE_UNSUPPORTED ((SLuint32) 0x0000000C) +#define SL_RESULT_INTERNAL_ERROR ((SLuint32) 0x0000000D) +#define SL_RESULT_UNKNOWN_ERROR ((SLuint32) 0x0000000E) +#define SL_RESULT_OPERATION_ABORTED ((SLuint32) 0x0000000F) +#define SL_RESULT_CONTROL_LOST ((SLuint32) 0x00000010) +#define SL_RESULT_READONLY ((SLuint32) 0x00000011) +#define SL_RESULT_ENGINEOPTION_UNSUPPORTED ((SLuint32) 0x00000012) +#define SL_RESULT_SOURCE_SINK_INCOMPATIBLE ((SLuint32) 0x00000013) + +/* Object state definitions */ + +#define SL_OBJECT_STATE_UNREALIZED ((SLuint32) 0x00000001) +#define SL_OBJECT_STATE_REALIZED ((SLuint32) 0x00000002) +#define SL_OBJECT_STATE_SUSPENDED ((SLuint32) 0x00000003) + +/* Object event definitions */ + +#define SL_OBJECT_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_OBJECT_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_OBJECT_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_OBJECT_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000004) +#define SL_OBJECT_EVENT_ITF_CONTROL_TAKEN ((SLuint32) 0x00000005) +#define SL_OBJECT_EVENT_ITF_CONTROL_RETURNED ((SLuint32) 0x00000006) +#define SL_OBJECT_EVENT_ITF_PARAMETERS_CHANGED ((SLuint32) 0x00000007) + + +/*****************************************************************************/ +/* Interface definitions */ +/*****************************************************************************/ + +/** NULL Interface */ + +SL_API extern const SLInterfaceID SL_IID_NULL; + +/*---------------------------------------------------------------------------*/ +/* Data Source and Data Sink Structures */ +/*---------------------------------------------------------------------------*/ + +/** Data locator macros */ +#define SL_DATALOCATOR_NULL ((SLuint32) 0x00000000) +#define SL_DATALOCATOR_URI ((SLuint32) 0x00000001) +#define SL_DATALOCATOR_ADDRESS ((SLuint32) 0x00000002) +#define SL_DATALOCATOR_IODEVICE ((SLuint32) 0x00000003) +#define SL_DATALOCATOR_OUTPUTMIX ((SLuint32) 0x00000004) +#define SL_DATALOCATOR_RESERVED5 ((SLuint32) 0x00000005) +#define SL_DATALOCATOR_BUFFERQUEUE ((SLuint32) 0x00000006) +#define SL_DATALOCATOR_MIDIBUFFERQUEUE ((SLuint32) 0x00000007) +#define SL_DATALOCATOR_MEDIAOBJECT ((SLuint32) 0x00000008) +#define SL_DATALOCATOR_CONTENTPIPE ((SLuint32) 0x00000009) + + +/** URI-based data locator definition where locatorType must be SL_DATALOCATOR_URI*/ +typedef struct SLDataLocator_URI_ { + SLuint32 locatorType; + const SLchar * pURI; +} SLDataLocator_URI; + +/** Address-based data locator definition where locatorType must be SL_DATALOCATOR_ADDRESS*/ +typedef struct SLDataLocator_Address_ { + SLuint32 locatorType; + void *pAddress; + SLuint32 length; +} SLDataLocator_Address; + +/** IODevice-types */ +#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) +#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) +#define SL_IODEVICE_VIBRA ((SLuint32) 0x00000003) +#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) +#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) +#define SL_IODEVICE_AUDIOOUTPUT ((SLuint32) 0x00000006) + +/** IODevice-based data locator definition where locatorType must be SL_DATALOCATOR_IODEVICE*/ +typedef struct SLDataLocator_IODevice_ { + SLuint32 locatorType; + SLuint32 deviceType; + SLuint32 deviceID; + SLObjectItf device; +} SLDataLocator_IODevice; + +/** OutputMix-based data locator definition where locatorType must be SL_DATALOCATOR_OUTPUTMIX*/ +typedef struct SLDataLocator_OutputMix_ { + SLuint32 locatorType; + SLObjectItf outputMix; +} SLDataLocator_OutputMix; + + +/** BufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_BUFFERQUEUE*/ +typedef struct SLDataLocator_BufferQueue_ { + SLuint32 locatorType; + SLuint32 numBuffers; +} SLDataLocator_BufferQueue; + +/** ContentPipe-based data locator definition where locatorType must be SL_DATALOCATOR_CONTENTPIPE */ +typedef struct SLDataLocator_ContentPipe_ { + SLuint32 locatorType; + void * pContentPipe; + const SLchar * pURI; +} SLDataLocator_ContentPipe; + +/** MidiBufferQueue-based data locator definition where locatorType must be SL_DATALOCATOR_MIDIBUFFERQUEUE*/ +typedef struct SLDataLocator_MIDIBufferQueue_ { + SLuint32 locatorType; + SLuint32 tpqn; + SLuint32 numBuffers; +} SLDataLocator_MIDIBufferQueue; + +/** Data format defines */ +#define SL_DATAFORMAT_MIME ((SLuint32) 0x00000001) +#define SL_DATAFORMAT_PCM ((SLuint32) 0x00000002) +#define SL_DATAFORMAT_RESERVED3 ((SLuint32) 0x00000003) +#define SL_DATAFORMAT_PCM_EX ((SLuint32) 0x00000004) + + +/** MIME-type-based data format definition where formatType must be SL_DATAFORMAT_MIME*/ +typedef struct SLDataFormat_MIME_ { + SLuint32 formatType; + const SLchar * pMimeType; + SLuint32 containerType; +} SLDataFormat_MIME; + +/* Byte order of a block of 16- or 32-bit data */ +#define SL_BYTEORDER_BIGENDIAN ((SLuint32) 0x00000001) +#define SL_BYTEORDER_LITTLEENDIAN ((SLuint32) 0x00000002) + +#ifdef SL_BYTEORDER_NATIVEBIGENDIAN +#define SL_BYTEORDER_NATIVE SL_BYTEORDER_BIGENDIAN +#else +#define SL_BYTEORDER_NATIVE SL_BYTEORDER_LITTLEENDIAN +#endif + +/* Container type */ +#define SL_CONTAINERTYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_CONTAINERTYPE_RAW ((SLuint32) 0x00000002) +#define SL_CONTAINERTYPE_ASF ((SLuint32) 0x00000003) +#define SL_CONTAINERTYPE_AVI ((SLuint32) 0x00000004) +#define SL_CONTAINERTYPE_BMP ((SLuint32) 0x00000005) +#define SL_CONTAINERTYPE_JPG ((SLuint32) 0x00000006) +#define SL_CONTAINERTYPE_JPG2000 ((SLuint32) 0x00000007) +#define SL_CONTAINERTYPE_M4A ((SLuint32) 0x00000008) +#define SL_CONTAINERTYPE_MP3 ((SLuint32) 0x00000009) +#define SL_CONTAINERTYPE_MP4 ((SLuint32) 0x0000000A) +#define SL_CONTAINERTYPE_MPEG_ES ((SLuint32) 0x0000000B) +#define SL_CONTAINERTYPE_MPEG_PS ((SLuint32) 0x0000000C) +#define SL_CONTAINERTYPE_MPEG_TS ((SLuint32) 0x0000000D) +#define SL_CONTAINERTYPE_QT ((SLuint32) 0x0000000E) +#define SL_CONTAINERTYPE_WAV ((SLuint32) 0x0000000F) +#define SL_CONTAINERTYPE_XMF_0 ((SLuint32) 0x00000010) +#define SL_CONTAINERTYPE_XMF_1 ((SLuint32) 0x00000011) +#define SL_CONTAINERTYPE_XMF_2 ((SLuint32) 0x00000012) +#define SL_CONTAINERTYPE_XMF_3 ((SLuint32) 0x00000013) +#define SL_CONTAINERTYPE_XMF_GENERIC ((SLuint32) 0x00000014) +#define SL_CONTAINERTYPE_AMR ((SLuint32) 0x00000015) +#define SL_CONTAINERTYPE_AAC ((SLuint32) 0x00000016) +#define SL_CONTAINERTYPE_3GPP ((SLuint32) 0x00000017) +#define SL_CONTAINERTYPE_3GA ((SLuint32) 0x00000018) +#define SL_CONTAINERTYPE_RM ((SLuint32) 0x00000019) +#define SL_CONTAINERTYPE_DMF ((SLuint32) 0x0000001A) +#define SL_CONTAINERTYPE_SMF ((SLuint32) 0x0000001B) +#define SL_CONTAINERTYPE_MOBILE_DLS ((SLuint32) 0x0000001C) +#define SL_CONTAINERTYPE_OGG ((SLuint32) 0x0000001D) + + +/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM*/ +/* SLDataFormat_PCM IS DEPRECATED. Use SLDataFormat_PCM_EX instead. */ +typedef struct SLDataFormat_PCM_ { + SLuint32 formatType; + SLuint32 numChannels; + SLuint32 samplesPerSec; + SLuint32 bitsPerSample; + SLuint32 containerSize; + SLuint32 channelMask; + SLuint32 endianness; +} SLDataFormat_PCM; + +/** PCM-type-based data format definition where formatType must be SL_DATAFORMAT_PCM_EX*/ +typedef struct SLDataFormat_PCM_EX_ { + SLuint32 formatType; + SLuint32 numChannels; + SLuint32 sampleRate; + SLuint32 bitsPerSample; + SLuint32 containerSize; + SLuint32 channelMask; + SLuint32 endianness; + SLuint32 representation; +} SLDataFormat_PCM_EX; + +/** MediaObject-type-based data format definition where formatType must be SL_DATAFORMAT_MEDIAOBJECT*/ +typedef struct SLDataLocator_MediaObject_ { + SLuint32 locatorType; + SLObjectItf mediaObject; +} SLDataLocator_MediaObject; + +/** NULL-type-based data format definition where formatType must be SL_DATAFORMAT_NULL*/ +typedef struct SLDataLocator_Null_ { + SLuint32 locatorType; +} SLDataLocator_Null; + + +typedef struct SLDataSource_ { + void *pLocator; + void *pFormat; +} SLDataSource; + + +typedef struct SLDataSink_ { + void *pLocator; + void *pFormat; +} SLDataSink; + +/*---------------------------------------------------------------------------*/ +/* Standard Object Interface */ +/*---------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_OBJECT; + +/** Object callback */ + + +typedef void (SLAPIENTRY *slObjectCallback) ( + SLObjectItf caller, + const void * pContext, + SLuint32 event, + SLresult result, + SLuint32 param, + void *pInterface +); + + +struct SLObjectItf_ { + SLresult (*Realize) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*Resume) ( + SLObjectItf self, + SLboolean async + ); + SLresult (*GetState) ( + SLObjectItf self, + SLuint32 * pState + ); + SLresult (*GetInterface) ( + SLObjectItf self, + const SLInterfaceID iid, + void * pInterface + ); + SLresult (*RegisterCallback) ( + SLObjectItf self, + slObjectCallback callback, + void * pContext + ); + void (*AbortAsyncOperation) ( + SLObjectItf self + ); + void (*Destroy) ( + SLObjectItf self + ); + SLresult (*SetPriority) ( + SLObjectItf self, + SLuint32 priority + ); + SLresult (*GetPriority) ( + SLObjectItf self, + SLuint32 *pPriority + ); + SLresult (*SetLossOfControlInterfaces) ( + SLObjectItf self, + SLuint16 numInterfaces, + const SLInterfaceID * pInterfaceIDs, + SLboolean enabled + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio IO Device capabilities interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_DEFAULTDEVICEID_AUDIOINPUT ((SLuint32) 0xFFFFFFFF) +#define SL_DEFAULTDEVICEID_AUDIOOUTPUT ((SLuint32) 0xFFFFFFFE) +#define SL_DEFAULTDEVICEID_LED ((SLuint32) 0xFFFFFFFD) +#define SL_DEFAULTDEVICEID_VIBRA ((SLuint32) 0xFFFFFFFC) +#define SL_DEFAULTDEVICEID_RESERVED1 ((SLuint32) 0xFFFFFFFB) + + +#define SL_DEVCONNECTION_INTEGRATED ((SLint16) 0x0001) +#define SL_DEVCONNECTION_ATTACHED_WIRED ((SLint16) 0x0100) +#define SL_DEVCONNECTION_ATTACHED_WIRELESS ((SLint16) 0x0200) +#define SL_DEVCONNECTION_NETWORK ((SLint16) 0x0400) + + +#define SL_DEVLOCATION_HANDSET ((SLuint16) 0x0001) +#define SL_DEVLOCATION_HEADSET ((SLuint16) 0x0002) +#define SL_DEVLOCATION_CARKIT ((SLuint16) 0x0003) +#define SL_DEVLOCATION_DOCK ((SLuint16) 0x0004) +#define SL_DEVLOCATION_REMOTE ((SLuint16) 0x0005) +/* Note: SL_DEVLOCATION_RESLTE is deprecated, use SL_DEVLOCATION_REMOTE instead. */ +#define SL_DEVLOCATION_RESLTE ((SLuint16) 0x0005) + + +#define SL_DEVSCOPE_UNKNOWN ((SLuint16) 0x0001) +#define SL_DEVSCOPE_ENVIRONMENT ((SLuint16) 0x0002) +#define SL_DEVSCOPE_USER ((SLuint16) 0x0003) + + +typedef struct SLAudioInputDescriptor_ { + SLchar *pDeviceName; + SLint16 deviceNameLength; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *pSamplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioInputDescriptor; + + +typedef struct SLAudioOutputDescriptor_ { + SLchar *pDeviceName; + SLint16 deviceNameLength; + SLint16 deviceConnection; + SLint16 deviceScope; + SLint16 deviceLocation; + SLboolean isForTelephony; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *pSamplingRatesSupported; + SLint16 numOfSamplingRatesSupported; + SLint16 maxChannels; +} SLAudioOutputDescriptor; + + + +SL_API extern const SLInterfaceID SL_IID_AUDIOIODEVICECAPABILITIES; + +struct SLAudioIODeviceCapabilitiesItf_; +typedef const struct SLAudioIODeviceCapabilitiesItf_ * const * SLAudioIODeviceCapabilitiesItf; + + +typedef void (SLAPIENTRY *slAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLuint32 numInputs, + SLboolean isNew +); + + +typedef void (SLAPIENTRY *slAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLuint32 deviceID, + SLuint32 numOutputs, + SLboolean isNew +); + +typedef void (SLAPIENTRY *slDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf caller, + void *pContext, + SLboolean isOutput, + SLuint32 numDevices +); + + +struct SLAudioIODeviceCapabilitiesItf_ { + SLresult (*GetAvailableAudioInputs)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 *pNumInputs, + SLuint32 *pInputDeviceIDs + ); + SLresult (*QueryAudioInputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioInputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioInputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioInputsChangedCallback callback, + void *pContext + ); + SLresult (*GetAvailableAudioOutputs)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 *pNumOutputs, + SLuint32 *pOutputDeviceIDs + ); + SLresult (*QueryAudioOutputCapabilities)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLAudioOutputDescriptor *pDescriptor + ); + SLresult (*RegisterAvailableAudioOutputsChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slAvailableAudioOutputsChangedCallback callback, + void *pContext + ); + SLresult (*RegisterDefaultDeviceIDMapChangedCallback) ( + SLAudioIODeviceCapabilitiesItf self, + slDefaultDeviceIDMapChangedCallback callback, + void *pContext + ); + SLresult (*GetAssociatedAudioInputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLuint32 *pNumAudioInputs, + SLuint32 *pAudioInputDeviceIDs + ); + SLresult (*GetAssociatedAudioOutputs) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLuint32 *pNumAudioOutputs, + SLuint32 *pAudioOutputDeviceIDs + ); + SLresult (*GetDefaultAudioDevices) ( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 defaultDeviceID, + SLuint32 *pNumAudioDevices, + SLuint32 *pAudioDeviceIDs + ); + SLresult (*QuerySampleFormatsSupported)( + SLAudioIODeviceCapabilitiesItf self, + SLuint32 deviceId, + SLmilliHertz samplingRate, + SLint32 *pSampleFormats, + SLuint32 *pNumOfSampleFormats + ); +}; + + + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the LED array IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLLEDDescriptor_ { + SLuint8 ledCount; + SLuint8 primaryLED; + SLuint32 colorMask; +} SLLEDDescriptor; + + +/*---------------------------------------------------------------------------*/ +/* LED Array interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLHSL_ { + SLmillidegree hue; + SLpermille saturation; + SLpermille lightness; +} SLHSL; + + +SL_API extern const SLInterfaceID SL_IID_LED; + +struct SLLEDArrayItf_; +typedef const struct SLLEDArrayItf_ * const * SLLEDArrayItf; + +struct SLLEDArrayItf_ { + SLresult (*ActivateLEDArray) ( + SLLEDArrayItf self, + SLuint32 lightMask + ); + SLresult (*IsLEDArrayActivated) ( + SLLEDArrayItf self, + SLuint32 *lightMask + ); + SLresult (*SetColor) ( + SLLEDArrayItf self, + SLuint8 index, + const SLHSL *color + ); + SLresult (*GetColor) ( + SLLEDArrayItf self, + SLuint8 index, + SLHSL *color + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Capabilities of the Vibra IODevice */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVibraDescriptor_ { + SLboolean supportsFrequency; + SLboolean supportsIntensity; + SLmilliHertz minFrequency; + SLmilliHertz maxFrequency; +} SLVibraDescriptor; + + + +/*---------------------------------------------------------------------------*/ +/* Vibra interface */ +/*---------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_VIBRA; + + +struct SLVibraItf_; +typedef const struct SLVibraItf_ * const * SLVibraItf; + +struct SLVibraItf_ { + SLresult (*Vibrate) ( + SLVibraItf self, + SLboolean vibrate + ); + SLresult (*IsVibrating) ( + SLVibraItf self, + SLboolean *pVibrating + ); + SLresult (*SetFrequency) ( + SLVibraItf self, + SLmilliHertz frequency + ); + SLresult (*GetFrequency) ( + SLVibraItf self, + SLmilliHertz *pFrequency + ); + SLresult (*SetIntensity) ( + SLVibraItf self, + SLpermille intensity + ); + SLresult (*GetIntensity) ( + SLVibraItf self, + SLpermille *pIntensity + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data extraction related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_CHARACTERENCODING_UNKNOWN ((SLuint32) 0x00000000) +#define SL_CHARACTERENCODING_BINARY ((SLuint32) 0x00000001) +#define SL_CHARACTERENCODING_ASCII ((SLuint32) 0x00000002) +#define SL_CHARACTERENCODING_BIG5 ((SLuint32) 0x00000003) +#define SL_CHARACTERENCODING_CODEPAGE1252 ((SLuint32) 0x00000004) +#define SL_CHARACTERENCODING_GB2312 ((SLuint32) 0x00000005) +#define SL_CHARACTERENCODING_HZGB2312 ((SLuint32) 0x00000006) +#define SL_CHARACTERENCODING_GB12345 ((SLuint32) 0x00000007) +#define SL_CHARACTERENCODING_GB18030 ((SLuint32) 0x00000008) +#define SL_CHARACTERENCODING_GBK ((SLuint32) 0x00000009) +#define SL_CHARACTERENCODING_IMAPUTF7 ((SLuint32) 0x0000000A) +#define SL_CHARACTERENCODING_ISO2022JP ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO2022JP1 ((SLuint32) 0x0000000B) +#define SL_CHARACTERENCODING_ISO88591 ((SLuint32) 0x0000000C) +#define SL_CHARACTERENCODING_ISO885910 ((SLuint32) 0x0000000D) +#define SL_CHARACTERENCODING_ISO885913 ((SLuint32) 0x0000000E) +#define SL_CHARACTERENCODING_ISO885914 ((SLuint32) 0x0000000F) +#define SL_CHARACTERENCODING_ISO885915 ((SLuint32) 0x00000010) +#define SL_CHARACTERENCODING_ISO88592 ((SLuint32) 0x00000011) +#define SL_CHARACTERENCODING_ISO88593 ((SLuint32) 0x00000012) +#define SL_CHARACTERENCODING_ISO88594 ((SLuint32) 0x00000013) +#define SL_CHARACTERENCODING_ISO88595 ((SLuint32) 0x00000014) +#define SL_CHARACTERENCODING_ISO88596 ((SLuint32) 0x00000015) +#define SL_CHARACTERENCODING_ISO88597 ((SLuint32) 0x00000016) +#define SL_CHARACTERENCODING_ISO88598 ((SLuint32) 0x00000017) +#define SL_CHARACTERENCODING_ISO88599 ((SLuint32) 0x00000018) +#define SL_CHARACTERENCODING_ISOEUCJP ((SLuint32) 0x00000019) +#define SL_CHARACTERENCODING_SHIFTJIS ((SLuint32) 0x0000001A) +#define SL_CHARACTERENCODING_SMS7BIT ((SLuint32) 0x0000001B) +#define SL_CHARACTERENCODING_UTF7 ((SLuint32) 0x0000001C) +#define SL_CHARACTERENCODING_UTF8 ((SLuint32) 0x0000001D) +#define SL_CHARACTERENCODING_JAVACONFORMANTUTF8 ((SLuint32) 0x0000001E) +#define SL_CHARACTERENCODING_UTF16BE ((SLuint32) 0x0000001F) +#define SL_CHARACTERENCODING_UTF16LE ((SLuint32) 0x00000020) + + +#define SL_METADATA_FILTER_KEY ((SLuint8) 0x01) +#define SL_METADATA_FILTER_LANG ((SLuint8) 0x02) +#define SL_METADATA_FILTER_ENCODING ((SLuint8) 0x04) + + +typedef struct SLMetadataInfo_ { + SLuint32 size; + SLuint32 encoding; + SLchar langCountry[16]; + SLuint8 data[1]; +} SLMetadataInfo; + +SL_API extern const SLInterfaceID SL_IID_METADATAEXTRACTION; + +struct SLMetadataExtractionItf_; +typedef const struct SLMetadataExtractionItf_ * const * SLMetadataExtractionItf; + + +struct SLMetadataExtractionItf_ { + SLresult (*GetItemCount) ( + SLMetadataExtractionItf self, + SLuint32 *pItemCount + ); + SLresult (*GetKeySize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pKeySize + ); + SLresult (*GetKey) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 keySize, + SLMetadataInfo *pKey + ); + SLresult (*GetValueSize) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 *pValueSize + ); + SLresult (*GetValue) ( + SLMetadataExtractionItf self, + SLuint32 index, + SLuint32 valueSize, + SLMetadataInfo *pValue + ); + SLresult (*AddKeyFilter) ( + SLMetadataExtractionItf self, + SLuint32 keySize, + const void *pKey, + SLuint32 keyEncoding, + const SLchar *pValueLangCountry, + SLuint32 valueEncoding, + SLuint8 filterMask + ); + SLresult (*ClearKeyFilter) ( + SLMetadataExtractionItf self + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Meta data message related types and interface */ +/*---------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_METADATAMESSAGE; + +struct SLMetadataMessageItf_; +typedef const struct SLMetadataMessageItf_ * const * SLMetadataMessageItf; + +typedef void (SLAPIENTRY *slMetadataCallback) ( + SLMetadataMessageItf caller, + void *pContext, + SLuint32 index +); + +struct SLMetadataMessageItf_ { + SLresult (*RegisterMetadataCallback) ( + SLMetadataMessageItf self, + slMetadataCallback callback, + void *pContext + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Meta data traversal related types and interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_METADATATRAVERSALMODE_ALL ((SLuint32) 0x00000001) +#define SL_METADATATRAVERSALMODE_NODE ((SLuint32) 0x00000002) + + +#define SL_NODETYPE_UNSPECIFIED ((SLuint32) 0x00000001) +#define SL_NODETYPE_AUDIO ((SLuint32) 0x00000002) +#define SL_NODETYPE_VIDEO ((SLuint32) 0x00000003) +#define SL_NODETYPE_IMAGE ((SLuint32) 0x00000004) + +#define SL_NODE_PARENT 0xFFFFFFFF + +SL_API extern const SLInterfaceID SL_IID_METADATATRAVERSAL; + +struct SLMetadataTraversalItf_; +typedef const struct SLMetadataTraversalItf_ * const * SLMetadataTraversalItf; + +struct SLMetadataTraversalItf_ { + SLresult (*SetMode) ( + SLMetadataTraversalItf self, + SLuint32 mode + ); + SLresult (*GetChildCount) ( + SLMetadataTraversalItf self, + SLuint32 *pCount + ); + SLresult (*GetChildMIMETypeSize) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLuint32 *pSize + ); + SLresult (*GetChildInfo) ( + SLMetadataTraversalItf self, + SLuint32 index, + SLint32 *pNodeID, + SLuint32 *pType, + SLuint32 size, + SLchar *pMimeType + ); + SLresult (*SetActiveNode) ( + SLMetadataTraversalItf self, + SLuint32 index + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Dynamic Source types and interface */ +/*---------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_DYNAMICSOURCE; + +struct SLDynamicSourceItf_; +typedef const struct SLDynamicSourceItf_ * const * SLDynamicSourceItf; + +struct SLDynamicSourceItf_ { + SLresult (*SetSource) ( + SLDynamicSourceItf self, + const SLDataSource *pDataSource + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Dynamic Source/Sink Change Interface */ +/*---------------------------------------------------------------------------*/ +SL_API extern const SLInterfaceID SL_IID_DYNAMICSOURCESINKCHANGE; + +struct SLDynamicSourceSinkChangeItf_; +typedef const struct SLDynamicSourceSinkChangeItf_ * const * SLDynamicSourceSinkChangeItf; + +typedef void (SLAPIENTRY *slSourceChangeCallback)( + SLDynamicSourceSinkChangeItf caller, + void *pContext, + SLuint32 resultCode, + const SLDataSource *pExistingDataSource, + const SLDataSource *pNewDataSource +); + +typedef void (SLAPIENTRY *slSinkChangeCallback)( + SLDynamicSourceSinkChangeItf caller, + void *pContext, + SLuint32 resultCode, + const SLDataSource *pExistingDataSink, + const SLDataSource *pNewDataSink +); + +struct SLDynamicSourceSinkChangeItf_ { + SLresult (*ChangeSource) ( + SLDynamicSourceSinkChangeItf self, + const SLDataSource * pExistingDataSource, + const SLDataSource * pNewDataSource, + SLboolean async + ); + SLresult (*ChangeSink) ( + SLDynamicSourceSinkChangeItf self, + const SLDataSink * pExistingDataSink, + const SLDataSink * pNewDataSink, + SLboolean async + ); + SLresult (*RegisterSourceChangeCallback) ( + SLDynamicSourceSinkChangeItf self, + slSourceChangeCallback callback, + void * pContext + ); + SLresult (*RegisterSinkChangeCallback) ( + SLDynamicSourceSinkChangeItf self, + slSinkChangeCallback callback, + void * pContext + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Output Mix interface */ +/*---------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_OUTPUTMIX; + +struct SLOutputMixItf_; +typedef const struct SLOutputMixItf_ * const * SLOutputMixItf; + +typedef void (SLAPIENTRY *slMixDeviceChangeCallback) ( + SLOutputMixItf caller, + void *pContext +); + + +struct SLOutputMixItf_ { + SLresult (*GetDestinationOutputDeviceIDs) ( + SLOutputMixItf self, + SLint32 *pNumDevices, + SLuint32 *pDeviceIDs + ); + SLresult (*RegisterDeviceChangeCallback) ( + SLOutputMixItf self, + slMixDeviceChangeCallback callback, + void *pContext + ); + SLresult (*ReRoute)( + SLOutputMixItf self, + SLint32 numOutputDevices, + SLuint32 *pOutputDeviceIDs + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Playback interface */ +/*---------------------------------------------------------------------------*/ + +/** Playback states */ +#define SL_PLAYSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_PLAYSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_PLAYSTATE_PLAYING ((SLuint32) 0x00000003) + +/** Play events **/ +#define SL_PLAYEVENT_HEADATEND ((SLuint32) 0x00000001) +#define SL_PLAYEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_PLAYEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_PLAYEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_PLAYEVENT_HEADSTALLED ((SLuint32) 0x00000010) +#define SL_PLAYEVENT_DURATIONUPDATED ((SLuint32) 0x00000020) + +#define SL_TIME_UNKNOWN ((SLuint32) 0xFFFFFFFF) + + +SL_API extern const SLInterfaceID SL_IID_PLAY; + +/** Playback interface methods */ + +struct SLPlayItf_; +typedef const struct SLPlayItf_ * const * SLPlayItf; + +typedef void (SLAPIENTRY *slPlayCallback) ( + SLPlayItf caller, + void *pContext, + SLuint32 event +); + +struct SLPlayItf_ { + SLresult (*SetPlayState) ( + SLPlayItf self, + SLuint32 state + ); + SLresult (*GetPlayState) ( + SLPlayItf self, + SLuint32 *pState + ); + SLresult (*GetDuration) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*GetPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLPlayItf self, + slPlayCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPlayItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLPlayItf self + ); + SLresult (*GetMarkerPosition) ( + SLPlayItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLPlayItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Prefetch status interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_PREFETCHEVENT_STATUSCHANGE ((SLuint32) 0x00000001) +#define SL_PREFETCHEVENT_FILLLEVELCHANGE ((SLuint32) 0x00000002) +#define SL_PREFETCHEVENT_ERROR ((SLuint32) 0x00000003) +#define SL_PREFETCHEVENT_ERROR_UNRECOVERABLE ((SLuint32) 0x00000004) + + +#define SL_PREFETCHSTATUS_UNDERFLOW ((SLuint32) 0x00000001) +#define SL_PREFETCHSTATUS_SUFFICIENTDATA ((SLuint32) 0x00000002) +#define SL_PREFETCHSTATUS_OVERFLOW ((SLuint32) 0x00000003) + + +SL_API extern const SLInterfaceID SL_IID_PREFETCHSTATUS; + + +/** Prefetch status interface methods */ + +struct SLPrefetchStatusItf_; +typedef const struct SLPrefetchStatusItf_ * const * SLPrefetchStatusItf; + +typedef void (SLAPIENTRY *slPrefetchCallback) ( + SLPrefetchStatusItf caller, + void *pContext, + SLuint32 event +); + +struct SLPrefetchStatusItf_ { + SLresult (*GetPrefetchStatus) ( + SLPrefetchStatusItf self, + SLuint32 *pStatus + ); + SLresult (*GetFillLevel) ( + SLPrefetchStatusItf self, + SLpermille *pLevel + ); + SLresult (*RegisterCallback) ( + SLPrefetchStatusItf self, + slPrefetchCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLPrefetchStatusItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille period + ); + SLresult (*GetFillUpdatePeriod) ( + SLPrefetchStatusItf self, + SLpermille *pPeriod + ); + SLresult (*GetError) ( + SLPrefetchStatusItf self, + SLresult *pResult + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Playback Rate interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_RATEPROP_RESERVED1 ((SLuint32) 0x00000001) +#define SL_RATEPROP_RESERVED2 ((SLuint32) 0x00000002) +#define SL_RATEPROP_SILENTAUDIO ((SLuint32) 0x00000100) +#define SL_RATEPROP_STAGGEREDAUDIO ((SLuint32) 0x00000200) +#define SL_RATEPROP_NOPITCHCORAUDIO ((SLuint32) 0x00000400) +#define SL_RATEPROP_PITCHCORAUDIO ((SLuint32) 0x00000800) + + +SL_API extern const SLInterfaceID SL_IID_PLAYBACKRATE; + +struct SLPlaybackRateItf_; +typedef const struct SLPlaybackRateItf_ * const * SLPlaybackRateItf; + +struct SLPlaybackRateItf_ { + SLresult (*SetRate)( + SLPlaybackRateItf self, + SLpermille rate + ); + SLresult (*GetRate)( + SLPlaybackRateItf self, + SLpermille *pRate + ); + SLresult (*SetPropertyConstraints)( + SLPlaybackRateItf self, + SLuint32 constraints + ); + SLresult (*GetProperties)( + SLPlaybackRateItf self, + SLuint32 *pProperties + ); + SLresult (*GetCapabilitiesOfRate)( + SLPlaybackRateItf self, + SLpermille rate, + SLuint32 *pCapabilities + ); + SLresult (*GetRateRange) ( + SLPlaybackRateItf self, + SLuint8 index, + SLpermille *pMinRate, + SLpermille *pMaxRate, + SLpermille *pStepSize, + SLuint32 *pCapabilities + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Seek Interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_SEEKMODE_FAST ((SLuint32) 0x0001) +#define SL_SEEKMODE_ACCURATE ((SLuint32) 0x0002) + +SL_API extern const SLInterfaceID SL_IID_SEEK; + +struct SLSeekItf_; +typedef const struct SLSeekItf_ * const * SLSeekItf; + +struct SLSeekItf_ { + SLresult (*SetPosition)( + SLSeekItf self, + SLmillisecond pos, + SLuint32 seekMode + ); + SLresult (*SetLoop)( + SLSeekItf self, + SLboolean loopEnable, + SLmillisecond startPos, + SLmillisecond endPos + ); + SLresult (*GetLoop)( + SLSeekItf self, + SLboolean *pLoopEnabled, + SLmillisecond *pStartPos, + SLmillisecond *pEndPos + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Standard Recording Interface */ +/*---------------------------------------------------------------------------*/ + +/** Recording states */ +#define SL_RECORDSTATE_STOPPED ((SLuint32) 0x00000001) +#define SL_RECORDSTATE_PAUSED ((SLuint32) 0x00000002) +#define SL_RECORDSTATE_RECORDING ((SLuint32) 0x00000003) + + +/** Record event **/ +#define SL_RECORDEVENT_HEADATLIMIT ((SLuint32) 0x00000001) +#define SL_RECORDEVENT_HEADATMARKER ((SLuint32) 0x00000002) +#define SL_RECORDEVENT_HEADATNEWPOS ((SLuint32) 0x00000004) +#define SL_RECORDEVENT_HEADMOVING ((SLuint32) 0x00000008) +#define SL_RECORDEVENT_HEADSTALLED ((SLuint32) 0x00000010) +/* Note: SL_RECORDEVENT_BUFFER_INSUFFICIENT is deprecated, use SL_RECORDEVENT_BUFFER_FULL instead. */ +#define SL_RECORDEVENT_BUFFER_INSUFFICIENT ((SLuint32) 0x00000020) +#define SL_RECORDEVENT_BUFFER_FULL ((SLuint32) 0x00000020) +#define SL_RECORDEVENT_BUFFERQUEUE_STARVED ((SLuint32) 0x00000040) + + +SL_API extern const SLInterfaceID SL_IID_RECORD; + +struct SLRecordItf_; +typedef const struct SLRecordItf_ * const * SLRecordItf; + +typedef void (SLAPIENTRY *slRecordCallback) ( + SLRecordItf caller, + void *pContext, + SLuint32 event +); + +/** Recording interface methods */ +struct SLRecordItf_ { + SLresult (*SetRecordState) ( + SLRecordItf self, + SLuint32 state + ); + SLresult (*GetRecordState) ( + SLRecordItf self, + SLuint32 *pState + ); + SLresult (*SetDurationLimit) ( + SLRecordItf self, + SLmillisecond msec + ); + SLresult (*GetPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*RegisterCallback) ( + SLRecordItf self, + slRecordCallback callback, + void *pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLRecordItf self, + SLuint32 *pEventFlags + ); + SLresult (*SetMarkerPosition) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*ClearMarkerPosition) ( + SLRecordItf self + ); + SLresult (*GetMarkerPosition) ( + SLRecordItf self, + SLmillisecond *pMsec + ); + SLresult (*SetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond mSec + ); + SLresult (*GetPositionUpdatePeriod) ( + SLRecordItf self, + SLmillisecond *pMsec + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Equalizer interface */ +/*---------------------------------------------------------------------------*/ + +#define SL_EQUALIZER_UNDEFINED ((SLuint16) 0xFFFF) + +SL_API extern const SLInterfaceID SL_IID_EQUALIZER; + +struct SLEqualizerItf_; +typedef const struct SLEqualizerItf_ * const * SLEqualizerItf; + +struct SLEqualizerItf_ { + SLresult (*SetEnabled)( + SLEqualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLEqualizerItf self, + SLboolean *pEnabled + ); + SLresult (*GetNumberOfBands)( + SLEqualizerItf self, + SLuint16 *pAmount + ); + SLresult (*GetBandLevelRange)( + SLEqualizerItf self, + SLmillibel *pMin, + SLmillibel *pMax + ); + SLresult (*SetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel level + ); + SLresult (*GetBandLevel)( + SLEqualizerItf self, + SLuint16 band, + SLmillibel *pLevel + ); + SLresult (*GetCenterFreq)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pCenter + ); + SLresult (*GetBandFreqRange)( + SLEqualizerItf self, + SLuint16 band, + SLmilliHertz *pMin, + SLmilliHertz *pMax + ); + SLresult (*GetBand)( + SLEqualizerItf self, + SLmilliHertz frequency, + SLuint16 *pBand + ); + SLresult (*GetCurrentPreset)( + SLEqualizerItf self, + SLuint16 *pPreset + ); + SLresult (*UsePreset)( + SLEqualizerItf self, + SLuint16 index + ); + SLresult (*GetNumberOfPresets)( + SLEqualizerItf self, + SLuint16 *pNumPresets + ); + SLresult (*GetPresetName)( + SLEqualizerItf self, + SLuint16 index, + SLuint16 * pSize, + SLchar * pName + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Volume Interface */ +/* --------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_VOLUME; + +struct SLVolumeItf_; +typedef const struct SLVolumeItf_ * const * SLVolumeItf; + +struct SLVolumeItf_ { + SLresult (*SetVolumeLevel) ( + SLVolumeItf self, + SLmillibel level + ); + SLresult (*GetVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pLevel + ); + SLresult (*GetMaxVolumeLevel) ( + SLVolumeItf self, + SLmillibel *pMaxLevel + ); + SLresult (*SetMute) ( + SLVolumeItf self, + SLboolean mute + ); + SLresult (*GetMute) ( + SLVolumeItf self, + SLboolean *pMute + ); + SLresult (*EnableStereoPosition) ( + SLVolumeItf self, + SLboolean enable + ); + SLresult (*IsEnabledStereoPosition) ( + SLVolumeItf self, + SLboolean *pEnable + ); + SLresult (*SetStereoPosition) ( + SLVolumeItf self, + SLpermille stereoPosition + ); + SLresult (*GetStereoPosition) ( + SLVolumeItf self, + SLpermille *pStereoPosition + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Device Volume Interface */ +/* --------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_DEVICEVOLUME; + +struct SLDeviceVolumeItf_; +typedef const struct SLDeviceVolumeItf_ * const * SLDeviceVolumeItf; + +struct SLDeviceVolumeItf_ { + SLresult (*GetVolumeScale) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pMinValue, + SLint32 *pMaxValue, + SLboolean *pIsMillibelScale + ); + SLresult (*SetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 volume + ); + SLresult (*GetVolume) ( + SLDeviceVolumeItf self, + SLuint32 deviceID, + SLint32 *pVolume + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Buffer Queue Interface */ +/*---------------------------------------------------------------------------*/ +/** Flags for buffer queue events */ +#define SL_BUFFERQUEUEEVENT_PROCESSED ((SLuint32) 0x00000001) +#define SL_BUFFERQUEUEEVENT_UNREALIZED ((SLuint32) 0x00000002) +#define SL_BUFFERQUEUEEVENT_CLEARED ((SLuint32) 0x00000004) +#define SL_BUFFERQUEUEEVENT_STOPPED ((SLuint32) 0x00000008) +#define SL_BUFFERQUEUEEVENT_ERROR ((SLuint32) 0x00000010) +#define SL_BUFFERQUEUEEVENT_CONTENT_END ((SLuint32) 0x00000020) + +SL_API extern const SLInterfaceID SL_IID_BUFFERQUEUE; + +struct SLBufferQueueItf_; +typedef const struct SLBufferQueueItf_ * const * SLBufferQueueItf; + +typedef void (SLAPIENTRY *slBufferQueueCallback) ( + SLBufferQueueItf caller, + SLuint32 eventFlags, + const void *pBuffer, + SLuint32 bufferSize, + SLuint32 dataUsed, + void *pContext +); + + +/** Buffer queue state **/ + +typedef struct SLBufferQueueState_ { + SLuint32 count; + SLuint32 index; +} SLBufferQueueState; + + +struct SLBufferQueueItf_ { + SLresult (*Enqueue) ( + SLBufferQueueItf self, + const void *pBuffer, + SLuint32 size, + SLboolean isLastBuffer + ); + SLresult (*Clear) ( + SLBufferQueueItf self + ); + SLresult (*GetState) ( + SLBufferQueueItf self, + SLBufferQueueState *pState + ); + SLresult (*RegisterCallback) ( + SLBufferQueueItf self, + slBufferQueueCallback callback, + void* pContext + ); + SLresult (*SetCallbackEventsMask) ( + SLBufferQueueItf self, + SLuint32 eventFlags + ); + SLresult (*GetCallbackEventsMask) ( + SLBufferQueueItf self, + SLuint32 *pEventFlags + ); + +}; + +/*---------------------------------------------------------------------------*/ +/* ConfigExtension */ +/*---------------------------------------------------------------------------*/ +SL_API extern const SLInterfaceID SL_IID_CONFIGEXTENSION; + +struct SLConfigExtensionsItf_; +typedef const struct SLConfigExtensionsItf_ + * const * SLConfigExtensionsItf; + +struct SLConfigExtensionsItf_ { + SLresult (*SetConfiguration) ( + SLConfigExtensionsItf self, + const SLchar * pConfigKey, + SLuint32 valueSize, + const void * pConfigValue + ); + SLresult (*GetConfiguration) ( + SLConfigExtensionsItf self, + const SLchar * pConfigKey, + SLuint32 * pValueSize, + void * pConfigValue + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* PresetReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_REVERBPRESET_NONE ((SLuint16) 0x0000) +#define SL_REVERBPRESET_SMALLROOM ((SLuint16) 0x0001) +#define SL_REVERBPRESET_MEDIUMROOM ((SLuint16) 0x0002) +#define SL_REVERBPRESET_LARGEROOM ((SLuint16) 0x0003) +#define SL_REVERBPRESET_MEDIUMHALL ((SLuint16) 0x0004) +#define SL_REVERBPRESET_LARGEHALL ((SLuint16) 0x0005) +#define SL_REVERBPRESET_PLATE ((SLuint16) 0x0006) + + +SL_API extern const SLInterfaceID SL_IID_PRESETREVERB; + +struct SLPresetReverbItf_; +typedef const struct SLPresetReverbItf_ * const * SLPresetReverbItf; + +struct SLPresetReverbItf_ { + SLresult (*SetPreset) ( + SLPresetReverbItf self, + SLuint16 preset + ); + SLresult (*GetPreset) ( + SLPresetReverbItf self, + SLuint16 *pPreset + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* EnvironmentalReverb */ +/*---------------------------------------------------------------------------*/ + +#define SL_I3DL2_ENVIRONMENT_PRESET_DEFAULT \ + { SL_MILLIBEL_MIN, 0, 1000, 500, SL_MILLIBEL_MIN, 20, SL_MILLIBEL_MIN, 40, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_GENERIC \ + { -1000, -100, 1490, 830, -2602, 7, 200, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL \ + { -1000,-6000, 170, 100, -1204, 1, 207, 2, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ROOM \ + { -1000, -454, 400, 830, -1646, 2, 53, 3, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_BATHROOM \ + { -1000,-1200, 1490, 540, -370, 7, 1030, 11, 1000, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM \ + { -1000,-6000, 500, 100, -1376, 3, -1104, 4, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONEROOM \ + { -1000, -300, 2310, 640, -711, 12, 83, 17, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM \ + { -1000, -476, 4320, 590, -789, 20, -289, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL \ + { -1000, -500, 3920, 700, -1230, 20, -2, 29, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CAVE \ + { -1000, 0, 2910, 1300, -602, 15, -302, 22, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ARENA \ + { -1000, -698, 7240, 330, -1166, 20, 16, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HANGAR \ + { -1000,-1000, 10050, 230, -602, 20, 198, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY \ + { -1000,-4000, 300, 100, -1831, 2, -1630, 30, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_HALLWAY \ + { -1000, -300, 1490, 590, -1219, 7, 441, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR \ + { -1000, -237, 2700, 790, -1214, 13, 395, 20, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_ALLEY \ + { -1000, -270, 1490, 860, -1204, 7, -4, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_FOREST \ + { -1000,-3300, 1490, 540, -2560, 162, -613, 88, 790,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_CITY \ + { -1000, -800, 1490, 670, -2273, 7, -2217, 11, 500,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS \ + { -1000,-2500, 1490, 210, -2780, 300, -2014, 100, 270,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_QUARRY \ + { -1000,-1000, 1490, 830, SL_MILLIBEL_MIN, 61, 500, 25, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLAIN \ + { -1000,-2000, 1490, 500, -2466, 179, -2514, 100, 210,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT \ + { -1000, 0, 1650, 1500, -1363, 8, -1153, 12, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE \ + { -1000,-1000, 2810, 140, 429, 14, 648, 21, 800, 600 } +#define SL_I3DL2_ENVIRONMENT_PRESET_UNDERWATER \ + { -1000,-4000, 1490, 100, -449, 7, 1700, 11, 1000,1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_SMALLROOM \ + { -1000,-600, 1100, 830, -400, 5, 500, 10, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM \ + { -1000,-600, 1300, 830, -1000, 20, -200, 20, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEROOM \ + { -1000,-600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL \ + { -1000,-600, 1800, 700, -1300, 15, -800, 30, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_LARGEHALL \ + { -1000,-600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000 } +#define SL_I3DL2_ENVIRONMENT_PRESET_PLATE \ + { -1000,-200, 1300, 900, 0, 2, 0, 10, 1000, 750 } + + +typedef struct SLEnvironmentalReverbSettings_ { + SLmillibel roomLevel; + SLmillibel roomHFLevel; + SLmillisecond decayTime; + SLpermille decayHFRatio; + SLmillibel reflectionsLevel; + SLmillisecond reflectionsDelay; + SLmillibel reverbLevel; + SLmillisecond reverbDelay; + SLpermille diffusion; + SLpermille density; +} SLEnvironmentalReverbSettings; + + + + +SL_API extern const SLInterfaceID SL_IID_ENVIRONMENTALREVERB; + + +struct SLEnvironmentalReverbItf_; +typedef const struct SLEnvironmentalReverbItf_ * const * SLEnvironmentalReverbItf; + +struct SLEnvironmentalReverbItf_ { + SLresult (*SetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel room + ); + SLresult (*GetRoomLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoom + ); + SLresult (*SetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel roomHF + ); + SLresult (*GetRoomHFLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pRoomHF + ); + SLresult (*SetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond decayTime + ); + SLresult (*GetDecayTime) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pDecayTime + ); + SLresult (*SetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille decayHFRatio + ); + SLresult (*GetDecayHFRatio) ( + SLEnvironmentalReverbItf self, + SLpermille *pDecayHFRatio + ); + SLresult (*SetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reflectionsLevel + ); + SLresult (*GetReflectionsLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReflectionsLevel + ); + SLresult (*SetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reflectionsDelay + ); + SLresult (*GetReflectionsDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReflectionsDelay + ); + SLresult (*SetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel reverbLevel + ); + SLresult (*GetReverbLevel) ( + SLEnvironmentalReverbItf self, + SLmillibel *pReverbLevel + ); + SLresult (*SetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond reverbDelay + ); + SLresult (*GetReverbDelay) ( + SLEnvironmentalReverbItf self, + SLmillisecond *pReverbDelay + ); + SLresult (*SetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille diffusion + ); + SLresult (*GetDiffusion) ( + SLEnvironmentalReverbItf self, + SLpermille *pDiffusion + ); + SLresult (*SetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille density + ); + SLresult (*GetDensity) ( + SLEnvironmentalReverbItf self, + SLpermille *pDensity + ); + SLresult (*SetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + const SLEnvironmentalReverbSettings *pProperties + ); + SLresult (*GetEnvironmentalReverbProperties) ( + SLEnvironmentalReverbItf self, + SLEnvironmentalReverbSettings *pProperties + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Effects Send Interface */ +/*---------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_EFFECTSEND; + +struct SLEffectSendItf_; +typedef const struct SLEffectSendItf_ * const * SLEffectSendItf; + +struct SLEffectSendItf_ { + SLresult (*EnableEffectSend) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLboolean enable, + SLmillibel initialLevel + ); + SLresult (*IsEnabled) ( + SLEffectSendItf self, + const void * pAuxEffect, + SLboolean *pEnable + ); + SLresult (*SetDirectLevel) ( + SLEffectSendItf self, + SLmillibel directLevel + ); + SLresult (*GetDirectLevel) ( + SLEffectSendItf self, + SLmillibel *pDirectLevel + ); + SLresult (*SetSendLevel) ( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel sendLevel + ); + SLresult (*GetSendLevel)( + SLEffectSendItf self, + const void *pAuxEffect, + SLmillibel *pSendLevel + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Grouping Interface */ +/*---------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_3DGROUPING; + + +struct SL3DGroupingItf_ ; +typedef const struct SL3DGroupingItf_ * const * SL3DGroupingItf; + +struct SL3DGroupingItf_ { + SLresult (*Set3DGroup) ( + SL3DGroupingItf self, + SLObjectItf group + ); + SLresult (*Get3DGroup) ( + SL3DGroupingItf self, + SLObjectItf *pGroup + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Hint Interface */ +/*---------------------------------------------------------------------------*/ +#define SL_3DHINT_OFF ((SLuint16) 0x0000) +#define SL_3DHINT_QUALITY_LOWEST ((SLuint16) 0x0001) +#define SL_3DHINT_QUALITY_LOW ((SLuint16) 0x4000) +#define SL_3DHINT_QUALITY_MEDIUM ((SLuint16) 0x8000) +#define SL_3DHINT_QUALITY_HIGH ((SLuint16) 0xC000) +#define SL_3DHINT_QUALITY_HIGHEST ((SLuint16) 0xFFFF) + +SL_API extern const SLInterfaceID SL_IID_3DHINT; + +struct SL3DHintItf_; +typedef const struct SL3DHintItf_ * const * SL3DHintItf; + +struct SL3DHintItf_ { + SLresult (*SetRenderHint) ( + SL3DHintItf self, + SLuint16 qualityHint + ); + SLresult (*GetRenderHint) ( + SL3DHintItf self, + SLuint16 *pQualityHint + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Commit Interface */ +/*---------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_3DCOMMIT; + +struct SL3DCommitItf_; +typedef const struct SL3DCommitItf_* const * SL3DCommitItf; + +struct SL3DCommitItf_ { + SLresult (*Commit) ( + SL3DCommitItf self + ); + SLresult (*SetDeferred) ( + SL3DCommitItf self, + SLboolean deferred + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Location Interface */ +/*---------------------------------------------------------------------------*/ + +typedef struct SLVec3D_ { + SLint32 x; + SLint32 y; + SLint32 z; +} SLVec3D; + +SL_API extern const SLInterfaceID SL_IID_3DLOCATION; + +struct SL3DLocationItf_; +typedef const struct SL3DLocationItf_ * const * SL3DLocationItf; + +struct SL3DLocationItf_ { + SLresult (*SetLocationCartesian) ( + SL3DLocationItf self, + const SLVec3D *pLocation + ); + SLresult (*SetLocationSpherical) ( + SL3DLocationItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter distance + ); + SLresult (*Move) ( + SL3DLocationItf self, + const SLVec3D *pMovement + ); + SLresult (*GetLocationCartesian) ( + SL3DLocationItf self, + SLVec3D *pLocation + ); + SLresult (*SetOrientationVectors) ( + SL3DLocationItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*SetOrientationAngles) ( + SL3DLocationItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*Rotate) ( + SL3DLocationItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DLocationItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* 3D Doppler Interface */ +/*---------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_3DDOPPLER; + +struct SL3DDopplerItf_; +typedef const struct SL3DDopplerItf_ * const * SL3DDopplerItf; + +struct SL3DDopplerItf_ { + SLresult (*SetVelocityCartesian) ( + SL3DDopplerItf self, + const SLVec3D *pVelocity + ); + SLresult (*SetVelocitySpherical) ( + SL3DDopplerItf self, + SLmillidegree azimuth, + SLmillidegree elevation, + SLmillimeter speed + ); + SLresult (*GetVelocityCartesian) ( + SL3DDopplerItf self, + SLVec3D *pVelocity + ); + SLresult (*SetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille dopplerFactor + ); + SLresult (*GetDopplerFactor) ( + SL3DDopplerItf self, + SLpermille *pDopplerFactor + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Source Interface and associated defines */ +/* --------------------------------------------------------------------------*/ + +#define SL_ROLLOFFMODEL_EXPONENTIAL ((SLuint32) 0x00000000) +#define SL_ROLLOFFMODEL_LINEAR ((SLuint32) 0x00000001) + + +SL_API extern const SLInterfaceID SL_IID_3DSOURCE; + +struct SL3DSourceItf_; +typedef const struct SL3DSourceItf_ * const * SL3DSourceItf; + +struct SL3DSourceItf_ { + SLresult (*SetHeadRelative) ( + SL3DSourceItf self, + SLboolean headRelative + ); + SLresult (*GetHeadRelative) ( + SL3DSourceItf self, + SLboolean *pHeadRelative + ); + SLresult (*SetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter minDistance, + SLmillimeter maxDistance + ); + SLresult (*GetRolloffDistances) ( + SL3DSourceItf self, + SLmillimeter *pMinDistance, + SLmillimeter *pMaxDistance + ); + SLresult (*SetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean mute + ); + SLresult (*GetRolloffMaxDistanceMute) ( + SL3DSourceItf self, + SLboolean *pMute + ); + SLresult (*SetRolloffFactor) ( + SL3DSourceItf self, + SLpermille rolloffFactor + ); + SLresult (*GetRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRolloffFactor + ); + SLresult (*SetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille roomRolloffFactor + ); + SLresult (*GetRoomRolloffFactor) ( + SL3DSourceItf self, + SLpermille *pRoomRolloffFactor + ); + SLresult (*SetRolloffModel) ( + SL3DSourceItf self, + SLuint8 model + ); + SLresult (*GetRolloffModel) ( + SL3DSourceItf self, + SLuint8 *pModel + ); + SLresult (*SetCone) ( + SL3DSourceItf self, + SLmillidegree innerAngle, + SLmillidegree outerAngle, + SLmillibel outerLevel + ); + SLresult (*GetCone) ( + SL3DSourceItf self, + SLmillidegree *pInnerAngle, + SLmillidegree *pOuterAngle, + SLmillibel *pOuterLevel + ); +}; + +/*---------------------------------------------------------------------------*/ +/* 3D Macroscopic Interface */ +/* --------------------------------------------------------------------------*/ + +SL_API extern const SLInterfaceID SL_IID_3DMACROSCOPIC; + +struct SL3DMacroscopicItf_; +typedef const struct SL3DMacroscopicItf_ * const * SL3DMacroscopicItf; + +struct SL3DMacroscopicItf_ { + SLresult (*SetSize) ( + SL3DMacroscopicItf self, + SLmillimeter width, + SLmillimeter height, + SLmillimeter depth + ); + SLresult (*GetSize) ( + SL3DMacroscopicItf self, + SLmillimeter *pWidth, + SLmillimeter *pHeight, + SLmillimeter *pDepth + ); + SLresult (*SetOrientationAngles) ( + SL3DMacroscopicItf self, + SLmillidegree heading, + SLmillidegree pitch, + SLmillidegree roll + ); + SLresult (*SetOrientationVectors) ( + SL3DMacroscopicItf self, + const SLVec3D *pFront, + const SLVec3D *pAbove + ); + SLresult (*Rotate) ( + SL3DMacroscopicItf self, + SLmillidegree theta, + const SLVec3D *pAxis + ); + SLresult (*GetOrientationVectors) ( + SL3DMacroscopicItf self, + SLVec3D *pFront, + SLVec3D *pUp + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Mute Solo Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_MUTESOLO; + +struct SLMuteSoloItf_; +typedef const struct SLMuteSoloItf_ * const * SLMuteSoloItf; + +struct SLMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMuteSoloItf self, + SLuint8 chan, + SLboolean *pSolo + ); + SLresult (*GetNumChannels) ( + SLMuteSoloItf self, + SLuint8 *pNumChannels + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Dynamic Interface Management Interface and associated types and macros */ +/* --------------------------------------------------------------------------*/ + +#define SL_DYNAMIC_ITF_EVENT_RUNTIME_ERROR ((SLuint32) 0x00000001) +#define SL_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION ((SLuint32) 0x00000002) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST ((SLuint32) 0x00000003) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_LOST_PERMANENTLY ((SLuint32) 0x00000004) +#define SL_DYNAMIC_ITF_EVENT_RESOURCES_AVAILABLE ((SLuint32) 0x00000005) + + + + +SL_API extern const SLInterfaceID SL_IID_DYNAMICINTERFACEMANAGEMENT; + +struct SLDynamicInterfaceManagementItf_; +typedef const struct SLDynamicInterfaceManagementItf_ * const * SLDynamicInterfaceManagementItf; + +typedef void (SLAPIENTRY *slDynamicInterfaceManagementCallback) ( + SLDynamicInterfaceManagementItf caller, + void * pContext, + SLuint32 event, + SLresult result, + const SLInterfaceID iid +); + + +struct SLDynamicInterfaceManagementItf_ { + SLresult (*AddInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RemoveInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid + ); + SLresult (*ResumeInterface) ( + SLDynamicInterfaceManagementItf self, + const SLInterfaceID iid, + SLboolean async + ); + SLresult (*RegisterCallback) ( + SLDynamicInterfaceManagementItf self, + slDynamicInterfaceManagementCallback callback, + void * pContext + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Midi Message Interface and associated types */ +/* --------------------------------------------------------------------------*/ + +#define SL_MIDIMESSAGETYPE_NOTE_ON_OFF ((SLuint32) 0x00000001) +#define SL_MIDIMESSAGETYPE_POLY_PRESSURE ((SLuint32) 0x00000002) +#define SL_MIDIMESSAGETYPE_CONTROL_CHANGE ((SLuint32) 0x00000003) +#define SL_MIDIMESSAGETYPE_PROGRAM_CHANGE ((SLuint32) 0x00000004) +#define SL_MIDIMESSAGETYPE_CHANNEL_PRESSURE ((SLuint32) 0x00000005) +#define SL_MIDIMESSAGETYPE_PITCH_BEND ((SLuint32) 0x00000006) +#define SL_MIDIMESSAGETYPE_SYSTEM_MESSAGE ((SLuint32) 0x00000007) + + +SL_API extern const SLInterfaceID SL_IID_MIDIMESSAGE; + +struct SLMIDIMessageItf_; +typedef const struct SLMIDIMessageItf_ * const * SLMIDIMessageItf; + +typedef void (SLAPIENTRY *slMetaEventCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 type, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +typedef void (SLAPIENTRY *slMIDIMessageCallback) ( + SLMIDIMessageItf caller, + void *pContext, + SLuint8 statusByte, + SLuint32 length, + const SLuint8 *pData, + SLuint32 tick, + SLuint16 track +); + +struct SLMIDIMessageItf_ { + SLresult (*SendMessage) ( + SLMIDIMessageItf self, + const SLuint8 *pData, + SLuint32 length + ); + SLresult (*RegisterMetaEventCallback) ( + SLMIDIMessageItf self, + slMetaEventCallback callback, + void *pContext + ); + SLresult (*RegisterMIDIMessageCallback) ( + SLMIDIMessageItf self, + slMIDIMessageCallback callback, + void *pContext + ); + SLresult (*AddMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self, + SLuint32 messageType + ); + SLresult (*ClearMIDIMessageCallbackFilter) ( + SLMIDIMessageItf self + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Mute Solo interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_MIDIMUTESOLO; + +struct SLMIDIMuteSoloItf_; +typedef const struct SLMIDIMuteSoloItf_ * const * SLMIDIMuteSoloItf; + +struct SLMIDIMuteSoloItf_ { + SLresult (*SetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean mute + ); + SLresult (*GetChannelMute) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pMute + ); + SLresult (*SetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean solo + ); + SLresult (*GetChannelSolo) ( + SLMIDIMuteSoloItf self, + SLuint8 channel, + SLboolean *pSolo + ); + SLresult (*GetTrackCount) ( + SLMIDIMuteSoloItf self, + SLuint16 *pCount + ); + SLresult (*SetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean mute + ); + SLresult (*GetTrackMute) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pMute + ); + SLresult (*SetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean solo + ); + SLresult (*GetTrackSolo) ( + SLMIDIMuteSoloItf self, + SLuint16 track, + SLboolean *pSolo + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Tempo interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_MIDITEMPO; + +struct SLMIDITempoItf_; +typedef const struct SLMIDITempoItf_ * const * SLMIDITempoItf; + +struct SLMIDITempoItf_ { + SLresult (*SetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 tpqn + ); + SLresult (*GetTicksPerQuarterNote) ( + SLMIDITempoItf self, + SLuint32 *pTpqn + ); + SLresult (*SetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond uspqn + ); + SLresult (*GetMicrosecondsPerQuarterNote) ( + SLMIDITempoItf self, + SLmicrosecond *uspqn + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Midi Time interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_MIDITIME; + +struct SLMIDITimeItf_; +typedef const struct SLMIDITimeItf_ * const * SLMIDITimeItf; + +struct SLMIDITimeItf_ { + SLresult (*GetDuration) ( + SLMIDITimeItf self, + SLuint32 *pDuration + ); + SLresult (*SetPosition) ( + SLMIDITimeItf self, + SLuint32 position + ); + SLresult (*GetPosition) ( + SLMIDITimeItf self, + SLuint32 *pPosition + ); + SLresult (*SetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 startTick, + SLuint32 numTicks + ); + SLresult (*GetLoopPoints) ( + SLMIDITimeItf self, + SLuint32 *pStartTick, + SLuint32 *pNumTicks + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Decoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/*Audio Codec related defines*/ +#define SL_AUDIOSTREAMFORMAT_UNDEFINED ((SLuint32) 0x00000000) + +#define SL_RATECONTROLMODE_CONSTANTBITRATE ((SLuint32) 0x00000001) +#define SL_RATECONTROLMODE_VARIABLEBITRATE ((SLuint32) 0x00000002) + +#define SL_AUDIOCODEC_PCM ((SLuint32) 0x00000001) +#define SL_AUDIOCODEC_MP3 ((SLuint32) 0x00000002) +#define SL_AUDIOCODEC_AMR ((SLuint32) 0x00000003) +#define SL_AUDIOCODEC_AMRWB ((SLuint32) 0x00000004) +#define SL_AUDIOCODEC_AMRWBPLUS ((SLuint32) 0x00000005) +#define SL_AUDIOCODEC_AAC ((SLuint32) 0x00000006) +#define SL_AUDIOCODEC_WMA ((SLuint32) 0x00000007) +#define SL_AUDIOCODEC_REAL ((SLuint32) 0x00000008) +#define SL_AUDIOCODEC_VORBIS ((SLuint32) 0x00000009) + +#define SL_AUDIOPROFILE_PCM ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_MPEG1_L3 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_MPEG2_L3 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_MPEG25_L3 ((SLuint32) 0x00000003) + +#define SL_AUDIOCHANMODE_MP3_MONO ((SLuint32) 0x00000001) +#define SL_AUDIOCHANMODE_MP3_STEREO ((SLuint32) 0x00000002) +#define SL_AUDIOCHANMODE_MP3_JOINTSTEREO ((SLuint32) 0x00000003) +#define SL_AUDIOCHANMODE_MP3_DUAL ((SLuint32) 0x00000004) + +#define SL_AUDIOPROFILE_AMR ((SLuint32) 0x00000001) + +#define SL_AUDIOSTREAMFORMAT_CONFORMANCE ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_IF1 ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_IF2 ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_FSF ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_RTPPAYLOAD ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_ITU ((SLuint32) 0x00000006) + +#define SL_AUDIOPROFILE_AMRWB ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AMRWBPLUS ((SLuint32) 0x00000001) + +#define SL_AUDIOPROFILE_AAC_AAC ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_AAC_MAIN ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_AAC_LC ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_AAC_SSR ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_AAC_LTP ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_AAC_HE ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_AAC_SCALABLE ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_AAC_ERLC ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_AAC_LD ((SLuint32) 0x00000008) +#define SL_AUDIOMODE_AAC_HE_PS ((SLuint32) 0x00000009) +#define SL_AUDIOMODE_AAC_HE_MPS ((SLuint32) 0x0000000A) + +#define SL_AUDIOSTREAMFORMAT_MP2ADTS ((SLuint32) 0x00000001) +#define SL_AUDIOSTREAMFORMAT_MP4ADTS ((SLuint32) 0x00000002) +#define SL_AUDIOSTREAMFORMAT_MP4LOAS ((SLuint32) 0x00000003) +#define SL_AUDIOSTREAMFORMAT_MP4LATM ((SLuint32) 0x00000004) +#define SL_AUDIOSTREAMFORMAT_ADIF ((SLuint32) 0x00000005) +#define SL_AUDIOSTREAMFORMAT_MP4FF ((SLuint32) 0x00000006) +#define SL_AUDIOSTREAMFORMAT_RAW ((SLuint32) 0x00000007) + +#define SL_AUDIOPROFILE_WMA7 ((SLuint32) 0x00000001) +#define SL_AUDIOPROFILE_WMA8 ((SLuint32) 0x00000002) +#define SL_AUDIOPROFILE_WMA9 ((SLuint32) 0x00000003) +#define SL_AUDIOPROFILE_WMA10 ((SLuint32) 0x00000004) + +#define SL_AUDIOMODE_WMA_LEVEL1 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_WMA_LEVEL2 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_WMA_LEVEL3 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_WMA_LEVEL4 ((SLuint32) 0x00000004) +#define SL_AUDIOMODE_WMAPRO_LEVELM0 ((SLuint32) 0x00000005) +#define SL_AUDIOMODE_WMAPRO_LEVELM1 ((SLuint32) 0x00000006) +#define SL_AUDIOMODE_WMAPRO_LEVELM2 ((SLuint32) 0x00000007) +#define SL_AUDIOMODE_WMAPRO_LEVELM3 ((SLuint32) 0x00000008) + +#define SL_AUDIOPROFILE_REALAUDIO ((SLuint32) 0x00000001) + +#define SL_AUDIOMODE_REALAUDIO_G2 ((SLuint32) 0x00000001) +#define SL_AUDIOMODE_REALAUDIO_8 ((SLuint32) 0x00000002) +#define SL_AUDIOMODE_REALAUDIO_10 ((SLuint32) 0x00000003) +#define SL_AUDIOMODE_REALAUDIO_SURROUND ((SLuint32) 0x00000004) + +typedef struct SLAudioCodecDescriptor_ { + SLuint32 maxChannels; + SLuint32 minBitsPerSample; + SLuint32 maxBitsPerSample; + SLmilliHertz minSampleRate; + SLmilliHertz maxSampleRate; + SLboolean isFreqRangeContinuous; + SLmilliHertz *pSampleRatesSupported; + SLuint32 numSampleRatesSupported; + SLuint32 minBitRate; + SLuint32 maxBitRate; + SLboolean isBitrateRangeContinuous; + SLuint32 *pBitratesSupported; + SLuint32 numBitratesSupported; + SLuint32 profileSetting; + SLuint32 modeSetting; + SLuint32 streamFormat; +} SLAudioCodecDescriptor; + +SL_API extern const SLInterfaceID SL_IID_AUDIODECODERCAPABILITIES; + +struct SLAudioDecoderCapabilitiesItf_; +typedef const struct SLAudioDecoderCapabilitiesItf_ * const * SLAudioDecoderCapabilitiesItf; + +struct SLAudioDecoderCapabilitiesItf_ { + SLresult (*GetAudioDecoders) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 * pNumDecoders , + SLuint32 *pDecoderIds + ); + SLresult (*GetAudioDecoderCapabilities) ( + SLAudioDecoderCapabilitiesItf self, + SLuint32 decoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor *pDescriptor + ); +}; + + + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + +/* Structure used when setting audio encoding parameters */ + +typedef struct SLAudioEncoderSettings_ { + SLuint32 encoderId; + SLuint32 channelsIn; + SLuint32 channelsOut; + SLmilliHertz sampleRate; + SLuint32 bitRate; + SLuint32 bitsPerSample; + SLuint32 rateControl; + SLuint32 profileSetting; + SLuint32 levelSetting; + SLuint32 channelMode; + SLuint32 streamFormat; + SLuint32 encodeOptions; + SLuint32 blockAlignment; +} SLAudioEncoderSettings; + +SL_API extern const SLInterfaceID SL_IID_AUDIOENCODERCAPABILITIES; + +struct SLAudioEncoderCapabilitiesItf_; +typedef const struct SLAudioEncoderCapabilitiesItf_ * const * SLAudioEncoderCapabilitiesItf; + +struct SLAudioEncoderCapabilitiesItf_ { + SLresult (*GetAudioEncoders) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 *pNumEncoders , + SLuint32 *pEncoderIds + ); + SLresult (*GetAudioEncoderCapabilities) ( + SLAudioEncoderCapabilitiesItf self, + SLuint32 encoderId, + SLuint32 *pIndex, + SLAudioCodecDescriptor * pDescriptor + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Audio Encoder Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_AUDIOENCODER; + +struct SLAudioEncoderItf_; +typedef const struct SLAudioEncoderItf_ * const * SLAudioEncoderItf; + +struct SLAudioEncoderItf_ { + SLresult (*SetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); + SLresult (*GetEncoderSettings) ( + SLAudioEncoderItf self, + SLAudioEncoderSettings *pSettings + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Bass Boost Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_BASSBOOST; + +struct SLBassBoostItf_; +typedef const struct SLBassBoostItf_ * const * SLBassBoostItf; + +struct SLBassBoostItf_ { + SLresult (*SetEnabled)( + SLBassBoostItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLBassBoostItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLBassBoostItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLBassBoostItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLBassBoostItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Pitch Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_PITCH; + +struct SLPitchItf_; +typedef const struct SLPitchItf_ * const * SLPitchItf; + +struct SLPitchItf_ { + SLresult (*SetPitch) ( + SLPitchItf self, + SLpermille pitch + ); + SLresult (*GetPitch) ( + SLPitchItf self, + SLpermille *pPitch + ); + SLresult (*GetPitchCapabilities) ( + SLPitchItf self, + SLpermille *pMinPitch, + SLpermille *pMaxPitch + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Rate Pitch Interface */ +/* RatePitchItf is an interface for controlling the rate a sound is played */ +/* back. A change in rate will cause a change in pitch. */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_RATEPITCH; + +struct SLRatePitchItf_; +typedef const struct SLRatePitchItf_ * const * SLRatePitchItf; + +struct SLRatePitchItf_ { + SLresult (*SetRate) ( + SLRatePitchItf self, + SLpermille rate + ); + SLresult (*GetRate) ( + SLRatePitchItf self, + SLpermille *pRate + ); + SLresult (*GetRatePitchCapabilities) ( + SLRatePitchItf self, + SLpermille *pMinRate, + SLpermille *pMaxRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Virtualizer Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_VIRTUALIZER; + +struct SLVirtualizerItf_; +typedef const struct SLVirtualizerItf_ * const * SLVirtualizerItf; + +struct SLVirtualizerItf_ { + SLresult (*SetEnabled)( + SLVirtualizerItf self, + SLboolean enabled + ); + SLresult (*IsEnabled)( + SLVirtualizerItf self, + SLboolean *pEnabled + ); + SLresult (*SetStrength)( + SLVirtualizerItf self, + SLpermille strength + ); + SLresult (*GetRoundedStrength)( + SLVirtualizerItf self, + SLpermille *pStrength + ); + SLresult (*IsStrengthSupported)( + SLVirtualizerItf self, + SLboolean *pSupported + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Visualization Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_VISUALIZATION; + +struct SLVisualizationItf_; +typedef const struct SLVisualizationItf_ * const * SLVisualizationItf; + +typedef void (SLAPIENTRY *slVisualizationCallback) ( + void *pContext, + const SLuint8 waveform[], + const SLuint8 fft[], + SLmilliHertz samplerate +); + +struct SLVisualizationItf_{ + SLresult (*RegisterVisualizationCallback)( + SLVisualizationItf self, + slVisualizationCallback callback, + void *pContext, + SLmilliHertz rate + ); + SLresult (*GetMaxRate)( + SLVisualizationItf self, + SLmilliHertz* pRate + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_ENGINE; + +struct SLEngineItf_; +typedef const struct SLEngineItf_ * const * SLEngineItf; + + +struct SLEngineItf_ { + + SLresult (*CreateLEDDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateVibraDevice) ( + SLEngineItf self, + SLObjectItf * pDevice, + SLuint32 deviceID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + const SLDataSource *pAudioSrc, + const SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateAudioRecorder) ( + SLEngineItf self, + SLObjectItf * pRecorder, + const SLDataSource *pAudioSrc, + const SLDataSink *pAudioSnk, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMidiPlayer) ( + SLEngineItf self, + SLObjectItf * pPlayer, + const SLDataSource *pMIDISrc, + const SLDataSource *pBankSrc, + const SLDataSink *pAudioOutput, + const SLDataSink *pVibra, + const SLDataSink *pLEDArray, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateListener) ( + SLEngineItf self, + SLObjectItf * pListener, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*Create3DGroup) ( + SLEngineItf self, + SLObjectItf * pGroup, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateOutputMix) ( + SLEngineItf self, + SLObjectItf * pMix, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateMetadataExtractor) ( + SLEngineItf self, + SLObjectItf * pMetadataExtractor, + const SLDataSource * pDataSource, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*CreateExtensionObject) ( + SLEngineItf self, + SLObjectItf * pObject, + void * pParameters, + SLuint32 objectID, + SLuint32 numInterfaces, + const SLInterfaceID * pInterfaceIds, + const SLboolean * pInterfaceRequired + ); + SLresult (*QueryNumSupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 * pNumSupportedInterfaces + ); + SLresult (*QuerySupportedInterfaces) ( + SLEngineItf self, + SLuint32 objectID, + SLuint32 index, + SLInterfaceID * pInterfaceId + ); + SLresult (*QueryNumSupportedExtensions) ( + SLEngineItf self, + SLuint32 * pNumExtensions + ); + SLresult (*QuerySupportedExtension) ( + SLEngineItf self, + SLuint32 index, + SLchar * pExtensionName, + SLuint16 * pNameLength + ); + SLresult (*IsExtensionSupported) ( + SLEngineItf self, + const SLchar * pExtensionName, + SLboolean * pSupported + ); +}; + + +/*---------------------------------------------------------------------------*/ +/* Engine Capabilities Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_ENGINECAPABILITIES; + +struct SLEngineCapabilitiesItf_; +typedef const struct SLEngineCapabilitiesItf_ * const * SLEngineCapabilitiesItf; + +struct SLEngineCapabilitiesItf_ { + SLresult (*QuerySupportedProfiles) ( + SLEngineCapabilitiesItf self, + SLuint16 *pProfilesSupported + ); + SLresult (*QueryAvailableVoices) ( + SLEngineCapabilitiesItf self, + SLuint16 voiceType, + SLuint16 *pNumMaxVoices, + SLboolean *pIsAbsoluteMax, + SLuint16 *pNumFreeVoices + ); + SLresult (*QueryNumberOfMIDISynthesizers) ( + SLEngineCapabilitiesItf self, + SLuint16 *pNumMIDIsynthesizers + ); + SLresult (*QueryAPIVersion) ( + SLEngineCapabilitiesItf self, + SLuint16 *pMajor, + SLuint16 *pMinor, + SLuint16 *pStep + ); + SLresult (*QueryLEDCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pLEDDeviceID, + SLLEDDescriptor *pDescriptor + ); + SLresult (*QueryVibraCapabilities) ( + SLEngineCapabilitiesItf self, + SLuint32 *pIndex, + SLuint32 *pVibraDeviceID, + SLVibraDescriptor *pDescriptor + ); + SLresult (*IsThreadSafe) ( + SLEngineCapabilitiesItf self, + SLboolean *pIsThreadSafe + ); +}; + +/*---------------------------------------------------------------------------*/ +/* Thread Sync Interface */ +/* --------------------------------------------------------------------------*/ + + +SL_API extern const SLInterfaceID SL_IID_THREADSYNC; + +struct SLThreadSyncItf_; +typedef const struct SLThreadSyncItf_ * const * SLThreadSyncItf; + + +struct SLThreadSyncItf_ { + SLresult (*EnterCriticalSection) ( + SLThreadSyncItf self + ); + SLresult (*ExitCriticalSection) ( + SLThreadSyncItf self + ); +}; + + +/*****************************************************************************/ +/* SL engine constructor */ +/*****************************************************************************/ + +#define SL_ENGINEOPTION_THREADSAFE ((SLuint32) 0x00000001) +#define SL_ENGINEOPTION_LOSSOFCONTROL ((SLuint32) 0x00000002) +#define SL_ENGINEOPTION_MAJORVERSION ((SLuint32) 0x00000003) +#define SL_ENGINEOPTION_MINORVERSION ((SLuint32) 0x00000004) +#define SL_ENGINEOPTION_STEPVERSION ((SLuint32) 0x00000005) + + +typedef struct SLEngineOption_ { + SLuint32 feature; + SLuint32 data; +} SLEngineOption; + + +SL_API SLresult SLAPIENTRY slCreateEngine( + SLObjectItf *pEngine, + SLuint32 numOptions, + const SLEngineOption *pEngineOptions, + SLuint32 numInterfaces, + const SLInterfaceID *pInterfaceIds, + const SLboolean * pInterfaceRequired +); + +SL_API SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces( + SLuint32 * pNumSupportedInterfaces +); + +SL_API SLresult SLAPIENTRY slQuerySupportedEngineInterfaces( + SLuint32 index, + SLInterfaceID * pInterfaceId +); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* OPENSL_ES_H_ */ diff --git a/third_party/openSLES/api/1.1/OpenSLES_Platform.h b/third_party/openSLES/api/1.1/OpenSLES_Platform.h index 1a54e74da6a56722bee06d0169347acf8e405b8a..2ffb44f1fdf2d843d875b30679983d3988d3e771 100644 --- a/third_party/openSLES/api/1.1/OpenSLES_Platform.h +++ b/third_party/openSLES/api/1.1/OpenSLES_Platform.h @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2007-2011 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and /or associated documentation files (the "Materials "), to - * deal in the Materials without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Materials, and to permit persons to whom the Materials are - * furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE - * MATERIALS. - * - * OpenSLES_Platform.h - OpenSL ES version 1.1 - * - */ - -/****************************************************************************/ -/* NOTE: This file contains definitions for the base types and the */ -/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ -/* the correct definitions specific to the platform being used. */ -/****************************************************************************/ - -#ifndef _OPENSLES_PLATFORM_H_ -#define _OPENSLES_PLATFORM_H_ - -typedef char sl_char_t; -typedef unsigned char sl_uint8_t; -typedef signed char sl_int8_t; -typedef unsigned short sl_uint16_t; -typedef signed short sl_int16_t; -typedef unsigned long sl_uint32_t; -typedef signed long sl_int32_t; -typedef float sl_float32_t; -typedef double sl_float64_t; - -/****************************************************************************/ -/* NOTE: SL_BYTEORDER_NATIVEBIGENDIAN will cause SL_BYTEORDER_NATIVE to */ -/* mirror SL_BYTEORDER_BIGENDIAN, otherwise it will default to */ -/* SL_BYTEORDER_LITTLEENDIAN. */ -/****************************************************************************/ -//#define SL_BYTEORDER_NATIVEBIGENDIAN 1 - -/** SLAPIENTRY is a system-dependent API function prototype declaration macro. -* -* Example: -* #ifdef WIN32 -* # define SLAPIENTRY __stdcall -* #endif -*/ -#ifndef SLAPIENTRY -#define SLAPIENTRY /* override per-platform */ -#endif - -/** The SL_API is a platform-specific macro used -* to declare OPENSL ES function prototypes. It is modified to meet the -* requirements for a particular platform -* -* Example: -* #ifdef __SYMBIAN32__ -* # define SL_API __declspec(dllimport) -* #endif -*/ -#ifndef SL_API -#define SL_API /* override per-platform */ -#endif - -#endif /* _OPENSLES_PLATFORM_H_ */ +/* + * Copyright (c) 2007-2011 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and /or associated documentation files (the "Materials "), to + * deal in the Materials without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Materials, and to permit persons to whom the Materials are + * furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS IN THE + * MATERIALS. + * + * OpenSLES_Platform.h - OpenSL ES version 1.1 + * + */ + +/****************************************************************************/ +/* NOTE: This file contains definitions for the base types and the */ +/* SLAPIENTRY macro. This file **WILL NEED TO BE EDITED** to provide */ +/* the correct definitions specific to the platform being used. */ +/****************************************************************************/ + +#ifndef _OPENSLES_PLATFORM_H_ +#define _OPENSLES_PLATFORM_H_ + +typedef char sl_char_t; +typedef unsigned char sl_uint8_t; +typedef signed char sl_int8_t; +typedef unsigned short sl_uint16_t; +typedef signed short sl_int16_t; +typedef unsigned long sl_uint32_t; +typedef signed long sl_int32_t; +typedef float sl_float32_t; +typedef double sl_float64_t; + +/****************************************************************************/ +/* NOTE: SL_BYTEORDER_NATIVEBIGENDIAN will cause SL_BYTEORDER_NATIVE to */ +/* mirror SL_BYTEORDER_BIGENDIAN, otherwise it will default to */ +/* SL_BYTEORDER_LITTLEENDIAN. */ +/****************************************************************************/ +//#define SL_BYTEORDER_NATIVEBIGENDIAN 1 + +/** SLAPIENTRY is a system-dependent API function prototype declaration macro. +* +* Example: +* #ifdef WIN32 +* # define SLAPIENTRY __stdcall +* #endif +*/ +#ifndef SLAPIENTRY +#define SLAPIENTRY /* override per-platform */ +#endif + +/** The SL_API is a platform-specific macro used +* to declare OPENSL ES function prototypes. It is modified to meet the +* requirements for a particular platform +* +* Example: +* #ifdef __SYMBIAN32__ +* # define SL_API __declspec(dllimport) +* #endif +*/ +#ifndef SL_API +#define SL_API /* override per-platform */ +#endif + +#endif /* _OPENSLES_PLATFORM_H_ */ diff --git a/third_party/openSLES/api/1.1/README.txt b/third_party/openSLES/api/1.1/README.txt index cb1c1b9f43a18aa796ffeee773862a22da8df0fb..6217365ac11806cf3209ff321e75048467ebdeff 100644 --- a/third_party/openSLES/api/1.1/README.txt +++ b/third_party/openSLES/api/1.1/README.txt @@ -1,5 +1,5 @@ -When building applications using the OpenSL-ES API you should compile -and link the OpenSLES_IID.c file into your project. This file -contains unique interface IDs for all OpenSL-ES API interfaces. -These IDs have have been automatically generated. Application -developers should not edit these interface IDs. +When building applications using the OpenSL-ES API you should compile +and link the OpenSLES_IID.c file into your project. This file +contains unique interface IDs for all OpenSL-ES API interfaces. +These IDs have have been automatically generated. Application +developers should not edit these interface IDs. diff --git a/third_party/openSLES/openSLES.ndk.json b/third_party/openSLES/openSLES.ndk.json index 89a966489c3ac88507e0d21aa3d39337806e2f88..13259586ae802f02d81989818582b1f4d5a71278 100644 --- a/third_party/openSLES/openSLES.ndk.json +++ b/third_party/openSLES/openSLES.ndk.json @@ -1,50 +1,50 @@ -[ - {"name":"SL_IID_NULL"}, - {"name":"SL_IID_OBJECT"}, - {"name":"SL_IID_AUDIOIODEVICECAPABILITIES"}, - {"name":"SL_IID_LED"}, - {"name":"SL_IID_VIBRA"}, - {"name":"SL_IID_METADATAEXTRACTION"}, - {"name":"SL_IID_METADATATRAVERSAL"}, - {"name":"SL_IID_DYNAMICSOURCE"}, - {"name":"SL_IID_OUTPUTMIX"}, - {"name":"SL_IID_PLAY"}, - {"name":"SL_IID_PREFETCHSTATUS"}, - {"name":"SL_IID_PLAYBACKRATE"}, - {"name":"SL_IID_SEEK"}, - {"name":"SL_IID_RECORD"}, - {"name":"SL_IID_EQUALIZER"}, - {"name":"SL_IID_VOLUME"}, - {"name":"SL_IID_DEVICEVOLUME"}, - {"name":"SL_IID_BUFFERQUEUE"}, - {"name":"SL_IID_OH_BUFFERQUEUE"}, - {"name":"SL_IID_PRESETREVERB"}, - {"name":"SL_IID_ENVIRONMENTALREVERB"}, - {"name":"SL_IID_EFFECTSEND"}, - {"name":"SL_IID_3DGROUPING"}, - {"name":"SL_IID_3DCOMMIT"}, - {"name":"SL_IID_3DLOCATION"}, - {"name":"SL_IID_3DDOPPLER"}, - {"name":"SL_IID_3DSOURCE"}, - {"name":"SL_IID_3DMACROSCOPIC"}, - {"name":"SL_IID_MUTESOLO"}, - {"name":"SL_IID_DYNAMICINTERFACEMANAGEMENT"}, - {"name":"SL_IID_MIDIMESSAGE"}, - {"name":"SL_IID_MIDIMUTESOLO"}, - {"name":"SL_IID_MIDITEMPO"}, - {"name":"SL_IID_MIDITIME"}, - {"name":"SL_IID_AUDIODECODERCAPABILITIES"}, - {"name":"SL_IID_AUDIOENCODERCAPABILITIES"}, - {"name":"SL_IID_AUDIOENCODER"}, - {"name":"SL_IID_BASSBOOST"}, - {"name":"SL_IID_PITCH"}, - {"name":"SL_IID_RATEPITCH"}, - {"name":"SL_IID_VIRTUALIZER"}, - {"name":"SL_IID_VISUALIZATION"}, - {"name":"SL_IID_ENGINE"}, - {"name":"SL_IID_ENGINECAPABILITIES"}, - {"name":"SL_IID_THREADSYNC"}, - {"name":"slCreateEngine"}, - {"name":"slQueryNumSupportedEngineInterfaces"}, - {"name":"slQuerySupportedEngineInterfaces"} -] +[ + {"name":"SL_IID_NULL"}, + {"name":"SL_IID_OBJECT"}, + {"name":"SL_IID_AUDIOIODEVICECAPABILITIES"}, + {"name":"SL_IID_LED"}, + {"name":"SL_IID_VIBRA"}, + {"name":"SL_IID_METADATAEXTRACTION"}, + {"name":"SL_IID_METADATATRAVERSAL"}, + {"name":"SL_IID_DYNAMICSOURCE"}, + {"name":"SL_IID_OUTPUTMIX"}, + {"name":"SL_IID_PLAY"}, + {"name":"SL_IID_PREFETCHSTATUS"}, + {"name":"SL_IID_PLAYBACKRATE"}, + {"name":"SL_IID_SEEK"}, + {"name":"SL_IID_RECORD"}, + {"name":"SL_IID_EQUALIZER"}, + {"name":"SL_IID_VOLUME"}, + {"name":"SL_IID_DEVICEVOLUME"}, + {"name":"SL_IID_BUFFERQUEUE"}, + {"name":"SL_IID_OH_BUFFERQUEUE"}, + {"name":"SL_IID_PRESETREVERB"}, + {"name":"SL_IID_ENVIRONMENTALREVERB"}, + {"name":"SL_IID_EFFECTSEND"}, + {"name":"SL_IID_3DGROUPING"}, + {"name":"SL_IID_3DCOMMIT"}, + {"name":"SL_IID_3DLOCATION"}, + {"name":"SL_IID_3DDOPPLER"}, + {"name":"SL_IID_3DSOURCE"}, + {"name":"SL_IID_3DMACROSCOPIC"}, + {"name":"SL_IID_MUTESOLO"}, + {"name":"SL_IID_DYNAMICINTERFACEMANAGEMENT"}, + {"name":"SL_IID_MIDIMESSAGE"}, + {"name":"SL_IID_MIDIMUTESOLO"}, + {"name":"SL_IID_MIDITEMPO"}, + {"name":"SL_IID_MIDITIME"}, + {"name":"SL_IID_AUDIODECODERCAPABILITIES"}, + {"name":"SL_IID_AUDIOENCODERCAPABILITIES"}, + {"name":"SL_IID_AUDIOENCODER"}, + {"name":"SL_IID_BASSBOOST"}, + {"name":"SL_IID_PITCH"}, + {"name":"SL_IID_RATEPITCH"}, + {"name":"SL_IID_VIRTUALIZER"}, + {"name":"SL_IID_VISUALIZATION"}, + {"name":"SL_IID_ENGINE"}, + {"name":"SL_IID_ENGINECAPABILITIES"}, + {"name":"SL_IID_THREADSYNC"}, + {"name":"slCreateEngine"}, + {"name":"slQueryNumSupportedEngineInterfaces"}, + {"name":"slQuerySupportedEngineInterfaces"} +] diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index 7396a6a12a7d3ef4f239309c0ccb673e09624c77..5b2ba9b3911b346bda6fb9d31facd4c25ca830bd 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn @@ -1,116 +1,116 @@ -# Copyright (c) 2019-2022 Huawei Device Co., Ltd. All rights reserved. - -import("//build/ohos.gni") -import("//build/ohos/ndk/ndk.gni") - -config("zlib_config") { - cflags = [ - "-Wno-incompatible-pointer-types", - "-Werror", - "-Wno-strict-prototypes", - "-Wimplicit-function-declaration", - ] -} - -config("zlib_public_config") { - include_dirs = [ "." ] -} - -ohos_static_library("libz") { - sources = [ - "adler32.c", - "compress.c", - "contrib/minizip/ioapi.c", - "contrib/minizip/unzip.c", - "contrib/minizip/zip.c", - "crc32.c", - "crc32.h", - "deflate.c", - "deflate.h", - "gzclose.c", - "gzguts.h", - "gzlib.c", - "gzread.c", - "gzwrite.c", - "infback.c", - "inffast.c", - "inffast.h", - "inffixed.h", - "inflate.c", - "inflate.h", - "inftrees.c", - "inftrees.h", - "trees.c", - "trees.h", - "uncompr.c", - "zconf.h", - "zlib.h", - "zutil.c", - "zutil.h", - ] - configs = [ ":zlib_config" ] - public_configs = [ ":zlib_public_config" ] - - part_name = "zlib" - subsystem_name = "thirdparty" -} - -ohos_shared_library("shared_libz") { - sources = [ - "adler32.c", - "compress.c", - "contrib/minizip/ioapi.c", - "contrib/minizip/unzip.c", - "contrib/minizip/zip.c", - "crc32.c", - "crc32.h", - "deflate.c", - "deflate.h", - "gzclose.c", - "gzguts.h", - "gzlib.c", - "gzread.c", - "gzwrite.c", - "infback.c", - "inffast.c", - "inffast.h", - "inffixed.h", - "inflate.c", - "inflate.h", - "inftrees.c", - "inftrees.h", - "trees.c", - "trees.h", - "uncompr.c", - "zconf.h", - "zlib.h", - "zutil.c", - "zutil.h", - ] - configs = [ ":zlib_config" ] - public_configs = [ ":zlib_public_config" ] - - install_images = [ - "system", - "updater", - ] - - symlink_target_name = [ "libz.so" ] - - innerapi_tags = [ "platformsdk" ] - part_name = "zlib" - subsystem_name = "thirdparty" -} - -ohos_ndk_headers("zlib_header") { - sources = [ - "./zconf.h", - "./zlib.h", - ] -} - -ohos_ndk_library("libz_ndk") { - output_name = "z" - ndk_description_file = "./zlib.ndk.json" - output_extension = "so" -} +# Copyright (c) 2019-2022 Huawei Device Co., Ltd. All rights reserved. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +config("zlib_config") { + cflags = [ + "-Wno-incompatible-pointer-types", + "-Werror", + "-Wno-strict-prototypes", + "-Wimplicit-function-declaration", + ] +} + +config("zlib_public_config") { + include_dirs = [ "." ] +} + +ohos_static_library("libz") { + sources = [ + "adler32.c", + "compress.c", + "contrib/minizip/ioapi.c", + "contrib/minizip/unzip.c", + "contrib/minizip/zip.c", + "crc32.c", + "crc32.h", + "deflate.c", + "deflate.h", + "gzclose.c", + "gzguts.h", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inffast.h", + "inffixed.h", + "inflate.c", + "inflate.h", + "inftrees.c", + "inftrees.h", + "trees.c", + "trees.h", + "uncompr.c", + "zconf.h", + "zlib.h", + "zutil.c", + "zutil.h", + ] + configs = [ ":zlib_config" ] + public_configs = [ ":zlib_public_config" ] + + part_name = "zlib" + subsystem_name = "thirdparty" +} + +ohos_shared_library("shared_libz") { + sources = [ + "adler32.c", + "compress.c", + "contrib/minizip/ioapi.c", + "contrib/minizip/unzip.c", + "contrib/minizip/zip.c", + "crc32.c", + "crc32.h", + "deflate.c", + "deflate.h", + "gzclose.c", + "gzguts.h", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inffast.h", + "inffixed.h", + "inflate.c", + "inflate.h", + "inftrees.c", + "inftrees.h", + "trees.c", + "trees.h", + "uncompr.c", + "zconf.h", + "zlib.h", + "zutil.c", + "zutil.h", + ] + configs = [ ":zlib_config" ] + public_configs = [ ":zlib_public_config" ] + + install_images = [ + "system", + "updater", + ] + + symlink_target_name = [ "libz.so" ] + + innerapi_tags = [ "platformsdk" ] + part_name = "zlib" + subsystem_name = "thirdparty" +} + +ohos_ndk_headers("zlib_header") { + sources = [ + "./zconf.h", + "./zlib.h", + ] +} + +ohos_ndk_library("libz_ndk") { + output_name = "z" + ndk_description_file = "./zlib.ndk.json" + output_extension = "so" +} diff --git a/third_party/zlib/zconf.h b/third_party/zlib/zconf.h index 5e1d68a004e9744cb35f9d5a2fe94fd4dbcb7f76..44d5bef9880375faec16a85b58cfd0fcb5ecabb0 100644 --- a/third_party/zlib/zconf.h +++ b/third_party/zlib/zconf.h @@ -1,534 +1,534 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) +# define Z_HAVE_UNISTD_H +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/third_party/zlib/zlib.h b/third_party/zlib/zlib.h index 4a98e38bf34c82def9f9bf77ced2a618899f8d11..bade13aee205e357d391bfdb5eee96b3edbce887 100644 --- a/third_party/zlib/zlib.h +++ b/third_party/zlib/zlib.h @@ -1,1935 +1,1935 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.12, March 11th, 2022 - - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.12" -#define ZLIB_VERNUM 0x12c0 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 12 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip and raw deflate streams in - memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in the case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte will go here */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text - for deflate, or the decoding state for inflate */ - uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. In that case, zlib is thread-safe. When zalloc and zfree are - Z_NULL on entry to the initialization function, they are set to internal - routines that use the standard library functions malloc() and free(). - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use by the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field for deflate() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary. Some output may be provided even if - flush is zero. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. See deflatePending(), - which can be used if desired to determine whether or not there is more ouput - in that case. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed - codes block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this - function must be called again with Z_FINISH and more output space (updated - avail_out) but no more input data, until it returns with Z_STREAM_END or an - error. After deflate has returned Z_STREAM_END, the only possible operations - on the stream are deflateReset or deflateEnd. - - Z_FINISH can be used in the first deflate call after deflateInit if all the - compression is to be done in a single step. In order to complete in one - call, avail_out must be at least the value returned by deflateBound (see - below). Then deflate is guaranteed to return Z_STREAM_END. If not enough - output space is provided, deflate will not return Z_STREAM_END, and it must - be called again as described above. - - deflate() sets strm->adler to the Adler-32 checksum of all input read - so far (that is, total_in bytes). If a gzip stream is being generated, then - strm->adler will be the CRC-32 checksum of the input read so far. (See - deflateInit2 below.) - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is - considered binary. This field is only for information purposes and does not - affect the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL or the state was inadvertently written over - by the application), or Z_BUF_ERROR if no progress is possible (for example - avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and - deflate() can be called again with more input and more output space to - continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. In the current version of inflate, the provided input is not - read or consumed. The allocation of a sliding window will be deferred to - the first call of inflate (if the decompression does not complete on the - first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression. - Actual decompression will be done by inflate(). So next_in, and avail_in, - next_out, and avail_out are unused and unchanged. The current - implementation of inflateInit() does not process any header information -- - that is deferred until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), then next_in and avail_in are updated - accordingly, and processing will resume at this point for the next call of - inflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. If the - caller of inflate() does not provide both available input and available - output space, it is possible that there will be no progress made. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - To assist in this, on return inflate() always sets strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed Adler-32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained unless inflateGetHeader() is used. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - produced so far. The CRC-32 is checked against the gzip trailer, as is the - uncompressed length, modulo 2^32. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value, in which case strm->msg points to a string with a more specific - error), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL, or the state was inadvertently written over - by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR - if no progress was possible or if there was not enough room in the output - buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is to be attempted. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state - was inconsistent. -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields zalloc, zfree and opaque must be initialized before by the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - For the current implementation of deflate(), a windowBits value of 8 (a - window size of 256 bytes) is not supported. As a result, a request for 8 - will result in 9 (a 512-byte window). In that case, providing 8 to - inflateInit2() will result in an error when the zlib header with 9 is - checked against the initialization of inflate(). The remedy is to not use 8 - with deflateInit2() with this initialization, or at least in that case use 9 - with inflateInit2(). - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute a check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to the appropriate value, - if the operating system was determined at compile time. If a gzip stream is - being written, strm->adler is a CRC-32 instead of an Adler-32. - - For raw deflate or gzip encoding, a request for a 256-byte window is - rejected as invalid, since only the zlib header provides a means of - transmitting the window size to the decompressor. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the Adler-32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler-32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - Adler-32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by deflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If deflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - deflateGetDictionary() may return a length less than the window size, even - when more than the window size in input has been provided. It may return up - to 258 bytes less in that case, due to how zlib's implementation of deflate - manages the sliding window and lookahead for matches, where matches can be - up to 258 bytes long. If the application needs the last window-size bytes of - input, then that would need to be saved by the application outside of zlib. - - deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, but - does not free and reallocate the internal compression state. The stream - will leave the compression level and any other attributes that may have been - set unchanged. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2(). This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression approach (which is a function of the level) or the - strategy is changed, and if there have been any deflate() calls since the - state was initialized or reset, then the input available so far is - compressed with the old level and strategy using deflate(strm, Z_BLOCK). - There are three approaches for the compression levels 0, 1..3, and 4..9 - respectively. The new level and strategy will take effect at the next call - of deflate(). - - If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does - not have enough output space to complete, then the parameter change will not - take effect. In this case, deflateParams() can be called again with the - same parameters and more output space to try again. - - In order to assure a change in the parameters on the first try, the - deflate stream should be flushed using deflate() with Z_BLOCK or other flush - request until strm.avail_out is not zero, before calling deflateParams(). - Then no more input data should be provided before the deflateParams() call. - If this is done, the old level and strategy will be applied to the data - compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). - - deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream - state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if - there was not enough output space to complete the compression of the - available input data before a change in the strategy or approach. Note that - in the case of a Z_BUF_ERROR, the parameters are not changed. A return - value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be - retried with more output space. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an Adler-32 or a CRC-32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will *not* automatically decode concatenated gzip members. - inflate() will return Z_STREAM_END at the end of the gzip member. The state - would need to be reset to continue decoding a subsequent gzip member. This - *must* be done if there is more data after a gzip member, in order for the - decompression to be compliant with the gzip standard (RFC 1952). - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler-32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler-32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. If the window size is changed, then the - memory allocated for the window is freed, and the window will be reallocated - by inflate() if needed. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above, or -65536 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the default - behavior of inflate(), which expects a zlib header and trailer around the - deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero -- buf is ignored in that - case -- and inflateBack() will return a buffer error. inflateBack() will - call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. - out() should return zero on success, or non-zero on failure. If out() - returns non-zero, inflateBack() will return with an error. Neither in() nor - out() are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: ZLIB_DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. compress() is equivalent to compress2() with a level - parameter of Z_DEFAULT_COMPRESSION. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed data. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); -/* - Same as uncompress, except that sourceLen is a pointer, where the - length of the source is *sourceLen. On return, *sourceLen is the number of - source bytes consumed. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Open the gzip (.gz) file at path for reading and decompressing, or - compressing and writing. The mode parameter is as in fopen ("rb" or "wb") - but can also include a compression level ("wb9") or a strategy: 'f' for - filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", - 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression - as in "wb9F". (See the description of deflateInit2 for more information - about the strategy parameter.) 'T' will request transparent writing or - appending with no compression and not using the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - Associate a gzFile with the file descriptor fd. File descriptors are - obtained from calls like open, dup, creat, pipe or fileno (if the file has - been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions for file to - size. The default buffer size is 8192 bytes. This function must be called - after gzopen() or gzdopen(), and before any other calls that read or write - the file. The buffer memory allocation is always deferred to the first read - or write. Three times that size in buffer space is allocated. A larger - buffer size of, for example, 64K or 128K bytes will noticeably increase the - speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level and strategy for file. See the - description of deflateInit2 for the meaning of these parameters. Previously - provided data is flushed before applying the parameter changes. - - gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not - opened for writing, Z_ERRNO if there is an error writing the flushed data, - or Z_MEM_ERROR if there is a memory allocation error. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Read and decompress up to len uncompressed bytes from file into buf. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. If len is too large to fit in an int, - then nothing is read, -1 is returned, and the error state is set to - Z_STREAM_ERROR. -*/ - -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); -/* - Read and decompress up to nitems items of size size from file into buf, - otherwise operating as gzread() does. This duplicates the interface of - stdio's fread(), with size_t request and return types. If the library - defines size_t, then z_size_t is identical to size_t. If not, then z_size_t - is an unsigned integer type that can contain a pointer. - - gzfread() returns the number of full items read of size size, or zero if - the end of the file was reached and a full item could not be read, or if - there was an error. gzerror() must be consulted if zero is returned in - order to determine if there was an error. If the multiplication of size and - nitems overflows, i.e. the product does not fit in a z_size_t, then nothing - is read, zero is returned, and the error state is set to Z_STREAM_ERROR. - - In the event that the end of file is reached and only a partial item is - available at the end, i.e. the remaining uncompressed data length is not a - multiple of size, then the final partial item is nevetheless read into buf - and the end-of-file flag is set. The length of the partial item read is not - provided, but could be inferred from the result of gztell(). This behavior - is the same as the behavior of fread() implementations in common libraries, - but it prevents the direct use of gzfread() to read a concurrently written - file, reseting and retrying on end-of-file, when size is not 1. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); -/* - Compress and write the len uncompressed bytes at buf to file. gzwrite - returns the number of uncompressed bytes written or 0 in case of error. -*/ - -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); -/* - Compress and write nitems items of size size from buf to file, duplicating - the interface of stdio's fwrite(), with size_t request and return types. If - the library defines size_t, then z_size_t is identical to size_t. If not, - then z_size_t is an unsigned integer type that can contain a pointer. - - gzfwrite() returns the number of full items written of size size, or zero - if there was an error. If the multiplication of size and nitems overflows, - i.e. the product does not fit in a z_size_t, then nothing is written, zero - is returned, and the error state is set to Z_STREAM_ERROR. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Convert, format, compress, and write the arguments (...) to file under - control of the string format, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or a negative zlib error code in case - of error. The number of uncompressed bytes written is limited to 8191, or - one less than the buffer size given to gzbuffer(). The caller should assure - that this limit is not exceeded. If it is exceeded, then gzprintf() will - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf(), - because the secure snprintf() or vsnprintf() functions were not available. - This can be determined using zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Compress and write the given null-terminated string s to file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Read and decompress bytes from file into buf, until len-1 characters are - read, or until a newline character is read and transferred to buf, or an - end-of-file condition is encountered. If any characters are read or if len - is one, the string is terminated with a null character. If no characters - are read due to an end-of-file or len is less than one, then the buffer is - left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Compress and write c, converted to an unsigned char, into file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Read and decompress one byte from file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push c back onto the stream for file to be read as the first character on - the next read. At least one character of push-back is always allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flush all pending output to file. The parameter flush is as in the - deflate() function. The return value is the zlib error number (see function - gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatenated gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Set the starting position to offset relative to whence for the next gzread - or gzwrite on file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewind file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Return the starting position for the next gzread or gzwrite on file. - This position represents a number of bytes in the uncompressed data stream, - and is zero when starting, even if appending or reading a gzip stream from - the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Return the current compressed (actual) read or write offset of file. This - offset includes the count of bytes that precede the gzip stream, for example - when appending or when using gzdopen() for reading. When reading, the - offset does not include as yet unused buffered input. This information can - be used for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Return true (1) if the end-of-file indicator for file has been set while - reading, false (0) otherwise. Note that the end-of-file indicator is set - only if the read tried to go past the end of the input, but came up short. - Therefore, just like feof(), gzeof() may return false even if there is no - more data to read, in the event that the last read request was for the exact - number of bytes remaining in the input file. This will happen if the input - file size is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Return true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flush all pending output for file, if necessary, close file and - deallocate the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Return the error message for the last error which occurred on file. - errnum is set to zlib error number. If an error occurred in the file system - and not in the compression library, errnum is set to Z_ERRNO and the - application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clear the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. An Adler-32 value is in the range of a 32-bit - unsigned integer. If buf is Z_NULL, this function returns the required - initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); -/* - Same as adler32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. - If buf is Z_NULL, this function returns the required initial value for the - crc. Pre- and post-conditioning (one's complement) is performed within this - function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, - z_size_t len)); -/* - Same as crc32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); - - Return the operator corresponding to length len2, to be used with - crc32_combine_op(). -*/ - -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); -/* - Give the same result as crc32_combine(), using op in place of len2. op is - is generated from len2 by crc32_combine_gen(). This will be faster than - crc32_combine() if the generated op is used more than once. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#ifdef Z_PREFIX_SET -# define z_deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define z_inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#else -# define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#endif - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# define z_crc32_combine_gen z_crc32_combine_gen64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# define crc32_combine_gen crc32_combine_gen64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); - -#endif /* !Z_SOLO */ - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.12, March 11th, 2022 + + Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 + (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.12" +#define ZLIB_VERNUM 0x12c0 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 12 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip and raw deflate streams in + memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in the case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + z_const Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total number of input bytes read so far */ + + Bytef *next_out; /* next output byte will go here */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total number of bytes output so far */ + + z_const char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text + for deflate, or the decoding state for inflate */ + uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. In that case, zlib is thread-safe. When zalloc and zfree are + Z_NULL on entry to the initialization function, they are set to internal + routines that use the standard library functions malloc() and free(). + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use by the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field for deflate() */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary. Some output may be provided even if + flush is zero. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. See deflatePending(), + which can be used if desired to determine whether or not there is more ouput + in that case. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed + codes block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this + function must be called again with Z_FINISH and more output space (updated + avail_out) but no more input data, until it returns with Z_STREAM_END or an + error. After deflate has returned Z_STREAM_END, the only possible operations + on the stream are deflateReset or deflateEnd. + + Z_FINISH can be used in the first deflate call after deflateInit if all the + compression is to be done in a single step. In order to complete in one + call, avail_out must be at least the value returned by deflateBound (see + below). Then deflate is guaranteed to return Z_STREAM_END. If not enough + output space is provided, deflate will not return Z_STREAM_END, and it must + be called again as described above. + + deflate() sets strm->adler to the Adler-32 checksum of all input read + so far (that is, total_in bytes). If a gzip stream is being generated, then + strm->adler will be the CRC-32 checksum of the input read so far. (See + deflateInit2 below.) + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is + considered binary. This field is only for information purposes and does not + affect the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL or the state was inadvertently written over + by the application), or Z_BUF_ERROR if no progress is possible (for example + avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and + deflate() can be called again with more input and more output space to + continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. In the current version of inflate, the provided input is not + read or consumed. The allocation of a sliding window will be deferred to + the first call of inflate (if the decompression does not complete on the + first call). If zalloc and zfree are set to Z_NULL, inflateInit updates + them to use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression. + Actual decompression will be done by inflate(). So next_in, and avail_in, + next_out, and avail_out are unused and unchanged. The current + implementation of inflateInit() does not process any header information -- + that is deferred until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), then next_in and avail_in are updated + accordingly, and processing will resume at this point for the next call of + inflate(). + + - Generate more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. If the + caller of inflate() does not provide both available input and available + output space, it is possible that there will be no progress made. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + To assist in this, on return inflate() always sets strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all of the uncompressed data for the + operation to complete. (The size of the uncompressed data may have been + saved by the compressor for this purpose.) The use of Z_FINISH is not + required to perform an inflation in one step. However it may be used to + inform inflate that a faster approach can be used for the single inflate() + call. Z_FINISH also informs inflate to not maintain a sliding window if the + stream completes, which reduces inflate's memory footprint. If the stream + does not complete, either because not all of the stream is provided or not + enough output space is provided, then a sliding window will be allocated and + inflate() can be called again to continue the operation as if Z_NO_FLUSH had + been used. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the effects of the flush parameter in this implementation are + on the return value of inflate() as noted below, when inflate() returns early + when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of + memory for a sliding window when Z_FINISH is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the Adler-32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the Adler-32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed Adler-32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained unless inflateGetHeader() is used. When processing + gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output + produced so far. The CRC-32 is checked against the gzip trailer, as is the + uncompressed length, modulo 2^32. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value, in which case strm->msg points to a string with a more specific + error), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL, or the state was inadvertently written over + by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR + if no progress was possible or if there was not enough room in the output + buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is to be attempted. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state + was inconsistent. +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields zalloc, zfree and opaque must be initialized before by the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + For the current implementation of deflate(), a windowBits value of 8 (a + window size of 256 bytes) is not supported. As a result, a request for 8 + will result in 9 (a 512-byte window). In that case, providing 8 to + inflateInit2() will result in an error when the zlib header with 9 is + checked against the initialization of inflate(). The remedy is to not use 8 + with deflateInit2() with this initialization, or at least in that case use 9 + with inflateInit2(). + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute a check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to the appropriate value, + if the operating system was determined at compile time. If a gzip stream is + being written, strm->adler is a CRC-32 instead of an Adler-32. + + For raw deflate or gzip encoding, a request for a 256-byte window is + rejected as invalid, since only the zlib header provides a means of + transmitting the window size to the decompressor. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. When using the zlib format, this + function must be called immediately after deflateInit, deflateInit2 or + deflateReset, and before any call of deflate. When doing raw deflate, this + function must be called either before any call of deflate, or immediately + after the completion of a deflate block, i.e. after all input has been + consumed and all output has been delivered when using any of the flush + options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The + compressor and decompressor must use exactly the same dictionary (see + inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the Adler-32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler-32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + Adler-32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if not at a block boundary for raw deflate). deflateSetDictionary does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by deflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If deflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + deflateGetDictionary() may return a length less than the window size, even + when more than the window size in input has been provided. It may return up + to 258 bytes less in that case, due to how zlib's implementation of deflate + manages the sliding window and lookahead for matches, where matches can be + up to 258 bytes long. If the application needs the last window-size bytes of + input, then that would need to be saved by the application outside of zlib. + + deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, but + does not free and reallocate the internal compression state. The stream + will leave the compression level and any other attributes that may have been + set unchanged. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2(). This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression approach (which is a function of the level) or the + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). + + If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does + not have enough output space to complete, then the parameter change will not + take effect. In this case, deflateParams() can be called again with the + same parameters and more output space to try again. + + In order to assure a change in the parameters on the first try, the + deflate stream should be flushed using deflate() with Z_BLOCK or other flush + request until strm.avail_out is not zero, before calling deflateParams(). + Then no more input data should be provided before the deflateParams() call. + If this is done, the old level and strategy will be applied to the data + compressed before deflateParams(), and the new level and strategy will be + applied to the the data compressed after deflateParams(). + + deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream + state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if + there was not enough output space to complete the compression of the + available input data before a change in the strategy or approach. Note that + in the case of a Z_BUF_ERROR, the parameters are not changed. A return + value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be + retried with more output space. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). If that first deflate() call is provided the + sourceLen input bytes, an output buffer allocated to the size returned by + deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed + to return Z_STREAM_END. Note that it is possible for the compressed size to + be larger than the value returned by deflateBound() if flush options other + than Z_FINISH or Z_NO_FLUSH are used. +*/ + +ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, + unsigned *pending, + int *bits)); +/* + deflatePending() returns the number of bytes and bits of output that have + been generated, but not yet provided in the available output. The bytes not + provided would be due to the available output space having being consumed. + The number of bits of output not provided are between 0 and 7, where they + await more bits to join them in order to fill out a full byte. If pending + or bits are Z_NULL, then those values are not set. + + deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. + */ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough + room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an Adler-32 or a CRC-32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see + below), inflate() will *not* automatically decode concatenated gzip members. + inflate() will return Z_STREAM_END at the end of the gzip member. The state + would need to be reset to continue decoding a subsequent gzip member. This + *must* be done if there is more data after a gzip member, in order for the + decompression to be compliant with the gzip standard (RFC 1952). + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler-32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called at any + time to set the dictionary. If the provided dictionary is smaller than the + window and there is already data in the window, then the provided dictionary + will amend what's there. The application must insure that the dictionary + that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler-32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, + Bytef *dictionary, + uInt *dictLength)); +/* + Returns the sliding dictionary being maintained by inflate. dictLength is + set to the number of bytes in the dictionary, and that many bytes are copied + to dictionary. dictionary must have enough space, where 32768 bytes is + always enough. If inflateGetDictionary() is called with dictionary equal to + Z_NULL, then only the dictionary length is returned, and nothing is copied. + Similary, if dictLength is Z_NULL, then it is not set. + + inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the + stream state is inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a possible full flush point (see above + for the description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync searches for a 00 00 FF FF pattern in the compressed data. + All full flush points have this pattern, but not all occurrences of this + pattern are full flush points. + + inflateSync returns Z_OK if a possible full flush point has been found, + Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point + has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. + In the success case, the application may save the current current value of + total_in which indicates where valid compressed data was found. In the + error case, the application may repeatedly call inflateSync, providing more + input each time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. If the window size is changed, then the + memory allocated for the window is freed, and the window will be reallocated + by inflate() if needed. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above, or -65536 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the parameters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, + z_const unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is potentially more efficient than + inflate() for file i/o applications, in that it avoids copying between the + output and the sliding window by simply making the window itself the output + buffer. inflate() can be faster on modern CPUs when used with large + buffers. inflateBack() trusts the application to not change the output + buffer passed by the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the default + behavior of inflate(), which expects a zlib header and trailer around the + deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero -- buf is ignored in that + case -- and inflateBack() will return a buffer error. inflateBack() will + call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. + out() should return zero on success, or non-zero on failure. If out() + returns non-zero, inflateBack() will return with an error. Neither in() nor + out() are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: ZLIB_DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + +#ifndef Z_SOLO + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. compress() is equivalent to compress2() with a level + parameter of Z_DEFAULT_COMPRESSION. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed data. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed data. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In + the case where there is not enough room, uncompress() will fill the output + buffer with the uncompressed data up to that point. +*/ + +ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen)); +/* + Same as uncompress, except that sourceLen is a pointer, where the + length of the source is *sourceLen. On return, *sourceLen is the number of + source bytes consumed. +*/ + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Open the gzip (.gz) file at path for reading and decompressing, or + compressing and writing. The mode parameter is as in fopen ("rb" or "wb") + but can also include a compression level ("wb9") or a strategy: 'f' for + filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", + 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression + as in "wb9F". (See the description of deflateInit2 for more information + about the strategy parameter.) 'T' will request transparent writing or + appending with no compression and not using the gzip format. + + "a" can be used instead of "w" to request that the gzip stream that will + be written be appended to the file. "+" will result in an error, since + reading and writing to the same gzip file is not supported. The addition of + "x" when writing will create the file exclusively, which fails if the file + already exists. On systems that support it, the addition of "e" when + reading or writing will set the flag to close the file on an execve() call. + + These functions, as well as gzip, will read and decode a sequence of gzip + streams in a file. The append function of gzopen() can be used to create + such a file. (Also see gzflush() for another way to do this.) When + appending, gzopen does not test whether the file begins with a gzip stream, + nor does it look for the end of the gzip streams to begin appending. gzopen + will simply append a gzip stream to the existing file. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. When + reading, this will be detected automatically by looking for the magic two- + byte gzip header. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + Associate a gzFile with the file descriptor fd. File descriptors are + obtained from calls like open, dup, creat, pipe or fileno (if the file has + been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. If you are using fileno() to get the + file descriptor from a FILE *, then you will have to use dup() to avoid + double-close()ing the file descriptor. Both gzclose() and fclose() will + close the associated file descriptor, so they need to have different file + descriptors. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions for file to + size. The default buffer size is 8192 bytes. This function must be called + after gzopen() or gzdopen(), and before any other calls that read or write + the file. The buffer memory allocation is always deferred to the first read + or write. Three times that size in buffer space is allocated. A larger + buffer size of, for example, 64K or 128K bytes will noticeably increase the + speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level and strategy for file. See the + description of deflateInit2 for the meaning of these parameters. Previously + provided data is flushed before applying the parameter changes. + + gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not + opened for writing, Z_ERRNO if there is an error writing the flushed data, + or Z_MEM_ERROR if there is a memory allocation error. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Read and decompress up to len uncompressed bytes from file into buf. If + the input file is not in gzip format, gzread copies the given number of + bytes into the buffer directly from the file. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream. Any number of gzip streams may be + concatenated in the input file, and will all be decompressed by gzread(). + If something other than a gzip stream is encountered after a gzip stream, + that remaining trailing garbage is ignored (and no error is returned). + + gzread can be used to read a gzip file that is being concurrently written. + Upon reaching the end of the input, gzread will return with the available + data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then + gzclearerr can be used to clear the end of file indicator in order to permit + gzread to be tried again. Z_OK indicates that a gzip stream was completed + on the last gzread. Z_BUF_ERROR indicates that the input file ended in the + middle of a gzip stream. Note that gzread does not return -1 in the event + of an incomplete gzip stream. This error is deferred until gzclose(), which + will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip + stream. Alternatively, gzerror can be used before gzclose to detect this + case. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. If len is too large to fit in an int, + then nothing is read, -1 is returned, and the error state is set to + Z_STREAM_ERROR. +*/ + +ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, + gzFile file)); +/* + Read and decompress up to nitems items of size size from file into buf, + otherwise operating as gzread() does. This duplicates the interface of + stdio's fread(), with size_t request and return types. If the library + defines size_t, then z_size_t is identical to size_t. If not, then z_size_t + is an unsigned integer type that can contain a pointer. + + gzfread() returns the number of full items read of size size, or zero if + the end of the file was reached and a full item could not be read, or if + there was an error. gzerror() must be consulted if zero is returned in + order to determine if there was an error. If the multiplication of size and + nitems overflows, i.e. the product does not fit in a z_size_t, then nothing + is read, zero is returned, and the error state is set to Z_STREAM_ERROR. + + In the event that the end of file is reached and only a partial item is + available at the end, i.e. the remaining uncompressed data length is not a + multiple of size, then the final partial item is nevetheless read into buf + and the end-of-file flag is set. The length of the partial item read is not + provided, but could be inferred from the result of gztell(). This behavior + is the same as the behavior of fread() implementations in common libraries, + but it prevents the direct use of gzfread() to read a concurrently written + file, reseting and retrying on end-of-file, when size is not 1. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); +/* + Compress and write the len uncompressed bytes at buf to file. gzwrite + returns the number of uncompressed bytes written or 0 in case of error. +*/ + +ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, + z_size_t nitems, gzFile file)); +/* + Compress and write nitems items of size size from buf to file, duplicating + the interface of stdio's fwrite(), with size_t request and return types. If + the library defines size_t, then z_size_t is identical to size_t. If not, + then z_size_t is an unsigned integer type that can contain a pointer. + + gzfwrite() returns the number of full items written of size size, or zero + if there was an error. If the multiplication of size and nitems overflows, + i.e. the product does not fit in a z_size_t, then nothing is written, zero + is returned, and the error state is set to Z_STREAM_ERROR. +*/ + +ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +/* + Convert, format, compress, and write the arguments (...) to file under + control of the string format, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or a negative zlib error code in case + of error. The number of uncompressed bytes written is limited to 8191, or + one less than the buffer size given to gzbuffer(). The caller should assure + that this limit is not exceeded. If it is exceeded, then gzprintf() will + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf(), + because the secure snprintf() or vsnprintf() functions were not available. + This can be determined using zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Compress and write the given null-terminated string s to file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Read and decompress bytes from file into buf, until len-1 characters are + read, or until a newline character is read and transferred to buf, or an + end-of-file condition is encountered. If any characters are read or if len + is one, the string is terminated with a null character. If no characters + are read due to an end-of-file or len is less than one, then the buffer is + left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Compress and write c, converted to an unsigned char, into file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Read and decompress one byte from file. gzgetc returns this byte or -1 + in case of end of file or error. This is implemented as a macro for speed. + As such, it does not do all of the checking the other functions do. I.e. + it does not check to see if file is NULL, nor whether the structure file + points to has been clobbered or not. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push c back onto the stream for file to be read as the first character on + the next read. At least one character of push-back is always allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flush all pending output to file. The parameter flush is as in the + deflate() function. The return value is the zlib error number (see function + gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatenated gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Set the starting position to offset relative to whence for the next gzread + or gzwrite on file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewind file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Return the starting position for the next gzread or gzwrite on file. + This position represents a number of bytes in the uncompressed data stream, + and is zero when starting, even if appending or reading a gzip stream from + the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Return the current compressed (actual) read or write offset of file. This + offset includes the count of bytes that precede the gzip stream, for example + when appending or when using gzdopen() for reading. When reading, the + offset does not include as yet unused buffered input. This information can + be used for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Return true (1) if the end-of-file indicator for file has been set while + reading, false (0) otherwise. Note that the end-of-file indicator is set + only if the read tried to go past the end of the input, but came up short. + Therefore, just like feof(), gzeof() may return false even if there is no + more data to read, in the event that the last read request was for the exact + number of bytes remaining in the input file. This will happen if the input + file size is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Return true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). + + When writing, gzdirect() returns true (1) if transparent writing was + requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: + gzdirect() is not needed when writing. Transparent writing must be + explicitly requested, so the application already knows the answer. When + linking statically, using gzdirect() will include all of the zlib code for + gzip file reading and decompression, which may not be desired.) +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flush all pending output for file, if necessary, close file and + deallocate the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the + last read ended in the middle of a gzip stream, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Return the error message for the last error which occurred on file. + errnum is set to zlib error number. If an error occurred in the file system + and not in the compression library, errnum is set to Z_ERRNO and the + application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clear the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + +#endif /* !Z_SOLO */ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. An Adler-32 value is in the range of a 32-bit + unsigned integer. If buf is Z_NULL, this function returns the required + initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, + z_size_t len)); +/* + Same as adler32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note + that the z_off_t type (like off_t) is a signed integer. If len2 is + negative, the result has no meaning or utility. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. + If buf is Z_NULL, this function returns the required initial value for the + crc. Pre- and post-conditioning (one's complement) is performed within this + function so it shouldn't be done by the application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, + z_size_t len)); +/* + Same as crc32(), but with a size_t length. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); + + Return the operator corresponding to length len2, to be used with + crc32_combine_op(). +*/ + +ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); +/* + Give the same result as crc32_combine(), using op in place of len2. op is + is generated from len2 by crc32_combine_gen(). This will be faster than + crc32_combine() if the generated op is used more than once. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#ifdef Z_PREFIX_SET +# define z_deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define z_inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define z_inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#else +# define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) +# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) +# define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ + (int)sizeof(z_stream)) +# define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, (int)sizeof(z_stream)) +#endif + +#ifndef Z_SOLO + +/* gzgetc() macro and its supporting function and exposed data structure. Note + * that the real internal state is much larger than the exposed structure. + * This abbreviated structure exposes just enough for the gzgetc() macro. The + * user should not mess with these exposed elements, since their names or + * behavior could change in the future, perhaps even capriciously. They can + * only be used by the gzgetc() macro. You have been warned. + */ +struct gzFile_s { + unsigned have; + unsigned char *next; + z_off64_t pos; +}; +ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +# define z_gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#else +# define gzgetc(g) \ + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) +#endif + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#ifdef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) +# ifdef Z_PREFIX_SET +# define z_gzopen z_gzopen64 +# define z_gzseek z_gzseek64 +# define z_gztell z_gztell64 +# define z_gzoffset z_gzoffset64 +# define z_adler32_combine z_adler32_combine64 +# define z_crc32_combine z_crc32_combine64 +# define z_crc32_combine_gen z_crc32_combine_gen64 +# else +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# define crc32_combine_gen crc32_combine_gen64 +# endif +# ifndef Z_LARGE64 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); +#endif + +#else /* Z_SOLO */ + + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + +#endif /* !Z_SOLO */ + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); +ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); +ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); +ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +#if defined(_WIN32) && !defined(Z_SOLO) +ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, + const char *mode)); +#endif +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, + const char *format, + va_list va)); +# endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/third_party/zlib/zlib.ndk.json b/third_party/zlib/zlib.ndk.json index 498f3945f10383d16cfb168ce05cdef627c772c5..76ff913da7b51753cff31ef19dc757539f5b973d 100644 --- a/third_party/zlib/zlib.ndk.json +++ b/third_party/zlib/zlib.ndk.json @@ -1,95 +1,95 @@ -[ - { "name": "_dist_code" }, - { "name": "_length_code" }, - { "name": "_tr_align" }, - { "name": "_tr_flush_bits" }, - { "name": "_tr_flush_block" }, - { "name": "_tr_init" }, - { "name": "_tr_stored_block" }, - { "name": "_tr_tally" }, - { "name": "adler32" }, - { "name": "adler32_combine" }, - { "name": "adler32_combine64" }, - { "name": "adler32_z" }, - { "name": "compress" }, - { "name": "compress2" }, - { "name": "compressBound" }, - { "name": "crc32" }, - { "name": "crc32_combine" }, - { "name": "crc32_combine64" }, - { "name": "crc32_z" }, - { "name": "deflate" }, - { "name": "deflateBound" }, - { "name": "deflateCopy" }, - { "name": "deflateEnd" }, - { "name": "deflateGetDictionary" }, - { "name": "deflateInit2_" }, - { "name": "deflateInit_" }, - { "name": "deflateParams" }, - { "name": "deflatePending" }, - { "name": "deflatePrime" }, - { "name": "deflateReset" }, - { "name": "deflateResetKeep" }, - { "name": "deflateSetDictionary" }, - { "name": "deflateSetHeader" }, - { "name": "deflateTune" }, - { "name": "get_crc_table" }, - { "name": "gzbuffer" }, - { "name": "gzclearerr" }, - { "name": "gzclose" }, - { "name": "gzclose_r" }, - { "name": "gzclose_w" }, - { "name": "gzdirect" }, - { "name": "gzdopen" }, - { "name": "gzeof" }, - { "name": "gzerror" }, - { "name": "gzflush" }, - { "name": "gzfread" }, - { "name": "gzfwrite" }, - { "name": "gzgetc" }, - { "name": "gzgetc_" }, - { "name": "gzgets" }, - { "name": "gzoffset64" }, - { "name": "gzopen" }, - { "name": "gzopen64" }, - { "name": "gzopen_w" }, - { "name": "gzprintf" }, - { "name": "gzputc" }, - { "name": "gzputs" }, - { "name": "gzread" }, - { "name": "gzrewind" }, - { "name": "gzseek" }, - { "name": "gzseek64" }, - { "name": "gzsetparams" }, - { "name": "gztell" }, - { "name": "gztell64" }, - { "name": "gzungetc" }, - { "name": "gzvprintf" }, - { "name": "gzwrite" }, - { "name": "inflate" }, - { "name": "inflateBack" }, - { "name": "inflateBackEnd" }, - { "name": "inflateBackInit_" }, - { "name": "inflateCodesUsed" }, - { "name": "inflateCopy" }, - { "name": "inflateEnd" }, - { "name": "inflateGetDictionary" }, - { "name": "inflateGetHeader" }, - { "name": "inflateInit_" }, - { "name": "inflateInit2_" }, - { "name": "inflateMark" }, - { "name": "inflatePrime" }, - { "name": "inflateReset" }, - { "name": "inflateReset2" }, - { "name": "inflateResetKeep" }, - { "name": "inflateSetDictionary" }, - { "name": "inflateSync" }, - { "name": "inflateSyncPoint" }, - { "name": "inflateUndermine" }, - { "name": "inflateValidate" }, - { "name": "uncompress" }, - { "name": "uncompress2" }, - { "name": "zError" }, - { "name": "zlibCompileFlags" }, - { "name": "zlibVersion" } -] +[ + { "name": "_dist_code" }, + { "name": "_length_code" }, + { "name": "_tr_align" }, + { "name": "_tr_flush_bits" }, + { "name": "_tr_flush_block" }, + { "name": "_tr_init" }, + { "name": "_tr_stored_block" }, + { "name": "_tr_tally" }, + { "name": "adler32" }, + { "name": "adler32_combine" }, + { "name": "adler32_combine64" }, + { "name": "adler32_z" }, + { "name": "compress" }, + { "name": "compress2" }, + { "name": "compressBound" }, + { "name": "crc32" }, + { "name": "crc32_combine" }, + { "name": "crc32_combine64" }, + { "name": "crc32_z" }, + { "name": "deflate" }, + { "name": "deflateBound" }, + { "name": "deflateCopy" }, + { "name": "deflateEnd" }, + { "name": "deflateGetDictionary" }, + { "name": "deflateInit2_" }, + { "name": "deflateInit_" }, + { "name": "deflateParams" }, + { "name": "deflatePending" }, + { "name": "deflatePrime" }, + { "name": "deflateReset" }, + { "name": "deflateResetKeep" }, + { "name": "deflateSetDictionary" }, + { "name": "deflateSetHeader" }, + { "name": "deflateTune" }, + { "name": "get_crc_table" }, + { "name": "gzbuffer" }, + { "name": "gzclearerr" }, + { "name": "gzclose" }, + { "name": "gzclose_r" }, + { "name": "gzclose_w" }, + { "name": "gzdirect" }, + { "name": "gzdopen" }, + { "name": "gzeof" }, + { "name": "gzerror" }, + { "name": "gzflush" }, + { "name": "gzfread" }, + { "name": "gzfwrite" }, + { "name": "gzgetc" }, + { "name": "gzgetc_" }, + { "name": "gzgets" }, + { "name": "gzoffset64" }, + { "name": "gzopen" }, + { "name": "gzopen64" }, + { "name": "gzopen_w" }, + { "name": "gzprintf" }, + { "name": "gzputc" }, + { "name": "gzputs" }, + { "name": "gzread" }, + { "name": "gzrewind" }, + { "name": "gzseek" }, + { "name": "gzseek64" }, + { "name": "gzsetparams" }, + { "name": "gztell" }, + { "name": "gztell64" }, + { "name": "gzungetc" }, + { "name": "gzvprintf" }, + { "name": "gzwrite" }, + { "name": "inflate" }, + { "name": "inflateBack" }, + { "name": "inflateBackEnd" }, + { "name": "inflateBackInit_" }, + { "name": "inflateCodesUsed" }, + { "name": "inflateCopy" }, + { "name": "inflateEnd" }, + { "name": "inflateGetDictionary" }, + { "name": "inflateGetHeader" }, + { "name": "inflateInit_" }, + { "name": "inflateInit2_" }, + { "name": "inflateMark" }, + { "name": "inflatePrime" }, + { "name": "inflateReset" }, + { "name": "inflateReset2" }, + { "name": "inflateResetKeep" }, + { "name": "inflateSetDictionary" }, + { "name": "inflateSync" }, + { "name": "inflateSyncPoint" }, + { "name": "inflateUndermine" }, + { "name": "inflateValidate" }, + { "name": "uncompress" }, + { "name": "uncompress2" }, + { "name": "zError" }, + { "name": "zlibCompileFlags" }, + { "name": "zlibVersion" } +]