ShaRT is a live-streaming server which ingests over SRT and broadcasts over SRT and HTTP licensed under the GPLv3.
ShaRT depends on SRT and
PicoHTTPParser which are vendored in
the thirdparty/
directory and linked statically. It also depends on
openssl
, libcrypto
and libpthread
which must be provided by the host
system. cmake
is required to compile SRT.
Clone the repository
(pass --recurse-submodules
or run
git submodule update --init --recursive
in the project directory after
cloning) and run make all
in its directory. Make sure you have cmake
installed (required to build SRT). An executable will be output at bin/ShaRT
.
The following values can be defined at compile time:
WEB_LISTEN_BACKLOG
:int
- Connection backlog size for HTTPSRT_LISTEN_BACKLOG
:int
- Connection backlog size for SRTMAP_SIZE
:int
- Number of "buckets" in the hashmap which stores stream information. You should set this to at least double the maximum number of streams you expect to handle to get the best possible performance.UNLISTED_STREAM_NAME_PREFIX
:string
- Streams published under a name beginning with this string will not be reported by the web API (default value is_
).MAX_WEB_SEND_FAILS
:int
- Number of send EAGAIN/EWOULDBLOCK errors to before disconnecting an HTTP subscriber (all other error types cause HTTP subscribers to be dropped immediately).MAX_PACKETS_IN_FLIGHT
:int
SRT docsSEND_BUFFER_SIZE
:int
SRT docsRECV_BUFFER_SIZE
:int
SRT docsRECV_LATENCY_MS
:int
SRT docsENABLE_TIMESTAMPS
:bool
SRT docsENABLE_REPEATED_LOSS_REPORTS
:bool
SRT docsENABLE_DRIFT_TRACER
:bool
SRT docsWEB_SEND_BUFFER_SIZE
:int
- LikeSEND_BUFFER_SIZE
, but for HTTP connections.
A configuration to run ShaRT under Docker is provided. By default, it includes an instance of Lighttpd to serve the web interface.
Run HOSTNAME=your-hostname docker-compose build && docker-compose up
where
your-hostname
is replaced with the hostname at which the web interface will be reachable
by an end-user (NOT the address at which it is reachable on the local machine).
The web player will be accessible at your-hostname:3000
and ShaRT will listen for
SRT publishers on port 9991
and SRT subscribers on port 1234
. To change these
settings as well as others, modify the relevant values in docker-compose.yml
.
Run docker-compose build shart && docker-compose up shart
ShaRT will listen for SRT publishers on port 9991
and SRT subscribers on port 1234
.
To change these settings as well as others, modify the relevant values in docker-compose.yml
.
See USAGE.md
- Connections for watching a stream are handled in non-blocking mode and traffic is managed "leaky bucket" style, i.e. if ShaRT can't broadcast the stream to connected clients in time with the rate at which data arrives, it will drop connections until it can.
- Stream names may not contain the following characters:
$
,(
,)
,[
,]
,<
,>
,|
,\n
(newline),\
,&
,*
,#
,~
,!
,`
,;
,'
,"
.
An example webpage for playing live streams using mpegts.js is provided. To use it, do the following:
- Serve the
www
directory with a web server. - Set the values of
web_url
andsrt_url
inwww/config.js
to the URLs at which ShaRT is configured to accept HTTP and SRT subscriber connections respectively. You must do this because ShaRT itself is served separately from any web interface to which it is attached.
Here is an example NGINX configuration for serving the sample web interface as well as proxying HTTP connections to ShaRT (Assuming ShaRT serves HTTP connections over the default port, 8071):
location /stream {
alias /path/to/ShaRT/www;
}
location /stream_backend/ {
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8071/;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
}
The following HTTP endpoints are exposed:
/api/streams/N
Returns a JSON-encoded list of stream names with lengthN
sorted by number of viewers. IfN
is0
, the full stream list will be returned./api/stream/NAME
Returns the number of viewers forNAME
. Returns404
if there is no stream calledNAME
being published./stream/NAME
This is the HTTP endpoint for serving MPEG-TS encoded streams.