winlin

fix reload ingest bug, remove when disabled. 0.9.196

@@ -14,5 +14,9 @@ http_stream { @@ -14,5 +14,9 @@ http_stream {
14 listen 8080; 14 listen 8080;
15 dir ./objs/nginx/html; 15 dir ./objs/nginx/html;
16 } 16 }
  17 +stats {
  18 + network 0;
  19 + disk sda sdb xvda xvdb;
  20 +}
17 vhost __defaultVhost__ { 21 vhost __defaultVhost__ {
18 } 22 }
@@ -414,11 +414,18 @@ int SrsConfig::reload() @@ -414,11 +414,18 @@ int SrsConfig::reload()
414 } 414 }
415 srs_info("config reloader parse file success."); 415 srs_info("config reloader parse file success.");
416 416
  417 + return reload_conf(&conf);
  418 +}
  419 +
  420 +int SrsConfig::reload_conf(SrsConfig* conf)
  421 +{
  422 + int ret = ERROR_SUCCESS;
  423 +
417 SrsConfDirective* old_root = root; 424 SrsConfDirective* old_root = root;
418 SrsAutoFree(SrsConfDirective, old_root); 425 SrsAutoFree(SrsConfDirective, old_root);
419 426
420 - root = conf.root;  
421 - conf.root = NULL; 427 + root = conf->root;
  428 + conf->root = NULL;
422 429
423 // merge config. 430 // merge config.
424 std::vector<ISrsReloadHandler*>::iterator it; 431 std::vector<ISrsReloadHandler*>::iterator it;
@@ -954,12 +961,10 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_ @@ -954,12 +961,10 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
954 for (int i = 0; i < (int)old_ingesters.size(); i++) { 961 for (int i = 0; i < (int)old_ingesters.size(); i++) {
955 SrsConfDirective* old_ingester = old_ingesters.at(i); 962 SrsConfDirective* old_ingester = old_ingesters.at(i);
956 std::string ingest_id = old_ingester->arg0(); 963 std::string ingest_id = old_ingester->arg0();
  964 + SrsConfDirective* new_ingester = new_vhost->get("ingest", ingest_id);
957 965
958 - // if ingester exists in new vhost, not removed, ignore.  
959 - if (new_vhost->get("ingest", ingest_id)) {  
960 - continue;  
961 - }  
962 - 966 + // ENABLED => DISABLED
  967 + if (get_ingest_enabled(old_ingester) && !get_ingest_enabled(new_ingester)) {
963 // notice handler ingester removed. 968 // notice handler ingester removed.
964 for (it = subscribes.begin(); it != subscribes.end(); ++it) { 969 for (it = subscribes.begin(); it != subscribes.end(); ++it) {
965 ISrsReloadHandler* subscribe = *it; 970 ISrsReloadHandler* subscribe = *it;
@@ -971,18 +976,16 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_ @@ -971,18 +976,16 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
971 } 976 }
972 srs_trace("vhost %s reload ingest=%s removed success.", vhost.c_str(), ingest_id.c_str()); 977 srs_trace("vhost %s reload ingest=%s removed success.", vhost.c_str(), ingest_id.c_str());
973 } 978 }
  979 + }
974 980
975 // for added ingesters, start them. 981 // for added ingesters, start them.
976 for (int i = 0; i < (int)new_ingesters.size(); i++) { 982 for (int i = 0; i < (int)new_ingesters.size(); i++) {
977 SrsConfDirective* new_ingester = new_ingesters.at(i); 983 SrsConfDirective* new_ingester = new_ingesters.at(i);
978 std::string ingest_id = new_ingester->arg0(); 984 std::string ingest_id = new_ingester->arg0();
  985 + SrsConfDirective* old_ingester = old_vhost->get("ingest", ingest_id);
979 986
980 - // if ingester exists in old vhost, not added, ignore.  
981 - if (old_vhost->get("ingest", ingest_id)) {  
982 - continue;  
983 - }  
984 -  
985 - // notice handler ingester removed. 987 + // DISABLED => ENABLED
  988 + if (!get_ingest_enabled(old_ingester) && get_ingest_enabled(new_ingester)) {
986 for (it = subscribes.begin(); it != subscribes.end(); ++it) { 989 for (it = subscribes.begin(); it != subscribes.end(); ++it) {
987 ISrsReloadHandler* subscribe = *it; 990 ISrsReloadHandler* subscribe = *it;
988 if ((ret = subscribe->on_reload_ingest_added(vhost, ingest_id)) != ERROR_SUCCESS) { 991 if ((ret = subscribe->on_reload_ingest_added(vhost, ingest_id)) != ERROR_SUCCESS) {
@@ -993,6 +996,7 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_ @@ -993,6 +996,7 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
993 } 996 }
994 srs_trace("vhost %s reload ingest=%s added success.", vhost.c_str(), ingest_id.c_str()); 997 srs_trace("vhost %s reload ingest=%s added success.", vhost.c_str(), ingest_id.c_str());
995 } 998 }
  999 + }
996 1000
997 // for updated ingesters, restart them. 1001 // for updated ingesters, restart them.
998 for (int i = 0; i < (int)new_ingesters.size(); i++) { 1002 for (int i = 0; i < (int)new_ingesters.size(); i++) {
@@ -1000,11 +1004,8 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_ @@ -1000,11 +1004,8 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
1000 std::string ingest_id = new_ingester->arg0(); 1004 std::string ingest_id = new_ingester->arg0();
1001 SrsConfDirective* old_ingester = old_vhost->get("ingest", ingest_id); 1005 SrsConfDirective* old_ingester = old_vhost->get("ingest", ingest_id);
1002 1006
1003 - // ignore the added ingester.  
1004 - if (!old_ingester) {  
1005 - continue;  
1006 - }  
1007 - 1007 + // ENABLED => ENABLED
  1008 + if (get_ingest_enabled(old_ingester) && get_ingest_enabled(new_ingester)) {
1008 if (srs_directive_equals(new_ingester, old_ingester)) { 1009 if (srs_directive_equals(new_ingester, old_ingester)) {
1009 continue; 1010 continue;
1010 } 1011 }
@@ -1020,6 +1021,7 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_ @@ -1020,6 +1021,7 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
1020 } 1021 }
1021 srs_trace("vhost %s reload ingest=%s updated success.", vhost.c_str(), ingest_id.c_str()); 1022 srs_trace("vhost %s reload ingest=%s updated success.", vhost.c_str(), ingest_id.c_str());
1022 } 1023 }
  1024 + }
1023 1025
1024 srs_trace("ingest not changed for vhost=%s", vhost.c_str()); 1026 srs_trace("ingest not changed for vhost=%s", vhost.c_str());
1025 1027
@@ -1270,11 +1272,11 @@ int SrsConfig::check_config() @@ -1270,11 +1272,11 @@ int SrsConfig::check_config()
1270 } 1272 }
1271 } 1273 }
1272 } 1274 }
1273 - for (int i = 0; i < (int)vhosts.size(); i++) {  
1274 - SrsConfDirective* conf = vhosts[i];  
1275 - for (int i = 0; conf && i < (int)conf->directives.size(); i++) {  
1276 - SrsConfDirective* conf0 = conf->at(i);  
1277 - string n = conf0->name; 1275 + for (int n = 0; n < (int)vhosts.size(); n++) {
  1276 + SrsConfDirective* vhost = vhosts[n];
  1277 + for (int i = 0; vhost && i < (int)vhost->directives.size(); i++) {
  1278 + SrsConfDirective* conf = vhost->at(i);
  1279 + string n = conf->name;
1278 if (n != "enabled" && n != "chunk_size" 1280 if (n != "enabled" && n != "chunk_size"
1279 && n != "mode" && n != "origin" && n != "token_traverse" 1281 && n != "mode" && n != "origin" && n != "token_traverse"
1280 && n != "dvr" && n != "ingest" && n != "http" && n != "hls" && n != "http_hooks" 1282 && n != "dvr" && n != "ingest" && n != "http" && n != "hls" && n != "http_hooks"
@@ -1290,8 +1292,8 @@ int SrsConfig::check_config() @@ -1290,8 +1292,8 @@ int SrsConfig::check_config()
1290 } 1292 }
1291 // for each sub directives of vhost. 1293 // for each sub directives of vhost.
1292 if (n == "dvr") { 1294 if (n == "dvr") {
1293 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1294 - string m = conf0->at(j)->name.c_str(); 1295 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1296 + string m = conf->at(j)->name.c_str();
1295 if (m != "enabled" && m != "dvr_path" && m != "dvr_plan" 1297 if (m != "enabled" && m != "dvr_path" && m != "dvr_plan"
1296 && m != "dvr_duration" && m != "time_jitter" 1298 && m != "dvr_duration" && m != "time_jitter"
1297 ) { 1299 ) {
@@ -1301,8 +1303,8 @@ int SrsConfig::check_config() @@ -1301,8 +1303,8 @@ int SrsConfig::check_config()
1301 } 1303 }
1302 } 1304 }
1303 } else if (n == "ingest") { 1305 } else if (n == "ingest") {
1304 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1305 - string m = conf0->at(j)->name.c_str(); 1306 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1307 + string m = conf->at(j)->name.c_str();
1306 if (m != "enabled" && m != "input" && m != "ffmpeg" 1308 if (m != "enabled" && m != "input" && m != "ffmpeg"
1307 && m != "engine" 1309 && m != "engine"
1308 ) { 1310 ) {
@@ -1312,8 +1314,8 @@ int SrsConfig::check_config() @@ -1312,8 +1314,8 @@ int SrsConfig::check_config()
1312 } 1314 }
1313 } 1315 }
1314 } else if (n == "http") { 1316 } else if (n == "http") {
1315 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1316 - string m = conf0->at(j)->name.c_str(); 1317 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1318 + string m = conf->at(j)->name.c_str();
1317 if (m != "enabled" && m != "mount" && m != "dir") { 1319 if (m != "enabled" && m != "mount" && m != "dir") {
1318 ret = ERROR_SYSTEM_CONFIG_INVALID; 1320 ret = ERROR_SYSTEM_CONFIG_INVALID;
1319 srs_error("unsupported vhost http directive %s, ret=%d", m.c_str(), ret); 1321 srs_error("unsupported vhost http directive %s, ret=%d", m.c_str(), ret);
@@ -1321,8 +1323,8 @@ int SrsConfig::check_config() @@ -1321,8 +1323,8 @@ int SrsConfig::check_config()
1321 } 1323 }
1322 } 1324 }
1323 } else if (n == "hls") { 1325 } else if (n == "hls") {
1324 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1325 - string m = conf0->at(j)->name.c_str(); 1326 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1327 + string m = conf->at(j)->name.c_str();
1326 if (m != "enabled" && m != "hls_path" && m != "hls_fragment" && m != "hls_window") { 1328 if (m != "enabled" && m != "hls_path" && m != "hls_fragment" && m != "hls_window") {
1327 ret = ERROR_SYSTEM_CONFIG_INVALID; 1329 ret = ERROR_SYSTEM_CONFIG_INVALID;
1328 srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret); 1330 srs_error("unsupported vhost hls directive %s, ret=%d", m.c_str(), ret);
@@ -1330,8 +1332,8 @@ int SrsConfig::check_config() @@ -1330,8 +1332,8 @@ int SrsConfig::check_config()
1330 } 1332 }
1331 } 1333 }
1332 } else if (n == "http_hooks") { 1334 } else if (n == "http_hooks") {
1333 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1334 - string m = conf0->at(j)->name.c_str(); 1335 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1336 + string m = conf->at(j)->name.c_str();
1335 if (m != "enabled" && m != "on_connect" && m != "on_close" && m != "on_publish" 1337 if (m != "enabled" && m != "on_connect" && m != "on_close" && m != "on_publish"
1336 && m != "on_unpublish" && m != "on_play" && m != "on_stop" 1338 && m != "on_unpublish" && m != "on_play" && m != "on_stop"
1337 ) { 1339 ) {
@@ -1342,8 +1344,8 @@ int SrsConfig::check_config() @@ -1342,8 +1344,8 @@ int SrsConfig::check_config()
1342 } 1344 }
1343 } else if (n == "forward") { 1345 } else if (n == "forward") {
1344 // TODO: FIXME: implements it. 1346 // TODO: FIXME: implements it.
1345 - /*for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1346 - string m = conf0->at(j)->name.c_str(); 1347 + /*for (int j = 0; j < (int)conf->directives.size(); j++) {
  1348 + string m = conf->at(j)->name.c_str();
1347 if (m != "enabled" && m != "vhost" && m != "refer") { 1349 if (m != "enabled" && m != "vhost" && m != "refer") {
1348 ret = ERROR_SYSTEM_CONFIG_INVALID; 1350 ret = ERROR_SYSTEM_CONFIG_INVALID;
1349 srs_error("unsupported vhost forward directive %s, ret=%d", m.c_str(), ret); 1351 srs_error("unsupported vhost forward directive %s, ret=%d", m.c_str(), ret);
@@ -1351,17 +1353,17 @@ int SrsConfig::check_config() @@ -1351,17 +1353,17 @@ int SrsConfig::check_config()
1351 } 1353 }
1352 }*/ 1354 }*/
1353 } else if (n == "transcode") { 1355 } else if (n == "transcode") {
1354 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1355 - SrsConfDirective* conf1 = conf0->at(j);  
1356 - string m = conf1->name.c_str(); 1356 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1357 + SrsConfDirective* trans = conf->at(j);
  1358 + string m = trans->name.c_str();
1357 if (m != "enabled" && m != "ffmpeg" && m != "engine") { 1359 if (m != "enabled" && m != "ffmpeg" && m != "engine") {
1358 ret = ERROR_SYSTEM_CONFIG_INVALID; 1360 ret = ERROR_SYSTEM_CONFIG_INVALID;
1359 srs_error("unsupported vhost transcode directive %s, ret=%d", m.c_str(), ret); 1361 srs_error("unsupported vhost transcode directive %s, ret=%d", m.c_str(), ret);
1360 return ret; 1362 return ret;
1361 } 1363 }
1362 if (m == "engine") { 1364 if (m == "engine") {
1363 - for (int k = 0; k < (int)conf1->directives.size(); k++) {  
1364 - string e = conf1->at(k)->name; 1365 + for (int k = 0; k < (int)trans->directives.size(); k++) {
  1366 + string e = trans->at(k)->name;
1365 if (e != "enabled" && e != "vfilter" && e != "vcodec" 1367 if (e != "enabled" && e != "vfilter" && e != "vcodec"
1366 && e != "vbitrate" && e != "vfps" && e != "vwidth" && e != "vheight" 1368 && e != "vbitrate" && e != "vfps" && e != "vwidth" && e != "vheight"
1367 && e != "vthreads" && e != "vprofile" && e != "vpreset" && e != "vparams" 1369 && e != "vthreads" && e != "vprofile" && e != "vpreset" && e != "vparams"
@@ -1377,8 +1379,8 @@ int SrsConfig::check_config() @@ -1377,8 +1379,8 @@ int SrsConfig::check_config()
1377 } 1379 }
1378 } 1380 }
1379 } else if (n == "bandcheck") { 1381 } else if (n == "bandcheck") {
1380 - for (int j = 0; j < (int)conf0->directives.size(); j++) {  
1381 - string m = conf0->at(j)->name.c_str(); 1382 + for (int j = 0; j < (int)conf->directives.size(); j++) {
  1383 + string m = conf->at(j)->name.c_str();
1382 if (m != "enabled" && m != "key" && m != "interval" && m != "limit_kbps") { 1384 if (m != "enabled" && m != "key" && m != "interval" && m != "limit_kbps") {
1383 ret = ERROR_SYSTEM_CONFIG_INVALID; 1385 ret = ERROR_SYSTEM_CONFIG_INVALID;
1384 srs_error("unsupported vhost bandcheck directive %s, ret=%d", m.c_str(), ret); 1386 srs_error("unsupported vhost bandcheck directive %s, ret=%d", m.c_str(), ret);
@@ -1388,6 +1390,29 @@ int SrsConfig::check_config() @@ -1388,6 +1390,29 @@ int SrsConfig::check_config()
1388 } 1390 }
1389 } 1391 }
1390 } 1392 }
  1393 + // check ingest id unique.
  1394 + for (int i = 0; i < (int)vhosts.size(); i++) {
  1395 + SrsConfDirective* vhost = vhosts[i];
  1396 + std::vector<std::string> ids;
  1397 +
  1398 + for (int j = 0; j < (int)vhost->directives.size(); j++) {
  1399 + SrsConfDirective* conf = vhost->at(j);
  1400 + if (conf->name != "ingest") {
  1401 + continue;
  1402 + }
  1403 +
  1404 + std::string id = conf->arg0();
  1405 + for (int k = 0; k < (int)ids.size(); k++) {
  1406 + if (id == ids.at(k)) {
  1407 + ret = ERROR_SYSTEM_CONFIG_INVALID;
  1408 + srs_error("directive \"ingest\" id duplicated, vhost=%s, id=%s, ret=%d",
  1409 + vhost->name.c_str(), id.c_str(), ret);
  1410 + return ret;
  1411 + }
  1412 + }
  1413 + ids.push_back(id);
  1414 + }
  1415 + }
1391 1416
1392 //////////////////////////////////////////////////////////////////////// 1417 ////////////////////////////////////////////////////////////////////////
1393 // check listen for rtmp. 1418 // check listen for rtmp.
@@ -290,6 +290,12 @@ public: @@ -290,6 +290,12 @@ public:
290 * @remark, user can test the config before reload it. 290 * @remark, user can test the config before reload it.
291 */ 291 */
292 virtual int reload(); 292 virtual int reload();
  293 +protected:
  294 + /**
  295 + * reload from the config.
  296 + * @remark, use protected for the utest to override with mock.
  297 + */
  298 + virtual int reload_conf(SrsConfig* conf);
293 private: 299 private:
294 /** 300 /**
295 * reload the http_api section of config. 301 * reload the http_api section of config.
@@ -334,7 +340,7 @@ protected: @@ -334,7 +340,7 @@ protected:
334 /** 340 /**
335 * parse config from the buffer. 341 * parse config from the buffer.
336 * @param buffer, the config buffer, user must delete it. 342 * @param buffer, the config buffer, user must delete it.
337 - * @remark, protected for the utest to override with mock. 343 + * @remark, use protected for the utest to override with mock.
338 */ 344 */
339 virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); 345 virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer);
340 private: 346 private:
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "195" 34 +#define VERSION_REVISION "196"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"
@@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include <srs_app_log.hpp> 30 #include <srs_app_log.hpp>
31 31
32 // kernel module. 32 // kernel module.
33 -ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Warn); 33 +ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Disabled);
34 ISrsThreadContext* _srs_context = new ISrsThreadContext(); 34 ISrsThreadContext* _srs_context = new ISrsThreadContext();
35 // app module. 35 // app module.
36 SrsConfig* _srs_config = NULL; 36 SrsConfig* _srs_config = NULL;
@@ -33,8 +33,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,8 +33,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 33
34 #include <srs_app_log.hpp> 34 #include <srs_app_log.hpp>
35 35
  36 +#define __UTEST_DEV
  37 +#undef __UTEST_DEV
  38 +
