What is rtsp pusher? How to set it up?
What is rtsp pusher?
Data pusher means that RTSP server receives external data sources and then sends them out as RTSP streams.
The data pusher support TCP, UDP and RTSP mode.
Audio and video data are packaged and sent in RTP format.
If it is TCP mode, you need to add 4 bytes in front of the RTP header, as the following:
typedef struct
{
uint32 magic : 8;
uint32 channel : 8;
uint32 rtp_len : 16;
} RILF;
magic: 0x24
channel: 0
ttp_len: the RTP payload length, including RTP header
You can download the examples of sending H264 data from the following link:
http://happytimesoft.com/downloads/happytime-rtsp-h264-data-pusher-example.zip
Note: If you use TCP or UDP mode data push, you need to add <pusher> tag in the rtsp server configuration file, specify the push audio and video parameters and push port, etc.
If you use RTSP mode to push data, no configuration is required. The url suffix of the pushed RTSP address can be any legal string.
If it is RTSP mode, it supports standard RTSP push stream, such as FFMPEG rtsp pusher.
FFMPEG rtsp over UDP:
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec copy -preset ultrafast -f rtsp -rtsp_transport udp rtsp://yourip/pusher
FFMPEG rtsp over TCP:
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec copy -preset ultrafast -f rtsp -rtsp_transport tcp rtsp://yourip/pusher
How to set it up?
Open the rtsp server configuration file config.xml and edit the pusher node.
<pusher>
<suffix>pusher</suffix>
<video>
<codec>H264</codec>
</video>
<audio>
<codec>G711</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
</audio>
<transfer>
<mode>rtsp</mode>
<ip></ip>
<vport>50001</vport>
<aport>50002</aport>
</transfer>
</pusher>
<pusher> : Specify the data pusher parameters, it can configure multiple nodes
<suffix>
Specify the rtsp stream suffix, you can play the pusher stream from:
rtsp://youip/suffix
<video> : Specify the input video data parameters
<codec>
Specify the video codec, it can specify the following value:
H264 : output H264 video stream
H265 : output H265 video stream
MP4 ļ¼output MP4 video stream
JPEG : output MJPEG video stream
<audio> : Specify the input audio data parameters
<codec>
Specify the audio codec, it can specify the following value:
G711A: output G711 a-law audio stream
G711U: output G711 mu-law audio stream
G722: output G726 audio stream
G726: output G726 audio stream
OPUS: output OPUS audio stream
AAC : output AAC audio stream
<transfer>: Specify the data transfer parameters
<mode>: Specify the data transfer protocol, it can specify the following value:
TCP: use TCP connection to transfer the data
UDP: use UDP connection to transfer the data
RTSP: use RTSP connection to transfer the data, it support FFMPEG rtsp pusher.
<ip>: Specify data receiving IP address, if there is no configuration, the default IP address is used.(Is valid when using TCP, UDP mode)
<vport>: Specify the video data receiving port (Is valid when using TCP, UDP mode)
<aport>: Specify the audio data receiving port (Is valid when using TCP, UDP mode)
Below is the setup example:
<config>
<serverip>192.168.1.10</serverip>
<serverport>554</serverport>
...
<pusher>
<suffix>pusher1</suffix>
<video>
<codec>H264</codec>
</video>
<audio>
<codec>G711</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
</audio>
<transfer>
<mode>rtsp</mode>
<ip></ip>
<vport>50001</vport>
<aport>50002</aport>
</transfer>
</pusher>
<pusher>
<suffix>pusher2</suffix>
<video>
<codec>H264</codec>
</video>
<audio>
<codec>G711</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
</audio>
<transfer>
<mode>UDP</mode>
<ip></ip>
<vport>50003</vport>
<aport>50004</aport>
</transfer>
</pusher>
...
</config>
Start the rtsp server and the push program, then use rtsp client to play the following rtsp stream:
rtsp://192.168.1.10/pusher1
rtsp://192.168.1.10/pusher2
Examples of protocols pushed by RTSP are as follows:
C->S:
OPTIONS rtsp://192.168.3.27/mypusher RTSP/1.0
CSeq: 1
User-Agent: happytimesoft rtsp client
S->C:
RTSP/1.0 200 OK
Server: happytime rtsp server V5.0
CSeq: 1
Date: Tue, Sep 15 2020 00:45:17 GMT
Public: DESCRIBE, SETUP, PLAY, PAUSE, OPTIONS, TEARDOWN, GET_PARAMETER, SET_PARAMETER, ANNOUNCE, RECORD
C->S:
ANNOUNCE rtsp://192.168.3.27/mypusher RTSP/1.0
CSeq: 2
User-Agent: happytimesoft rtsp client
Content-type: application/sdp
Content-Length: 476
v=0
o=- 0 0 IN IP4 192.168.3.27
s=session
c=IN IP4 192.168.3.27
t=0 0
a=control:*
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96
packetization-mode=1;profile-level-id=000015;sprop-parameter-sets=Z2QAFaw07AoDmwEQAAADABAAAAMDCPFi04A=,aO+8sA==
a=control:realvideo
m=audio 0 RTP/AVP 97
a=rtpmap:97 MPEG4-GENERIC/8000/2
a=fmtp:97
vstreamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=159056E500
a=control:realaudio
S->C:
RTSP/1.0 200 OK
Server: happytime rtsp server V5.0
CSeq: 2
Date: Tue, Sep 15 2020 00:45:17 GMT
C->S:
SETUP rtsp://192.168.3.27/mypusher/realvideo RTSP/1.0
CSeq: 3
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
User-Agent: happytimesoft rtsp client
S->C:
RTSP/1.0 200 OK
Server: happytime rtsp server V5.0
CSeq: 3
Date: Tue, Sep 15 2020 00:45:17 GMT
Session: 41
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
C->S:
SETUP rtsp://192.168.3.27/mypusher/realaudio RTSP/1.0
CSeq: 4
Session: 41
Transport: RTP/AVP/TCP;unicast;interleaved=2-3
User-Agent: happytimesoft rtsp client
S->C:
RTSP/1.0 200 OK
Server: happytime rtsp server V5.0
CSeq: 4
Date: Tue, Sep 15 2020 00:45:17 GMT
Session: 41
Transport: RTP/AVP/TCP;unicast;interleaved=2-3
C->S:
RECORD rtsp://192.168.3.27/mypusher RTSP/1.0
CSeq: 5
Session: 41
Range: npt=0.0-
User-Agent: happytimesoft rtsp client
S->C:
RTSP/1.0 200 OK
Server: happytime rtsp server V5.0
CSeq: 5
Date: Tue, Sep 15 2020 00:45:17 GMT
Session: 41