Input parameter for the stream start function, used to get image resources. This function is customized by the user. The interface only provides type definitions to standardize the definition of callback functions.
int start_stream(string stream_id, GetImageCB &cb)
Start a stream based on stream id (since stream configuration is complex, it is recommended to configure the stream through a configuration file, this interface is the only recommended interface)
int start_stream_input_file(string file_path, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Start file stream
int start_stream_input_rtsp(string rtsp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Start RTSP stream
int start_stream_input_rtmp(string rtmp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Start RTMP stream
ENUM
Public Member Variable
Type
Description
GSTLogLevel
SINFO
uint8_t
Log level SINFO
SWARNING
uint8_t
Log level SWARNING
SERROR
uint8_t
Log level SERROR
SDEBUG
uint8_t
Log level SDEBUG
SOFF
uint8_t
Log level SOFF
StreamType
EMPTY
uint8_t
Stream protocol type empty
WAYLANDSINK
uint8_t
Stream protocol type WayLand
RTSPSINK
uint8_t
Stream protocol type RTSP
RTMPSINK
uint8_t
Stream protocol type RTMP
Structure Image
Defines image data-related information, including image configuration information and pointer variables.
Member Variable
Type
Default Value
Description
data
const char *
Pointer to the buffer storing data
data_mask
const char *
Pointer to the buffer storing mask data (reserved)
stream_id
string
Unique ID identifying the stream (required, convenient for locating in multi-threaded conditions)
width
int
Image width
height
int
Image height
width_padding
int
Target image width padding (only used for 6490 ql)
height_padding
int
Target image height padding (only used for 6490 ql)
size
uint64_t
Memory length occupied by image data
fps
double
Frame rate
idx
uint64_t
Frame counter
frame_time
string
Frame timestamp (only used for 6490 ql)
Unless otherwise specified, all definitions belong to the namespace AidLux::AidStream. It can be introduced in the code with the following command:
using namespace AidLux::AidStream;
Start Stream Based on Stream ID
API
int start_stream(string stream_id, GetImageCB &cb)
Description
Start a stream. Parameter is stream id. Stream id and corresponding configuration are defined in the file /usr/local/share/aidstream-gst/conf/aidstream-gst.conf. The stream id in this configuration file must be unique. Note: This interface is the only strongly recommended interface
Parameters
stream_id: Identifies a unique stream configuration. cb: Callback function. Regarding callback functions, please refer to Callback Function. For information on how to set up the configuration file, please refer to Reference
Return Value
0: Success, -1: Failure
Example:
// Start a stream identified as stream1
int res = start_stream("stream1", my_cb);
Start File Stream
API
int start_stream_input_file(string file_path, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Description
Start a file stream. Does not depend on configuration file, directly configure corresponding parameters.
Parameters
file_path: Source MP4 data file. cb: Callback function. display_type: Output stream type. target_path: Output stream target address. Note: width and height are no longer effective
Return Value
0: Success, -1: Failure
Example:
// Start file stream
int res = start_stream_input_file("./test.mp4", my_cb, StreamType::WAYLANDSINK, "rtsp://192.168.111.115:8554/aidstream-gst-test-6");
Start RTSP Stream
API
int start_stream_input_rtsp(string rtsp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Description
Start RTSP stream. Does not depend on configuration file, directly configure corresponding parameters.
Parameters
rtsp_addr: Source RTSP address. cb: Callback function. display_type: Output stream type. target_path: Output stream target address. Note: width and height are no longer effective
Return Value
0: Success, -1: Failure
Example:
// Start RTSP stream
int res = start_stream_input_rtsp("rtsp://admin:[email protected]:554/h264/ch1/main/av_stream", my_cb, StreamType::RTSPSINK, "rtsp://192.168.111.115:8554/aidstream-gst-test-3");
Start RTMP Stream
API
int start_stream_input_rtmp(string rtmp_addr, GetImageCB cb, StreamType display_type, string target_path, int width, int height, string stream_id)
Description
Start RTMP stream. Does not depend on configuration file, directly configure corresponding parameters.
Parameters
rtmp_addr: Source RTMP address. cb: Callback function. display_type: Output stream type. target_path: Output stream target address. Note: width and height are no longer effective
Return Value
0: Success, -1: Failure
Example:
// Start RTMP stream
int res = start_stream_input_rtmp("rtmp://admin:[email protected]:554/h264/ch1/main/av_stream", my_cb, StreamType::EMPTY, "rtsp://192.168.111.115:8554/aidstream-gst-test-2");
Create Log, Set Filename and Path (function clogger)
API
void clogger(const char* path_and_prefix)
Description
Create log, set filename and path
Parameters
path_and_prefix: Log filename with path. Example: "./aidclog_aidstream_".
Return Value
None
Example:
// Create log, set filename and path
const char* log_path = "./aidclog_aidstream_";
Aidlux::AidStream::clogger(log_path);
Set Log Level (function set_log_level)
API
void set_log_level(GSTLogLevel log_level)
Description
Set log level.
Parameters
log_level is an enumeration of GSTLogLevel type. For information about GSTLogLevel, please refer to Enum GSTLogLevel
Return Value
None
Example:
// Set log level
Aidlux::AidStream::set_log_level(GSTLogLevel::SINFO);
Input parameter for the stream start function, used to get image resources. This function is customized by the user. The interface only provides type definitions to standardize the definition of callback functions.
Parameters
The first parameter is an instantiated object of the structure Image, through which data is passed in. Image object includes parameters such as pointers to data buffer, data width and height, frame rate, etc. Please refer to Image for details