提交 a516d443 编写于 作者: G ge-yafang

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

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/ge-yafang/docs into OpenHarmony-3.2-Release
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
- Application Package Structure - Application Package Structure
- [Application Package Structure in Stage Model)](quick-start/application-package-structure-stage.md) - [Application Package Structure in Stage Model)](quick-start/application-package-structure-stage.md)
- [Application Package Structure in FA Model](quick-start/application-package-structure-fa.md) - [Application Package Structure in FA Model](quick-start/application-package-structure-fa.md)
- [HAR File Structure](quick-start/har-structure.md)
- Multi-HAP Mechanism - Multi-HAP Mechanism
- [Multi-HAP Design Objectives](quick-start/multi-hap-objective.md) - [Multi-HAP Design Objectives](quick-start/multi-hap-objective.md)
- [Multi-HAP Build View](quick-start/multi-hap-build-view.md) - [Multi-HAP Build View](quick-start/multi-hap-build-view.md)
...@@ -25,6 +24,11 @@ ...@@ -25,6 +24,11 @@
- [Multi-HAP Usage Rules](quick-start/multi-hap-rules.md) - [Multi-HAP Usage Rules](quick-start/multi-hap-rules.md)
- [Multi-HAP Operation Mechanism and Data Communication Modes](quick-start/multi-hap-principles.md) - [Multi-HAP Operation Mechanism and Data Communication Modes](quick-start/multi-hap-principles.md)
- [Application Installation and Uninstallation Process](quick-start/application-package-install-uninstall.md) - [Application Installation and Uninstallation Process](quick-start/application-package-install-uninstall.md)
- Shared Package
- [Shared Package Overview](quick-start/shared-guide.md)
- [HAR](quick-start/har-package.md)
- HSP
- [In-Application HSP Development](quick-start/in-app-hsp.md)
- Application Configuration Files in Stage Model - Application Configuration Files in Stage Model
- [Application Configuration File Overview (Stage Model)](quick-start/application-configuration-file-overview-stage.md) - [Application Configuration File Overview (Stage Model)](quick-start/application-configuration-file-overview-stage.md)
- [app.json5 Configuration File](quick-start/app-configuration-file.md) - [app.json5 Configuration File](quick-start/app-configuration-file.md)
......
...@@ -17,7 +17,7 @@ Both explicit Want and implicit Want can be used to match an ability to start ba ...@@ -17,7 +17,7 @@ Both explicit Want and implicit Want can be used to match an ability to start ba
| flags | number | No| No| This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.| | flags | number | No| No| This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.|
| parameters | {[key: string]: any} | No| No| This field is not used for matching. It is passed to the target ability as a parameter.| | parameters | {[key: string]: any} | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
## Matching Rules for Implicit Want ## Matching Rules of Implicit Want
| Name | Type | Matching Item| Mandatory| Rule Description | | Name | Type | Matching Item| Mandatory| Rule Description |
| ----------- | ------------------------------ | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------------------------------ | ------ | ---- | ------------------------------------------------------------ |
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
When switching an application from the FA model to the stage model, you must migrate the configurations under the **module** tag in the **config.json** file to the **module** tag in the **module.json5** file. When switching an application from the FA model to the stage model, you must migrate the configurations under the **module** tag in the **config.json** file to the **module** tag in the **module.json5** file.
**Table 1** module comparison ### Table 1 module Comparison
| Field Name in the FA Model| Field Description| Field Name in the Stage Model| Difference| | Field Name in the FA Model| Field Description| Field Name in the Stage Model| Difference|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -26,7 +26,7 @@ When switching an application from the FA model to the stage model, you must mig ...@@ -26,7 +26,7 @@ When switching an application from the FA model to the stage model, you must mig
| commonEvents | Common events.| common_event_config.json| In the stage model, the **common_event_config.json** file is defined in **resources/base/profile** in the development view.| | commonEvents | Common events.| common_event_config.json| In the stage model, the **common_event_config.json** file is defined in **resources/base/profile** in the development view.|
| entryTheme | Keyword of an OpenHarmony internal theme.| / | This configuration is not supported in the stage model.| | entryTheme | Keyword of an OpenHarmony internal theme.| / | This configuration is not supported in the stage model.|
**Table 2** metaData comparison ### Table 2 metaData Comparison
| Field Name Under metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference| | Field Name Under metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -34,7 +34,7 @@ When switching an application from the FA model to the stage model, you must mig ...@@ -34,7 +34,7 @@ When switching an application from the FA model to the stage model, you must mig
| results | Metadata of the ability return value.| / | This configuration is not supported in the stage model.| | results | Metadata of the ability return value.| / | This configuration is not supported in the stage model.|
| customizeData | Custom metadata of the parent component. **parameters** and **results** cannot be configured in **application**.| metadata | See [Table 3](#table-3-comparison-between-customizedata-under-metadata-in-the-fa-model-and-metadata-in-the-stage-model).| | customizeData | Custom metadata of the parent component. **parameters** and **results** cannot be configured in **application**.| metadata | See [Table 3](#table-3-comparison-between-customizedata-under-metadata-in-the-fa-model-and-metadata-in-the-stage-model).|
**Table 3** Comparison between customizeData under metaData in the FA model and metadata in the stage model ### Table 3 Comparison Between customizeData Under metaData in the FA Model and metadata in the Stage Model
| Field Name Under customizeData in metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference| | Field Name Under customizeData in metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -42,14 +42,14 @@ When switching an application from the FA model to the stage model, you must mig ...@@ -42,14 +42,14 @@ When switching an application from the FA model to the stage model, you must mig
| value | Value of the data item. The value is a string with a maximum of 255 bytes.| value | None.| | value | Value of the data item. The value is a string with a maximum of 255 bytes.| value | None.|
| extra | Format of the current custom data. The value is the resource value of **extra**.| resource | The field name is changed. For details, see [Table 4](#table-4-metadata-examples).| | extra | Format of the current custom data. The value is the resource value of **extra**.| resource | The field name is changed. For details, see [Table 4](#table-4-metadata-examples).|
**Table 4** metaData examples ### Table 4 metaData Examples
| Example in the FA Model| Example in the Stage Model| | Example in the FA Model| Example in the Stage Model|
| -------- | -------- | | -------- | -------- |
| "meteData": {<br> "customizeDate": [{<br> "name": "label",<br> "value": "string",<br> "extra": "$string:label",<br> }]<br>} | "meteData": [{<br> "name": "label",<br> "value": "string",<br> "resource": "$string:label",<br>}] | | "meteData": {<br> "customizeDate": [{<br> "name": "label",<br> "value": "string",<br> "extra": "$string:label",<br> }]<br>} | "meteData": [{<br> "name": "label",<br> "value": "string",<br> "resource": "$string:label",<br>}] |
**Table 5** abilities comparison ### Table 5 abilities Comparison
| Field Name Under abilities in the FA Model| Field Description| Field Name Under abilities in the Stage Model| Difference| | Field Name Under abilities in the FA Model| Field Description| Field Name Under abilities in the Stage Model| Difference|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
......
...@@ -22,7 +22,7 @@ The following figures show the AVRecorder state transition and the interaction w ...@@ -22,7 +22,7 @@ The following figures show the AVRecorder state transition and the interaction w
Before developing audio recording, configure the permission **ohos.permission.MICROPHONE** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). Before developing audio recording, configure the permission **ohos.permission.MICROPHONE** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
To use the camera to record videos, the camera module is required. For details about how to use the camera APIs, see [Camera Management](js-apis-camera.md). To use the camera to record videos, the camera module is required. For details about how to use the camera APIs, see [Camera Management](../reference/apis/js-apis-camera.md).
## How to Develop ## How to Develop
......
...@@ -33,6 +33,7 @@ As shown above, the **app.json5** file contains several tags. ...@@ -33,6 +33,7 @@ As shown above, the **app.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed| | 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| | 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**)| | 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| | 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| | 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. ...@@ -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)| | [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)| | [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)| | [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 ## deviceTypes
...@@ -206,10 +208,13 @@ UIAbility configuration of the module, which is valid only for the current UIAbi ...@@ -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. 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). 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**: **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 ...@@ -231,37 +236,39 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
}] }]
}], }],
... ...
} }
} }
``` ```
**Querying an application icon:** **Display rules of application icons and labels on the home screen:**
* The HAP file contains ability configuration. * The HAP file contains UIAbility configuration.
* The application icon is set under **abilities** in the **module.json5** file. * 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 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 application icon displayed on the home screen is the icon configured for the UIAbility.
* The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned. * 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 returned component name is the component name of the ability. * The name of the UIAbility is displayed.
* When the user touches the home screen icon, the home screen of the ability 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 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.
* 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 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 application icon displayed on the home screen is the icon specified under **app**. (The **icon** field 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 application label displayed on the home screen is the label specified under **app**. (The **label** field 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 application icon on the home screen will direct the user to the application details screen shown in Figure 1.
* Touching the home screen icon will direct the user to the application details screen.
* The application has the privilege to hide its icon from the home screen. * 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.
* 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 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 application icon displayed on the home screen is the icon specified under **app**. (The **icon** field 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 application label displayed on the home screen is the label specified under **app**. (The **label** field 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 application icon on the home screen will direct the user to the application details screen shown in Figure 1.
* Touching the home screen icon will direct the user to the application details screen.
* The application has the privilege to hide its icon from the home screen. * 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 **Table 4** abilities
...@@ -396,38 +403,6 @@ Example of the **skills** structure: ...@@ -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 ## extensionAbilities
...@@ -461,7 +436,7 @@ Example of the **extensionAbilities** structure: ...@@ -461,7 +436,7 @@ Example of the **extensionAbilities** structure:
"icon": "$media:icon", "icon": "$media:icon",
"label" : "$string:extension_name", "label" : "$string:extension_name",
"description": "$string:form_description", "description": "$string:form_description",
"type": "form", "type": "form",
"permissions": ["ohos.abilitydemo.permission.PROVIDER"], "permissions": ["ohos.abilitydemo.permission.PROVIDER"],
"readPermission": "", "readPermission": "",
"writePermission": "", "writePermission": "",
...@@ -475,7 +450,7 @@ Example of the **extensionAbilities** structure: ...@@ -475,7 +450,7 @@ Example of the **extensionAbilities** structure:
"metadata": [ "metadata": [
{ {
"name": "ohos.extension.form", "name": "ohos.extension.form",
"resource": "$profile:form_config", "resource": "$profile:form_config",
} }
] ]
} }
...@@ -534,7 +509,7 @@ The **shortcut** information is identified in **metadata**, where: ...@@ -534,7 +509,7 @@ The **shortcut** information is identified in **metadata**, where:
- **resource** indicates where the resources of the shortcut are stored. - **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| | 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)| | 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. ...@@ -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| | 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| | 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 ```json
...@@ -719,3 +694,80 @@ Example of the / structure: ...@@ -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"
}
]
}
}
```
...@@ -118,8 +118,8 @@ if (!hasHceCap) { ...@@ -118,8 +118,8 @@ if (!hasHceCap) {
} }
var elementName = { var elementName = {
"bundleName": "com.test.cardemulation", "bundleName": "com.example.myapplication",
"abilityName": "com.test.cardemulation.MainAbility", "abilityName": "EntryAbility",
}; };
var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT); var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
console.log('is the app is default service for this card type: ' + isDefaultService); console.log('is the app is default service for this card type: ' + isDefaultService);
......
...@@ -32,6 +32,7 @@ isNfcAvailable(): boolean ...@@ -32,6 +32,7 @@ isNfcAvailable(): boolean
Checks whether the device supports NFC. Checks whether the device supports NFC.
> **NOTE** > **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"). > 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 **System capability**: SystemCapability.Communication.NFC.Core
...@@ -50,6 +51,7 @@ openNfc(): boolean ...@@ -50,6 +51,7 @@ openNfc(): boolean
Opens NFC. Opens NFC.
> **NOTE** > **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [enableNfc](#controllerenablenfc9). > 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 **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
...@@ -64,9 +66,9 @@ Opens NFC. ...@@ -64,9 +66,9 @@ Opens NFC.
## controller.enableNfc<sup>9+</sup> ## controller.enableNfc<sup>9+</sup>
enableNfc(): boolean enableNfc(): void
Opens NFC. Enables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
...@@ -87,6 +89,7 @@ closeNfc(): boolean ...@@ -87,6 +89,7 @@ closeNfc(): boolean
Closes NFC. Closes NFC.
> **NOTE** > **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [disableNfc](#controllerdisablenfc9). > 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 **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
...@@ -101,9 +104,9 @@ Closes NFC. ...@@ -101,9 +104,9 @@ Closes NFC.
## controller.disableNfc<sup>9+</sup> ## controller.disableNfc<sup>9+</sup>
disableNfc(): boolean disableNfc(): void
Closes NFC. Disables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
...@@ -172,7 +175,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta ...@@ -172,7 +175,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
| **Name**| **Type**| **Mandatory**| **Description**| | **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.| | callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
**Example** **Example**
...@@ -180,7 +183,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta ...@@ -180,7 +183,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
```js ```js
import controller from '@ohos.nfc.controller'; 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)=> { controller.on("nfcStateChange", (err, nfcState)=> {
if (err) { if (err) {
console.log("controller on callback err: " + err); console.log("controller on callback err: " + err);
...@@ -189,7 +192,7 @@ controller.on("nfcStateChange", (err, nfcState)=> { ...@@ -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()) { if (!controller.isNfcOpen()) {
var ret = controller.openNfc(); var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret); console.log("controller openNfc ret: " + ret);
...@@ -203,7 +206,7 @@ try { ...@@ -203,7 +206,7 @@ try {
console.log("controller enableNfc busiError: " + busiError); 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()) { if (controller.isNfcOpen()) {
var ret = controller.closeNfc(); var ret = controller.closeNfc();
console.log("controller closeNfc ret: " + ret); console.log("controller closeNfc ret: " + ret);
......
...@@ -766,7 +766,7 @@ Defines the **TagInfo** object, which provides information about the tag technol ...@@ -766,7 +766,7 @@ Defines the **TagInfo** object, which provides information about the tag technol
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| uid<sup>9+</sup> | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| | uid<sup>9+</sup> | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| technology<sup>9+</sup> | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.| | technology<sup>9+</sup> | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.|
| supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#taginfo) instead.| | supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead.|
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.<br>**System API**: This is a system API.| | extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.<br>**System API**: This is a system API.|
| tagRfDiscId<sup>9+</sup> | number | Yes| No| ID allocated when the tag is discovered.<br>**System API**: This is a system API.| | tagRfDiscId<sup>9+</sup> | number | Yes| No| ID allocated when the tag is discovered.<br>**System API**: This is a system API.|
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.| | remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.|
......
...@@ -96,7 +96,7 @@ Connects to this tag. Call this API to set up a connection before reading data f ...@@ -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). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -154,7 +154,7 @@ Resets the connection to this tag. ...@@ -154,7 +154,7 @@ Resets the connection to this tag.
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -183,8 +183,6 @@ Checks whether the tag is connected. ...@@ -183,8 +183,6 @@ Checks whether the tag is connected.
> **NOTE** > **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.isConnected](#tagsessionisconnected9). > 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 **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -211,8 +209,6 @@ isConnected(): boolean ...@@ -211,8 +209,6 @@ isConnected(): boolean
Checks whether the tag is connected. Checks whether the tag is connected.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -287,7 +283,7 @@ Obtains the maximum length of the data that can be sent to this tag. ...@@ -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). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -357,7 +353,7 @@ Obtains the timeout period for sending data to this tag, in milliseconds. ...@@ -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). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -419,7 +415,7 @@ console.log("tag setSendDataTimeout setStatus: " + setStatus); ...@@ -419,7 +415,7 @@ console.log("tag setSendDataTimeout setStatus: " + setStatus);
setTimeout(timeout: number): void 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 **Required permissions**: ohos.permission.NFC_TAG
...@@ -435,7 +431,7 @@ Obtains the timeout period for sending data to this tag, in milliseconds. ...@@ -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). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -555,7 +551,7 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> { ...@@ -555,7 +551,7 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> {
transmit(data: number[]): Promise<number[]> 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 **Required permissions**: ohos.permission.NFC_TAG
...@@ -565,7 +561,7 @@ Sends data to this tag. This API uses a promise to return the result. ...@@ -565,7 +561,7 @@ Sends data to this tag. This API uses a promise to return the result.
| Name | Type | Mandatory| Description | | 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** **Return value**
...@@ -577,7 +573,7 @@ Sends data to this tag. This API uses a promise to return the result. ...@@ -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). 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. | | 3100201 | Tag running state is abnormal in service. |
...@@ -616,7 +612,7 @@ try { ...@@ -616,7 +612,7 @@ try {
transmit(data: number[], callback: AsyncCallback<number[]>): void 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 **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 ...@@ -626,14 +622,14 @@ Sends data to this tag. This API uses an asynchronous callback to return the res
| Name | Type | Mandatory| Description | | 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**.| | 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** **Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). 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. | | 3100201 | Tag running state is abnormal in service. |
......
...@@ -105,7 +105,6 @@ ...@@ -105,7 +105,6 @@
- [ColumnSplit](ts-container-columnsplit.md) - [ColumnSplit](ts-container-columnsplit.md)
- [Counter](ts-container-counter.md) - [Counter](ts-container-counter.md)
- [Flex](ts-container-flex.md) - [Flex](ts-container-flex.md)
- [FlowItem](ts-container-flowitem.md)
- [GridCol](ts-container-gridcol.md) - [GridCol](ts-container-gridcol.md)
- [GridRow](ts-container-gridrow.md) - [GridRow](ts-container-gridrow.md)
- [Grid](ts-container-grid.md) - [Grid](ts-container-grid.md)
......
...@@ -37,10 +37,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -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.| | 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.| | 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.| | 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.| | 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.| | 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.| | 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 ...@@ -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.| | 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.| | 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.| | 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.| | 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.| | 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.| | 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 ...@@ -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.| | 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.| | 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.| | 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.| | 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.| | 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.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.<br>Since API version 9, this API is supported in ArkTS widgets.|
## Example ## Example
...@@ -58,35 +58,41 @@ struct LineExample { ...@@ -58,35 +58,41 @@ struct LineExample {
Column({ space: 10 }) { 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. // 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() Line()
.width(200)
.height(150)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([50, 100]) .endPoint([50, 100])
.stroke(Color.Black) .stroke(Color.Black)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
Line() Line()
.width(200) .width(200)
.height(200) .height(150)
.startPoint([50, 50]) .startPoint([50, 50])
.endPoint([150, 150]) .endPoint([150, 150])
.strokeWidth(5) .strokeWidth(5)
.stroke(Color.Orange) .stroke(Color.Orange)
.strokeOpacity(0.5) .strokeOpacity(0.5)
.backgroundColor('#F5F5F5') .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. // strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered.
Line({ width: 50, height: 50 }) Line()
.width(200)
.height(150)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([100, 100]) .endPoint([100, 100])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
.strokeDashArray([10, 3]) .strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
// strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered. // 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 }) Line()
.width(50)
.height(50)
.startPoint([0, 0]) .startPoint([0, 0])
.endPoint([100, 100]) .endPoint([100, 100])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(3) .strokeWidth(3)
.strokeDashArray([10, 3]) .strokeDashArray([10, 3])
.strokeDashOffset(5)
.backgroundColor('#F5F5F5') .backgroundColor('#F5F5F5')
} }
} }
...@@ -151,12 +157,16 @@ struct LineExample { ...@@ -151,12 +157,16 @@ struct LineExample {
build() { build() {
Column() { Column() {
Line() Line()
.width(300)
.height(30)
.startPoint([50, 30]) .startPoint([50, 30])
.endPoint([300, 30]) .endPoint([300, 30])
.stroke(Color.Black) .stroke(Color.Black)
.strokeWidth(10) .strokeWidth(10)
// Set the interval for strokeDashArray to 50. // Set the interval for strokeDashArray to 50.
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -164,6 +174,8 @@ struct LineExample { ...@@ -164,6 +174,8 @@ struct LineExample {
.strokeDashArray([50]) .strokeDashArray([50])
// Set the interval for strokeDashArray to 50, 10. // Set the interval for strokeDashArray to 50, 10.
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -171,6 +183,8 @@ struct LineExample { ...@@ -171,6 +183,8 @@ struct LineExample {
.strokeDashArray([50, 10]) .strokeDashArray([50, 10])
// Set the interval for strokeDashArray to 50, 10, 20. // Set the interval for strokeDashArray to 50, 10, 20.
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
...@@ -178,6 +192,8 @@ struct LineExample { ...@@ -178,6 +192,8 @@ struct LineExample {
.strokeDashArray([50, 10, 20]) .strokeDashArray([50, 10, 20])
// Set the interval for strokeDashArray to 50, 10, 20, 30. // Set the interval for strokeDashArray to 50, 10, 20, 30.
Line() Line()
.width(300)
.height(30)
.startPoint([50, 20]) .startPoint([50, 20])
.endPoint([300, 20]) .endPoint([300, 20])
.stroke(Color.Black) .stroke(Color.Black)
......
...@@ -14,7 +14,7 @@ Image effects include blur, shadow, and much more. ...@@ -14,7 +14,7 @@ Image effects include blur, shadow, and much more.
| ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ |
| blur | number | - | Applies the content blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.| | blur | number | - | Applies the content blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.|
| backdropBlur | number | - | Applies the background blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.| | backdropBlur | number | - | Applies the background blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.|
| shadow | [ShadowOptions](#shadowoptions) | - | Applies a shadow effect to the current component.<br>When the value type is **ShadowOptions**, the blur radius, shadow color, and offset along the x-axis and y-axis can be specified.<br>When the value type is **ShadowStyle**, the shadow style can be specified.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>ArkTS widgets do not support the [ShadowStyle](#shadowstyle10) value type.| | shadow | {<br/>radius: number \| [Resource](ts-types.md#resource),<br/>color?: [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource),<br/>offsetX?: number \| [Resource](ts-types.md#resource),<br/>offsetY?: number \| [Resource](ts-types.md#resource)<br/>} | - | Applies a shadow effect to the current component.<br>When the value type is **ShadowOptions**, the blur radius, shadow color, and offset along the x-axis and y-axis can be specified.<br>Since API version 9, this API is supported in ArkTS widgets.|
| grayscale | number | 0.0 | Converts the input image to grayscale. The value indicates the grayscale conversion ratio. If the input value is **1.0**, the image is converted into a grayscale image. If the input value is **0.0**, the image does not change. If the input value is between **0.0** and **1.0**, the effect changes in linear mode. The unit is percentage.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br>Since API version 9, this API is supported in ArkTS widgets.| | grayscale | number | 0.0 | Converts the input image to grayscale. The value indicates the grayscale conversion ratio. If the input value is **1.0**, the image is converted into a grayscale image. If the input value is **0.0**, the image does not change. If the input value is between **0.0** and **1.0**, the effect changes in linear mode. The unit is percentage.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br>Since API version 9, this API is supported in ArkTS widgets.|
| brightness | number | 1.0 | Applies a brightness to the current component. The input parameter is a brightness ratio. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than **1**, the brightness decreases. If the value is greater than **1**, the brightness increases. A larger value indicates a higher brightness.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>Since API version 9, this API is supported in ArkTS widgets.| | brightness | number | 1.0 | Applies a brightness to the current component. The input parameter is a brightness ratio. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than **1**, the brightness decreases. If the value is greater than **1**, the brightness increases. A larger value indicates a higher brightness.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>Since API version 9, this API is supported in ArkTS widgets.|
| saturate | number | 1.0 | Applies the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is **1**, the source image is displayed. When the input value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>Since API version 9, this API is supported in ArkTS widgets.| | saturate | number | 1.0 | Applies the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is **1**, the source image is displayed. When the input value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>Since API version 9, this API is supported in ArkTS widgets.|
......
...@@ -23,7 +23,7 @@ The [universal attributes](js-service-widget-common-attributes.md) are supported ...@@ -23,7 +23,7 @@ The [universal attributes](js-service-widget-common-attributes.md) are supported
| Name| Type| Default Value| Mandatory| Description| | Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| color | &lt;color&gt; | - | No| Font color of the modified text.| | 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-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.| | 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.| | 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 ...@@ -25,7 +25,7 @@ In addition to the [universal styles](js-service-widget-common-styles.md), the f
| Name| Type| Default Value| Mandatory| Description| | Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| color | &lt;color&gt; | - | No| Font color.| | 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).| | 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-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**.| | 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.
此差异已折叠。
此差异已折叠。
此差异已折叠。
# 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.
先完成此消息的编辑!
想要评论请 注册