36 // enable all utest. 39 // enable all utest.
37 -#if 1 40 +#ifndef __UTEST_DEV
38 #define ENABLE_UTEST_AMF0 41 #define ENABLE_UTEST_AMF0
39 #define ENABLE_UTEST_CONFIG 42 #define ENABLE_UTEST_CONFIG
40 #define ENABLE_UTEST_CORE 43 #define ENABLE_UTEST_CORE
@@ -44,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -44,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 #endif 47 #endif
45 48
46 // disable some for fast dev, compile and startup. 49 // disable some for fast dev, compile and startup.
47 -#if 0 50 +#ifdef __UTEST_DEV
48 #undef ENABLE_UTEST_AMF0 51 #undef ENABLE_UTEST_AMF0
49 #undef ENABLE_UTEST_CONFIG 52 #undef ENABLE_UTEST_CONFIG
50 #undef ENABLE_UTEST_CORE 53 #undef ENABLE_UTEST_CORE
@@ -53,6 +56,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -53,6 +56,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 #undef ENABLE_UTEST_RELOAD 56 #undef ENABLE_UTEST_RELOAD
54 #endif 57 #endif
55 58
  59 +#ifdef __UTEST_DEV
  60 + #define ENABLE_UTEST_RELOAD
  61 +#endif
  62 +
