RTSP服务端转发服务(live555库中的testH264VideoStreamer.cpp和testOnDemandRTSPServer.cpp实例)

1、h264文件的推送

testH264VideoStreamer.cpp文件的开头就定义了

char const* inputFileName = "test.264";

后面接着创建了会话

ServerMediaSession* sms
    = ServerMediaSession::createNew(*env, "testStream", inputFileName,
     "Session streamed by "testH264VideoStreamer"",
        True /*SSM*/);

也就是将test.264文件,取出一帧一帧的数据并推送到rtsp://host_ip:port/testStream

本实例运行如下

2、实时码流的推送

实时流的推送只需要将如上h264文件的定义改成一个fifo

mkfifo /tmp/test.264

char const* inputFileName = "/tmp/test.264";


然后将camera采集的数据编码成h264的格式存到这个缓存,testH264VideoStreamer就可以将缓存的h264视频数据推送出去.

例如像树梅派将camera数据编码到test.264缓存.

raspivid -o /tmp/test.264 -t 0 -d

这里就不拿板子出来运行了,这里http://www.cnblogs.com/dong1/p/5095739.html,有个testOnDemandRTSPServer实例,

跟testH264VideoStreamer一样的功能.

3、live555 estProgs里还有个testOnDemandRTSPServer.cpp 实例

参考

https://blog.csdn.net/firehood_/article/details/16844397

https://blog.csdn.net/caoshangpa/article/details/53200527

记得修改makefile

MEDIA_SERVER_OBJS = live555MediaServer.$(OBJ) DynamicRTSPServer.$(OBJ) WW_H264VideoSource.$(OBJ) WW_H264VideoServerMediaSubsession.$(OBJ)
live555MediaServer.$(CPP): DynamicRTSPServer.hh version.hh WW_H264VideoSource.hh WW_H264VideoServerMediaSubsession.hh
DynamicRTSPServer.$(CPP): DynamicRTSPServer.hh
MEDIA_SERVER_OBJS = live555MediaServer.$(OBJ) DynamicRTSPServer.$(OBJ) h264LiveFramedSource.$(OBJ) h264LiveVideoServerMediaSubssion.$(OBJ)
live555MediaServer.$(CPP): DynamicRTSPServer.hh version.hh h264LiveVideoServerMediaSubssion.hh h264LiveFramedSource.hh
DynamicRTSPServer.$(CPP): DynamicRTSPServer.hh
原文地址:https://www.cnblogs.com/dong1/p/5968207.html