1 Star 0 Fork 4.9K

Lin_bruin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MultiMedia_MediaCommon.md 131.12 KB
一键复制 编辑 原始数据 按行查看 历史
wenjun 提交于 2020-09-08 10:08 . add OpenHarmony 1.0 baseline

MultiMedia_MediaCommon

Overview

Provides data types and media formats required for recording and playing audio and videos.

Since:

1.0

Version:

1.0

Summary

Files

File Name

Description

format.h

Declares the media formats provided in the Format class.

media_errors.h

Declares the media_errors class to define errors that may occur during media operations.

media_info.h

Declares the media_info class and provides various audio, video, and codec types.

source.h

Declares the Source class, which is used to implement source-related operations.

Data Structures

Data Structure Name

Description

OHOS::Media::FormatData

Represents the data format.

OHOS::Media::Format

Saves and sets media metadata, such as the media playback duration.

AudioDeviceDesc

Defines the audio Device Descriptor.

OHOS::Media::StreamCallback

Provides functions to obtain the address of a buffer memory and write the filled buffers into the playback queue. You need to implement the StreamCallback functions in a player object.

OHOS::Media::StreamSource

Provides functions related to the stream source for upper-layer applications.

OHOS::Media::Source

Provides functions to implement source-related operations.

Enumerations

Enumeration Name

Description

OHOS::Media::FormatDataType : uint32_t {   OHOS::Media::FORMAT_TYPE_NONE, OHOS::Media::FORMAT_TYPE_INT32, OHOS::Media::FORMAT_TYPE_INT64, OHOS::Media::FORMAT_TYPE_FLOAT,   OHOS::Media::FORMAT_TYPE_DOUBLE, OHOS::Media::FORMAT_TYPE_STRING }

Enumerates formats.

AudioSourceType {   AUDIO_SOURCE_INVALID = -1, AUDIO_SOURCE_DEFAULT = 0, AUDIO_MIC = 1, AUDIO_VOICE_UPLINK = 2,   AUDIO_VOICE_DOWNLINK = 3, AUDIO_VOICE_CALL = 4, AUDIO_CAMCORDER = 5, AUDIO_VOICE_RECOGNITION = 6,   AUDIO_VOICE_COMMUNICATION = 7, AUDIO_REMOTE_SUBMIX = 8, AUDIO_UNPROCESSED = 9, AUDIO_VOICE_PERFORMANCE = 10,   AUDIO_ECHO_REFERENCE = 1997, AUDIO_RADIO_TUNER = 1998, AUDIO_HOTWORD = 1999, AUDIO_REMOTE_SUBMIX_EXTEND = 10007 }

Enumerates audio source types.

AudioStreamType {   TYPE_DEFAULT = -1, TYPE_MEDIA = 0, TYPE_VOICE_COMMUNICATION = 1, TYPE_SYSTEM = 2,   TYPE_RING = 3, TYPE_MUSIC = 4, TYPE_ALARM = 5, TYPE_NOTIFICATION = 6,   TYPE_BLUETOOTH_SCO = 7, TYPE_ENFORCED_AUDIBLE = 8, TYPE_DTMF = 9, TYPE_TTS = 10,   TYPE_ACCESSIBILITY = 11 }

Enumerates audio stream types.

VideoCodecFormat { VIDEO_DEFAULT = 0, H264 = 2, HEVC = 5 }

Enumerates video codec formats.

AudioCodecFormat {   AUDIO_DEFAULT = 0, AAC_LC = 1, AAC_HE_V1 = 2, AAC_HE_V2 = 3,   AAC_LD = 4, AAC_ELD = 5, FORMAT_BUTT }

Enumerates audio codec formats.

AudioBitWidth { BIT_WIDTH_8 = 8, BIT_WIDTH_16 = 16, BIT_WIDTH_24 = 24, BIT_WIDTH_BUTT }

Enumerates audio bit widths.

