user-manual
user-manual
(RTSP Server)
Since the product version upgrade or other reasons, this manual will
subsequently be updated. Unless otherwise agreed, this manual only as a
guide, this manual all statements, information, recommendations do not
constitute any express or implied warranties。
www.happytimesoft.com
Table of Contents
Chapter 1 Introduction .................................................................................................................. 4
Chapter 2 Key features .................................................................................................................. 5
Chapter 3 Function chart .............................................................................................................. 6
Chapter 4 Configuration ............................................................................................................... 7
4.1 Configuration Templates ..................................................................................................... 7
4.2 Configuring Node Description .......................................................................................... 10
4.2.1 System parameters ................................................................................................. 10
4.2.2 http_notify .............................................................................................................. 12
4.2.3 User node ............................................................................................................... 13
4.2.4 Output node ............................................................................................................ 14
4.2.5 Proxy node.............................................................................................................. 16
4.2.6 Pusher node............................................................................................................ 17
4.2.7 Backchannel node .................................................................................................. 18
Chapter 5 Data pusher................................................................................................................. 20
Chapter 6 RTSP over HTTP ....................................................................................................... 22
Chapter 7 RTSP over Websocket ............................................................................................... 24
Chapter 8 RTP Multicast ............................................................................................................ 25
Chapter 9 Audio back channel.................................................................................................... 26
9.1 RTSP Require- Tag ........................................................................................................... 26
9.2 Connection setup for a bi- directional connection............................................................ 26
9.3 Example ........................................................................................................................... 29
Chapter 10 Run RTSP Server ..................................................................................................... 30
Chapter 11 Multiple capture devices support ........................................................................... 31
Chapter 12 Capture application window ................................................................................... 32
Chapter 13 Support URL parameters ........................................................................................ 33
Chapter 14 Support SRTP .......................................................................................................... 35
14.1 SRTP for publishing ........................................................................................................ 35
14.2 SRTP for playback .......................................................................................................... 36
Chapter 1 Introduction
Happytime RTSP Server is a complete RTSP server application. It can stream audio
and video files in various formats.
It can also stream video from camera, living screen and application windows,
stream audio from audio device.
It can stream H265, H264, MP4, MJPEG video stream and G711, G722, G726, AAC,
OPUS audio stream.
These streams can be received/played by standards-compliant RTSP/RTP media
clients.
It supports rtsp proxy function.
It supports audio back channel function.
It supports rtsp over http function.
It supports rtsp over https function.
It supports rtp multicast function.
Support for data pusher function.
Enjoying multimedia content from your computer can be a pleasant way for you
to spend your free time. However, sometimes you might need to access it from various
locations, such as a different computer or a handheld device, Happytime RTSP Server,
that can help you achieve quick and efficient results.
Chapter 2 Key features
The server can transmit multiple streams concurrently
It can stream audio and video files in various formats
It can stream audio from audio device
It can stream video from camera and living screen
It can stream video from application windows
It can stream H265, H264, MP4, MJPEG video stream
It can stream G711, G722, G726, AAC, OPUS audio stream
It supports rtsp over http function
It supports rtsp over https function
It supports rtsp over websocket function
It supports rtp multicast function
It supports data pusher function
It supports srtp
It supports RTSP proxy function, as the following:
<http_notify>
<on_connect></on_connect>
<on_play></on_play>
<on_publish></on_publish>
<on_done></on_done>
<notify_method></notify_method>
</http_notify>
<user>
<username>admin</username>
<password>admin</password>
</user>
<output>
<url></url>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>G711U</codec>
<samplerate></samplerate>
<channels></channels>
<bitrate></bitrate>
</audio>
</output>
<proxy>
<suffix>proxy</suffix>
<url></url>
<user></user>
<pass></pass>
<transfer>TCP</transfer>
<ondemand>0</ondemand>
<output>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>AAC</codec>
<samplerate></samplerate>
<channels></channels>
<bitrate></bitrate>
</audio>
</output>
</proxy>
<pusher>
<suffix>pusher</suffix>
<video>
<codec>H264</codec>
</video>
<audio>
<codec>G711U</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
</audio>
<transfer>
<mode>RTSP</mode>
<ip></ip>
<vport>50001</vport>
<aport>50002</aport>
</transfer>
<output>
<video>
<codec></codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec></codec>
<samplerate></samplerate>
<channels></channels>
<bitrate></bitrate>
</audio>
</output>
</pusher>
<backchannel>
<codec>G711U</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
</backchannel>
</config>
<serverport>
Specify the RTSP server port, the default is 554.
Note: On Linux systems, ports below 1024 are reserved by the system and require
root privileges to be used.
<loop_nums>
When streaming media files, specify the number of loop playback,-1 means
infinite loop.
<multicast>
Whether to enable rtp multicast function, 0-disable, 1-enable.
<udp_base_port>
UDP media transmission base port, RTSP over UDP mode assign UDP port on this
base port.
Each rtsp session needs to assign 8 UDP ports, video RTP/RTCP port, audio
RTP/RTCP port, METADATA stream RTP/RTCP port, audio back-channel RTP/RTCP port.
<metadata>
Whether to enable the meta data stream, 0-disable, 1-enable.
<rtsp_over_http>
Whether to enable rtsp over http function, 0-disable,1-enable.
<http_port>
Specify the HTTP service port for rtsp over http function.
Note: On Linux systems, ports below 1024 are reserved by the system and require
root privileges to be used.
<rtsp_over_https>
Whether to enable rtsp over https function, 0-disable,1-enable.
<https_port>
Specify the HTTPS service port for rtsp over https function.
Note: On Linux systems, ports below 1024 are reserved by the system and require
root privileges to be used.
<cert_file>
Specify the HTTPS service certificate file.
<key_file>
Specify the HTTPS service key file.
Note: The certificate file ssl.ca and key file ssl.key provided by default are
self signed local hosts certificates, only for testing purposes (browsers may pop
up untrusted certificate warnings), and cannot be used in formal deployment
environments.
<ipv6_enable>
Indicates whether IPv6 is enabled, 0-disable, 1-enable.
Note: If the server does not specify a server ip in <serverip> and the
<ipv6_enable> is 1, and the server has an IPv6 address, the client can connect to
the server through the IPv6 address.
<need_auth>
Whether enable the user authentication function,0-disable,1-enable.
<log_enable>
Whether enable the log function,0-disable,1-enable.
<log_level>
The log level:
TRACE 0
DEBUG 1
INFO 2
WARN 3
ERROR 4
FATAL 5
4.2.2 http_notify
<http_notify> : Specify the HTTP notification callback address.
<on_connect> :
Sets HTTP connection callback. When clients issues connect command an
HTTP request is issued and command processing is suspended until it returns
result code. If HTTP 200 code is returned then RTSP session continues.
HTTP request receives a number of arguments. POST method is used with
application/x-www-form-urlencoded MIME type. The following arguments are
passed to caller:
protocol=rtsp
call=connect
addr - client IP address
url - URL requested by the client
name – stream name
clientid – rtsp session id
<on_play> :
Sets HTTP play callback. Each time a clients issues play command an HTTP
request is issued and command processing is suspended until it returns
result code. If HTTP 200 code is returned then RTSP session continues.
HTTP request receives a number of arguments. POST method is used with
application/x-www-form-urlencoded MIME type. The following arguments are
passed to caller:
protocol=rtsp
call=play
addr - client IP address
url - URL requested by the client
name – stream name
clientid – rtsp session id
<on_publish> :
The same as on_play above with the only difference that this node sets
callback on publish command. Instead of remote pull push is performed in
this case.
<on_done> :
Sets play/publish terminate callback. All the above applies here.
However HTTP status code is not checked for this callback.
<notify_method>
Sets HTTP method for notifications. Default is POST
with application/x-www-form-urlencoded content type.
Support GET and POST method.
<password>
The login password.
<width>
Specify the output video width, If 0 use the original video width
(live screen stream use the screen width, camera stream use the default
width)
<height>
Specify the output video height, If 0 use the original video height
(live screen stream use the screen height, camera stream use the default
height)
<framerate>
Specify the output video framerate, If 0 use the original video
framerate (live screen use the default value 25, camera stream use the
default value 25)
<bitrate>
Specify the output video bit rate, if 0, automatically calculate
the output bit rate, the unit is kb/s.
Note: This parameter is valid only if encoding is required (eg
screenlive, videodevice) or transcoding is required.
<samplerate>
Specify the audio sample rate, it can specify the following values:
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
If 0 use the original audio sample rate (audio device stream use
the default value 8000)
<channels>
Specify the audio channel number, 1 is mono, 2 is stereo
If 0 use the original audio channel number (audio device stream use
the default value 2)
Note : G726 only support mono.
<bitrate>
Specify the output audio bit rate, if 0, automatically calculate
the output bit rate, the unit is kb/s.
Note: This parameter is valid only if encoding is required (eg
screenlive, videodevice) or transcoding is required.
<output>
Specify the stream output parameter. If the parameter does not appear,
use the parameters of the original pusher stream. If it appears and the
configured parameters are inconsistent with the parameters of the original
pusher stream, then the transcode output is performed.
The child nodes under this node are consistent with the meaning of the
<output> node.
<samplerate>
Specify the audio back channel sample rate, it can specify the following
values:
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
If 0 use the default value 8000
<channels>
Specify the audio channel number, 1 is mono, 2 is stereo
If 0 use the default value 1
Note : G726 only support mono.
Chapter 5 Data pusher
Data push means that RTSP server receives external data sources and then sends
them out as RTSP streams.
The data pusher supports 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
rtp_len: the RTP payload length, including RTP header
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
push.
FFMPEG rtsp over UDP:
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec copy -preset ultrafast -f rtsp
rtsp://[serverip]:[serverport]/pusher
Happytime rtsp client also supports rtsp streams starting with http:// or
https://.
If it starts with http://, it is considered to be a rtsp over http stream.
If it starts with https://, it is considered to be a rtsp over https stream.
Chapter 7 RTSP over Websocket
First establish an HTTP connection, and then upgrade to the websocket protocol,
RTSP over websocket protocol upgrade process:
C-->S:
GET /websocket HTTP/1.1 Host: 192.168.3.27
Upgrade: websocket Connection: Upgrade
Sec-WebSocket-Key: KSO+hOFs1q5SkEnx8bvp6w== Origin: http://192.168.3.27
Sec-WebSocket-Protocol: rtsp.onvif.org Sec-WebSocket-Version: 13
S-->C:
HTTP/1.1 101 Switching Protocols Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: G/cEt4HtsYEnP0MnSVkKRk459gM= Sec-WebSocket-Protocol:
rtsp.onvif.org
Sec-WebSocket-Version: 13
After the protocol upgrade is successful, perform normal rtsp protocol exchange,
and send and receive data through websocket connection.
Happytime rtsp client
(http://happytimesoft.com/products/rtsp-client/index.html) supports RTSP
over Websocket, The setting as the following:
Happytime rtsp client also supports rtsp streams starting with ws://.
If it starts with ws://, it is considered to be a rtsp over websocket stream.
Chapter 8 RTP Multicast
To enable the rtp multicast function, it need to specify the <multicast> to 1
in the configuration file.
The rtsp server does not support the configuration of multicast addresses.
Different rtsp stream addresses use multicast, randomly assigned multicast
addresses starting with 232.
Different rtsp sessions use rtp multicast to play the same rtsp stream, using
the same multicast address.Only the first rtsp session sends audio and video data,
and subsequent sessions refer to the first rtsp session.
The rtp multicast stream address is the same as the other rtsp stream address.
Use VLC to test rtp multicast, use the following settings:
Chapter 9 Audio back channel
The backchannel connection handling is done using RTSP [RFC 2326]. Therefore
a mechanism is introduced which indicates that a client wants to built up a
backchannel connection. RTSP provides feature-tags to deal with such functionality
additions. A device that supports bi-directional connections (e.g audio or metadata
connections) shall support the introduced RTSP extensions.
This SDP file completely describes the RTSP session. The Server gives the client
its control URLs to setup the streams.
In the next step the client can setup the sessions:
The third setup request establishes the audio backchannel connection.
In the next step the client starts the session by sending a PLAY request.
After receiving the OK response to the PLAY request the client MAY start sending
audio data to the server. It shall not start sending data to the server before it
has received the response.
The Require-header indicates that a special interpretation of the PLAY command
is necessary. The command covers both starting of the video and audio stream from
NVT to the client and starting the audio connection from client to server.
To terminate the session the client sends a TEARDOWN request.
9.3 Example
Server with Onvif backchannel support (with multiple decoding capability)
If a device supports multiple audio decoders as backchannel, it can signal such
capability by listing multiple a=rtpmap fields illustrated as follows.
Chapter 10 Run RTSP Server
The server is a console application.
Windows: to run the server, simply type "rtspserver".
Linux: to run the server, type "./start.sh", on linux platform, rtsp server run
as deamon by default.
If your system have multiple video capture device, you can use
rtsp://[serverip]:[serverport]/videodeviceN
The N to specify the video capture device index, start from 0, such as:
rtsp://192.168.0.100/videodevice ; stream video from the first video device
rtsp://192.168.0.100/videodevice1 ; stream video from the second video device
The audio index or video index represents which device can run the following
command to view:
rtspserver -l device
Note that there can be no spaces in the device name, if the device name contains
spaces, you need to use %20 instead of spaces.
If the device name is “FaceTime HD Camera”, the rtsp stream address is:
rtsp://[serverip]:[serverport]/videodevice=FaceTime%20HD%20Camera
Chapter 12 Capture application window
The rtsp server supports capturing application windows, you can use the
following command to list valid application windows:
rtspserver -l window
You can use the following url to capture the specified application window:
rtsp://[serverip]:[serverport]/window=[window title]
Note : window title case insensitive
Such as :
rtsp://[serverip]:[serverport]/window=rtspserver
Note that there can be no spaces in the window title, if the window title contains
spaces, you need to use %20 instead of spaces. Such as:
rtsp://[serverip]:[serverport]/window=user%20manual.doc%20-%20WPS%20Office
Chapter 13 Support URL parameters
RTSP server supports URL parameters, with the following format:
Taking playing the test.mp4 file as an example:
rtsp://[serverip]:[serverport]/test.mp4?param1=value1¶m2=value2
Pararm1 and param2 represent URL parameters, while value1 and value2 represent
the values of param1 and param2.
Note : The parameter value specified through the URL has a higher priority than
the parameters configured in the configuration file.
Example:
Using unicast RTP over UDP mode, output video encoding as H264, resolution as
1920 * 1080, frame rate as 30, bit rate as 4000K, audio as AAC, sampling rate as
44100, stereo RTSP stream:
rtsp://[serverip]:[serverport]/test.mp4?t=unicast&p=udp&ve=h264&w=1920&h=1
080&fps=30&vb=4000&ae=aac&sr=44100&ch=2
Chapter 14 Support SRTP
Happytiem rtsp server supports Secure Real-time Transport Protocol (secure RTP
or SRTP) for publishing and playback. The encryption keys can be passed in the SDP
data. The open-source tools FFmpeg and FFplay can be used for SRTP testing.
<pusher>
<src>test.mp4</src>
<transfer>
<mode>RTSP</mode>
<rtspurl>rtsp://192.168.3.36/myapp/live</rtspurl>
<user>admin</user>
<pass>admin</pass>
</transfer>
<video>
……
</video>
<audio>
……
</audio>
<metadata>0</metadata>
<srtp>1</srtp>
</pusher>
You will see SDP information in the ANNOUNCE request message of rsp pusher. It
should look something like this:
v=0
o=- 0 0 IN IP4 192.168.3.36
c=IN IP4 192.168.3.36
s=session
t=0 0
a=control:*
m=video 0 RTP/SAVP 96
a=rtpmap:96 H264/90000
a=fmtp:96
packetization-mode=1;profile-level-id=42801F;sprop-parameter-sets=Z0KAH5ZSAKALdJQEBAUAAAMAAQ
AAAwAyhA==,aMuNSA==
a=control:realvideo
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:KSO+hOFs1q5SkEnx8bvp67Om2zyHDD6ZJF4NHAa3
m=audio 0 RTP/SAVP 97
a=rtpmap:97 MPEG4-GENERIC/44100/2
a=fmtp:97
streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;
config=121056E500
a=control:realaudio
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:R96zEk3IQ7uLph8DWn0JOCUfXdTL/Jb1RTsTDYkK