mirror of
https://gitee.com/openharmony/interface_sdk_c
synced 2024-11-23 06:39:54 +00:00
同步代码到interface_sdk_c仓
Signed-off-by: huangdongting <huangdongting3@huawei.com>
This commit is contained in:
parent
e901fb748e
commit
6ee538a78e
34
ai/neural_network_runtime/BUILD.gn
Normal file
34
ai/neural_network_runtime/BUILD.gn
Normal file
@ -0,0 +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",
|
||||
]
|
||||
}
|
95
ai/neural_network_runtime/libneural_network_runtime.ndk.json
Normal file
95
ai/neural_network_runtime/libneural_network_runtime.ndk.json
Normal file
@ -0,0 +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"
|
||||
}
|
||||
]
|
690
ai/neural_network_runtime/neural_network_runtime.h
Normal file
690
ai/neural_network_runtime/neural_network_runtime.h
Normal file
@ -0,0 +1,690 @@
|
||||
/*
|
||||
* 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 <b>tensor</b> 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 <b>tensor.dimensions</b> to <b>-1</b>.
|
||||
* For example, if <b>tensor.dimensions</b> of a four-dimensional tensor is set to <b>[1, -1, 2, 2]</b>, 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, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>op</b>, and
|
||||
* the operator parameters, inputs, and outputs are specified by <b>paramIndices</b>, <b>inputIndices</b>, and <b>outputIndices</b> 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
|
||||
*
|
||||
* <b>paramIndices</b>, <b>inputIndices</b>, and <b>outputIndices</b> 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 <b>OH_NN_UInt32Array</b> instance, which is used to set operator parameters.
|
||||
* @param inputIndices Pointer to the <b>OH_NN_UInt32Array</b> instance, which is used to set the operator input.
|
||||
* @param outputIndices Pointer to the <b>OH_NN_UInt32Array</b> instance, which is used to set the operator output.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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 <b>OH_NNExecutor</b> 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 <b>OH_NN_UInt32Array</b> instance, which is used to set the operator input.
|
||||
* @param outputIndices Pointer to the <b>OH_NN_UInt32Array</b> instance, which is used to set the operator output.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>model</b> or <b>*model</b> 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 <b>*model</b> 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 <b>deviceID</b>,
|
||||
* and the result is represented by the array pointed by <b>isSupported</b>. If the <i>i</i>th operator is supported,
|
||||
* the value of <b>(*isSupported)</b>[<i>i</i>] is <b>true</b>. Otherwise, the value is <b>false</b>. \n
|
||||
*
|
||||
* After this method is successfully executed, <b>(*isSupported)</b> 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, <b>(*isSupported)</b> 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 <b>(*isSupported)</b> array.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>version</b>. \n
|
||||
*
|
||||
* - A complete cache file exists in the cache directory, and its version is <b>version</b>:
|
||||
* 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 <b>version</b>:
|
||||
* When model compilation is complete on the underlying device, overwrites the cache file and changes the version number to <b>version</b>. \n
|
||||
*
|
||||
* - A complete cache file exists in the cache directory, and its version is later than <b>version</b>:
|
||||
* 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 <b>cachePath</b> 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, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>true</b>, float16 inference is performed.
|
||||
* If this parameter is set to <b>false</b>, float32 inference is performed.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>Compilation</b> 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 <b>compilation</b> or <b>*compilation</b> 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 <b>*compilation</b> 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 <b>length</b> (in bytes) in <b>dataBuffer</b> to the shared memory
|
||||
* of the underlying device. <b>inputIndex</b> specifies the input to be set and <b>tensor</b> 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 <b>tensor</b> 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 <b>tensor.dimensions</b> must be greater than
|
||||
* <b>0</b> 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 <b>-1</b>. Assume that <b>[-1, 224, 224, 3]</b> 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 <b>[3, 224, 224, 3]</b>.
|
||||
* 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 <b>inputIndices</b> is <b>{1, 5, 9}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* In input settings, the index value for the three inputs is <b>{0, 1, 2}</b>. \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, <b>OH_NN_SUCCESS</b> 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 <b>dataBuffer</b> points to the output specified by <b>outputIndex</b>.
|
||||
* The length of the buffer is specified by <b>length</b>. \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 <b>dataBuffer</b> 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 <b>dataBuffer</b>.
|
||||
* - 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 <b>outputIndices</b> is <b>{4, 6, 8}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs}
|
||||
* is called. In output buffer settings, the index value for the three outputs is <b>{0, 1, 2}</b>.
|
||||
* @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, <b>OH_NN_SUCCESS</b> 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 <b>outputIndices</b> is <b>{4, 6, 8}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* When {@link OH_NNExecutor_GetOutputShape} is called to obtain dimension information about the output tensor,
|
||||
* <b>outputIndices</b> is <b>{0, 1, 2}</b>.
|
||||
*
|
||||
* @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, <b>OH_NN_SUCCESS</b> 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, <b>OH_NN_SUCCESS</b> 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 <b>length</b> 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 <b>inputIndices</b> is <b>{1, 5, 9}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* In the memory input application, the index value for the three inputs is <b>{0, 1, 2}</b>.
|
||||
* @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 <b>length</b> 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 <b>outputIndices</b> is <b>{4, 6, 8}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* In output memory application, the index value for the three outputs is <b>{0, 1, 2}</b>.
|
||||
* @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 <b>inputIndex</b> and <b>memory</b> must be the same as that in memory instance creation. \n
|
||||
*
|
||||
* If <b>memory</b> or <b>*memory</b> 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 <b>inputIndices</b> is <b>{1, 5, 9}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* In memory input release, the index value for the three inputs is <b>{0, 1, 2}</b>.
|
||||
* @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets <b>*memory</b> 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 <b>outputIndex</b> and <b>memory</b> must be the same as that in memory instance creation. \n
|
||||
*
|
||||
* If <b>memory</b> or <b>*memory</b> 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 <b>outputIndices</b> is <b>{4, 6, 8}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* In output memory release, the index value for the three outputs is <b>{0, 1, 2}</b>.
|
||||
* @param memory Level-2 pointer to the {@link OH_NN_Memory} instance. After shared memory is destroyed, this method sets <b>*memory</b> 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 <b>inputIndices</b> is <b>{1, 5, 9}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* When the input shared memory is specified, the index value for the three inputs is <b>{0, 1, 2}</b>.
|
||||
* @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, <b>OH_NN_SUCCESS</b> 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 <b>outputIndices</b> is <b>{4, 6, 8}</b> when {@link OH_NNModel_SpecifyInputsAndOutputs} is called.
|
||||
* When output shared memory is specified, the index value for the three outputs is <b>{0, 1, 2}</b>.
|
||||
* @param memory Pointer to {@link OH_NN_Memory}.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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 <b>executor</b> or <b>*executor</b> 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 <b>*allDevicesID</b> 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 <b>(*allDevicesID)</b>.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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.
|
||||
*
|
||||
* <b>deviceID</b> 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 <b>(*char)</b> must be a null pointer. Otherwise, {@link OH_NN_INVALID_PARAMETER} is returned.
|
||||
* The value of <b>(*name)</b> is a C-style string ended with <b>'\0'</b>.
|
||||
* @return Execution result of the function. If the operation is successful, <b>OH_NN_SUCCESS</b> 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.
|
||||
*
|
||||
* <b>deviceID</b> specifies the device whose type will be obtained. Currently, Neural Network Runtime supports the following device types:
|
||||
* - <b>OH_NN_CPU</b>: CPU device.
|
||||
* - <b>OH_NN_GPU</b>: GPU device.
|
||||
* - <b>OH_NN_ACCELERATOR</b>: machine learning dedicated accelerator.
|
||||
* - <b>OH_NN_OTHERS</b>: 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, <b>OH_NN_SUCCESS</b> 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
|
1783
ai/neural_network_runtime/neural_network_runtime_type.h
Normal file
1783
ai/neural_network_runtime/neural_network_runtime_type.h
Normal file
File diff suppressed because it is too large
Load Diff
74
arkui/ace_engine/native/BUILD.gn
Normal file
74
arkui/ace_engine/native/BUILD.gn
Normal file
@ -0,0 +1,74 @@
|
||||
# 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"
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("ace_ndk") {
|
||||
if (current_os == "ohos") {
|
||||
sanitize = {
|
||||
integer_overflow = true
|
||||
boundary_sanitize = true
|
||||
debug = ace_sanitize_debug
|
||||
}
|
||||
}
|
||||
include_dirs = [
|
||||
"//foundation/arkui/ace_engine",
|
||||
"//foundation/arkui/ace_engine/frameworks",
|
||||
"//foundation/arkui/ace_engine/interfaces/native",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"//foundation/arkui/ace_engine/frameworks/core/components/xcomponent/native_interface_xcomponent_impl.cpp",
|
||||
"native_interface_xcomponent.cpp",
|
||||
]
|
||||
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
|
||||
cflags_cc = [ "-Wno-missing-braces" ]
|
||||
|
||||
if (target_os == "ohos") {
|
||||
sources += [ "$ace_root/adapter/ohos/osal/log_wrapper.cpp" ]
|
||||
deps += [ ":libace_ndk" ]
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
version_script =
|
||||
get_label_info(":libace_ndk", "target_gen_dir") + "/" +
|
||||
get_label_info(":libace_ndk", "name") + version_script_suffix
|
||||
} else if (target_os == "android") {
|
||||
sources += [ "$ace_root/adapter/android/osal/log_wrapper.cpp" ]
|
||||
libs = [ "log" ]
|
||||
}
|
||||
|
||||
subsystem_name = ace_engine_subsystem
|
||||
part_name = ace_engine_part
|
||||
}
|
||||
|
||||
group("ace_packages_ndk") {
|
||||
deps = [ ":ace_ndk" ]
|
||||
}
|
82
arkui/ace_engine/native/libace.ndk.json
Normal file
82
arkui/ace_engine/native/libace.ndk.json
Normal file
@ -0,0 +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"
|
||||
}
|
||||
]
|
206
arkui/ace_engine/native/native_interface_xcomponent.cpp
Normal file
206
arkui/ace_engine/native/native_interface_xcomponent.cpp
Normal file
@ -0,0 +1,206 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "native_interface_xcomponent.h"
|
||||
|
||||
#include "frameworks/core/components/xcomponent/native_interface_xcomponent_impl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size)
|
||||
{
|
||||
if ((component == nullptr) || (id == nullptr) || (size == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
if (((*size) == 0) || ((*size) > (OH_XCOMPONENT_ID_LEN_MAX + 1))) {
|
||||
LOGE("The referenced value of 'size' should be in the range (0, OH_XCOMPONENT_ID_LEN_MAX + 1]");
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetXComponentId(id, size);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetXComponentSize(
|
||||
OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height)
|
||||
{
|
||||
if ((component == nullptr) || (window == nullptr) || (width == nullptr) || (height == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetXComponentSize(window, width, height);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetXComponentOffset(
|
||||
OH_NativeXComponent* component, const void* window, double* x, double* y)
|
||||
{
|
||||
if ((component == nullptr) || (window == nullptr) || (x == nullptr) || (y == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetXComponentOffset(window, x, y);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetTouchEvent(
|
||||
OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent)
|
||||
{
|
||||
if ((component == nullptr) || (window == nullptr) || (touchEvent == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetTouchEvent(window, touchEvent);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetTouchPointToolType(
|
||||
OH_NativeXComponent* component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType* toolType)
|
||||
{
|
||||
if ((component == nullptr) || (toolType == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetToolType(pointIndex, toolType);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX)
|
||||
{
|
||||
if ((component == nullptr) || (tiltX == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetTiltX(pointIndex, tiltX);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY)
|
||||
{
|
||||
if ((component == nullptr) || (tiltY == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetTiltY(pointIndex, tiltY);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window,
|
||||
int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints)
|
||||
{
|
||||
if ((component == nullptr) || (window == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetHistoryPoints(window, size, historicalPoints);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetMouseEvent(
|
||||
OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent)
|
||||
{
|
||||
if ((component == nullptr) || (window == nullptr) || (mouseEvent == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetMouseEvent(window, mouseEvent);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback)
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->RegisterCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterMouseEventCallback(
|
||||
OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback)
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->RegisterMouseEventCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterFocusEventCallback(
|
||||
OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->RegisterFocusEventCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterKeyEventCallback(
|
||||
OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->RegisterKeyEventCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_RegisterBlurEventCallback(
|
||||
OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window))
|
||||
{
|
||||
if ((component == nullptr) || (callback == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->RegisterBlurEventCallback(callback);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent)
|
||||
{
|
||||
if ((component == nullptr) || (keyEvent == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
return component->GetKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEventAction(
|
||||
OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action)
|
||||
{
|
||||
if ((keyEvent == nullptr) || (action == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
(*action) = keyEvent->action;
|
||||
return OH_NATIVEXCOMPONENT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code)
|
||||
{
|
||||
if ((keyEvent == nullptr) || (code == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
(*code) = keyEvent->code;
|
||||
return OH_NATIVEXCOMPONENT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEventSourceType(
|
||||
OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType)
|
||||
{
|
||||
if ((keyEvent == nullptr) || (sourceType == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
(*sourceType) = keyEvent->sourceType;
|
||||
return OH_NATIVEXCOMPONENT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId)
|
||||
{
|
||||
if ((keyEvent == nullptr) || (deviceId == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
(*deviceId) = keyEvent->deviceId;
|
||||
return OH_NATIVEXCOMPONENT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp)
|
||||
{
|
||||
if ((keyEvent == nullptr) || (timestamp == nullptr)) {
|
||||
return OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
|
||||
}
|
||||
(*timestamp) = keyEvent->timestamp;
|
||||
return OH_NATIVEXCOMPONENT_RESULT_SUCCESS;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
579
arkui/ace_engine/native/native_interface_xcomponent.h
Normal file
579
arkui/ace_engine/native/native_interface_xcomponent.h
Normal file
@ -0,0 +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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
* @param id Indicates the char buffer to keep the ID of this <b>OH_NativeXComponent</b> 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 <b>id</b>, 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
*
|
||||
* @param component Indicates the pointer to this <b>OH_NativeXComponent</b> 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 <b>OH_NativeXComponent</b> instance.
|
||||
* @param keyEvent Indicates the pointer to pointer of <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> instance.
|
||||
* @param action Indicates the action of the <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> instance.
|
||||
* @param code Indicates the keyCode of the <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> instance.
|
||||
* @param sourceType Indicates the sourceType of the <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> instance.
|
||||
* @param deviceId Indicates the deviceId of the <b>OH_NativeXComponent_KeyEvent</b> 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 <b>OH_NativeXComponent_KeyEvent</b> instance.
|
||||
* @param timestamp Indicates the timestamp of the <b>OH_NativeXComponent_KeyEvent</b> 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_
|
391
arkui/ace_engine/native/native_xcomponent_key_event.h
Normal file
391
arkui/ace_engine/native/native_xcomponent_key_event.h
Normal file
@ -0,0 +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_
|
281
arkui/napi/BUILD.gn
Normal file
281
arkui/napi/BUILD.gn
Normal file
@ -0,0 +1,281 @@
|
||||
# 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("//foundation/arkui/napi/napi.gni")
|
||||
|
||||
config("ace_napi_config") {
|
||||
include_dirs = [
|
||||
"../../../foundation/arkui/napi/native_engine",
|
||||
"//foundation/arkui/napi",
|
||||
"//foundation/arkui/napi/interfaces/inner_api",
|
||||
"//foundation/arkui/napi/interfaces/kits",
|
||||
"//third_party/libuv/include",
|
||||
"//third_party/node/src",
|
||||
]
|
||||
}
|
||||
|
||||
config("module_manager_config") {
|
||||
include_dirs = [ "../../../foundation/arkui/napi/module_manager" ]
|
||||
}
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/arkui/ace_engine/ace_config.gni")
|
||||
|
||||
ohos_source_set("ace_napi_static") {
|
||||
defines = []
|
||||
public_configs = [ ":ace_napi_config" ]
|
||||
deps = []
|
||||
|
||||
include_dirs = [
|
||||
"../../../napi",
|
||||
"../../../napi/interfaces/inner_api",
|
||||
"../../../napi/interfaces/kits",
|
||||
"//third_party/libuv/include",
|
||||
"//third_party/node/src",
|
||||
"../../../base/include",
|
||||
]
|
||||
|
||||
sources = napi_sources
|
||||
|
||||
if (current_cpu == "arm64") {
|
||||
defines += [ "_ARM64_" ]
|
||||
}
|
||||
if (current_os == "ohos" && current_cpu == "x86_64") {
|
||||
defines += [ "SIMULATOR" ]
|
||||
}
|
||||
if (use_mingw_win || use_mac || use_linux) {
|
||||
defines += [ "PREVIEW" ]
|
||||
}
|
||||
if (use_mingw_win) {
|
||||
defines += [ "WINDOWS_PLATFORM" ]
|
||||
} else if (use_mac) {
|
||||
defines += [ "MAC_PLATFORM" ]
|
||||
} else if (use_linux) {
|
||||
defines += [ "LINUX_PLATFORM" ]
|
||||
} else if (is_cross_platform_build && target_os == "ios") {
|
||||
defines += [ "IOS_PLATFORM" ]
|
||||
if (napi_enable_container_scope) {
|
||||
deps += [ ":ace_container_scope_static" ]
|
||||
defines += [ "ENABLE_CONTAINER_SCOPE" ]
|
||||
}
|
||||
} else if (is_cross_platform_build && target_os == "android") {
|
||||
defines += [ "ANDROID_PLATFORM" ]
|
||||
if (napi_enable_container_scope) {
|
||||
deps += [ ":ace_container_scope_static" ]
|
||||
defines += [ "ENABLE_CONTAINER_SCOPE" ]
|
||||
}
|
||||
libs = [ "log" ]
|
||||
} else {
|
||||
if (is_standard_system) {
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"hitrace:libhitracechain",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
defines += [ "ENABLE_HITRACE" ]
|
||||
if (product_name != "ohos-sdk") {
|
||||
if (napi_enable_container_scope) {
|
||||
if (target_os == "ios") {
|
||||
deps += [ ":ace_container_scope_static" ]
|
||||
} else {
|
||||
deps += [ ":ace_container_scope" ]
|
||||
}
|
||||
defines += [ "ENABLE_CONTAINER_SCOPE" ]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
}
|
||||
|
||||
deps += [
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
"//third_party/libuv:uv",
|
||||
]
|
||||
|
||||
# Use static libuv for cross build
|
||||
if (is_cross_platform_build) {
|
||||
deps -= [ "//third_party/libuv:uv" ]
|
||||
deps += [ "//third_party/libuv:uv_static" ]
|
||||
}
|
||||
|
||||
cflags_cc = [ "-Wno-missing-braces" ]
|
||||
|
||||
subsystem_name = "arkui"
|
||||
part_name = "napi"
|
||||
}
|
||||
|
||||
if (is_cross_platform_build) {
|
||||
ohos_source_set("ace_napi") {
|
||||
deps = [ ":ace_napi_static" ]
|
||||
public_configs = [ ":ace_napi_config" ]
|
||||
subsystem_name = "arkui"
|
||||
part_name = "napi"
|
||||
}
|
||||
} else {
|
||||
ohos_shared_library("ace_napi") {
|
||||
deps = [ ":ace_napi_static" ]
|
||||
public_configs = [
|
||||
":ace_napi_config",
|
||||
":module_manager_config",
|
||||
]
|
||||
if (!is_cross_platform_build) {
|
||||
public_deps = [ "//third_party/libuv:uv" ]
|
||||
}
|
||||
subsystem_name = "arkui"
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "napi"
|
||||
}
|
||||
}
|
||||
|
||||
config("container_scope_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "$ace_root/frameworks" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("ace_container_scope") {
|
||||
public_configs = [ ":container_scope_config" ]
|
||||
|
||||
configs = [ "$ace_root:ace_config" ]
|
||||
|
||||
sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]
|
||||
|
||||
subsystem_name = "arkui"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "napi"
|
||||
}
|
||||
|
||||
ohos_source_set("ace_container_scope_static") {
|
||||
public_configs = [ ":container_scope_config" ]
|
||||
|
||||
configs = [ "$ace_root:ace_config" ]
|
||||
|
||||
sources = [ "$ace_root/frameworks/core/common/container_scope.cpp" ]
|
||||
}
|
||||
|
||||
template("ace_napi_lib") {
|
||||
forward_variables_from(invoker, "*")
|
||||
if (defined(use_js_debug) && use_js_debug) {
|
||||
deps_ = [
|
||||
"native_engine/impl/${engine_path}:ace_napi_impl_${engine_path}_debug",
|
||||
]
|
||||
} else {
|
||||
deps_ = [ "native_engine/impl/${engine_path}:ace_napi_impl_${engine_path}" ]
|
||||
}
|
||||
|
||||
if (is_cross_platform_build) {
|
||||
ohos_source_set(target_name) {
|
||||
public_configs =
|
||||
[ "native_engine/impl/${engine_path}:ace_napi_${engine_path}_config" ]
|
||||
deps = deps_
|
||||
if (defined(use_icu) && use_icu) {
|
||||
deps += [
|
||||
"//third_party/icu/icu4c:static_icui18n",
|
||||
"//third_party/icu/icu4c:static_icuuc",
|
||||
]
|
||||
}
|
||||
subsystem_name = "arkui"
|
||||
part_name = "napi"
|
||||
}
|
||||
} else {
|
||||
ohos_shared_library(target_name) {
|
||||
public_configs =
|
||||
[ "native_engine/impl/${engine_path}:ace_napi_${engine_path}_config" ]
|
||||
deps = deps_
|
||||
if (defined(use_icu) && use_icu) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
}
|
||||
|
||||
if (target_name == "ark" || target_name == "quickjs") {
|
||||
deps -= [ "//third_party/libuv:uv" ]
|
||||
}
|
||||
|
||||
subsystem_name = "arkui"
|
||||
part_name = "napi"
|
||||
}
|
||||
}
|
||||
}
|
||||
napi_libs = []
|
||||
|
||||
foreach(item, ace_platforms) {
|
||||
if (item.name == "ohos" || is_cross_platform_build) {
|
||||
engine_config = {
|
||||
}
|
||||
support_engines = {
|
||||
}
|
||||
engine_config = item.config
|
||||
support_engines = engine_config.js_engines
|
||||
foreach(engine, support_engines) {
|
||||
if (engine.engine_name != "ark") {
|
||||
ace_napi_lib("ace_napi_${engine.engine_path}") {
|
||||
engine_path = engine.engine_path
|
||||
}
|
||||
napi_libs += [ ":ace_napi_${engine.engine_path}" ]
|
||||
if (defined(engine.have_debug) && engine.have_debug) {
|
||||
ace_napi_lib("ace_napi_${engine.engine_path}_debug") {
|
||||
engine_path = engine.engine_path
|
||||
use_js_debug = true
|
||||
}
|
||||
napi_libs += [ ":ace_napi_${engine.engine_path}_debug" ]
|
||||
}
|
||||
} else if (engine.engine_name == "ark") {
|
||||
ace_napi_lib("ace_napi_${engine.engine_name}") {
|
||||
engine_path = engine.engine_name
|
||||
use_icu = true
|
||||
}
|
||||
napi_libs += [ ":ace_napi_${engine.engine_name}" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group("napi_packages") {
|
||||
deps = [ ":ace_napi" ]
|
||||
deps += napi_libs
|
||||
}
|
||||
|
||||
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 = [
|
||||
"interfaces/kits/napi/common.h",
|
||||
"interfaces/kits/napi/native_api.h",
|
||||
]
|
||||
}
|
||||
|
||||
group("napi_packages_ndk") {
|
||||
deps = [ ":libnapi_ndk" ]
|
||||
}
|
||||
|
||||
if (!build_ohos_ndk && !is_cross_platform_build) {
|
||||
group("napi_packages_test") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"sample/native_module_calc:calc",
|
||||
"sample/native_module_calc:number",
|
||||
"sample/native_module_callback:callback",
|
||||
"sample/native_module_demo:demo",
|
||||
"sample/native_module_netserver:netserver",
|
||||
"sample/native_module_storage:storage",
|
||||
"test/fuzztest:fuzztest",
|
||||
"test/unittest:unittest",
|
||||
]
|
||||
}
|
||||
}
|
26
arkui/napi/common.h
Normal file
26
arkui/napi/common.h
Normal file
@ -0,0 +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;
|
||||
|
||||
#endif /* FOUNDATION_ACE_NAPI_INTERFACES_KITS_NAPI_NATIVE_API_H */
|
135
arkui/napi/libnapi.ndk.json
Normal file
135
arkui/napi/libnapi.ndk.json
Normal file
@ -0,0 +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"}
|
||||
]
|
130
arkui/napi/native_api.h
Normal file
130
arkui/napi/native_api.h
Normal file
@ -0,0 +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 */
|
71
bundlemanager/bundle_framework/bundle/BUILD.gn
Normal file
71
bundlemanager/bundle_framework/bundle/BUILD.gn
Normal file
@ -0,0 +1,71 @@
|
||||
# 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("../../../../appexecfwk.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"
|
||||
}
|
||||
|
||||
ohos_shared_library("bundle_ndk") {
|
||||
public_configs = [ ":bundle_ndk_config" ]
|
||||
include_dirs = [
|
||||
"${common_path}/log/include",
|
||||
"${inner_api_path}/appexecfwk_base/include",
|
||||
"${inner_api_path}/appexecfwk_base/include/quick_fix",
|
||||
"${inner_api_path}/appexecfwk_base/include/overlay",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
defines = [
|
||||
"APP_LOG_TAG = \"BundleMgrService\"",
|
||||
"LOG_DOMAIN = 0xD001120",
|
||||
]
|
||||
sources = [
|
||||
"${inner_api_path}/appexecfwk_base/src/ability_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/application_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/bundle_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/compatible_application_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/extension_ability_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/hap_module_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/module_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/overlay/overlay_bundle_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/overlay/overlay_module_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/quick_fix/app_quick_fix.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/quick_fix/appqf_info.cpp",
|
||||
"${inner_api_path}/appexecfwk_base/src/quick_fix/hqf_info.cpp",
|
||||
"src/bundle_mgr_proxy_native.cpp",
|
||||
"src/native_interface_bundle.cpp",
|
||||
]
|
||||
|
||||
deps = [ "${common_path}:libappexecfwk_common" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
subsystem_name = "bundlemanager"
|
||||
part_name = "bundle_framework"
|
||||
}
|
@ -0,0 +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 <string>
|
||||
|
||||
#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<IRemoteObject> GetBmsProxy();
|
||||
template <typename T>
|
||||
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
|
@ -0,0 +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 <b>Bundle</b>-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
|
6
bundlemanager/bundle_framework/bundle/libbundle.ndk.json
Normal file
6
bundlemanager/bundle_framework/bundle/libbundle.ndk.json
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"first_introduced": "9",
|
||||
"name": "OH_NativeBundle_GetCurrentApplicationInfo"
|
||||
}
|
||||
]
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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 "bundle_mgr_proxy_native.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::u16string BMS_PROXY_INTERFACE_TOKEN = u"ohos.appexecfwk.BundleMgr";
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> BundleMgrProxyNative::GetBmsProxy()
|
||||
{
|
||||
auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgrProxy == nullptr) {
|
||||
APP_LOGE("fail to get samgr.");
|
||||
return nullptr;
|
||||
}
|
||||
return samgrProxy->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
}
|
||||
|
||||
bool BundleMgrProxyNative::GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo)
|
||||
{
|
||||
APP_LOGI("begin to get bundle info for self");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(BMS_PROXY_INTERFACE_TOKEN)) {
|
||||
APP_LOGE("fail to GetBundleInfoForSelf due to write InterfaceToken fail");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(flags)) {
|
||||
APP_LOGE("fail to GetBundleInfoForSelf due to write flag fail");
|
||||
return false;
|
||||
}
|
||||
if (!GetParcelableInfo<BundleInfo>(GET_BUNDLE_INFO_FOR_SELF_NATIVE, data, bundleInfo)) {
|
||||
APP_LOGE("fail to GetBundleInfoForSelf from server");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrProxyNative::SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
|
||||
sptr<IRemoteObject> remote = GetBmsProxy();
|
||||
if (remote == nullptr) {
|
||||
APP_LOGE("fail to send transact cmd %{public}d due to remote object", code);
|
||||
return false;
|
||||
}
|
||||
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
|
||||
if (result != NO_ERROR) {
|
||||
APP_LOGE("receive error transact code %{public}d in transact cmd %{public}d", result, code);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BundleMgrProxyNative::GetParcelableInfo(uint32_t code, MessageParcel &data, T &parcelableInfo)
|
||||
{
|
||||
MessageParcel reply;
|
||||
if (!SendTransactCmd(code, data, reply)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t res = reply.ReadInt32();
|
||||
if (res != NO_ERROR) {
|
||||
APP_LOGE("reply result failed");
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<T> info(reply.ReadParcelable<T>());
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("readParcelableInfo failed");
|
||||
return false;
|
||||
}
|
||||
parcelableInfo = *info;
|
||||
APP_LOGD("get parcelable info success");
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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_interface_bundle.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "application_info.h"
|
||||
#include "bundle_info.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "bundle_mgr_proxy_native.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "securec.h"
|
||||
namespace {
|
||||
const size_t CHAR_MAX_LENGTH = 10240;
|
||||
}
|
||||
|
||||
OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo()
|
||||
{
|
||||
OH_NativeBundle_ApplicationInfo nativeApplicationInfo;
|
||||
OHOS::AppExecFwk::BundleMgrProxyNative bundleMgrProxyNative;
|
||||
OHOS::AppExecFwk::BundleInfo bundleInfo;
|
||||
auto bundleInfoFlag = static_cast<int32_t>(OHOS::AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION);
|
||||
|
||||
if (!bundleMgrProxyNative.GetBundleInfoForSelf(bundleInfoFlag, bundleInfo)) {
|
||||
APP_LOGE("can not get bundleInfo for self");
|
||||
return nativeApplicationInfo;
|
||||
};
|
||||
OHOS::AppExecFwk::ApplicationInfo applicationInfo = bundleInfo.applicationInfo;
|
||||
|
||||
size_t bundleNameLen = applicationInfo.bundleName.size();
|
||||
if ((bundleNameLen == 0) || (bundleNameLen + 1) > CHAR_MAX_LENGTH) {
|
||||
APP_LOGE("failed due to the length of bundleName is 0 or to long");
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
nativeApplicationInfo.bundleName = static_cast<char*>(malloc(bundleNameLen + 1));
|
||||
if (nativeApplicationInfo.bundleName == nullptr) {
|
||||
APP_LOGE("failed due to malloc error");
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
|
||||
if (strcpy_s(nativeApplicationInfo.bundleName, bundleNameLen + 1, applicationInfo.bundleName.c_str()) != EOK) {
|
||||
APP_LOGE("failed due to strcpy_s error");
|
||||
free(nativeApplicationInfo.bundleName);
|
||||
nativeApplicationInfo.bundleName = nullptr;
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
|
||||
size_t fingerprintLen = applicationInfo.fingerprint.size();
|
||||
if ((fingerprintLen == 0) || (fingerprintLen + 1) > CHAR_MAX_LENGTH) {
|
||||
APP_LOGE("failed due to the length of fingerprint is 0 or to long");
|
||||
free(nativeApplicationInfo.bundleName);
|
||||
nativeApplicationInfo.bundleName = nullptr;
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
nativeApplicationInfo.fingerprint = static_cast<char*>(malloc(fingerprintLen + 1));
|
||||
if (nativeApplicationInfo.fingerprint == nullptr) {
|
||||
APP_LOGE("failed due to malloc error");
|
||||
free(nativeApplicationInfo.bundleName);
|
||||
nativeApplicationInfo.bundleName = nullptr;
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
|
||||
if (strcpy_s(nativeApplicationInfo.fingerprint, fingerprintLen + 1, applicationInfo.fingerprint.c_str()) != EOK) {
|
||||
APP_LOGE("failed due to strcpy_s error");
|
||||
free(nativeApplicationInfo.bundleName);
|
||||
nativeApplicationInfo.bundleName = nullptr;
|
||||
free(nativeApplicationInfo.fingerprint);
|
||||
nativeApplicationInfo.fingerprint = nullptr;
|
||||
return nativeApplicationInfo;
|
||||
}
|
||||
APP_LOGI("OH_NativeBundle_GetCurrentApplicationInfo success");
|
||||
return nativeApplicationInfo;
|
||||
}
|
27
commonlibrary/memory_utils/libpurgeablemem/BUILD.gn
Normal file
27
commonlibrary/memory_utils/libpurgeablemem/BUILD.gn
Normal file
@ -0,0 +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"
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
206
commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h
Normal file
206
commonlibrary/memory_utils/libpurgeablemem/purgeable_memory.h
Normal file
@ -0,0 +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 <stdbool.h> /* bool */
|
||||
#include <stddef.h> /* 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 */
|
44
distributeddatamgr/relational_store/BUILD.gn
Normal file
44
distributeddatamgr/relational_store/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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/distributeddatamgr/relational_store/relational_store.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",
|
||||
]
|
||||
}
|
254
distributeddatamgr/relational_store/include/oh_cursor.h
Normal file
254
distributeddatamgr/relational_store/include/oh_cursor.h
Normal file
@ -0,0 +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 <cstdint>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#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
|
403
distributeddatamgr/relational_store/include/oh_predicates.h
Normal file
403
distributeddatamgr/relational_store/include/oh_predicates.h
Normal file
@ -0,0 +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 <cstdint>
|
||||
#include <stddef.h>
|
||||
#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
|
120
distributeddatamgr/relational_store/include/oh_value_object.h
Normal file
120
distributeddatamgr/relational_store/include/oh_value_object.h
Normal file
@ -0,0 +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 <cstdint>
|
||||
#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
|
146
distributeddatamgr/relational_store/include/oh_values_bucket.h
Normal file
146
distributeddatamgr/relational_store/include/oh_values_bucket.h
Normal file
@ -0,0 +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 <cstdint>
|
||||
#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
|
350
distributeddatamgr/relational_store/include/relational_store.h
Normal file
350
distributeddatamgr/relational_store/include/relational_store.h
Normal file
@ -0,0 +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
|
@ -0,0 +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
|
||||
|
||||
#endif // RELATIONAL_STORE_ERRNO_CODE_H
|
21
distributeddatamgr/relational_store/libnative_rdb.ndk.json
Normal file
21
distributeddatamgr/relational_store/libnative_rdb.ndk.json
Normal file
@ -0,0 +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"}
|
||||
]
|
33
drivers/external_device_manager/usb/BUILD.gn
Normal file
33
drivers/external_device_manager/usb/BUILD.gn
Normal file
@ -0,0 +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",
|
||||
]
|
||||
}
|
44
drivers/external_device_manager/usb/libusb.ndk.json
Normal file
44
drivers/external_device_manager/usb/libusb.ndk.json
Normal file
@ -0,0 +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"
|
||||
}
|
||||
]
|
215
drivers/external_device_manager/usb/usb_ddk_api.h
Normal file
215
drivers/external_device_manager/usb/usb_ddk_api.h
Normal file
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "usb_ddk_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @brief Initializes the DDK.
|
||||
*
|
||||
* @return <b>0</b> 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 <b>0</b> 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 <b>OH_Usb_FreeConfigDescriptor</b>\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 <b>bConfigurationValue</b> 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 <b>0</b> 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 <b>OH_Usb_FreeConfigDescriptor</b>\n
|
||||
* to release a descriptor after use.
|
||||
*
|
||||
* @param config Configuration descriptor obtained by calling <b>OH_Usb_GetConfigDescriptor</b>.
|
||||
* @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 <b>bInterfaceNumber</b> 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 <b>0</b> 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 <b>0</b> 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 <b>bAlternateSetting</b>\n
|
||||
* in the USB protocol.
|
||||
* @return <b>0</b> 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 <b>bAlternateSetting</b>\n
|
||||
* in the USB protocol.
|
||||
* @return <b>0</b> 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 <b>Setup Data</b> 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 <b>0</b> 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 <b>Setup Data</b> in the USB protocol.
|
||||
* @param timeout Timeout duration, in milliseconds.
|
||||
* @param data Data to be transferred.
|
||||
* @param dataLen Data length.
|
||||
* @return <b>0</b> 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 <b>OH_Usb_CreateDeviceMemMap</b>.
|
||||
* @return <b>0</b> 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
|
||||
* <b>OH_Usb_DestroyDeviceMemMap</b> 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 <b>0</b> 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 <b>OH_Usb_CreateDeviceMemMap</b>.
|
||||
* @since 10
|
||||
* @version 1.0
|
||||
*/
|
||||
void OH_Usb_DestroyDeviceMemMap(UsbDeviceMemMap *devMmap);
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // USB_DDK_API_H
|
316
drivers/external_device_manager/usb/usb_ddk_types.h
Normal file
316
drivers/external_device_manager/usb/usb_ddk_types.h
Normal file
@ -0,0 +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 <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
/**
|
||||
* @brief Setup data for control transfer. It corresponds to <b>Setup Data</b> 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 <b>Standard Device Descriptor</b> 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 <b>Standard Configuration Descriptor</b>\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 <b>Standard Interface Descriptor</b>
|
||||
* 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 <b>Standard Endpoint Descriptor</b> 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 <b>OH_Usb_CreateDeviceMemMap</b>.\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
|
29
global/resource_management/BUILD.gn
Normal file
29
global/resource_management/BUILD.gn
Normal file
@ -0,0 +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",
|
||||
]
|
||||
}
|
102
global/resource_management/include/raw_dir.h
Normal file
102
global/resource_management/include/raw_dir.h
Normal file
@ -0,0 +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 <b>NULL</b> 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
|
173
global/resource_management/include/raw_file.h
Normal file
173
global/resource_management/include/raw_file.h
Normal file
@ -0,0 +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 <string>
|
||||
|
||||
#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 <b>length</b> 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 <b>0</b> 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
|
||||
* <b>0</b>: The new read/write position is set to <b>offset</b>. \n
|
||||
* <b>1</b>: The read/write position is set to the current position plus <b>offset</b>. \n
|
||||
* <b>2</b>: The read/write position is set to the end of file (EOF) plus <b>offset</b>.
|
||||
* @return Returns the new read/write position if the operation is successful; returns <b>(long) -1</b> 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
|
126
global/resource_management/include/raw_file_manager.h
Normal file
126
global/resource_management/include/raw_file_manager.h
Normal file
@ -0,0 +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
|
||||
* <b>ResourceManager</b> 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
|
44
global/resource_management/librawfile.ndk.json
Normal file
44
global/resource_management/librawfile.ndk.json
Normal file
@ -0,0 +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"
|
||||
}
|
||||
]
|
36
graphic/graphic_2d/EGL/BUILD.gn
Normal file
36
graphic/graphic_2d/EGL/BUILD.gn
Normal file
@ -0,0 +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 = [
|
||||
"//third_party/EGL/api/EGL/egl.h",
|
||||
"//third_party/EGL/api/EGL/eglext.h",
|
||||
"//third_party/EGL/api/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",
|
||||
]
|
||||
}
|
46
graphic/graphic_2d/EGL/libEGL.ndk.json
Normal file
46
graphic/graphic_2d/EGL/libEGL.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
38
graphic/graphic_2d/GLES3/BUILD.gn
Normal file
38
graphic/graphic_2d/GLES3/BUILD.gn
Normal file
@ -0,0 +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 = [
|
||||
"//third_party/openGLES/api/GLES3/gl3.h",
|
||||
"//third_party/openGLES/api/GLES3/gl31.h",
|
||||
"//third_party/openGLES/api/GLES3/gl32.h",
|
||||
"//third_party/openGLES/api/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",
|
||||
]
|
||||
}
|
360
graphic/graphic_2d/GLES3/libGLESv3.ndk.json
Normal file
360
graphic/graphic_2d/GLES3/libGLESv3.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
20
graphic/graphic_2d/KHR/BUILD.gn
Normal file
20
graphic/graphic_2d/KHR/BUILD.gn
Normal file
@ -0,0 +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 = [ "//third_party/EGL/api/KHR/khrplatform.h" ]
|
||||
}
|
28
graphic/graphic_2d/native_buffer/BUILD.gn
Normal file
28
graphic/graphic_2d/native_buffer/BUILD.gn
Normal file
@ -0,0 +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 = [ "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/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" ]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
50
graphic/graphic_2d/native_drawing/BUILD.gn
Normal file
50
graphic/graphic_2d/native_drawing/BUILD.gn
Normal file
@ -0,0 +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 = [
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_bitmap.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_brush.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_canvas.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_color.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_font_collection.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_path.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_pen.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_text_declaration.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/drawing_text_typography.h",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include/c/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",
|
||||
]
|
||||
}
|
85
graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
Normal file
85
graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
28
graphic/graphic_2d/native_image/BUILD.gn
Normal file
28
graphic/graphic_2d/native_image/BUILD.gn
Normal file
@ -0,0 +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 = [ "//foundation/graphic/graphic_2d/interfaces/inner_api/surface/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" ]
|
||||
}
|
10
graphic/graphic_2d/native_image/libnative_image.ndk.json
Normal file
10
graphic/graphic_2d/native_image/libnative_image.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
28
graphic/graphic_2d/native_vsync/BUILD.gn
Normal file
28
graphic/graphic_2d/native_vsync/BUILD.gn
Normal file
@ -0,0 +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 = [ "//foundation/graphic/graphic_2d/interfaces/inner_api/composer/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" ]
|
||||
}
|
5
graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json
Normal file
5
graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json
Normal file
@ -0,0 +1,5 @@
|
||||
[
|
||||
{ "name": "OH_NativeVSync_Create" },
|
||||
{ "name": "OH_NativeVSync_Destroy" },
|
||||
{ "name": "OH_NativeVSync_RequestFrame" }
|
||||
]
|
35
graphic/graphic_2d/native_window/BUILD.gn
Normal file
35
graphic/graphic_2d/native_window/BUILD.gn
Normal file
@ -0,0 +1,35 @@
|
||||
# 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")
|
||||
import("//foundation/graphic/graphic_2d/graphic_config.gni")
|
||||
|
||||
ohos_ndk_headers("native_window_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/native_window"
|
||||
sources = [
|
||||
"$graphic_2d_root/frameworks/surface/include/buffer_handle.h",
|
||||
"$graphic_2d_root/interfaces/inner_api/surface/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",
|
||||
]
|
||||
}
|
18
graphic/graphic_2d/native_window/libnative_window.ndk.json
Normal file
18
graphic/graphic_2d/native_window/libnative_window.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
38
graphic/graphic_2d/vulkan/BUILD.gn
Normal file
38
graphic/graphic_2d/vulkan/BUILD.gn
Normal file
@ -0,0 +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 = [
|
||||
"//third_party/vulkan-headers/include/vulkan/vk_platform.h",
|
||||
"//third_party/vulkan-headers/include/vulkan/vulkan.h",
|
||||
"//third_party/vulkan-headers/include/vulkan/vulkan_core.h",
|
||||
"//third_party/vulkan-headers/include/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",
|
||||
]
|
||||
}
|
248
graphic/graphic_2d/vulkan/libvulkan.ndk.json
Normal file
248
graphic/graphic_2d/vulkan/libvulkan.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
31
hiviewdfx/hiappevent/BUILD.gn
Normal file
31
hiviewdfx/hiappevent/BUILD.gn
Normal file
@ -0,0 +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",
|
||||
]
|
||||
}
|
374
hiviewdfx/hiappevent/include/hiappevent/hiappevent.h
Normal file
374
hiviewdfx/hiappevent/include/hiappevent/hiappevent.h
Normal file
@ -0,0 +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.
|
||||
*
|
||||
* <p>Event domain: a string used to identify the domain of event logging.
|
||||
* <p>Event name: a string used to identify the event name of event logging.
|
||||
* <p>Event type: FAULT, STATISTIC, SECURITY, BEHAVIOR.
|
||||
* <p>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:
|
||||
* <pre>
|
||||
* #include "hiappevent/hiappevent.h"
|
||||
* </pre>
|
||||
* 01 create a ParamList pointer.
|
||||
* <pre>
|
||||
* ParamList list = OH_HiAppEvent_CreateParamList();
|
||||
* </pre>
|
||||
* 02 add params to the ParamList.
|
||||
* <pre>
|
||||
* 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]));
|
||||
* </pre>
|
||||
* 03 performing event logging.
|
||||
* <pre>
|
||||
* int res = OH_HiAppEvent_Write("test_domain", "test_event", BEHAVIOR, list);
|
||||
* </pre>
|
||||
* 04 destroy the ParamList pointer.
|
||||
* <pre>
|
||||
* OH_HiAppEvent_DestroyParamList(list);
|
||||
* </pre>
|
||||
*
|
||||
* @since 8
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#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
|
75
hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h
Normal file
75
hiviewdfx/hiappevent/include/hiappevent/hiappevent_cfg.h
Normal file
@ -0,0 +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:
|
||||
* <pre>
|
||||
* bool res = OH_HiAppEvent_Configure(MAX_STORAGE, "100M");
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
86
hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h
Normal file
86
hiviewdfx/hiappevent/include/hiappevent/hiappevent_event.h
Normal file
@ -0,0 +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:
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
85
hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h
Normal file
85
hiviewdfx/hiappevent/include/hiappevent/hiappevent_param.h
Normal file
@ -0,0 +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:
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
62
hiviewdfx/hiappevent/libhiappevent.ndk.json
Normal file
62
hiviewdfx/hiappevent/libhiappevent.ndk.json
Normal file
@ -0,0 +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"
|
||||
}
|
||||
]
|
26
hiviewdfx/hilog/BUILD.gn
Normal file
26
hiviewdfx/hilog/BUILD.gn
Normal file
@ -0,0 +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" ]
|
||||
}
|
258
hiviewdfx/hilog/include/hilog/log.h
Normal file
258
hiviewdfx/hilog/include/hilog/log.h
Normal file
@ -0,0 +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
|
||||
* <ul><li>Service domain: used to identify the subsystem and module of a service. Its value is a hexadecimal
|
||||
* integer ranging from 0x0 to 0xFFFF. \n
|
||||
* <li>Log tag: a string used to identify the class, file, or service.</li> \n
|
||||
* <li>Log level: <b>DEBUG</b>, <b>INFO</b>, <b>WARN</b>, <b>ERROR</b>, and <b>FATAL</b></li> \n
|
||||
* <li>Parameter format: a printf format string that starts with a % character, including format specifiers
|
||||
* and variable parameters.</li> \n
|
||||
* <li>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 <b>private</b>.</li></ul> \n
|
||||
*
|
||||
* Sample code:\n
|
||||
* Defining the service domain and log tag:\n
|
||||
* #include <hilog/log.h>\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 <private>, reason:503.\n
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#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, <b>LOG_APP</b> 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
|
||||
* <ul><li><b>DEBUG</b>: used for debugging and disabled from commercial releases</li> \n
|
||||
* <li><b>INFO</b>: used for logging important system running status and steps in key processes</li> \n
|
||||
* <li><b>WARN</b>: 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.</li> \n
|
||||
* <li><b>ERROR</b>: used for logging malfunction that affects user experience and cannot automatically
|
||||
* recover</li>\n
|
||||
* <li><b>FATAL</b>: used for logging major exceptions that have severely affected user experience and should
|
||||
* not occur.</li></ul> \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 <b>LOG_DEBUG</b>, <b>LOG_INFO</b>, <b>LOG_WARN</b>,
|
||||
* <b>LOG_ERROR</b>, and <b>LOG_FATAL</b>.
|
||||
* @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 <b>0</b> or a larger value if the operation is successful; returns a value smaller
|
||||
* than <b>0</b> 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 <b>true</b> if the specified logs can be output; returns <b>false</b> 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
|
8
hiviewdfx/hilog/libhilog.ndk.json
Normal file
8
hiviewdfx/hilog/libhilog.ndk.json
Normal file
@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"name": "OH_LOG_Print"
|
||||
},
|
||||
{
|
||||
"name": "OH_LOG_IsLoggable"
|
||||
}
|
||||
]
|
26
hiviewdfx/hitrace/BUILD.gn
Normal file
26
hiviewdfx/hitrace/BUILD.gn
Normal file
@ -0,0 +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" ]
|
||||
}
|
144
hiviewdfx/hitrace/include/hitrace/trace.h
Normal file
144
hiviewdfx/hitrace/include/hitrace/trace.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Marks the start of a synchronous trace task.
|
||||
*
|
||||
* The <b>OH_HiTrace_StartTrace</b> and <b>OH_HiTrace_FinishTrace</b> 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 <b>OH_HiTrace_StartTrace</b> in pairs. During trace data parsing, the system matches
|
||||
* it with the <b>OH_HiTrace_StartTrace</b> 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 <b>taskId</b> is required to ensure proper data parsing.
|
||||
* It is passed as an input parameter for the asynchronous API.
|
||||
* This API is used with <b>OH_HiTrace_FinishAsyncTrace</b> 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 <b>OH_HiTrace_StartTrace</b>.
|
||||
* 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 <b>OH_HiTrace_StartAsyncTrace</b> in pairs. Its name and task ID must be the same as those of
|
||||
* <b>OH_HiTrace_StartAsyncTrace</b>.
|
||||
*
|
||||
* @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
|
17
hiviewdfx/hitrace/libhitrace.ndk.json
Normal file
17
hiviewdfx/hitrace/libhitrace.ndk.json
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"name": "OH_HiTrace_StartTrace"
|
||||
},
|
||||
{
|
||||
"name": "OH_HiTrace_FinishTrace"
|
||||
},
|
||||
{
|
||||
"name": "OH_HiTrace_StartAsyncTrace"
|
||||
},
|
||||
{
|
||||
"name": "OH_HiTrace_FinishAsyncTrace"
|
||||
},
|
||||
{
|
||||
"name": "OH_HiTrace_CountTrace"
|
||||
}
|
||||
]
|
39
multimedia/audio_framework/BUILD.gn
Normal file
39
multimedia/audio_framework/BUILD.gn
Normal file
@ -0,0 +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/audio_framework/config.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",
|
||||
]
|
||||
}
|
234
multimedia/audio_framework/audio_capturer/native_audiocapturer.h
Normal file
234
multimedia/audio_framework/audio_capturer/native_audiocapturer.h
Normal file
@ -0,0 +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 <time.h>
|
||||
#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
|
232
multimedia/audio_framework/audio_renderer/native_audiorenderer.h
Normal file
232
multimedia/audio_framework/audio_renderer/native_audiorenderer.h
Normal file
@ -0,0 +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 <time.h>
|
||||
#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
|
556
multimedia/audio_framework/common/native_audiostream_base.h
Normal file
556
multimedia/audio_framework/common/native_audiostream_base.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
|
||||
#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
|
206
multimedia/audio_framework/common/native_audiostreambuilder.h
Normal file
206
multimedia/audio_framework/common/native_audiostreambuilder.h
Normal file
@ -0,0 +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
|
41
multimedia/audio_framework/ohaudio.ndk.json
Normal file
41
multimedia/audio_framework/ohaudio.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
274
multimedia/av_codec/BUILD.gn
Normal file
274
multimedia/av_codec/BUILD.gn
Normal file
@ -0,0 +1,274 @@
|
||||
# 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("//foundation/multimedia/av_codec/config.gni")
|
||||
|
||||
group("capi_packages") {
|
||||
deps = []
|
||||
if (av_codec_support_capi) {
|
||||
deps += [
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_adec",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_aenc",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_avdemuxer",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_avmuxer",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_avsource",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_codecbase",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_vdec",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_venc",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
config("av_codec_capi_config") {
|
||||
include_dirs = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/common",
|
||||
"$av_codec_root_dir/interfaces/inner_api/native",
|
||||
"$av_codec_root_dir/interfaces/kits/c",
|
||||
"$av_codec_root_dir/services/dfx/include",
|
||||
"$av_codec_root_dir/services/utils/include",
|
||||
"//foundation/graphic/graphic_2d/frameworks/surface/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-fno-exceptions",
|
||||
"-Wall",
|
||||
"-fno-common",
|
||||
"-fstack-protector-all",
|
||||
"-Wshadow",
|
||||
"-FPIC",
|
||||
"-FS",
|
||||
"-O2",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-Wformat=2",
|
||||
"-Wdate-time",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-std=c++17",
|
||||
"-fno-rtti",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_core") {
|
||||
install_enable = true
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
blocklist = "../../../cfi_blocklist.txt"
|
||||
}
|
||||
|
||||
configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
sources = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/common/native_avformat.cpp",
|
||||
"$av_codec_root_dir/frameworks/native/capi/common/native_avmemory.cpp",
|
||||
]
|
||||
|
||||
if (av_codec_support_codeclist) {
|
||||
sources += [ "$av_codec_root_dir/frameworks/native/capi/common/native_avcapability.cpp" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/services/utils:av_codec_format",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_avmuxer") {
|
||||
install_enable = true
|
||||
sources = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/avcodec/native_avcodec_base.cpp",
|
||||
"$av_codec_root_dir/frameworks/native/capi/avmuxer/native_avmuxer.cpp",
|
||||
"$av_codec_root_dir/frameworks/native/capi/common/native_avformat.cpp",
|
||||
"$av_codec_root_dir/frameworks/native/capi/common/native_avmemory.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/services/utils:av_codec_format",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_avdemuxer") {
|
||||
install_enable = true
|
||||
sources = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/avdemuxer/native_avdemuxer.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/utils:av_codec_format",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_avsource") {
|
||||
install_enable = true
|
||||
sources = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/avsource/native_avsource.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/utils:av_codec_format",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_codecbase") {
|
||||
install_enable = true
|
||||
sources = [
|
||||
"$av_codec_root_dir/frameworks/native/capi/avcodec/native_avcodec_base.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_adec") {
|
||||
install_enable = true
|
||||
sources = [ "$av_codec_root_dir/frameworks/native/capi/avcodec/native_audio_decoder.cpp" ]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_codecbase",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/dfx:av_codec_service_dfx",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_aenc") {
|
||||
install_enable = true
|
||||
sources = [ "$av_codec_root_dir/frameworks/native/capi/avcodec/native_audio_encoder.cpp" ]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_codecbase",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/dfx:av_codec_service_dfx",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_vdec") {
|
||||
install_enable = true
|
||||
sources = [ "$av_codec_root_dir/frameworks/native/capi/avcodec/native_video_decoder.cpp" ]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_codecbase",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/dfx:av_codec_service_dfx",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
||||
|
||||
ohos_shared_library("native_media_venc") {
|
||||
install_enable = true
|
||||
sources = [ "$av_codec_root_dir/frameworks/native/capi/avcodec/native_video_encoder.cpp" ]
|
||||
|
||||
public_configs = [ ":av_codec_capi_config" ]
|
||||
|
||||
deps = [
|
||||
"$av_codec_root_dir/interfaces/inner_api/native:av_codec_client",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_codecbase",
|
||||
"$av_codec_root_dir/interfaces/kits/c:native_media_core",
|
||||
"$av_codec_root_dir/services/dfx:av_codec_service_dfx",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"graphic_2d:surface",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
output_extension = "so"
|
||||
subsystem_name = "multimedia"
|
||||
part_name = "av_codec"
|
||||
}
|
32
multimedia/av_codec/audio_decoder/BUILD.gn
Normal file
32
multimedia/av_codec/audio_decoder/BUILD.gn
Normal file
@ -0,0 +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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_adec_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources =
|
||||
[ "$av_codec_root_dir/interfaces/kits/c/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" ]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
32
multimedia/av_codec/audio_encoder/BUILD.gn
Normal file
32
multimedia/av_codec/audio_encoder/BUILD.gn
Normal file
@ -0,0 +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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_aenc_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources =
|
||||
[ "$av_codec_root_dir/interfaces/kits/c/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" ]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
161
multimedia/av_codec/avcodec_audio_channel_layout.h
Normal file
161
multimedia/av_codec/avcodec_audio_channel_layout.h
Normal file
@ -0,0 +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 <cstdint>
|
||||
#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
|
31
multimedia/av_codec/avdemuxer/BUILD.gn
Normal file
31
multimedia/av_codec/avdemuxer/BUILD.gn
Normal file
@ -0,0 +1,31 @@
|
||||
# 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/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_avdemuxer_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources = [ "$av_codec_root_dir/interfaces/kits/c/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" ]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
30
multimedia/av_codec/avmuxer/BUILD.gn
Normal file
30
multimedia/av_codec/avmuxer/BUILD.gn
Normal file
@ -0,0 +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")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_avmuxer_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources = [ "$av_codec_root_dir/interfaces/kits/c/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" ]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
31
multimedia/av_codec/avsource/BUILD.gn
Normal file
31
multimedia/av_codec/avsource/BUILD.gn
Normal file
@ -0,0 +1,31 @@
|
||||
# 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/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_avsource_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources = [ "$av_codec_root_dir/interfaces/kits/c/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" ]
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
[
|
||||
{ "name": "OH_AVSource_CreateWithURI" },
|
||||
{ "name": "OH_AVSource_CreateWithFD" },
|
||||
{ "name": "OH_AVSource_Destroy" },
|
||||
{ "name": "OH_AVSource_GetSourceFormat" },
|
||||
{ "name": "OH_AVSource_GetTrackFormat" }
|
||||
]
|
38
multimedia/av_codec/codec_base/BUILD.gn
Normal file
38
multimedia/av_codec/codec_base/BUILD.gn
Normal file
@ -0,0 +1,38 @@
|
||||
# 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")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_codecbase_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources = [
|
||||
"$av_codec_root_dir/interfaces/kits/c/avcodec_audio_channel_layout.h",
|
||||
"$av_codec_root_dir/interfaces/kits/c/native_avcapability.h",
|
||||
"$av_codec_root_dir/interfaces/kits/c/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",
|
||||
]
|
||||
}
|
@ -0,0 +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" }
|
||||
]
|
||||
|
38
multimedia/av_codec/core/BUILD.gn
Normal file
38
multimedia/av_codec/core/BUILD.gn
Normal file
@ -0,0 +1,38 @@
|
||||
# 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")
|
||||
import("//foundation/multimedia/av_codec/config.gni")
|
||||
ohos_ndk_headers("native_media_core_header") {
|
||||
dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
|
||||
sources = [
|
||||
"$av_codec_root_dir/interfaces/kits/c/native_averrors.h",
|
||||
"$av_codec_root_dir/interfaces/kits/c/native_avformat.h",
|
||||
"$av_codec_root_dir/interfaces/kits/c/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",
|
||||
]
|
||||
}
|
26
multimedia/av_codec/core/libnative_media_core.ndk.json
Normal file
26
multimedia/av_codec/core/libnative_media_core.ndk.json
Normal file
@ -0,0 +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" }
|
||||
]
|
356
multimedia/av_codec/native_avcapability.h
Normal file
356
multimedia/av_codec/native_avcapability.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#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
|
224
multimedia/av_codec/native_avcodec_audiodecoder.h
Normal file
224
multimedia/av_codec/native_avcodec_audiodecoder.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#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
|
218
multimedia/av_codec/native_avcodec_audioencoder.h
Normal file
218
multimedia/av_codec/native_avcodec_audioencoder.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#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
|
450
multimedia/av_codec/native_avcodec_base.h
Normal file
450
multimedia/av_codec/native_avcodec_base.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#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
|
249
multimedia/av_codec/native_avcodec_videodecoder.h
Normal file
249
multimedia/av_codec/native_avcodec_videodecoder.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#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
|
265
multimedia/av_codec/native_avcodec_videoencoder.h
Normal file
265
multimedia/av_codec/native_avcodec_videoencoder.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#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
|
117
multimedia/av_codec/native_avdemuxer.h
Normal file
117
multimedia/av_codec/native_avdemuxer.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#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
|
79
multimedia/av_codec/native_averrors.h
Normal file
79
multimedia/av_codec/native_averrors.h
Normal file
@ -0,0 +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
|
278
multimedia/av_codec/native_avformat.h
Normal file
278
multimedia/av_codec/native_avformat.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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
|
71
multimedia/av_codec/native_avmemory.h
Normal file
71
multimedia/av_codec/native_avmemory.h
Normal file
@ -0,0 +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 <stdint.h>
|
||||
#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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user