harmony 鸿蒙AVSource
AVSource
Overview
The AVSource module provides the functions for constructing media resource objects.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Summary
File
Name | Description |
---|---|
native_avsource.h | Declares the APIs for parsing audio and video media data. |
Types
Name | Description |
---|---|
typedef struct OH_AVSource OH_AVSource | Defines a struct that describes a native object for the media resource interface. |
Functions
Name | Description |
---|---|
OH_AVSource * OH_AVSource_CreateWithDataSource (OH_AVDataSource *dataSource) | Creates an OH_AVSource instance with a user-defined data source. You can release the instance by calling OH_AVSource_Destroy. |
OH_AVSource * OH_AVSource_CreateWithURI (char *uri) | Creates an OH_AVSource instance based on a URI. |
OH_AVSource * OH_AVSource_CreateWithFD (int32_t fd, int64_t offset, int64_t size) | Creates an OH_AVSource instance based on a file descriptor (FD). |
OH_AVErrCode OH_AVSource_Destroy (OH_AVSource *source) | Destroys an OH_AVSource instance and clears internal resources. |
OH_AVFormat * OH_AVSource_GetSourceFormat (OH_AVSource *source) | Obtains the basic information about a media resource file. |
OH_AVFormat * OH_AVSource_GetTrackFormat (OH_AVSource *source, uint32_t trackIndex) | Obtains the basic information about a track. |
OH_AVFormat * OH_AVSource_GetCustomMetadataFormat (OH_AVSource *source) | Obtains the basic information about custom metadata. |
Type Description
OH_AVSource
typedef struct OH_AVSource OH_AVSource
Description
Defines a struct that describes a native object for the media resource interface.
Since: 10
Function Description
OH_AVSource_CreateWithDataSource()
OH_AVSource* OH_AVSource_CreateWithDataSource (OH_AVDataSource * dataSource)
Description
Creates an OH_AVSource instance with a user-defined data source. You can release the instance by calling OH_AVSource_Destroy.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 12
Parameters
Name | Description |
---|---|
dataSource | User-defined data source. |
Returns
Returns the pointer to the OH_AVSource instance created if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
The value of dataSource is a null pointer.
The size of the data source is 0.
Setting the data source fails.
The memory is insufficient.
The decoder engine is a null pointer.
dataSource->readAt == nullptr.
OH_AVSource_CreateWithFD()
OH_AVSource* OH_AVSource_CreateWithFD (int32_t fd, int64_t offset, int64_t size)
Description
Creates an OH_AVSource instance based on an FD.
You can release the instance by calling OH_AVSource_Destroy.
If offset is not the start position of the file or size is not the file size, undefined errors such as creation failure and demultiplexing failure may occur due to incomplete data obtained.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Parameters
Name | Description |
---|---|
fd | FD of a media resource file. |
offset | Position from which data is to read. |
size | File size, in bytes. |
Returns
Returns the pointer to the OH_AVSource instance created if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
The FD is invalid.
The offset is not the start position of the file.
The size is incorrect.
The resource is invalid.
The file format is not supported.
OH_AVSource_CreateWithURI()
OH_AVSource* OH_AVSource_CreateWithURI (char *uri)
Description
Create an OH_AVSource instance based on a URI. You can release the instance by calling OH_AVSource_Destroy.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Parameters
Name | Description |
---|---|
uri | URI of the media resource. |
Returns
Returns the pointer to the OH_AVSource instance created if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
The network is abnormal.
The resource is invalid.
The file format is not supported.
OH_AVSource_Destroy()
OH_AVErrCode OH_AVSource_Destroy (OH_AVSource *source)
Description
Destroys an OH_AVSource instance and clears internal resources.
An instance can be destroyed only once. The destroyed instance cannot be used until it is re-created. You are advised to set the pointer to NULL after the instance is destroyed.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Parameters
Name | Description |
---|---|
source | Pointer to an OH_AVSource instance. |
Returns
Returns either of the following result codes:
AV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The operation fails.
1. The source pointer is invalid.
2. The pointer is null or does not point to an **OH_AVSource** instance.
OH_AVSource_GetCustomMetadataFormat()
OH_AVFormat *OH_AVSource_GetCustomMetadataFormat(OH_AVSource *source)
Description
Obtains the basic information about custom metadata.
You must call OH_AVFormat_Destroy to release the OH_AVFormat instance when its lifecycle ends.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 18
Parameters
Name | Description |
---|---|
source | Pointer to an OH_AVSource instance. |
Returns
Returns the basic information about the metadata if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
- The source pointer is invalid.
- The pointer is null or does not point to an OH_AVSource instance.
- The source is not initialized.
OH_AVSource_GetSourceFormat()
OH_AVFormat* OH_AVSource_GetSourceFormat (OH_AVSource *source)
Description
Obtains the basic information about a media resource file.
You must call OH_AVFormat_Destroy to release the OH_AVFormat instance when its lifecycle ends.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Parameters
Name | Description |
---|---|
source | Pointer to an OH_AVSource instance. |
Returns
Returns the basic information about the file if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
- The source pointer is invalid.
- The pointer is null or does not point to an OH_AVSource instance.
- The source is not initialized.
OH_AVSource_GetTrackFormat()
OH_AVFormat* OH_AVSource_GetTrackFormat (OH_AVSource *source, uint32_t trackIndex)
Description
Obtains the basic information about a track.
You must call OH_AVFormat_Destroy to release the OH_AVFormat instance when its lifecycle ends.
System capability: SystemCapability.Multimedia.Media.Spliter
Since: 10
Parameters
Name | Description |
---|---|
source | Pointer to an OH_AVSource instance. |
trackIndex | Index of the track whose information is to be obtained. |
Returns
Returns the basic information about the track if the operation is successful; returns NULL otherwise.
The possible causes of an operation failure are as follows:
- The value of source is invalid (either a null pointer or a pointer to a non-OH_AVSource instance).
- The track index is out of range.
- The source is not initialized.
你可能感兴趣的鸿蒙文章
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