mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
refine main object(server, config, log, context), handler reload in intialize(), change to 0.9.59
This commit is contained in:
parent
7c64a893f5
commit
b38df9cd1a
8 changed files with 90 additions and 63 deletions
|
@ -350,7 +350,7 @@ class RESTServers(object):
|
|||
if rtmp_url is None:
|
||||
return "meeting stream not found"
|
||||
urls = rtmp_url.replace("...vhost...", "?vhost=").replace("rtmp://", "").split("/")
|
||||
hls_url = "http://%s:8080/%s/%s.m3u8"%(urls[0].replace(":1935",""), urls[1].split("?")[0], urls[2])
|
||||
hls_url = "http://%s:8080/%s/%s.m3u8"%(urls[0].strip(":19350").strip(":1935"), urls[1].split("?")[0], urls[2])
|
||||
return """
|
||||
<video width="640" height="360"
|
||||
autoplay controls autobuffer
|
||||
|
|
|
@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <fcntl.h>
|
||||
|
||||
#include <srs_app_config.hpp>
|
||||
#include <srs_kernel_error.hpp>
|
||||
|
||||
SrsThreadContext::SrsThreadContext()
|
||||
{
|
||||
|
@ -65,8 +66,6 @@ SrsFastLog::SrsFastLog()
|
|||
log_data = new char[LOG_MAX_SIZE];
|
||||
|
||||
fd = -1;
|
||||
|
||||
// TODO: support reload.
|
||||
}
|
||||
|
||||
SrsFastLog::~SrsFastLog()
|
||||
|
@ -79,6 +78,12 @@ SrsFastLog::~SrsFastLog()
|
|||
}
|
||||
}
|
||||
|
||||
int SrsFastLog::initialize()
|
||||
{
|
||||
// TODO: support reload.
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int SrsFastLog::level()
|
||||
{
|
||||
return _level;
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
SrsFastLog();
|
||||
virtual ~SrsFastLog();
|
||||
public:
|
||||
virtual int initialize();
|
||||
virtual int level();
|
||||
virtual void set_level(int level);
|
||||
virtual void verbose(const char* tag, int context_id, const char* fmt, ...);
|
||||
|
|
|
@ -160,9 +160,6 @@ SrsServer::SrsServer()
|
|||
signal_reload = false;
|
||||
signal_gmc_stop = false;
|
||||
|
||||
srs_assert(_srs_config);
|
||||
_srs_config->subscribe(this);
|
||||
|
||||
// donot new object in constructor,
|
||||
// for some global instance is not ready now,
|
||||
// new these objects in initialize instead.
|
||||
|
@ -208,6 +205,12 @@ int SrsServer::initialize()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// for the main objects(server, config, log),
|
||||
// never subscribe handler in constructor,
|
||||
// instead, subscribe handler in initialize method.
|
||||
srs_assert(_srs_config);
|
||||
_srs_config->subscribe(this);
|
||||
|
||||
#ifdef SRS_HTTP_API
|
||||
srs_assert(!http_api_handler);
|
||||
http_api_handler = SrsHttpHandler::create_http_api();
|
||||
|
|
|
@ -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 "58"
|
||||
#define VERSION_REVISION "59"
|
||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "srs"
|
||||
|
|
|
@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
||||
#include <srs_kernel_error.hpp>
|
||||
|
||||
ISrsLog::ISrsLog()
|
||||
{
|
||||
}
|
||||
|
@ -31,6 +33,11 @@ ISrsLog::~ISrsLog()
|
|||
{
|
||||
}
|
||||
|
||||
int ISrsLog::initialize()
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsLog::level()
|
||||
{
|
||||
return SrsLogLevel::Trace;
|
||||
|
|
|
@ -62,6 +62,11 @@ class ISrsLog
|
|||
public:
|
||||
ISrsLog();
|
||||
virtual ~ISrsLog();
|
||||
public:
|
||||
/**
|
||||
* initialize log utilities.
|
||||
*/
|
||||
virtual int initialize();
|
||||
public:
|
||||
/**
|
||||
* defined in SrsLogLevel.
|
||||
|
|
|
@ -55,38 +55,61 @@ void handler(int signo)
|
|||
_srs_server->on_signal(signo);
|
||||
}
|
||||
|
||||
int run_master()
|
||||
int run();
|
||||
int run_master();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
signal(SIGNAL_RELOAD, handler);
|
||||
signal(SIGTERM, handler);
|
||||
signal(SIGINT, handler);
|
||||
// TODO: support both little and big endian.
|
||||
srs_assert(srs_is_little_endian());
|
||||
|
||||
#ifdef SRS_GPERF_MP
|
||||
HeapProfilerStart("gperf.srs.gmp");
|
||||
#endif
|
||||
#ifdef SRS_GPERF_CP
|
||||
ProfilerStart("gperf.srs.gcp");
|
||||
#endif
|
||||
|
||||
#ifdef SRS_GPERF_MC
|
||||
#ifdef SRS_GPERF_MP
|
||||
srs_error("option --with-gmc confict with --with-gmp, "
|
||||
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\n"
|
||||
"Note that since the heap-checker uses the heap-profiling framework internally, "
|
||||
"it is not possible to run both the heap-checker and heap profiler at the same time");
|
||||
return -1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ((ret = _srs_server->acquire_pid_file()) != ERROR_SUCCESS) {
|
||||
// never use srs log(srs_trace, srs_error, etc) before config parse the option,
|
||||
// which will load the log config and apply it.
|
||||
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) {
|
||||
// config parsed, initialize log.
|
||||
if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
_srs_log->set_level(srs_get_log_level(_srs_config->get_srs_log_level()));
|
||||
|
||||
srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION);
|
||||
srs_trace("uname: "SRS_UNAME);
|
||||
srs_trace("build: %s, %s", SRS_BUILD_DATE, srs_is_little_endian()? "little-endian":"big-endian");
|
||||
srs_trace("configure: "SRS_CONFIGURE);
|
||||
#ifdef SRS_ARM_UBUNTU12
|
||||
srs_trace("arm tool chain: "SRS_ARM_TOOL_CHAIN);
|
||||
#endif
|
||||
|
||||
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->listen()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->ingest()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->cycle()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return run();
|
||||
}
|
||||
|
||||
int run()
|
||||
int run()
|
||||
{
|
||||
// if not deamon, directly run master.
|
||||
if (!_srs_config->get_deamon()) {
|
||||
|
@ -133,50 +156,33 @@ int run()
|
|||
return run_master();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int run_master()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// TODO: support both little and big endian.
|
||||
srs_assert(srs_is_little_endian());
|
||||
|
||||
#ifdef SRS_GPERF_MP
|
||||
HeapProfilerStart("gperf.srs.gmp");
|
||||
#endif
|
||||
#ifdef SRS_GPERF_CP
|
||||
ProfilerStart("gperf.srs.gcp");
|
||||
#endif
|
||||
|
||||
#ifdef SRS_GPERF_MC
|
||||
#ifdef SRS_GPERF_MP
|
||||
srs_error("option --with-gmc confict with --with-gmp, "
|
||||
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html\n"
|
||||
"Note that since the heap-checker uses the heap-profiling framework internally, "
|
||||
"it is not possible to run both the heap-checker and heap profiler at the same time");
|
||||
return -1;
|
||||
#endif
|
||||
#endif
|
||||
signal(SIGNAL_RELOAD, handler);
|
||||
signal(SIGTERM, handler);
|
||||
signal(SIGINT, handler);
|
||||
|
||||
// never use srs log(srs_trace, srs_error, etc) before config parse the option,
|
||||
// which will load the log config and apply it.
|
||||
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
|
||||
if ((ret = _srs_server->acquire_pid_file()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// config parsed, initialize log.
|
||||
_srs_log->set_level(srs_get_log_level(_srs_config->get_srs_log_level()));
|
||||
|
||||
srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION);
|
||||
srs_trace("uname: "SRS_UNAME);
|
||||
srs_trace("build: %s, %s", SRS_BUILD_DATE, srs_is_little_endian()? "little-endian":"big-endian");
|
||||
srs_trace("configure: "SRS_CONFIGURE);
|
||||
#ifdef SRS_ARM_UBUNTU12
|
||||
srs_trace("arm tool chain: "SRS_ARM_TOOL_CHAIN);
|
||||
#endif
|
||||
|
||||
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) {
|
||||
if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return run();
|
||||
if ((ret = _srs_server->listen()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->ingest()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->cycle()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue