refine the chat, use players_pub_rtmp without hls and gopcache, low latecy
正在显示
3 个修改的文件
包含
93 行增加
和
6 行删除
| @@ -142,6 +142,13 @@ vhost players_pub { | @@ -142,6 +142,13 @@ vhost players_pub { | ||
| 142 | hls_window 30; | 142 | hls_window 30; |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | +# rtmp only, no hls, for chat(low latecy) | ||
| 146 | +vhost players_pub_rtmp { | ||
| 147 | + gop_cache off; | ||
| 148 | + hls { | ||
| 149 | + enabled off; | ||
| 150 | + } | ||
| 151 | +} | ||
| 145 | 152 | ||
| 146 | # for development | 153 | # for development |
| 147 | vhost dev { | 154 | vhost dev { |
| @@ -121,7 +121,7 @@ function build_default_publish_rtmp_url() { | @@ -121,7 +121,7 @@ function build_default_publish_rtmp_url() { | ||
| 121 | if (server == vhost || vhost == "") { | 121 | if (server == vhost || vhost == "") { |
| 122 | return "rtmp://" + server + ":" + port + "/" + app + "/" + stream; | 122 | return "rtmp://" + server + ":" + port + "/" + app + "/" + stream; |
| 123 | } else { | 123 | } else { |
| 124 | - vhost = srs_get_player_publish_vhost(vhost); | 124 | + vhost = srs_get_player_chat_vhost(vhost); |
| 125 | return "rtmp://" + server + ":" + port + "/" + app + "...vhost..." + vhost + "/" + stream; | 125 | return "rtmp://" + server + ":" + port + "/" + app + "...vhost..." + vhost + "/" + stream; |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| @@ -211,6 +211,8 @@ function srs_get_api_server_port() { return 8085; } | @@ -211,6 +211,8 @@ function srs_get_api_server_port() { return 8085; } | ||
| 211 | // for example, src_vhost is "players", we transcode stream to vhost "players_pub". | 211 | // for example, src_vhost is "players", we transcode stream to vhost "players_pub". |
| 212 | // if not equals to the player vhost, return the orignal vhost. | 212 | // if not equals to the player vhost, return the orignal vhost. |
| 213 | function srs_get_player_publish_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub"); } | 213 | function srs_get_player_publish_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub"); } |
| 214 | +// for chat, use rtmp only vhost, low latecy, without gop cache. | ||
| 215 | +function srs_get_player_chat_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub_rtmp"); } | ||
| 214 | 216 | ||
| 215 | /** | 217 | /** |
| 216 | * initialize the page. | 218 | * initialize the page. |
| @@ -276,6 +278,7 @@ function srs_publisher_initialize_page( | @@ -276,6 +278,7 @@ function srs_publisher_initialize_page( | ||
| 276 | for (var i = 0; i < profiles.length; i++) { | 278 | for (var i = 0; i < profiles.length; i++) { |
| 277 | $(sl_profile).append("<option value='" + profiles[i] + "'>" + profiles[i] + "</option"); | 279 | $(sl_profile).append("<option value='" + profiles[i] + "'>" + profiles[i] + "</option"); |
| 278 | } | 280 | } |
| 281 | + $(sl_profile + " option[value='main']").attr("selected", true); | ||
| 279 | 282 | ||
| 280 | $(sl_level).empty(); | 283 | $(sl_level).empty(); |
| 281 | var levels = ["1", "1b", "1.1", "1.2", "1.3", | 284 | var levels = ["1", "1b", "1.1", "1.2", "1.3", |
| @@ -291,7 +294,84 @@ function srs_publisher_initialize_page( | @@ -291,7 +294,84 @@ function srs_publisher_initialize_page( | ||
| 291 | for (var i = 0; i < gops.length; i++) { | 294 | for (var i = 0; i < gops.length; i++) { |
| 292 | $(sl_gop).append("<option value='" + gops[i] + "'>" + gops[i] + "秒</option"); | 295 | $(sl_gop).append("<option value='" + gops[i] + "'>" + gops[i] + "秒</option"); |
| 293 | } | 296 | } |
| 294 | - $(sl_gop + " option[value='5']").attr("selected", true); | 297 | + $(sl_gop + " option[value='10']").attr("selected", true); |
| 298 | + | ||
| 299 | + $(sl_size).empty(); | ||
| 300 | + var sizes = ["176x144", "320x240", "352x240", | ||
| 301 | + "352x288", "460x240", "640x480", "720x480", "720x576", "800x600", | ||
| 302 | + "1024x768", "1280x720", "1360x768", "1920x1080"]; | ||
| 303 | + for (i = 0; i < sizes.length; i++) { | ||
| 304 | + $(sl_size).append("<option value='" + sizes[i] + "'>" + sizes[i] + "</option"); | ||
| 305 | + } | ||
| 306 | + $(sl_size + " option[value='640x480']").attr("selected", true); | ||
| 307 | + | ||
| 308 | + $(sl_fps).empty(); | ||
| 309 | + var fpses = ["5", "10", "15", "20", "24", "25", "29.97", "30"]; | ||
| 310 | + for (i = 0; i < fpses.length; i++) { | ||
| 311 | + $(sl_fps).append("<option value='" + fpses[i] + "'>" + Number(fpses[i]).toFixed(2) + " 帧/秒</option"); | ||
| 312 | + } | ||
| 313 | + $(sl_fps + " option[value='20']").attr("selected", true); | ||
| 314 | + | ||
| 315 | + $(sl_bitrate).empty(); | ||
| 316 | + var bitrates = ["50", "200", "350", "500", "650", "800", | ||
| 317 | + "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"]; | ||
| 318 | + for (i = 0; i < bitrates.length; i++) { | ||
| 319 | + $(sl_bitrate).append("<option value='" + bitrates[i] + "'>" + bitrates[i] + " kbps</option"); | ||
| 320 | + } | ||
| 321 | + $(sl_bitrate + " option[value='500']").attr("selected", true); | ||
| 322 | +} | ||
| 323 | +/** | ||
| 324 | +* for chat, use low latecy settings. | ||
| 325 | +*/ | ||
| 326 | +function srs_chat_initialize_page( | ||
| 327 | + cameras, microphones, | ||
| 328 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | ||
| 329 | +) { | ||
| 330 | + $(sl_cameras).empty(); | ||
| 331 | + for (var i = 0; i < cameras.length; i++) { | ||
| 332 | + $(sl_cameras).append("<option value='" + i + "'>" + cameras[i] + "</option"); | ||
| 333 | + } | ||
| 334 | + // optional: select the first no "virtual" signed. | ||
| 335 | + for (var i = 0; i < cameras.length; i++) { | ||
| 336 | + if (cameras[i].toLowerCase().indexOf("virtual") == -1) { | ||
| 337 | + $(sl_cameras + " option[value='" + i + "']").attr("selected", true); | ||
| 338 | + break; | ||
| 339 | + } | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + $(sl_microphones).empty(); | ||
| 343 | + for (var i = 0; i < microphones.length; i++) { | ||
| 344 | + $(sl_microphones).append("<option value='" + i + "'>" + microphones[i] + "</option"); | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + $(sl_vcodec).empty(); | ||
| 348 | + var vcodecs = ["h264", "vp6"]; | ||
| 349 | + for (var i = 0; i < vcodecs.length; i++) { | ||
| 350 | + $(sl_vcodec).append("<option value='" + vcodecs[i] + "'>" + vcodecs[i] + "</option"); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + $(sl_profile).empty(); | ||
| 354 | + var profiles = ["baseline", "main"]; | ||
| 355 | + for (var i = 0; i < profiles.length; i++) { | ||
| 356 | + $(sl_profile).append("<option value='" + profiles[i] + "'>" + profiles[i] + "</option"); | ||
| 357 | + } | ||
| 358 | + $(sl_profile + " option[value='baseline']").attr("selected", true); | ||
| 359 | + | ||
| 360 | + $(sl_level).empty(); | ||
| 361 | + var levels = ["1", "1b", "1.1", "1.2", "1.3", | ||
| 362 | + "2", "2.1", "2.2", "3", "3.1", "3.2", "4", "4.1", "4.2", "5", "5.1"]; | ||
| 363 | + for (var i = 0; i < levels.length; i++) { | ||
| 364 | + $(sl_level).append("<option value='" + levels[i] + "'>" + levels[i] + "</option"); | ||
| 365 | + } | ||
| 366 | + $(sl_level + " option[value='3.1']").attr("selected", true); | ||
| 367 | + | ||
| 368 | + $(sl_gop).empty(); | ||
| 369 | + var gops = ["0.3", "0.5", "1", "2", "3", "4", | ||
| 370 | + "5", "6", "7", "8", "9", "10", "15", "20"]; | ||
| 371 | + for (var i = 0; i < gops.length; i++) { | ||
| 372 | + $(sl_gop).append("<option value='" + gops[i] + "'>" + gops[i] + "秒</option"); | ||
| 373 | + } | ||
| 374 | + $(sl_gop + " option[value='0.5']").attr("selected", true); | ||
| 295 | 375 | ||
| 296 | $(sl_size).empty(); | 376 | $(sl_size).empty(); |
| 297 | var sizes = ["176x144", "320x240", "352x240", | 377 | var sizes = ["176x144", "320x240", "352x240", |
| @@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
| 48 | // start the publisher. | 48 | // start the publisher. |
| 49 | srs_publisher = new SrsPublisher("local_publisher", 430, 185); | 49 | srs_publisher = new SrsPublisher("local_publisher", 430, 185); |
| 50 | srs_publisher.on_publisher_ready = function(cameras, microphones) { | 50 | srs_publisher.on_publisher_ready = function(cameras, microphones) { |
| 51 | - srs_publisher_initialize_page( | 51 | + srs_chat_initialize_page( |
| 52 | cameras, microphones, | 52 | cameras, microphones, |
| 53 | "#sl_cameras", "#sl_microphones", | 53 | "#sl_cameras", "#sl_microphones", |
| 54 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", | 54 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", |
| @@ -67,8 +67,8 @@ | @@ -67,8 +67,8 @@ | ||
| 67 | // start the realtime player. | 67 | // start the realtime player. |
| 68 | realtime_player = new SrsPlayer("realtime_player", 430, 185); | 68 | realtime_player = new SrsPlayer("realtime_player", 430, 185); |
| 69 | realtime_player.on_player_ready = function() { | 69 | realtime_player.on_player_ready = function() { |
| 70 | - realtime_player.set_bt(0.8); | ||
| 71 | - realtime_player.set_fs("screen", 100); | 70 | + this.set_bt(0.5); |
| 71 | + this.set_fs("screen", 100); | ||
| 72 | }; | 72 | }; |
| 73 | realtime_player.start(); | 73 | realtime_player.start(); |
| 74 | } | 74 | } |
| @@ -211,7 +211,7 @@ | @@ -211,7 +211,7 @@ | ||
| 211 | // start the realtime player. | 211 | // start the realtime player. |
| 212 | var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300); | 212 | var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300); |
| 213 | _player.on_player_ready = function() { | 213 | _player.on_player_ready = function() { |
| 214 | - this.set_bt(0.8); | 214 | + this.set_bt(0.5); |
| 215 | this.set_fs("screen", 100); | 215 | this.set_fs("screen", 100); |
| 216 | }; | 216 | }; |
| 217 | _player.start(chat.url); | 217 | _player.start(chat.url); |
-
请 注册 或 登录 后发表评论