- Format
- Overview
- Summary
- Files
- Data Structures
- Macros
- Typedefs
- Enumerations
- Functions
- Details
- Macro Definition Documentation
- FORMAT_INVALID_PROGRAM_ID
- FORMAT_INVALID_TRACK_ID
- FORMAT_LANGUAGE_LEN
- FORMAT_MAX_LANGUAGE_NUM
- FORMAT_TITLE_LEN
- URL_LEN
- Typedef Documentation
- CALLBACK_HANDLE
- Enumeration Type Documentation
- AudioSampleFmt
- CodecFormat
- DataFlags
- FormatErrorType
- FormatInfoType
- FormatSeekMode
- FrameType
- KeyType
- ManualSplitType
- OutputFormat
- OutputType
- SourceType
- SubtitleFormat
- SubtitleFrameType
- TrackSourceType
- TrackType
- Function Documentation
- FormatDeInit()
- FormatDemuxerCreate()
- FormatDemuxerDestory()
- FormatDemuxerFreeFrame()
- FormatDemuxerGetBufferConfig()
- FormatDemuxerGetFileInfo()
- FormatDemuxerGetParameter()
- FormatDemuxerGetSelectedTrack()
- FormatDemuxerPrepare()
- FormatDemuxerReadFrame()
- FormatDemuxerSeek()
- FormatDemuxerSelectTrack()
- FormatDemuxerSetBufferConfig()
- FormatDemuxerSetCallBack()
- FormatDemuxerSetParameter()
- FormatDemuxerStart()
- FormatDemuxerStop()
- FormatDemuxerUnselectTrack()
- FormatInit()
- FormatMuxerAddTrack()
- FormatMuxerCreate()
- FormatMuxerDestory()
- FormatMuxerGetParameter()
- FormatMuxerSetCallBack()
- FormatMuxerSetFileSplitDuration()
- FormatMuxerSetLocation()
- FormatMuxerSetMaxFileDuration()
- FormatMuxerSetMaxFileSize()
- FormatMuxerSetNextOutputFile()
- FormatMuxerSetOrientation()
- FormatMuxerSetParameter()
- FormatMuxerStart()
- FormatMuxerStop()
- FormatMuxerWriteFrame()
Format
Overview
Defines format-related APIs.
For example, you use this module to define custom data types and to initialize, create, destroy the muxer and demuxer, and set their parameters. Also, you can read demuxer data frames, select demuxer tracks, add muxer tracks, and write data frames into a container.
Since:
1.0
Version:
1.0
Summary
Files
Data Structures
Defines the data frame, which is used for data transferring. |
|
Defines a structure for configuring and obtaining dynamic parameters. |
Macros
URL_LEN 4096 |
Typedefs
Indicates the pointer to the callback handle for listening the muxer. |
Enumerations
Functions
FormatInit (void) |
|
FormatDeInit (void) |
|
FormatDemuxerCreate (const FormatSource source, void **handle) |
|
FormatDemuxerSetParameter (const void handle, int32_t trackId, const ParameterItem metaData, int32_t metaDataCnt) |
|
FormatDemuxerGetParameter (const void handle, int32_t trackId, ParameterItem metaData) |
|
FormatDemuxerSetCallBack (void handle, const FormatCallback callBack) |
|
FormatDemuxerSetBufferConfig (void handle, const FormatBufferSetting setting) |
|
FormatDemuxerGetBufferConfig (const void handle, FormatBufferSetting setting) |
|
FormatDemuxerPrepare (void handle) |
|
FormatDemuxerGetFileInfo (void handle, FileInfo info) |
|
FormatDemuxerSelectTrack (const void handle, int32_t programId, int32_t trackId) |
|
FormatDemuxerUnselectTrack (const void handle, int32_t programId, int32_t trackId) |
Unselects a specified media track from which the demuxer reads data frames. |
FormatDemuxerStart (void handle) |
|
FormatDemuxerGetSelectedTrack (const void handle, int32_t programId, int32_t trackId[], int32_t nums) |
Obtains the ID of the media track selected by the demuxer for output. |
FormatDemuxerReadFrame (const void handle, FormatFrame frame, int32_t timeOutMs) |
|
FormatDemuxerFreeFrame (void handle, FormatFrame frame) |
|
FormatDemuxerSeek (const void handle, int32_t streamIndex, int64_t timeStampUs, FormatSeekMode mode) |
|
FormatDemuxerStop (void handle) |
|
FormatDemuxerDestory (void handle) |
|
FormatMuxerCreate (void **handle, FormatOutputConfig outputConfig) |
|
FormatMuxerDestory (const void handle) |
Destroys a muxer and release its resources created by calling FormatMuxerCreate. |
FormatMuxerAddTrack (void handle, const TrackSource trackSource) |
Adds a media track source for the muxer. For details about track sources, see TrackSource. |
FormatMuxerSetCallBack (void handle, const FormatCallback callBack) |
Sets a callback for the muxer. For details about the callback, see FormatCallback. |
FormatMuxerSetOrientation (void handle, int degrees) |
|
FormatMuxerSetLocation (const void handle, int latitude, int longitude) |
Sets the geographical information for the output file of the muxer. |
FormatMuxerSetMaxFileSize (void handle, int64_t bytes) |
Sets the maximum size (in bytes) for the output file of the muxer. |
FormatMuxerSetMaxFileDuration (void handle, int64_t durationUs) |
|
FormatMuxerSetFileSplitDuration (const void handle, ManualSplitType type, int64_t timestampUs, uint32_t durationUs) |
|
FormatMuxerStart (void handle) |
|
FormatMuxerWriteFrame (const void handle, const FormatFrame frameData) |
|
FormatMuxerSetNextOutputFile (const void handle, int32_t fd) |
|
FormatMuxerStop (const void handle, bool block) |
Stops the muxer that was started by calling FormatMuxerStart. |
FormatMuxerSetParameter (void handle, int32_t trackId, const ParameterItem item, int32_t itemNum) |
|
FormatMuxerGetParameter (void handle, int32_t trackId, ParameterItem *item, int32_t itemNum) |
Details
Macro Definition Documentation
FORMAT_INVALID_PROGRAM_ID
#define FORMAT_INVALID_PROGRAM_ID -1
Description:
Indicates an invalid program ID.
FORMAT_INVALID_TRACK_ID
#define FORMAT_INVALID_TRACK_ID -1
Description:
Indicates an invalid track ID.
FORMAT_LANGUAGE_LEN
#define FORMAT_LANGUAGE_LEN 4
Description:
Indicates the number of characters contained in the language description.
FORMAT_MAX_LANGUAGE_NUM
#define FORMAT_MAX_LANGUAGE_NUM 4
Description:
Indicates the number of languages in the subtitle file.
FORMAT_TITLE_LEN
#define FORMAT_TITLE_LEN 64
Description:
Indicates the number of title characters.
URL_LEN
#define URL_LEN 4096
Description:
Indicates the URL length.
Typedef Documentation
CALLBACK_HANDLE
typedef void* [CALLBACK_HANDLE]($api-api-SmartVision-Devices-Format.md#gab928f39c359734527bda3fd160f89331)
Description:
Indicates the pointer to the callback handle for listening the muxer.
Enumeration Type Documentation
AudioSampleFmt
enum [AudioSampleFmt]($api-api-SmartVision-Devices-Format.md#gadf0700999998f587f0017c4d02977b22)
Description:
Enumerates audio sampling formats.
AUDIO_SAMPLE_FMT_S8 | |
AUDIO_SAMPLE_FMT_S16 | |
AUDIO_SAMPLE_FMT_S24 | |
AUDIO_SAMPLE_FMT_S32 | |
AUDIO_SAMPLE_FMT_FLOAT |
CodecFormat
enum [CodecFormat]($api-api-SmartVision-Devices-Format.md#gaf7ed135f15d4b218d41705bac0122ba7)
Description:
Enumerates audio, video, and image encoding formats.
CODEC_H264 | |
CODEC_H265 | |
CODEC_JPEG | |
CODEC_AAC | |
CODEC_G711A | |
CODEC_G711U | |
CODEC_PCM | |
CODEC_MP3 | |
CODEC_BUT |
DataFlags
enum [DataFlags]($api-api-SmartVision-Devices-Format.md#gacff079fdf8427c743f9197ea5be33a7f)
Description:
Enumerates flags of raw stream data.
FormatErrorType
enum [FormatErrorType]($api-api-SmartVision-Devices-Format.md#ga31e7fcf42722fa15e4e5489c2fef9092)
Description:
Enumerates callback error types.
FormatInfoType
enum [FormatInfoType]($api-api-SmartVision-Devices-Format.md#ga6f00342925d3d5e586c76f8695985cad)
Description:
Enumerates types of callback information.
MUXER_INFO_MAX_DURATION_APPROACHING | The capturing duration is reaching the threshold specified by FormatMuxerSetMaxFileDuration. This information is reported when only one second or 10% is left to reach the allowed duration. |
MUXER_INFO_MAX_FILESIZE_APPROACHING | The captured file size is reaching the threshold specified by FormatMuxerSetMaxFileSize. This information is reported when only 100 KB or 10% is left to reach the allowed size. |
MUXER_INFO_MAX_DURATION_REACHED | The capturing duration reached the threshold specified by FormatMuxerSetMaxFileDuration, and the capturing is ended. If the file is set by a file descriptor, the caller needs to close the file. |
MUXER_INFO_MAX_FILESIZE_REACHED | The captured file size reached the threshold specified by FormatMuxerSetMaxFileSize, and the capturing is ended. If the file is set by a file descriptor, the caller needs to close the file. |
MUXER_INFO_NEXT_OUTPUT_FILE_STARTED | |
MUXER_INFO_FILE_SPLIT_FINISHED | |
MUXER_INFO_FILE_START_TIME_MS | |
DEMUXER_INFO_PREPARED | The prepare function is asynchronously executed. This information is reported after the execution is complete. |
DEMUXER_INFO_SEEK_COMPLETE | The seek function is asynchronously executed. This information is reported after the execution is complete. |
DEMUXER_INFO_NETWORK_DISCONNECTED | |
DEMUXER_INFO_NETWORK_RECONNECTED | The network is automatically reconnected during network playback. |
FormatSeekMode
enum [FormatSeekMode]($api-api-SmartVision-Devices-Format.md#ga14aa9d18a71eff4a0b70f748f0377c94)
Description:
Enumerates seek modes.
FrameType
enum [FrameType]($api-api-SmartVision-Devices-Format.md#gad495a9f61af7fff07d7e97979d1ab854)
Description:
Enumerates data frame types.
FRAME_TYPE_NONE | Unknown type, which can be used for transport stream (TS) packets |
FRAME_TYPE_AUDIO | |
FRAME_TYPE_VIDEO | |
FRAME_TYPE_IMAGE | |
FRAME_TYPE_SUB | |
FRAME_TYPE_DATA | |
FRAME_TYPE_BUT |
KeyType
enum [KeyType]($api-api-SmartVision-Devices-Format.md#gaab0feaba617470cb4aa830dc5935238c)
Description:
Enumerates key types used for setting and obtaining parameters.
KEY_TYPE_MIME | |
KEY_TYPE_HTTP_HEADERS | |
KEY_TYPE_LANGUAGE | Track language, which is usually the language of audio and subtitles. The value type is cstring. |
KEY_TYPE_PRE_CACHE |
ManualSplitType
enum [ManualSplitType]($api-api-SmartVision-Devices-Format.md#ga10d9833450f29129d249c41d9acb4bc4)
Description:
Enumerates manual split types for the muxer.
OutputFormat
enum [OutputFormat]($api-api-SmartVision-Devices-Format.md#gaeb712c6c6c0a8af0dfd79f451ecb9277)
Description:
Enumerates output file formats.
OUTPUT_FORMAT_MPEG_4 | |
OUTPUT_FORMAT_TS | |
OUTPUT_FORMAT_THREE_GPP | |
OUTPUT_FORMAT_HEIF | |
OUTPUT_FORMAT_OGG | |
OUTPUT_FORMAT_INVALID |
OutputType
enum [OutputType]($api-api-SmartVision-Devices-Format.md#ga4e0517338e6c4a31a2addafc06d4f3a3)
Description:
Enumerates muxer output types.
OUTPUT_TYPE_FD | |
OUTPUT_TYPE_URI | |
OUTPUT_TYPE_INVALID |
SourceType
enum [SourceType]($api-api-SmartVision-Devices-Format.md#ga3ae727773c367ac1041d72ac770a0ab1)
Description:
Enumerates types of the demuxer data source.
SOURCE_TYPE_FD | |
SOURCE_TYPE_URI | |
SOURCE_TYPE_STREAM | |
SOURCE_TYPE_BUT |
SubtitleFormat
enum [SubtitleFormat]($api-api-SmartVision-Devices-Format.md#gadac45ce4731516c262292c15433439b3)
Description:
Enumerates subtitle file formats.
FORMAT_SUB_ASS | |
FORMAT_SUB_LRC | |
FORMAT_SUB_SRT | |
FORMAT_SUB_SMI | |
FORMAT_SUB_SUB | |
FORMAT_SUB_TXT | |
FORMAT_SUB_HDMV_PGS | |
FORMAT_SUB_DVB_SUB | |
FORMAT_SUB_DVD_SUB | |
FORMAT_SUB_TTML | |
FORMAT_SUB_WEBVTT | |
FORMAT_SUB_BUTT |
SubtitleFrameType
enum [SubtitleFrameType]($api-api-SmartVision-Devices-Format.md#ga43b7f046e365a89697272d850b0517b7)
Description:
Enumerates subtitle frame types.
HI_SVR_SUBTITLE_BITMAP | |
HI_SVR_SUBTITLE_TEXT |
TrackSourceType
enum [TrackSourceType]($api-api-SmartVision-Devices-Format.md#ga953bc46f95d7b2d8866838d792f8f6aa)
Description:
Enumerates types of the muxer source track.
TRACK_SOURCE_TYPE_VIDEO | |
TRACK_SOURCE_TYPE_AUDIO | |
TRACK_SOURCE_TYPE_DATA | |
TRACK_SOURCE_TYPE_INVALID |
TrackType
enum [TrackType]($api-api-SmartVision-Devices-Format.md#gad80740dd555f7d3688d2c4d9f44d3b04)
Description:
Enumerates track types.
TRACK_TYPE_VIDEO | |
TRACK_TYPE_AUDIO | |
TRACK_TYPE_IMAGE | |
TRACK_TYPE_SUB | |
TRACK_TYPE_DATA | |
TRACK_TYPE_BUT |
Function Documentation
FormatDeInit()
void FormatDeInit (void )
Description:
Deinitializes the format.
You can call this function to deinitialize the demuxer and muxer. This function works in pair with FormatInit.
FormatDemuxerCreate()
int32_t FormatDemuxerCreate (const [FormatSource]($api-api-SmartVision-Devices-FormatSource.md) * source, void ** handle )
Description:
Creates a demuxer component and returns its context handle.
This function returns the demuxer context handle without probing the container format or obtaining stream information.
Parameters:
source | Indicates the pointer to the format source of the demuxer. For details, see FormatSource. |
handle | Indicates the double pointer to the demuxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerDestory()
int32_t FormatDemuxerDestory (void * handle)
Description:
Destroys demuxer resources.
This function works in pair with FormatDemuxerCreate. If you do not call this function, resource leakage may occur.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerFreeFrame()
int32_t FormatDemuxerFreeFrame (void * handle, [FormatFrame]($api-api-SmartVision-Devices-FormatFrame.md) * frame )
Description:
Frees data frames.
You can call this function to free the data frames obtained by calling FormatDemuxerReadFrame.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
frame | Indicates the pointer to the data structure FormatFrame. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerGetBufferConfig()
int32_t FormatDemuxerGetBufferConfig (const void * handle, [FormatBufferSetting]($api-api-SmartVision-Devices-FormatBufferSetting.md) * setting )
Description:
Obtains the buffer information of the demuxer.
If there is a buffer mechanism in the demuxer, you can call this function to obtain the maximum buffer size and time.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
setting | Indicates the pointer to the maximum demuxer buffer size and time, as defined in FormatBufferSetting. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerGetFileInfo()
int32_t FormatDemuxerGetFileInfo (void * handle, [FileInfo]($api-api-SmartVision-Devices-FileInfo.md) * info )
Description:
Obtains the attributes of a media file.
The attributes contain file, program, and stream attributes. This function should be called after FormatDemuxerPrepare is called.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
info | Indicates the pointer to the source attributes, as defined in FileInfo. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerGetParameter()
int32_t FormatDemuxerGetParameter (const void * handle, int32_t trackId, [ParameterItem]($api-api-SmartVision-Devices-ParameterItem.md) * metaData )
Description:
Obtains demuxer attributes.
You can call this function to obtain the HTTP header, HTTP referer, and other extension items for the demuxer after FormatDemuxerCreate is called. The demuxer will store the value in the metaData based on the key.If the demuxer has allocated memory for the metaData to store the value, the caller should manually free the memory.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
trackId | Identifies the track. If the value is an invalid value (-1), this parameter identifies the file or program. |
metaData | Indicates the pointer to the buffer for storing the parameters values that the demuxer has searched for based on the input key. For details, see ParameterItem. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerGetSelectedTrack()
int32_t FormatDemuxerGetSelectedTrack (const void * handle, int32_t * programId, int32_t trackId[], int32_t * nums )
Description:
Obtains the ID of the media track selected by the demuxer for output.
The demuxer automatically selects the default program and its media tracks. However, if the program and media tracks have changed after FormatDemuxerSelectTrack and FormatDemuxerUnselectTrack are called, you can obtain the currently selected program and media tracks by calling this function (FormatDemuxerGetSelectedTrack.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerPrepare()
int32_t FormatDemuxerPrepare (void * handle)
Description:
Makes preparations for the demuxer.
This function triggers the demuxer to probe the media file container format and parse stream information. You can obtain media file attributes only after this function is called.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerReadFrame()
int32_t FormatDemuxerReadFrame (const void * handle, [FormatFrame]($api-api-SmartVision-Devices-FormatFrame.md) * frame, int32_t timeOutMs )
Description:
Reads data frames.
After the data frames are read, you need to call FormatDemuxerFreeFame to free them.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
frame | Indicates the pointer to the data structure FormatFrame. |
timeOutMs | Indicates the time required for waiting data frame read. The value 0 indicates that data frames are immediately read without any wait. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerSeek()
int32_t FormatDemuxerSeek (const void * handle, int32_t streamIndex, int64_t timeStampUs, [FormatSeekMode]($api-api-SmartVision-Devices-Format.md#ga14aa9d18a71eff4a0b70f748f0377c94) mode )
Description:
Seeks for a specified position for the demuxer.
After being started, the demuxer seeks for a specified position to read data frames. You can specify the position close to the time specified by streamIndex.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
streamIndex | Identifies the stream in the media file. |
timeStampUs | Indicates the target position, in microseconds. |
mode | Indicates the seek mode, as defined in FormatSeekMode. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerSelectTrack()
int32_t FormatDemuxerSelectTrack (const void * handle, int32_t programId, int32_t trackId )
Description:
Selects a specified media track.
The media tracks to select must belong to the same program. If you do not call this function, the default media tracks of the default program are selected. If programId is valid but trackId is invalid, the default media track of the specified program is used.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
programId | Identifies the program. |
trackId | Identifies the media track. If a valid value is passed, the media track must belong to the specified program. If an invalid value is passed, the default media track of the specified program is used. If multiple audio tracks are specified, the player determines which audio track to use. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerSetBufferConfig()
int32_t FormatDemuxerSetBufferConfig (void * handle, const [FormatBufferSetting]($api-api-SmartVision-Devices-FormatBufferSetting.md) * setting )
Description:
Sets buffer information for the demuxer.
If there is a buffer mechanism in the demuxer, you can call this function to set the maximum buffer size and time. Alternatively, you can disable the buffer mechanism by setting the buffer size and time to 0 in the setting parameter. If there is no buffer mechanism or the default setting is retained, you can skip this function.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
setting | Indicates the pointer to the maximum demuxer buffer size and time, as defined in FormatBufferSetting. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerSetCallBack()
int32_t FormatDemuxerSetCallBack (void * handle, const [FormatCallback]($api-api-SmartVision-Devices-FormatCallback.md) * callBack )
Description:
Sets a callback for the demuxer.
The callback will be invoked to notify the upper layer of internal events of the demuxer.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
callBack | Indicates the pointer to the callback, as defined in FormatCallback. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerSetParameter()
int32_t FormatDemuxerSetParameter (const void * handle, int32_t trackId, const [ParameterItem]($api-api-SmartVision-Devices-ParameterItem.md) * metaData, int32_t metaDataCnt )
Description:
Sets demuxer attributes.
You can call this function to set the HTTP header, HTTP referer, and other extension items for the demuxer after FormatDemuxerCreate is called.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
trackId | Identifies the track. If the value is an invalid value (-1), this parameter identifies the file or program. |
metaData | Indicates the pointer to an array of key-value pairs representing parameter names and values. For details, see ParameterItem. |
metaDataCnt | Indicates the number of key-value pairs in the array. This parameter works in pair with metaData. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerStart()
int32_t FormatDemuxerStart (void * handle)
Description:
Starts the demuxer.
After being started, the caller can read data frames from the demuxer. This function should be called after FormatDemuxerPrepare is called.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerStop()
int32_t FormatDemuxerStop (void * handle)
Description:
Stops the demuxer from working.
After this function is called, the demuxer cannot resume decapsulation.
Parameters:
handle | Indicates the pointer to the demuxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatDemuxerUnselectTrack()
int32_t FormatDemuxerUnselectTrack (const void * handle, int32_t programId, int32_t trackId )
Description:
Unselects a specified media track from which the demuxer reads data frames.
The demuxer can read all media tracks of the default program. You can call this function to unselect all or certain tracks of a specified program that the demuxer is expected not to read. If trackId is invalid, the demuxer will read none of the tracks of the specified program.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatInit()
void FormatInit (void )
Description:
Initializes the format.
You can call this function to initialize the demuxer and muxer. This function should always be called before other format-specific functions, and it can be called only once within a process.
FormatMuxerAddTrack()
int32_t FormatMuxerAddTrack (void * handle, const [TrackSource]($api-api-SmartVision-Devices-TrackSource.md) * trackSource )
Description:
Adds a media track source for the muxer. For details about track sources, see TrackSource.
This function must be called after FormatMuxerCreate is successfully called and before FormatMuxerStart is called.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
trackSource | Indicates the pointer to the track source. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerCreate()
int32_t FormatMuxerCreate (void ** handle, [FormatOutputConfig]($api-api-SmartVision-Devices-FormatOutputConfig.md) * outputConfig )
Description:
Creates a muxer and returns its context handle.
Parameters:
handle | Indicates the double pointer to the muxer context handle. |
outputConfig | Indicates the pointer to the muxer output configuration, as defined in FormatOutputConfig. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerDestory()
int32_t FormatMuxerDestory (const void * handle)
Description:
Destroys a muxer and release its resources created by calling FormatMuxerCreate.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerGetParameter()
int32_t FormatMuxerGetParameter (void * handle, int32_t trackId, [ParameterItem]($api-api-SmartVision-Devices-ParameterItem.md) * item, int32_t itemNum )
Description:
Obtains muxer attributes.
This is an extended function that can be used to obtain muxer or track attributes. The demuxer then obtains the muxer attributes based on the key contained in item.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
trackId | Identifies the media track. If the value is FORMAT_INVALID_TRACK_ID, this function obtains the muxer attributes. |
item | Indicates the pointer to the items carrying muxer attributes. You can specify multiple items at a time in this parameter, which works in pair with itemNum. |
itemNum | Indicates the number of attributes set at a time. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value if any requested attribute fails to be obtained or is not found.
FormatMuxerSetCallBack()
int32_t FormatMuxerSetCallBack (void * handle, const [FormatCallback]($api-api-SmartVision-Devices-FormatCallback.md) * callBack )
Description:
Sets a callback for the muxer. For details about the callback, see FormatCallback.
This function should be called after FormatMuxerCreate is successfully called.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
FormatCallback | Indicates the pointer to the muxer callback to set. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetFileSplitDuration()
int32_t FormatMuxerSetFileSplitDuration (const void * handle, [ManualSplitType]($api-api-SmartVision-Devices-Format.md#ga10d9833450f29129d249c41d9acb4bc4) type, int64_t timestampUs, uint32_t durationUs )
Description:
Manually splits a file.
This function can be called after FormatMuxerStart is called. Once this function is called, the file is split based on the manual split type. After manual split is complete, file split will proceed to use the initially set split type. You can call this function again only after the MUXER_INFO_FILE_SPLIT_FINISHED event is reported.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetLocation()
int32_t FormatMuxerSetLocation (const void * handle, int latitude, int longitude )
Description:
Sets the geographical information for the output file of the muxer.
This function should be called after FormatMuxerCreate is successfully called.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
latitude | Indicates the latitude, within the range [-90,90]. |
longitude | Indicates the longitude, within the range [-180,180]. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetMaxFileDuration()
int32_t FormatMuxerSetMaxFileDuration (void * handle, int64_t durationUs )
Description:
Sets the maximum duration (in seconds) for the output file.
You need to call this function before calling FormatMuxerStart. If the maximum duration you set is valid and capturing is approaching 90% of that duration or the remaining duration is 1s, the message MUXER_INFO_MAX_DURATION_APPROACHING is reported via OnInfo of FormatCallback. If the output file has been set by calling FormatMuxerCreate, you need to call FormatMuxerSetNextOutputFile to set the next output file. Otherwise, the current output file will be overwritten when the capturing reaches the maximum duration you set.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetMaxFileSize()
int32_t FormatMuxerSetMaxFileSize (void * handle, int64_t bytes )
Description:
Sets the maximum size (in bytes) for the output file of the muxer.
This function should be called after FormatMuxerCreate is successfully called.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetNextOutputFile()
int32_t FormatMuxerSetNextOutputFile (const void * handle, int32_t fd )
Description:
Sets the descriptor for the next output file.
If FormatMuxerCreate is successfully called and the file descriptor involved is valid, you can call this function (FormatMuxerSetNextOutputFile) upon receiving the message MUXER_INFO_MAX_FILESIZE_APPROACHING or MUXER_INFO_MAX_DURATION_APPROACHING.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
fd | Indicates the file descriptor to set. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetOrientation()
int32_t FormatMuxerSetOrientation (void * handle, int degrees )
Description:
Sets the orientation of the video track for the muxer.
This function should be called after FormatMuxerAddTrack is successfully called. The following degrees are supported: 0, 90, 180, and 270.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
degrees | Indicates the clockwise angle of the video track. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerSetParameter()
int32_t FormatMuxerSetParameter (void * handle, int32_t trackId, const [ParameterItem]($api-api-SmartVision-Devices-ParameterItem.md) * item, int32_t itemNum )
Description:
Sets muxer attributes.
This is an extended function that can be used to add MP4-dedicated boxes and tags (such as exif).
Parameters:
handle | Indicates the pointer to the muxer context handle. |
trackId | Identifies the media track. If the value is FORMAT_INVALID_TRACK_ID, this function sets the muxer attributes. |
item | Indicates the pointer to the items carrying muxer attributes. You can specify multiple items at a time in this parameter, which works in pair with itemNum. |
itemNum | Indicates the number of attributes set at a time. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerStart()
int32_t FormatMuxerStart (void * handle)
Description:
Starts the muxer.
You can call this function to encapsulate media data after the muxer is created, media tracks are added, and related parameters are set.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerStop()
int32_t FormatMuxerStop (const void * handle, bool block )
Description:
Stops the muxer that was started by calling FormatMuxerStart.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
FormatMuxerWriteFrame()
int32_t FormatMuxerWriteFrame (const void * handle, const [FormatFrame]($api-api-SmartVision-Devices-FormatFrame.md) * frameData )
Description:
Writes data frames into the muxer.
This function should be called after FormatMuxerCreate is successfully called.
Parameters:
handle | Indicates the pointer to the muxer context handle. |
frameData | Indicates the pointer to the data structure FormatFrame. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.