正在显示
11 个修改的文件
包含
96 行增加
和
19 行删除
| @@ -180,9 +180,32 @@ vhost players_pub { | @@ -180,9 +180,32 @@ vhost players_pub { | ||
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | -vhost players_pub_rtmp { | 183 | +vhost players_chat { |
| 184 | gop_cache off; | 184 | gop_cache off; |
| 185 | hls { | 185 | hls { |
| 186 | enabled off; | 186 | enabled off; |
| 187 | } | 187 | } |
| 188 | + transcode { | ||
| 189 | + enabled on; | ||
| 190 | + ffmpeg ./objs/ffmpeg/bin/ffmpeg; | ||
| 191 | + engine chat_hls { | ||
| 192 | + enabled on; | ||
| 193 | + vcodec copy; | ||
| 194 | + acodec libaacplus; | ||
| 195 | + abitrate 30; | ||
| 196 | + asample_rate 44100; | ||
| 197 | + achannels 2; | ||
| 198 | + aparams { | ||
| 199 | + } | ||
| 200 | + output rtmp://127.0.0.1:[port]/[app]?vhost=players_pub/[stream]; | ||
| 201 | + } | ||
| 202 | + } | ||
| 203 | +} | ||
| 204 | +vhost chat_hls { | ||
| 205 | + hls { | ||
| 206 | + enabled on; | ||
| 207 | + hls_path ./objs/nginx/html; | ||
| 208 | + hls_fragment 2; | ||
| 209 | + hls_window 8; | ||
| 210 | + } | ||
| 188 | } | 211 | } |
| @@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
| 2 | ////////////////////////////////////////////////////////////////////////////////// | 2 | ////////////////////////////////////////////////////////////////////////////////// |
| 3 | ////////////////////////////////////////////////////////////////////////////////// | 3 | ////////////////////////////////////////////////////////////////////////////////// |
| 4 | 4 | ||
| 5 | +// to query the swf anti cache. | ||
| 6 | +function srs_get_version_code() { return "1.20"; } | ||
| 7 | + | ||
| 5 | /** | 8 | /** |
| 6 | * player specified size. | 9 | * player specified size. |
| 7 | */ | 10 | */ |
| @@ -9,8 +12,6 @@ function srs_get_player_modal() { return 740; } | @@ -9,8 +12,6 @@ function srs_get_player_modal() { return 740; } | ||
| 9 | function srs_get_player_width() { return srs_get_player_modal() - 30; } | 12 | function srs_get_player_width() { return srs_get_player_modal() - 30; } |
| 10 | function srs_get_player_height() { return srs_get_player_width() * 9 / 19; } | 13 | function srs_get_player_height() { return srs_get_player_width() * 9 / 19; } |
| 11 | 14 | ||
| 12 | -// to query the swf anti cache. | ||
| 13 | -function srs_get_version_code() { return "1.19"; } | ||
| 14 | // get the default vhost for players. | 15 | // get the default vhost for players. |
| 15 | function srs_get_player_vhost() { return "players"; } | 16 | function srs_get_player_vhost() { return "players"; } |
| 16 | // the api server port, for chat room. | 17 | // the api server port, for chat room. |
| @@ -23,7 +24,7 @@ function srs_get_srs_http_server_port() { return 8080; } | @@ -23,7 +24,7 @@ function srs_get_srs_http_server_port() { return 8080; } | ||
| 23 | // if not equals to the player vhost, return the orignal vhost. | 24 | // if not equals to the player vhost, return the orignal vhost. |
| 24 | function srs_get_player_publish_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub"); } | 25 | function srs_get_player_publish_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub"); } |
| 25 | // for chat, use rtmp only vhost, low latecy, without gop cache. | 26 | // for chat, use rtmp only vhost, low latecy, without gop cache. |
| 26 | -function srs_get_player_chat_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_pub_rtmp"); } | 27 | +function srs_get_player_chat_vhost(src_vhost) { return (src_vhost != srs_get_player_vhost())? src_vhost:(src_vhost + "_chat"); } |
| 27 | 28 | ||
| 28 | ////////////////////////////////////////////////////////////////////////////////// | 29 | ////////////////////////////////////////////////////////////////////////////////// |
| 29 | ////////////////////////////////////////////////////////////////////////////////// | 30 | ////////////////////////////////////////////////////////////////////////////////// |
| @@ -181,7 +182,8 @@ function srs_can_republish() { | @@ -181,7 +182,8 @@ function srs_can_republish() { | ||
| 181 | // without default values set. | 182 | // without default values set. |
| 182 | function srs_initialize_codec_page( | 183 | function srs_initialize_codec_page( |
| 183 | cameras, microphones, | 184 | cameras, microphones, |
| 184 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 185 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 186 | + sl_acodec | ||
| 185 | ) { | 187 | ) { |
| 186 | $(sl_cameras).empty(); | 188 | $(sl_cameras).empty(); |
| 187 | for (var i = 0; i < cameras.length; i++) { | 189 | for (var i = 0; i < cameras.length; i++) { |
| @@ -292,17 +294,25 @@ function srs_initialize_codec_page( | @@ -292,17 +294,25 @@ function srs_initialize_codec_page( | ||
| 292 | for (i = 0; i < bitrates.length; i++) { | 294 | for (i = 0; i < bitrates.length; i++) { |
| 293 | $(sl_bitrate).append("<option value='" + bitrates[i] + "'>" + bitrates[i] + " kbps</option"); | 295 | $(sl_bitrate).append("<option value='" + bitrates[i] + "'>" + bitrates[i] + " kbps</option"); |
| 294 | } | 296 | } |
| 297 | + | ||
| 298 | + $(sl_acodec).empty(); | ||
| 299 | + var bitrates = ["speex", "nellymoser", "pcma", "pcmu"]; | ||
| 300 | + for (i = 0; i < bitrates.length; i++) { | ||
| 301 | + $(sl_acodec).append("<option value='" + bitrates[i] + "'>" + bitrates[i] + "</option"); | ||
| 302 | + } | ||
| 295 | } | 303 | } |
| 296 | /** | 304 | /** |
| 297 | * when publisher ready, init the page elements. | 305 | * when publisher ready, init the page elements. |
| 298 | */ | 306 | */ |
| 299 | function srs_publisher_initialize_page( | 307 | function srs_publisher_initialize_page( |
| 300 | cameras, microphones, | 308 | cameras, microphones, |
| 301 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 309 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 310 | + sl_acodec | ||
| 302 | ) { | 311 | ) { |
| 303 | srs_initialize_codec_page( | 312 | srs_initialize_codec_page( |
| 304 | cameras, microphones, | 313 | cameras, microphones, |
| 305 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 314 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 315 | + sl_acodec | ||
| 306 | ); | 316 | ); |
| 307 | 317 | ||
| 308 | //var profiles = ["baseline", "main"]; | 318 | //var profiles = ["baseline", "main"]; |
| @@ -327,17 +337,22 @@ function srs_publisher_initialize_page( | @@ -327,17 +337,22 @@ function srs_publisher_initialize_page( | ||
| 327 | //var bitrates = ["50", "200", "350", "500", "650", "800", | 337 | //var bitrates = ["50", "200", "350", "500", "650", "800", |
| 328 | // "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"]; | 338 | // "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"]; |
| 329 | $(sl_bitrate + " option[value='500']").attr("selected", true); | 339 | $(sl_bitrate + " option[value='500']").attr("selected", true); |
| 340 | + | ||
| 341 | + // speex | ||
| 342 | + $(sl_acodec + " option[value='speex']").attr("selected", true); | ||
| 330 | } | 343 | } |
| 331 | /** | 344 | /** |
| 332 | * for chat, use low latecy settings. | 345 | * for chat, use low latecy settings. |
| 333 | */ | 346 | */ |
| 334 | function srs_chat_initialize_page( | 347 | function srs_chat_initialize_page( |
| 335 | cameras, microphones, | 348 | cameras, microphones, |
| 336 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 349 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 350 | + sl_acodec | ||
| 337 | ) { | 351 | ) { |
| 338 | srs_initialize_codec_page( | 352 | srs_initialize_codec_page( |
| 339 | cameras, microphones, | 353 | cameras, microphones, |
| 340 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 354 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 355 | + sl_acodec | ||
| 341 | ); | 356 | ); |
| 342 | 357 | ||
| 343 | //var profiles = ["baseline", "main"]; | 358 | //var profiles = ["baseline", "main"]; |
| @@ -362,14 +377,19 @@ function srs_chat_initialize_page( | @@ -362,14 +377,19 @@ function srs_chat_initialize_page( | ||
| 362 | //var bitrates = ["50", "200", "350", "500", "650", "800", | 377 | //var bitrates = ["50", "200", "350", "500", "650", "800", |
| 363 | // "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"]; | 378 | // "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"]; |
| 364 | $(sl_bitrate + " option[value='350']").attr("selected", true); | 379 | $(sl_bitrate + " option[value='350']").attr("selected", true); |
| 380 | + | ||
| 381 | + // speex | ||
| 382 | + $(sl_acodec + " option[value='speex']").attr("selected", true); | ||
| 365 | } | 383 | } |
| 366 | /** | 384 | /** |
| 367 | * get the vcodec and acodec. | 385 | * get the vcodec and acodec. |
| 368 | */ | 386 | */ |
| 369 | function srs_publiser_get_codec( | 387 | function srs_publiser_get_codec( |
| 370 | vcodec, acodec, | 388 | vcodec, acodec, |
| 371 | - sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate | 389 | + sl_cameras, sl_microphones, sl_vcodec, sl_profile, sl_level, sl_gop, sl_size, sl_fps, sl_bitrate, |
| 390 | + sl_acodec | ||
| 372 | ) { | 391 | ) { |
| 392 | + acodec.codec = $(sl_acodec).val(); | ||
| 373 | acodec.device_code = $(sl_microphones).val(); | 393 | acodec.device_code = $(sl_microphones).val(); |
| 374 | acodec.device_name = $(sl_microphones).text(); | 394 | acodec.device_name = $(sl_microphones).text(); |
| 375 | 395 |
| @@ -82,7 +82,8 @@ | @@ -82,7 +82,8 @@ | ||
| 82 | cameras, microphones, | 82 | cameras, microphones, |
| 83 | "#sl_cameras", "#sl_microphones", | 83 | "#sl_cameras", "#sl_microphones", |
| 84 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", | 84 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", |
| 85 | - "#sl_fps", "#sl_bitrate" | 85 | + "#sl_fps", "#sl_bitrate", |
| 86 | + "#sl_acodec" | ||
| 86 | ); | 87 | ); |
| 87 | }; | 88 | }; |
| 88 | srs_publisher.on_publisher_error = function(code, desc) { | 89 | srs_publisher.on_publisher_error = function(code, desc) { |
| @@ -490,7 +491,8 @@ | @@ -490,7 +491,8 @@ | ||
| 490 | vcodec, acodec, | 491 | vcodec, acodec, |
| 491 | "#sl_cameras", "#sl_microphones", | 492 | "#sl_cameras", "#sl_microphones", |
| 492 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", | 493 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", |
| 493 | - "#sl_fps", "#sl_bitrate" | 494 | + "#sl_fps", "#sl_bitrate", |
| 495 | + "#sl_acodec" | ||
| 494 | ); | 496 | ); |
| 495 | 497 | ||
| 496 | var chat = {}; | 498 | var chat = {}; |
| @@ -760,6 +762,17 @@ | @@ -760,6 +762,17 @@ | ||
| 760 | <select class="span4" id="sl_microphones"></select> | 762 | <select class="span4" id="sl_microphones"></select> |
| 761 | </div> | 763 | </div> |
| 762 | </div> | 764 | </div> |
| 765 | + <div class="control-group"> | ||
| 766 | + <label class="control-label" for="sl_acodec"> | ||
| 767 | + 编码 | ||
| 768 | + <a id="sl_acodec_tips" href="#" data-toggle="tooltip" data-placement="right" title=""> | ||
| 769 | + <img src="img/tooltip.png"/> | ||
| 770 | + </a> | ||
| 771 | + </label> | ||
| 772 | + <div class="controls"> | ||
| 773 | + <select class="span2" id="sl_acodec"></select> | ||
| 774 | + </div> | ||
| 775 | + </div> | ||
| 763 | </div> | 776 | </div> |
| 764 | </div> | 777 | </div> |
| 765 | <div class="modal-footer"> | 778 | <div class="modal-footer"> |
| @@ -67,7 +67,8 @@ | @@ -67,7 +67,8 @@ | ||
| 67 | cameras, microphones, | 67 | cameras, microphones, |
| 68 | "#sl_cameras", "#sl_microphones", | 68 | "#sl_cameras", "#sl_microphones", |
| 69 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", | 69 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", |
| 70 | - "#sl_fps", "#sl_bitrate" | 70 | + "#sl_fps", "#sl_bitrate", |
| 71 | + "#sl_acodec" | ||
| 71 | ); | 72 | ); |
| 72 | }; | 73 | }; |
| 73 | srs_publisher.on_publisher_error = function(code, desc) { | 74 | srs_publisher.on_publisher_error = function(code, desc) { |
| @@ -184,7 +185,8 @@ | @@ -184,7 +185,8 @@ | ||
| 184 | vcodec, acodec, | 185 | vcodec, acodec, |
| 185 | "#sl_cameras", "#sl_microphones", | 186 | "#sl_cameras", "#sl_microphones", |
| 186 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", | 187 | "#sl_vcodec", "#sl_profile", "#sl_level", "#sl_gop", "#sl_size", |
| 187 | - "#sl_fps", "#sl_bitrate" | 188 | + "#sl_fps", "#sl_bitrate", |
| 189 | + "#sl_acodec" | ||
| 188 | ); | 190 | ); |
| 189 | 191 | ||
| 190 | info("开始推流到服务器"); | 192 | info("开始推流到服务器"); |
| @@ -376,6 +378,17 @@ | @@ -376,6 +378,17 @@ | ||
| 376 | <select class="span4" id="sl_microphones"></select> | 378 | <select class="span4" id="sl_microphones"></select> |
| 377 | </div> | 379 | </div> |
| 378 | </div> | 380 | </div> |
| 381 | + <div class="control-group"> | ||
| 382 | + <label class="control-label" for="sl_acodec"> | ||
| 383 | + 编码 | ||
| 384 | + <a id="sl_acodec_tips" href="#" data-toggle="tooltip" data-placement="right" title=""> | ||
| 385 | + <img src="img/tooltip.png"/> | ||
| 386 | + </a> | ||
| 387 | + </label> | ||
| 388 | + <div class="controls"> | ||
| 389 | + <select class="span2" id="sl_acodec"></select> | ||
| 390 | + </div> | ||
| 391 | + </div> | ||
| 379 | </div> | 392 | </div> |
| 380 | </div> | 393 | </div> |
| 381 | <div class="modal-footer"> | 394 | <div class="modal-footer"> |
| @@ -273,7 +273,7 @@ package | @@ -273,7 +273,7 @@ package | ||
| 273 | var microRate:int = 22; // 22 === 22050 Hz | 273 | var microRate:int = 22; // 22 === 22050 Hz |
| 274 | 274 | ||
| 275 | trace("[Publish] audio encoding parameters: " | 275 | trace("[Publish] audio encoding parameters: " |
| 276 | - + "audio(microphone) encodeQuality=" + microEncodeQuality | 276 | + + "audio(microphone) codec=" + acodec.codec + "encodeQuality=" + microEncodeQuality |
| 277 | + ", rate=" + microRate + "(22050Hz)" | 277 | + ", rate=" + microRate + "(22050Hz)" |
| 278 | ); | 278 | ); |
| 279 | 279 | ||
| @@ -288,7 +288,15 @@ package | @@ -288,7 +288,15 @@ package | ||
| 288 | m.rate = microRate; | 288 | m.rate = microRate; |
| 289 | 289 | ||
| 290 | // see: http://www.adobe.com/cn/devnet/flashplayer/articles/acoustic-echo-cancellation.html | 290 | // see: http://www.adobe.com/cn/devnet/flashplayer/articles/acoustic-echo-cancellation.html |
| 291 | + if (acodec.codec == "nellymoser") { | ||
| 292 | + m.codec = SoundCodec.NELLYMOSER; | ||
| 293 | + } else if (acodec.codec == "pcma") { | ||
| 294 | + m.codec = SoundCodec.PCMA; | ||
| 295 | + } else if (acodec.codec == "pcmu") { | ||
| 296 | + m.codec = SoundCodec.PCMU; | ||
| 297 | + } else { | ||
| 291 | m.codec = SoundCodec.SPEEX; | 298 | m.codec = SoundCodec.SPEEX; |
| 299 | + } | ||
| 292 | m.framesPerPacket = 1; | 300 | m.framesPerPacket = 1; |
| 293 | } | 301 | } |
| 294 | private function __build_video_codec(stream:NetStream, c:Camera, vcodec:Object):void { | 302 | private function __build_video_codec(stream:NetStream, c:Camera, vcodec:Object):void { |
| @@ -189,7 +189,7 @@ int SrsCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* sample) | @@ -189,7 +189,7 @@ int SrsCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* sample) | ||
| 189 | // only support aac | 189 | // only support aac |
| 190 | if (audio_codec_id != SrsCodecAudioAAC) { | 190 | if (audio_codec_id != SrsCodecAudioAAC) { |
| 191 | ret = ERROR_HLS_DECODE_ERROR; | 191 | ret = ERROR_HLS_DECODE_ERROR; |
| 192 | - srs_error("hls only support audio aac codec. ret=%d", ret); | 192 | + srs_error("hls only support audio aac codec. actual=%d, ret=%d", audio_codec_id, ret); |
| 193 | return ret; | 193 | return ret; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| @@ -299,7 +299,7 @@ int SrsCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* sample) | @@ -299,7 +299,7 @@ int SrsCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* sample) | ||
| 299 | // only support h.264/avc | 299 | // only support h.264/avc |
| 300 | if (codec_id != SrsCodecVideoAVC) { | 300 | if (codec_id != SrsCodecVideoAVC) { |
| 301 | ret = ERROR_HLS_DECODE_ERROR; | 301 | ret = ERROR_HLS_DECODE_ERROR; |
| 302 | - srs_error("hls only support video h.264/avc codec. ret=%d", ret); | 302 | + srs_error("hls only support video h.264/avc codec. actual=%d, ret=%d", codec_id, ret); |
| 303 | return ret; | 303 | return ret; |
| 304 | } | 304 | } |
| 305 | video_codec_id = codec_id; | 305 | video_codec_id = codec_id; |
| @@ -289,7 +289,7 @@ int SrsRtmpConn::stream_service_cycle() | @@ -289,7 +289,7 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | bool enabled_cache = _srs_config->get_gop_cache(req->vhost); | 291 | bool enabled_cache = _srs_config->get_gop_cache(req->vhost); |
| 292 | - srs_info("source found, url=%s, enabled_cache=%d", req->get_stream_url().c_str(), enabled_cache); | 292 | + srs_trace("source found, url=%s, enabled_cache=%d", req->get_stream_url().c_str(), enabled_cache); |
| 293 | source->set_cache(enabled_cache); | 293 | source->set_cache(enabled_cache); |
| 294 | 294 | ||
| 295 | switch (type) { | 295 | switch (type) { |
| @@ -418,7 +418,7 @@ SrsSource* SrsSource::find(SrsRequest* req) | @@ -418,7 +418,7 @@ SrsSource* SrsSource::find(SrsRequest* req) | ||
| 418 | 418 | ||
| 419 | if (pool.find(stream_url) == pool.end()) { | 419 | if (pool.find(stream_url) == pool.end()) { |
| 420 | pool[stream_url] = new SrsSource(req); | 420 | pool[stream_url] = new SrsSource(req); |
| 421 | - srs_verbose("create new source for url=%s, vhost=%s", stream_url.c_str(), vhost.c_str()); | 421 | + srs_info("create new source for url=%s, vhost=%s", stream_url.c_str(), vhost.c_str()); |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | return pool[stream_url]; | 424 | return pool[stream_url]; |
-
请 注册 或 登录 后发表评论