56 // we add an empty macro for upp to show the smart tips. 63 // we add an empty macro for upp to show the smart tips.
57 #define VOID 64 #define VOID
58 65
@@ -70,8 +70,6 @@ int MockSrsConfig::parse(string buf) @@ -70,8 +70,6 @@ int MockSrsConfig::parse(string buf)
70 70
71 #ifdef ENABLE_UTEST_CONFIG 71 #ifdef ENABLE_UTEST_CONFIG
72 72
73 -#define _MIN_OK_CONF "listen 1935; "  
74 -  
75 // full.conf 73 // full.conf
76 std::string __full_conf = "" 74 std::string __full_conf = ""
77 "# all config for srs \n" 75 "# all config for srs \n"
@@ -5454,5 +5452,13 @@ VOID TEST(ConfigMainTest, CheckConf_pithy_print) @@ -5454,5 +5452,13 @@ VOID TEST(ConfigMainTest, CheckConf_pithy_print)
5454 } 5452 }
5455 } 5453 }
5456 5454
  5455 +VOID TEST(ConfigMainTest, CheckConf_vhost_ingest_id)
  5456 +{
  5457 + MockSrsConfig conf;
  5458 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{ingest id{}}"));
  5459 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{ingest id{} ingest id{}}"));
  5460 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{ingest{} ingest{}}"));
  5461 +}
  5462 +
5457 #endif 5463 #endif
5458 5464
@@ -33,6 +33,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,6 +33,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 33
34 #include <srs_app_config.hpp> 34 #include <srs_app_config.hpp>
35 35
  36 +#define _MIN_OK_CONF "listen 1935; "
  37 +
