1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

add consts to kernel

This commit is contained in:
winlin 2014-07-20 13:04:48 +08:00
parent 24a041266c
commit 073d900674
13 changed files with 337 additions and 29 deletions

View file

@ -1143,8 +1143,8 @@ void SrsConfig::print_help(char** argv)
"\n"
"For example:\n"
" %s -v\n"
" %s -t -c "SRS_DEFAULT_CONF"\n"
" %s -c "SRS_DEFAULT_CONF"\n",
" %s -t -c "SRS_CONF_DEFAULT_COFNIG_FILE"\n"
" %s -c "SRS_CONF_DEFAULT_COFNIG_FILE"\n",
argv[0], argv[0], argv[0], argv[0]);
}
@ -1968,12 +1968,12 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* engine)
string SrsConfig::get_engine_iformat(SrsConfDirective* engine)
{
if (!engine) {
return "flv";
return SRS_CONF_DEFAULT_TRANSCODE_IFORMAT;
}
SrsConfDirective* conf = engine->get("iformat");
if (!conf) {
return "flv";
return SRS_CONF_DEFAULT_TRANSCODE_IFORMAT;
}
return conf->arg0();
@ -2228,12 +2228,12 @@ vector<string> SrsConfig::get_engine_aparams(SrsConfDirective* engine)
string SrsConfig::get_engine_oformat(SrsConfDirective* engine)
{
if (!engine) {
return "flv";
return SRS_CONF_DEFAULT_TRANSCODE_OFORMAT;
}
SrsConfDirective* conf = engine->get("oformat");
if (!conf) {
return "flv";
return SRS_CONF_DEFAULT_TRANSCODE_OFORMAT;
}
return conf->arg0();
@ -2346,7 +2346,7 @@ string SrsConfig::get_log_file()
SrsConfDirective* conf = root->get("srs_log_file");
if (!conf || conf->arg0().empty()) {
return "./objs/srs.log";
return SRS_CONF_DEFAULT_LOG_FILE;
}
return conf->arg0();
@ -2355,7 +2355,7 @@ string SrsConfig::get_log_file()
bool SrsConfig::get_ffmpeg_log_enabled()
{
string log = get_ffmpeg_log_dir();
return log != "/dev/null";
return log != SRS_CONSTS_NULL_FILE;
}
string SrsConfig::get_ffmpeg_log_dir()
@ -2364,7 +2364,7 @@ string SrsConfig::get_ffmpeg_log_dir()
SrsConfDirective* conf = root->get("ff_log_dir");
if (!conf || conf->arg0().empty()) {
return "./objs";
return SRS_CONF_DEFAULT_FF_LOG_DIR;
}
return conf->arg0();
@ -2376,7 +2376,7 @@ string SrsConfig::get_log_level()
SrsConfDirective* conf = root->get("srs_log_level");
if (!conf || conf->arg0().empty()) {
return "trace";
return SRS_CONF_DEFAULT_LOG_LEVEL;
}
return conf->arg0();
@ -2387,7 +2387,7 @@ bool SrsConfig::get_log_tank_file()
srs_assert(root);
SrsConfDirective* conf = root->get("srs_log_tank");
if (conf && conf->arg0() == "console") {
if (conf && conf->arg0() == SRS_CONF_DEFAULT_LOG_TANK_CONSOLE) {
return false;
}

View file

@ -34,9 +34,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_reload.hpp>
#define SRS_LOCALHOST "127.0.0.1"
///////////////////////////////////////////////////////////
// the value consts
///////////////////////////////////////////////////////////
#define SRS_CONSTS_NULL_FILE "/dev/null"
#define SRS_CONSTS_LOCALHOST "127.0.0.1"
///////////////////////////////////////////////////////////
// default consts values
///////////////////////////////////////////////////////////
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
#define SRS_DEFAULT_CONF "conf/srs.conf"
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 12345
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
@ -67,7 +79,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://127.0.0.1:8085/api/v1/servers"
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INDEX 0
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
@ -82,6 +94,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_AUTO_INGEST_TYPE_FILE "file"
#define SRS_AUTO_INGEST_TYPE_STREAM "stream"
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
namespace _srs_internal
{
class SrsConfigBuffer;
@ -687,7 +702,7 @@ public:
*/
virtual std::string get_engine_oformat(SrsConfDirective* engine);
/**
* get the output of engine, for example, rtmp://127.0.0.1/live/livestream,
* get the output of engine, for example, rtmp://localhost/live/livestream,
* @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
*/
virtual std::string get_engine_output(SrsConfDirective* engine);

View file

@ -261,8 +261,10 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir
std::string input;
// input stream, from local.
// ie. rtmp://127.0.0.1:1935/live/livestream
input = "rtmp://127.0.0.1:";
// ie. rtmp://localhost:1935/live/livestream
input = "rtmp://";
input += SRS_CONSTS_LOCALHOST;
input += ":";
input += req->port;
input += "/";
input += req->app;
@ -280,14 +282,14 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir
std::string output = _srs_config->get_engine_output(engine);
// output stream, to other/self server
// ie. rtmp://127.0.0.1:1935/live/livestream_sd
// ie. rtmp://localhost:1935/live/livestream_sd
output = srs_string_replace(output, "[vhost]", req->vhost);
output = srs_string_replace(output, "[port]", req->port);
output = srs_string_replace(output, "[app]", req->app);
output = srs_string_replace(output, "[stream]", req->stream);
output = srs_string_replace(output, "[engine]", engine->arg0());
std::string log_file = "/dev/null"; // disabled
std::string log_file = SRS_CONSTS_NULL_FILE; // disabled
// write ffmpeg info to log file.
if (_srs_config->get_ffmpeg_log_enabled()) {
log_file = _srs_config->get_ffmpeg_log_dir();

View file

@ -111,7 +111,7 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server)
source_ep += req->vhost;
std::string dest_ep = "rtmp://";
if (forward_server == "127.0.0.1") {
if (forward_server == SRS_CONSTS_LOCALHOST) {
dest_ep += req->host;
} else {
dest_ep += forward_server;

View file

@ -235,7 +235,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
std::string output = _srs_config->get_engine_output(engine);
// output stream, to other/self server
// ie. rtmp://127.0.0.1:1935/live/livestream_sd
// ie. rtmp://localhost:1935/live/livestream_sd
output = srs_string_replace(output, "[vhost]", vhost->arg0());
output = srs_string_replace(output, "[port]", port);
if (output.empty()) {
@ -260,7 +260,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
app = app.substr(0, pos);
}
std::string log_file = "/dev/null"; // disabled
std::string log_file = SRS_CONSTS_NULL_FILE; // disabled
// write ffmpeg info to log file.
if (_srs_config->get_ffmpeg_log_enabled()) {
log_file = _srs_config->get_ffmpeg_log_dir();

View file

@ -37,8 +37,6 @@ using namespace std;
#include <srs_app_kbps.hpp>
#include <srs_app_json.hpp>
#define SRS_LOCAL_LOOP_IP "127.0.0.1"
int srs_socket_connect(std::string server, int port, int64_t timeout, st_netfd_t* pstfd)
{
int ret = ERROR_SUCCESS;
@ -707,7 +705,7 @@ void retrieve_local_ipv4_ips()
}
std::string ip = buf;
if (ip != SRS_LOCAL_LOOP_IP) {
if (ip != SRS_CONSTS_LOCALHOST) {
srs_trace("retrieve local ipv4 addresses: %s", ip.c_str());
ips.push_back(ip);
}