This topic describes the functions of Native RTS SDK.
Overview
Function | Description |
---|---|
get_rts_funcs | Queries other function pointers. This is the only visible function. |
preconfig | Sets a global parameter. |
open | Opens a stream. |
close | Closes a stream. |
ioctl | Queries a parameter of Native RTS SDK. |
read | Reads a data frame from Native RTS SDK. |
write | Sends a data frame to Native RTS SDK. |
Sample code
- get_rts_funcs: queries other function pointers. This is the only visible function.
const struct rts_glue_funcs *get_rts_funcs( int version );
Parameter description
Parameter Type Description version int The API version. Set the value to 2. Return value description
If the pointer of the rts_glue_funcs function is returned, the call is successful. If NULL is returned, the call fails. In most cases, a call fails because the value of the version parameter is invalid.
- preconfig: sets a global parameter. You must call the preconfig function before you
call the open function or after you call the close function.
int (* preconfig)( const char *key, const char *val );
Parameter description
Parameter Type Description key const char * The name of the parameter. The name is case-sensitive. For more information, see the following table. val const char * The value of the parameter. Parameter Description AutoReconnect Specifies whether to enable automatic reconnection if Native RTS SDK detects a disconnection. By default, automatic reconnection is enabled. BufferingDuration The duration of the jitter buffer. Default value: 500. Unit: milliseconds. LogCallback Sets the callback function of external logs. This parameter takes effect only if the LogCbParam parameter is also set. LogCbParam Sets parameters for the callback function of external logs. This parameter takes effect only if the LogCallback parameter is also set. LogToConsole Specifies whether to export built-in logs to the ApsaraVideo Live console. By default, built-in logs are not exported to the ApsaraVideo Live console. LogToFile Specifies whether to export built-in logs to a file. By default, built-in logs are not exported to a file. LogToServer Specifies whether to export built-in logs to a server. By default, built-in logs are not exported to a server. MessageCallback Sets the message callback function. This parameter takes effect only if the MessageCbParam parameter is also set. MessageCbParam Sets parameters for the message callback function. This parameter takes effect only if the MessageCallback parameter is also set. AacdCreateCallback Sets the callback for creating an external Advanced Audio Coding (AAC) decoder. AacdDecodeCallback Sets the callback for using an external AAC decoder to perform decoding. AacdCloseCallback Sets the callback for closing an external AAC decoder. HelpSupportIDPrefix Specifies the prefix of the help support ID. LogLevel Note This parameter can be used only in Native RTS SDK 2.1.0 or later.The level of the logs to be obtained in a callback. Valid values: - 0: the ERR level.
- 1: the WARN level.
- 2: the INFO level.
- 3: the DEBUG level.
- 100: the NONE level.
SigTimeoutMs Note This parameter can be used only in Native RTS SDK 2.2.0 or later.The signaling timeout period. Unit: milliseconds. Default value: 10000. We recommend that you set the parameter to a value no less than 6000. Return value description
If 0 is returned, the call is successful. Otherwise, the call fails.
- open: opens a stream.
void *(* open){ const char *url, const char *mode );
Parameter description
Parameter Type Description url const char * The URL of the stream. URLs that start with artc://
are supported.mode const char * The operation mode of the stream. Valid values: - r: plays the stream.
- w: pushes the stream.
Return value description
If a handle is returned, the call is successful. If NULL is returned, the call fails.
- close: closes a stream.
void (* close)( void *handle );
Parameter description
Parameter Type Description handle void * The handle that is returned when the open function is called. - ioctl: queries a parameter of Native RTS SDK.
long long (* ioctl)( void *handle, const char *cmd, void *arg );
Parameter description
Parameter Type Description handle void * The handle that is returned when the open function is called. cmd const char * The command that is sent. For more information about available commands, see the following table. arg void * The parameters of the sent command. If the command does not contain parameters, set this parameter to NULL. Command Command parameter Description get_stream_info The variable address of rts_worker_demux_info. Obtains the stream information from Native RTS SDK and stores the information in the corresponding rts_worker_demux_info variable to which the arg parameter points. The value of this variable cannot be NULL. reload NULL Prompts Native RTS SDK to reconnect. skip_avformat_find_stream_info Note This command can be used only in Native RTS SDK 2.2.0 or later.NULL Specifies whether the code line avformat_find_stream_info()
can be skipped when players that depend on FFmpeg start to play streams.If 0 is returned, the code line cannot be skipped. If 1 is returned, the code line can be skipped.
Notice If you want to instantly play streams, we recommend that you run this command.Return value description
If 0 is returned, the call is successful. Otherwise, the call fails.
- read: reads a data frame from Native RTS SDK.
int (* read)( struct **frame, void *handle );
Parameter description
Parameter Type Description frame struct ** The location in which the returned audio or video frame is stored. handle void * The handle that is returned when the open function is called. Return value description
- If 1 is returned, one data frame is read.
- If 0 is returned, the system tries again later.
- If -1 is returned, end-of-file (EOF) occurs.
- If a negative number other than -1 is returned, a severe error occurs.
NoteIf 1 is returned, the caller must release the returned frame. Sample code:
struct rts_frame *f = NULL; int r = __rts_funcs->read(&f, handle); ... if(f != NULL) f->free_ptr(f);
- write: sends a data frame to Native RTS SDK.
int (* write)( struct **frame, void *handle );
Parameter description
Parameter Type Description frame struct ** The audio or video frame to be sent. handle void * The handle that is returned when the open function is called. Return value description
- If 1 is returned, the call is successful.
- If 0 is returned, the system tries again later.
- If -1 is returned, EOF occurs.
- If a negative number other than -1 is returned, a severe error occurs.
Note If 1 is returned, the ownership of the returned frame is transferred to and released by Native RTS SDK.