diff --git a/trunk/research/librtmp/srs_publish.c b/trunk/research/librtmp/srs_publish.c index e0e9424ec..30c2af255 100644 --- a/trunk/research/librtmp/srs_publish.c +++ b/trunk/research/librtmp/srs_publish.c @@ -42,6 +42,13 @@ int main(int argc, char** argv) printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n"); printf("srs(simple-rtmp-server) client librtmp library.\n"); printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); + // warn it . + // @see: https://github.com/winlinvip/simple-rtmp-server/issues/126 + printf("\033[33m%s\033[0m", + "[warning] it's only a sample to use librtmp. " + "please never use it to publish and test forward/transcode/edge/HLS whatever. " + "you should refer to this tool to use the srs-librtmp to publish the real media stream."); + printf("\n"); rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index c9413fdc1..2a07c9580 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -80,17 +80,21 @@ SrsFastLog::~SrsFastLog() fd = -1; } - _srs_config->unsubscribe(this); + if (_srs_config) { + _srs_config->unsubscribe(this); + } } int SrsFastLog::initialize() { int ret = ERROR_SUCCESS; - _srs_config->subscribe(this); - - log_to_file_tank = _srs_config->get_log_tank_file(); - _level = srs_get_log_level(_srs_config->get_log_level()); + if (_srs_config) { + _srs_config->subscribe(this); + + log_to_file_tank = _srs_config->get_log_tank_file(); + _level = srs_get_log_level(_srs_config->get_log_level()); + } return ret; } diff --git a/trunk/src/app/srs_app_log.hpp b/trunk/src/app/srs_app_log.hpp index bb4c61bd8..44de104fe 100644 --- a/trunk/src/app/srs_app_log.hpp +++ b/trunk/src/app/srs_app_log.hpp @@ -60,7 +60,8 @@ public: */ class SrsFastLog : public ISrsLog, public ISrsReloadHandler { -private: +// for utest to override +protected: // defined in SrsLogLevel. int _level; char* log_data; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 276ed6b8e..0c9b12902 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "171" +#define VERSION_REVISION "172" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/kernel/srs_kernel_log.hpp b/trunk/src/kernel/srs_kernel_log.hpp index 5cc301f24..c92655295 100644 --- a/trunk/src/kernel/srs_kernel_log.hpp +++ b/trunk/src/kernel/srs_kernel_log.hpp @@ -52,6 +52,8 @@ public: static const int Trace = 0x03; static const int Warn = 0x04; static const int Error = 0x05; + // specified the disabled level, no log, for utest. + static const int Disabled = 0x06; }; /** diff --git a/trunk/src/utest/srs_utest.cpp b/trunk/src/utest/srs_utest.cpp index 95190fa0e..50a3bd232 100644 --- a/trunk/src/utest/srs_utest.cpp +++ b/trunk/src/utest/srs_utest.cpp @@ -30,12 +30,36 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include // kernel module. -ISrsLog* _srs_log = new ISrsLog(); +ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Disabled); ISrsThreadContext* _srs_context = new ISrsThreadContext(); // app module. SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; +MockEmptyLog::MockEmptyLog(int level) +{ + _level = level; +} + +MockEmptyLog::~MockEmptyLog() +{ +} + +int MockEmptyLog::on_reload_log_tank() +{ + return ERROR_SUCCESS; +} + +int MockEmptyLog::on_reload_log_level() +{ + return ERROR_SUCCESS; +} + +int MockEmptyLog::on_reload_log_file() +{ + return ERROR_SUCCESS; +} + void __srs_bytes_print(char* pa, int size) { for(int i = 0; i < size; i++) { diff --git a/trunk/src/utest/srs_utest.hpp b/trunk/src/utest/srs_utest.hpp index fd0e0b635..b8f522b70 100644 --- a/trunk/src/utest/srs_utest.hpp +++ b/trunk/src/utest/srs_utest.hpp @@ -31,6 +31,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "gtest/gtest.h" +#include + // we add an empty macro for upp to show the smart tips. #define VOID @@ -52,4 +54,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // print the bytes. void __srs_bytes_print(char* pa, int size); +class MockEmptyLog : public SrsFastLog +{ +private: + int _level; +public: + MockEmptyLog(int level); + virtual ~MockEmptyLog(); +public: + virtual int on_reload_log_tank(); + virtual int on_reload_log_level(); + virtual int on_reload_log_file(); +}; + #endif diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 1b2231ac9..12831f9e8 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -4341,3 +4341,26 @@ VOID TEST(ConfigMainTest, ParseFullConf_removed) EXPECT_STREQ("/", conf.get_vhost_http_mount(vhost).c_str()); EXPECT_STREQ("./objs/nginx/html", conf.get_vhost_http_dir(vhost).c_str()); } + +VOID TEST(ConfigMainTest, CheckConf_listen) +{ + if (true) { + MockSrsConfig conf; + EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listens 1935;")); + } + + if (true) { + MockSrsConfig conf; + EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listen 0;")); + } + + if (true) { + MockSrsConfig conf; + EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listen -1;")); + } + + if (true) { + MockSrsConfig conf; + EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listen -1935;")); + } +}