使用live555源码目录中testProgs目录中的testOnDemandRTSPServer.cpp进行推流,可以设置推流端口号、推流地址以及推流数据源文件。
编译live555,生成testOnDemandRTSPServer可执行文件。运行testOnDemandRTSPServer即可启动推流服务。
1、需要修改其中的OutPacketBuffer::maxSize,改为1000000,避免推流数据包大小超限。
2、设置推流端口号
RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554, authDB);
创建服务时,指定端口号即可。
4、设置访问权限
UserAuthenticationDatabase* authDB = NULL;
#ifdef ACCESS_CONTROL
// To implement client access control to the RTSP server, do the following:
authDB = new UserAuthenticationDatabase;
authDB->addUserRecord("username1", "password1"); // replace these with real strings
// Repeat the above with each <username>, <password> that you wish to allow
// access to the server.
#endif
RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554, authDB);
如注释所述,创建服务前,设置authDB,并定义ACCESS_CONTROL宏即可。
5、设置推流地址
char const* streamName = "h264ESVideoTest";
rtsp推流地址为:rtsp://[ip]:[port]/[streamName]
例如:rtsp://192.168.0.10:8554/h264ESVideoTest
6、设置推流数据源文件
char const* inputFileName = "test.264";
推流数据源文件为test.264。
7、实时推流时,使用Linux FIFO文件作为推流数据源文件。
(1)在PC平台可使用x264库进行编码,将264裸流数据写入FIFO文件。详见x264_Test项目。
(2)在RK3588平台可使用MPP进行H264硬件编码,将264裸流数据写入FIFO文件。详见rk3588_mpp_enc_test_rtsp_push项目。