winlin

refine readme, confs

@@ -69,166 +69,6 @@ cd simple-rtmp-server/trunk @@ -69,166 +69,6 @@ cd simple-rtmp-server/trunk
69 [Usage: How to show the demo of SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleDemo)<br/> 69 [Usage: How to show the demo of SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleDemo)<br/>
70 [Usage: Who is using SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/Sample)<br/> 70 [Usage: Who is using SRS?](https://github.com/winlinvip/simple-rtmp-server/wiki/Sample)<br/>
71 71
72 -### Architecture  
73 -System Architecture:  
74 -<pre>  
75 -+------------------------------------------------------+  
76 -| SRS(Simple RTMP Server) |  
77 -+---------------+---------------+-----------+----------+  
78 -| API/hook | Transcoder | HLS | RTMP |  
79 -| http-parser | FFMPEG/x264 | NGINX/ts | protocol |  
80 -+---------------+---------------+-----------+----------+  
81 -| Network(state-threads) |  
82 -+------------------------------------------------------+  
83 -| All Linux(RHEL,CentOS,Ubuntu,Fedora...) |  
84 -+------------------------------------------------------+  
85 -</pre>  
86 -Modularity Architecture:  
87 -<pre>  
88 -+------------------------------------------------------+  
89 -| Main(srs/bandwidth/librtmp) |  
90 -+------------------------------------------------------+  
91 -| App(Server/Client application) |  
92 -+------------------------------------------------------+  
93 -| RTMP(Protocol stack) |  
94 -+------------------------------------------------------+  
95 -| Kernel(depends on Core, provides error/log) |  
96 -+------------------------------------------------------+  
97 -| Core(depends only on system apis) |  
98 -+------------------------------------------------------+  
99 -</pre>  
100 -Stream Architecture:  
101 -<pre>  
102 - +---------+ +----------+  
103 - + Publish + + Deliver |  
104 - +---|-----+ +----|-----+  
105 -+------------------+-------------------------+----------------+  
106 -| Input | SRS(Simple RTMP Server) | Output |  
107 -+------------------+-------------------------+----------------+  
108 -| Encoder(1) | +-> RTMP protocol ----+-> Flash Player |  
109 -| (FMLE,FFMPEG, --+->-+-> HLS/NGINX --------+-> m3u8 player |  
110 -| Flash,XSPLIT, | +-> Fowarder ---------+-> RTMP Server |  
111 -| ......) | +-> Transcoder -------+-> RTMP Server |  
112 -| | +-> DVR --------------+-> FILE |  
113 -| | +-> BandwidthTest ----+-> Flash/StLoad |  
114 -+------------------+ | |  
115 -| MediaSource(2) | | |  
116 -| (RTSP,FILE, | | |  
117 -| HTTP,HLS, --+->-- Ingester -----------+-> SRS |  
118 -| Device, | | |  
119 -| ......) | | |  
120 -+------------------+-------------------------+----------------+  
121 -  
122 -Remark:  
123 -(1) Encoder: encoder must push RTMP stream to SRS server.  
124 -(2) MediaSource: any media source, which can be ingest by ffmpeg.  
125 -</pre>  
126 -(plan) RTMP cluster(origin/edge) Architecture:<br/>  
127 -Remark: cluster over forward, see [Cluster](https://github.com/winlinvip/simple-rtmp-server/wiki/Cluster)  
128 -<pre>  
129 -+---------+ +-----------------+ +-----------------------+  
130 -+ Encoder +--+-->-+ SRS(RTMP Edge) +--->-+ (RTMP Origin) |  
131 -+---------+ | +-----------------+ | SRS/FMS/NGINX-RTMP |  
132 - | | Red5/HELIX/CRTMP |  
133 - +-------------------------->-+ ...... |  
134 - +-----------------------+  
135 -Schema#1: Any RTMP encoder push RTMP stream to RTMP (origin/edge)server,  
136 - where SRS RTMP Edge server will forward stream to origin.  
137 -  
138 -  
139 -+-------------+ +-----------------+ +--------------------+  
140 -| RTMP Origin +-->-+ SRS(RTMP Edge) +--+->-+ Client(RTMP/HLS) |  
141 -+-------------+ +-----------------+ | | Flash/IOS/Android |  
142 - | +--------------------+  
143 - |  
144 - | +-----------------+  
145 - +->-+ SRS(RTMP Edge) +  
146 - +-----------------+  
147 -Schema#2: SRS RTMP Edge server pull stream from origin (or upstream SRS  
148 - RTMP Edge server), then delivery to Client.  
149 -</pre>  
150 -(plan) SRS Multiple processes Architecture(design by wenjie):<br/>  
151 -<pre>  
152 - +---------------+ +--------+  
153 - | upnode server | + client +  
154 - +-------+-------+ +---+----+  
155 - -------------+------------network-------+---------  
156 - | |  
157 - +--------+ +----+-----------+ +----+----------+  
158 - | master +--fork->-+ back source(1) +-->-pull-+ stream 1-N(2) +  
159 - +---+----+ +----------------+ +-------+-------+  
160 - | |  
161 - +-------------------------------------fork--->-----+  
162 - | +-------------+  
163 - +-------------------fork-->-+ http/vod(3) |  
164 - +-------------+  
165 -Remark:  
166 -(1) back source process: create by master process, get stream from  
167 - upnode server if edge, create stream if origin, serve the stream  
168 - process.  
169 -(2) stream process: create by master process, get stream from back  
170 - source process, serve the client.  
171 -(3) the embeded mininum http server, also provides vod service. for  
172 - http server, it provides http api, hls(live/vod) delivery. for  
173 - vod server, it slice the file to hls(m3u8/ts).  
174 -Remark:  
175 -(a) This multiple processes architecture is design by wenjie, it's a  
176 - very simple and powerful multiple process architecture, for the  
177 - master no need to pass between stream process.  
178 -(b) The CLI architecture is similar to this, instead, cli process  
179 - will collect informations from all stream process, master process  
180 - only send signals to child processes.  
181 -</pre>  
182 -CLI Architecture:  
183 -<pre>  
184 - +---------+  
185 - +--+ stream1 +---------+  
186 - | +---------+ |  
187 - +--------+ | +---------+ | +-------+  
188 - | master +--fork->-+--+ streamN +---amf0--+>--+ cli +  
189 - +--------+ | +---------+ | +-------+  
190 - | +-------------+ |  
191 - +--+ back source +-----+  
192 - +-------------+  
193 -Remark:  
194 -(1) master listen the global api port, for example, 33330  
195 -(2) back source and stream processes listen at private api port,  
196 - for example, 33331, 33332, 33333  
197 -(3) work processes(stream and back-source), report private api  
198 - port to master global api port.  
199 -(4) cli connect to master global api port, get all other private  
200 - api ports  
201 -(5) cli connect to each stream/back-source process to get api data,  
202 - cli analysis and summary the data, return to user.  
203 -</pre>  
204 -Bandwidth Test Workflow:  
205 -<pre>  
206 - +------------+ +----------+  
207 - | Client | | Server |  
208 - +-----+------+ +-----+----+  
209 - | |  
210 - | connect vhost-------------> |  
211 - | &lt;-----------result(success) |  
212 - | |  
213 - | &lt;----------call(start play) |  
214 - | result(playing)----------> |  
215 - | &lt;-------------data(playing) |  
216 - | &lt;-----------call(stop play) |  
217 - | result(stopped)----------> |  
218 - | |  
219 - | &lt;-------call(start publish) |  
220 - | result(publishing)-------> |  
221 - | data(publishing)---------> |  
222 - | &lt;--------call(stop publish) |  
223 - | result(stopped)(1)-------> |  
224 - | |  
225 - | &lt;--------------------report |  
226 - | final(2)-----------------> |  
227 - | &lt;END> |  
228 -  
229 -@See: class SrsBandwidth comments.  
230 -</pre>  
231 -  
232 ### System Requirements 72 ### System Requirements
233 Supported operating systems and hardware: 73 Supported operating systems and hardware:
234 * All Linux , both 32 and 64 bits 74 * All Linux , both 32 and 64 bits
@@ -424,6 +264,166 @@ on_connect/close/publish/unpublish/play/stop. @@ -424,6 +264,166 @@ on_connect/close/publish/unpublish/play/stop.
424 * v0.1, 2013-10-18, support rtmp message2chunk protocol(send\_message). 264 * v0.1, 2013-10-18, support rtmp message2chunk protocol(send\_message).
425 * v0.1, 2013-10-17, support rtmp chunk2message protocol(recv\_message). 265 * v0.1, 2013-10-17, support rtmp chunk2message protocol(recv\_message).
426 266
  267 +### Architecture
  268 +System Architecture:
  269 +<pre>
  270 ++------------------------------------------------------+
  271 +| SRS(Simple RTMP Server) |
  272 ++---------------+---------------+-----------+----------+
  273 +| API/hook | Transcoder | HLS | RTMP |
  274 +| http-parser | FFMPEG/x264 | NGINX/ts | protocol |
  275 ++---------------+---------------+-----------+----------+
  276 +| Network(state-threads) |
  277 ++------------------------------------------------------+
  278 +| All Linux(RHEL,CentOS,Ubuntu,Fedora...) |
  279 ++------------------------------------------------------+
  280 +</pre>
  281 +Modularity Architecture:
  282 +<pre>
  283 ++------------------------------------------------------+
  284 +| Main(srs/bandwidth/librtmp) |
  285 ++------------------------------------------------------+
  286 +| App(Server/Client application) |
  287 ++------------------------------------------------------+
  288 +| RTMP(Protocol stack) |
  289 ++------------------------------------------------------+
  290 +| Kernel(depends on Core, provides error/log) |
  291 ++------------------------------------------------------+
  292 +| Core(depends only on system apis) |
  293 ++------------------------------------------------------+
  294 +</pre>
  295 +Stream Architecture:
  296 +<pre>
  297 + +---------+ +----------+
  298 + + Publish + + Deliver |
  299 + +---|-----+ +----|-----+
  300 ++------------------+-------------------------+----------------+
  301 +| Input | SRS(Simple RTMP Server) | Output |
  302 ++------------------+-------------------------+----------------+
  303 +| Encoder(1) | +-> RTMP protocol ----+-> Flash Player |
  304 +| (FMLE,FFMPEG, --+->-+-> HLS/NGINX --------+-> m3u8 player |
  305 +| Flash,XSPLIT, | +-> Fowarder ---------+-> RTMP Server |
  306 +| ......) | +-> Transcoder -------+-> RTMP Server |
  307 +| | +-> DVR --------------+-> FILE |
  308 +| | +-> BandwidthTest ----+-> Flash/StLoad |
  309 ++------------------+ | |
  310 +| MediaSource(2) | | |
  311 +| (RTSP,FILE, | | |
  312 +| HTTP,HLS, --+->-- Ingester -----------+-> SRS |
  313 +| Device, | | |
  314 +| ......) | | |
  315 ++------------------+-------------------------+----------------+
  316 +
  317 +Remark:
  318 +(1) Encoder: encoder must push RTMP stream to SRS server.
  319 +(2) MediaSource: any media source, which can be ingest by ffmpeg.
  320 +</pre>
  321 +(plan) RTMP cluster(origin/edge) Architecture:<br/>
  322 +Remark: cluster over forward, see [Cluster](https://github.com/winlinvip/simple-rtmp-server/wiki/Cluster)
  323 +<pre>
  324 ++---------+ +-----------------+ +-----------------------+
  325 ++ Encoder +--+-->-+ SRS(RTMP Edge) +--->-+ (RTMP Origin) |
  326 ++---------+ | +-----------------+ | SRS/FMS/NGINX-RTMP |
  327 + | | Red5/HELIX/CRTMP |
  328 + +-------------------------->-+ ...... |
  329 + +-----------------------+
  330 +Schema#1: Any RTMP encoder push RTMP stream to RTMP (origin/edge)server,
  331 + where SRS RTMP Edge server will forward stream to origin.
  332 +
  333 +
  334 ++-------------+ +-----------------+ +--------------------+
  335 +| RTMP Origin +-->-+ SRS(RTMP Edge) +--+->-+ Client(RTMP/HLS) |
  336 ++-------------+ +-----------------+ | | Flash/IOS/Android |
  337 + | +--------------------+
  338 + |
  339 + | +-----------------+
  340 + +->-+ SRS(RTMP Edge) +
  341 + +-----------------+
  342 +Schema#2: SRS RTMP Edge server pull stream from origin (or upstream SRS
  343 + RTMP Edge server), then delivery to Client.
  344 +</pre>
  345 +(plan) SRS Multiple processes Architecture(design by wenjie):<br/>
  346 +<pre>
  347 + +---------------+ +--------+
  348 + | upnode server | + client +
  349 + +-------+-------+ +---+----+
  350 + -------------+------------network-------+---------
  351 + | |
  352 + +--------+ +----+-----------+ +----+----------+
  353 + | master +--fork->-+ back source(1) +-->-pull-+ stream 1-N(2) +
  354 + +---+----+ +----------------+ +-------+-------+
  355 + | |
  356 + +-------------------------------------fork--->-----+
  357 + | +-------------+
  358 + +-------------------fork-->-+ http/vod(3) |
  359 + +-------------+
  360 +Remark:
  361 +(1) back source process: create by master process, get stream from
  362 + upnode server if edge, create stream if origin, serve the stream
  363 + process.
  364 +(2) stream process: create by master process, get stream from back
  365 + source process, serve the client.
  366 +(3) the embeded mininum http server, also provides vod service. for
  367 + http server, it provides http api, hls(live/vod) delivery. for
  368 + vod server, it slice the file to hls(m3u8/ts).
  369 +Remark:
  370 +(a) This multiple processes architecture is design by wenjie, it's a
  371 + very simple and powerful multiple process architecture, for the
  372 + master no need to pass between stream process.
  373 +(b) The CLI architecture is similar to this, instead, cli process
  374 + will collect informations from all stream process, master process
  375 + only send signals to child processes.
  376 +</pre>
  377 +CLI Architecture:
  378 +<pre>
  379 + +---------+
  380 + +--+ stream1 +---------+
  381 + | +---------+ |
  382 + +--------+ | +---------+ | +-------+
  383 + | master +--fork->-+--+ streamN +---amf0--+>--+ cli +
  384 + +--------+ | +---------+ | +-------+
  385 + | +-------------+ |
  386 + +--+ back source +-----+
  387 + +-------------+
  388 +Remark:
  389 +(1) master listen the global api port, for example, 33330
  390 +(2) back source and stream processes listen at private api port,
  391 + for example, 33331, 33332, 33333
  392 +(3) work processes(stream and back-source), report private api
  393 + port to master global api port.
  394 +(4) cli connect to master global api port, get all other private
  395 + api ports
  396 +(5) cli connect to each stream/back-source process to get api data,
  397 + cli analysis and summary the data, return to user.
  398 +</pre>
  399 +Bandwidth Test Workflow:
  400 +<pre>
  401 + +------------+ +----------+
  402 + | Client | | Server |
  403 + +-----+------+ +-----+----+
  404 + | |
  405 + | connect vhost-------------> |
  406 + | &lt;-----------result(success) |
  407 + | |
  408 + | &lt;----------call(start play) |
  409 + | result(playing)----------> |
  410 + | &lt;-------------data(playing) |
  411 + | &lt;-----------call(stop play) |
  412 + | result(stopped)----------> |
  413 + | |
  414 + | &lt;-------call(start publish) |
  415 + | result(publishing)-------> |
  416 + | data(publishing)---------> |
  417 + | &lt;--------call(stop publish) |
  418 + | result(stopped)(1)-------> |
  419 + | |
  420 + | &lt;--------------------report |
  421 + | final(2)-----------------> |
  422 + | &lt;END> |
  423 +
  424 +@See: class SrsBandwidth comments.
  425 +</pre>
  426 +
427 Beijing, 2013<br/> 427 Beijing, 2013<br/>
428 Winlin 428 Winlin
429 429
  1 +# the config for srs demo
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleDemo
  3 +# @see full.conf for detail config.
  4 +
1 listen 19350; 5 listen 19350;
2 chunk_size 65000; 6 chunk_size 65000;
3 vhost __defaultVhost__ { 7 vhost __defaultVhost__ {
  1 +# the config for srs demo
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleDemo
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 chunk_size 60000; 6 chunk_size 60000;
3 log_dir ./objs/logs; 7 log_dir ./objs/logs;
  1 +# the config for srs use ffmpeg to transcode
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleFFMPEG
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 transcode { 7 transcode {
  1 +# the config for srs to forward
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleForward
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 forward 127.0.0.1:19350; 7 forward 127.0.0.1:19350;
  1 +# the config for srs to forward
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleForward
  3 +# @see full.conf for detail config.
  4 +
1 listen 19350; 5 listen 19350;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 } 7 }
  1 +# all config for srs
  2 +
1 # the listen ports, split by space. 3 # the listen ports, split by space.
2 listen 1935; 4 listen 1935;
3 # the default chunk size is 128, max is 65536, 5 # the default chunk size is 128, max is 65536,
  1 +# the config for srs to delivery hls
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleHLS
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 hls { 7 hls {
  1 +# the config for srs to delivery realtime RTMP stream
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleRealtime
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 gop_cache off; 7 gop_cache off;
  1 +# the config for srs to delivery RTMP
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleRTMP
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 } 7 }
  1 +# main config for srs.
  2 +# @see full.conf for detail config.
  3 +
1 listen 1935; 4 listen 1935;
2 -# see full.conf for each config.  
3 vhost __defaultVhost__ { 5 vhost __defaultVhost__ {
4 } 6 }
  1 +# the config for srs to delivery hls
  2 +# @see https://github.com/winlinvip/simple-rtmp-server/wiki/SampleHLS
  3 +# @see full.conf for detail config.
  4 +
1 listen 1935; 5 listen 1935;
2 vhost __defaultVhost__ { 6 vhost __defaultVhost__ {
3 hls { 7 hls {