正在显示
2 个修改的文件
包含
134 行增加
和
133 行删除
| @@ -20,7 +20,7 @@ vhost __defaultVhost__ { | @@ -20,7 +20,7 @@ vhost __defaultVhost__ { | ||
| 20 | transcode { | 20 | transcode { |
| 21 | enabled on; | 21 | enabled on; |
| 22 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 22 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 23 | - engine ld{ | 23 | + engine ld { |
| 24 | enabled on; | 24 | enabled on; |
| 25 | vfilter { | 25 | vfilter { |
| 26 | vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | 26 | vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; |
| @@ -43,7 +43,7 @@ vhost __defaultVhost__ { | @@ -43,7 +43,7 @@ vhost __defaultVhost__ { | ||
| 43 | } | 43 | } |
| 44 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | 44 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 45 | } | 45 | } |
| 46 | - engine sd{ | 46 | + engine sd { |
| 47 | enabled on; | 47 | enabled on; |
| 48 | vfilter { | 48 | vfilter { |
| 49 | vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | 49 | vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; |
| @@ -76,11 +76,11 @@ vhost dev { | @@ -76,11 +76,11 @@ vhost dev { | ||
| 76 | hls_path ./objs/nginx/html; | 76 | hls_path ./objs/nginx/html; |
| 77 | hls_fragment 5; | 77 | hls_fragment 5; |
| 78 | hls_window 30; | 78 | hls_window 30; |
| 79 | - forward 127.0.0.1:19350?vhost=dev; | 79 | + forward 127.0.0.1:19350; |
| 80 | transcode { | 80 | transcode { |
| 81 | enabled on; | 81 | enabled on; |
| 82 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 82 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 83 | - engine dev{ | 83 | + engine dev { |
| 84 | enabled on; | 84 | enabled on; |
| 85 | vfilter { | 85 | vfilter { |
| 86 | } | 86 | } |
| @@ -109,7 +109,7 @@ vhost mirror.transcode.vhost.com { | @@ -109,7 +109,7 @@ vhost mirror.transcode.vhost.com { | ||
| 109 | transcode { | 109 | transcode { |
| 110 | enabled on; | 110 | enabled on; |
| 111 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 111 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 112 | - engine mirror{ | 112 | + engine mirror { |
| 113 | enabled on; | 113 | enabled on; |
| 114 | vfilter { | 114 | vfilter { |
| 115 | vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; | 115 | vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; |
| @@ -139,7 +139,7 @@ vhost drawtext.transcode.vhost.com { | @@ -139,7 +139,7 @@ vhost drawtext.transcode.vhost.com { | ||
| 139 | transcode { | 139 | transcode { |
| 140 | enabled on; | 140 | enabled on; |
| 141 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 141 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 142 | - engine drawtext{ | 142 | + engine drawtext { |
| 143 | enabled on; | 143 | enabled on; |
| 144 | vfilter { | 144 | vfilter { |
| 145 | vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; | 145 | vf 'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'; |
| @@ -169,7 +169,7 @@ vhost crop.transcode.vhost.com { | @@ -169,7 +169,7 @@ vhost crop.transcode.vhost.com { | ||
| 169 | transcode { | 169 | transcode { |
| 170 | enabled on; | 170 | enabled on; |
| 171 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 171 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 172 | - engine crop{ | 172 | + engine crop { |
| 173 | enabled on; | 173 | enabled on; |
| 174 | vfilter { | 174 | vfilter { |
| 175 | vf 'crop=in_w-20:in_h-160:10:80'; | 175 | vf 'crop=in_w-20:in_h-160:10:80'; |
| @@ -199,7 +199,7 @@ vhost logo.transcode.vhost.com { | @@ -199,7 +199,7 @@ vhost logo.transcode.vhost.com { | ||
| 199 | transcode { | 199 | transcode { |
| 200 | enabled on; | 200 | enabled on; |
| 201 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 201 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 202 | - engine logo{ | 202 | + engine logo { |
| 203 | enabled on; | 203 | enabled on; |
| 204 | vfilter { | 204 | vfilter { |
| 205 | vf 'crop=200:100:10:10'; | 205 | vf 'crop=200:100:10:10'; |
| @@ -237,7 +237,7 @@ vhost all.transcode.vhost.com { | @@ -237,7 +237,7 @@ vhost all.transcode.vhost.com { | ||
| 237 | # the transcode engine for matched stream. | 237 | # the transcode engine for matched stream. |
| 238 | # all matched stream will transcoded to the following stream. | 238 | # all matched stream will transcoded to the following stream. |
| 239 | # the transcode set name(ie. hd) is optional and not used. | 239 | # the transcode set name(ie. hd) is optional and not used. |
| 240 | - engine ffsuper{ | 240 | + engine ffsuper { |
| 241 | # whether the engine is enabled | 241 | # whether the engine is enabled |
| 242 | # default: off. | 242 | # default: off. |
| 243 | enabled on; | 243 | enabled on; |
| @@ -300,7 +300,7 @@ vhost all.transcode.vhost.com { | @@ -300,7 +300,7 @@ vhost all.transcode.vhost.com { | ||
| 300 | # [engine] the tanscode engine name. | 300 | # [engine] the tanscode engine name. |
| 301 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | 301 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 302 | } | 302 | } |
| 303 | - engine ffhd{ | 303 | + engine ffhd { |
| 304 | enabled on; | 304 | enabled on; |
| 305 | vcodec libx264; | 305 | vcodec libx264; |
| 306 | vbitrate 1200; | 306 | vbitrate 1200; |
| @@ -318,9 +318,9 @@ vhost all.transcode.vhost.com { | @@ -318,9 +318,9 @@ vhost all.transcode.vhost.com { | ||
| 318 | achannels 2; | 318 | achannels 2; |
| 319 | aparams { | 319 | aparams { |
| 320 | } | 320 | } |
| 321 | - output rtmp://[vhost]:[port]/[app]/[stream]_ffhd; | 321 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 322 | } | 322 | } |
| 323 | - engine ffsd{ | 323 | + engine ffsd { |
| 324 | enabled on; | 324 | enabled on; |
| 325 | vcodec libx264; | 325 | vcodec libx264; |
| 326 | vbitrate 800; | 326 | vbitrate 800; |
| @@ -338,9 +338,9 @@ vhost all.transcode.vhost.com { | @@ -338,9 +338,9 @@ vhost all.transcode.vhost.com { | ||
| 338 | achannels 2; | 338 | achannels 2; |
| 339 | aparams { | 339 | aparams { |
| 340 | } | 340 | } |
| 341 | - output rtmp://[vhost]:[port]/[app]/[stream]_ffsd; | 341 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 342 | } | 342 | } |
| 343 | - engine fffast{ | 343 | + engine fffast { |
| 344 | enabled on; | 344 | enabled on; |
| 345 | vcodec libx264; | 345 | vcodec libx264; |
| 346 | vbitrate 300; | 346 | vbitrate 300; |
| @@ -358,7 +358,7 @@ vhost all.transcode.vhost.com { | @@ -358,7 +358,7 @@ vhost all.transcode.vhost.com { | ||
| 358 | achannels 2; | 358 | achannels 2; |
| 359 | aparams { | 359 | aparams { |
| 360 | } | 360 | } |
| 361 | - output rtmp://[vhost]:[port]/[app]/[stream]_fffast; | 361 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 362 | } | 362 | } |
| 363 | } | 363 | } |
| 364 | } | 364 | } |
| @@ -367,7 +367,7 @@ vhost ffempty.transcode.vhost.com { | @@ -367,7 +367,7 @@ vhost ffempty.transcode.vhost.com { | ||
| 367 | transcode { | 367 | transcode { |
| 368 | enabled on; | 368 | enabled on; |
| 369 | ffmpeg ./research/ffempty/ffempty; | 369 | ffmpeg ./research/ffempty/ffempty; |
| 370 | - engine empty{ | 370 | + engine empty { |
| 371 | enabled on; | 371 | enabled on; |
| 372 | vcodec libx264; | 372 | vcodec libx264; |
| 373 | vbitrate 300; | 373 | vbitrate 300; |
| @@ -385,7 +385,7 @@ vhost ffempty.transcode.vhost.com { | @@ -385,7 +385,7 @@ vhost ffempty.transcode.vhost.com { | ||
| 385 | achannels 2; | 385 | achannels 2; |
| 386 | aparams { | 386 | aparams { |
| 387 | } | 387 | } |
| 388 | - output rtmp://[vhost]:[port]/[app]/[stream]_empty; | 388 | + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 389 | } | 389 | } |
| 390 | } | 390 | } |
| 391 | } | 391 | } |
| @@ -396,7 +396,7 @@ vhost app.transcode.vhost.com { | @@ -396,7 +396,7 @@ vhost app.transcode.vhost.com { | ||
| 396 | transcode live { | 396 | transcode live { |
| 397 | enabled on; | 397 | enabled on; |
| 398 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 398 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 399 | - engine fd{ | 399 | + engine { |
| 400 | enabled off; | 400 | enabled off; |
| 401 | } | 401 | } |
| 402 | } | 402 | } |
| @@ -408,13 +408,13 @@ vhost stream.transcode.vhost.com { | @@ -408,13 +408,13 @@ vhost stream.transcode.vhost.com { | ||
| 408 | transcode live/livestream { | 408 | transcode live/livestream { |
| 409 | enabled on; | 409 | enabled on; |
| 410 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 410 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| 411 | - engine fd{ | 411 | + engine { |
| 412 | enabled off; | 412 | enabled off; |
| 413 | } | 413 | } |
| 414 | } | 414 | } |
| 415 | } | 415 | } |
| 416 | # the vhost which forward publish streams. | 416 | # the vhost which forward publish streams. |
| 417 | -vhost forward.vhost.com { | 417 | +vhost same.vhost.forward.vhost.com { |
| 418 | # forward all publish stream to the specified server. | 418 | # forward all publish stream to the specified server. |
| 419 | # this used to split/forward the current stream for cluster active-standby, | 419 | # this used to split/forward the current stream for cluster active-standby, |
| 420 | # active-active for cdn to build high available fault tolerance system. | 420 | # active-active for cdn to build high available fault tolerance system. |
| @@ -425,7 +425,7 @@ vhost forward.vhost.com { | @@ -425,7 +425,7 @@ vhost forward.vhost.com { | ||
| 425 | forward 127.0.0.1:1936 127.0.0.1:1937; | 425 | forward 127.0.0.1:1936 127.0.0.1:1937; |
| 426 | } | 426 | } |
| 427 | # the vhost which forward publish streams to other vhosts. | 427 | # the vhost which forward publish streams to other vhosts. |
| 428 | -vhost forward1.vhost.com { | 428 | +vhost change.vhost.forward.vhost.com { |
| 429 | forward 127.0.0.1:1936?vhost=forward2.vhost.com 127.0.0.1:1937?vhost=forward3.vhost.com; | 429 | forward 127.0.0.1:1936?vhost=forward2.vhost.com 127.0.0.1:1937?vhost=forward3.vhost.com; |
| 430 | } | 430 | } |
| 431 | # the vhost disabled. | 431 | # the vhost disabled. |
trunk/src/core/srs_core.cpp
100644 → 100755
| 1 | -/* | ||
| 2 | -The MIT License (MIT) | ||
| 3 | - | ||
| 4 | -Copyright (c) 2013 winlin | ||
| 5 | - | ||
| 6 | -Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 7 | -this software and associated documentation files (the "Software"), to deal in | ||
| 8 | -the Software without restriction, including without limitation the rights to | ||
| 9 | -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 10 | -the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 11 | -subject to the following conditions: | ||
| 12 | - | ||
| 13 | -The above copyright notice and this permission notice shall be included in all | ||
| 14 | -copies or substantial portions of the Software. | ||
| 15 | - | ||
| 16 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 18 | -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 19 | -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 20 | -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | -*/ | ||
| 23 | - | ||
| 24 | -#include <srs_core.hpp> | ||
| 25 | - | ||
| 26 | -#include <sys/time.h> | ||
| 27 | -#include <netdb.h> | ||
| 28 | -#include <arpa/inet.h> | ||
| 29 | - | ||
| 30 | -#include <srs_core_log.hpp> | ||
| 31 | - | ||
| 32 | -static int64_t _srs_system_time_us_cache = 0; | ||
| 33 | - | ||
| 34 | -int64_t srs_get_system_time_ms() | ||
| 35 | -{ | ||
| 36 | - return _srs_system_time_us_cache / 1000; | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -void srs_update_system_time_ms() | ||
| 40 | -{ | ||
| 41 | - timeval now; | ||
| 42 | - | ||
| 43 | - gettimeofday(&now, NULL); | ||
| 44 | - | ||
| 45 | - // we must convert the tv_sec/tv_usec to int64_t. | ||
| 46 | - _srs_system_time_us_cache = now.tv_sec * 1000 * 1000 + now.tv_usec; | ||
| 47 | - | ||
| 48 | - _srs_system_time_us_cache = srs_max(0, _srs_system_time_us_cache); | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -std::string srs_replace(std::string str, std::string old_str, std::string new_str) | ||
| 52 | -{ | ||
| 53 | - std::string ret = str; | ||
| 54 | - | ||
| 55 | - if (old_str == new_str) { | ||
| 56 | - return ret; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - size_t pos = 0; | ||
| 60 | - while ((pos = ret.find(old_str, pos)) != std::string::npos) { | ||
| 61 | - ret = ret.replace(pos, old_str.length(), new_str); | ||
| 62 | - pos += new_str.length(); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - return ret; | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -std::string srs_dns_resolve(std::string host) | ||
| 69 | -{ | ||
| 70 | - if (inet_addr(host.c_str()) != INADDR_NONE) { | ||
| 71 | - return host; | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - hostent* answer = gethostbyname(host.c_str()); | ||
| 75 | - if (answer == NULL) { | ||
| 76 | - srs_error("dns resolve host %s error.", host.c_str()); | ||
| 77 | - return ""; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - char ipv4[16]; | ||
| 81 | - memset(ipv4, 0, sizeof(ipv4)); | ||
| 82 | - for (int i = 0; i < answer->h_length; i++) { | ||
| 83 | - inet_ntop(AF_INET, answer->h_addr_list[i], ipv4, sizeof(ipv4)); | ||
| 84 | - srs_info("dns resolve host %s to %s.", host.c_str(), ipv4); | ||
| 85 | - break; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - return ipv4; | ||
| 89 | -} | ||
| 90 | - | ||
| 91 | -void srs_vhost_resolve(std::string& vhost, std::string& app) | ||
| 92 | -{ | ||
| 93 | - app = srs_replace(app, "...", "?"); | ||
| 94 | - | ||
| 95 | - if ((pos = app.find("?")) == std::string::npos) { | ||
| 96 | - return; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - std::string query = app.substr(pos + 1); | ||
| 100 | - app = app.substr(0, pos); | ||
| 101 | - | ||
| 102 | - if ((pos = query.find("vhost?")) != std::string::npos | ||
| 103 | - || (pos = query.find("vhost=")) != std::string::npos | ||
| 104 | - || (pos = query.find("Vhost?")) != std::string::npos | ||
| 105 | - || (pos = query.find("Vhost=")) != std::string::npos | ||
| 106 | - ) { | ||
| 107 | - query = query.substr(pos + 6); | ||
| 108 | - if (!query.empty()) { | ||
| 109 | - vhost = query; | ||
| 110 | - } | ||
| 111 | - } | ||
| 112 | -} | 1 | +/* |
| 2 | +The MIT License (MIT) | ||
| 3 | + | ||
| 4 | +Copyright (c) 2013 winlin | ||
| 5 | + | ||
| 6 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 7 | +this software and associated documentation files (the "Software"), to deal in | ||
| 8 | +the Software without restriction, including without limitation the rights to | ||
| 9 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 10 | +the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 11 | +subject to the following conditions: | ||
| 12 | + | ||
| 13 | +The above copyright notice and this permission notice shall be included in all | ||
| 14 | +copies or substantial portions of the Software. | ||
| 15 | + | ||
| 16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 18 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 19 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 20 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | +*/ | ||
| 23 | + | ||
| 24 | +#include <srs_core.hpp> | ||
| 25 | + | ||
| 26 | +#include <sys/time.h> | ||
| 27 | +#include <netdb.h> | ||
| 28 | +#include <arpa/inet.h> | ||
| 29 | + | ||
| 30 | +#include <srs_core_log.hpp> | ||
| 31 | + | ||
| 32 | +static int64_t _srs_system_time_us_cache = 0; | ||
| 33 | + | ||
| 34 | +int64_t srs_get_system_time_ms() | ||
| 35 | +{ | ||
| 36 | + return _srs_system_time_us_cache / 1000; | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +void srs_update_system_time_ms() | ||
| 40 | +{ | ||
| 41 | + timeval now; | ||
| 42 | + | ||
| 43 | + gettimeofday(&now, NULL); | ||
| 44 | + | ||
| 45 | + // we must convert the tv_sec/tv_usec to int64_t. | ||
| 46 | + _srs_system_time_us_cache = now.tv_sec * 1000 * 1000 + now.tv_usec; | ||
| 47 | + | ||
| 48 | + _srs_system_time_us_cache = srs_max(0, _srs_system_time_us_cache); | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +std::string srs_replace(std::string str, std::string old_str, std::string new_str) | ||
| 52 | +{ | ||
| 53 | + std::string ret = str; | ||
| 54 | + | ||
| 55 | + if (old_str == new_str) { | ||
| 56 | + return ret; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + size_t pos = 0; | ||
| 60 | + while ((pos = ret.find(old_str, pos)) != std::string::npos) { | ||
| 61 | + ret = ret.replace(pos, old_str.length(), new_str); | ||
| 62 | + pos += new_str.length(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + return ret; | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +std::string srs_dns_resolve(std::string host) | ||
| 69 | +{ | ||
| 70 | + if (inet_addr(host.c_str()) != INADDR_NONE) { | ||
| 71 | + return host; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + hostent* answer = gethostbyname(host.c_str()); | ||
| 75 | + if (answer == NULL) { | ||
| 76 | + srs_error("dns resolve host %s error.", host.c_str()); | ||
| 77 | + return ""; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + char ipv4[16]; | ||
| 81 | + memset(ipv4, 0, sizeof(ipv4)); | ||
| 82 | + for (int i = 0; i < answer->h_length; i++) { | ||
| 83 | + inet_ntop(AF_INET, answer->h_addr_list[i], ipv4, sizeof(ipv4)); | ||
| 84 | + srs_info("dns resolve host %s to %s.", host.c_str(), ipv4); | ||
| 85 | + break; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return ipv4; | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +void srs_vhost_resolve(std::string& vhost, std::string& app) | ||
| 92 | +{ | ||
| 93 | + app = srs_replace(app, "...", "?"); | ||
| 94 | + | ||
| 95 | + size_t pos = 0; | ||
| 96 | + if ((pos = app.find("?")) == std::string::npos) { | ||
| 97 | + return; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + std::string query = app.substr(pos + 1); | ||
| 101 | + app = app.substr(0, pos); | ||
| 102 | + | ||
| 103 | + if ((pos = query.find("vhost?")) != std::string::npos | ||
| 104 | + || (pos = query.find("vhost=")) != std::string::npos | ||
| 105 | + || (pos = query.find("Vhost?")) != std::string::npos | ||
| 106 | + || (pos = query.find("Vhost=")) != std::string::npos | ||
| 107 | + ) { | ||
| 108 | + query = query.substr(pos + 6); | ||
| 109 | + if (!query.empty()) { | ||
| 110 | + vhost = query; | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | +} |
-
请 注册 或 登录 后发表评论