提交 1142d67e 编写于 作者: H HelloCrease

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs...

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs into OpenHarmony-3.2-Release
......@@ -33,6 +33,7 @@ As shown above, the **app.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:<br>- Consists of letters, digits, underscores (_), and periods (.).<br>- Starts with a letter.<br>- Contains 7 to 127 bytes.<br>You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.<br>If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No|
| bundleType| Bundle type, which is used to distinguish applications and atomic services.<br>- **app**: The bundle is a common application.<br>- **atomicService**: The bundle is an atomic service. | String| Yes (initial value: **"app"**)|
| debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.<br>- **true**: The application can be debugged.<br>- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)|
| icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No|
| label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No|
......
# Atomic Service
## Pre-loading by HAP Type
### HAP File Implementation
To speed up the initial startup of an atomic service, you can configure it to load on demand with the use of HAP files. HAP files of an atomic service are classified as entry-type or feature-type. The entry-type HAP file contains the page code and related resources required for starting up the atomic service. The feature-type HAP files contain the rest of the code and resources. To start the atomic service, the user only needs to download and install the entry-type HAP file, which minimizes the time for downloading the atomic service.
#### How to Use
You create HAP files of an atomic service by creating an atomic service project in DevEco Studio. The basic project directory structure is as follows:
```
├── AppScope
| ├── resources
| └── app.json5
├── entry
| └── src/main
| ├── ets
| ├── resources
| └── module.json5
├── feature
| └── src/main
| ├── ets
| ├── resources
| └── module.json5
├── library
| └── src/main
| ├── ets
| ├── resources
| └── module.json5
├── node_modules
```
Note that you must set the **bundleType** field to **atomicService** in the [app.json5](app-configuration-file.md) file, which is located in the **AppScope** folder. The following is an example of the file content:
```json
{
"app": {
"bundleName": "com.example.hmservice",
"bundleType":"atomicService",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"targetAPIVersion": 9
}
}
```
For details about HAP files, see [Multi-HAP Design Objectives](multi-hap-objective.md).
#### Restrictions
1. The **installationFree** field must be set to **true** in each module-specific configuration file [module.json5](module-configuration-file.md) file.
2. When packaging an atomic service, comply with the following size rules:
- The total size of HAP files cannot exceed 10 MB.
- The size of a HAP file itself and all its dependent [HSP](in-app-hsp.md) cannot exceed 2 MB.
### Pre-loading Implementation
You can configure the system to automatically pre-download required modules when the atomic service enters a module, thereby speeding up module access.
Currently, pre-loading can be implemented only through configuration, not by invoking APIs.
#### How to Use
Pre-loading is triggered after the first frame of the newly accessed module is rendered. You can configure what to pre-load for a module, by setting the **preloads** field under **atomicService** in the [module.json5](module-configuration-file.md) file of the module. The following is an example of the **module.json5** file of the **entry** module, saved in **entry/src/main**:
```json
{
"module": {
"name": "entry",
"type": "entry",
"srcEnty": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": true,
"pages": "$profile:main_pages",
"atomicService": {
"preloads": [
{
"moduleName": "feature"
}
]
},
"abilities": [
{
"name": "MainAbility",
"srcEnty": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
```
In this example, the system automatically pre-loads the **feature** module after the first frame of the **entry** module is rendered.
#### Restrictions
[moduleType](../reference/apis/js-apis-bundleManager.md#moduletype) corresponding to moduleName in the **preloads** list cannot be entry.
## Using Dynamic Shared Packages in Atomic Services
A [Harmony Shared Package (HSP)](shared-guide.md) is a dynamic shared package for sharing code, C++ libraries, resources, and configuration files among modules.
For details about how to use the HSP within an atomic service, see [In-Application HSP Development](in-app-hsp.md).
#### How to Use
Assume that the project directory structure is as follows:
```
├── AppScope
| ├── resources
| └── app.json5
├── entry
| └── src/main
| ├── ets
| ├── entryAbility
| └── pages
| └── Index.ets
| ├── resources
| └── module.json5
├── feature
| └── src/main
| ├── ets
| ├── resources
| └── module.json5
├── library
| └── src/main
| ├── ets
| └── pages
| └── menu.ets
| ├── resources
| └── module.json5
├── node_modules
```
If you want to add a button in the **entry** module to jump to the menu page (**library/src/main/ets/pages/menu.ets**) in the **library** module, you can write the following code in the **entry/src/main/ets/MainAbility/Index.ets** file of the **entry** module:
```ts
import router from '@ohos.router';
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
// Add a button to respond to user clicks.
Button() {
Text('click to menu')
.fontSize(30)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('40%')
.height('5%')
// Bind click events.
.onClick(() => {
router.pushUrl({
url: '@bundle:com.example.hmservice/library/ets/pages/menu'
}).then(() => {
console.log("push page success");
}).catch(err => {
console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
})
})
.width('100%')
}
.height('100%')
}
}
}
```
The input parameter **url** of the **router.pushUrl** API is as follows:
```ets
'@bundle:com.example.hmservice/library/ets/pages/menu'
```
The **url** content template is as follows:
```ets
'@bundle:bundle name/module name/path/page file name (without the extension .ets)'
```
......@@ -87,6 +87,8 @@ As shown above, the **module.json5** file contains several tags.
| [extensionAbilities](#extensionabilities) | ExtensionAbility configuration of the module, which is valid only for the current ExtensionAbility component.| Object| Yes (initial value: left empty)|
| [requestPermissions](#requestpermissions) | A set of permissions that the application needs to request from the system for running correctly.| Object| Yes (initial value: left empty)|
| [testRunner](#testrunner) | Test runner configuration of the module.| Object| Yes (initial value: left empty)|
| [atomicService](#atomicservice)| Atomic service configuration.| Object| Yes (initial value: left empty) |
| [dependencies](#dependencies)| List of shared libraries on which the current module depends during running.| Object array| Yes (initial value: left empty) |
## deviceTypes
......@@ -206,10 +208,13 @@ UIAbility configuration of the module, which is valid only for the current UIAbi
The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system uses the icon specified in the **app.json** file as the application icon and displays it on the home screen.
Touching this icon will direct the user to the application details screen in **Settings**.
Touching this icon will direct the user to the application details screen in **Settings**, as shown in Figure 1.
To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
**Objectives**:
This requirement on application icons is intended to prevent malicious applications from deliberately configuring no icon to block uninstallation attempts.
**Setting the application icon to be displayed on the home screen**:
......@@ -231,37 +236,39 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
}]
}],
...
}
}
```
**Querying an application icon:**
* The HAP file contains ability configuration.
* The application icon is set under **abilities** in the **module.json5** file.
**Display rules of application icons and labels on the home screen:**
* The HAP file contains UIAbility configuration.
* The application icon on the home screen is set under **abilities** in the **module.json5** file.
* The application does not have the privilege to hide its icon from the home screen.
* The returned home screen icon is the icon configured for the ability.
* The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned.
* The returned component name is the component name of the ability.
* When the user touches the home screen icon, the home screen of the ability is displayed.
* The application icon displayed on the home screen is the icon configured for the UIAbility.
* The application label displayed on the home screen is the label configured for the UIAbility. If no label is configured, the bundle name is returned.
* The name of the UIAbility is displayed.
* When the user touches the home screen icon, the home screen of the UIAbility is displayed.
* The application has the privilege to hide its icon from the home screen.
* The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
* The application icon is not set under **abilities** in the **module.json5** file.
* The application icon on the home screen is not set under **abilities** in the **module.json5** file.
* The application does not have the privilege to hide its icon from the home screen.
* The returned home screen icon is the icon configured under **app**. (The **icon** parameter in the **app.json** file is mandatory.)
* The returned home screen label is the label configured under **app**. (The **label** parameter in the **app.json** file is mandatory.)
* The returned component name is the component name displayed on the application details screen (this component is built in the system).
* Touching the home screen icon will direct the user to the application details screen.
* The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.)
* The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.)
* Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1.
* The application has the privilege to hide its icon from the home screen.
* The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
* The HAP file does not contain ability configuration.
* The HAP file does not contain UIAbility configuration.
* The application does not have the privilege to hide its icon from the home screen.
* The returned home screen icon is the icon configured under **app**. (The **icon** parameter in the **app.json** file is mandatory.)
* The returned home screen label is the label configured under **app**. (The **label** parameter in the **app.json** file is mandatory.)
* The returned component name is the component name displayed on the application details screen (this component is built in the system).
* Touching the home screen icon will direct the user to the application details screen.
* The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.)
* The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.)
* Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1.
* The application has the privilege to hide its icon from the home screen.
* The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
* The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.<br><br>
**Figure 1** Application details screen
![Application details screen](figures/application_details.jpg)
**Table 4** abilities
......@@ -396,38 +403,6 @@ Example of the **skills** structure:
}
```
**Enhanced implicit query**
URI-level prefix matching is supported.
When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in.
* The query enhancement involves the following APIs:
[@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)<br>
1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback<Array\<AbilityInfo>>): void;<br>
2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void;<br>
3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise<Array\<AbilityInfo>>;
* Configuration requirements<br>
abilities -> skills -> uris object<br>
Configuration 1: only **scheme = 'http'**<br>
Configuration 2: only **(scheme = 'http') + (host = 'example.com')**<br>
Configuration 3: only **(scheme = 'http') + (host = 'example.com') + (port = '8080')**
* Prefix match<br>
If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API:
1. uri = 'https://': No matches<br>
2. uri = 'http://': Matches configuration 1<br>
3. uri = 'https://example.com': No matches<br>
4. uri = 'https://exa.com': No matches<br>
5. uri = 'http://exa.com': Matches configuration 1<br>
6. uri = 'http://example.com': Matches configuration 1 and configuration 2<br>
7. uri = 'https://example.com:8080': No matches<br>
8. uri = 'http://exampleaa.com:8080': Matches configuration 1<br>
9. uri = 'http://example.com:9180': Matches configuration 1 and configuration 2<br>
10. uri = 'http://example.com:8080': Matches configuration 1, configuration 2, and configuration 3<br>
11. uri = 'https://example.com:9180/path': No matches<br>
12. uri = 'http://exampleap.com:8080/path': Matches configuration 1<br>
13. uri = 'http://example.com:9180/path': Matches configuration 1 and configuration 2<br>
14. uri = 'http://example.com:8080/path': Matches configuration 1, configuration 2, and configuration 3<br>
## extensionAbilities
......@@ -461,7 +436,7 @@ Example of the **extensionAbilities** structure:
"icon": "$media:icon",
"label" : "$string:extension_name",
"description": "$string:form_description",
"type": "form",
"type": "form",
"permissions": ["ohos.abilitydemo.permission.PROVIDER"],
"readPermission": "",
"writePermission": "",
......@@ -475,7 +450,7 @@ Example of the **extensionAbilities** structure:
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config",
"resource": "$profile:form_config",
}
]
}
......@@ -534,7 +509,7 @@ The **shortcut** information is identified in **metadata**, where:
- **resource** indicates where the resources of the shortcut are stored.
| Attribute| Description| Data Type | Default Value|
| Name| Description| Data Type | Default Value|
| -------- | -------- | -------- | -------- |
| shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No|
| label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
......@@ -705,7 +680,7 @@ The **testRunner** tag represents the supported test runner.
| name | Name of the test runner object. The value is a string with a maximum of 255 bytes.| String| No|
| srcPath | Code path of the test runner. The value is a string with a maximum of 255 bytes.| String| No|
Example of the / structure:
Example of the **testRunner** structure:
```json
......@@ -719,3 +694,80 @@ Example of the / structure:
}
}
```
## atomicService
The **atomicService** tag represents the atomic service configuration. It is available only when **bundleType** is set to **atomicService** in the **app.json** file.
**Table 18** Internal structure of the atomicService tag
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| preloads | List of modules to pre-load.| Object array| Yes (initial value: left empty)|
Example of the **atomicService** structure:
```json
{
"module": {
"atomicService": {
"preloads":[
{
"moduleName":"feature"
}
]
}
}
}
```
## preloads
The **preloads** tag represents a list of modules to pre-load in an atomic service.
**Table 19** Internal structure of the preloads tag
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| moduleName | Name of the module to be preloaded when the current module is loaded in the atomic service.| String| No|
Example of the **preloads** structure:
```json
{
"module": {
"atomicService": {
"preloads":[
{
"moduleName":"feature"
}
]
}
}
}
```
## dependencies
The **dependencies** tag identifies the list of shared libraries that the module depends on when it is running.
**Table 20** Internal structure of the dependencies tag
| Name | Description | Data Type| Initial Value Allowed|
| ----------- | ------------------------------ | -------- | ---------- |
| moduleName | Module name of the shared bundle on which the current module depends.| String | No|
Example of the **dependencies** structure:
```json
{
"module": {
"dependencies": [
{
"moduleName": "library"
}
]
}
}
```
......@@ -233,7 +233,7 @@
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
- [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md)
- [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md)
- [@ohos.file.fileuri (File URI)](js-apis-file-fileuri.md)
- [@ohos.file.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.picker (Picker)](js-apis-file-picker.md)
......
......@@ -118,8 +118,8 @@ if (!hasHceCap) {
}
var elementName = {
"bundleName": "com.test.cardemulation",
"abilityName": "com.test.cardemulation.MainAbility",
"bundleName": "com.example.myapplication",
"abilityName": "EntryAbility",
};
var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
console.log('is the app is default service for this card type: ' + isDefaultService);
......
# @ohos.data.relationalStore (RDB Store)
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.
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. The worker threads are not supported.
The **relationalStore** module provides the following functions:
......@@ -317,6 +317,10 @@ Defines the RDB store configuration.
Enumerates the RDB store security levels.
> **NOTE**
>
> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Cross-Device Data Synchronization Mechanism](../../database/sync-app-data-across-devices-overview.md#cross-device-data-synchronization-mechanism).
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Value | Description |
......@@ -424,6 +428,7 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceIds = [];
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -432,7 +437,6 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
......@@ -1231,7 +1235,7 @@ predicates.notIn("NAME", ["Lisa", "Rose"]);
Provides methods to manage an RDB store.
Before using the following APIs, use [executeSql](#executesql) to initialize the database table structure and related data. For details, see [RDB Development](../../database/database-relational-guidelines.md).
Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data.
### insert
......@@ -1868,6 +1872,7 @@ Queries data from the RDB store of a remote device based on specified conditions
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceId = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -1876,7 +1881,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
deviceId = devices[0].deviceId;
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
......@@ -1925,6 +1930,7 @@ Queries data from the RDB store of a remote device based on specified conditions
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceId = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -1933,12 +1939,12 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
deviceId = devices[0].deviceId;
})
let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
predicates.greaterThan("id", 0);
let promise = store.remoteQuery("deviceId", "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
let promise = store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`);
......@@ -1957,11 +1963,11 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. |
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.|
| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned. |
**Example**
......@@ -1986,10 +1992,10 @@ Queries data using the specified SQL statement. This API uses a promise to retur
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | --------------------- |
| sql | string | Yes | SQL statement to run.|
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No | Arguments in the SQL statement. |
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank.|
**Return value**
......@@ -2000,7 +2006,7 @@ Queries data using the specified SQL statement. This API uses a promise to retur
**Example**
```js
let promise = store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo']);
let promise = store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'");
promise.then((resultSet) => {
console.info(`ResultSet column names: ${resultSet.columnNames}`);
console.info(`ResultSet column count: ${resultSet.columnCount}`);
......@@ -2019,22 +2025,22 @@ Executes an SQL statement that contains specified arguments but returns no value
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ---------------------- |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
store.executeSql(SQL_CREATE_TABLE, null, function(err) {
const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
store.executeSql(SQL_DELETE_TABLE, ['zhangsan'], function(err) {
if (err) {
console.error(`ExecuteSql failed, err: ${err}`);
return;
}
console.info(`Create table done.`);
console.info(`Delete table done.`);
})
```
......@@ -2048,10 +2054,10 @@ Executes an SQL statement that contains specified arguments but returns no value
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | --------------------- |
| sql | string | Yes | SQL statement to run.|
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No | Arguments in the SQL statement. |
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| sql | string | Yes | SQL statement to run. |
| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank.|
**Return value**
......@@ -2062,10 +2068,10 @@ Executes an SQL statement that contains specified arguments but returns no value
**Example**
```js
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = store.executeSql(SQL_CREATE_TABLE);
const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
let promise = store.executeSql(SQL_DELETE_TABLE);
promise.then(() => {
console.info(`Create table done.`);
console.info(`Delete table done.`);
}).catch((err) => {
console.error(`ExecuteSql failed, err: ${err}`);
})
......@@ -2384,6 +2390,7 @@ Obtains the distributed table name of a remote device based on the local table n
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceId = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -2392,7 +2399,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
deviceId = devices[0].deviceId;
})
store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) {
......@@ -2436,6 +2443,7 @@ Obtains the distributed table name of a remote device based on the local table n
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceId = null;
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -2444,7 +2452,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceId = devices[0].deviceId;
deviceId = devices[0].deviceId;
})
let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE");
......@@ -2478,6 +2486,7 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceIds = [];
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -2486,7 +2495,6 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
......@@ -2534,6 +2542,7 @@ Synchronizes data between devices. This API uses a promise to return the result.
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null;
let deviceIds = [];
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) {
......@@ -2542,7 +2551,6 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync();
let deviceIds = [];
for (var i = 0; i < devices.length; i++) {
deviceIds[i] = devices[i].deviceId;
}
......
# @ohos.file.fileUri (File URI)
# @ohos.file.fileuri (File URI)
The **fileUri** module allows the uniform resource identifier (URI) of a file to be obtained based on the file path. With the file URI, you can use the APIs provided by [@ohos.file.fs](js-apis-file-fs.md) to operate the file.
......@@ -9,7 +9,7 @@ The **fileUri** module allows the uniform resource identifier (URI) of a file to
## Modules to Import
```js
import fileUri from "@ohos.file.fileUri";
import fileuri from "@ohos.file.fileuri";
```
Before using this module, you need to obtain the path of the file in the application sandbox. The following is an example:
......@@ -57,5 +57,5 @@ For details about the error codes, see [File Management Error Codes](../errorcod
```js
let filePath = pathDir + "test.txt";
let uri = fileUri.getUriFromPath(filePath);
let uri = fileuri.getUriFromPath(filePath);
```
......@@ -32,6 +32,7 @@ isNfcAvailable(): boolean
Checks whether the device supports NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use canIUse("SystemCapability.Communication.NFC.Core").
**System capability**: SystemCapability.Communication.NFC.Core
......@@ -50,6 +51,7 @@ openNfc(): boolean
Opens NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [enableNfc](#controllerenablenfc9).
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
......@@ -64,9 +66,9 @@ Opens NFC.
## controller.enableNfc<sup>9+</sup>
enableNfc(): boolean
enableNfc(): void
Opens NFC.
Enables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
......@@ -87,6 +89,7 @@ closeNfc(): boolean
Closes NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [disableNfc](#controllerdisablenfc9).
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
......@@ -101,9 +104,9 @@ Closes NFC.
## controller.disableNfc<sup>9+</sup>
disableNfc(): boolean
disableNfc(): void
Closes NFC.
Disables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
......@@ -172,7 +175,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.|
| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
**Example**
......@@ -180,7 +183,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
```js
import controller from '@ohos.nfc.controller';
// Register the callback to receive NFC state change notifications.
// Register a callback to receive the NFC state change notification.
controller.on("nfcStateChange", (err, nfcState)=> {
if (err) {
console.log("controller on callback err: " + err);
......@@ -189,7 +192,7 @@ controller.on("nfcStateChange", (err, nfcState)=> {
}
});
// Open NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
// Open NFC. The ohos.permission.MANAGE_SECURE_SETTINGS permission is required.
if (!controller.isNfcOpen()) {
var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret);
......@@ -203,7 +206,7 @@ try {
console.log("controller enableNfc busiError: " + busiError);
}
// Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
// Close NFC. The ohos.permission.MANAGE_SECURE_SETTINGS permission is required.
if (controller.isNfcOpen()) {
var ret = controller.closeNfc();
console.log("controller closeNfc ret: " + ret);
......
......@@ -96,7 +96,7 @@ Connects to this tag. Call this API to set up a connection before reading data f
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -154,7 +154,7 @@ Resets the connection to this tag.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -183,8 +183,6 @@ Checks whether the tag is connected.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.isConnected](#tagsessionisconnected9).
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -211,8 +209,6 @@ isConnected(): boolean
Checks whether the tag is connected.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -287,7 +283,7 @@ Obtains the maximum length of the data that can be sent to this tag.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -357,7 +353,7 @@ Obtains the timeout period for sending data to this tag, in milliseconds.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -419,7 +415,7 @@ console.log("tag setSendDataTimeout setStatus: " + setStatus);
setTimeout(timeout: number): void
Obtains the timeout period for sending data to this tag, in milliseconds.
Sets the timeout period for sending data to this tag, in milliseconds.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -435,7 +431,7 @@ Obtains the timeout period for sending data to this tag, in milliseconds.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -555,7 +551,7 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> {
transmit(data: number[]): Promise<number[]>
Sends data to this tag. This API uses a promise to return the result.
Transmits data to this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -565,7 +561,7 @@ Sends data to this tag. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to send. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| data | number[] | Yes| Data to transmit. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**. |
**Return value**
......@@ -577,7 +573,7 @@ Sends data to this tag. This API uses a promise to return the result.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......@@ -616,7 +612,7 @@ try {
transmit(data: number[], callback: AsyncCallback<number[]>): void
Sends data to this tag. This API uses an asynchronous callback to return the result.
Transmits data to this tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -626,14 +622,14 @@ Sends data to this tag. This API uses an asynchronous callback to return the res
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to send. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| data | number[] | Yes| Data to transmit. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**. |
| callback | AsyncCallback<number[]> | Yes| Callback invoked to return the response from the tag. The response consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
......
......@@ -37,10 +37,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| strokeDashArray | Array&lt;Length&gt; | Stroke dashes.<br>Default value: **[]**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeDashOffset | number \| string | Offset of the start point for drawing the stroke.<br>Default value: **0**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the stroke.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.<br>Default value: **LineJoinStyle.Miter**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.<br>Default value: **LineJoinStyle.Miter**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not work for the **\<circle>** component, which does not have corners.|
| strokeMiterLimit | number \| string | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.<br>Default value: **4**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not take effect for the **\<Circle>** component, because it does not have a miter join.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| Stroke opacity.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.|
| strokeWidth | Length | Stroke width.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | Length | Stroke width.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value cannot be a percentage.|
| antiAlias | boolean | Whether anti-aliasing is enabled.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets.|
......
......@@ -37,10 +37,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not work for the **\<ellipse>** component, which does not have corners.|
| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not take effect for the **\<Ellipse>** component, because it does not have a miter join.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.|
| strokeWidth | Length | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | Length | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value cannot be a percentage.|
| antiAlias | boolean | true | Whether anti-aliasing is enabled.<br>Since API version 9, this API is supported in ArkTS widgets.|
......
......@@ -39,10 +39,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| strokeDashArray | Array&lt;Length&gt; | [] | Stroke dashes.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not work for the **\<Line>** component, which does not have corners. |
| strokeMiterLimit | number \| string | 4 | Limit value when the sharp angle is drawn as a miter.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute does not take effect because the **\<Line>** component cannot be used to draw a shape with a sharp angle.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.|
| strokeWidth | Length | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | Length | 1 | Stroke width.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The value cannot be a percentage.|
| antiAlias | boolean | true | Whether anti-aliasing is enabled.<br>Since API version 9, this API is supported in ArkTS widgets.|
## Example
......@@ -58,35 +58,41 @@ struct LineExample {
Column({ space: 10 }) {
// The coordinates of the start and end points of the line are determined relative to the coordinates of the drawing area of the <Line> component.
Line()
.width(200)
.height(150)
.startPoint([0, 0])
.endPoint([50, 100])
.stroke(Color.Black)
.backgroundColor('#F5F5F5')
Line()
.width(200)
.height(200)
.height(150)
.startPoint([50, 50])
.endPoint([150, 150])
.strokeWidth(5)
.stroke(Color.Orange)
.strokeOpacity(0.5)
.backgroundColor('#F5F5F5')
// If the coordinates of a point are beyond the width and height range of the <Line> component, the line will exceed the drawing area.
Line({ width: 50, height: 50 })
// strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered.
Line()
.width(200)
.height(150)
.startPoint([0, 0])
.endPoint([100, 100])
.stroke(Color.Black)
.strokeWidth(3)
.strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5')
// strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered.
Line({ width: 50, height: 50 })
// If the coordinates of a point are beyond the width and height range of the <Line> component, the line will exceed the drawing area.
Line()
.width(50)
.height(50)
.startPoint([0, 0])
.endPoint([100, 100])
.stroke(Color.Black)
.strokeWidth(3)
.strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5')
}
}
......@@ -151,12 +157,16 @@ struct LineExample {
build() {
Column() {
Line()
.width(300)
.height(30)
.startPoint([50, 30])
.endPoint([300, 30])
.stroke(Color.Black)
.strokeWidth(10)
// Set the interval for strokeDashArray to 50.
Line()
.width(300)
.height(30)
.startPoint([50, 20])
.endPoint([300, 20])
.stroke(Color.Black)
......@@ -164,6 +174,8 @@ struct LineExample {
.strokeDashArray([50])
// Set the interval for strokeDashArray to 50, 10.
Line()
.width(300)
.height(30)
.startPoint([50, 20])
.endPoint([300, 20])
.stroke(Color.Black)
......@@ -171,6 +183,8 @@ struct LineExample {
.strokeDashArray([50, 10])
// Set the interval for strokeDashArray to 50, 10, 20.
Line()
.width(300)
.height(30)
.startPoint([50, 20])
.endPoint([300, 20])
.stroke(Color.Black)
......@@ -178,6 +192,8 @@ struct LineExample {
.strokeDashArray([50, 10, 20])
// Set the interval for strokeDashArray to 50, 10, 20, 30.
Line()
.width(300)
.height(30)
.startPoint([50, 20])
.endPoint([300, 20])
.stroke(Color.Black)
......
......@@ -23,7 +23,7 @@ The [universal attributes](js-service-widget-common-attributes.md) are supported
| Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
| color | &lt;color&gt; | - | No| Font color of the modified text.|
| font-size | &lt;length&gt; | 30px | No| Font size of the modified text.|
| font-size | &lt;length&gt; | 16px | No| Font size of the modified text.|
| font-style | string | normal | No| Font style of the modified text. For details, see **font-style** of the [**\<text>**](js-service-widget-basic-text.md#styles) component.|
| font-weight | number \| string | normal | No| Font weight of the modified text. For details, see **font-weight** of the [**\<text>**](js-service-widget-basic-text.md##styles) component.|
| text-decoration | string | none | No| Text decoration of the modified text. For details, see **text-decoration** of the [**\<text>**](js-service-widget-basic-text.md#styles) component.|
......
......@@ -25,7 +25,7 @@ In addition to the [universal styles](js-service-widget-common-styles.md), the f
| Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
| color | &lt;color&gt; | - | No| Font color.|
| font-size | &lt;length&gt; | 30px | No| Font size.|
| font-size | &lt;length&gt; | 16px | No| Font size.|
| letter-spacing | &lt;length&gt; | 0px | No| Character spacing (px).|
| font-style | string | normal | No| Font style. Available values are as follows:<br>- **normal**: standard font style<br>- **italic**: italic font style|
| font-weight | number \| string | normal | No| Font weight. For the number type, the value ranges from 100 to 900. The default value is 400. A larger value indicates a heavier font weight.<br>The value of the number type must be an integer multiple of 100.<br>The value of the string type can be **lighter**, **normal**, **bold**, or **bolder**.|
......
# Native API
- Modules
- [Native XComponent](_o_h___native_x_component.md)
- [HiLog](_hi_log.md)
- [NativeWindow](_native_window.md)
- [Drawing](_drawing.md)
- [Image](image.md)
- [Rawfile](rawfile.md)
- [MindSpore](_mind_spore.md)
- [NeuralNeworkRuntime](_neural_nework_runtime.md)
- [AudioDecoder](_audio_decoder.md)
- [AudioEncoder](_audio_encoder.md)
- [CodecBase](_codec_base.md)
- [VideoDecoder](_video_decoder.md)
- [VideoEncoder](_video_encoder.md)
- [Core](_core.md)
- [HuksKeyApi](_huks_key_api.md)
- [HuksParamSetApi](_huks_param_set_api.md)
- [HuksTypeApi](_huks_type_api.md)
- Header Files
- [drawing_bitmap.h](drawing__bitmap_8h.md)
- [drawing_brush.h](drawing__brush_8h.md)
- [drawing_canvas.h](drawing__canvas_8h.md)
- [drawing_color.h](drawing__color_8h.md)
- [drawing_font_collection.h](drawing__font__collection_8h.md)
- [drawing_path.h](drawing__path_8h.md)
- [drawing_pen.h](drawing__pen_8h.md)
- [drawing_text_declaration.h](drawing__text__declaration_8h.md)
- [drawing_text_typography.h](drawing__text__typography_8h.md)
- [drawing_types.h](drawing__types_8h.md)
- [external_window.h](external__window_8h.md)
- [image_pixel_map_napi.h](image__pixel__map__napi_8h.md)
- [log.h](log_8h.md)
- [native_interface_xcomponent.h](native__interface__xcomponent_8h.md)
- [raw_dir.h](raw__dir_8h.md)
- [raw_file_manager.h](raw__file__manager_8h.md)
- [raw_file.h](raw__file_8h.md)
- [context.h](context_8h.md)
- [data_type.h](data__type_8h.md)
- [format.h](format_8h.md)
- [model.h](model_8h.md)
- [status.h](status_8h.md)
- [tensor.h](tensor_8h.md)
- [types.h](types_8h.md)
- [neural_network_runtime_type.h](neural__network__runtime__type_8h.md)
- [neural_network_runtime.h](neural__network__runtime_8h.md)
- [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md)
- [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md)
- [native_avcodec_base.h](native__avcodec__base_8h.md)
- [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md)
- [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md)
- [native_averrors.h](native__averrors_8h.md)
- [native_avformat.h](native__avformat_8h.md)
- [native_avmemory.h](native__avmemory_8h.md)
- [native_huks_api.h](native__huks__api_8h.md)
- [native_huks_param.h](native__huks__param_8h.md)
- [native_huks_type.h](native__huks__type_8h.md)
- Structs
- [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)
- [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md)
- [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md)
- [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md)
- [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md)
- [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md)
- [OHExtDataHandle](_o_h_ext_data_handle.md)
- [OHHDRMetaData](_o_h_h_d_r_meta_data.md)
- [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md)
- [OhosPixelMapInfo](_ohos_pixel_map_info.md)
- [RawFileDescriptor](_raw_file_descriptor.md)
- [Region](_region.md)
- [Rect](_rect.md)
- [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md)
- [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md)
- [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md)
- [OH_NN_Memory](_o_h___n_n___memory.md)
- [OH_NN_QuantParam](_o_h___n_n___quant_param.md)
- [OH_NN_Tensor](_o_h___n_n___tensor.md)
- [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)
- [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md)
- [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)
- [OH_Huks_Blob](_o_h___huks___blob.md)
- [OH_Huks_CertChain](_o_h___huks___cert_chain.md)
- [OH_Huks_KeyInfo](_o_h___huks___key_info.md)
- [OH_Huks_KeyMaterial25519](_o_h___huks___key_material25519.md)
- [OH_Huks_KeyMaterialDh](_o_h___huks___key_material_dh.md)
- [OH_Huks_KeyMaterialDsa](_o_h___huks___key_material_dsa.md)
- [OH_Huks_KeyMaterialEcc](_o_h___huks___key_material_ecc.md)
- [OH_Huks_KeyMaterialRsa](_o_h___huks___key_material_rsa.md)
- [OH_Huks_Param](_o_h___huks___param.md)
- [OH_Huks_ParamSet](_o_h___huks___param_set.md)
- [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md)
- [OH_Huks_Result](_o_h___huks___result.md)
# AudioDecoder
## Overview
Provides the functions for audio decoding.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding. <br>File to Include: <multimedia/player_framework/native_avcodec_audiodecoder.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. |
| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. |
| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. |
| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. |
| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. |
| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. |
| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. |
| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. |
| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. |
## Function Description
### OH_AudioDecoder_Configure()
```
OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the audio track to be decoded. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_CreateByMime()
```
OH_AVCodec* OH_AudioDecoder_CreateByMime (const char * mime)
```
**Description**<br>
Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). |
**Returns**
Returns the pointer to an **OH_AVCodec** instance.
### OH_AudioDecoder_CreateByName()
```
OH_AVCodec* OH_AudioDecoder_CreateByName (const char * name)
```
**Description**<br>
Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| name | Indicates the pointer to an audio decoder name. |
**Returns**
Returns the pointer to an **OH_AVCodec** instance.
### OH_AudioDecoder_Destroy()
```
OH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec * codec)
```
**Description**<br>
Clears the internal resources of an audio decoder and destroys the audio decoder instance.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_Flush()
```
OH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec * codec)
```
**Description**<br>
Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_FreeOutputData()
```
OH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index )
```
**Description**<br>
Frees an output buffer of an audio decoder.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an output buffer. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_GetOutputDescription()
```
OH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec)
```
**Description**<br>
Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns the handle to an **OH_AVFormat** instance, which must be manually released.
### OH_AudioDecoder_Prepare()
```
OH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec * codec)
```
**Description**<br>
Prepares internal resources for an audio decoder. This API must be called after **Configure**.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_PushInputData()
```
OH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr )
```
**Description**<br>
Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an input buffer. |
| attr | Indicates the attributes of the data contained in the buffer. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_Reset()
```
OH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec * codec)
```
**Description**<br>
Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_SetCallback()
```
OH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData )
```
**Description**<br>
Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_SetParameter()
```
OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| format | Indicates the handle to an **OH_AVFormat** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_Start()
```
OH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec * codec)
```
**Description**<br>
Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioDecoder_Stop()
```
OH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec * codec)
```
**Description**<br>
Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again.
\@syscap SystemCapability.Multimedia.Media.AudioDecoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
# AudioEncoder
## Overview
Provides the functions for audio encoding.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding. <br>File to Include: <multimedia/player_framework/native_avcodec_audioencoder.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. |
| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. |
| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. |
| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. |
| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. |
| [OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. |
| [OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. |
| [OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. |
| [OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. |
| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. |
| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. |
| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. |
| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. |
## Function Description
### OH_AudioEncoder_Configure()
```
OH_AVErrCode OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| format | Indicates the handle to an **OH_AVFormat** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_CreateByMime()
```
OH_AVCodec* OH_AudioEncoder_CreateByMime (const char * mime)
```
**Description**<br>
Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). |
**Returns**
Returns the pointer to an **OH_AVCodec** instance.
### OH_AudioEncoder_CreateByName()
```
OH_AVCodec* OH_AudioEncoder_CreateByName (const char * name)
```
**Description**<br>
Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| name | Indicates the pointer to an audio encoder name. |
**Returns**
Returns the pointer to an **OH_AVCodec** instance.
### OH_AudioEncoder_Destroy()
```
OH_AVErrCode OH_AudioEncoder_Destroy (OH_AVCodec * codec)
```
**Description**<br>
Clears the internal resources of an audio encoder and destroys the audio encoder instance.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_Flush()
```
OH_AVErrCode OH_AudioEncoder_Flush (OH_AVCodec * codec)
```
**Description**<br>
Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_FreeOutputData()
```
OH_AVErrCode OH_AudioEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index )
```
**Description**<br>
Frees an output buffer of an audio encoder.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an output buffer. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_GetOutputDescription()
```
OH_AVFormat* OH_AudioEncoder_GetOutputDescription (OH_AVCodec * codec)
```
**Description**<br>
Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns the handle to an **OH_AVFormat** instance, which must be manually released.
### OH_AudioEncoder_Prepare()
```
OH_AVErrCode OH_AudioEncoder_Prepare (OH_AVCodec * codec)
```
**Description**<br>
Prepares internal resources for an audio encoder. This API must be called after **Configure**.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_PushInputData()
```
OH_AVErrCode OH_AudioEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr )
```
**Description**<br>
Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an input buffer. |
| attr | Indicates the attributes of the data contained in the buffer. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_Reset()
```
OH_AVErrCode OH_AudioEncoder_Reset (OH_AVCodec * codec)
```
**Description**<br>
Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_SetCallback()
```
OH_AVErrCode OH_AudioEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData )
```
**Description**<br>
Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). |
| userData | Indicates the pointer to user-specific data. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_SetParameter()
```
OH_AVErrCode OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format )
```
**Description**<br>
Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| format | Indicates the handle to an **OH_AVFormat** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_Start()
```
OH_AVErrCode OH_AudioEncoder_Start (OH_AVCodec * codec)
```
**Description**<br>
Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
### OH_AudioEncoder_Stop()
```
OH_AVErrCode OH_AudioEncoder_Stop (OH_AVCodec * codec)
```
**Description**<br>
Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again.
\@syscap SystemCapability.Multimedia.Media.AudioEncoder
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
**Returns**
Returns **AV_ERR_OK** if the operation is successful.
Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails.
# CodecBase
## Overview
Provides the common structs, character constants, and enums for running **OH_AVCodec** instances.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances. <br>File to Include: <multimedia/player_framework/native_avcodec_base.h> |
### Structs
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. |
| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. |
| [OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. |
| [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. |
| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. |
| [OH_MediaType](#oh_mediatype) | Enumerates the media types. |
| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. |
| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {<br/>**AVCODEC_BUFFER_FLAGS_NONE** = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 &lt;&lt; 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 &lt;&lt; 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 &lt;&lt; 2,<br/>AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 &lt;&lt; 3<br/>} | Enumerates the buffer flags of an **OH_AVCodec** instance. |
| [OH_MediaType](#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types. |
| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles. |
| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles. |
### Variables
| Name | Description |
| -------- | -------- |
| [OH_AVCodecBufferAttr::pts](#pts) | Presentation timestamp of the buffer, in microseconds. |
| [OH_AVCodecBufferAttr::size](#size) | Size of the data contained in the buffer, in bytes. |
| [OH_AVCodecBufferAttr::offset](#offset) | Start offset of valid data in the buffer. |
| [OH_AVCodecBufferAttr::flags](#flags) | Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). |
| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). |
| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). |
| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. |
| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. |
| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. |
| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string. |
| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t. |
| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. |
| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. |
| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. |
| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. |
| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). |
| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. |
| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. |
| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). |
| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). |
| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. |
| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. |
| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. |
| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. |
## Type Description
### OH_AACProfile
```
typedef enum OH_AACProfileOH_AACProfile
```
**Description**<br>
Enumerates the AAC profiles.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_AVCodecAsyncCallback
```
typedef struct OH_AVCodecAsyncCallbackOH_AVCodecAsyncCallback
```
**Description**<br>
Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Parameters**
| Name | Description |
| -------- | -------- |
| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror). |
| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged). |
| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata). |
| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata). |
### OH_AVCodecBufferAttr
```
typedef struct OH_AVCodecBufferAttrOH_AVCodecBufferAttr
```
**Description**<br>
Defines the buffer attributes of an **OH_AVCodec** instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_AVCodecBufferFlags
```
typedef enum OH_AVCodecBufferFlagsOH_AVCodecBufferFlags
```
**Description**<br>
Enumerates the buffer flags of an **OH_AVCodec** instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_AVCodecOnError
```
typedef void(* OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *userData)
```
**Description**<br>
Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| errorCode | Indicates an error code. |
| userData | Indicates the pointer to user-specific data. |
### OH_AVCodecOnNeedInputData
```
typedef void(* OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData)
```
**Description**<br>
Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of an input buffer. |
| data | Indicates the pointer to the new input data. |
| userData | Indicates the pointer to user-specific data. |
### OH_AVCodecOnNewOutputData
```
typedef void(* OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData)
```
**Description**<br>
Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| index | Indicates the index of a new output buffer. |
| data | Indicates the pointer to the new output data. |
| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md). |
| userData | Indicates the pointer to user-specific data. |
| userData | specified data |
### OH_AVCodecOnStreamChanged
```
typedef void(* OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *format, void *userData)
```
**Description**<br>
Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Parameters**
| Name | Description |
| -------- | -------- |
| codec | Indicates the pointer to an **OH_AVCodec** instance. |
| format | Indicates the handle to the attributes of the new output stream. |
| userData | Indicates the pointer to user-specific data. |
### OH_AVCProfile
```
typedef enum OH_AVCProfileOH_AVCProfile
```
**Description**<br>
Enumerates the AVC profiles.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_MediaType
```
typedef enum OH_MediaTypeOH_MediaType
```
**Description**<br>
Enumerates the media types.
\@syscap SystemCapability.Multimedia.Media.CodecBase
## Enum Description
### OH_AACProfile
```
enum OH_AACProfile
```
**Description**<br>
Enumerates the AAC profiles.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_AVCodecBufferFlags
```
enum OH_AVCodecBufferFlags
```
**Description**<br>
Enumerates the buffer flags of an **OH_AVCodec** instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
| Name | Description |
| -------- | -------- |
| AVCODEC_BUFFER_FLAGS_EOS | The buffer contains an end-of-stream frame. |
| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains a sync frame. |
| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The buffer contains part of a frame. |
| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data. |
### OH_AVCProfile
```
enum OH_AVCProfile
```
**Description**<br>
Enumerates the AVC profiles.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_MediaType
```
enum OH_MediaType
```
**Description**<br>
Enumerates the media types.
\@syscap SystemCapability.Multimedia.Media.CodecBase
| Name | Description |
| -------- | -------- |
| MEDIA_TYPE_AUD | Audio track. |
| MEDIA_TYPE_VID | Video track. |
## Variable Description
### flags
```
uint32_t OH_AVCodecBufferAttr::flags
```
**Description**<br>
Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags).
### offset
```
int32_t OH_AVCodecBufferAttr::offset
```
**Description**<br>
Start offset of valid data in the buffer.
### OH_AVCODEC_MIMETYPE_AUDIO_AAC
```
const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC
```
**Description**<br>
Defines the MIME type for Advanced Audio Coding (AAC).
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_AVCODEC_MIMETYPE_VIDEO_AVC
```
const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC
```
**Description**<br>
Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC).
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_ED_KEY_EOS
```
const char* OH_ED_KEY_EOS
```
**Description**<br>
Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.
### OH_ED_KEY_TIME_STAMP
```
const char* OH_ED_KEY_TIME_STAMP
```
**Description**<br>
Provides unified character descriptors for the auxiliary data of the surface buffer.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_MD_KEY_AUD_CHANNEL_COUNT
```
const char* OH_MD_KEY_AUD_CHANNEL_COUNT
```
**Description**<br>
Character descriptor of the number of audio channels. The value type is uint32_t.
### OH_MD_KEY_AUD_SAMPLE_RATE
```
const char* OH_MD_KEY_AUD_SAMPLE_RATE
```
**Description**<br>
Character descriptor of the audio sampling rate. The value type is uint32_t.
### OH_MD_KEY_AUDIO_SAMPLE_FORMAT
```
const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT
```
**Description**<br>
Character descriptor of the audio sample format. The value type is uint32_t.
### OH_MD_KEY_BITRATE
```
const char* OH_MD_KEY_BITRATE
```
**Description**<br>
Character descriptor of the bit rate. The value type is uint32_t.
### OH_MD_KEY_CODEC_MIME
```
const char* OH_MD_KEY_CODEC_MIME
```
**Description**<br>
Character descriptor of the MIME type. The value type is string.
### OH_MD_KEY_DURATION
```
const char* OH_MD_KEY_DURATION
```
**Description**<br>
Character descriptor of duration. The value type is int64_t.
### OH_MD_KEY_FRAME_RATE
```
const char* OH_MD_KEY_FRAME_RATE
```
**Description**<br>
Character descriptor of the video frame rate. The value type is double.
### OH_MD_KEY_HEIGHT
```
const char* OH_MD_KEY_HEIGHT
```
**Description**<br>
Character descriptor of the video height. The value type is uint32_t.
### OH_MD_KEY_I_FRAME_INTERVAL
```
const char* OH_MD_KEY_I_FRAME_INTERVAL
```
**Description**<br>
Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms.
### OH_MD_KEY_MAX_INPUT_SIZE
```
const char* OH_MD_KEY_MAX_INPUT_SIZE
```
**Description**<br>
Character descriptor of the maximum input size. The value type is uint32_t.
### OH_MD_KEY_PIXEL_FORMAT
```
const char* OH_MD_KEY_PIXEL_FORMAT
```
**Description**<br>
Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).
### OH_MD_KEY_PROFILE
```
const char* OH_MD_KEY_PROFILE
```
**Description**<br>
Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).
### OH_MD_KEY_ROTATION
```
const char* OH_MD_KEY_ROTATION
```
**Description**<br>
Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0.
### OH_MD_KEY_TRACK_TYPE
```
const char* OH_MD_KEY_TRACK_TYPE
```
**Description**<br>
Provides unified character descriptors for the media playback framework.
\@syscap SystemCapability.Multimedia.Media.CodecBase
### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
```
const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
```
**Description**<br>
Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).
### OH_MD_KEY_WIDTH
```
const char* OH_MD_KEY_WIDTH
```
**Description**<br>
Character descriptor of the video width. The value type is uint32_t.
### pts
```
int64_t OH_AVCodecBufferAttr::pts
```
**Description**<br>
Presentation timestamp of the buffer, in microseconds.
### size
```
int32_t OH_AVCodecBufferAttr::size
```
**Description**<br>
Size of the data contained in the buffer, in bytes.
# Core
## Overview
Provides the basic backbone capabilities for the media playback framework, including functions related to the memory, error code, and format carrier.
\@syscap SystemCapability.Multimedia.Media.Core
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media playback framework. <br>File to Include: <multimedia/player_framework/native_averrors.h> |
| [native_avformat.h](native__avformat_8h.md) | Declares the format-related functions and enums. <br>File to Include: <multimedia/player_framework/native_avformat.h> |
| [native_avmemory.h](native__avmemory_8h.md) | Declares the memory-related functions. <br>File to Include: <multimedia/player_framework/native_avmemory.h> |
### Types
| Name | Description |
| -------- | -------- |
| [OH_AVErrCode](#oh_averrcode) | Enumerates the audio and video error codes. |
| [OH_AVPixelFormat](#oh_avpixelformat) | Enumerates the audio and video pixel formats. |
### Enums
| Name | Description |
| -------- | -------- |
| [OH_AVErrCode](#oh_averrcode) {<br/>AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,<br/>AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,<br/>AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100<br/>} | Enumerates the audio and video error codes. |
| [OH_AVPixelFormat](#oh_avpixelformat) {<br/>AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,<br/>AV_PIXEL_FORMAT_RGBA = 5<br/>} | Enumerates the audio and video pixel formats. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_AVFormat_Create](#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading and writing data. |
| [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. |
| [OH_AVFormat_Copy](#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. |
| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. |
| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. |
| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. |
| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. |
| [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an**OH_AVFormat** instance as a string. |
| [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. |
| [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. |
## Type Description
### OH_AVErrCode
```
typedef enum OH_AVErrCodeOH_AVErrCode
```
**Description**<br>
Enumerates the audio and video error codes.
\@syscap SystemCapability.Multimedia.Media.Core
### OH_AVPixelFormat
```
typedef enum OH_AVPixelFormatOH_AVPixelFormat
```
**Description**<br>
Enumerates the audio and video pixel formats.
\@syscap SystemCapability.Multimedia.Media.Core
## Enum Description
### OH_AVErrCode
```
enum OH_AVErrCode
```
**Description**<br>
Enumerates the audio and video error codes.
\@syscap SystemCapability.Multimedia.Media.Core
| Name | Description |
| -------- | -------- |
| AV_ERR_OK | Operation successful. |
| AV_ERR_NO_MEMORY | No memory. |
| AV_ERR_OPERATE_NOT_PERMIT | Invalid parameter. |
| AV_ERR_INVALID_VAL | Invalid value. |
| AV_ERR_IO | I/O error. |
| AV_ERR_TIMEOUT | Timeout. |
| AV_ERR_UNKNOWN | Unknown error. |
| AV_ERR_SERVICE_DIED | Unavailable media service. |
| AV_ERR_INVALID_STATE | Unsupported operation in this state. |
| AV_ERR_UNSUPPORT | Unsupported API. |
| AV_ERR_EXTEND_START | Initial value for extended error codes. |
### OH_AVPixelFormat
```
enum OH_AVPixelFormat
```
**Description**<br>
Enumerates the audio and video pixel formats.
\@syscap SystemCapability.Multimedia.Media.Core
| Name | Description |
| -------- | -------- |
| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar. |
| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 Semi-planar. |
| AV_PIXEL_FORMAT_NV21 | NV21. YVU 420 Semi-planar. |
| AV_PIXEL_FORMAT_SURFACE_FORMAT | Surface. |
| AV_PIXEL_FORMAT_RGBA | RGBA8888. |
## Function Description
### OH_AVFormat_Copy()
```
bool OH_AVFormat_Copy (struct OH_AVFormat * to, struct OH_AVFormat * from )
```
**Description**<br>
Copies the resources from an **OH_AVFormat** instance to another.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| to | Indicates the handle to the **OH_AVFormat** instance to which the data will be copied. |
| from | Indicates the handle to the **OH_AVFormat** instance from which the data will be copied. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_Create()
```
struct OH_AVFormat* OH_AVFormat_Create (void )
```
**Description**<br>
Creates an **OH_AVFormat** instance for reading and writing data.
\@syscap SystemCapability.Multimedia.Media.Core
**Returns**
Returns the handle to an **OH_AVFormat** instance.
### OH_AVFormat_Destroy()
```
void OH_AVFormat_Destroy (struct OH_AVFormat * format)
```
**Description**<br>
Destroys an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
**Returns**
void
### OH_AVFormat_DumpInfo()
```
const char* OH_AVFormat_DumpInfo (struct OH_AVFormat * format)
```
**Description**<br>
Dumps the information contained in an**OH_AVFormat** instance as a string.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
**Returns**
Returns the pointer to a collect of strings, each of which consists of a key and value.
### OH_AVFormat_GetBuffer()
```
bool OH_AVFormat_GetBuffer (struct OH_AVFormat * format, const char * key, uint8_t ** addr, size_t * size )
```
**Description**<br>
Reads data with a specified size from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| addr | Indicates the double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. |
| size | Indicates the pointer to the size of the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetDoubleValue()
```
bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat * format, const char * key, double * out )
```
**Description**<br>
Reads data of the double type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetFloatValue()
```
bool OH_AVFormat_GetFloatValue (struct OH_AVFormat * format, const char * key, float * out )
```
**Description**<br>
Reads data of the float type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetIntValue()
```
bool OH_AVFormat_GetIntValue (struct OH_AVFormat * format, const char * key, int32_t * out )
```
**Description**<br>
Reads data of the int type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetLongValue()
```
bool OH_AVFormat_GetLongValue (struct OH_AVFormat * format, const char * key, int64_t * out )
```
**Description**<br>
Reads data of the long type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the pointer to the data read. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_GetStringValue()
```
bool OH_AVFormat_GetStringValue (struct OH_AVFormat * format, const char * key, const char ** out )
```
**Description**<br>
Reads data of the double type from an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to read. |
| out | Indicates the double pointer to the data read. The data read is updated when **GetString** is called and destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetBuffer()
```
bool OH_AVFormat_SetBuffer (struct OH_AVFormat * format, const char * key, const uint8_t * addr, size_t size )
```
**Description**<br>
Writes data with a specified size to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| addr | Indicates the pointer to the address where the data is written. |
| size | Indicates the size of the data written. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetDoubleValue()
```
bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat * format, const char * key, double value )
```
**Description**<br>
Writes data of the double type to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| value | Indicates the value of the data to write. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetFloatValue()
```
bool OH_AVFormat_SetFloatValue (struct OH_AVFormat * format, const char * key, float value )
```
**Description**<br>
Writes data of the float type to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| value | Indicates the value of the data to write. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetIntValue()
```
bool OH_AVFormat_SetIntValue (struct OH_AVFormat * format, const char * key, int32_t value )
```
**Description**<br>
Writes data of the int type to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| value | Indicates the value of the data to write. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetLongValue()
```
bool OH_AVFormat_SetLongValue (struct OH_AVFormat * format, const char * key, int64_t value )
```
**Description**<br>
Writes data of the long type to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| value | Indicates the value of the data to write. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVFormat_SetStringValue()
```
bool OH_AVFormat_SetStringValue (struct OH_AVFormat * format, const char * key, const char * value )
```
**Description**<br>
Writes data of the string type to an **OH_AVFormat** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| format | Indicates the handle to an **OH_AVFormat** instance. |
| key | Indicates the pointer to the key of the data to write. |
| value | Indicates the pointer to the value of the data to write. |
**Returns**
Returns **TRUE** if the operation is successful.
Returns **FALSE** if the operation fails.
### OH_AVMemory_GetAddr()
```
uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory * mem)
```
**Description**<br>
Obtains the virtual memory address of an **OH_AVMemory** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| mem | Indicates the pointer to an **OH_AVMemory** instance. |
**Returns**
Returns the virtual address if the memory is valid.
Returns a null pointer if the memory is invalid.
### OH_AVMemory_GetSize()
```
int32_t OH_AVMemory_GetSize (struct OH_AVMemory * mem)
```
**Description**<br>
Obtains the memory size of an **OH_AVMemory** instance.
\@syscap SystemCapability.Multimedia.Media.Core
**Parameters**
| Name | Description |
| -------- | -------- |
| mem | Indicates the pointer to an **OH_AVMemory** instance. |
**Returns**
Returns the size if the memory is valid.
Returns **-1** if the memory is invalid.
此差异已折叠。
# HiLog
## Overview
Provides logging functions.
For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level.
\@syscap SystemCapability.HiviewDFX.HiLog
**Since:**
8
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.<br>File to Include: <hilog/log.h> |
### Macros
| Name | Description |
| -------- | -------- |
| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file. |
| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service. |
| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. |
| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. |
| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. |
| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. |
| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. |
### Enums
| Name | Description |
| -------- | -------- |
| [LogType](#logtype) { LOG_APP = 0 } | Enumerates log types. |
| [LogLevel](#loglevel) {<br/>LOG_DEBUG = 3, LOG_INFO = 4, LOG_WARN = 5, LOG_ERROR = 6,<br/>LOG_FATAL = 7<br/>} | Enumerates log levels. |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_LOG_Print](#oh_log_print) ([LogType](#logtype) type, [LogLevel](#loglevel) level, unsigned int domain, const char *tag, const char *fmt,...) \_\_attribute\_\_((\_\_format\_\_(os_log, 5,6))) |Outputs logs. |
| [OH_LOG_IsLoggable](#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. |
## Macro Description
### LOG_DOMAIN
```
#define LOG_DOMAIN 0
```
**Description**<br>
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.
### LOG_TAG
```
#define LOG_TAG NULL
```
**Description**<br>
Defines a string constant used to identify the class, file, or service.
### OH_LOG_DEBUG
```
#define OH_LOG_DEBUG( type, ... ) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
### OH_LOG_ERROR
```
#define OH_LOG_ERROR( type, ... ) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
### OH_LOG_FATAL
```
#define OH_LOG_FATAL( type, ... ) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
### OH_LOG_INFO
```
#define OH_LOG_INFO( type, ... ) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
Outputs INFO 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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
### OH_LOG_WARN
```
#define OH_LOG_WARN( type, ... ) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__))
```
**Description**<br>
Outputs WARN 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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**See**
[OH_LOG_Print](#oh_log_print)
## Enum Description
### LogLevel
```
enum LogLevel
```
**Description**<br>
Enumerates log levels.
You are advised to select log levels based on their respective use cases:
DEBUG: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
INFO: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.
WARN: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations.
ERROR: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.
FATAL: indicates that a program or functionality is about to crash and the fault cannot be rectified.
| Name | Description |
| -------- | -------- |
| LOG_DEBUG | DEBUG level to be used by OH_LOG_DEBUG |
| LOG_INFO | INFO level to be used by OH_LOG_INFO |
| LOG_WARN | WARN level to be used by OH_LOG_WARN |
| LOG_ERROR | ERROR level to be used by OH_LOG_ERROR |
| LOG_FATAL | FATAL level to be used by OH_LOG_FATAL |
### LogType
```
enum LogType
```
**Description**<br>
Enumerates log types.
Currently, only LOG_APP is available.
| Name | Description |
| -------- | -------- |
| LOG_APP | Application log |
## Function Description
### OH_LOG_IsLoggable()
```
int bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level )
```
**Description**<br>
Checks whether logs of the specified service domain, log tag, and log level can be output.
**Parameters**
| Name | Description |
| -------- | -------- |
| domain | Indicates the service domain of logs. |
| tag | Indicates the log tag. |
| level | Indicates the log level. |
**Returns**
Returns **true** if the specified logs can be output; returns **false** otherwise.
### OH_LOG_Print()
```
int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... )
```
**Description**<br>
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.
**Parameters**
| Name | Description |
| -------- | -------- |
| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. |
| level | Indicates the log level, which can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**. |
| domain | Indicates the service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. |
| tag | Indicates the log tag, which is a string used to identify the class, file, or service. |
| 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. |
| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. |
**Returns**
Returns **0** or a larger value if the operation is successful; returns a value smaller than **0** otherwise.
# HuksKeyApi
## Overview
Describes the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and cryptography operations, provided for applications. The keys managed by HUKS can be imported by applications or generated by calling the HUKS APIs.
\@syscap SystemCapability.Security.Huks
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_huks_api.h](native__huks__api_8h.md) | Declares the APIs used to access the HUKS. <br>File to Include: <huks/native_huks/api.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Huks_GetSdkVersion](#oh_huks_getsdkversion) (struct [OH_Huks_Blob](_o_h___huks___blob.md) \*sdkVersion) | Obtains the current HUKS SDK version. |
| [OH_Huks_GenerateKeyItem](#oh_huks_generatekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Generates a key. |
| [OH_Huks_ImportKeyItem](#oh_huks_importkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Imports a key in plaintext. |
| [OH_Huks_ImportWrappedKeyItem](#oh_huks_importwrappedkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappingKeyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappedKeyData) | Imports a wrapped key. |
| [OH_Huks_ExportPublicKeyItem](#oh_huks_exportpublickeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Exports a public key. |
| [OH_Huks_DeleteKeyItem](#oh_huks_deletekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Deletes a key. |
| [OH_Huks_GetKeyItemParamSet](#oh_huks_getkeyitemparamset) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Obtains the attributes of a key. |
| [OH_Huks_IsKeyItemExist](#oh_huks_iskeyitemexist) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether a key exists. |
| [OH_Huks_AttestKeyItem](#oh_huks_attestkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_CertChain](_o_h___huks___cert_chain.md) \*certChain) | Obtain the key certificate chain. |
| [OH_Huks_InitSession](#oh_huks_initsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*challenge) | Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). |
| [OH_Huks_UpdateSession](#oh_huks_updatesession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. |
| [OH_Huks_FinishSession](#oh_huks_finishsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Ends the key session. |
| [OH_Huks_AbortSession](#oh_huks_abortsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Aborts a key session. |
## Function Description
### OH_Huks_AbortSession()
```
struct OH_Huks_Result OH_Huks_AbortSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet )
```
**Description**<br>
Aborts a key session.
**Parameters**
| Name | Description |
| -------- | -------- |
| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). |
| paramSet | Indicates the pointer to the parameters required for aborting the key session. By default, this parameter is a null pointer. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
**See**
[OH_Huks_InitSession](#oh_huks_initsession)
[OH_Huks_UpdateSession](#oh_huks_updatesession)
[OH_Huks_FinishSession](#oh_huks_finishsession)
### OH_Huks_AttestKeyItem()
```
struct OH_Huks_Result OH_Huks_AttestKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_CertChain * certChain )
```
**Description**<br>
Obtain the key certificate chain.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the target key. |
| paramSet | Indicates the pointer to the parameters required for obtaining the key certificate. |
| certChain | Indicates the pointer to the key certificate chain obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_DeleteKeyItem()
```
struct OH_Huks_Result OH_Huks_DeleteKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet )
```
**Description**<br>
Deletes a key.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the key to delete. The alias must be the same as the alias for the key generated. |
| paramSet | Indicates the pointer to the parameters required for deleting the key. By default, this parameter is a null pointer. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_ExportPublicKeyItem()
```
struct OH_Huks_Result OH_Huks_ExportPublicKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * key )
```
**Description**<br>
Exports a public key.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the public key to export. The alias must be the same as the alias for the key generated. |
| paramSet | Indicates the pointer to the parameters required for exporting the public key. |
| key | Indicates the pointer to the public key exported. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_FinishSession()
```
struct OH_Huks_Result OH_Huks_FinishSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData )
```
**Description**<br>
Ends the key session.
**Parameters**
| Name | Description |
| -------- | -------- |
| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). |
| paramSet | Indicates the pointer to the parameters required for the key operation. |
| inData | Indicates the pointer to the data to be processed. |
| outData | Indicates the pointer to the output data. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
**See**
[OH_Huks_InitSession](#oh_huks_initsession)
[OH_Huks_UpdateSession](#oh_huks_updatesession)
[OH_Huks_AbortSession](#oh_huks_abortsession)
### OH_Huks_GenerateKeyItem()
```
struct OH_Huks_Result OH_Huks_GenerateKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut )
```
**Description**<br>
Generates a key.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the key to generate. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| paramSetIn | Indicates the pointer to the parameter set for generating the key. |
| paramSetOut | Indicates the pointer to a temporary key generated. If the generated key is not of a temporary type, this parameter is a null pointer. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_GetKeyItemParamSet()
```
struct OH_Huks_Result OH_Huks_GetKeyItemParamSet (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut )
```
**Description**<br>
Obtains the attributes of a key.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the target key. |
| paramSetIn | Indicates the pointer to the attribute tag required for obtaining the attributes. By default, this parameter is a null pointer. |
| paramSetOut | Indicates the pointer to the attributes obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_GetSdkVersion()
```
struct OH_Huks_Result OH_Huks_GetSdkVersion (struct OH_Huks_Blob * sdkVersion)
```
**Description**<br>
Obtains the current HUKS SDK version.
**Parameters**
| Name | Description |
| -------- | -------- |
| sdkVersion | Indicates the pointer to the SDK version (in string format) obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_ImportKeyItem()
```
struct OH_Huks_Result OH_Huks_ImportKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * key )
```
**Description**<br>
Imports a key in plaintext.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| paramSet | Indicates the pointer to the parameters of the key to import. |
| key | Indicates the pointer to the key to import. The key must be in the format required by the HUKS. For details, see [HuksTypeApi](_huks_type_api.md). |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_ImportWrappedKeyItem()
```
struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_Blob * wrappingKeyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * wrappedKeyData )
```
**Description**<br>
Imports a wrapped key.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. |
| wrappingKeyAlias | Indicates the pointer to the alias of the wrapping key, which is obtained through key agreement and used to decrypt the key to import. |
| paramSet | Indicates the pointer to the parameters of the wrapped key to import. |
| wrappedKeyData | Indicates the pointer to the wrapped key to import. The key must be in the format required by the HUKS. For details, see [OH_Huks_AlgSuite](_huks_type_api.md#oh_huks_algsuite). |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_InitSession()
```
struct OH_Huks_Result OH_Huks_InitSession (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * handle, struct OH_Huks_Blob * challenge )
```
**Description**<br>
Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional).
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the target key. |
| paramSet | Indicates the pointer to the parameters for the initialization operation. |
| handle | Indicates the pointer to the handle of the key session obtained. This handle is required for subsequent operations, including [OH_Huks_UpdateSession](#oh_huks_updatesession), [OH_Huks_FinishSession](#oh_huks_finishsession), and [OH_Huks_AbortSession](#oh_huks_abortsession). |
| challenge | Indicates the pointer to the challenge value obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
**See**
[OH_Huks_UpdateSession](#oh_huks_updatesession)
[OH_Huks_FinishSession](#oh_huks_finishsession)
[OH_Huks_AbortSession](#oh_huks_abortsession)
### OH_Huks_IsKeyItemExist()
```
struct OH_Huks_Result OH_Huks_IsKeyItemExist (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet )
```
**Description**<br>
Checks whether a key exists.
**Parameters**
| Name | Description |
| -------- | -------- |
| keyAlias | Indicates the pointer to the alias of the target key. |
| paramSet | Indicates the pointer to the attribute tag required for checking the key. By default, this parameter is a null pointer. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the key exists.
Returns [OH_Huks_ErrCode#OH_HUKS_ERR_CODE_ITEM_NOT_EXIST](_huks_type_api.md) if the key does not exist.
Returns any other error code for other cases.
### OH_Huks_UpdateSession()
```
struct OH_Huks_Result OH_Huks_UpdateSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData )
```
**Description**<br>
Adds data by segment for the key operation, performs the related key operation, and outputs the processed data.
**Parameters**
| Name | Description |
| -------- | -------- |
| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). |
| paramSet | Indicates the pointer to the parameters required for the key operation. |
| inData | Indicates the pointer to the data to be processed. This API can be called multiples time to process large data by segment. |
| outData | Indicates the pointer to the output data. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
**See**
[OH_Huks_InitSession](#oh_huks_initsession)
[OH_Huks_FinishSession](#oh_huks_finishsession)
[OH_Huks_AbortSession](#oh_huks_abortsession)
# HuksParamSetApi
## Overview
Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. The HUKS APIs can be used to perform parameter set lifecycle management, including initializing a parameter set, adding parameters to a parameter set, constructing a parameter set, and destroying a parameter set. They can also be used to obtain parameters, copy parameter sets, and check parameter validity.
\@syscap SystemCapability.Security.Huks
**Since:**
9
## Summary
### Files
| Name | Description |
| -------- | -------- |
| [native_huks_param.h](native__huks__param_8h.md) | Provides APIs for constructing, using, and destroying parameter sets. <br>File to Include: <huks/native_huks/native_huks_param.h> |
### Functions
| Name | Description |
| -------- | -------- |
| [OH_Huks_InitParamSet](#oh_huks_initparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. |
| [OH_Huks_AddParams](#oh_huks_addparams) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md) \*params, uint32_t paramCnt) | Adds parameters to a parameter set. |
| [OH_Huks_BuildParamSet](#oh_huks_buildparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. |
| [OH_Huks_FreeParamSet](#oh_huks_freeparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. |
| [OH_Huks_CopyParamSet](#oh_huks_copyparamset) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Copies a parameter set (deep copy). |
| [OH_Huks_GetParam](#oh_huks_getparam) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md) \*\*param) | Obtains parameters from a parameter set. |
| [OH_Huks_FreshParamSet](#oh_huks_freshparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. |
| [OH_Huks_isParamSetTagValid](#oh_huks_isparamsettagvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether the parameters in a parameter set are valid. |
| [OH_Huks_isParamSetValid](#oh_huks_isparamsetvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. |
| [OH_Huks_CheckParamMatch](#oh_huks_checkparammatch) (const struct [OH_Huks_Param](_o_h___huks___param.md) \*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md) \*param) | Checks whether two parameters are the same. |
## Function Description
### OH_Huks_AddParams()
```
int32_t OH_Huks_AddParams (struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Param * params, uint32_t paramCnt )
```
**Description**<br>
Adds parameters to a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the parameter set to which parameters are to be added. |
| params | Indicates the pointer to the array of parameters to add. |
| paramCnt | Indicates the number of parameters to add. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_BuildParamSet()
```
int32_t OH_Huks_BuildParamSet (struct OH_Huks_ParamSet ** paramSet)
```
**Description**<br>
Constructs a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the double pointer to the parameter set to construct. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_CheckParamMatch()
```
int32_t OH_Huks_CheckParamMatch (const struct OH_Huks_Param * baseParam, const struct OH_Huks_Param * param )
```
**Description**<br>
Checks whether two parameters are the same.
**Parameters**
| Name | Description |
| -------- | -------- |
| baseParam | Indicates the pointer to the first parameter. |
| param | Indicates the pointer to the second parameter. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the two parameters are the same; returns an error code otherwise.
### OH_Huks_CopyParamSet()
```
int32_t OH_Huks_CopyParamSet (const struct OH_Huks_ParamSet * fromParamSet, uint32_t fromParamSetSize, struct OH_Huks_ParamSet ** paramSet )
```
**Description**<br>
Copies a parameter set (deep copy).
**Parameters**
| Name | Description |
| -------- | -------- |
| fromParamSet | Indicates the pointer to the parameter set to copy. |
| fromParamSetSize | Indicates the memory size occupied by the source parameter set. |
| paramSet | Indicates the double pointer to the new parameter set generated. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise.
### OH_Huks_FreeParamSet()
```
void OH_Huks_FreeParamSet (struct OH_Huks_ParamSet ** paramSet)
```
**Description**<br>
Destroys a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the double pointer to the parameter set to destroy. |
### OH_Huks_FreshParamSet()
```
int32_t OH_Huks_FreshParamSet (struct OH_Huks_ParamSet * paramSet, bool isCopy )
```
**Description**<br>
Refreshes data of the **Blob** type in a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the target parameter set. |
| isCopy | Specifies whether to copy the data of the **Blob** type to the parameter set. If yes, the data of the **Blob** type will be copied to the parameter set. Otherwise, only the address of the **Blob** data will be refreshed. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if operation is successful; returns an error code otherwise.
### OH_Huks_GetParam()
```
int32_t OH_Huks_GetParam (const struct OH_Huks_ParamSet * paramSet, uint32_t tag, struct OH_Huks_Param ** param )
```
**Description**<br>
Obtains parameters from a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the target parameter set. |
| tag | Indicates the value of the parameter to be obtained. |
| param | Indicates the double pointer to the parameter obtained. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful, returns an error code otherwise.
### OH_Huks_InitParamSet()
```
int32_t OH_Huks_InitParamSet (struct OH_Huks_ParamSet ** paramSet)
```
**Description**<br>
Initializes a parameter set.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the double pointer to the parameter set to initialize. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the initialization is successful; returns an error code otherwise.
### OH_Huks_isParamSetTagValid()
```
int32_t OH_Huks_isParamSetTagValid (const struct OH_Huks_ParamSet * paramSet)
```
**Description**<br>
Checks whether the parameters in a parameter set are valid.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the parameter set to check. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameters in the parameter set are valid; returns other values if the parameter set has invalid, duplicate, or incorrect parameters.
### OH_Huks_isParamSetValid()
```
int32_t OH_Huks_isParamSetValid (const struct OH_Huks_ParamSet * paramSet, uint32_t size )
```
**Description**<br>
Checks whether a parameter set is of the valid size.
**Parameters**
| Name | Description |
| -------- | -------- |
| paramSet | Indicates the pointer to the parameter set to check. |
| size | Indicates the memory size occupied by the parameter set. |
**Returns**
Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameter set is of the valid size; returns an error code otherwise.
此差异已折叠。
# OH_AVCodecAsyncCallback
## Overview
Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.
\@syscap SystemCapability.Multimedia.Media.CodecBase
**Since:**
9
**Related Modules:**
[CodecBase](_codec_base.md)
## Summary
### Member Variables
| Name | Description |
| -------- | -------- |
| **onError** | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror) |
| **onStreamChanged** | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged) |
| **onNeedInputData** | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) |
| **onNeedOutputData** | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata) |
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册