<commit_before>simple-rtmp-server
==================

srs(simple rtmp origin live server) over state-threads.<br/>
srs is a simple, high-performance, running in single process, origin live server.<br/>
srs supports vhost, rtmp, HLS, transcoding, forward, http hooks. <br/>
blog: [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin) <br/>
see also: [https://github.com/winlinvip/simple-rtmp-server](https://github.com/winlinvip/simple-rtmp-server) <br/>
see also: [http://winlinvip.github.io/simple-rtmp-server](http://winlinvip.github.io/simple-rtmp-server)

### Contributors
winlin([winterserver](#)): [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin) <br/>
wenjie([wenjiegit](https://github.com/wenjiegit/simple-rtmp-server)): [http://blog.chinaunix.net/uid/25006789.html](http://blog.chinaunix.net/uid/25006789.html) <br/>
who is the contributors: <br/>
1. contribute important features to srs. <br/>
2. the name of all contributors will send in the response of NetConnection.connect and metadata. 

### Usage
<strong>step 1:</strong> build srs <br/>
<pre>
tar xf simple-rtmp-server-*.*.tar.gz
cd simple-rtmp-server-*.*/trunk
./configure --with-ssl --with-hls --with-ffmpeg --with-http
make
</pre>
or get the latest code:<br/>
<pre>
git clone  https://github.com/winlinvip/simple-rtmp-server
cd simple-rtmp-server/trunk
./configure --with-ssl --with-hls --with-ffmpeg --with-http
</pre>
<strong>step 2:</strong> start srs <br/>
<pre>
./objs/srs -c conf/srs.conf
</pre>
<strong>step 3(optinal):</strong> start srs listen at 19350 to forward to<br/>
<pre>
./objs/srs -c conf/srs.19350.conf
</pre>
<strong>step 4(optinal):</strong> start nginx for HLS <br/>
<pre>
sudo ./objs/nginx/sbin/nginx
</pre>
<strong>step 5(optinal):</strong> start http hooks for srs callback <br/>
<pre>
python ./research/api-server/server.py 8085
</pre>
<strong>step 6:</strong> publish live stream <br/>
<pre>
FMS URL: rtmp://127.0.0.1/live
Stream:  livestream
For example, use ffmpeg to publish:
    for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
        -vcodec copy -acodec copy \
        -f flv -y rtmp://127.0.0.1/live?vhost=demo.srs.com/livestream; \
        sleep 1; \
    done
</pre>
<strong>step 7:</strong> add server ip to client hosts as demo. <br/>
<pre>
# edit the folowing file:
# linux: /etc/hosts
# windows: C:\Windows\System32\drivers\etc\hosts
# where server ip is 192.168.2.111
192.168.2.111 demo.srs.com
</pre>
<strong>step 8:</strong> play live stream. <br/>
<pre>
players: http://demo.srs.com/players
rtmp url: rtmp://demo.srs.com/live/livestream
m3u8 url: http://demo.srs.com/live/livestream.m3u8
for android: http://demo.srs.com/live/livestream.html
</pre>
<strong>step 9(optinal):</strong> play live stream auto transcoded<br/>
<pre>
rtmp url: rtmp://demo.srs.com/live/livestream_ld
m3u8 url: http://demo.srs.com/live/livestream_ld.m3u8
for android: http://demo.srs.com/live/livestream_ld.html
rtmp url: rtmp://demo.srs.com/live/livestream_sd
m3u8 url: http://demo.srs.com/live/livestream_sd.m3u8
for android: http://demo.srs.com/live/livestream_sd.html
</pre>
<strong>step 10(optinal):</strong> play live stream auto forwarded, the hls dir change to /forward<br/>
<pre>
rtmp url: rtmp://demo.srs.com:19350/live/livestream
m3u8 url: http://demo.srs.com/forward/live/livestream.m3u8
for android: http://demo.srs.com/forward/live/livestream.html
rtmp url: rtmp://demo.srs.com:19350/live/livestream_ld
m3u8 url: http://demo.srs.com/forward/live/livestream_ld.m3u8
for android: http://demo.srs.com/forward/live/livestream_ld.html
rtmp url: rtmp://demo.srs.com:19350/live/livestream_sd
m3u8 url: http://demo.srs.com/forward/live/livestream_sd.m3u8
for android: http://demo.srs.com/forward/live/livestream_sd.html
</pre>
<strong>step 11(optinal):</strong> modify the config and reload it (all features support reload)<br/>
<pre>
killall -1 srs
</pre>
or use specified signal to reload:<br/>
<pre>
killall -s SIGHUP srs
</pre>

### Architecture
System Architecture:
<pre>
+------------------------------------------------------+
|             SRS(Simple Rtmp Server)                  |
+---------------+---------------+-----------+----------+
|   API/hook    |   Transcoder  |    HLS    |   RTMP   |
|  http-parser  |  FFMPEG/x264  |  NGINX/ts | protocol |
+---------------+---------------+-----------+----------+
|              Network(state-threads)                  |
+------------------------------------------------------+
|      All Linux(RHEL,Centos,Ubuntu,Fedora...)         |
+------------------------------------------------------+
</pre>
Stream Architecture:
<pre>
        +---------+              +----------+ 
        + Publish +              +  Deliver | 
        +---|-----+              +----|-----+ 
+-----------+-------------------------+----------------+
| Encoder   | SRS(Simple Rtmp Server) |     Client     |
+-----------+-------------------------+----------------+
| (FMLE,    |   +-> RTMP protocol ----+-> Flash Player |
| FFMPEG, --+-> +-> HLS/NGINX --------+-> m3u8 player  |
| Flash,    |   +-> Fowarder ---------+-> RTMP Server  |
| XSPLIT,   |   +-> Transcoder -------+-> RTMP Server  |
|  ...)     |   +-> DVR --------------+-> FILE         |
|           |   +-> BandwidthTest-----+-> Flash/StLoad |
+-----------+-------------------------+----------------+
</pre>
Bandwidth Test Workflow:
<pre>
      +------------+             +----------+
      |  Client    |             |  Server  |
      +-----+------+             +-----+----+
            |                          |
            |  connect vhost------>    |
            |  \<-----result(success)   |
            |                          |
            |  <----call(start play)   |
            |  result(playing)----->   |
            |  <-------data(playing)   |
            |  <-----call(stop play)   |
            |  result(stopped)----->   |
            |                          |
            |  <-call(start publish)   |
            |  result(publishing)-->   |
            |  data(publishing)---->   |
            |  <--call(stop publish)   |
            |  result(stopped)(1)-->   |
            |                          |
            |  <--------------report   |
            |  final(2)------------>   |
            |          <END>           |
            
@see: class SrsBandwidth comments.
</pre>

### System Requirements
Supported operating systems and hardware:
* All Linux , both 32 and 64 bits
* All handware.

### Summary
1. simple: also stable enough.<br/>
2. high-performance: single-thread, async socket, event/st-thread driven.<br/>
3. no edge server, origin server only.<br/>
4. no vod streaming, live streaming only.<br/>
5. no multiple processes, single process only.<br/>
6. support vhost, support \_\_defaultVhost\_\_.<br/>
7. support adobe rtmp live streaming.<br/>
8. support apple hls(m3u8) live streaming.<br/>
9. support reload config to enable changes.<br/>
10. support cache last gop for flash player to fast startup.<br/>
11. support listen at multiple ports.<br/><commit_msg>add bandwidth workflow<commit_after>simple-rtmp-server
==================

srs(simple rtmp origin live server) over state-threads.<br/>
srs is a simple, high-performance, running in single process, origin live server.<br/>
srs supports vhost, rtmp, HLS, transcoding, forward, http hooks. <br/>
blog: [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin) <br/>
see also: [https://github.com/winlinvip/simple-rtmp-server](https://github.com/winlinvip/simple-rtmp-server) <br/>
see also: [http://winlinvip.github.io/simple-rtmp-server](http://winlinvip.github.io/simple-rtmp-server)

### Contributors
winlin([winterserver](#)): [http://blog.csdn.net/win_lin](http://blog.csdn.net/win_lin) <br/>
wenjie([wenjiegit](https://github.com/wenjiegit/simple-rtmp-server)): [http://blog.chinaunix.net/uid/25006789.html](http://blog.chinaunix.net/uid/25006789.html) <br/>
who is the contributors: <br/>
1. contribute important features to srs. <br/>
2. the name of all contributors will send in the response of NetConnection.connect and metadata. 

### Usage
<strong>step 1:</strong> build srs <br/>
<pre>
tar xf simple-rtmp-server-*.*.tar.gz
cd simple-rtmp-server-*.*/trunk
./configure --with-ssl --with-hls --with-ffmpeg --with-http
make
</pre>
or get the latest code:<br/>
<pre>
git clone  https://github.com/winlinvip/simple-rtmp-server
cd simple-rtmp-server/trunk
./configure --with-ssl --with-hls --with-ffmpeg --with-http
</pre>
<strong>step 2:</strong> start srs <br/>
<pre>
./objs/srs -c conf/srs.conf
</pre>
<strong>step 3(optinal):</strong> start srs listen at 19350 to forward to<br/>
<pre>
./objs/srs -c conf/srs.19350.conf
</pre>
<strong>step 4(optinal):</strong> start nginx for HLS <br/>
<pre>
sudo ./objs/nginx/sbin/nginx
</pre>
<strong>step 5(optinal):</strong> start http hooks for srs callback <br/>
<pre>
python ./research/api-server/server.py 8085
</pre>
<strong>step 6:</strong> publish live stream <br/>
<pre>
FMS URL: rtmp://127.0.0.1/live
Stream:  livestream
For example, use ffmpeg to publish:
    for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
        -vcodec copy -acodec copy \
        -f flv -y rtmp://127.0.0.1/live?vhost=demo.srs.com/livestream; \
        sleep 1; \
    done
</pre>
<strong>step 7:</strong> add server ip to client hosts as demo. <br/>
<pre>
# edit the folowing file:
# linux: /etc/hosts
# windows: C:\Windows\System32\drivers\etc\hosts
# where server ip is 192.168.2.111
192.168.2.111 demo.srs.com
</pre>
<strong>step 8:</strong> play live stream. <br/>
<pre>
players: http://demo.srs.com/players
rtmp url: rtmp://demo.srs.com/live/livestream
m3u8 url: http://demo.srs.com/live/livestream.m3u8
for android: http://demo.srs.com/live/livestream.html
</pre>
<strong>step 9(optinal):</strong> play live stream auto transcoded<br/>
<pre>
rtmp url: rtmp://demo.srs.com/live/livestream_ld
m3u8 url: http://demo.srs.com/live/livestream_ld.m3u8
for android: http://demo.srs.com/live/livestream_ld.html
rtmp url: rtmp://demo.srs.com/live/livestream_sd
m3u8 url: http://demo.srs.com/live/livestream_sd.m3u8
for android: http://demo.srs.com/live/livestream_sd.html
</pre>
<strong>step 10(optinal):</strong> play live stream auto forwarded, the hls dir change to /forward<br/>
<pre>
rtmp url: rtmp://demo.srs.com:19350/live/livestream
m3u8 url: http://demo.srs.com/forward/live/livestream.m3u8
for android: http://demo.srs.com/forward/live/livestream.html
rtmp url: rtmp://demo.srs.com:19350/live/livestream_ld
m3u8 url: http://demo.srs.com/forward/live/livestream_ld.m3u8
for android: http://demo.srs.com/forward/live/livestream_ld.html
rtmp url: rtmp://demo.srs.com:19350/live/livestream_sd
m3u8 url: http://demo.srs.com/forward/live/livestream_sd.m3u8
for android: http://demo.srs.com/forward/live/livestream_sd.html
</pre>
<strong>step 11(optinal):</strong> modify the config and reload it (all features support reload)<br/>
<pre>
killall -1 srs
</pre>
or use specified signal to reload:<br/>
<pre>
killall -s SIGHUP srs
</pre>

### Architecture
System Architecture:
<pre>
+------------------------------------------------------+
|             SRS(Simple Rtmp Server)                  |
+---------------+---------------+-----------+----------+
|   API/hook    |   Transcoder  |    HLS    |   RTMP   |
|  http-parser  |  FFMPEG/x264  |  NGINX/ts | protocol |
+---------------+---------------+-----------+----------+
|              Network(state-threads)                  |
+------------------------------------------------------+
|      All Linux(RHEL,Centos,Ubuntu,Fedora...)         |
+------------------------------------------------------+
</pre>
Stream Architecture:
<pre>
        +---------+              +----------+ 
        + Publish +              +  Deliver | 
        +---|-----+              +----|-----+ 
+-----------+-------------------------+----------------+
| Encoder   | SRS(Simple Rtmp Server) |     Client     |
+-----------+-------------------------+----------------+
| (FMLE,    |   +-> RTMP protocol ----+-> Flash Player |
| FFMPEG, --+-> +-> HLS/NGINX --------+-> m3u8 player  |
| Flash,    |   +-> Fowarder ---------+-> RTMP Server  |
| XSPLIT,   |   +-> Transcoder -------+-> RTMP Server  |
|  ...)     |   +-> DVR --------------+-> FILE         |
|           |   +-> BandwidthTest-----+-> Flash/StLoad |
+-----------+-------------------------+----------------+
</pre>
Bandwidth Test Workflow:
<pre>
      +------------+             +----------+
      |  Client    |             |  Server  |
      +-----+------+             +-----+----+
            |                          |
            |  connect vhost------>    |
            |  &lt;-----result(success)   |
            |                          |
            |  &lt;----call(start play)   |
            |  result(playing)----->   |
            |  &lt;-------data(playing)   |
            |  &lt;-----call(stop play)   |
            |  result(stopped)----->   |
            |                          |
            |  &lt;-call(start publish)   |
            |  result(publishing)-->   |
            |  data(publishing)---->   |
            |  &lt;--call(stop publish)   |
            |  result(stopped)(1)-->   |
            |                          |
            |  &lt;--------------report   |
            |  final(2)------------>   |
            |          &lt;END>           |
            
@see: class SrsBandwidth comments.
</pre>

### System Requirements
Supported operating systems and hardware:
* All Linux , both 32 and 64 bits
* All handware.

### Summary
1. simple: also stable enough.<br/>
2. high-performance: single-thread, async socket, event/st-thread driven.<br/>
3. no edge server, origin server only.<br/>
4. no vod streaming, live streaming only.<br/>
5. no multiple processes, single process only.<br/>
6. support vhost, support \_\_defaultVhost\_\_.<br/>
7. support adobe rtmp live streaming.<br/>
8. support apple hls(m3u8) live streaming.<br/>
9. support reload config to enable changes.<br/>
10. support cache last gop for flash player to fast startup.<br/>
11. support listen at multiple ports.<br/>
{'fraction_non_alphanumeric': 0.23879858657243816, 'fraction_numerical': 0.021908127208480566, 'mean_word_length': 1.8832518337408313, 'pattern_counts': {'":': 0, '<': 185, '<?xml version=': 0, '>': 219, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3643110', 'n_tokens_mistral': 4954, 'n_tokens_neox': 4698, 'n_words': 1029}