What is rtsp pusher? How to set it up?

What is rtsp pusher?

Use the ANNOUNCE and RECORD commands of the RTSP protocol to send data to the rtsp server, and then the rtsp server distributes the data to the clients.
Send data to the rtsp server using a TCP or UDP connection, and then the rtsp server distributes the data to the clients.
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 load 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

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>
        <width>1280</width>
        <height>720</height>
        <framerate>25</framerate>
    </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 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
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

<transfer>: Specify the data transfer parameters
<mode>: Specify the data transer 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>: Specified data receiving IP address, if there is no configuration, the default IP address is used.
<vport>: Specify the video data receiving port
<aport>: Specify the audio data receiving port


Below is the setup example:

<config>
<serverip>192.168.1.10</serverip>
<serverport>554</serverport>
...

<pusher>
    <suffix>pusher1</suffix>
    <video>
        <codec>H264</codec>
        <width>1280</width>
        <height>720</height>
        <framerate>25</framerate>
    </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>
        <width>1280</width>
        <height>720</height>
        <framerate>25</framerate>
    </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