OHOS::Media::SourceType : int32_t { OHOS::Media::SourceType::SOURCE_TYPE_URI = 0, OHOS::Media::SourceType::SOURCE_TYPE_FD, OHOS::Media::SourceType::SOURCE_TYPE_STREAM }

Enumerates media source types.

OHOS::Media::StreamCallback::BufferFlags : uint32_t {   OHOS::Media::StreamCallback::STREAM_FLAG_SYNCFRAME = 1, OHOS::Media::StreamCallback::STREAM_FLAG_CODECCONFIG = 2, OHOS::Media::StreamCallback::STREAM_FLAG_EOS = 4, OHOS::Media::StreamCallback::STREAM_FLAG_PARTIAL_FRAME = 8,   OHOS::Media::StreamCallback::STREAM_FLAG_ENDOFFRAME = 16, OHOS::Media::StreamCallback::STREAM_FLAG_MUXER_DATA = 32 }

Enumerates buffer types of stream sources.

Functions

Function Name

Description

OHOS::Media::FormatData::GetType () const

FormatDataType 

Obtains the format type.

OHOS::Media::FormatData::SetValue (int32_t val)

bool 

Sets a 32-bit integer.

OHOS::Media::FormatData::SetValue (int64_t val)

bool 

Sets a 64-bit long integer.

OHOS::Media::FormatData::SetValue (float val)

bool 

Sets a single-precision floating-point number.

OHOS::Media::FormatData::SetValue (double val)

bool 

Sets a double-precision floating-point number.

OHOS::Media::FormatData::SetValue (const std::string &val)

bool 

Sets a string.

OHOS::Media::FormatData::GetInt32Value (int32_t &val) const

bool 

Obtains a 32-bit integer.

OHOS::Media::FormatData::GetInt64Value (int64_t &val) const

bool 

Obtains a long integer.

OHOS::Media::FormatData::GetFloatValue (float &val) const

bool 

Obtains a single-precision floating-point number.

OHOS::Media::FormatData::GetDoubleValue (double &val) const

bool 

Obtains a double-precision floating-point number.

OHOS::Media::FormatData::GetStringValue (std::string &val) const

bool 

Obtains a string.

OHOS::Media::Format::Format ()

 

Default constructor of the Format instance.

OHOS::Media::Format::PutIntValue (const std::string &key, int32_t value)

bool 

Sets metadata of the integer type.

OHOS::Media::Format::PutLongValue (const std::string &key, int64_t value)

bool 

Sets metadata of the long integer type.

OHOS::Media::Format::PutFloatValue (const std::string &key, float value)

bool 

Sets metadata of the single-precision floating-point type.

OHOS::Media::Format::PutDoubleValue (const std::string &key, double value)

bool 

Sets metadata of the double-precision floating-point type.

OHOS::Media::Format::PutStringValue (const std::string &key, const std::string &value)

bool 

Sets metadata of the string type.

OHOS::Media::Format::GetIntValue (const std::string &key, int32_t &value) const

bool 

Obtains the metadata value of the integer type.

OHOS::Media::Format::GetLongValue (const std::string &key, int64_t &value) const

bool 

Obtains the metadata value of the long integer type.

OHOS::Media::Format::GetFloatValue (const std::string &key, float &value) const

bool 

Obtains the metadata value of the single-precision floating-point type.

OHOS::Media::Format::GetDoubleValue (const std::string &key, double &value) const

bool 

Obtains the metadata value of the double-precision floating-point type.

OHOS::Media::Format::GetStringValue (const std::string &key, std::string &value) const

bool 

Obtains the metadata value of the string type.

OHOS::Media::Format::GetFormatMap () const

const std::map< std::string, FormatData * > & 

Obtains the metadata map.

OHOS::Media::Format::CopyFrom (const Format &format)

bool 

Sets all metadata to a specified format.

OHOS::Media::ErrCodeOffset (unsigned int subsystem, unsigned int module=0)

