Skip to content

Commit

Permalink
Merge pull request #327 from wenjiegit/develop
Browse files Browse the repository at this point in the history
for ossrs#328, add hds supported.
  • Loading branch information
winlinvip committed Mar 11, 2015
2 parents a739b2c + 07d8f06 commit 03bcfd9
Show file tree
Hide file tree
Showing 8 changed files with 952 additions and 1 deletion.
19 changes: 19 additions & 0 deletions trunk/conf/hds.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# the config for srs to delivery hds
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SampleHDS
# @see full.conf for detail config.

listen 1935;
max_connections 1000;

daemon off;
srs_log_tank console;
srs_log_level trace;

vhost __defaultVhost__ {
hds {
enabled on;
hds_fragment 10;
hds_window 60;
hds_path ./objs/nginx/html;
}
}
80 changes: 80 additions & 0 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ int SrsConfig::check_config()
&& n != "mr" && n != "mw_latency" && n != "min_latency"
&& n != "security" && n != "http_remux"
&& n != "http" && n != "http_static"
&& n != "hds"
) {
ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported vhost directive %s, ret=%d", n.c_str(), ret);
Expand Down Expand Up @@ -3277,6 +3278,85 @@ string SrsConfig::get_hls_vcodec(string vhost)
return conf->arg0();
}

SrsConfDirective *SrsConfig::get_hds(const string &vhost)
{
SrsConfDirective* conf = get_vhost(vhost);

if (!conf) {
return NULL;
}

return conf->get("hds");
}

bool SrsConfig::get_hds_enabled(const string &vhost)
{
SrsConfDirective* hds = get_hds(vhost);

if (!hds) {
return false;
}

SrsConfDirective* conf = hds->get("enabled");

if (!conf) {
return false;
}

return conf->arg0() == "on";
}

string SrsConfig::get_hds_path(const string &vhost)
{
SrsConfDirective* hds = get_hds(vhost);

if (!hds) {
return SRS_CONF_DEFAULT_HDS_PATH;
}

SrsConfDirective* conf = hds->get("hds_path");

if (!conf) {
return SRS_CONF_DEFAULT_HDS_PATH;
}

return conf->arg0();
}

double SrsConfig::get_hds_fragment(const string &vhost)
{
SrsConfDirective* hds = get_hds(vhost);

if (!hds) {
return SRS_CONF_DEFAULT_HDS_FRAGMENT;
}

SrsConfDirective* conf = hds->get("hds_fragment");

if (!conf) {
return SRS_CONF_DEFAULT_HDS_FRAGMENT;
}

return ::atof(conf->arg0().c_str());
}

double SrsConfig::get_hds_window(const string &vhost)
{
SrsConfDirective* hds = get_hds(vhost);

if (!hds) {
return SRS_CONF_DEFAULT_HDS_WINDOW;
}

SrsConfDirective* conf = hds->get("hds_window");

if (!conf) {
return SRS_CONF_DEFAULT_HDS_WINDOW;
}

return ::atof(conf->arg0().c_str());
}

SrsConfDirective* SrsConfig::get_dvr(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);
Expand Down
33 changes: 32 additions & 1 deletion trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"

// hds default value
#define SRS_CONF_DEFAULT_HDS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HDS_WINDOW (60)
#define SRS_CONF_DEFAULT_HDS_FRAGMENT (10)

namespace _srs_internal
{
class SrsConfigBuffer;
};
}

/**
* the config directive.
Expand Down Expand Up @@ -903,6 +908,32 @@ class SrsConfig
* get the HLS default video codec.
*/
virtual std::string get_hls_vcodec(std::string vhost);

// hds section
private:
/**
* get the hds directive of vhost.
*/
virtual SrsConfDirective* get_hds(const std::string &vhost);
public:
/**
* whether HDS is enabled.
*/
virtual bool get_hds_enabled(const std::string &vhost);
/**
* get the HDS file store path.
*/
virtual std::string get_hds_path(const std::string &vhost);
/**
* get the hds fragment time, in seconds.
*/
virtual double get_hds_fragment(const std::string &vhost);
/**
* get the hds window time, in seconds.
* a window is a set of hds fragments.
*/
virtual double get_hds_window(const std::string &vhost);

// dvr section
private:
/**
Expand Down
Loading

0 comments on commit 03bcfd9

Please sign in to comment.