srs.conf 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. listen 1935;
  2. max_connections 1000;
  3. srs_log_tank file;
  4. srs_log_file ./objs/srs.log;
  5. daemon off;
  6. http_api {
  7. enabled on;
  8. listen 1985;
  9. raw_api {
  10. # whether enable the HTTP RAW API.
  11. # default: off
  12. enabled on;
  13. # whether enable rpc reload.
  14. # default: off
  15. allow_reload on;
  16. # whether enable rpc query.
  17. # default: off
  18. allow_query on;
  19. # whether enable rpc update.
  20. # default: off
  21. allow_update on;
  22. }
  23. }
  24. http_server {
  25. enabled on;
  26. listen 8080;
  27. dir ./objs/nginx/html;
  28. }
  29. stats {
  30. network 0;
  31. disk sda sdb xvda xvdb;
  32. }
  33. stream_caster {
  34. enabled on;
  35. caster gb28181;
  36. # 转发流到rtmp服务器地址与端口
  37. # TODO: https://github.com/ossrs/srs/pull/1679/files#r400875104
  38. # [stream] is VideoChannelCodecID(视频通道编码ID) for sip
  39. # 自动创建的道通[stream] 是‘chid[ssrc]’ [ssrc]是rtp的ssrc
  40. # [ssrc] rtp中的ssrc
  41. output rtmp://127.0.0.1:1935/live/[ssrc];
  42. # 接收设备端rtp流的多路复用端口
  43. listen 9000;
  44. # rtp接收监听端口范围,最小值
  45. rtp_port_min 58200;
  46. # rtp接收监听端口范围,最大值
  47. rtp_port_max 58300;
  48. # 是否等待关键帧之后,再转发,
  49. # off:不需等待,直接转发
  50. # on:等第一个关键帧后,再转发
  51. wait_keyframe on;
  52. # rtp包空闲等待时间,如果指定时间没有收到任何包
  53. # rtp监听连接自动停止,发送BYE命令
  54. rtp_idle_timeout 30;
  55. # 是否转发音频流
  56. # 目前只支持aac格式,所以需要设备支持aac格式
  57. # on:转发音频
  58. # off:不转发音频,只有视频
  59. # *注意*!!!:flv 只支持11025 22050 44100 三种
  60. # 如果设备端没有三种中任何一个,转发时为自动选择一种格式
  61. # 同时也会将adts的头封装在flv aac raw数据中
  62. # 这样的话播放器为自动通过adts头自动选择采样频率
  63. # 像ffplay, vlc都可以,但是flash是没有声音,
  64. # 因为flash,只支持11025 22050 44100
  65. audio_enable on;
  66. # 是否开启rtp缓冲
  67. # 开启之后能有效解决rtp乱序等问题
  68. jitterbuffer_enable on;
  69. # 服务器主机号,可以域名或ip地址
  70. # 也就是设备端将媒体发送的地址,如果是服务器是内外网
  71. # 需要写外网地址,
  72. # 调用api创建stream session时返回ip地址也是host
  73. # $CANDIDATE 是系统环境变量,从环境变量获取地址,如果没有配置,用*
  74. # *代表指定stats network 的网卡号地址,如果没有配置network,默认则是第0号网卡地址
  75. # TODO: https://github.com/ossrs/srs/pull/1679/files#r400917594
  76. host host.docker.internal;
  77. #根据收到ps rtp包自带创建rtmp媒体通道,不需要api接口创建
  78. #rtmp地址参数[stream] 就是通道id 格式chid[ssrc]
  79. auto_create_channel on;
  80. sip {
  81. # 是否启用srs内部sip信令
  82. # 为on信令走srs, off 只转发ps流
  83. enabled off;
  84. # sip监听udp端口
  85. listen 5060;
  86. # SIP server ID(SIP服务器ID).
  87. # 设备端配置编号需要与该值一致,否则无法注册
  88. serial 34020000002000000001;
  89. # SIP server domain(SIP服务器域)
  90. realm 3402000000;
  91. # 服务端发送ack后,接收回应的超时时间,单位为秒
  92. # 如果指定时间没有回应,认为失败
  93. ack_timeout 30;
  94. # 设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
  95. # 认为设备离线
  96. keepalive_timeout 120;
  97. # 注册之后是否自动给设备端发送invite
  98. # on: 是 off 不是,需要通过api控制
  99. auto_play on;
  100. # 设备将流发送的端口,是否固定
  101. # on 发送流到多路复用端口 如9000
  102. # off 自动从rtp_mix_port - rtp_max_port 之间的值中
  103. # 选一个可以用的端口
  104. invite_port_fixed on;
  105. # 向设备或下级域查询设备列表的间隔,单位(秒)
  106. # 默认60秒
  107. query_catalog_interval 60;
  108. }
  109. }
  110. vhost __defaultVhost__ {
  111. hls {
  112. enabled off;
  113. }
  114. http_remux {
  115. enabled on;
  116. mount [vhost]/[app]/[stream].flv;
  117. }
  118. rtc {
  119. enabled on;
  120. bframe discard;
  121. }
  122. http_hooks {
  123. # whether the http hooks enable.
  124. # default off.
  125. enabled on;
  126. # when client connect to vhost/app, call the hook,
  127. # the request in the POST data string is a object encode by json:
  128. # {
  129. # "action": "on_connect",
  130. # "client_id": 1985,
  131. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  132. # "tcUrl": "rtmp://video.test.com/live?key=d2fa801d08e3f90ed1e1670e6e52651a",
  133. # "pageUrl": "http://www.test.com/live.html"
  134. # }
  135. # if valid, the hook must return HTTP code 200(Status OK) and response
  136. # an int value specifies the error code(0 corresponding to success):
  137. # 0
  138. # support multiple api hooks, format:
  139. # on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN
  140. # @remark For SRS4, the HTTPS url is supported, for example:
  141. # on_connect https://xxx/api0 https://xxx/api1 https://xxx/apiN
  142. on_connect http://host.docker.internal:8844/media/srs/notify/on_connect;
  143. # when client close/disconnect to vhost/app/stream, call the hook,
  144. # the request in the POST data string is a object encode by json:
  145. # {
  146. # "action": "on_close",
  147. # "client_id": 1985,
  148. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  149. # "send_bytes": 10240, "recv_bytes": 10240
  150. # }
  151. # if valid, the hook must return HTTP code 200(Status OK) and response
  152. # an int value specifies the error code(0 corresponding to success):
  153. # 0
  154. # support multiple api hooks, format:
  155. # on_close http://xxx/api0 http://xxx/api1 http://xxx/apiN
  156. # @remark For SRS4, the HTTPS url is supported, for example:
  157. # on_close https://xxx/api0 https://xxx/api1 https://xxx/apiN
  158. on_close http://host.docker.internal:8844/media/srs/notify/on_close;
  159. # when client(encoder) publish to vhost/app/stream, call the hook,
  160. # the request in the POST data string is a object encode by json:
  161. # {
  162. # "action": "on_publish",
  163. # "client_id": 1985,
  164. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  165. # "stream": "livestream", "param":"?token=xxx&salt=yyy"
  166. # }
  167. # if valid, the hook must return HTTP code 200(Status OK) and response
  168. # an int value specifies the error code(0 corresponding to success):
  169. # 0
  170. # support multiple api hooks, format:
  171. # on_publish http://xxx/api0 http://xxx/api1 http://xxx/apiN
  172. # @remark For SRS4, the HTTPS url is supported, for example:
  173. # on_publish https://xxx/api0 https://xxx/api1 https://xxx/apiN
  174. on_publish http://host.docker.internal:8844/media/srs/notify/on_publish;
  175. # when client(encoder) stop publish to vhost/app/stream, call the hook,
  176. # the request in the POST data string is a object encode by json:
  177. # {
  178. # "action": "on_unpublish",
  179. # "client_id": 1985,
  180. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  181. # "stream": "livestream", "param":"?token=xxx&salt=yyy"
  182. # }
  183. # if valid, the hook must return HTTP code 200(Status OK) and response
  184. # an int value specifies the error code(0 corresponding to success):
  185. # 0
  186. # support multiple api hooks, format:
  187. # on_unpublish http://xxx/api0 http://xxx/api1 http://xxx/apiN
  188. # @remark For SRS4, the HTTPS url is supported, for example:
  189. # on_unpublish https://xxx/api0 https://xxx/api1 https://xxx/apiN
  190. on_unpublish http://host.docker.internal:8844/media/srs/notify/on_unpublish;
  191. # when client start to play vhost/app/stream, call the hook,
  192. # the request in the POST data string is a object encode by json:
  193. # {
  194. # "action": "on_play",
  195. # "client_id": 1985,
  196. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  197. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  198. # "pageUrl": "http://www.test.com/live.html"
  199. # }
  200. # if valid, the hook must return HTTP code 200(Status OK) and response
  201. # an int value specifies the error code(0 corresponding to success):
  202. # 0
  203. # support multiple api hooks, format:
  204. # on_play http://xxx/api0 http://xxx/api1 http://xxx/apiN
  205. # @remark For SRS4, the HTTPS url is supported, for example:
  206. # on_play https://xxx/api0 https://xxx/api1 https://xxx/apiN
  207. on_play http://host.docker.internal:8844/media/srs/notify/on_play;
  208. # when client stop to play vhost/app/stream, call the hook,
  209. # the request in the POST data string is a object encode by json:
  210. # {
  211. # "action": "on_stop",
  212. # "client_id": 1985,
  213. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  214. # "stream": "livestream", "param":"?token=xxx&salt=yyy"
  215. # }
  216. # if valid, the hook must return HTTP code 200(Status OK) and response
  217. # an int value specifies the error code(0 corresponding to success):
  218. # 0
  219. # support multiple api hooks, format:
  220. # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
  221. # @remark For SRS4, the HTTPS url is supported, for example:
  222. # on_stop https://xxx/api0 https://xxx/api1 https://xxx/apiN
  223. on_stop http://host.docker.internal:8844/media/srs/notify/on_stop;
  224. # when srs reap a dvr file, call the hook,
  225. # the request in the POST data string is a object encode by json:
  226. # {
  227. # "action": "on_dvr",
  228. # "client_id": 1985,
  229. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  230. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  231. # "cwd": "/usr/local/srs",
  232. # "file": "./objs/nginx/html/live/livestream.1420254068776.flv"
  233. # }
  234. # if valid, the hook must return HTTP code 200(Status OK) and response
  235. # an int value specifies the error code(0 corresponding to success):
  236. # 0
  237. on_dvr http://host.docker.internal:8844/media/srs/notify/on_dvr;
  238. # when srs reap a ts file of hls, call the hook,
  239. # the request in the POST data string is a object encode by json:
  240. # {
  241. # "action": "on_hls",
  242. # "client_id": 1985,
  243. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  244. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  245. # "duration": 9.36, // in seconds
  246. # "cwd": "/usr/local/srs",
  247. # "file": "./objs/nginx/html/live/livestream/2015-04-23/01/476584165.ts",
  248. # "url": "live/livestream/2015-04-23/01/476584165.ts",
  249. # "m3u8": "./objs/nginx/html/live/livestream/live.m3u8",
  250. # "m3u8_url": "live/livestream/live.m3u8",
  251. # "seq_no": 100
  252. # }
  253. # if valid, the hook must return HTTP code 200(Status OK) and response
  254. # an int value specifies the error code(0 corresponding to success):
  255. # 0
  256. on_hls http://host.docker.internal:8844/media/srs/notify/on_hls;
  257. # when srs reap a ts file of hls, call this hook,
  258. # used to push file to cdn network, by get the ts file from cdn network.
  259. # so we use HTTP GET and use the variable following:
  260. # [app], replace with the app.
  261. # [stream], replace with the stream.
  262. # [param], replace with the param.
  263. # [ts_url], replace with the ts url.
  264. # ignore any return data of server.
  265. # @remark random select a url to report, not report all.
  266. on_hls_notify http://host.docker.internal:8844/media/srs/notify/hls_[app]_[stream]_[ts_url]/[param];
  267. }
  268. }