constexpr ErrCode 

Generates a start error code with a unique identifier based on specified subsystem and module bit numbers.

OHOS::Media::StreamCallback::GetBuffer (size_t index)=0

virtual uint8_t * 

Obtains the virtual address of a buffer memory block based on its index.

OHOS::Media::StreamCallback::QueueBuffer (size_t index, size_t offset, size_t size, int64_t timestampUs, uint32_t flags)=0

virtual void 

Writes the filled buffer memory block into the player memory.

OHOS::Media::StreamCallback::SetParameters (const Format &params)=0

virtual void 

Sets additional information about a stream.

OHOS::Media::StreamSource::OnBufferAvailable (size_t index, size_t offset, size_t size)=0

virtual void 

Notifies your application of the information about the buffer memory block that can be filled with data.

OHOS::Media::StreamSource::SetStreamCallback (const std::shared_ptr< StreamCallback > &callback)=0

virtual void 

Sets a callback function for your application.

OHOS::Media::Source::Source (const std::string &uri)

 

A constructor used to create a Source instance based on a specified URI.

OHOS::Media::Source::Source (const std::string &uri, const std::map< std::string, std::string > &header)

 

A constructor used to create a Source instance based on a specified URI and header.

OHOS::Media::Source::Source (const std::shared_ptr< StreamSource > &stream, const Format &formats)

 

A constructor used to create a Source instance based on the stream source and format information.

OHOS::Media::Source::GetSourceType () const

SourceType 

Obtains the source type.

OHOS::Media::Source::GetSourceUri () const

const std::string & 

Obtains the media source URI.

OHOS::Media::Source::GetSourceHeader () const

const std::map< std::string, std::string > & 

Obtains the HTTP header for the media source.

OHOS::Media::Source::GetSourceStream () const

const std::shared_ptr< StreamSource > & 

Obtains information about the media source stream.

OHOS::Media::Source::GetSourceStreamFormat () const

const Format

Obtains the media source stream format.

Details

Enumeration Type Documentation

AudioBitWidth