36 class MockSrsConfigBuffer : public _srs_internal::SrsConfigBuffer 38 class MockSrsConfigBuffer : public _srs_internal::SrsConfigBuffer
37 { 39 {
38 public: 40 public:
@@ -23,7 +23,919 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -23,7 +23,919 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 23
24 #include <srs_utest_reload.hpp> 24 #include <srs_utest_reload.hpp>
25 25
  26 +using namespace std;
  27 +
  28 +#include <srs_kernel_error.hpp>
  29 +
  30 +MockReloadHandler::MockReloadHandler()
  31 +{
  32 + reset();
  33 +}
  34 +
  35 +MockReloadHandler::~MockReloadHandler()
  36 +{
  37 +}
  38 +
  39 +void MockReloadHandler::reset()
  40 +{
  41 + listen_reloaded = false;
  42 + pid_reloaded = false;
  43 + log_tank_reloaded = false;
  44 + log_level_reloaded = false;
  45 + log_file_reloaded = false;
  46 + pithy_print_reloaded = false;
  47 + http_api_enabled_reloaded = false;
  48 + http_api_disabled_reloaded = false;
  49 + http_stream_enabled_reloaded = false;
  50 + http_stream_disabled_reloaded = false;
  51 + http_stream_updated_reloaded = false;
  52 + vhost_http_updated_reloaded = false;
  53 + vhost_added_reloaded = false;
  54 + vhost_removed_reloaded = false;
  55 + vhost_atc_reloaded = false;
  56 + vhost_gop_cache_reloaded = false;
  57 + vhost_queue_length_reloaded = false;
  58 + vhost_time_jitter_reloaded = false;
  59 + vhost_forward_reloaded = false;
  60 + vhost_hls_reloaded = false;
  61 + vhost_dvr_reloaded = false;
  62 + vhost_transcode_reloaded = false;
  63 + ingest_removed_reloaded = false;
  64 + ingest_added_reloaded = false;
  65 + ingest_updated_reloaded = false;
  66 +}
  67 +
  68 +int MockReloadHandler::count_total()
  69 +{
  70 + return 56 - 31;
  71 +}
  72 +
  73 +int MockReloadHandler::count_true()
  74 +{
  75 + int count_true = 0;
  76 +
  77 + if (listen_reloaded) count_true++;
  78 + if (pid_reloaded) count_true++;
  79 + if (log_tank_reloaded) count_true++;
  80 + if (log_level_reloaded) count_true++;
  81 + if (log_file_reloaded) count_true++;
  82 + if (pithy_print_reloaded) count_true++;
  83 + if (http_api_enabled_reloaded) count_true++;
  84 + if (http_api_disabled_reloaded) count_true++;
  85 + if (http_stream_enabled_reloaded) count_true++;
  86 + if (http_stream_disabled_reloaded) count_true++;
  87 + if (http_stream_updated_reloaded) count_true++;
  88 + if (vhost_http_updated_reloaded) count_true++;
  89 + if (vhost_added_reloaded) count_true++;
  90 + if (vhost_removed_reloaded) count_true++;
  91 + if (vhost_atc_reloaded) count_true++;
  92 + if (vhost_gop_cache_reloaded) count_true++;
  93 + if (vhost_queue_length_reloaded) count_true++;
  94 + if (vhost_time_jitter_reloaded) count_true++;
  95 + if (vhost_forward_reloaded) count_true++;
  96 + if (vhost_hls_reloaded) count_true++;
  97 + if (vhost_dvr_reloaded) count_true++;
  98 + if (vhost_transcode_reloaded) count_true++;
  99 + if (ingest_removed_reloaded) count_true++;
  100 + if (ingest_added_reloaded) count_true++;
  101 + if (ingest_updated_reloaded) count_true++;
  102 +
  103 + return count_true;
  104 +}
  105 +
  106 +int MockReloadHandler::count_false()
  107 +{
  108 + int count_false = 0;
  109 +
  110 + if (!listen_reloaded) count_false++;
  111 + if (!pid_reloaded) count_false++;
  112 + if (!log_tank_reloaded) count_false++;
  113 + if (!log_level_reloaded) count_false++;
  114 + if (!log_file_reloaded) count_false++;
  115 + if (!pithy_print_reloaded) count_false++;
  116 + if (!http_api_enabled_reloaded) count_false++;
  117 + if (!http_api_disabled_reloaded) count_false++;
  118 + if (!http_stream_enabled_reloaded) count_false++;
  119 + if (!http_stream_disabled_reloaded) count_false++;
  120 + if (!http_stream_updated_reloaded) count_false++;
  121 + if (!vhost_http_updated_reloaded) count_false++;
  122 + if (!vhost_added_reloaded) count_false++;
  123 + if (!vhost_removed_reloaded) count_false++;
  124 + if (!vhost_atc_reloaded) count_false++;
  125 + if (!vhost_gop_cache_reloaded) count_false++;
  126 + if (!vhost_queue_length_reloaded) count_false++;
  127 + if (!vhost_time_jitter_reloaded) count_false++;
  128 + if (!vhost_forward_reloaded) count_false++;
  129 + if (!vhost_hls_reloaded) count_false++;
  130 + if (!vhost_dvr_reloaded) count_false++;
  131 + if (!vhost_transcode_reloaded) count_false++;
  132 + if (!ingest_removed_reloaded) count_false++;
  133 + if (!ingest_added_reloaded) count_false++;
  134 + if (!ingest_updated_reloaded) count_false++;
  135 +
  136 + return count_false;
  137 +}
  138 +
  139 +bool MockReloadHandler::all_false()
  140 +{
  141 + return count_true() == 0;
  142 +}
  143 +
  144 +bool MockReloadHandler::all_true()
  145 +{
  146 + return count_true() == count_total();
  147 +}
  148 +
  149 +int MockReloadHandler::on_reload_listen()
  150 +{
  151 + listen_reloaded = true;
  152 + return ERROR_SUCCESS;
  153 +}
  154 +
  155 +int MockReloadHandler::on_reload_pid()
  156 +{
  157 + pid_reloaded = true;
  158 + return ERROR_SUCCESS;
  159 +}
  160 +
  161 +int MockReloadHandler::on_reload_log_tank()
  162 +{
  163 + log_tank_reloaded = true;
  164 + return ERROR_SUCCESS;
  165 +}
  166 +
  167 +int MockReloadHandler::on_reload_log_level()
  168 +{
  169 + log_level_reloaded = true;
  170 + return ERROR_SUCCESS;
  171 +}
  172 +
  173 +int MockReloadHandler::on_reload_log_file()
  174 +{
  175 + log_file_reloaded = true;
  176 + return ERROR_SUCCESS;
  177 +}
  178 +
  179 +int MockReloadHandler::on_reload_pithy_print()
  180 +{
  181 + pithy_print_reloaded = true;
  182 + return ERROR_SUCCESS;
  183 +}
  184 +
  185 +int MockReloadHandler::on_reload_http_api_enabled()
  186 +{
  187 + http_api_enabled_reloaded = true;
  188 + return ERROR_SUCCESS;
  189 +}
  190 +
  191 +int MockReloadHandler::on_reload_http_api_disabled()
  192 +{
  193 + http_api_disabled_reloaded = true;
  194 + return ERROR_SUCCESS;
  195 +}
  196 +
  197 +int MockReloadHandler::on_reload_http_stream_enabled()
  198 +{
  199 + http_stream_enabled_reloaded = true;
  200 + return ERROR_SUCCESS;
  201 +}
  202 +
  203 +int MockReloadHandler::on_reload_http_stream_disabled()
  204 +{
  205 + http_stream_disabled_reloaded = true;
  206 + return ERROR_SUCCESS;
  207 +}
  208 +
  209 +int MockReloadHandler::on_reload_http_stream_updated()
  210 +{
  211 + http_stream_updated_reloaded = true;
  212 + return ERROR_SUCCESS;
  213 +}
  214 +
  215 +int MockReloadHandler::on_reload_vhost_http_updated()
  216 +{
  217 + vhost_http_updated_reloaded = true;
  218 + return ERROR_SUCCESS;
  219 +}
  220 +
  221 +int MockReloadHandler::on_reload_vhost_added(string /*vhost*/)
  222 +{
  223 + vhost_added_reloaded = true;
  224 + return ERROR_SUCCESS;
  225 +}
  226 +
  227 +int MockReloadHandler::on_reload_vhost_removed(string /*vhost*/)
  228 +{
  229 + vhost_removed_reloaded = true;
  230 + return ERROR_SUCCESS;
  231 +}
  232 +
  233 +int MockReloadHandler::on_reload_vhost_atc(string /*vhost*/)
  234 +{
  235 + vhost_atc_reloaded = true;
  236 + return ERROR_SUCCESS;
  237 +}
  238 +
  239 +int MockReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/)
  240 +{
  241 + vhost_gop_cache_reloaded = true;
  242 + return ERROR_SUCCESS;
  243 +}
  244 +
  245 +int MockReloadHandler::on_reload_vhost_queue_length(string /*vhost*/)
  246 +{
  247 + vhost_queue_length_reloaded = true;
  248 + return ERROR_SUCCESS;
  249 +}
  250 +
  251 +int MockReloadHandler::on_reload_vhost_time_jitter(string /*vhost*/)
  252 +{
  253 + vhost_time_jitter_reloaded = true;
  254 + return ERROR_SUCCESS;
  255 +}
  256 +
  257 +int MockReloadHandler::on_reload_vhost_forward(string /*vhost*/)
  258 +{
  259 + vhost_forward_reloaded = true;
  260 + return ERROR_SUCCESS;
  261 +}
  262 +
  263 +int MockReloadHandler::on_reload_vhost_hls(string /*vhost*/)
  264 +{
  265 + vhost_hls_reloaded = true;
  266 + return ERROR_SUCCESS;
  267 +}
  268 +
  269 +int MockReloadHandler::on_reload_vhost_dvr(string /*vhost*/)
  270 +{
  271 + vhost_dvr_reloaded = true;
  272 + return ERROR_SUCCESS;
  273 +}
  274 +
  275 +int MockReloadHandler::on_reload_vhost_transcode(string /*vhost*/)
  276 +{
  277 + vhost_transcode_reloaded = true;
  278 + return ERROR_SUCCESS;
  279 +}
  280 +
  281 +int MockReloadHandler::on_reload_ingest_removed(string /*vhost*/, string /*ingest_id*/)
  282 +{
  283 + ingest_removed_reloaded = true;
  284 + return ERROR_SUCCESS;
  285 +}
  286 +
  287 +int MockReloadHandler::on_reload_ingest_added(string /*vhost*/, string /*ingest_id*/)
  288 +{
  289 + ingest_added_reloaded = true;
  290 + return ERROR_SUCCESS;
  291 +}
  292 +
  293 +int MockReloadHandler::on_reload_ingest_updated(string /*vhost*/, string /*ingest_id*/)
  294 +{
  295 + ingest_updated_reloaded = true;
  296 + return ERROR_SUCCESS;
  297 +}
  298 +
  299 +MockSrsReloadConfig::MockSrsReloadConfig()
  300 +{
  301 +}
  302 +
  303 +MockSrsReloadConfig::~MockSrsReloadConfig()
  304 +{
  305 +}
  306 +
  307 +int MockSrsReloadConfig::reload(string buf)
  308 +{
  309 + int ret = ERROR_SUCCESS;
  310 +
  311 + MockSrsReloadConfig conf;
  312 + if ((ret = conf.parse(buf)) != ERROR_SUCCESS) {
  313 + return ret;
  314 + }
  315 +
  316 + return reload_conf(&conf);
  317 +}
  318 +
26 #ifdef ENABLE_UTEST_RELOAD 319 #ifdef ENABLE_UTEST_RELOAD
27 320
  321 +VOID TEST(ConfigReloadTest, ReloadEmpty)
  322 +{
  323 + MockReloadHandler handler;
  324 + MockSrsReloadConfig conf;
  325 +
  326 + conf.subscribe(&handler);
  327 + EXPECT_FALSE(ERROR_SUCCESS == conf.parse(""));
  328 + EXPECT_FALSE(ERROR_SUCCESS == conf.reload(""));
  329 + EXPECT_TRUE(handler.all_false());
  330 +}
  331 +
  332 +VOID TEST(ConfigReloadTest, ReloadListen)
  333 +{
  334 + MockReloadHandler handler;
  335 + MockSrsReloadConfig conf;
  336 +
  337 + conf.subscribe(&handler);
  338 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935;"));
  339 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;"));
  340 + EXPECT_TRUE(handler.all_false());
  341 + handler.reset();
  342 +
  343 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936;"));
  344 + EXPECT_TRUE(handler.listen_reloaded);
  345 + EXPECT_EQ(1, handler.count_true());
  346 + handler.reset();
  347 +
  348 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936;"));
  349 + EXPECT_TRUE(handler.all_false());
  350 + handler.reset();
  351 +
  352 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1936 1935;"));
  353 + EXPECT_TRUE(handler.listen_reloaded);
  354 + EXPECT_EQ(1, handler.count_true());
  355 + handler.reset();
  356 +
  357 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;"));
  358 + EXPECT_TRUE(handler.listen_reloaded);
  359 + EXPECT_EQ(1, handler.count_true());
  360 + handler.reset();
  361 +
  362 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935 1935;"));
  363 + EXPECT_TRUE(handler.listen_reloaded);
  364 + EXPECT_EQ(1, handler.count_true());
  365 + handler.reset();
  366 +
  367 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload("listen 1935;"));
  368 + EXPECT_TRUE(handler.listen_reloaded);
  369 + EXPECT_EQ(1, handler.count_true());
  370 + handler.reset();
  371 +}
  372 +
  373 +VOID TEST(ConfigReloadTest, ReloadPid)
  374 +{
  375 + MockReloadHandler handler;
  376 + MockSrsReloadConfig conf;
  377 +
  378 + conf.subscribe(&handler);
  379 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pid srs.pid;"));
  380 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs.pid;"));
  381 + EXPECT_TRUE(handler.all_false());
  382 + handler.reset();
  383 +
  384 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs1.pid;"));
  385 + EXPECT_TRUE(handler.pid_reloaded);
  386 + EXPECT_EQ(1, handler.count_true());
  387 + handler.reset();
  388 +
  389 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pid srs.pid;"));
  390 + EXPECT_EQ(1, handler.count_true());
  391 + handler.reset();
  392 +}
  393 +
  394 +VOID TEST(ConfigReloadTest, ReloadLogTank)
  395 +{
  396 + MockReloadHandler handler;
  397 + MockSrsReloadConfig conf;
  398 +
  399 + conf.subscribe(&handler);
  400 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_tank console;"));
  401 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank console;"));
  402 + EXPECT_TRUE(handler.all_false());
  403 + handler.reset();
  404 +
  405 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank file;"));
  406 + EXPECT_TRUE(handler.log_tank_reloaded);
  407 + EXPECT_EQ(1, handler.count_true());
  408 + handler.reset();
  409 +
  410 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_tank console;"));
  411 + EXPECT_EQ(1, handler.count_true());
  412 + handler.reset();
  413 +}
  414 +
  415 +VOID TEST(ConfigReloadTest, ReloadLogLevel)
  416 +{
  417 + MockReloadHandler handler;
  418 + MockSrsReloadConfig conf;
  419 +
  420 + conf.subscribe(&handler);
  421 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_level trace;"));
  422 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level trace;"));
  423 + EXPECT_TRUE(handler.all_false());
  424 + handler.reset();
  425 +
  426 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level warn;"));
  427 + EXPECT_TRUE(handler.log_level_reloaded);
  428 + EXPECT_EQ(1, handler.count_true());
  429 + handler.reset();
  430 +
  431 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_level trace;"));
  432 + EXPECT_EQ(1, handler.count_true());
  433 + handler.reset();
  434 +}
  435 +
  436 +VOID TEST(ConfigReloadTest, ReloadLogFile)
  437 +{
  438 + MockReloadHandler handler;
  439 + MockSrsReloadConfig conf;
  440 +
  441 + conf.subscribe(&handler);
  442 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_file srs.log;"));
  443 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs.log;"));
  444 + EXPECT_TRUE(handler.all_false());
  445 + handler.reset();
  446 +
  447 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs1.log;"));
  448 + EXPECT_TRUE(handler.log_file_reloaded);
  449 + EXPECT_EQ(1, handler.count_true());
  450 + handler.reset();
  451 +
  452 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"srs_log_file srs.log;"));
  453 + EXPECT_EQ(1, handler.count_true());
  454 + handler.reset();
  455 +}
  456 +
  457 +VOID TEST(ConfigReloadTest, ReloadPithyPrint)
  458 +{
  459 + MockReloadHandler handler;
  460 + MockSrsReloadConfig conf;
  461 +
  462 + conf.subscribe(&handler);
  463 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"pithy_print {publish 1000;}"));
  464 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print {publish 1000;}"));
  465 + EXPECT_TRUE(handler.all_false());
  466 + handler.reset();
  467 +
  468 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print {publish 2000;}"));
  469 + EXPECT_TRUE(handler.pithy_print_reloaded);
  470 + EXPECT_EQ(1, handler.count_true());
  471 + handler.reset();
  472 +
  473 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"pithy_print {publish 1000;}"));
  474 + EXPECT_EQ(1, handler.count_true());
  475 + handler.reset();
  476 +}
  477 +
  478 +VOID TEST(ConfigReloadTest, ReloadHttpApiEnabled)
  479 +{
  480 + MockReloadHandler handler;
  481 + MockSrsReloadConfig conf;
  482 +
  483 + conf.subscribe(&handler);
  484 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled off;}"));
  485 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}"));
  486 + EXPECT_TRUE(handler.all_false());
  487 + handler.reset();
  488 +
  489 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}"));
  490 + EXPECT_TRUE(handler.http_api_enabled_reloaded);
  491 + EXPECT_EQ(1, handler.count_true());
  492 + handler.reset();
  493 +
  494 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}"));
  495 + EXPECT_EQ(1, handler.count_true());
  496 + handler.reset();
  497 +}
  498 +
  499 +VOID TEST(ConfigReloadTest, ReloadHttpApiDisabled)
  500 +{
  501 + MockReloadHandler handler;
  502 + MockSrsReloadConfig conf;
  503 +
  504 + conf.subscribe(&handler);
  505 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api {enabled on;}"));
  506 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}"));
  507 + EXPECT_TRUE(handler.all_false());
  508 + handler.reset();
  509 +
  510 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled off;}"));
  511 + EXPECT_TRUE(handler.http_api_disabled_reloaded);
  512 + EXPECT_EQ(1, handler.count_true());
  513 + handler.reset();
  514 +
  515 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_api {enabled on;}"));
  516 + EXPECT_EQ(1, handler.count_true());
  517 + handler.reset();
  518 +}
  519 +
  520 +VOID TEST(ConfigReloadTest, ReloadHttpStreamEnabled)
  521 +{
  522 + MockReloadHandler handler;
  523 + MockSrsReloadConfig conf;
  524 +
  525 + conf.subscribe(&handler);
  526 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled off;}"));
  527 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}"));
  528 + EXPECT_TRUE(handler.all_false());
  529 + handler.reset();
  530 +
  531 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}"));
  532 + EXPECT_TRUE(handler.http_stream_enabled_reloaded);
  533 + EXPECT_EQ(1, handler.count_true());
  534 + handler.reset();
  535 +
  536 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}"));
  537 + EXPECT_EQ(1, handler.count_true());
  538 + handler.reset();
  539 +}
  540 +
  541 +VOID TEST(ConfigReloadTest, ReloadHttpStreamDisabled)
  542 +{
  543 + MockReloadHandler handler;
  544 + MockSrsReloadConfig conf;
  545 +
  546 + conf.subscribe(&handler);
  547 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on;}"));
  548 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}"));
  549 + EXPECT_TRUE(handler.all_false());
  550 + handler.reset();
  551 +
  552 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled off;}"));
  553 + EXPECT_TRUE(handler.http_stream_disabled_reloaded);
  554 + EXPECT_EQ(1, handler.count_true());
  555 + handler.reset();
  556 +
  557 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on;}"));
  558 + EXPECT_EQ(1, handler.count_true());
  559 + handler.reset();
  560 +}
  561 +
  562 +VOID TEST(ConfigReloadTest, ReloadHttpStreamUpdated)
  563 +{
  564 + MockReloadHandler handler;
  565 + MockSrsReloadConfig conf;
  566 +
  567 + conf.subscribe(&handler);
  568 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}"));
  569 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}"));
  570 + EXPECT_TRUE(handler.all_false());
  571 + handler.reset();
  572 +
  573 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8000;}"));
  574 + EXPECT_TRUE(handler.http_stream_updated_reloaded);
  575 + EXPECT_EQ(1, handler.count_true());
  576 + handler.reset();
  577 +
  578 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}"));
  579 + EXPECT_EQ(1, handler.count_true());
  580 + handler.reset();
  581 +}
  582 +
  583 +VOID TEST(ConfigReloadTest, ReloadVhostHttpUpdated)
  584 +{
  585 + MockReloadHandler handler;
  586 + MockSrsReloadConfig conf;
  587 +
  588 + conf.subscribe(&handler);
  589 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}"));
  590 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}"));
  591 + EXPECT_TRUE(handler.all_false());
  592 + handler.reset();
  593 +
  594 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls1;}}"));
  595 + EXPECT_TRUE(handler.vhost_http_updated_reloaded);
  596 + EXPECT_EQ(1, handler.count_true());
  597 + handler.reset();
  598 +
  599 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost http.srs.com {http {enabled on;mount /hls;}}"));
  600 + EXPECT_EQ(1, handler.count_true());
  601 + handler.reset();
  602 +}
  603 +
  604 +VOID TEST(ConfigReloadTest, ReloadVhostAdded)
  605 +{
  606 + MockReloadHandler handler;
  607 + MockSrsReloadConfig conf;
  608 +
  609 + conf.subscribe(&handler);
  610 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}"));
  611 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  612 + EXPECT_TRUE(handler.all_false());
  613 + handler.reset();
  614 +
  615 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}"));
  616 + EXPECT_TRUE(handler.vhost_added_reloaded);
  617 + EXPECT_EQ(1, handler.count_true());
  618 + handler.reset();
  619 +
  620 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  621 + EXPECT_EQ(1, handler.count_true());
  622 + handler.reset();
  623 +}
  624 +
  625 +VOID TEST(ConfigReloadTest, ReloadVhostRemoved)
  626 +{
  627 + MockReloadHandler handler;
  628 + MockSrsReloadConfig conf;
  629 +
  630 + conf.subscribe(&handler);
  631 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}"));
  632 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  633 + EXPECT_TRUE(handler.all_false());
  634 + handler.reset();
  635 +
  636 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{enabled off;}"));
  637 + EXPECT_TRUE(handler.vhost_removed_reloaded);
  638 + EXPECT_EQ(1, handler.count_true());
  639 + handler.reset();
  640 +
  641 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  642 + EXPECT_EQ(1, handler.count_true());
  643 + handler.reset();
  644 +}
  645 +
  646 +VOID TEST(ConfigReloadTest, ReloadVhostRemoved2)
  647 +{
  648 + MockReloadHandler handler;
  649 + MockSrsReloadConfig conf;
  650 +
  651 + conf.subscribe(&handler);
  652 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{} vhost b{}"));
  653 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}"));
  654 + EXPECT_TRUE(handler.all_false());
  655 + handler.reset();
  656 +
  657 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  658 + EXPECT_TRUE(handler.vhost_removed_reloaded);
  659 + EXPECT_EQ(1, handler.count_true());
  660 + handler.reset();
  661 +
  662 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{} vhost b{}"));
  663 + EXPECT_EQ(1, handler.count_true());
  664 + handler.reset();
  665 +}
  666 +
  667 +VOID TEST(ConfigReloadTest, ReloadVhostAtc)
  668 +{
  669 + MockReloadHandler handler;
  670 + MockSrsReloadConfig conf;
  671 +
  672 + conf.subscribe(&handler);
  673 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{atc off;}"));
  674 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc off;}"));
  675 + EXPECT_TRUE(handler.all_false());
  676 + handler.reset();
  677 +
  678 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc on;}"));
  679 + EXPECT_TRUE(handler.vhost_atc_reloaded);
  680 + EXPECT_EQ(1, handler.count_true());
  681 + handler.reset();
  682 +
  683 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{atc off;}"));
  684 + EXPECT_EQ(1, handler.count_true());
  685 + handler.reset();
  686 +}
  687 +
  688 +VOID TEST(ConfigReloadTest, ReloadVhostGopCache)
  689 +{
  690 + MockReloadHandler handler;
  691 + MockSrsReloadConfig conf;
  692 +
  693 + conf.subscribe(&handler);
  694 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{gop_cache off;}"));
  695 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache off;}"));
  696 + EXPECT_TRUE(handler.all_false());
  697 + handler.reset();
  698 +
  699 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache on;}"));
  700 + EXPECT_TRUE(handler.vhost_gop_cache_reloaded);
  701 + EXPECT_EQ(1, handler.count_true());
  702 + handler.reset();
  703 +
  704 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{gop_cache off;}"));
  705 + EXPECT_EQ(1, handler.count_true());
  706 + handler.reset();
  707 +}
  708 +
  709 +VOID TEST(ConfigReloadTest, ReloadVhostQueueLength)
  710 +{
  711 + MockReloadHandler handler;
  712 + MockSrsReloadConfig conf;
  713 +
  714 + conf.subscribe(&handler);
  715 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{queue_length 10;}"));
  716 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 10;}"));
  717 + EXPECT_TRUE(handler.all_false());
  718 + handler.reset();
  719 +
  720 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 20;}"));
  721 + EXPECT_TRUE(handler.vhost_queue_length_reloaded);
  722 + EXPECT_EQ(1, handler.count_true());
  723 + handler.reset();
  724 +
  725 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{queue_length 10;}"));
  726 + EXPECT_EQ(1, handler.count_true());
  727 + handler.reset();
  728 +}
  729 +
  730 +VOID TEST(ConfigReloadTest, ReloadVhostTimeJitter)
  731 +{
  732 + MockReloadHandler handler;
  733 + MockSrsReloadConfig conf;
  734 +
  735 + conf.subscribe(&handler);
  736 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{time_jitter full;}"));
  737 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter full;}"));
  738 + EXPECT_TRUE(handler.all_false());
  739 + handler.reset();
  740 +
  741 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter zero;}"));
  742 + EXPECT_TRUE(handler.vhost_time_jitter_reloaded);
  743 + EXPECT_EQ(1, handler.count_true());
  744 + handler.reset();
  745 +
  746 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{time_jitter full;}"));
  747 + EXPECT_EQ(1, handler.count_true());
  748 + handler.reset();
  749 +}
  750 +
  751 +VOID TEST(ConfigReloadTest, ReloadVhostForward)
  752 +{
  753 + MockReloadHandler handler;
  754 + MockSrsReloadConfig conf;
  755 +
  756 + conf.subscribe(&handler);
  757 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}"));
  758 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}"));
  759 + EXPECT_TRUE(handler.all_false());
  760 + handler.reset();
  761 +
  762 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1937;}"));
  763 + EXPECT_TRUE(handler.vhost_forward_reloaded);
  764 + EXPECT_EQ(1, handler.count_true());
  765 + handler.reset();
  766 +
  767 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{forward 127.0.0.1:1936;}"));
  768 + EXPECT_EQ(1, handler.count_true());
  769 + handler.reset();
  770 +}
  771 +
  772 +VOID TEST(ConfigReloadTest, ReloadVhostHls)
  773 +{
  774 + MockReloadHandler handler;
  775 + MockSrsReloadConfig conf;
  776 +
  777 + conf.subscribe(&handler);
  778 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{hls {enabled on;}}"));
  779 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}"));
  780 + EXPECT_TRUE(handler.all_false());
  781 + handler.reset();
  782 +
  783 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled off;}}"));
  784 + EXPECT_TRUE(handler.vhost_hls_reloaded);
  785 + EXPECT_EQ(1, handler.count_true());
  786 + handler.reset();
  787 +
  788 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{hls {enabled on;}}"));
  789 + EXPECT_EQ(1, handler.count_true());
  790 + handler.reset();
  791 +}
  792 +
  793 +VOID TEST(ConfigReloadTest, ReloadVhostDvr)
  794 +{
  795 + MockReloadHandler handler;
  796 + MockSrsReloadConfig conf;
  797 +
  798 + conf.subscribe(&handler);
  799 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{dvr {enabled on;}}"));
  800 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}"));
  801 + EXPECT_TRUE(handler.all_false());
  802 + handler.reset();
  803 +
  804 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled off;}}"));
  805 + EXPECT_TRUE(handler.vhost_dvr_reloaded);
  806 + EXPECT_EQ(1, handler.count_true());
  807 + handler.reset();
  808 +
  809 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{dvr {enabled on;}}"));
  810 + EXPECT_EQ(1, handler.count_true());
  811 + handler.reset();
  812 +}
  813 +
  814 +VOID TEST(ConfigReloadTest, ReloadVhostTranscode)
  815 +{
  816 + MockReloadHandler handler;
  817 + MockSrsReloadConfig conf;
  818 +
  819 + conf.subscribe(&handler);
  820 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{transcode {enabled on;}}"));
  821 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}"));
  822 + EXPECT_TRUE(handler.all_false());
  823 + handler.reset();
  824 +
  825 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled off;}}"));
  826 + EXPECT_TRUE(handler.vhost_transcode_reloaded);
  827 + EXPECT_EQ(1, handler.count_true());
  828 + handler.reset();
  829 +
  830 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{transcode {enabled on;}}"));
  831 + EXPECT_EQ(1, handler.count_true());
  832 + handler.reset();
  833 +}
  834 +
  835 +VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded)
  836 +{
  837 + MockReloadHandler handler;
  838 + MockSrsReloadConfig conf;
  839 +
  840 + conf.subscribe(&handler);
  841 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{}"));
  842 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  843 + EXPECT_TRUE(handler.all_false());
  844 + handler.reset();
  845 +
  846 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  847 + EXPECT_TRUE(handler.ingest_added_reloaded);
  848 + EXPECT_EQ(1, handler.count_true());
  849 + handler.reset();
  850 +
  851 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  852 + EXPECT_EQ(1, handler.count_true());
  853 + handler.reset();
  854 +}
  855 +
  856 +VOID TEST(ConfigReloadTest, ReloadVhostIngestAdded2)
  857 +{
  858 + MockReloadHandler handler;
  859 + MockSrsReloadConfig conf;
  860 +
  861 + conf.subscribe(&handler);
  862 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}"));
  863 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}"));
  864 + EXPECT_TRUE(handler.all_false());
  865 + handler.reset();
  866 +
  867 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;} ingest b {enabled on;}}"));
  868 + EXPECT_TRUE(handler.ingest_added_reloaded);
  869 + EXPECT_EQ(1, handler.count_true());
  870 + handler.reset();
  871 +
  872 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest a {enabled on;}}"));
  873 + EXPECT_EQ(1, handler.count_true());
  874 + handler.reset();
  875 +}
  876 +
  877 +VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved)
  878 +{
  879 + MockReloadHandler handler;
  880 + MockSrsReloadConfig conf;
  881 +
  882 + conf.subscribe(&handler);
  883 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  884 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  885 + EXPECT_TRUE(handler.all_false());
  886 + handler.reset();
  887 +
  888 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{}"));
  889 + EXPECT_TRUE(handler.ingest_removed_reloaded);
  890 + EXPECT_EQ(1, handler.count_true());
  891 + handler.reset();
  892 +
  893 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  894 + EXPECT_EQ(1, handler.count_true());
  895 + handler.reset();
  896 +}
  897 +
  898 +VOID TEST(ConfigReloadTest, ReloadVhostIngestRemoved2)
  899 +{
  900 + MockReloadHandler handler;
  901 + MockSrsReloadConfig conf;
  902 +
  903 + conf.subscribe(&handler);
  904 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  905 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  906 + EXPECT_TRUE(handler.all_false());
  907 + handler.reset();
  908 +
  909 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled off;}}"));
  910 + EXPECT_TRUE(handler.ingest_removed_reloaded);
  911 + EXPECT_EQ(1, handler.count_true());
  912 + handler.reset();
  913 +
  914 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;}}"));
  915 + EXPECT_EQ(1, handler.count_true());
  916 + handler.reset();
  917 +}
  918 +
  919 +VOID TEST(ConfigReloadTest, ReloadVhostIngestUpdated)
  920 +{
  921 + MockReloadHandler handler;
  922 + MockSrsReloadConfig conf;
  923 +
  924 + conf.subscribe(&handler);
  925 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}"));
  926 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}"));
  927 + EXPECT_TRUE(handler.all_false());
  928 + handler.reset();
  929 +
  930 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg1;}}"));
  931 + EXPECT_TRUE(handler.ingest_updated_reloaded);
  932 + EXPECT_EQ(1, handler.count_true());
  933 + handler.reset();
  934 +
  935 + EXPECT_TRUE(ERROR_SUCCESS == conf.reload(_MIN_OK_CONF"vhost a{ingest {enabled on;ffmpeg ffmpeg;}}"));
  936 + EXPECT_EQ(1, handler.count_true());
  937 + handler.reset();
  938 +}
  939 +
