正在显示
30 个修改的文件
包含
461 行增加
和
234 行删除
此 diff 太大无法显示。
| @@ -31,9 +31,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,9 +31,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | 31 | ||
| 32 | #include <vector> | 32 | #include <vector> |
| 33 | #include <string> | 33 | #include <string> |
| 34 | +#include <map> | ||
| 34 | #include <sstream> | 35 | #include <sstream> |
| 35 | 36 | ||
| 36 | #include <srs_app_reload.hpp> | 37 | #include <srs_app_reload.hpp> |
| 38 | +#include <srs_app_async_call.hpp> | ||
| 39 | +#include <srs_app_thread.hpp> | ||
| 37 | 40 | ||
| 38 | class SrsRequest; | 41 | class SrsRequest; |
| 39 | class SrsFileWriter; | 42 | class SrsFileWriter; |
| @@ -41,10 +44,89 @@ class SrsAmf0Object; | @@ -41,10 +44,89 @@ class SrsAmf0Object; | ||
| 41 | class SrsAmf0StrictArray; | 44 | class SrsAmf0StrictArray; |
| 42 | class SrsAmf0Any; | 45 | class SrsAmf0Any; |
| 43 | 46 | ||
| 47 | +class SrsConfig; | ||
| 48 | +class SrsRequest; | ||
| 49 | +class SrsJsonArray; | ||
| 50 | +class SrsConfDirective; | ||
| 51 | + | ||
| 52 | + | ||
| 44 | namespace _srs_internal | 53 | namespace _srs_internal |
| 45 | { | 54 | { |
| 46 | - class SrsConfigBuffer; | ||
| 47 | -} | 55 | + /** |
| 56 | + * the buffer of config content. | ||
| 57 | + */ | ||
| 58 | + class SrsConfigBuffer | ||
| 59 | + { | ||
| 60 | + protected: | ||
| 61 | + // last available position. | ||
| 62 | + char* last; | ||
| 63 | + // end of buffer. | ||
| 64 | + char* end; | ||
| 65 | + // start of buffer. | ||
| 66 | + char* start; | ||
| 67 | + public: | ||
| 68 | + // current consumed position. | ||
| 69 | + char* pos; | ||
| 70 | + // current parsed line. | ||
| 71 | + int line; | ||
| 72 | + public: | ||
| 73 | + SrsConfigBuffer(); | ||
| 74 | + virtual ~SrsConfigBuffer(); | ||
| 75 | + public: | ||
| 76 | + /** | ||
| 77 | + * fullfill the buffer with content of file specified by filename. | ||
| 78 | + */ | ||
| 79 | + virtual int fullfill(const char* filename); | ||
| 80 | + /** | ||
| 81 | + * whether buffer is empty. | ||
| 82 | + */ | ||
| 83 | + virtual bool empty(); | ||
| 84 | + }; | ||
| 85 | +}; | ||
| 86 | + | ||
| 87 | +/** | ||
| 88 | + * deep compare directive. | ||
| 89 | + */ | ||
| 90 | +extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b); | ||
| 91 | +extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b, std::string except); | ||
| 92 | + | ||
| 93 | +/** | ||
| 94 | + * helper utilities, used for compare the consts values. | ||
| 95 | + */ | ||
| 96 | +extern bool srs_config_hls_is_on_error_ignore(std::string strategy); | ||
| 97 | +extern bool srs_config_hls_is_on_error_continue(std::string strategy); | ||
| 98 | +extern bool srs_config_ingest_is_file(std::string type); | ||
| 99 | +extern bool srs_config_ingest_is_stream(std::string type); | ||
| 100 | +extern bool srs_config_dvr_is_plan_segment(std::string plan); | ||
| 101 | +extern bool srs_config_dvr_is_plan_session(std::string plan); | ||
| 102 | +extern bool srs_config_dvr_is_plan_append(std::string plan); | ||
| 103 | +extern bool srs_stream_caster_is_udp(std::string caster); | ||
| 104 | +extern bool srs_stream_caster_is_rtsp(std::string caster); | ||
| 105 | +extern bool srs_stream_caster_is_flv(std::string caster); | ||
| 106 | +// whether the dvr_apply active the stream specified by req. | ||
| 107 | +extern bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req); | ||
| 108 | + | ||
| 109 | +/** | ||
| 110 | + * convert bool in str to on/off | ||
| 111 | + */ | ||
| 112 | +extern std::string srs_config_bool2switch(const std::string& sbool); | ||
| 113 | + | ||
| 114 | +/** | ||
| 115 | + * parse loaded vhost directives to compatible mode. | ||
| 116 | + * for exmaple, SRS1/2 use the follow refer style: | ||
| 117 | + * refer a.domain.com b.domain.com; | ||
| 118 | + * while SRS3 use the following: | ||
| 119 | + * refer { | ||
| 120 | + * enabled on; | ||
| 121 | + * all a.domain.com b.domain.com; | ||
| 122 | + * } | ||
| 123 | + * so we must transform the vhost directive anytime load the config. | ||
| 124 | + * @param root the root directive to transform, in and out parameter. | ||
| 125 | + */ | ||
| 126 | +extern int srs_config_transform_vhost(SrsConfDirective* root); | ||
| 127 | + | ||
| 128 | +// global config | ||
| 129 | +extern SrsConfig* _srs_config; | ||
| 48 | 130 | ||
| 49 | /** | 131 | /** |
| 50 | * the config directive. | 132 | * the config directive. |
| @@ -103,6 +185,13 @@ public: | @@ -103,6 +185,13 @@ public: | ||
| 103 | public: | 185 | public: |
| 104 | SrsConfDirective(); | 186 | SrsConfDirective(); |
| 105 | virtual ~SrsConfDirective(); | 187 | virtual ~SrsConfDirective(); |
| 188 | +public: | ||
| 189 | + /** | ||
| 190 | + * deep copy the directive, for SrsConfig to use it to support reload in upyun cluster, | ||
| 191 | + * for when reload the upyun dynamic config, the root will be changed, | ||
| 192 | + * so need to copy it to an old root directive, and use the copy result to do reload. | ||
| 193 | + */ | ||
| 194 | + virtual SrsConfDirective* copy(); | ||
| 106 | // args | 195 | // args |
| 107 | public: | 196 | public: |
| 108 | /** | 197 | /** |
| @@ -190,10 +279,6 @@ private: | @@ -190,10 +279,6 @@ private: | ||
| 190 | */ | 279 | */ |
| 191 | virtual int parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type); | 280 | virtual int parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type); |
| 192 | /** | 281 | /** |
| 193 | - * deep copy the directive. | ||
| 194 | - */ | ||
| 195 | - virtual SrsConfDirective* copy(); | ||
| 196 | - /** | ||
| 197 | * read a token from buffer. | 282 | * read a token from buffer. |
| 198 | * a token, is the directive args and a flag indicates whether has child-directives. | 283 | * a token, is the directive args and a flag indicates whether has child-directives. |
| 199 | * @param args, the output directive args, the first is the directive name, left is the args. | 284 | * @param args, the output directive args, the first is the directive name, left is the args. |
| @@ -1291,83 +1376,5 @@ public: | @@ -1291,83 +1376,5 @@ public: | ||
| 1291 | virtual SrsConfDirective* get_stats_disk_device(); | 1376 | virtual SrsConfDirective* get_stats_disk_device(); |
| 1292 | }; | 1377 | }; |
| 1293 | 1378 | ||
| 1294 | -namespace _srs_internal | ||
| 1295 | -{ | ||
| 1296 | - /** | ||
| 1297 | - * the buffer of config content. | ||
| 1298 | - */ | ||
| 1299 | - class SrsConfigBuffer | ||
| 1300 | - { | ||
| 1301 | - protected: | ||
| 1302 | - // last available position. | ||
| 1303 | - char* last; | ||
| 1304 | - // end of buffer. | ||
| 1305 | - char* end; | ||
| 1306 | - // start of buffer. | ||
| 1307 | - char* start; | ||
| 1308 | - public: | ||
| 1309 | - // current consumed position. | ||
| 1310 | - char* pos; | ||
| 1311 | - // current parsed line. | ||
| 1312 | - int line; | ||
| 1313 | - public: | ||
| 1314 | - SrsConfigBuffer(); | ||
| 1315 | - virtual ~SrsConfigBuffer(); | ||
| 1316 | - public: | ||
| 1317 | - /** | ||
| 1318 | - * fullfill the buffer with content of file specified by filename. | ||
| 1319 | - */ | ||
| 1320 | - virtual int fullfill(const char* filename); | ||
| 1321 | - /** | ||
| 1322 | - * whether buffer is empty. | ||
| 1323 | - */ | ||
| 1324 | - virtual bool empty(); | ||
| 1325 | - }; | ||
| 1326 | -}; | ||
| 1327 | - | ||
| 1328 | -/** | ||
| 1329 | -* deep compare directive. | ||
| 1330 | - */ | ||
| 1331 | -extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b); | ||
| 1332 | -extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b, std::string except); | ||
| 1333 | - | ||
| 1334 | -/** | ||
| 1335 | - * helper utilities, used for compare the consts values. | ||
| 1336 | - */ | ||
| 1337 | -extern bool srs_config_hls_is_on_error_ignore(std::string strategy); | ||
| 1338 | -extern bool srs_config_hls_is_on_error_continue(std::string strategy); | ||
| 1339 | -extern bool srs_config_ingest_is_file(std::string type); | ||
| 1340 | -extern bool srs_config_ingest_is_stream(std::string type); | ||
| 1341 | -extern bool srs_config_dvr_is_plan_segment(std::string plan); | ||
| 1342 | -extern bool srs_config_dvr_is_plan_session(std::string plan); | ||
| 1343 | -extern bool srs_config_dvr_is_plan_append(std::string plan); | ||
| 1344 | -extern bool srs_stream_caster_is_udp(std::string caster); | ||
| 1345 | -extern bool srs_stream_caster_is_rtsp(std::string caster); | ||
| 1346 | -extern bool srs_stream_caster_is_flv(std::string caster); | ||
| 1347 | -// whether the dvr_apply active the stream specified by req. | ||
| 1348 | -extern bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req); | ||
| 1349 | - | ||
| 1350 | -/** | ||
| 1351 | - * convert bool in str to on/off | ||
| 1352 | - */ | ||
| 1353 | -extern std::string srs_config_bool2switch(const std::string& sbool); | ||
| 1354 | - | ||
| 1355 | -/** | ||
| 1356 | - * parse loaded vhost directives to compatible mode. | ||
| 1357 | - * for exmaple, SRS1/2 use the follow refer style: | ||
| 1358 | - * refer a.domain.com b.domain.com; | ||
| 1359 | - * while SRS3 use the following: | ||
| 1360 | - * refer { | ||
| 1361 | - * enabled on; | ||
| 1362 | - * all a.domain.com b.domain.com; | ||
| 1363 | - * } | ||
| 1364 | - * so we must transform the vhost directive anytime load the config. | ||
| 1365 | - * @param root the root directive to transform, in and out parameter. | ||
| 1366 | - */ | ||
| 1367 | -extern int srs_config_transform_vhost(SrsConfDirective* root); | ||
| 1368 | - | ||
| 1369 | -// global config | ||
| 1370 | -extern SrsConfig* _srs_config; | ||
| 1371 | - | ||
| 1372 | #endif | 1379 | #endif |
| 1373 | 1380 |
| @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 26 | #include <srs_kernel_log.hpp> | 26 | #include <srs_kernel_log.hpp> |
| 27 | #include <srs_kernel_error.hpp> | 27 | #include <srs_kernel_error.hpp> |
| 28 | #include <srs_app_utility.hpp> | 28 | #include <srs_app_utility.hpp> |
| 29 | +#include <srs_kernel_utility.hpp> | ||
| 29 | 30 | ||
| 30 | IConnectionManager::IConnectionManager() | 31 | IConnectionManager::IConnectionManager() |
| 31 | { | 32 | { |
| @@ -42,7 +43,12 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) | @@ -42,7 +43,12 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) | ||
| 42 | stfd = c; | 43 | stfd = c; |
| 43 | disposed = false; | 44 | disposed = false; |
| 44 | expired = false; | 45 | expired = false; |
| 45 | - | 46 | + create_time = srs_get_system_time_ms(); |
| 47 | + | ||
| 48 | + skt = new SrsStSocket(c); | ||
| 49 | + kbps = new SrsKbps(); | ||
| 50 | + kbps->set_io(skt, skt); | ||
| 51 | + | ||
| 46 | // the client thread should reap itself, | 52 | // the client thread should reap itself, |
| 47 | // so we never use joinable. | 53 | // so we never use joinable. |
| 48 | // TODO: FIXME: maybe other thread need to stop it. | 54 | // TODO: FIXME: maybe other thread need to stop it. |
| @@ -53,10 +59,32 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) | @@ -53,10 +59,32 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) | ||
| 53 | SrsConnection::~SrsConnection() | 59 | SrsConnection::~SrsConnection() |
| 54 | { | 60 | { |
| 55 | dispose(); | 61 | dispose(); |
| 56 | - | 62 | + |
| 63 | + srs_freep(kbps); | ||
| 64 | + srs_freep(skt); | ||
| 57 | srs_freep(pthread); | 65 | srs_freep(pthread); |
| 58 | } | 66 | } |
| 59 | 67 | ||
| 68 | +void SrsConnection::resample() | ||
| 69 | +{ | ||
| 70 | + kbps->resample(); | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +int64_t SrsConnection::get_send_bytes_delta() | ||
| 74 | +{ | ||
| 75 | + return kbps->get_send_bytes_delta(); | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +int64_t SrsConnection::get_recv_bytes_delta() | ||
| 79 | +{ | ||
| 80 | + return kbps->get_recv_bytes_delta(); | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +void SrsConnection::cleanup() | ||
| 84 | +{ | ||
| 85 | + kbps->cleanup(); | ||
| 86 | +} | ||
| 87 | + | ||
| 60 | void SrsConnection::dispose() | 88 | void SrsConnection::dispose() |
| 61 | { | 89 | { |
| 62 | if (disposed) { | 90 | if (disposed) { |
| @@ -86,7 +114,7 @@ int SrsConnection::cycle() | @@ -86,7 +114,7 @@ int SrsConnection::cycle() | ||
| 86 | 114 | ||
| 87 | ip = srs_get_peer_ip(st_netfd_fileno(stfd)); | 115 | ip = srs_get_peer_ip(st_netfd_fileno(stfd)); |
| 88 | 116 | ||
| 89 | - ret = do_cycle(); | 117 | + int oret = ret = do_cycle(); |
| 90 | 118 | ||
| 91 | // if socket io error, set to closed. | 119 | // if socket io error, set to closed. |
| 92 | if (srs_is_client_gracefully_close(ret)) { | 120 | if (srs_is_client_gracefully_close(ret)) { |
| @@ -100,7 +128,7 @@ int SrsConnection::cycle() | @@ -100,7 +128,7 @@ int SrsConnection::cycle() | ||
| 100 | 128 | ||
| 101 | // client close peer. | 129 | // client close peer. |
| 102 | if (ret == ERROR_SOCKET_CLOSED) { | 130 | if (ret == ERROR_SOCKET_CLOSED) { |
| 103 | - srs_warn("client disconnect peer. ret=%d", ret); | 131 | + srs_warn("client disconnect peer. oret=%d, ret=%d", oret, ret); |
| 104 | } | 132 | } |
| 105 | 133 | ||
| 106 | return ERROR_SUCCESS; | 134 | return ERROR_SUCCESS; |
| @@ -93,9 +93,31 @@ protected: | @@ -93,9 +93,31 @@ protected: | ||
| 93 | * when expired, the connection must never be served and quit ASAP. | 93 | * when expired, the connection must never be served and quit ASAP. |
| 94 | */ | 94 | */ |
| 95 | bool expired; | 95 | bool expired; |
| 96 | + /** | ||
| 97 | + * the underlayer socket. | ||
| 98 | + */ | ||
| 99 | + SrsStSocket* skt; | ||
| 100 | + /** | ||
| 101 | + * connection total kbps. | ||
| 102 | + * not only the rtmp or http connection, all type of connection are | ||
| 103 | + * need to statistic the kbps of io. | ||
| 104 | + * the SrsStatistic will use it indirectly to statistic the bytes delta of current connection. | ||
| 105 | + */ | ||
| 106 | + SrsKbps* kbps; | ||
| 107 | + /** | ||
| 108 | + * the create time in milliseconds. | ||
| 109 | + * for current connection to log self create time and calculate the living time. | ||
| 110 | + */ | ||
| 111 | + int64_t create_time; | ||
| 96 | public: | 112 | public: |
| 97 | SrsConnection(IConnectionManager* cm, st_netfd_t c); | 113 | SrsConnection(IConnectionManager* cm, st_netfd_t c); |
| 98 | virtual ~SrsConnection(); | 114 | virtual ~SrsConnection(); |
| 115 | +// interface IKbpsDelta | ||
| 116 | +public: | ||
| 117 | + virtual void resample(); | ||
| 118 | + virtual int64_t get_send_bytes_delta(); | ||
| 119 | + virtual int64_t get_recv_bytes_delta(); | ||
| 120 | + virtual void cleanup(); | ||
| 99 | public: | 121 | public: |
| 100 | /** | 122 | /** |
| 101 | * to dipose the connection. | 123 | * to dipose the connection. |
| @@ -70,6 +70,7 @@ SrsEdgeIngester::SrsEdgeIngester() | @@ -70,6 +70,7 @@ SrsEdgeIngester::SrsEdgeIngester() | ||
| 70 | origin_index = 0; | 70 | origin_index = 0; |
| 71 | stream_id = 0; | 71 | stream_id = 0; |
| 72 | stfd = NULL; | 72 | stfd = NULL; |
| 73 | + curr_origin_server = ""; | ||
| 73 | pthread = new SrsReusableThread2("edge-igs", this, SRS_EDGE_INGESTER_SLEEP_US); | 74 | pthread = new SrsReusableThread2("edge-igs", this, SRS_EDGE_INGESTER_SLEEP_US); |
| 74 | } | 75 | } |
| 75 | 76 | ||
| @@ -118,6 +119,11 @@ void SrsEdgeIngester::stop() | @@ -118,6 +119,11 @@ void SrsEdgeIngester::stop() | ||
| 118 | _source->on_unpublish(); | 119 | _source->on_unpublish(); |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 122 | +string SrsEdgeIngester::get_curr_origin() | ||
| 123 | +{ | ||
| 124 | + return curr_origin_server; | ||
| 125 | +} | ||
| 126 | + | ||
| 121 | int SrsEdgeIngester::cycle() | 127 | int SrsEdgeIngester::cycle() |
| 122 | { | 128 | { |
| 123 | int ret = ERROR_SUCCESS; | 129 | int ret = ERROR_SUCCESS; |
| @@ -205,7 +211,7 @@ int SrsEdgeIngester::ingest() | @@ -205,7 +211,7 @@ int SrsEdgeIngester::ingest() | ||
| 205 | return ret; | 211 | return ret; |
| 206 | } | 212 | } |
| 207 | } | 213 | } |
| 208 | - | 214 | + |
| 209 | return ret; | 215 | return ret; |
| 210 | } | 216 | } |
| 211 | 217 | ||
| @@ -352,9 +358,9 @@ int SrsEdgeIngester::connect_server(string& ep_server, string& ep_port) | @@ -352,9 +358,9 @@ int SrsEdgeIngester::connect_server(string& ep_server, string& ep_port) | ||
| 352 | } | 358 | } |
| 353 | 359 | ||
| 354 | // select the origin. | 360 | // select the origin. |
| 355 | - std::string server = conf->args.at(origin_index % conf->args.size()); | 361 | + std::string server = curr_origin_server = conf->args.at(origin_index % conf->args.size()); |
| 356 | origin_index = (origin_index + 1) % conf->args.size(); | 362 | origin_index = (origin_index + 1) % conf->args.size(); |
| 357 | - | 363 | + |
| 358 | std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT; | 364 | std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT; |
| 359 | int port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT); | 365 | int port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT); |
| 360 | size_t pos = server.find(":"); | 366 | size_t pos = server.find(":"); |
| @@ -754,6 +760,11 @@ void SrsPlayEdge::on_all_client_stop() | @@ -754,6 +760,11 @@ void SrsPlayEdge::on_all_client_stop() | ||
| 754 | } | 760 | } |
| 755 | } | 761 | } |
| 756 | 762 | ||
| 763 | +string SrsPlayEdge::get_curr_origin() | ||
| 764 | +{ | ||
| 765 | + return ingester->get_curr_origin(); | ||
| 766 | +} | ||
| 767 | + | ||
| 757 | int SrsPlayEdge::on_ingest_play() | 768 | int SrsPlayEdge::on_ingest_play() |
| 758 | { | 769 | { |
| 759 | int ret = ERROR_SUCCESS; | 770 | int ret = ERROR_SUCCESS; |
| @@ -89,6 +89,8 @@ private: | @@ -89,6 +89,8 @@ private: | ||
| 89 | SrsKbps* kbps; | 89 | SrsKbps* kbps; |
| 90 | SrsRtmpClient* client; | 90 | SrsRtmpClient* client; |
| 91 | int origin_index; | 91 | int origin_index; |
| 92 | + // current origin server of current source. | ||
| 93 | + std::string curr_origin_server; | ||
| 92 | public: | 94 | public: |
| 93 | SrsEdgeIngester(); | 95 | SrsEdgeIngester(); |
| 94 | virtual ~SrsEdgeIngester(); | 96 | virtual ~SrsEdgeIngester(); |
| @@ -96,6 +98,7 @@ public: | @@ -96,6 +98,7 @@ public: | ||
| 96 | virtual int initialize(SrsSource* source, SrsPlayEdge* edge, SrsRequest* req); | 98 | virtual int initialize(SrsSource* source, SrsPlayEdge* edge, SrsRequest* req); |
| 97 | virtual int start(); | 99 | virtual int start(); |
| 98 | virtual void stop(); | 100 | virtual void stop(); |
| 101 | + virtual std::string get_curr_origin(); | ||
| 99 | // interface ISrsReusableThread2Handler | 102 | // interface ISrsReusableThread2Handler |
| 100 | public: | 103 | public: |
| 101 | virtual int cycle(); | 104 | virtual int cycle(); |
| @@ -182,6 +185,7 @@ public: | @@ -182,6 +185,7 @@ public: | ||
| 182 | * when all client stopped play, disconnect to origin. | 185 | * when all client stopped play, disconnect to origin. |
| 183 | */ | 186 | */ |
| 184 | virtual void on_all_client_stop(); | 187 | virtual void on_all_client_stop(); |
| 188 | + virtual std::string get_curr_origin(); | ||
| 185 | public: | 189 | public: |
| 186 | /** | 190 | /** |
| 187 | * when ingester start to play stream. | 191 | * when ingester start to play stream. |
| @@ -387,13 +387,13 @@ int SrsHlsMuxer::deviation() | @@ -387,13 +387,13 @@ int SrsHlsMuxer::deviation() | ||
| 387 | int SrsHlsMuxer::initialize(ISrsHlsHandler* h) | 387 | int SrsHlsMuxer::initialize(ISrsHlsHandler* h) |
| 388 | { | 388 | { |
| 389 | int ret = ERROR_SUCCESS; | 389 | int ret = ERROR_SUCCESS; |
| 390 | - | 390 | + |
| 391 | handler = h; | 391 | handler = h; |
| 392 | 392 | ||
| 393 | if ((ret = async->start()) != ERROR_SUCCESS) { | 393 | if ((ret = async->start()) != ERROR_SUCCESS) { |
| 394 | return ret; | 394 | return ret; |
| 395 | } | 395 | } |
| 396 | - | 396 | + |
| 397 | return ret; | 397 | return ret; |
| 398 | } | 398 | } |
| 399 | 399 | ||
| @@ -724,7 +724,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -724,7 +724,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 724 | // when too large, it maybe timestamp corrupt. | 724 | // when too large, it maybe timestamp corrupt. |
| 725 | if (current->duration * 1000 >= SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS && (int)current->duration <= max_td) { | 725 | if (current->duration * 1000 >= SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS && (int)current->duration <= max_td) { |
| 726 | segments.push_back(current); | 726 | segments.push_back(current); |
| 727 | - | 727 | + |
| 728 | // use async to call the http hooks, for it will cause thread switch. | 728 | // use async to call the http hooks, for it will cause thread switch. |
| 729 | if ((ret = async->execute(new SrsDvrAsyncCallOnHls( | 729 | if ((ret = async->execute(new SrsDvrAsyncCallOnHls( |
| 730 | _srs_context->get_id(), req, | 730 | _srs_context->get_id(), req, |
| @@ -733,12 +733,12 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -733,12 +733,12 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 733 | { | 733 | { |
| 734 | return ret; | 734 | return ret; |
| 735 | } | 735 | } |
| 736 | - | 736 | + |
| 737 | // use async to call the http hooks, for it will cause thread switch. | 737 | // use async to call the http hooks, for it will cause thread switch. |
| 738 | if ((ret = async->execute(new SrsDvrAsyncCallOnHlsNotify(_srs_context->get_id(), req, current->uri))) != ERROR_SUCCESS) { | 738 | if ((ret = async->execute(new SrsDvrAsyncCallOnHlsNotify(_srs_context->get_id(), req, current->uri))) != ERROR_SUCCESS) { |
| 739 | return ret; | 739 | return ret; |
| 740 | } | 740 | } |
| 741 | - | 741 | + |
| 742 | srs_info("%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64, | 742 | srs_info("%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64, |
| 743 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, | 743 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, |
| 744 | current->segment_start_dts); | 744 | current->segment_start_dts); |
| @@ -749,12 +749,12 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -749,12 +749,12 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 749 | srs_error("notify handler for update ts failed. ret=%d", ret); | 749 | srs_error("notify handler for update ts failed. ret=%d", ret); |
| 750 | return ret; | 750 | return ret; |
| 751 | } | 751 | } |
| 752 | - | 752 | + |
| 753 | // close the muxer of finished segment. | 753 | // close the muxer of finished segment. |
| 754 | srs_freep(current->muxer); | 754 | srs_freep(current->muxer); |
| 755 | std::string full_path = current->full_path; | 755 | std::string full_path = current->full_path; |
| 756 | current = NULL; | 756 | current = NULL; |
| 757 | - | 757 | + |
| 758 | // rename from tmp to real path | 758 | // rename from tmp to real path |
| 759 | std::string tmp_file = full_path + ".tmp"; | 759 | std::string tmp_file = full_path + ".tmp"; |
| 760 | if (should_write_file && rename(tmp_file.c_str(), full_path.c_str()) < 0) { | 760 | if (should_write_file && rename(tmp_file.c_str(), full_path.c_str()) < 0) { |
| @@ -766,11 +766,11 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -766,11 +766,11 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 766 | } else { | 766 | } else { |
| 767 | // reuse current segment index. | 767 | // reuse current segment index. |
| 768 | _sequence_no--; | 768 | _sequence_no--; |
| 769 | - | 769 | + |
| 770 | srs_trace("%s drop ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64"", | 770 | srs_trace("%s drop ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64"", |
| 771 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, | 771 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, |
| 772 | current->segment_start_dts); | 772 | current->segment_start_dts); |
| 773 | - | 773 | + |
| 774 | // rename from tmp to real path | 774 | // rename from tmp to real path |
| 775 | std::string tmp_file = current->full_path + ".tmp"; | 775 | std::string tmp_file = current->full_path + ".tmp"; |
| 776 | if (should_write_file) { | 776 | if (should_write_file) { |
| @@ -778,13 +778,13 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -778,13 +778,13 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 778 | srs_warn("ignore unlink path failed, file=%s.", tmp_file.c_str()); | 778 | srs_warn("ignore unlink path failed, file=%s.", tmp_file.c_str()); |
| 779 | } | 779 | } |
| 780 | } | 780 | } |
| 781 | - | 781 | + |
| 782 | srs_freep(current); | 782 | srs_freep(current); |
| 783 | } | 783 | } |
| 784 | - | 784 | + |
| 785 | // the segments to remove | 785 | // the segments to remove |
| 786 | std::vector<SrsHlsSegment*> segment_to_remove; | 786 | std::vector<SrsHlsSegment*> segment_to_remove; |
| 787 | - | 787 | + |
| 788 | // shrink the segments. | 788 | // shrink the segments. |
| 789 | double duration = 0; | 789 | double duration = 0; |
| 790 | int remove_index = -1; | 790 | int remove_index = -1; |
| @@ -802,7 +802,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -802,7 +802,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 802 | segments.erase(segments.begin()); | 802 | segments.erase(segments.begin()); |
| 803 | segment_to_remove.push_back(segment); | 803 | segment_to_remove.push_back(segment); |
| 804 | } | 804 | } |
| 805 | - | 805 | + |
| 806 | // refresh the m3u8, donot contains the removed ts | 806 | // refresh the m3u8, donot contains the removed ts |
| 807 | ret = refresh_m3u8(); | 807 | ret = refresh_m3u8(); |
| 808 | 808 | ||
| @@ -815,24 +815,24 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -815,24 +815,24 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 815 | srs_warn("cleanup unlink path failed, file=%s.", segment->full_path.c_str()); | 815 | srs_warn("cleanup unlink path failed, file=%s.", segment->full_path.c_str()); |
| 816 | } | 816 | } |
| 817 | } | 817 | } |
| 818 | - | 818 | + |
| 819 | if (should_write_cache) { | 819 | if (should_write_cache) { |
| 820 | if ((ret = handler->on_remove_ts(req, segment->uri)) != ERROR_SUCCESS) { | 820 | if ((ret = handler->on_remove_ts(req, segment->uri)) != ERROR_SUCCESS) { |
| 821 | srs_warn("remove the ts from ram hls failed. ret=%d", ret); | 821 | srs_warn("remove the ts from ram hls failed. ret=%d", ret); |
| 822 | return ret; | 822 | return ret; |
| 823 | } | 823 | } |
| 824 | } | 824 | } |
| 825 | - | 825 | + |
| 826 | srs_freep(segment); | 826 | srs_freep(segment); |
| 827 | } | 827 | } |
| 828 | segment_to_remove.clear(); | 828 | segment_to_remove.clear(); |
| 829 | - | 829 | + |
| 830 | // check ret of refresh m3u8 | 830 | // check ret of refresh m3u8 |
| 831 | if (ret != ERROR_SUCCESS) { | 831 | if (ret != ERROR_SUCCESS) { |
| 832 | srs_error("refresh m3u8 failed. ret=%d", ret); | 832 | srs_error("refresh m3u8 failed. ret=%d", ret); |
| 833 | return ret; | 833 | return ret; |
| 834 | } | 834 | } |
| 835 | - | 835 | + |
| 836 | return ret; | 836 | return ret; |
| 837 | } | 837 | } |
| 838 | 838 |
| @@ -44,6 +44,7 @@ SrsHttpClient::SrsHttpClient() | @@ -44,6 +44,7 @@ SrsHttpClient::SrsHttpClient() | ||
| 44 | skt = NULL; | 44 | skt = NULL; |
| 45 | parser = NULL; | 45 | parser = NULL; |
| 46 | timeout_us = 0; | 46 | timeout_us = 0; |
| 47 | + port = 0; | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | SrsHttpClient::~SrsHttpClient() | 50 | SrsHttpClient::~SrsHttpClient() |
| @@ -56,6 +57,11 @@ int SrsHttpClient::initialize(string h, int p, int64_t t_us) | @@ -56,6 +57,11 @@ int SrsHttpClient::initialize(string h, int p, int64_t t_us) | ||
| 56 | { | 57 | { |
| 57 | int ret = ERROR_SUCCESS; | 58 | int ret = ERROR_SUCCESS; |
| 58 | 59 | ||
| 60 | + // disconnect first when h:p changed. | ||
| 61 | + if ((!host.empty() && host != h) || (port != 0 && port != p)) { | ||
| 62 | + disconnect(); | ||
| 63 | + } | ||
| 64 | + | ||
| 59 | srs_freep(parser); | 65 | srs_freep(parser); |
| 60 | parser = new SrsHttpParser(); | 66 | parser = new SrsHttpParser(); |
| 61 | 67 |
| @@ -55,6 +55,9 @@ using namespace std; | @@ -55,6 +55,9 @@ using namespace std; | ||
| 55 | #include <srs_app_http_static.hpp> | 55 | #include <srs_app_http_static.hpp> |
| 56 | #include <srs_app_http_stream.hpp> | 56 | #include <srs_app_http_stream.hpp> |
| 57 | #include <srs_app_http_api.hpp> | 57 | #include <srs_app_http_api.hpp> |
| 58 | +#include <srs_protocol_json.hpp> | ||
| 59 | +#include <srs_app_http_hooks.hpp> | ||
| 60 | +#include <srs_rtmp_amf0.hpp> | ||
| 58 | 61 | ||
| 59 | #endif | 62 | #endif |
| 60 | 63 | ||
| @@ -1204,47 +1207,57 @@ int SrsHttpConn::do_cycle() | @@ -1204,47 +1207,57 @@ int SrsHttpConn::do_cycle() | ||
| 1204 | srs_error("http initialize http parser failed. ret=%d", ret); | 1207 | srs_error("http initialize http parser failed. ret=%d", ret); |
| 1205 | return ret; | 1208 | return ret; |
| 1206 | } | 1209 | } |
| 1207 | - | ||
| 1208 | - // underlayer socket | ||
| 1209 | - SrsStSocket skt(stfd); | ||
| 1210 | - | 1210 | + |
| 1211 | // set the recv timeout, for some clients never disconnect the connection. | 1211 | // set the recv timeout, for some clients never disconnect the connection. |
| 1212 | // @see https://github.com/simple-rtmp-server/srs/issues/398 | 1212 | // @see https://github.com/simple-rtmp-server/srs/issues/398 |
| 1213 | - skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US); | ||
| 1214 | - | 1213 | + skt->set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US); |
| 1214 | + | ||
| 1215 | + SrsRequest* last_req = NULL; | ||
| 1216 | + SrsAutoFree(SrsRequest, last_req); | ||
| 1217 | + | ||
| 1215 | // process http messages. | 1218 | // process http messages. |
| 1216 | while (!disposed) { | 1219 | while (!disposed) { |
| 1217 | ISrsHttpMessage* req = NULL; | 1220 | ISrsHttpMessage* req = NULL; |
| 1218 | - | 1221 | + |
| 1219 | // get a http message | 1222 | // get a http message |
| 1220 | - if ((ret = parser->parse_message(&skt, this, &req)) != ERROR_SUCCESS) { | ||
| 1221 | - return ret; | 1223 | + if ((ret = parser->parse_message(skt, this, &req)) != ERROR_SUCCESS) { |
| 1224 | + break; | ||
| 1222 | } | 1225 | } |
| 1223 | 1226 | ||
| 1224 | // if SUCCESS, always NOT-NULL. | 1227 | // if SUCCESS, always NOT-NULL. |
| 1225 | srs_assert(req); | 1228 | srs_assert(req); |
| 1226 | - | 1229 | + |
| 1227 | // always free it in this scope. | 1230 | // always free it in this scope. |
| 1228 | SrsAutoFree(ISrsHttpMessage, req); | 1231 | SrsAutoFree(ISrsHttpMessage, req); |
| 1229 | - | 1232 | + |
| 1233 | + // get the last request, for report the info of request on connection disconnect. | ||
| 1234 | + delete last_req; | ||
| 1235 | + SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(req); | ||
| 1236 | + last_req = hreq->to_request(hreq->host()); | ||
| 1237 | + | ||
| 1230 | // may should discard the body. | 1238 | // may should discard the body. |
| 1231 | if ((ret = on_got_http_message(req)) != ERROR_SUCCESS) { | 1239 | if ((ret = on_got_http_message(req)) != ERROR_SUCCESS) { |
| 1232 | - return ret; | 1240 | + break; |
| 1233 | } | 1241 | } |
| 1234 | - | 1242 | + |
| 1235 | // ok, handle http request. | 1243 | // ok, handle http request. |
| 1236 | - SrsHttpResponseWriter writer(&skt); | 1244 | + SrsHttpResponseWriter writer(skt); |
| 1237 | if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) { | 1245 | if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) { |
| 1238 | - return ret; | 1246 | + break; |
| 1239 | } | 1247 | } |
| 1240 | - | 1248 | + |
| 1241 | // donot keep alive, disconnect it. | 1249 | // donot keep alive, disconnect it. |
| 1242 | // @see https://github.com/simple-rtmp-server/srs/issues/399 | 1250 | // @see https://github.com/simple-rtmp-server/srs/issues/399 |
| 1243 | if (!req->is_keep_alive()) { | 1251 | if (!req->is_keep_alive()) { |
| 1244 | break; | 1252 | break; |
| 1245 | } | 1253 | } |
| 1246 | } | 1254 | } |
| 1247 | - | 1255 | + |
| 1256 | + int disc_ret = ERROR_SUCCESS; | ||
| 1257 | + if ((disc_ret = on_disconnect(last_req)) != ERROR_SUCCESS) { | ||
| 1258 | + srs_warn("connection on disconnect peer failed, but ignore this error. disc_ret=%d, ret=%d", disc_ret, ret); | ||
| 1259 | + } | ||
| 1260 | + | ||
| 1248 | return ret; | 1261 | return ret; |
| 1249 | } | 1262 | } |
| 1250 | 1263 | ||
| @@ -1266,6 +1279,13 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1266,6 +1279,13 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1266 | return ret; | 1279 | return ret; |
| 1267 | } | 1280 | } |
| 1268 | 1281 | ||
| 1282 | +int SrsHttpConn::on_disconnect(SrsRequest* req) | ||
| 1283 | +{ | ||
| 1284 | + int ret = ERROR_SUCCESS; | ||
| 1285 | + // TODO: implements it.s | ||
| 1286 | + return ret; | ||
| 1287 | +} | ||
| 1288 | + | ||
| 1269 | SrsResponseOnlyHttpConn::SrsResponseOnlyHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m) | 1289 | SrsResponseOnlyHttpConn::SrsResponseOnlyHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m) |
| 1270 | : SrsHttpConn(cm, fd, m) | 1290 | : SrsHttpConn(cm, fd, m) |
| 1271 | { | 1291 | { |
| @@ -406,6 +406,12 @@ protected: | @@ -406,6 +406,12 @@ protected: | ||
| 406 | virtual int on_got_http_message(ISrsHttpMessage* msg) = 0; | 406 | virtual int on_got_http_message(ISrsHttpMessage* msg) = 0; |
| 407 | private: | 407 | private: |
| 408 | virtual int process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); | 408 | virtual int process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); |
| 409 | + /** | ||
| 410 | + * when the connection disconnect, call this method. | ||
| 411 | + * e.g. log msg of connection and report to other system. | ||
| 412 | + * @param request: request which is converted by the last http message. | ||
| 413 | + */ | ||
| 414 | + virtual int on_disconnect(SrsRequest* req); | ||
| 409 | }; | 415 | }; |
| 410 | 416 | ||
| 411 | /** | 417 | /** |
| @@ -474,13 +474,13 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i | @@ -474,13 +474,13 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i | ||
| 474 | srs_error("res code error, ret=%d", ret); | 474 | srs_error("res code error, ret=%d", ret); |
| 475 | return ret; | 475 | return ret; |
| 476 | } | 476 | } |
| 477 | - | 477 | + |
| 478 | if ((res_code->to_integer()) != ERROR_SUCCESS) { | 478 | if ((res_code->to_integer()) != ERROR_SUCCESS) { |
| 479 | ret = ERROR_RESPONSE_CODE; | 479 | ret = ERROR_RESPONSE_CODE; |
| 480 | srs_error("res code error, ret=%d, code=%d", ret, code); | 480 | srs_error("res code error, ret=%d, code=%d", ret, code); |
| 481 | return ret; | 481 | return ret; |
| 482 | } | 482 | } |
| 483 | - | 483 | + |
| 484 | return ret; | 484 | return ret; |
| 485 | } | 485 | } |
| 486 | 486 |
| @@ -54,6 +54,7 @@ using namespace std; | @@ -54,6 +54,7 @@ using namespace std; | ||
| 54 | #include <srs_app_pithy_print.hpp> | 54 | #include <srs_app_pithy_print.hpp> |
| 55 | #include <srs_app_source.hpp> | 55 | #include <srs_app_source.hpp> |
| 56 | #include <srs_app_server.hpp> | 56 | #include <srs_app_server.hpp> |
| 57 | +#include <srs_app_statistic.hpp> | ||
| 57 | 58 | ||
| 58 | #endif | 59 | #endif |
| 59 | 60 | ||
| @@ -494,6 +495,13 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -494,6 +495,13 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 494 | SrsAutoFree(SrsPithyPrint, pprint); | 495 | SrsAutoFree(SrsPithyPrint, pprint); |
| 495 | 496 | ||
| 496 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); | 497 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); |
| 498 | + | ||
| 499 | + // update the statistic when source disconveried. | ||
| 500 | + SrsStatistic* stat = SrsStatistic::instance(); | ||
| 501 | + if ((ret = stat->on_client(_srs_context->get_id(), req, NULL, SrsRtmpConnPlay)) != ERROR_SUCCESS) { | ||
| 502 | + srs_error("stat client failed. ret=%d", ret); | ||
| 503 | + return ret; | ||
| 504 | + } | ||
| 497 | 505 | ||
| 498 | // the memory writer. | 506 | // the memory writer. |
| 499 | SrsStreamWriter writer(w); | 507 | SrsStreamWriter writer(w); |
| @@ -1132,7 +1140,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | @@ -1132,7 +1140,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | ||
| 1132 | if (ext.empty()) { | 1140 | if (ext.empty()) { |
| 1133 | return ret; | 1141 | return ret; |
| 1134 | } | 1142 | } |
| 1135 | - | 1143 | + |
| 1136 | // find the actually request vhost. | 1144 | // find the actually request vhost. |
| 1137 | SrsConfDirective* vhost = _srs_config->get_vhost(request->host()); | 1145 | SrsConfDirective* vhost = _srs_config->get_vhost(request->host()); |
| 1138 | if (!vhost || !_srs_config->get_vhost_enabled(vhost)) { | 1146 | if (!vhost || !_srs_config->get_vhost_enabled(vhost)) { |
| @@ -1179,7 +1187,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | @@ -1179,7 +1187,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | ||
| 1179 | return ret; | 1187 | return ret; |
| 1180 | } | 1188 | } |
| 1181 | } | 1189 | } |
| 1182 | - | 1190 | + |
| 1183 | // convert to concreate class. | 1191 | // convert to concreate class. |
| 1184 | SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(request); | 1192 | SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(request); |
| 1185 | srs_assert(hreq); | 1193 | srs_assert(hreq); |
trunk/src/app/srs_app_rtmp_conn.cpp
100755 → 100644
| @@ -53,6 +53,8 @@ using namespace std; | @@ -53,6 +53,8 @@ using namespace std; | ||
| 53 | #include <srs_kernel_utility.hpp> | 53 | #include <srs_kernel_utility.hpp> |
| 54 | #include <srs_app_security.hpp> | 54 | #include <srs_app_security.hpp> |
| 55 | #include <srs_app_statistic.hpp> | 55 | #include <srs_app_statistic.hpp> |
| 56 | +#include <srs_rtmp_utility.hpp> | ||
| 57 | +#include <srs_protocol_json.hpp> | ||
| 56 | 58 | ||
| 57 | // when stream is busy, for example, streaming is already | 59 | // when stream is busy, for example, streaming is already |
| 58 | // publishing, when a new client to request to publish, | 60 | // publishing, when a new client to request to publish, |
| @@ -89,13 +91,13 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c) | @@ -89,13 +91,13 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c) | ||
| 89 | kbps = new SrsKbps(); | 91 | kbps = new SrsKbps(); |
| 90 | kbps->set_io(skt, skt); | 92 | kbps->set_io(skt, skt); |
| 91 | wakable = NULL; | 93 | wakable = NULL; |
| 92 | - | 94 | + |
| 93 | mw_sleep = SRS_PERF_MW_SLEEP; | 95 | mw_sleep = SRS_PERF_MW_SLEEP; |
| 94 | mw_enabled = false; | 96 | mw_enabled = false; |
| 95 | realtime = SRS_PERF_MIN_LATENCY_ENABLED; | 97 | realtime = SRS_PERF_MIN_LATENCY_ENABLED; |
| 96 | send_min_interval = 0; | 98 | send_min_interval = 0; |
| 97 | tcp_nodelay = false; | 99 | tcp_nodelay = false; |
| 98 | - | 100 | + |
| 99 | _srs_config->subscribe(this); | 101 | _srs_config->subscribe(this); |
| 100 | } | 102 | } |
| 101 | 103 | ||
| @@ -208,8 +210,11 @@ int SrsRtmpConn::do_cycle() | @@ -208,8 +210,11 @@ int SrsRtmpConn::do_cycle() | ||
| 208 | } | 210 | } |
| 209 | 211 | ||
| 210 | ret = service_cycle(); | 212 | ret = service_cycle(); |
| 211 | - | ||
| 212 | - http_hooks_on_close(); | 213 | + |
| 214 | + int disc_ret = ERROR_SUCCESS; | ||
| 215 | + if ((disc_ret = on_disconnect()) != ERROR_SUCCESS) { | ||
| 216 | + srs_warn("connection on disconnect peer failed, but ignore this error. disc_ret=%d, ret=%d", disc_ret, ret); | ||
| 217 | + } | ||
| 213 | 218 | ||
| 214 | return ret; | 219 | return ret; |
| 215 | } | 220 | } |
| @@ -1308,6 +1313,17 @@ int SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client) | @@ -1308,6 +1313,17 @@ int SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client) | ||
| 1308 | return ret; | 1313 | return ret; |
| 1309 | } | 1314 | } |
| 1310 | 1315 | ||
| 1316 | +int SrsRtmpConn::on_disconnect() | ||
| 1317 | +{ | ||
| 1318 | + int ret = ERROR_SUCCESS; | ||
| 1319 | + | ||
| 1320 | + http_hooks_on_close(); | ||
| 1321 | + | ||
| 1322 | + // TODO: implements it. | ||
| 1323 | + | ||
| 1324 | + return ret; | ||
| 1325 | +} | ||
| 1326 | + | ||
| 1311 | int SrsRtmpConn::http_hooks_on_connect() | 1327 | int SrsRtmpConn::http_hooks_on_connect() |
| 1312 | { | 1328 | { |
| 1313 | int ret = ERROR_SUCCESS; | 1329 | int ret = ERROR_SUCCESS; |
trunk/src/app/srs_app_rtmp_conn.hpp
100755 → 100644
| @@ -134,6 +134,11 @@ private: | @@ -134,6 +134,11 @@ private: | ||
| 134 | virtual int check_edge_token_traverse_auth(); | 134 | virtual int check_edge_token_traverse_auth(); |
| 135 | virtual int connect_server(int origin_index, st_netfd_t* pstsock); | 135 | virtual int connect_server(int origin_index, st_netfd_t* pstsock); |
| 136 | virtual int do_token_traverse_auth(SrsRtmpClient* client); | 136 | virtual int do_token_traverse_auth(SrsRtmpClient* client); |
| 137 | + /** | ||
| 138 | + * when the connection disconnect, call this method. | ||
| 139 | + * e.g. log msg of connection and report to other system. | ||
| 140 | + */ | ||
| 141 | + virtual int on_disconnect(); | ||
| 137 | private: | 142 | private: |
| 138 | virtual int http_hooks_on_connect(); | 143 | virtual int http_hooks_on_connect(); |
| 139 | virtual void http_hooks_on_close(); | 144 | virtual void http_hooks_on_close(); |
trunk/src/app/srs_app_source.cpp
100755 → 100644
| @@ -2292,3 +2292,8 @@ void SrsSource::destroy_forwarders() | @@ -2292,3 +2292,8 @@ void SrsSource::destroy_forwarders() | ||
| 2292 | forwarders.clear(); | 2292 | forwarders.clear(); |
| 2293 | } | 2293 | } |
| 2294 | 2294 | ||
| 2295 | +string SrsSource::get_curr_origin() | ||
| 2296 | +{ | ||
| 2297 | + return play_edge->get_curr_origin(); | ||
| 2298 | +} | ||
| 2299 | + |
trunk/src/app/srs_app_source.hpp
100755 → 100644
| @@ -592,6 +592,8 @@ public: | @@ -592,6 +592,8 @@ public: | ||
| 592 | private: | 592 | private: |
| 593 | virtual int create_forwarders(); | 593 | virtual int create_forwarders(); |
| 594 | virtual void destroy_forwarders(); | 594 | virtual void destroy_forwarders(); |
| 595 | +public: | ||
| 596 | + virtual std::string get_curr_origin(); | ||
| 595 | }; | 597 | }; |
| 596 | 598 | ||
| 597 | #endif | 599 | #endif |
| @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 32 | 32 | ||
| 33 | #include <map> | 33 | #include <map> |
| 34 | #include <string> | 34 | #include <string> |
| 35 | +#include <vector> | ||
| 35 | 36 | ||
| 36 | #include <srs_kernel_codec.hpp> | 37 | #include <srs_kernel_codec.hpp> |
| 37 | #include <srs_rtmp_stack.hpp> | 38 | #include <srs_rtmp_stack.hpp> |
| @@ -435,6 +435,11 @@ void SrsReusableThread::stop() | @@ -435,6 +435,11 @@ void SrsReusableThread::stop() | ||
| 435 | pthread->stop(); | 435 | pthread->stop(); |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | +bool SrsReusableThread::can_loop() | ||
| 439 | +{ | ||
| 440 | + return pthread->can_loop(); | ||
| 441 | +} | ||
| 442 | + | ||
| 438 | int SrsReusableThread::cid() | 443 | int SrsReusableThread::cid() |
| 439 | { | 444 | { |
| 440 | return pthread->cid(); | 445 | return pthread->cid(); |
| @@ -340,6 +340,12 @@ public: | @@ -340,6 +340,12 @@ public: | ||
| 340 | * @remark user can stop multiple times, ignore if already stopped. | 340 | * @remark user can stop multiple times, ignore if already stopped. |
| 341 | */ | 341 | */ |
| 342 | virtual void stop(); | 342 | virtual void stop(); |
| 343 | + /** | ||
| 344 | + * whether the thread should loop, | ||
| 345 | + * used for handler->cycle() which has a loop method, | ||
| 346 | + * to check this method, break if false. | ||
| 347 | + */ | ||
| 348 | + virtual bool can_loop(); | ||
| 343 | public: | 349 | public: |
| 344 | /** | 350 | /** |
| 345 | * get the context id. @see: ISrsThreadContext.get_id(). | 351 | * get the context id. @see: ISrsThreadContext.get_id(). |
| @@ -1483,3 +1483,17 @@ void srs_api_dump_summaries(SrsAmf0Object* obj) | @@ -1483,3 +1483,17 @@ void srs_api_dump_summaries(SrsAmf0Object* obj) | ||
| 1483 | sys->set("conn_srs", SrsAmf0Any::number(nrs->nb_conn_srs)); | 1483 | sys->set("conn_srs", SrsAmf0Any::number(nrs->nb_conn_srs)); |
| 1484 | } | 1484 | } |
| 1485 | 1485 | ||
| 1486 | +string srs_join_vector_string(vector<string>& vs, string separator) | ||
| 1487 | +{ | ||
| 1488 | + string str = ""; | ||
| 1489 | + | ||
| 1490 | + for (int i = 0; i < (int)vs.size(); i++) { | ||
| 1491 | + str += vs.at(i); | ||
| 1492 | + if (i != (int)vs.size() - 1) { | ||
| 1493 | + str += separator; | ||
| 1494 | + } | ||
| 1495 | + } | ||
| 1496 | + | ||
| 1497 | + return str; | ||
| 1498 | +} | ||
| 1499 | + |
| @@ -684,5 +684,8 @@ extern bool srs_is_boolean(const std::string& str); | @@ -684,5 +684,8 @@ extern bool srs_is_boolean(const std::string& str); | ||
| 684 | // dump summaries for /api/v1/summaries. | 684 | // dump summaries for /api/v1/summaries. |
| 685 | extern void srs_api_dump_summaries(SrsAmf0Object* obj); | 685 | extern void srs_api_dump_summaries(SrsAmf0Object* obj); |
| 686 | 686 | ||
| 687 | +// join string in vector with indicated separator | ||
| 688 | +extern std::string srs_join_vector_string(std::vector<std::string>& vs, std::string separator); | ||
| 689 | + | ||
| 687 | #endif | 690 | #endif |
| 688 | 691 |
| @@ -42,6 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -42,6 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 42 | /////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////// |
| 43 | // default vhost of rtmp | 43 | // default vhost of rtmp |
| 44 | #define SRS_CONSTS_RTMP_DEFAULT_VHOST "__defaultVhost__" | 44 | #define SRS_CONSTS_RTMP_DEFAULT_VHOST "__defaultVhost__" |
| 45 | +#define SRS_CONSTS_RTMP_DEFAULT_APP "__defaultApp__" | ||
| 45 | // default port of rtmp | 46 | // default port of rtmp |
| 46 | #define SRS_CONSTS_RTMP_DEFAULT_PORT "1935" | 47 | #define SRS_CONSTS_RTMP_DEFAULT_PORT "1935" |
| 47 | 48 |
| @@ -198,6 +198,7 @@ ISrsTsHandler::~ISrsTsHandler() | @@ -198,6 +198,7 @@ ISrsTsHandler::~ISrsTsHandler() | ||
| 198 | SrsTsContext::SrsTsContext() | 198 | SrsTsContext::SrsTsContext() |
| 199 | { | 199 | { |
| 200 | pure_audio = false; | 200 | pure_audio = false; |
| 201 | + sync_byte = 0x47; // ts default sync byte. | ||
| 201 | vcodec = SrsCodecVideoReserved; | 202 | vcodec = SrsCodecVideoReserved; |
| 202 | acodec = SrsCodecAudioReserved1; | 203 | acodec = SrsCodecAudioReserved1; |
| 203 | } | 204 | } |
| @@ -368,6 +369,11 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo | @@ -368,6 +369,11 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo | ||
| 368 | } | 369 | } |
| 369 | } | 370 | } |
| 370 | 371 | ||
| 372 | +void SrsTsContext::set_sync_byte(int8_t sb) | ||
| 373 | +{ | ||
| 374 | + sync_byte = sb; | ||
| 375 | +} | ||
| 376 | + | ||
| 371 | int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as) | 377 | int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as) |
| 372 | { | 378 | { |
| 373 | int ret = ERROR_SUCCESS; | 379 | int ret = ERROR_SUCCESS; |
| @@ -384,6 +390,8 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea | @@ -384,6 +390,8 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea | ||
| 384 | SrsTsPacket* pkt = SrsTsPacket::create_pat(this, pmt_number, pmt_pid); | 390 | SrsTsPacket* pkt = SrsTsPacket::create_pat(this, pmt_number, pmt_pid); |
| 385 | SrsAutoFree(SrsTsPacket, pkt); | 391 | SrsAutoFree(SrsTsPacket, pkt); |
| 386 | 392 | ||
| 393 | + pkt->sync_byte = sync_byte; | ||
| 394 | + | ||
| 387 | char* buf = new char[SRS_TS_PACKET_SIZE]; | 395 | char* buf = new char[SRS_TS_PACKET_SIZE]; |
| 388 | SrsAutoFree(char, buf); | 396 | SrsAutoFree(char, buf); |
| 389 | 397 | ||
| @@ -409,6 +417,8 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea | @@ -409,6 +417,8 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea | ||
| 409 | SrsTsPacket* pkt = SrsTsPacket::create_pmt(this, pmt_number, pmt_pid, vpid, vs, apid, as); | 417 | SrsTsPacket* pkt = SrsTsPacket::create_pmt(this, pmt_number, pmt_pid, vpid, vs, apid, as); |
| 410 | SrsAutoFree(SrsTsPacket, pkt); | 418 | SrsAutoFree(SrsTsPacket, pkt); |
| 411 | 419 | ||
| 420 | + pkt->sync_byte = sync_byte; | ||
| 421 | + | ||
| 412 | char* buf = new char[SRS_TS_PACKET_SIZE]; | 422 | char* buf = new char[SRS_TS_PACKET_SIZE]; |
| 413 | SrsAutoFree(char, buf); | 423 | SrsAutoFree(char, buf); |
| 414 | 424 | ||
| @@ -479,6 +489,8 @@ int SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t p | @@ -479,6 +489,8 @@ int SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t p | ||
| 479 | } | 489 | } |
| 480 | SrsAutoFree(SrsTsPacket, pkt); | 490 | SrsAutoFree(SrsTsPacket, pkt); |
| 481 | 491 | ||
| 492 | + pkt->sync_byte = sync_byte; | ||
| 493 | + | ||
| 482 | char* buf = new char[SRS_TS_PACKET_SIZE]; | 494 | char* buf = new char[SRS_TS_PACKET_SIZE]; |
| 483 | SrsAutoFree(char, buf); | 495 | SrsAutoFree(char, buf); |
| 484 | 496 | ||
| @@ -2704,7 +2716,7 @@ int SrsTSMuxer::open(string p) | @@ -2704,7 +2716,7 @@ int SrsTSMuxer::open(string p) | ||
| 2704 | path = p; | 2716 | path = p; |
| 2705 | 2717 | ||
| 2706 | close(); | 2718 | close(); |
| 2707 | - | 2719 | + |
| 2708 | // reset the context for a new ts start. | 2720 | // reset the context for a new ts start. |
| 2709 | context->reset(); | 2721 | context->reset(); |
| 2710 | 2722 |
| @@ -345,6 +345,7 @@ class SrsTsContext | @@ -345,6 +345,7 @@ class SrsTsContext | ||
| 345 | private: | 345 | private: |
| 346 | std::map<int, SrsTsChannel*> pids; | 346 | std::map<int, SrsTsChannel*> pids; |
| 347 | bool pure_audio; | 347 | bool pure_audio; |
| 348 | + int8_t sync_byte; | ||
| 348 | // encoder | 349 | // encoder |
| 349 | private: | 350 | private: |
| 350 | // when any codec changed, write the PAT/PMT. | 351 | // when any codec changed, write the PAT/PMT. |
| @@ -394,6 +395,13 @@ public: | @@ -394,6 +395,13 @@ public: | ||
| 394 | * @param ac the audio codec, write the PAT/PMT table when changed. | 395 | * @param ac the audio codec, write the PAT/PMT table when changed. |
| 395 | */ | 396 | */ |
| 396 | virtual int encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo vc, SrsCodecAudio ac); | 397 | virtual int encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo vc, SrsCodecAudio ac); |
| 398 | +// drm methods | ||
| 399 | +public: | ||
| 400 | + /** | ||
| 401 | + * set sync byte of ts segment. | ||
| 402 | + * replace the standard ts sync byte to bravo sync byte. | ||
| 403 | + */ | ||
| 404 | + virtual void set_sync_byte(int8_t sb); | ||
| 397 | private: | 405 | private: |
| 398 | virtual int encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as); | 406 | virtual int encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as); |
| 399 | virtual int encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio); | 407 | virtual int encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio); |
| @@ -258,7 +258,7 @@ int main(int argc, char** argv) | @@ -258,7 +258,7 @@ int main(int argc, char** argv) | ||
| 258 | #ifdef SRS_AUTO_GPERF_MP | 258 | #ifdef SRS_AUTO_GPERF_MP |
| 259 | #warning "gmp is not used for memory leak, please use gmc instead." | 259 | #warning "gmp is not used for memory leak, please use gmc instead." |
| 260 | #endif | 260 | #endif |
| 261 | - | 261 | + |
| 262 | // never use srs log(srs_trace, srs_error, etc) before config parse the option, | 262 | // never use srs log(srs_trace, srs_error, etc) before config parse the option, |
| 263 | // which will load the log config and apply it. | 263 | // which will load the log config and apply it. |
| 264 | if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { | 264 | if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) { |
| @@ -274,7 +274,7 @@ int main(int argc, char** argv) | @@ -274,7 +274,7 @@ int main(int argc, char** argv) | ||
| 274 | if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) { | 274 | if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) { |
| 275 | return ret; | 275 | return ret; |
| 276 | } | 276 | } |
| 277 | - | 277 | + |
| 278 | srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION); | 278 | srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION); |
| 279 | srs_trace("license: "RTMP_SIG_SRS_LICENSE", "RTMP_SIG_SRS_COPYRIGHT); | 279 | srs_trace("license: "RTMP_SIG_SRS_LICENSE", "RTMP_SIG_SRS_COPYRIGHT); |
| 280 | srs_trace("primary/master: "RTMP_SIG_SRS_PRIMARY); | 280 | srs_trace("primary/master: "RTMP_SIG_SRS_PRIMARY); |
| @@ -288,11 +288,11 @@ int main(int argc, char** argv) | @@ -288,11 +288,11 @@ int main(int argc, char** argv) | ||
| 288 | srs_trace("arm tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN); | 288 | srs_trace("arm tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN); |
| 289 | #endif | 289 | #endif |
| 290 | srs_trace("conf: %s, limit: %d", _srs_config->config().c_str(), _srs_config->get_max_connections()); | 290 | srs_trace("conf: %s, limit: %d", _srs_config->config().c_str(), _srs_config->get_max_connections()); |
| 291 | - | 291 | + |
| 292 | // features | 292 | // features |
| 293 | check_macro_features(); | 293 | check_macro_features(); |
| 294 | show_macro_features(); | 294 | show_macro_features(); |
| 295 | - | 295 | + |
| 296 | /** | 296 | /** |
| 297 | * we do nothing in the constructor of server, | 297 | * we do nothing in the constructor of server, |
| 298 | * and use initialize to create members, set hooks for instance the reload handler, | 298 | * and use initialize to create members, set hooks for instance the reload handler, |
| @@ -357,7 +357,7 @@ int run_master() | @@ -357,7 +357,7 @@ int run_master() | ||
| 357 | if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) { | 357 | if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) { |
| 358 | return ret; | 358 | return ret; |
| 359 | } | 359 | } |
| 360 | - | 360 | + |
| 361 | if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) { | 361 | if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) { |
| 362 | return ret; | 362 | return ret; |
| 363 | } | 363 | } |
| @@ -487,6 +487,36 @@ SrsJsonAny* SrsJsonObject::ensure_property_boolean(string name) | @@ -487,6 +487,36 @@ SrsJsonAny* SrsJsonObject::ensure_property_boolean(string name) | ||
| 487 | return prop; | 487 | return prop; |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | +SrsJsonAny* SrsJsonObject::ensure_property_object(string name) | ||
| 491 | +{ | ||
| 492 | + SrsJsonAny* prop = get_property(name); | ||
| 493 | + | ||
| 494 | + if (!prop) { | ||
| 495 | + return NULL; | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + if (!prop->is_object()) { | ||
| 499 | + return NULL; | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + return prop; | ||
| 503 | +} | ||
| 504 | + | ||
| 505 | +SrsJsonAny* SrsJsonObject::ensure_property_array(string name) | ||
| 506 | +{ | ||
| 507 | + SrsJsonAny* prop = get_property(name); | ||
| 508 | + | ||
| 509 | + if (!prop) { | ||
| 510 | + return NULL; | ||
| 511 | + } | ||
| 512 | + | ||
| 513 | + if (!prop->is_array()) { | ||
| 514 | + return NULL; | ||
| 515 | + } | ||
| 516 | + | ||
| 517 | + return prop; | ||
| 518 | +} | ||
| 519 | + | ||
| 490 | SrsJsonArray::SrsJsonArray() | 520 | SrsJsonArray::SrsJsonArray() |
| 491 | { | 521 | { |
| 492 | marker = SRS_JSON_Array; | 522 | marker = SRS_JSON_Array; |
| @@ -151,6 +151,8 @@ public: | @@ -151,6 +151,8 @@ public: | ||
| 151 | virtual SrsJsonAny* ensure_property_string(std::string name); | 151 | virtual SrsJsonAny* ensure_property_string(std::string name); |
| 152 | virtual SrsJsonAny* ensure_property_integer(std::string name); | 152 | virtual SrsJsonAny* ensure_property_integer(std::string name); |
| 153 | virtual SrsJsonAny* ensure_property_boolean(std::string name); | 153 | virtual SrsJsonAny* ensure_property_boolean(std::string name); |
| 154 | + virtual SrsJsonAny* ensure_property_object(std::string name); | ||
| 155 | + virtual SrsJsonAny* ensure_property_array(std::string name); | ||
| 154 | }; | 156 | }; |
| 155 | 157 | ||
| 156 | class SrsJsonArray : public SrsJsonAny | 158 | class SrsJsonArray : public SrsJsonAny |
| @@ -67,8 +67,13 @@ void srs_discovery_tc_url( | @@ -67,8 +67,13 @@ void srs_discovery_tc_url( | ||
| 67 | host = host.substr(0, pos); | 67 | host = host.substr(0, pos); |
| 68 | srs_info("discovery host=%s, port=%s", host.c_str(), port.c_str()); | 68 | srs_info("discovery host=%s, port=%s", host.c_str(), port.c_str()); |
| 69 | } | 69 | } |
| 70 | - | ||
| 71 | - app = url; | 70 | + |
| 71 | + if (url.empty()) { | ||
| 72 | + app = SRS_CONSTS_RTMP_DEFAULT_APP; | ||
| 73 | + } else { | ||
| 74 | + app = url; | ||
| 75 | + } | ||
| 76 | + | ||
| 72 | vhost = host; | 77 | vhost = host; |
| 73 | srs_vhost_resolve(vhost, app, param); | 78 | srs_vhost_resolve(vhost, app, param); |
| 74 | } | 79 | } |
| @@ -230,7 +235,7 @@ std::string srs_generate_stream_url(std::string vhost, std::string app, std::str | @@ -230,7 +235,7 @@ std::string srs_generate_stream_url(std::string vhost, std::string app, std::str | ||
| 230 | std::string url = ""; | 235 | std::string url = ""; |
| 231 | 236 | ||
| 232 | if (SRS_CONSTS_RTMP_DEFAULT_VHOST != vhost){ | 237 | if (SRS_CONSTS_RTMP_DEFAULT_VHOST != vhost){ |
| 233 | - url += vhost; | 238 | + url += vhost; |
| 234 | } | 239 | } |
| 235 | url += "/"; | 240 | url += "/"; |
| 236 | url += app; | 241 | url += app; |
| @@ -292,7 +292,7 @@ MockSrsReloadConfig::~MockSrsReloadConfig() | @@ -292,7 +292,7 @@ MockSrsReloadConfig::~MockSrsReloadConfig() | ||
| 292 | { | 292 | { |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | -int MockSrsReloadConfig::reload(string buf) | 295 | +int MockSrsReloadConfig::do_reload(string buf) |
| 296 | { | 296 | { |
| 297 | int ret = ERROR_SUCCESS; | 297 | int ret = ERROR_SUCCESS; |
| 298 | 298 | ||
| @@ -301,7 +301,7 @@ int MockSrsReloadConfig::reload(string buf) | @@ -301,7 +301,7 @@ int MockSrsReloadConfig::reload(string buf) | ||
| 301 | return ret; | 301 | return ret; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | - return reload_conf(&conf); | 304 | + return MockSrsConfig::reload_conf(&conf); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | #ifdef ENABLE_UTEST_RELOAD | 307 | #ifdef ENABLE_UTEST_RELOAD |
| @@ -313,7 +313,7 @@ VOID TEST(ConfigReloadTest, ReloadEmpty) | @@ -313,7 +313,7 @@ VOID TEST(ConfigReloadTest, ReloadEmpty) | ||
| 313 | 313 | ||
| 314 | conf.subscribe(&handler); | 314 | conf.subscribe(&handler); |
| 315 | EXPECT_FALSE(ERROR_SUCCESS == conf.parse("")); | 315 | EXPECT_FALSE(ERROR_SUCCESS == conf.parse("")); |
| 316 | - EXPECT_FALSE(ERROR_SUCCESS == conf.reload("")); | 316 | + EXPECT_FALSE(ERROR_SUCCESS == conf.do_reload("")); |
| 317 | EXPECT_TRUE(handler.all_false()); | 317 | EXPECT_TRUE(handler.all_false()); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| @@ -324,35 +324,35 @@ VOID TEST(ConfigReloadTest, ReloadListen) | @@ -324,35 +324,35 @@ VOID TEST(ConfigReloadTest, ReloadListen) | ||
| 324 | 324 | ||
| 325 | conf.subscribe(&handler); | 325 | conf.subscribe(&handler); |
| 326 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935;")); | 326 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935;")); |
| 327 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;")); | 327 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); |
| 328 | EXPECT_TRUE(handler.all_false()); | 328 | EXPECT_TRUE(handler.all_false()); |
| 329 | handler.reset(); | 329 | handler.reset(); |
| 330 | 330 | ||
| 331 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936;")); | 331 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936;")); |
| 332 | EXPECT_TRUE(handler.listen_reloaded); | 332 | EXPECT_TRUE(handler.listen_reloaded); |
| 333 | EXPECT_EQ(1, handler.count_true()); | 333 | EXPECT_EQ(1, handler.count_true()); |
| 334 | handler.reset(); | 334 | handler.reset(); |
| 335 | 335 | ||
| 336 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936;")); | 336 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936;")); |
| 337 | EXPECT_TRUE(handler.all_false()); | 337 | EXPECT_TRUE(handler.all_false()); |
| 338 | handler.reset(); | 338 | handler.reset(); |
| 339 | 339 | ||
| 340 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936 1935;")); | 340 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936 1935;")); |
| 341 | EXPECT_TRUE(handler.listen_reloaded); | 341 | EXPECT_TRUE(handler.listen_reloaded); |
| 342 | EXPECT_EQ(1, handler.count_true()); | 342 | EXPECT_EQ(1, handler.count_true()); |
| 343 | handler.reset(); | 343 | handler.reset(); |
| 344 | 344 | ||
| 345 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;")); | 345 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); |
| 346 | EXPECT_TRUE(handler.listen_reloaded); | 346 | EXPECT_TRUE(handler.listen_reloaded); |
| 347 | EXPECT_EQ(1, handler.count_true()); | 347 | EXPECT_EQ(1, handler.count_true()); |
| 348 | handler.reset(); | 348 | handler.reset(); |
| 349 | 349 | ||
| 350 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935 1935;")); | 350 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935 1935;")); |
| 351 | EXPECT_TRUE(handler.listen_reloaded); | 351 | EXPECT_TRUE(handler.listen_reloaded); |
| 352 | EXPECT_EQ(1, handler.count_true()); | 352 | EXPECT_EQ(1, handler.count_true()); |
| 353 | handler.reset(); | 353 | handler.reset(); |
| 354 | 354 | ||
| 355 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;")); | 355 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); |
| 356 | EXPECT_TRUE(handler.listen_reloaded); | 356 | EXPECT_TRUE(handler.listen_reloaded); |
| 357 | EXPECT_EQ(1, handler.count_true()); | 357 | EXPECT_EQ(1, handler.count_true()); |
| 358 | handler.reset(); | 358 | handler.reset(); |
| @@ -365,16 +365,16 @@ VOID TEST(ConfigReloadTest, ReloadPid) | @@ -365,16 +365,16 @@ VOID TEST(ConfigReloadTest, ReloadPid) | ||
| 365 | 365 | ||
| 366 | conf.subscribe(&handler); | 366 | conf.subscribe(&handler); |
| 367 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pid srs.pid;")); | 367 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pid srs.pid;")); |
| 368 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs.pid;")); | 368 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pid srs.pid;")); |
| 369 | EXPECT_TRUE(handler.all_false()); | 369 | EXPECT_TRUE(handler.all_false()); |
| 370 | handler.reset(); | 370 | handler.reset(); |
| 371 | 371 | ||
| 372 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs1.pid;")); | 372 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pid srs1.pid;")); |
| 373 | EXPECT_TRUE(handler.pid_reloaded); | 373 | EXPECT_TRUE(handler.pid_reloaded); |
| 374 | EXPECT_EQ(1, handler.count_true()); | 374 | EXPECT_EQ(1, handler.count_true()); |
| 375 | handler.reset(); | 375 | handler.reset(); |
| 376 | 376 | ||
| 377 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs.pid;")); | 377 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pid srs.pid;")); |
| 378 | EXPECT_EQ(1, handler.count_true()); | 378 | EXPECT_EQ(1, handler.count_true()); |
| 379 | handler.reset(); | 379 | handler.reset(); |
| 380 | } | 380 | } |
| @@ -386,16 +386,16 @@ VOID TEST(ConfigReloadTest, ReloadLogTank) | @@ -386,16 +386,16 @@ VOID TEST(ConfigReloadTest, ReloadLogTank) | ||
| 386 | 386 | ||
| 387 | conf.subscribe(&handler); | 387 | conf.subscribe(&handler); |
| 388 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_tank console;")); | 388 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_tank console;")); |
| 389 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank console;")); | 389 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_tank console;")); |
| 390 | EXPECT_TRUE(handler.all_false()); | 390 | EXPECT_TRUE(handler.all_false()); |
| 391 | handler.reset(); | 391 | handler.reset(); |
| 392 | 392 | ||
| 393 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank file;")); | 393 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_tank file;")); |
| 394 | EXPECT_TRUE(handler.log_tank_reloaded); | 394 | EXPECT_TRUE(handler.log_tank_reloaded); |
| 395 | EXPECT_EQ(1, handler.count_true()); | 395 | EXPECT_EQ(1, handler.count_true()); |
| 396 | handler.reset(); | 396 | handler.reset(); |
| 397 | 397 | ||
| 398 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank console;")); | 398 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_tank console;")); |
| 399 | EXPECT_EQ(1, handler.count_true()); | 399 | EXPECT_EQ(1, handler.count_true()); |
| 400 | handler.reset(); | 400 | handler.reset(); |
| 401 | } | 401 | } |
| @@ -407,16 +407,16 @@ VOID TEST(ConfigReloadTest, ReloadLogLevel) | @@ -407,16 +407,16 @@ VOID TEST(ConfigReloadTest, ReloadLogLevel) | ||
| 407 | 407 | ||
| 408 | conf.subscribe(&handler); | 408 | conf.subscribe(&handler); |
| 409 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_level trace;")); | 409 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_level trace;")); |
| 410 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level trace;")); | 410 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_level trace;")); |
| 411 | EXPECT_TRUE(handler.all_false()); | 411 | EXPECT_TRUE(handler.all_false()); |
| 412 | handler.reset(); | 412 | handler.reset(); |
| 413 | 413 | ||
| 414 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level warn;")); | 414 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_level warn;")); |
| 415 | EXPECT_TRUE(handler.log_level_reloaded); | 415 | EXPECT_TRUE(handler.log_level_reloaded); |
| 416 | EXPECT_EQ(1, handler.count_true()); | 416 | EXPECT_EQ(1, handler.count_true()); |
| 417 | handler.reset(); | 417 | handler.reset(); |
| 418 | 418 | ||
| 419 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level trace;")); | 419 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_level trace;")); |
| 420 | EXPECT_EQ(1, handler.count_true()); | 420 | EXPECT_EQ(1, handler.count_true()); |
| 421 | handler.reset(); | 421 | handler.reset(); |
| 422 | } | 422 | } |
| @@ -428,16 +428,16 @@ VOID TEST(ConfigReloadTest, ReloadLogFile) | @@ -428,16 +428,16 @@ VOID TEST(ConfigReloadTest, ReloadLogFile) | ||
| 428 | 428 | ||
| 429 | conf.subscribe(&handler); | 429 | conf.subscribe(&handler); |
| 430 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_file srs.log;")); | 430 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_file srs.log;")); |
| 431 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs.log;")); | 431 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_file srs.log;")); |
| 432 | EXPECT_TRUE(handler.all_false()); | 432 | EXPECT_TRUE(handler.all_false()); |
| 433 | handler.reset(); | 433 | handler.reset(); |
| 434 | 434 | ||
| 435 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs1.log;")); | 435 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_file srs1.log;")); |
| 436 | EXPECT_TRUE(handler.log_file_reloaded); | 436 | EXPECT_TRUE(handler.log_file_reloaded); |
| 437 | EXPECT_EQ(1, handler.count_true()); | 437 | EXPECT_EQ(1, handler.count_true()); |
| 438 | handler.reset(); | 438 | handler.reset(); |
| 439 | 439 | ||
| 440 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs.log;")); | 440 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"srs_log_file srs.log;")); |
| 441 | EXPECT_EQ(1, handler.count_true()); | 441 | EXPECT_EQ(1, handler.count_true()); |
| 442 | handler.reset(); | 442 | handler.reset(); |
| 443 | } | 443 | } |
| @@ -449,16 +449,16 @@ VOID TEST(ConfigReloadTest, ReloadPithyPrint) | @@ -449,16 +449,16 @@ VOID TEST(ConfigReloadTest, ReloadPithyPrint) | ||
| 449 | 449 | ||
| 450 | conf.subscribe(&handler); | 450 | conf.subscribe(&handler); |
| 451 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pithy_print_ms 1000;")); | 451 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pithy_print_ms 1000;")); |
| 452 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print_ms 1000;")); | 452 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pithy_print_ms 1000;")); |
| 453 | EXPECT_TRUE(handler.all_false()); | 453 | EXPECT_TRUE(handler.all_false()); |
| 454 | handler.reset(); | 454 | handler.reset(); |
| 455 | 455 | ||
| 456 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print_ms 2000;")); | 456 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pithy_print_ms 2000;")); |
| 457 | EXPECT_TRUE(handler.pithy_print_reloaded); | 457 | EXPECT_TRUE(handler.pithy_print_reloaded); |
| 458 | EXPECT_EQ(1, handler.count_true()); | 458 | EXPECT_EQ(1, handler.count_true()); |
| 459 | handler.reset(); | 459 | handler.reset(); |
| 460 | 460 | ||
| 461 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print_ms 1000;")); | 461 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"pithy_print_ms 1000;")); |
| 462 | EXPECT_EQ(1, handler.count_true()); | 462 | EXPECT_EQ(1, handler.count_true()); |
| 463 | handler.reset(); | 463 | handler.reset(); |
| 464 | } | 464 | } |
| @@ -470,16 +470,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpApiEnabled) | @@ -470,16 +470,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpApiEnabled) | ||
| 470 | 470 | ||
| 471 | conf.subscribe(&handler); | 471 | conf.subscribe(&handler); |
| 472 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled off;}")); | 472 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled off;}")); |
| 473 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}")); | 473 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled off;}")); |
| 474 | EXPECT_TRUE(handler.all_false()); | 474 | EXPECT_TRUE(handler.all_false()); |
| 475 | handler.reset(); | 475 | handler.reset(); |
| 476 | 476 | ||
| 477 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}")); | 477 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled on;}")); |
| 478 | EXPECT_TRUE(handler.http_api_enabled_reloaded); | 478 | EXPECT_TRUE(handler.http_api_enabled_reloaded); |
| 479 | EXPECT_EQ(1, handler.count_true()); | 479 | EXPECT_EQ(1, handler.count_true()); |
| 480 | handler.reset(); | 480 | handler.reset(); |
| 481 | 481 | ||
| 482 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}")); | 482 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled off;}")); |
| 483 | EXPECT_EQ(1, handler.count_true()); | 483 | EXPECT_EQ(1, handler.count_true()); |
| 484 | handler.reset(); | 484 | handler.reset(); |
| 485 | } | 485 | } |
| @@ -491,16 +491,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpApiDisabled) | @@ -491,16 +491,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpApiDisabled) | ||
| 491 | 491 | ||
| 492 | conf.subscribe(&handler); | 492 | conf.subscribe(&handler); |
| 493 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled on;}")); | 493 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled on;}")); |
| 494 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}")); | 494 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled on;}")); |
| 495 | EXPECT_TRUE(handler.all_false()); | 495 | EXPECT_TRUE(handler.all_false()); |
| 496 | handler.reset(); | 496 | handler.reset(); |
| 497 | 497 | ||
| 498 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}")); | 498 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled off;}")); |
| 499 | EXPECT_TRUE(handler.http_api_disabled_reloaded); | 499 | EXPECT_TRUE(handler.http_api_disabled_reloaded); |
| 500 | EXPECT_EQ(1, handler.count_true()); | 500 | EXPECT_EQ(1, handler.count_true()); |
| 501 | handler.reset(); | 501 | handler.reset(); |
| 502 | 502 | ||
| 503 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}")); | 503 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_api {enabled on;}")); |
| 504 | EXPECT_EQ(1, handler.count_true()); | 504 | EXPECT_EQ(1, handler.count_true()); |
| 505 | handler.reset(); | 505 | handler.reset(); |
| 506 | } | 506 | } |
| @@ -512,16 +512,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamEnabled) | @@ -512,16 +512,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamEnabled) | ||
| 512 | 512 | ||
| 513 | conf.subscribe(&handler); | 513 | conf.subscribe(&handler); |
| 514 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled off;}")); | 514 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled off;}")); |
| 515 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}")); | 515 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); |
| 516 | EXPECT_TRUE(handler.all_false()); | 516 | EXPECT_TRUE(handler.all_false()); |
| 517 | handler.reset(); | 517 | handler.reset(); |
| 518 | 518 | ||
| 519 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}")); | 519 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); |
| 520 | EXPECT_TRUE(handler.http_stream_enabled_reloaded); | 520 | EXPECT_TRUE(handler.http_stream_enabled_reloaded); |
| 521 | EXPECT_EQ(1, handler.count_true()); | 521 | EXPECT_EQ(1, handler.count_true()); |
| 522 | handler.reset(); | 522 | handler.reset(); |
| 523 | 523 | ||
| 524 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}")); | 524 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); |
| 525 | EXPECT_EQ(1, handler.count_true()); | 525 | EXPECT_EQ(1, handler.count_true()); |
| 526 | handler.reset(); | 526 | handler.reset(); |
| 527 | } | 527 | } |
| @@ -533,16 +533,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamDisabled) | @@ -533,16 +533,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamDisabled) | ||
| 533 | 533 | ||
| 534 | conf.subscribe(&handler); | 534 | conf.subscribe(&handler); |
| 535 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on;}")); | 535 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on;}")); |
| 536 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}")); | 536 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); |
| 537 | EXPECT_TRUE(handler.all_false()); | 537 | EXPECT_TRUE(handler.all_false()); |
| 538 | handler.reset(); | 538 | handler.reset(); |
| 539 | 539 | ||
| 540 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}")); | 540 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); |
| 541 | EXPECT_TRUE(handler.http_stream_disabled_reloaded); | 541 | EXPECT_TRUE(handler.http_stream_disabled_reloaded); |
| 542 | EXPECT_EQ(1, handler.count_true()); | 542 | EXPECT_EQ(1, handler.count_true()); |
| 543 | handler.reset(); | 543 | handler.reset(); |
| 544 | 544 | ||
| 545 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}")); | 545 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); |
| 546 | EXPECT_EQ(1, handler.count_true()); | 546 | EXPECT_EQ(1, handler.count_true()); |
| 547 | handler.reset(); | 547 | handler.reset(); |
| 548 | } | 548 | } |
| @@ -554,16 +554,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamUpdated) | @@ -554,16 +554,16 @@ VOID TEST(ConfigReloadTest, ReloadHttpStreamUpdated) | ||
| 554 | 554 | ||
| 555 | conf.subscribe(&handler); | 555 | conf.subscribe(&handler); |
| 556 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); | 556 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); |
| 557 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); | 557 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); |
| 558 | EXPECT_TRUE(handler.all_false()); | 558 | EXPECT_TRUE(handler.all_false()); |
| 559 | handler.reset(); | 559 | handler.reset(); |
| 560 | 560 | ||
| 561 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8000;}")); | 561 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8000;}")); |
| 562 | EXPECT_TRUE(handler.http_stream_updated_reloaded); | 562 | EXPECT_TRUE(handler.http_stream_updated_reloaded); |
| 563 | EXPECT_EQ(1, handler.count_true()); | 563 | EXPECT_EQ(1, handler.count_true()); |
| 564 | handler.reset(); | 564 | handler.reset(); |
| 565 | 565 | ||
| 566 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); | 566 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); |
| 567 | EXPECT_EQ(1, handler.count_true()); | 567 | EXPECT_EQ(1, handler.count_true()); |
| 568 | handler.reset(); | 568 | handler.reset(); |
| 569 | } | 569 | } |
| @@ -575,16 +575,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostHttpUpdated) | @@ -575,16 +575,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostHttpUpdated) | ||
| 575 | 575 | ||
| 576 | conf.subscribe(&handler); | 576 | conf.subscribe(&handler); |
| 577 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); | 577 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); |
| 578 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); | 578 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); |
| 579 | EXPECT_TRUE(handler.all_false()); | 579 | EXPECT_TRUE(handler.all_false()); |
| 580 | handler.reset(); | 580 | handler.reset(); |
| 581 | 581 | ||
| 582 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls1;}}")); | 582 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls1;}}")); |
| 583 | EXPECT_TRUE(handler.vhost_http_updated_reloaded); | 583 | EXPECT_TRUE(handler.vhost_http_updated_reloaded); |
| 584 | EXPECT_EQ(1, handler.count_true()); | 584 | EXPECT_EQ(1, handler.count_true()); |
| 585 | handler.reset(); | 585 | handler.reset(); |
| 586 | 586 | ||
| 587 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); | 587 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}")); |
| 588 | EXPECT_EQ(1, handler.count_true()); | 588 | EXPECT_EQ(1, handler.count_true()); |
| 589 | handler.reset(); | 589 | handler.reset(); |
| 590 | } | 590 | } |
| @@ -596,16 +596,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostAdded) | @@ -596,16 +596,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostAdded) | ||
| 596 | 596 | ||
| 597 | conf.subscribe(&handler); | 597 | conf.subscribe(&handler); |
| 598 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); | 598 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); |
| 599 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 599 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 600 | EXPECT_TRUE(handler.all_false()); | 600 | EXPECT_TRUE(handler.all_false()); |
| 601 | handler.reset(); | 601 | handler.reset(); |
| 602 | 602 | ||
| 603 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}")); | 603 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{} vhost b{}")); |
| 604 | EXPECT_TRUE(handler.vhost_added_reloaded); | 604 | EXPECT_TRUE(handler.vhost_added_reloaded); |
| 605 | EXPECT_EQ(1, handler.count_true()); | 605 | EXPECT_EQ(1, handler.count_true()); |
| 606 | handler.reset(); | 606 | handler.reset(); |
| 607 | 607 | ||
| 608 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 608 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 609 | EXPECT_EQ(1, handler.count_true()); | 609 | EXPECT_EQ(1, handler.count_true()); |
| 610 | handler.reset(); | 610 | handler.reset(); |
| 611 | } | 611 | } |
| @@ -617,16 +617,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostRemoved) | @@ -617,16 +617,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostRemoved) | ||
| 617 | 617 | ||
| 618 | conf.subscribe(&handler); | 618 | conf.subscribe(&handler); |
| 619 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); | 619 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); |
| 620 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 620 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 621 | EXPECT_TRUE(handler.all_false()); | 621 | EXPECT_TRUE(handler.all_false()); |
| 622 | handler.reset(); | 622 | handler.reset(); |
| 623 | 623 | ||
| 624 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{enabled off;}")); | 624 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{enabled off;}")); |
| 625 | EXPECT_TRUE(handler.vhost_removed_reloaded); | 625 | EXPECT_TRUE(handler.vhost_removed_reloaded); |
| 626 | EXPECT_EQ(1, handler.count_true()); | 626 | EXPECT_EQ(1, handler.count_true()); |
| 627 | handler.reset(); | 627 | handler.reset(); |
| 628 | 628 | ||
| 629 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 629 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 630 | EXPECT_EQ(1, handler.count_true()); | 630 | EXPECT_EQ(1, handler.count_true()); |
| 631 | handler.reset(); | 631 | handler.reset(); |
| 632 | } | 632 | } |
| @@ -638,16 +638,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostRemoved2) | @@ -638,16 +638,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostRemoved2) | ||
| 638 | 638 | ||
| 639 | conf.subscribe(&handler); | 639 | conf.subscribe(&handler); |
| 640 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{} vhost b{}")); | 640 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{} vhost b{}")); |
| 641 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}")); | 641 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{} vhost b{}")); |
| 642 | EXPECT_TRUE(handler.all_false()); | 642 | EXPECT_TRUE(handler.all_false()); |
| 643 | handler.reset(); | 643 | handler.reset(); |
| 644 | 644 | ||
| 645 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 645 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 646 | EXPECT_TRUE(handler.vhost_removed_reloaded); | 646 | EXPECT_TRUE(handler.vhost_removed_reloaded); |
| 647 | EXPECT_EQ(1, handler.count_true()); | 647 | EXPECT_EQ(1, handler.count_true()); |
| 648 | handler.reset(); | 648 | handler.reset(); |
| 649 | 649 | ||
| 650 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}")); | 650 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{} vhost b{}")); |
| 651 | EXPECT_EQ(1, handler.count_true()); | 651 | EXPECT_EQ(1, handler.count_true()); |
| 652 | handler.reset(); | 652 | handler.reset(); |
| 653 | } | 653 | } |
| @@ -659,16 +659,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostAtc) | @@ -659,16 +659,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostAtc) | ||
| 659 | 659 | ||
| 660 | conf.subscribe(&handler); | 660 | conf.subscribe(&handler); |
| 661 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{atc off;}")); | 661 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{atc off;}")); |
| 662 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc off;}")); | 662 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{atc off;}")); |
| 663 | EXPECT_TRUE(handler.all_false()); | 663 | EXPECT_TRUE(handler.all_false()); |
| 664 | handler.reset(); | 664 | handler.reset(); |
| 665 | 665 | ||
| 666 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc on;}")); | 666 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{atc on;}")); |
| 667 | EXPECT_TRUE(handler.vhost_atc_reloaded); | 667 | EXPECT_TRUE(handler.vhost_atc_reloaded); |
| 668 | EXPECT_EQ(1, handler.count_true()); | 668 | EXPECT_EQ(1, handler.count_true()); |
| 669 | handler.reset(); | 669 | handler.reset(); |
| 670 | 670 | ||
| 671 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc off;}")); | 671 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{atc off;}")); |
| 672 | EXPECT_EQ(1, handler.count_true()); | 672 | EXPECT_EQ(1, handler.count_true()); |
| 673 | handler.reset(); | 673 | handler.reset(); |
| 674 | } | 674 | } |
| @@ -680,16 +680,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostGopCache) | @@ -680,16 +680,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostGopCache) | ||
| 680 | 680 | ||
| 681 | conf.subscribe(&handler); | 681 | conf.subscribe(&handler); |
| 682 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{gop_cache off;}")); | 682 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{gop_cache off;}")); |
| 683 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache off;}")); | 683 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{gop_cache off;}")); |
| 684 | EXPECT_TRUE(handler.all_false()); | 684 | EXPECT_TRUE(handler.all_false()); |
| 685 | handler.reset(); | 685 | handler.reset(); |
| 686 | 686 | ||
| 687 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache on;}")); | 687 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{gop_cache on;}")); |
| 688 | EXPECT_TRUE(handler.vhost_gop_cache_reloaded); | 688 | EXPECT_TRUE(handler.vhost_gop_cache_reloaded); |
| 689 | EXPECT_EQ(1, handler.count_true()); | 689 | EXPECT_EQ(1, handler.count_true()); |
| 690 | handler.reset(); | 690 | handler.reset(); |
| 691 | 691 | ||
| 692 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache off;}")); | 692 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{gop_cache off;}")); |
| 693 | EXPECT_EQ(1, handler.count_true()); | 693 | EXPECT_EQ(1, handler.count_true()); |
| 694 | handler.reset(); | 694 | handler.reset(); |
| 695 | } | 695 | } |
| @@ -701,16 +701,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostQueueLength) | @@ -701,16 +701,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostQueueLength) | ||
| 701 | 701 | ||
| 702 | conf.subscribe(&handler); | 702 | conf.subscribe(&handler); |
| 703 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{queue_length 10;}")); | 703 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{queue_length 10;}")); |
| 704 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 10;}")); | 704 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{queue_length 10;}")); |
| 705 | EXPECT_TRUE(handler.all_false()); | 705 | EXPECT_TRUE(handler.all_false()); |
| 706 | handler.reset(); | 706 | handler.reset(); |
| 707 | 707 | ||
| 708 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 20;}")); | 708 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{queue_length 20;}")); |
| 709 | EXPECT_TRUE(handler.vhost_queue_length_reloaded); | 709 | EXPECT_TRUE(handler.vhost_queue_length_reloaded); |
| 710 | EXPECT_EQ(1, handler.count_true()); | 710 | EXPECT_EQ(1, handler.count_true()); |
| 711 | handler.reset(); | 711 | handler.reset(); |
| 712 | 712 | ||
| 713 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 10;}")); | 713 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{queue_length 10;}")); |
| 714 | EXPECT_EQ(1, handler.count_true()); | 714 | EXPECT_EQ(1, handler.count_true()); |
| 715 | handler.reset(); | 715 | handler.reset(); |
| 716 | } | 716 | } |
| @@ -722,16 +722,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostTimeJitter) | @@ -722,16 +722,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostTimeJitter) | ||
| 722 | 722 | ||
| 723 | conf.subscribe(&handler); | 723 | conf.subscribe(&handler); |
| 724 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{time_jitter full;}")); | 724 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{time_jitter full;}")); |
| 725 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter full;}")); | 725 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{time_jitter full;}")); |
| 726 | EXPECT_TRUE(handler.all_false()); | 726 | EXPECT_TRUE(handler.all_false()); |
| 727 | handler.reset(); | 727 | handler.reset(); |
| 728 | 728 | ||
| 729 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter zero;}")); | 729 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{time_jitter zero;}")); |
| 730 | EXPECT_TRUE(handler.vhost_time_jitter_reloaded); | 730 | EXPECT_TRUE(handler.vhost_time_jitter_reloaded); |
| 731 | EXPECT_EQ(1, handler.count_true()); | 731 | EXPECT_EQ(1, handler.count_true()); |
| 732 | handler.reset(); | 732 | handler.reset(); |
| 733 | 733 | ||
| 734 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter full;}")); | 734 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{time_jitter full;}")); |
| 735 | EXPECT_EQ(1, handler.count_true()); | 735 | EXPECT_EQ(1, handler.count_true()); |
| 736 | handler.reset(); | 736 | handler.reset(); |
| 737 | } | 737 | } |
| @@ -743,16 +743,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostForward) | @@ -743,16 +743,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostForward) | ||
| 743 | 743 | ||
| 744 | conf.subscribe(&handler); | 744 | conf.subscribe(&handler); |
| 745 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); | 745 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); |
| 746 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); | 746 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); |
| 747 | EXPECT_TRUE(handler.all_false()); | 747 | EXPECT_TRUE(handler.all_false()); |
| 748 | handler.reset(); | 748 | handler.reset(); |
| 749 | 749 | ||
| 750 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1937;}")); | 750 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1937;}")); |
| 751 | EXPECT_TRUE(handler.vhost_forward_reloaded); | 751 | EXPECT_TRUE(handler.vhost_forward_reloaded); |
| 752 | EXPECT_EQ(1, handler.count_true()); | 752 | EXPECT_EQ(1, handler.count_true()); |
| 753 | handler.reset(); | 753 | handler.reset(); |
| 754 | 754 | ||
| 755 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); | 755 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}")); |
| 756 | EXPECT_EQ(1, handler.count_true()); | 756 | EXPECT_EQ(1, handler.count_true()); |
| 757 | handler.reset(); | 757 | handler.reset(); |
| 758 | } | 758 | } |
| @@ -764,16 +764,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostHls) | @@ -764,16 +764,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostHls) | ||
| 764 | 764 | ||
| 765 | conf.subscribe(&handler); | 765 | conf.subscribe(&handler); |
| 766 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); | 766 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); |
| 767 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); | 767 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); |
| 768 | EXPECT_TRUE(handler.all_false()); | 768 | EXPECT_TRUE(handler.all_false()); |
| 769 | handler.reset(); | 769 | handler.reset(); |
| 770 | 770 | ||
| 771 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled off;}}")); | 771 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{hls {enabled off;}}")); |
| 772 | EXPECT_TRUE(handler.vhost_hls_reloaded); | 772 | EXPECT_TRUE(handler.vhost_hls_reloaded); |
| 773 | EXPECT_EQ(1, handler.count_true()); | 773 | EXPECT_EQ(1, handler.count_true()); |
| 774 | handler.reset(); | 774 | handler.reset(); |
| 775 | 775 | ||
| 776 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); | 776 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}")); |
| 777 | EXPECT_EQ(1, handler.count_true()); | 777 | EXPECT_EQ(1, handler.count_true()); |
| 778 | handler.reset(); | 778 | handler.reset(); |
| 779 | } | 779 | } |
| @@ -785,16 +785,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostDvr) | @@ -785,16 +785,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostDvr) | ||
| 785 | 785 | ||
| 786 | conf.subscribe(&handler); | 786 | conf.subscribe(&handler); |
| 787 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); | 787 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); |
| 788 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); | 788 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); |
| 789 | EXPECT_TRUE(handler.all_false()); | 789 | EXPECT_TRUE(handler.all_false()); |
| 790 | handler.reset(); | 790 | handler.reset(); |
| 791 | 791 | ||
| 792 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled off;}}")); | 792 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{dvr {enabled off;}}")); |
| 793 | EXPECT_TRUE(handler.vhost_dvr_reloaded); | 793 | EXPECT_TRUE(handler.vhost_dvr_reloaded); |
| 794 | EXPECT_EQ(1, handler.count_true()); | 794 | EXPECT_EQ(1, handler.count_true()); |
| 795 | handler.reset(); | 795 | handler.reset(); |
| 796 | 796 | ||
| 797 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); | 797 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}")); |
| 798 | EXPECT_EQ(1, handler.count_true()); | 798 | EXPECT_EQ(1, handler.count_true()); |
| 799 | handler.reset(); | 799 | handler.reset(); |
| 800 | } | 800 | } |
| @@ -806,16 +806,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostTranscode) | @@ -806,16 +806,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostTranscode) | ||
| 806 | 806 | ||
| 807 | conf.subscribe(&handler); | 807 | conf.subscribe(&handler); |
| 808 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); | 808 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); |
| 809 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); | 809 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); |
| 810 | EXPECT_TRUE(handler.all_false()); | 810 | EXPECT_TRUE(handler.all_false()); |
| 811 | handler.reset(); | 811 | handler.reset(); |
| 812 | 812 | ||
| 813 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled off;}}")); | 813 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{transcode {enabled off;}}")); |
| 814 | EXPECT_TRUE(handler.vhost_transcode_reloaded); | 814 | EXPECT_TRUE(handler.vhost_transcode_reloaded); |
| 815 | EXPECT_EQ(1, handler.count_true()); | 815 | EXPECT_EQ(1, handler.count_true()); |
| 816 | handler.reset(); | 816 | handler.reset(); |
| 817 | 817 | ||
| 818 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); | 818 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}")); |
| 819 | EXPECT_EQ(1, handler.count_true()); | 819 | EXPECT_EQ(1, handler.count_true()); |
| 820 | handler.reset(); | 820 | handler.reset(); |
| 821 | } | 821 | } |
| @@ -827,16 +827,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded) | @@ -827,16 +827,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded) | ||
| 827 | 827 | ||
| 828 | conf.subscribe(&handler); | 828 | conf.subscribe(&handler); |
| 829 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); | 829 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}")); |
| 830 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 830 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 831 | EXPECT_TRUE(handler.all_false()); | 831 | EXPECT_TRUE(handler.all_false()); |
| 832 | handler.reset(); | 832 | handler.reset(); |
| 833 | 833 | ||
| 834 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 834 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 835 | EXPECT_TRUE(handler.ingest_added_reloaded); | 835 | EXPECT_TRUE(handler.ingest_added_reloaded); |
| 836 | EXPECT_EQ(1, handler.count_true()); | 836 | EXPECT_EQ(1, handler.count_true()); |
| 837 | handler.reset(); | 837 | handler.reset(); |
| 838 | 838 | ||
| 839 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 839 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 840 | EXPECT_EQ(1, handler.count_true()); | 840 | EXPECT_EQ(1, handler.count_true()); |
| 841 | handler.reset(); | 841 | handler.reset(); |
| 842 | } | 842 | } |
| @@ -848,16 +848,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded2) | @@ -848,16 +848,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded2) | ||
| 848 | 848 | ||
| 849 | conf.subscribe(&handler); | 849 | conf.subscribe(&handler); |
| 850 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); | 850 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); |
| 851 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); | 851 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); |
| 852 | EXPECT_TRUE(handler.all_false()); | 852 | EXPECT_TRUE(handler.all_false()); |
| 853 | handler.reset(); | 853 | handler.reset(); |
| 854 | 854 | ||
| 855 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;} ingest b {enabled on;}}")); | 855 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;} ingest b {enabled on;}}")); |
| 856 | EXPECT_TRUE(handler.ingest_added_reloaded); | 856 | EXPECT_TRUE(handler.ingest_added_reloaded); |
| 857 | EXPECT_EQ(1, handler.count_true()); | 857 | EXPECT_EQ(1, handler.count_true()); |
| 858 | handler.reset(); | 858 | handler.reset(); |
| 859 | 859 | ||
| 860 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); | 860 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}")); |
| 861 | EXPECT_EQ(1, handler.count_true()); | 861 | EXPECT_EQ(1, handler.count_true()); |
| 862 | handler.reset(); | 862 | handler.reset(); |
| 863 | } | 863 | } |
| @@ -869,16 +869,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved) | @@ -869,16 +869,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved) | ||
| 869 | 869 | ||
| 870 | conf.subscribe(&handler); | 870 | conf.subscribe(&handler); |
| 871 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 871 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 872 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 872 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 873 | EXPECT_TRUE(handler.all_false()); | 873 | EXPECT_TRUE(handler.all_false()); |
| 874 | handler.reset(); | 874 | handler.reset(); |
| 875 | 875 | ||
| 876 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}")); | 876 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{}")); |
| 877 | EXPECT_TRUE(handler.ingest_removed_reloaded); | 877 | EXPECT_TRUE(handler.ingest_removed_reloaded); |
| 878 | EXPECT_EQ(1, handler.count_true()); | 878 | EXPECT_EQ(1, handler.count_true()); |
| 879 | handler.reset(); | 879 | handler.reset(); |
| 880 | 880 | ||
| 881 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 881 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 882 | EXPECT_EQ(1, handler.count_true()); | 882 | EXPECT_EQ(1, handler.count_true()); |
| 883 | handler.reset(); | 883 | handler.reset(); |
| 884 | } | 884 | } |
| @@ -890,16 +890,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved2) | @@ -890,16 +890,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved2) | ||
| 890 | 890 | ||
| 891 | conf.subscribe(&handler); | 891 | conf.subscribe(&handler); |
| 892 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 892 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 893 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 893 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 894 | EXPECT_TRUE(handler.all_false()); | 894 | EXPECT_TRUE(handler.all_false()); |
| 895 | handler.reset(); | 895 | handler.reset(); |
| 896 | 896 | ||
| 897 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled off;}}")); | 897 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled off;}}")); |
| 898 | EXPECT_TRUE(handler.ingest_removed_reloaded); | 898 | EXPECT_TRUE(handler.ingest_removed_reloaded); |
| 899 | EXPECT_EQ(1, handler.count_true()); | 899 | EXPECT_EQ(1, handler.count_true()); |
| 900 | handler.reset(); | 900 | handler.reset(); |
| 901 | 901 | ||
| 902 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); | 902 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}")); |
| 903 | EXPECT_EQ(1, handler.count_true()); | 903 | EXPECT_EQ(1, handler.count_true()); |
| 904 | handler.reset(); | 904 | handler.reset(); |
| 905 | } | 905 | } |
| @@ -911,16 +911,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestUpdated) | @@ -911,16 +911,16 @@ VOID TEST(ConfigReloadTest, ReloadVhostIngestUpdated) | ||
| 911 | 911 | ||
| 912 | conf.subscribe(&handler); | 912 | conf.subscribe(&handler); |
| 913 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); | 913 | EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); |
| 914 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); | 914 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); |
| 915 | EXPECT_TRUE(handler.all_false()); | 915 | EXPECT_TRUE(handler.all_false()); |
| 916 | handler.reset(); | 916 | handler.reset(); |
| 917 | 917 | ||
| 918 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg1;}}")); | 918 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg1;}}")); |
| 919 | EXPECT_TRUE(handler.ingest_updated_reloaded); | 919 | EXPECT_TRUE(handler.ingest_updated_reloaded); |
| 920 | EXPECT_EQ(1, handler.count_true()); | 920 | EXPECT_EQ(1, handler.count_true()); |
| 921 | handler.reset(); | 921 | handler.reset(); |
| 922 | 922 | ||
| 923 | - EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); | 923 | + EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}")); |
| 924 | EXPECT_EQ(1, handler.count_true()); | 924 | EXPECT_EQ(1, handler.count_true()); |
| 925 | handler.reset(); | 925 | handler.reset(); |
| 926 | } | 926 | } |
| @@ -102,7 +102,7 @@ public: | @@ -102,7 +102,7 @@ public: | ||
| 102 | MockSrsReloadConfig(); | 102 | MockSrsReloadConfig(); |
| 103 | virtual ~MockSrsReloadConfig(); | 103 | virtual ~MockSrsReloadConfig(); |
| 104 | public: | 104 | public: |
| 105 | - virtual int reload(std::string buf); | 105 | + virtual int do_reload(std::string buf); |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | #endif | 108 | #endif |
-
请 注册 或 登录 后发表评论