enum [AudioBitWidth](MultiMedia_MediaCommon.md#gae3e35ee2a2222a667fdebbc5b793ca7c)

Description:

Enumerates audio bit widths.

Enumerator

Description

BIT_WIDTH_8 

8-bit width

BIT_WIDTH_16 

16-bit width

BIT_WIDTH_24 

24-bit width

BIT_WIDTH_BUTT 

Invalid value

AudioCodecFormat

enum [AudioCodecFormat](MultiMedia_MediaCommon.md#gaa4ea6f314644ed287e0704be26c768b7)

Description:

Enumerates audio codec formats.

Enumerator

Description

AUDIO_DEFAULT 

Default format

AAC_LC 

Advanced Audio Coding Low Complexity (AAC-LC)

AAC_HE_V1 

High-Efficiency Advanced Audio Coding (AAC-HE), previously known as AAC+ or aacPlus v1

AAC_HE_V2 

AAC++ or aacPlus v2

AAC_LD 

Advanced Audio Coding Low Delay (AAC-LD)

AAC_ELD 

Advanced Audio Coding Enhanced Low Delay (AAC-ELD)

FORMAT_BUTT 

Invalid value

AudioSourceType

enum [AudioSourceType](MultiMedia_MediaCommon.md#gadc3158e093b995ca7b9b6aa32388ccdd)

Description:

Enumerates audio source types.

Enumerator

Description

AUDIO_SOURCE_INVALID 

Invalid audio source

AUDIO_SOURCE_DEFAULT 

Default audio source

AUDIO_MIC 

Microphone

AUDIO_VOICE_UPLINK 

Uplink voice

AUDIO_VOICE_DOWNLINK 

Downlink voice

AUDIO_VOICE_CALL 

Voice call

AUDIO_CAMCORDER 

Camcorder

AUDIO_VOICE_RECOGNITION 

Voice recognition

AUDIO_VOICE_COMMUNICATION 

Voice communication

AUDIO_REMOTE_SUBMIX 

Remote submix

AUDIO_UNPROCESSED 

Unprocessed audio

AUDIO_VOICE_PERFORMANCE 

Voice performance

AUDIO_ECHO_REFERENCE 

Echo reference

AUDIO_RADIO_TUNER 

Radio tuner

AUDIO_HOTWORD 

Hotword

AUDIO_REMOTE_SUBMIX_EXTEND 

Extended remote submix

AudioStreamType

enum [AudioStreamType](MultiMedia_MediaCommon.md#gae7077e4211e48131ae544adb20fc494a)

Description:

Enumerates audio stream types.

Enumerator

Description

TYPE_DEFAULT 

Default audio stream type

TYPE_MEDIA 

Media

TYPE_VOICE_COMMUNICATION 

Voice call

TYPE_SYSTEM 

System sound

TYPE_RING 

Ringtone

TYPE_MUSIC 

Music

TYPE_ALARM 

Alarm

TYPE_NOTIFICATION 

Notification

TYPE_BLUETOOTH_SCO 

Bluetooth Synchronous Connection-Oriented (SCO)

TYPE_ENFORCED_AUDIBLE 

Enforced audible

TYPE_DTMF 

Dual-tone multi-frequency (DTMF)

TYPE_TTS 

Text-To-Speech (TTS)

TYPE_ACCESSIBILITY 

Accessibility

BufferFlags

enum [OHOS::Media::StreamCallback::BufferFlags](MultiMedia_MediaCommon.md#ga6f4847f443de5cdf3641386011335e21) : uint32_t

Description:

Enumerates buffer types of stream sources.

Enumerator

Description

STREAM_FLAG_SYNCFRAME 

Synchronous frame

STREAM_FLAG_CODECCONFIG 

Codec configuration information

STREAM_FLAG_EOS 

End of Stream (EOS)

STREAM_FLAG_PARTIAL_FRAME 

Part of a frame

STREAM_FLAG_ENDOFFRAME 

End of a frame. It is used in pair with STREAM_FLAG_PARTIAL_FRAME.

STREAM_FLAG_MUXER_DATA 

Container file data, such as MP4 file data (not supported yet)

FormatDataType

enum [OHOS::Media::FormatDataType](MultiMedia_MediaCommon.md#gaa3bfacc6563d8ec8bc870f4b216b4f46) : uint32_t

Description:

Enumerates formats.

Enumerator

Description

FORMAT_TYPE_NONE 

None

FORMAT_TYPE_INT32 

Int32

FORMAT_TYPE_INT64 

Int64

FORMAT_TYPE_FLOAT 

Float

FORMAT_TYPE_DOUBLE 

Double

FORMAT_TYPE_STRING 

String

SourceType

enum [OHOS::Media::SourceType](MultiMedia_MediaCommon.md#ga4052b7b55dfd94f1d07678e79d80b507) : int32_t

Description:

Enumerates media source types.

Enumerator

Description

SOURCE_TYPE_URI 

Local file path or network address

SOURCE_TYPE_FD 

Local file descriptor

SOURCE_TYPE_STREAM 

Stream data, such as Advanced Audio Coding (AAC) stream data

VideoCodecFormat

enum [VideoCodecFormat](MultiMedia_MediaCommon.md#ga797e6c5e38e23e730eff5bcc41427d7e)

Description:

Enumerates video codec formats.

Enumerator

Description

VIDEO_DEFAULT 

Default format

H264 

H.264

HEVC 

High Efficiency Video Coding (HEVC)

Function Documentation

CopyFrom()

bool OHOS::Media::Format::CopyFrom (const [Format](OHOS-Media-Format.md) & format)

Description:

Sets all metadata to a specified format.

Parameters:

Name

Description

format Indicates the format. For details, see Format.

Returns:

Returns true if the setting is successful; returns false otherwise.

ErrCodeOffset()

constexpr ErrCode OHOS::Media::ErrCodeOffset (unsigned int subsystem, unsigned int module = [/topic/body/section/screen/code
     {""}) 0 (code] )

Description:

Generates a start error code with a unique identifier based on specified subsystem and module bit numbers.

Parameters:

Name

Description

subsystem Indicates the subsystem bit number.
module Indicates the module bit number.

Returns:

Format()

OHOS::Media::Format::Format ()

Description:

Default constructor of the Format instance.

GetBuffer()

virtual uint8_t* OHOS::Media::StreamCallback::GetBuffer (size_t index)

Description:

Obtains the virtual address of a buffer memory block based on its index.

Parameters:

Name

Description

index Indicates the index of the buffer memory block.

Returns:

Returns the pointer to the virtual address of the buffer memory block.

GetDoubleValue() [1/2]

bool OHOS::Media::Format::GetDoubleValue (const std::string & key, double & value ) const

Description:

Obtains the metadata value of the double-precision floating-point type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value to obtain, which is a double-precision floating-point number.

Returns:

Returns true if the double-precision number is successfully obtained; returns false otherwise.

GetDoubleValue() [2/2]

bool OHOS::Media::FormatData::GetDoubleValue (double & val) const

Description:

Obtains a double-precision floating-point number.

Parameters:

Name

Description

val Indicates the double-precision floating-point number to obtain.

Returns:

Returns true if the double-precision number is successfully obtained; returns false otherwise.

GetFloatValue() [1/2]

bool OHOS::Media::Format::GetFloatValue (const std::string & key, float & value ) const

Description:

Obtains the metadata value of the single-precision floating-point type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value to obtain, which is a single-precision floating-point number.

Returns:

Returns true if the single-precision number is successfully obtained; returns false otherwise.

GetFloatValue() [2/2]

bool OHOS::Media::FormatData::GetFloatValue (float & val) const

Description:

Obtains a single-precision floating-point number.

Parameters:

Name

Description

val Indicates the single-precision floating-point number to obtain.

Returns:

Returns true if the single-precision number is successfully obtained; returns false otherwise.

GetFormatMap()

const std::map<std::string, [FormatData](OHOS-Media-FormatData.md) *>& OHOS::Media::Format::GetFormatMap () const

Description:

Obtains the metadata map.

Returns:

Returns the map object.

GetInt32Value()

bool OHOS::Media::FormatData::GetInt32Value (int32_t & val) const

Description:

Obtains a 32-bit integer.

Parameters:

Name

Description

val Indicates the 32-bit integer to obtain.

Returns:

Returns true if the integer is successfully obtained; returns false otherwise.

GetInt64Value()

bool OHOS::Media::FormatData::GetInt64Value (int64_t & val) const

Description:

Obtains a long integer.

Parameters:

Name

Description

val Indicates the long integer to obtain.

Returns:

Returns true if the integer is successfully obtained; returns false otherwise.

GetIntValue()

bool OHOS::Media::Format::GetIntValue (const std::string & key, int32_t & value ) const

Description:

Obtains the metadata value of the integer type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value to obtain, which is a 32-bit integer.

Returns:

Returns true if the integer is successfully obtained; returns false otherwise.

GetLongValue()

bool OHOS::Media::Format::GetLongValue (const std::string & key, int64_t & value ) const

Description:

Obtains the metadata value of the long integer type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value to obtain, which is a 64-bit long integer.

Returns:

Returns true if the integer is successfully obtained; returns false otherwise.

GetSourceHeader()

const std::map<std::string, std::string>& OHOS::Media::Source::GetSourceHeader () const

Description:

Obtains the HTTP header for the media source.

This function is called only when the SourceType is SOURCE_TYPE_URI.

Returns:

Returns the media source header.

GetSourceStream()

const std::shared_ptr<[StreamSource](OHOS-Media-StreamSource.md)>& OHOS::Media::Source::GetSourceStream () const

Description:

Obtains information about the media source stream.

This function is called only when the SourceType is SOURCE_TYPE_STREAM.

Returns:

Returns information about the media source stream. For details, see StreamSource.

GetSourceStreamFormat()

const [Format](OHOS-Media-Format.md)& OHOS::Media::Source::GetSourceStreamFormat () const

Description:

Obtains the media source stream format.

Returns:

Returns the media source stream format. For details, see Format.

GetSourceType()

[SourceType](MultiMedia_MediaCommon.md#ga4052b7b55dfd94f1d07678e79d80b507) OHOS::Media::Source::GetSourceType () const

Description:

Obtains the source type.

Returns:

Returns the source type. For details, see SourceType.

GetSourceUri()

const std::string& OHOS::Media::Source::GetSourceUri () const

Description:

Obtains the media source URI.

This function is called only when the SourceType is SOURCE_TYPE_URI.

Returns:

Returns the media source URI.

GetStringValue() [1/2]

bool OHOS::Media::Format::GetStringValue (const std::string & key, std::string & value ) const

Description:

Obtains the metadata value of the string type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value to obtain, which is a string.

Returns:

Returns true if the string is successfully obtained; returns false otherwise.

GetStringValue() [2/2]

bool OHOS::Media::FormatData::GetStringValue (std::string & val) const

Description:

Obtains a string.

Parameters:

Name

Description

val Indicates the string to obtain.

Returns:

Returns true if the string is successfully obtained; returns false otherwise.

GetType()

[FormatDataType](MultiMedia_MediaCommon.md#gaa3bfacc6563d8ec8bc870f4b216b4f46) OHOS::Media::FormatData::GetType () const

Description:

Obtains the format type.

Returns:

Returns the format type. For details, see OHOS::Media::FormatDataType.

OnBufferAvailable()

virtual void OHOS::Media::StreamSource::OnBufferAvailable (size_t index, size_t offset, size_t size )

Description:

Notifies your application of the information about the buffer memory block that can be filled with data.

Parameters:

Name

Description

index Indicates the index of the buffer memory block.
offset Indicates the start offset into which the data will be written.
size Indicates the size of data that the buffer memory block can store.

PutDoubleValue()

bool OHOS::Media::Format::PutDoubleValue (const std::string & key, double value )

Description:

Sets metadata of the double-precision floating-point type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value, which is a double-precision floating-point number.

Returns:

Returns true if the setting is successful; returns false otherwise.

PutFloatValue()

bool OHOS::Media::Format::PutFloatValue (const std::string & key, float value )

Description:

Sets metadata of the single-precision floating-point type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value, which is a single-precision floating-point number.

Returns:

Returns true if the metadata is successfully set; returns false otherwise.

PutIntValue()

bool OHOS::Media::Format::PutIntValue (const std::string & key, int32_t value )

Description:

Sets metadata of the integer type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value, which is a 32-bit integer.

Returns:

Returns true if the setting is successful; returns false otherwise.

PutLongValue()

bool OHOS::Media::Format::PutLongValue (const std::string & key, int64_t value )

Description:

Sets metadata of the long integer type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value, which is a 64-bit integer.

Returns:

Returns true if the setting is successful; returns false otherwise.

PutStringValue()

bool OHOS::Media::Format::PutStringValue (const std::string & key, const std::string & value )

Description:

Sets metadata of the string type.

Parameters:

Name

Description

key Indicates the metadata key.
value Indicates the metadata value, which is a string.

Returns:

Returns true if the metadata is successfully set; returns false otherwise.

QueueBuffer()

virtual void OHOS::Media::StreamCallback::QueueBuffer (size_t index, size_t offset, size_t size, int64_t timestampUs, uint32_t flags )

Description:

Writes the filled buffer memory block into the player memory.

Parameters:

Name

Description

index Indicates the index of the buffer memory block.
offset Indicates the start offset into which the buffer memory block will be written.
size Indicates the size of the data filled in the buffer memory block.
timestampUs Indicates the timestamp of the frame filled in the buffer memory block. As data in AAC streams can be filled not on a frame basis, set this parameter to 0 for AAC streams.
flags Indicates the type of the current buffer memory block. For details, see BufferFlags.

SetParameters()

virtual void OHOS::Media::StreamCallback::SetParameters (const [Format](OHOS-Media-Format.md) & params)

Description:

Sets additional information about a stream.

Parameters:

Name

Description

params Indicates the parameters for additional stream information. For details, see Format.

SetStreamCallback()

virtual void OHOS::Media::StreamSource::SetStreamCallback (const std::shared_ptr< [StreamCallback](OHOS-Media-StreamCallback.md) > & callback)

Description:

Sets a callback function for your application.

Parameters:

Name

Description

callback Indicates the StreamCallback function to set.

SetValue() [1/5]

bool OHOS::Media::FormatData::SetValue (const std::string & val)

Description:

Sets a string.

Parameters:

Name

Description

val Indicates the string to set.

Returns:

Returns true if the setting is successful; returns false otherwise.

SetValue() [2/5]

bool OHOS::Media::FormatData::SetValue (double val)

Description:

Sets a double-precision floating-point number.

Parameters:

Name

Description

val Indicates the double-precision floating-point number to set.

Returns:

Returns true if the double-precision floating-point number is successfully set; returns false otherwise.

SetValue() [3/5]

bool OHOS::Media::FormatData::SetValue (float val)

Description:

Sets a single-precision floating-point number.

Parameters:

Name

Description

val Indicates the single-precision floating-point number to set.

Returns:

Returns true if the setting is successful; returns false otherwise.

SetValue() [4/5]

bool OHOS::Media::FormatData::SetValue (int32_t val)

Description:

Sets a 32-bit integer.

Parameters:

Name

Description

val Indicates the 32-bit integer to set.

Returns:

Returns true if the setting is successful; returns false otherwise.

SetValue() [5/5]

bool OHOS::Media::FormatData::SetValue (int64_t val)

Description:

Sets a 64-bit long integer.

Parameters:

Name

Description

val Indicates the 64-bit long integer to set.

Returns:

Returns true if the setting is successful; returns false otherwise.

Source() [1/3]

OHOS::Media::Source::Source (const std::shared_ptr< [StreamSource](OHOS-Media-StreamSource.md) > & stream, const [Format](OHOS-Media-Format.md) & formats )

Description:

A constructor used to create a Source instance based on the stream source and format information.

Parameters:

Name

Description

stream Indicates the media source stream. For details, see StreamSource.
formats Indicates stream data information, which is subject to the stream type. For example, the key is CODEC_MIME, and the value is MIME_AUDIO_AAC. For details, see Format. This parameter can be null if no information needs to be passed.

Source() [2/3]

OHOS::Media::Source::Source (const std::string & uri)

Description:

A constructor used to create a Source instance based on a specified URI.

Parameters:

Name

Description

uri Indicates the media source URI, which can be a network URI or local file path.

Source() [3/3]

OHOS::Media::Source::Source (const std::string & uri, const std::map< std::string, std::string > & header )

Description:

A constructor used to create a Source instance based on a specified URI and header.

If the HTTP URL header does not carry valid information for network playback, this function is equivalent to Source(const std::string& uri).

Parameters:

Name

Description

uri Indicates the media source URI.
header Indicates the header.

Variable Documentation

BITRATE_MODE_CBR

const int BITRATE_MODE_CBR = 2

Description:

Indicates the constant bit rate mode. In this mode, the codec keeps the output bit rate as constant as possible.

BITRATE_MODE_CQ

const int BITRATE_MODE_CQ = 0

Description:

Indicates the constant quality mode. In this mode, the bit rate is not limited to guarantee the image quality to the largest extent.

BITRATE_MODE_VBR

const int BITRATE_MODE_VBR = 1

Description:

Indicates the variable bit rate mode. In this mode, the codec dynamically adjusts the output bit rate based on the image complexity. The codec increases the bit rate if the image is complex and decreases the bit rate if the image is simple.

CODEC_MIME

const char* OHOS::Media::CODEC_MIME

Description:

Indicates the key representing the codec type.

COLOR_FORMAT_ARGB8888_32BIT

const int32_t COLOR_FORMAT_ARGB8888_32BIT = 16

Description:

Indicates the ARGB8888 color format.

COLOR_FORMAT_YUV420SP

const int32_t COLOR_FORMAT_YUV420SP = 21

Description:

Indicates the YUV420SP color format.

deviceId

uint32_t AudioDeviceDesc::deviceId

Description:

Bits 31-24: reserved bits; bits 23-16: mode ID; bits 15-8: device ID; bits 7-0: channel ID

deviceName

std::string AudioDeviceDesc::deviceName

Description:

Device name

ERR_EARLY_PREPARE

const int32_t OHOS::Media::ERR_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 3

Description:

Early media preparation

ERR_ILLEGAL_STATE

const int32_t OHOS::Media::ERR_ILLEGAL_STATE = BASE_MEDIA_ERR_OFFSET + 1

Description:

Status error

ERR_INVALID_OPERATION

const int32_t OHOS::Media::ERR_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 5

Description:

Invalid operation

ERR_INVALID_PARAM

const int32_t OHOS::Media::ERR_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 2

Description:

Invalid parameter

ERR_INVALID_READ

const int32_t OHOS::Media::ERR_INVALID_READ = -1

Description:

Invalid data size that has been read

ERR_NOFREE_CHANNEL

const int32_t OHOS::Media::ERR_NOFREE_CHANNEL = BASE_MEDIA_ERR_OFFSET + 6

Description:

No idle channel

ERR_NOT_STARTED

const int32_t OHOS::Media::ERR_NOT_STARTED = BASE_MEDIA_ERR_OFFSET + 8

Description:

Device not started

ERR_READ_BUFFER

const int32_t OHOS::Media::ERR_READ_BUFFER = BASE_MEDIA_ERR_OFFSET + 7

Description:

Buffer reading failed

ERR_SOURCE_NOT_SET

const int32_t OHOS::Media::ERR_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 4

Description:

No media source

ERR_UNKNOWN

const int32_t OHOS::Media::ERR_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200

Description:

Unknown error

ERROR

const int32_t OHOS::Media::ERROR = BASE_MEDIA_ERR_OFFSET

Description:

Fail

inputSourceType

[AudioSourceType](MultiMedia_MediaCommon.md#gadc3158e093b995ca7b9b6aa32388ccdd) AudioDeviceDesc::inputSourceType

Description:

Type of the audio input source

KEY_IS_SYNC_FRAME

const std::string KEY_IS_SYNC_FRAME = "is-sync-frame"

Description:

Indicates that the current frame is an Instantaneous Decoder Refresh (IDR) frame.

KEY_TIME_US

const std::string KEY_TIME_US = "timeUs"

Description:

Indicates the frame timestamp.

MIME_AUDIO_AAC

const char* OHOS::Media::MIME_AUDIO_AAC

Description:

Indicates the codec for Advanced Audio Coding (AAC) streams, which is a value of the codec type key.

MIME_AUDIO_RAW

const char* OHOS::Media::MIME_AUDIO_RAW

Description:

Indicates the codec for RAW audios (not supported yet), which is a value of the codec type key.

SUCCESS

const int32_t OHOS::Media::SUCCESS = 0

Description:

Success

1
https://gitee.com/dreaminghell/docs.git
git@gitee.com:dreaminghell/docs.git
dreaminghell
docs
docs
master

搜索帮助