From f572531eca7dee35c34e782ed5b8cc23e172ead6 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 18 Jul 2014 10:35:31 +0800 Subject: [PATCH] refine config, return the vhosts vector. --- trunk/src/app/srs_app_config.cpp | 6 +++++- trunk/src/app/srs_app_config.hpp | 37 +++++++++++++++++++++++--------- trunk/src/app/srs_app_ingest.cpp | 3 +-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 04d012e19..924ac1a52 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1412,10 +1412,12 @@ SrsConfDirective* SrsConfig::get_vhost(string vhost) return NULL; } -void SrsConfig::get_vhosts(std::vector& vhosts) +vector SrsConfig::get_vhosts() { srs_assert(root); + std::vector vhosts; + for (int i = 0; i < (int)root->directives.size(); i++) { SrsConfDirective* conf = root->at(i); @@ -1425,6 +1427,8 @@ void SrsConfig::get_vhosts(std::vector& vhosts) vhosts.push_back(conf); } + + return vhosts; } SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 5a34c27d9..e4fe4566b 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -366,44 +366,61 @@ public: */ virtual std::vector get_listen(); /** - * + * get the pid file path. + * the pid file is used to save the pid of SRS, + * use file lock to prevent multiple SRS starting. + * @remark, if user need to run multiple SRS instance, + * for example, to start multiple SRS for multiple CPUs, + * user can use different pid file for each process. */ virtual std::string get_pid_file(); /** - * + * get the pithy print interval for publish, in ms, + * the publish(flash/FMLE) message print. */ virtual int get_pithy_print_publish(); /** - * + * get the pithy print interval for forwarder, in ms, + * the forwarder message print, for SRS forward stream to other servers. */ virtual int get_pithy_print_forwarder(); /** - * + * get the pithy print interval for encoder, in ms, + * the encoder message print, for FFMPEG transcoder. */ virtual int get_pithy_print_encoder(); /** - * + * get the pithy print interval for ingester, in ms, + * the ingest used FFMPEG, or your tools, to read and transcode other stream + * to RTMP to SRS. */ virtual int get_pithy_print_ingester(); /** - * + * get the pithy print interval for HLS, in ms, + * the HLS used for IOS/android/PC, SRS will mux RTMP to HLS. */ virtual int get_pithy_print_hls(); /** - * + * get the pithy print interval for Play, in ms, + * the play is client or edge playing RTMP stream */ virtual int get_pithy_print_play(); /** - * + * get the pithy print interval for edge, in ms, + * the edge will get stream from upnode. */ virtual int get_pithy_print_edge(); // vhost specified section public: + /** + * get the vhost directive by vhost name. + * @param vhost, the name of vhost to get. + */ virtual SrsConfDirective* get_vhost(std::string vhost); /** - * + * get all vhosts in config file. */ - virtual void get_vhosts(std::vector& vhosts); + virtual std::vector get_vhosts(); /** * */ diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index 16f80208f..9f472de01 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -215,8 +215,7 @@ int SrsIngester::parse() int ret = ERROR_SUCCESS; // parse ingesters - std::vector vhosts; - _srs_config->get_vhosts(vhosts); + std::vector vhosts = _srs_config->get_vhosts(); for (int i = 0; i < (int)vhosts.size(); i++) { SrsConfDirective* vhost = vhosts[i];