28 #endif 940 #endif
29 941
@@ -29,5 +29,83 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -29,5 +29,83 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 */ 29 */
30 #include <srs_core.hpp> 30 #include <srs_core.hpp>
31 31
  32 +#include <srs_utest_config.hpp>
  33 +#include <srs_app_reload.hpp>
  34 +
  35 +class MockReloadHandler : public ISrsReloadHandler
  36 +{
  37 +public:
  38 + bool listen_reloaded;
  39 + bool pid_reloaded;
  40 + bool log_tank_reloaded;
  41 + bool log_level_reloaded;
  42 + bool log_file_reloaded;
  43 + bool pithy_print_reloaded;
  44 + bool http_api_enabled_reloaded;
  45 + bool http_api_disabled_reloaded;
  46 + bool http_stream_enabled_reloaded;
  47 + bool http_stream_disabled_reloaded;
  48 + bool http_stream_updated_reloaded;
  49 + bool vhost_http_updated_reloaded;
  50 + bool vhost_added_reloaded;
  51 + bool vhost_removed_reloaded;
  52 + bool vhost_atc_reloaded;
  53 + bool vhost_gop_cache_reloaded;
  54 + bool vhost_queue_length_reloaded;
  55 + bool vhost_time_jitter_reloaded;
  56 + bool vhost_forward_reloaded;
  57 + bool vhost_hls_reloaded;
  58 + bool vhost_dvr_reloaded;
  59 + bool vhost_transcode_reloaded;
  60 + bool ingest_removed_reloaded;
  61 + bool ingest_added_reloaded;
  62 + bool ingest_updated_reloaded;
  63 +public:
  64 + MockReloadHandler();
  65 + virtual ~MockReloadHandler();
  66 +public:
  67 + virtual void reset();
  68 + virtual bool all_false();
  69 + virtual bool all_true();
  70 + virtual int count_total();
  71 + virtual int count_true();
  72 + virtual int count_false();
  73 +public:
  74 + virtual int on_reload_listen();
  75 + virtual int on_reload_pid();
  76 + virtual int on_reload_log_tank();
  77 + virtual int on_reload_log_level();
  78 + virtual int on_reload_log_file();
  79 + virtual int on_reload_pithy_print();
  80 + virtual int on_reload_http_api_enabled();
  81 + virtual int on_reload_http_api_disabled();
  82 + virtual int on_reload_http_stream_enabled();
  83 + virtual int on_reload_http_stream_disabled();
  84 + virtual int on_reload_http_stream_updated();
  85 + virtual int on_reload_vhost_http_updated();
  86 + virtual int on_reload_vhost_added(std::string vhost);
  87 + virtual int on_reload_vhost_removed(std::string vhost);
  88 + virtual int on_reload_vhost_atc(std::string vhost);
  89 + virtual int on_reload_vhost_gop_cache(std::string vhost);
  90 + virtual int on_reload_vhost_queue_length(std::string vhost);
  91 + virtual int on_reload_vhost_time_jitter(std::string vhost);
  92 + virtual int on_reload_vhost_forward(std::string vhost);
  93 + virtual int on_reload_vhost_hls(std::string vhost);
  94 + virtual int on_reload_vhost_dvr(std::string vhost);
  95 + virtual int on_reload_vhost_transcode(std::string vhost);
  96 + virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id);
  97 + virtual int on_reload_ingest_added(std::string vhost, std::string ingest_id);
  98 + virtual int on_reload_ingest_updated(std::string vhost, std::string ingest_id);
  99 +};
  100 +
  101 +class MockSrsReloadConfig : public MockSrsConfig
  102 +{
  103 +public:
  104 + MockSrsReloadConfig();
  105 + virtual ~MockSrsReloadConfig();
  106 +public:
  107 + virtual int reload(std::string buf);
  108 +};
  109 +
32 #endif 110 #endif
33 111