本文整理汇总了C++中SrsConfDirective::arg0方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsConfDirective::arg0方法的具体用法?C++ SrsConfDirective::arg0怎么用?C++ SrsConfDirective::arg0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsConfDirective
的用法示例。
在下文中一共展示了SrsConfDirective::arg0方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_transcode
int SrsEncoder::parse_transcode(SrsConfDirective* conf)
{
int ret = ERROR_SUCCESS;
srs_assert(conf);
// enabled
if (!config->get_transcode_enabled(conf)) {
srs_trace("ignore the disabled transcode: %s",
conf->arg0().c_str());
return ret;
}
// ffmpeg
std::string ffmpeg_bin = config->get_transcode_ffmpeg(conf);
if (ffmpeg_bin.empty()) {
srs_trace("ignore the empty ffmpeg transcode: %s",
conf->arg0().c_str());
return ret;
}
// get all engines.
std::vector<SrsConfDirective*> engines;
config->get_transcode_engines(conf, engines);
if (engines.empty()) {
srs_trace("ignore the empty transcode engine: %s",
conf->arg0().c_str());
return ret;
}
// create engine
for (int i = 0; i < (int)engines.size(); i++) {
SrsConfDirective* engine = engines[i];
if (!config->get_engine_enabled(engine)) {
srs_trace("ignore the diabled transcode engine: %s %s",
conf->arg0().c_str(), engine->arg0().c_str());
continue;
}
SrsFFMPEG* ffmpeg = new SrsFFMPEG(ffmpeg_bin);
if ((ret = ffmpeg->initialize(vhost, port, app, stream, engine)) != ERROR_SUCCESS) {
srs_freep(ffmpeg);
// if got a loop, donot transcode the whole stream.
if (ret == ERROR_ENCODER_LOOP) {
clear_engines();
break;
}
srs_error("invalid transcode engine: %s %s",
conf->arg0().c_str(), engine->arg0().c_str());
return ret;
}
ffmpegs.push_back(ffmpeg);
}
return ret;
}
示例2: parse_ffmpeg
int SrsEncoder::parse_ffmpeg(SrsRequest* req, SrsConfDirective* conf)
{
int ret = ERROR_SUCCESS;
srs_assert(conf);
// enabled
if (!_srs_config->get_transcode_enabled(conf)) {
srs_trace("ignore the disabled transcode: %s",
conf->arg0().c_str());
return ret;
}
// ffmpeg
std::string ffmpeg_bin = _srs_config->get_transcode_ffmpeg(conf);
if (ffmpeg_bin.empty()) {
srs_trace("ignore the empty ffmpeg transcode: %s",
conf->arg0().c_str());
return ret;
}
// get all engines.
std::vector<SrsConfDirective*> engines = _srs_config->get_transcode_engines(conf);
if (engines.empty()) {
srs_trace("ignore the empty transcode engine: %s",
conf->arg0().c_str());
return ret;
}
// create engine
for (int i = 0; i < (int)engines.size(); i++) {
SrsConfDirective* engine = engines[i];
if (!_srs_config->get_engine_enabled(engine)) {
srs_trace("ignore the diabled transcode engine: %s %s",
conf->arg0().c_str(), engine->arg0().c_str());
continue;
}
SrsFFMPEG* ffmpeg = new SrsFFMPEG(ffmpeg_bin);
if ((ret = initialize_ffmpeg(ffmpeg, req, engine)) != ERROR_SUCCESS) {
srs_freep(ffmpeg);
if (ret != ERROR_ENCODER_LOOP) {
srs_error("invalid transcode engine: %s %s", conf->arg0().c_str(), engine->arg0().c_str());
}
return ret;
}
ffmpegs.push_back(ffmpeg);
}
return ret;
}
示例3: initialize_hls_streaming
int SrsHttpStreamServer::initialize_hls_streaming()
{
int ret = ERROR_SUCCESS;
// http hls live stream mount for each vhost.
SrsConfDirective* root = _srs_config->get_root();
for (int i = 0; i < (int)root->directives.size(); i++) {
SrsConfDirective* conf = root->at(i);
if (!conf->is_vhost()) {
continue;
}
std::string vhost = conf->arg0();
if (!_srs_config->get_hls_enabled(vhost)) {
continue;
}
std::string storage = _srs_config->get_hls_storage(vhost);
if (storage != "ram" && storage != "both") {
continue;
}
SrsHlsEntry* entry = new SrsHlsEntry();
entry->mount = _srs_config->get_hls_mount(vhost);
thls[vhost] = entry;
srs_trace("http hls live stream, vhost=%s, mount=%s",
vhost.c_str(), entry->mount.c_str());
}
return ret;
}
示例4: initialize
int SrsHttpStaticServer::initialize()
{
int ret = ERROR_SUCCESS;
bool default_root_exists = false;
// http static file and flv vod stream mount for each vhost.
SrsConfDirective* root = _srs_config->get_root();
for (int i = 0; i < (int)root->directives.size(); i++) {
SrsConfDirective* conf = root->at(i);
if (!conf->is_vhost()) {
continue;
}
std::string vhost = conf->arg0();
if (!_srs_config->get_vhost_http_enabled(vhost)) {
continue;
}
std::string mount = _srs_config->get_vhost_http_mount(vhost);
std::string dir = _srs_config->get_vhost_http_dir(vhost);
// replace the vhost variable
mount = srs_string_replace(mount, "[vhost]", vhost);
// remove the default vhost mount
mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/");
// the dir mount must always ends with "/"
if (mount != "/" && mount.rfind("/") != mount.length() - 1) {
mount += "/";
}
// mount the http of vhost.
if ((ret = mux.handle(mount, new SrsVodStream(dir))) != ERROR_SUCCESS) {
srs_error("http: mount dir=%s for vhost=%s failed. ret=%d", dir.c_str(), vhost.c_str(), ret);
return ret;
}
if (mount == "/") {
default_root_exists = true;
srs_warn("http: root mount to %s", dir.c_str());
}
srs_trace("http: vhost=%s mount to %s", vhost.c_str(), mount.c_str());
}
if (!default_root_exists) {
// add root
std::string dir = _srs_config->get_http_stream_dir();
if ((ret = mux.handle("/", new SrsVodStream(dir))) != ERROR_SUCCESS) {
srs_error("http: mount root dir=%s failed. ret=%d", dir.c_str(), ret);
return ret;
}
srs_trace("http: root mount to %s", dir.c_str());
}
return ret;
}
示例5: allow_check
int SrsSecurity::allow_check(SrsConfDirective* rules, SrsRtmpConnType type, std::string ip)
{
int ret = ERROR_SUCCESS;
for (int i = 0; i < (int)rules->directives.size(); i++) {
SrsConfDirective* rule = rules->at(i);
if (rule->name != "allow") {
continue;
}
switch (type) {
case SrsRtmpConnPlay:
if (rule->arg0() != "play") {
break;
}
if (rule->arg1() == "all" || rule->arg1() == ip) {
ret = ERROR_SYSTEM_SECURITY_ALLOW;
break;
}
break;
case SrsRtmpConnFMLEPublish:
case SrsRtmpConnFlashPublish:
case SrsRtmpConnHaivisionPublish:
if (rule->arg0() != "publish") {
break;
}
if (rule->arg1() == "all" || rule->arg1() == ip) {
ret = ERROR_SYSTEM_SECURITY_ALLOW;
break;
}
break;
case SrsRtmpConnUnknown:
default:
break;
}
// when matched, donot search more.
if (ret == ERROR_SYSTEM_SECURITY_ALLOW) {
break;
}
}
return ret;
}
示例6: parse_engines
int SrsIngester::parse_engines(SrsConfDirective* vhost, SrsConfDirective* ingest)
{
int ret = ERROR_SUCCESS;
if (!_srs_config->get_ingest_enabled(ingest)) {
return ret;
}
std::string ffmpeg_bin = _srs_config->get_ingest_ffmpeg(ingest);
if (ffmpeg_bin.empty()) {
ret = ERROR_ENCODER_PARSE;
srs_trace("empty ffmpeg ret=%d", ret);
return ret;
}
// get all engines.
std::vector<SrsConfDirective*> engines;
_srs_config->get_transcode_engines(ingest, engines);
if (engines.empty()) {
SrsFFMPEG* ffmpeg = new SrsFFMPEG(ffmpeg_bin);
if ((ret = initialize_ffmpeg(ffmpeg, vhost, ingest, NULL)) != ERROR_SUCCESS) {
srs_freep(ffmpeg);
if (ret != ERROR_ENCODER_LOOP) {
srs_error("invalid ingest engine. ret=%d", ret);
}
return ret;
}
SrsIngesterFFMPEG* ingester = new SrsIngesterFFMPEG(ffmpeg, vhost->arg0(), ingest->arg0());
ingesters.push_back(ingester);
return ret;
}
// create engine
for (int i = 0; i < (int)engines.size(); i++) {
SrsConfDirective* engine = engines[i];
SrsFFMPEG* ffmpeg = new SrsFFMPEG(ffmpeg_bin);
if ((ret = initialize_ffmpeg(ffmpeg, vhost, ingest, engine)) != ERROR_SUCCESS) {
srs_freep(ffmpeg);
if (ret != ERROR_ENCODER_LOOP) {
srs_error("invalid ingest engine: %s %s, ret=%d",
ingest->arg0().c_str(), engine->arg0().c_str(), ret);
}
return ret;
}
SrsIngesterFFMPEG* ingester = new SrsIngesterFFMPEG(ffmpeg, vhost->arg0(), ingest->arg0());
ingesters.push_back(ingester);
}
return ret;
}
示例7: check_vhost
int SrsRtmpConn::check_vhost()
{
int ret = ERROR_SUCCESS;
srs_assert(req != NULL);
SrsConfDirective* vhost = _srs_config->get_vhost(req->vhost);
if (vhost == NULL) {
ret = ERROR_RTMP_VHOST_NOT_FOUND;
srs_error("vhost %s not found. ret=%d", req->vhost.c_str(), ret);
return ret;
}
if (!_srs_config->get_vhost_enabled(req->vhost)) {
ret = ERROR_RTMP_VHOST_NOT_FOUND;
srs_error("vhost %s disabled. ret=%d", req->vhost.c_str(), ret);
return ret;
}
if (req->vhost != vhost->arg0()) {
srs_trace("vhost change from %s to %s", req->vhost.c_str(), vhost->arg0().c_str());
req->vhost = vhost->arg0();
}
if ((ret = refer->check(req->pageUrl, _srs_config->get_refer(req->vhost))) != ERROR_SUCCESS) {
srs_error("check refer failed. ret=%d", ret);
return ret;
}
srs_verbose("check refer success.");
if ((ret = http_hooks_on_connect()) != ERROR_SUCCESS) {
return ret;
}
return ret;
}
示例8: initialize_flv_streaming
int SrsHttpStreamServer::initialize_flv_streaming()
{
int ret = ERROR_SUCCESS;
// http flv live stream mount for each vhost.
SrsConfDirective* root = _srs_config->get_root();
for (int i = 0; i < (int)root->directives.size(); i++) {
SrsConfDirective* conf = root->at(i);
if (!conf->is_vhost()) {
continue;
}
if ((ret = initialize_flv_entry(conf->arg0())) != ERROR_SUCCESS) {
return ret;
}
}
return ret;
}
示例9: initialize
int SrsHttpRoot::initialize()
{
int ret = ERROR_SUCCESS;
bool default_root_exists = false;
// add other virtual path
SrsConfDirective* root = _srs_config->get_root();
for (int i = 0; i < (int)root->directives.size(); i++) {
SrsConfDirective* conf = root->at(i);
if (!conf->is_vhost()) {
continue;
}
std::string vhost = conf->arg0();
if (!_srs_config->get_vhost_http_enabled(vhost)) {
continue;
}
std::string mount = _srs_config->get_vhost_http_mount(vhost);
std::string dir = _srs_config->get_vhost_http_dir(vhost);
handlers.push_back(new SrsHttpVhost(vhost, mount, dir));
if (mount == "/") {
default_root_exists = true;
}
}
if (!default_root_exists) {
// add root
handlers.push_back(new SrsHttpVhost(
"__http__", "/", _srs_config->get_http_stream_dir()));
}
return ret;
}
示例10: hijack
int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
{
int ret = ERROR_SUCCESS;
// when handler not the root, we think the handler is ok.
ISrsHttpHandler* h = *ph? *ph : NULL;
if (h && h->entry && h->entry->pattern != "/") {
return ret;
}
// only hijack for http streaming, http-flv/ts/mp3/aac.
std::string ext = request->ext();
if (ext.empty()) {
return ret;
}
// find the actually request vhost.
SrsConfDirective* vhost = _srs_config->get_vhost(request->host());
if (!vhost || !_srs_config->get_vhost_enabled(vhost)) {
return ret;
}
// find the entry template for the stream.
SrsLiveEntry* entry = NULL;
if (true) {
// no http streaming on vhost, ignore.
std::map<std::string, SrsLiveEntry*>::iterator it = tflvs.find(vhost->arg0());
if (it == tflvs.end()) {
return ret;
}
// hstrs not enabled, ignore.
// for origin, the http stream will be mount already when publish,
// so it must never enter this line for stream already mounted.
// for edge, the http stream is trigger by hstrs and mount by it,
// so we only hijack when only edge and hstrs is on.
entry = it->second;
if (!entry->hstrs) {
return ret;
}
// check entry and request extension.
if (entry->is_flv()) {
if (ext != ".flv") {
return ret;
}
} else if (entry->is_ts()) {
if (ext != ".ts") {
return ret;
}
} else if (entry->is_mp3()) {
if (ext != ".mp3") {
return ret;
}
} else if (entry->is_aac()) {
if (ext != ".aac") {
return ret;
}
} else {
return ret;
}
}
// convert to concreate class.
SrsHttpMessage* hreq = dynamic_cast<SrsHttpMessage*>(request);
srs_assert(hreq);
// hijack for entry.
SrsRequest* r = hreq->to_request(vhost->arg0());
SrsAutoFree(SrsRequest, r);
std::string sid = r->get_stream_url();
// check whether the http remux is enabled,
// for example, user disable the http flv then reload.
if (sflvs.find(sid) != sflvs.end()) {
SrsLiveEntry* s_entry = sflvs[sid];
if (!s_entry->stream->entry->enabled) {
// only when the http entry is disabled, check the config whether http flv disable,
// for the http flv edge use hijack to trigger the edge ingester, we always mount it
// eventhough the origin does not exists the specified stream.
if (!_srs_config->get_vhost_http_remux_enabled(r->vhost)) {
srs_error("stream is disabled, hijack failed. ret=%d", ret);
return ret;
}
}
}
SrsSource* s = SrsSource::fetch(r);
if (!s) {
if ((ret = SrsSource::create(r, server, server, &s)) != ERROR_SUCCESS) {
return ret;
}
}
srs_assert(s != NULL);
// create http streaming handler.
if ((ret = http_mount(s, r)) != ERROR_SUCCESS) {
return ret;
}
//.........这里部分代码省略.........
示例11: initialize_ffmpeg
int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, SrsConfDirective* ingest, SrsConfDirective* engine)
{
int ret = ERROR_SUCCESS;
SrsConfDirective* listen = _srs_config->get_listen();
srs_assert(listen->args.size() > 0);
std::string port = listen->arg0();
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
output = srs_string_replace(output, "[vhost]", vhost->arg0());
output = srs_string_replace(output, "[port]", port);
if (output.empty()) {
ret = ERROR_ENCODER_NO_OUTPUT;
srs_trace("empty output url, ingest=%s. ret=%d", ingest->arg0().c_str(), ret);
return ret;
}
// find the app and stream in rtmp url
std::string url = output;
std::string app, stream;
size_t pos = std::string::npos;
if ((pos = url.rfind("/")) != std::string::npos) {
stream = url.substr(pos + 1);
url = url.substr(0, pos);
}
if ((pos = url.rfind("/")) != std::string::npos) {
app = url.substr(pos + 1);
url = url.substr(0, pos);
}
if ((pos = app.rfind("?")) != std::string::npos) {
app = app.substr(0, pos);
}
std::string log_file;
// write ffmpeg info to log file.
log_file = _srs_config->get_ffmpeg_log_dir();
log_file += "/";
log_file += "ffmpeg-ingest";
log_file += "-";
log_file += vhost->arg0();
log_file += "-";
log_file += app;
log_file += "-";
log_file += stream;
log_file += ".log";
// input
std::string input_type = _srs_config->get_ingest_input_type(ingest);
if (input_type.empty()) {
ret = ERROR_ENCODER_NO_INPUT;
srs_trace("empty intput type, ingest=%s. ret=%d", ingest->arg0().c_str(), ret);
return ret;
}
if (input_type == SRS_AUTO_INGEST_TYPE_FILE) {
std::string input_url = _srs_config->get_ingest_input_url(ingest);
if (input_url.empty()) {
ret = ERROR_ENCODER_NO_INPUT;
srs_trace("empty intput url, ingest=%s. ret=%d", ingest->arg0().c_str(), ret);
return ret;
}
// for file, set re.
ffmpeg->set_iparams("-re");
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
return ret;
}
} else if (input_type == SRS_AUTO_INGEST_TYPE_STREAM) {
std::string input_url = _srs_config->get_ingest_input_url(ingest);
if (input_url.empty()) {
ret = ERROR_ENCODER_NO_INPUT;
srs_trace("empty intput url, ingest=%s. ret=%d", ingest->arg0().c_str(), ret);
return ret;
}
// for stream, no re.
ffmpeg->set_iparams("");
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
return ret;
}
} else {
ret = ERROR_ENCODER_INPUT_TYPE;
srs_error("invalid ingest=%s type=%s, ret=%d",
ingest->arg0().c_str(), input_type.c_str(), ret);
}
std::string vcodec = _srs_config->get_engine_vcodec(engine);
std::string acodec = _srs_config->get_engine_acodec(engine);
// whatever the engine config, use copy as default.
if (!engine || vcodec.empty() || acodec.empty()
|| !_srs_config->get_engine_enabled(engine)
) {
if ((ret = ffmpeg->initialize_copy()) != ERROR_SUCCESS) {
return ret;
}
} else {
//.........这里部分代码省略.........