mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #126, srs_publiser add warnings. refine config utest.
This commit is contained in:
parent
b17c736f3f
commit
7241fa8744
8 changed files with 84 additions and 8 deletions
|
@ -42,6 +42,13 @@ int main(int argc, char** argv)
|
||||||
printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
|
printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
|
||||||
printf("srs(simple-rtmp-server) client librtmp library.\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());
|
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");
|
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
|
||||||
|
|
||||||
|
|
|
@ -80,17 +80,21 @@ SrsFastLog::~SrsFastLog()
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_srs_config->unsubscribe(this);
|
if (_srs_config) {
|
||||||
|
_srs_config->unsubscribe(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsFastLog::initialize()
|
int SrsFastLog::initialize()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
_srs_config->subscribe(this);
|
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());
|
log_to_file_tank = _srs_config->get_log_tank_file();
|
||||||
|
_level = srs_get_log_level(_srs_config->get_log_level());
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsFastLog : public ISrsLog, public ISrsReloadHandler
|
class SrsFastLog : public ISrsLog, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
// for utest to override
|
||||||
|
protected:
|
||||||
// defined in SrsLogLevel.
|
// defined in SrsLogLevel.
|
||||||
int _level;
|
int _level;
|
||||||
char* log_data;
|
char* log_data;
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "9"
|
#define VERSION_MINOR "9"
|
||||||
#define VERSION_REVISION "171"
|
#define VERSION_REVISION "172"
|
||||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
static const int Trace = 0x03;
|
static const int Trace = 0x03;
|
||||||
static const int Warn = 0x04;
|
static const int Warn = 0x04;
|
||||||
static const int Error = 0x05;
|
static const int Error = 0x05;
|
||||||
|
// specified the disabled level, no log, for utest.
|
||||||
|
static const int Disabled = 0x06;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,12 +30,36 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_app_log.hpp>
|
#include <srs_app_log.hpp>
|
||||||
|
|
||||||
// kernel module.
|
// kernel module.
|
||||||
ISrsLog* _srs_log = new ISrsLog();
|
ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Disabled);
|
||||||
ISrsThreadContext* _srs_context = new ISrsThreadContext();
|
ISrsThreadContext* _srs_context = new ISrsThreadContext();
|
||||||
// app module.
|
// app module.
|
||||||
SrsConfig* _srs_config = NULL;
|
SrsConfig* _srs_config = NULL;
|
||||||
SrsServer* _srs_server = 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)
|
void __srs_bytes_print(char* pa, int size)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < size; i++) {
|
for(int i = 0; i < size; i++) {
|
||||||
|
|
|
@ -31,6 +31,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include <srs_app_log.hpp>
|
||||||
|
|
||||||
// we add an empty macro for upp to show the smart tips.
|
// we add an empty macro for upp to show the smart tips.
|
||||||
#define VOID
|
#define VOID
|
||||||
|
|
||||||
|
@ -52,4 +54,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// print the bytes.
|
// print the bytes.
|
||||||
void __srs_bytes_print(char* pa, int size);
|
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
|
#endif
|
||||||
|
|
|
@ -4341,3 +4341,26 @@ VOID TEST(ConfigMainTest, ParseFullConf_removed)
|
||||||
EXPECT_STREQ("/", conf.get_vhost_http_mount(vhost).c_str());
|
EXPECT_STREQ("/", conf.get_vhost_http_mount(vhost).c_str());
|
||||||
EXPECT_STREQ("./objs/nginx/html", conf.get_vhost_http_dir(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;"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue