Skip to content

Commit

Permalink
for ossrs#179, revert dvr http api. 2.0.128.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 1, 2015
1 parent 4505983 commit fb3fced
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 932 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,6 @@ Supported operating systems and hardware:
[#304](https://github.com/winlinvip/simple-rtmp-server/issues/304).
1. Support push RTSP to SRS, read
[#133](https://github.com/winlinvip/simple-rtmp-server/issues/133).
1. Support DVR http api, read
[#179](https://github.com/winlinvip/simple-rtmp-server/issues/179).
1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech).
1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/winlinvip/simple-rtmp-server/issues/92).
1. [no-plan] Support multiple processes, for both origin and edge
Expand Down Expand Up @@ -552,10 +550,9 @@ Supported operating systems and hardware:
## History

### SRS 2.0 history

* v2.0, 2015-02-24, for [#179](https://github.com/winlinvip/simple-rtmp-server/issues/179), dvr suport vhost/app/stream level control. 2.0.125.
* v2.0, 2015-02-24, for [#304](https://github.com/winlinvip/simple-rtmp-server/issues/304), fix hls bug, write pts/dts error. 2.0.124.
* v2.0, 2015-02-24, fix [#179](https://github.com/winlinvip/simple-rtmp-server/issues/179), support dvr http api. 2.0.123.
.
* v2.0, 2015-03-01, for [#179](https://github.com/winlinvip/simple-rtmp-server/issues/179), revert dvr http api. 2.0.128.
* v2.0, 2015-02-24, for [#304](https://github.com/winlinvip/simple-rtmp-server/issues/304), fix hls bug, write pts/dts error. 2.0.124
* v2.0, 2015-02-19, refine dvr, append file when dvr file exists. 2.0.122.
* v2.0, 2015-02-19, refine pithy print to more easyer to use. 2.0.121.
* v2.0, 2015-02-18, fix [#133](https://github.com/winlinvip/simple-rtmp-server/issues/133), support push rtsp to srs. 2.0.120.
Expand Down
56 changes: 2 additions & 54 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -288,52 +288,7 @@ vhost dvr.srs.com {
# session reap flv when session end(unpublish).
# segment reap flv when flv duration exceed the specified dvr_duration.
# append always append to flv file, never reap it.
# api reap flv when api required.
# about the api plan, the HTTP api to dvr,
# http url to control dvr, for example, http://dev:1985/api/v1/dvrs
# method=GET
# to query dvrs of server.
# request params, for example ?vhost=__defaultVhost__&&app=live&&stream=livestream, where:
# vhost, <required>, query all dvr of this vhost.
# app, [optinal], query all dvr of this app. query all app if not specified.
# stream, [optional], query specified dvr stream. query all stream if not specified.
# response in json, where:
# {code:0, dvrs: [{path_tmpl:"./[15].[04].[05].[999].flv", path_dvr:"./22.7.43.312.flv",
# vhost:"__defaultVhost", app:"live", stream:"livestream",
# wait_keyframe:true, callback:"http://127.0.0.1:8085/api/v1/dvrs",
# status:"stop"|"start"
# }]}
# method=POST
# to start dvr of specified vhost.
# request should encode in json, specifies the dvr to create, where:
# {path_tmpl:"./[15].[04].[05].[999].flv",
# vhost:"__defaultVhost", app:"live", stream:"livestream",
# wait_keyframe:true, callback:"http://127.0.0.1:8085/api/v1/dvrs"
# }
# @remark, the app and stream is required for POST.
# response in json, where:
# {code:0}
# method=DELETE, to stop dvr
# to stop dvr of specified vhost.
# request params, for example ?vhost=__defaultVhost__, where:
# vhost, stop all dvr of this vhost.
# response in json, where:
# {code:0}
# method=PUT, use as RPC(remote process call).
# reap_segment, the request params in json, where:
# {action:"reap_segment", vhost:"__defaultVhost", app:"live", stream:"livestream",
# path_tmpl:"./[15].[04].[05].[999].flv"
# }
# @remark, the app and stream is optional.
# when reap segment, the callback POST request in json:
# {action:"on_dvr_reap_segment", client_id:100, vhost:"__defaultVhost__",
# app:"live", stream:"livestream", cwd:"/home/winlin/srs", file:"./dvr.flv"
# }
# for the dvr http callback, @see http_hooks.on_dvr of vhost hooks.callback.srs.com
# @read https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DVR#http-callback
# @read https://github.com/winlinvip/simple-rtmp-server/wiki/v2_EN_DVR#http-callback
# default: session
# TODO: FIXME: update wiki for the api plan.
dvr_plan session;
# the dvr output path.
# we supports some variables to generate the filename.
Expand Down Expand Up @@ -369,27 +324,20 @@ vhost dvr.srs.com {
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DVR#custom-path
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/v2_EN_DVR#custom-path
# segment,session apply it.
# api apply before api specified the path.
# default: ./objs/nginx/html
dvr_path ./objs/nginx/html;
# the duration for dvr file, reap if exeed, in seconds.
# segment apply it.
# session,api ignore.
# session,append ignore.
# default: 30
dvr_duration 30;
# whether wait keyframe to reap segment,
# if off, reap segment when duration exceed the dvr_duration,
# if on, reap segment when duration exceed and got keyframe.
# segment apply it.
# session,api ignore.
# session,append ignore.
# default: on
dvr_wait_keyframe on;
# whether dvr auto start when publish.
# if off, dvr wait for api to start it.
# api apply it.
# segment,session ignore.
# default: on
dvr_autostart on;
# about the stream monotonically increasing:
# 1. video timestamp is monotonically increasing,
# 2. audio timestamp is monotonically increasing,
Expand Down
95 changes: 0 additions & 95 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,6 @@ int SrsConfig::check_config()
string m = conf->at(j)->name.c_str();
if (m != "enabled" && m != "dvr_path" && m != "dvr_plan"
&& m != "dvr_duration" && m != "dvr_wait_keyframe" && m != "time_jitter"
&& m != "dvr_autostart"
) {
ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported vhost dvr directive %s, ret=%d", m.c_str(), ret);
Expand Down Expand Up @@ -1977,41 +1976,6 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* sc)
return ::atoi(conf->arg0().c_str());
}

SrsConfDirective* SrsConfig::create_directive(string vhost, string directive, string sub_directive)
{
SrsConfDirective* vhost_conf = get_vhost(vhost);

if (!vhost_conf) {
vhost_conf = new SrsConfDirective();
vhost_conf->name = vhost;
root->directives.push_back(vhost_conf);
}

if (directive.empty()) {
return vhost_conf;
}

SrsConfDirective* dir = vhost_conf->get(directive);
if (!dir) {
dir = new SrsConfDirective();
dir->name = directive;
vhost_conf->directives.push_back(dir);
}

if (sub_directive.empty()) {
return dir;
}

SrsConfDirective* sdir = dir->get(sub_directive);
if (!sdir) {
sdir = new SrsConfDirective();
sdir->name = sub_directive;
dir->directives.push_back(sdir);
}

return sdir;
}

SrsConfDirective* SrsConfig::get_vhost(string vhost)
{
srs_assert(root);
Expand Down Expand Up @@ -2355,13 +2319,6 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
return true;
}

void SrsConfig::set_vhost_http_hooks_enabled(string vhost, bool enabled)
{
SrsConfDirective* conf = create_directive(vhost, "http_hooks", "enabled");
conf->args.clear();
conf->args.push_back(enabled? "on":"off");
}

SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
{
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
Expand Down Expand Up @@ -2439,13 +2396,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost)
return conf->get("on_dvr");
}

void SrsConfig::set_vhost_on_dvr(string vhost, string callback)
{
SrsConfDirective* conf = create_directive(vhost, "http_hooks", "on_dvr");
conf->args.clear();
conf->args.push_back(callback);
}

bool SrsConfig::get_bw_check_enabled(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);
Expand Down Expand Up @@ -3359,13 +3309,6 @@ bool SrsConfig::get_dvr_enabled(string vhost)
return false;
}

void SrsConfig::set_dvr_enabled(string vhost, bool enabled)
{
SrsConfDirective* conf = create_directive(vhost, "dvr", "enabled");
conf->args.clear();
conf->args.push_back(enabled? "on":"off");
}

string SrsConfig::get_dvr_path(string vhost)
{
SrsConfDirective* dvr = get_dvr(vhost);
Expand All @@ -3383,13 +3326,6 @@ string SrsConfig::get_dvr_path(string vhost)
return conf->arg0();
}

void SrsConfig::set_dvr_path(string vhost, string path)
{
SrsConfDirective* conf = create_directive(vhost, "dvr", "dvr_path");
conf->args.clear();
conf->args.push_back(path);
}

string SrsConfig::get_dvr_plan(string vhost)
{
SrsConfDirective* dvr = get_dvr(vhost);
Expand All @@ -3407,13 +3343,6 @@ string SrsConfig::get_dvr_plan(string vhost)
return conf->arg0();
}

void SrsConfig::set_dvr_plan(string vhost, string plan)
{
SrsConfDirective* conf = create_directive(vhost, "dvr", "dvr_plan");
conf->args.clear();
conf->args.push_back(plan);
}

int SrsConfig::get_dvr_duration(string vhost)
{
SrsConfDirective* dvr = get_dvr(vhost);
Expand Down Expand Up @@ -3448,30 +3377,6 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost)
return false;
}

void SrsConfig::set_dvr_wait_keyframe(string vhost, bool wait_keyframe)
{
SrsConfDirective* conf = create_directive(vhost, "dvr", "dvr_wait_keyframe");
conf->args.clear();
conf->args.push_back(wait_keyframe? "on":"off");
}

bool SrsConfig::get_dvr_autostart(string vhost)
{
SrsConfDirective* dvr = get_dvr(vhost);

if (!dvr) {
return true;
}

SrsConfDirective* conf = dvr->get("dvr_autostart");

if (!conf || conf->arg0() != "off") {
return true;
}

return false;
}

int SrsConfig::get_dvr_time_jitter(string vhost)
{
SrsConfDirective* dvr = get_dvr(vhost);
Expand Down
19 changes: 0 additions & 19 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
#define SRS_CONF_DEFAULT_DVR_PLAN_API "api"
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
#define SRS_CONF_DEFAULT_DVR_DURATION 30
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
Expand Down Expand Up @@ -452,14 +451,6 @@ class SrsConfig
* get the max udp port for rtp of stream caster rtsp.
*/
virtual int get_stream_caster_rtp_port_max(SrsConfDirective* sc);
private:
/**
* create directive under vhost.
* @param directive, get the directive of vhost. get vhost if directive is empty.
* @param sub_directive, get the sub directive of vhost. get directive if sub-directive is empty.
* @return the vhost(empty directive and sub-directive); the directive(empty sub-directive); the sub-directive.
*/
virtual SrsConfDirective* create_directive(std::string vhost, std::string directive, std::string sub_directive);
// vhost specified section
public:
/**
Expand Down Expand Up @@ -596,7 +587,6 @@ class SrsConfig
* @remark, if not enabled, donot callback all http hooks.
*/
virtual bool get_vhost_http_hooks_enabled(std::string vhost);
virtual void set_vhost_http_hooks_enabled(std::string vhost, bool enabled);
/**
* get the on_connect callbacks of vhost.
* @return the on_connect callback directive, the args is the url to callback.
Expand Down Expand Up @@ -632,7 +622,6 @@ class SrsConfig
* @return the on_dvr callback directive, the args is the url to callback.
*/
virtual SrsConfDirective* get_vhost_on_dvr(std::string vhost);
virtual void set_vhost_on_dvr(std::string vhost, std::string callback);
// bwct(bandwidth check tool) section
public:
/**
Expand Down Expand Up @@ -925,17 +914,14 @@ class SrsConfig
* whether dvr is enabled.
*/
virtual bool get_dvr_enabled(std::string vhost);
virtual void set_dvr_enabled(std::string vhost, bool enabled);
/**
* get the dvr path, the flv file to save in.
*/
virtual std::string get_dvr_path(std::string vhost);
virtual void set_dvr_path(std::string vhost, std::string path);
/**
* get the plan of dvr, how to reap the flv file.
*/
virtual std::string get_dvr_plan(std::string vhost);
virtual void set_dvr_plan(std::string vhost, std::string plan);
/**
* get the duration of dvr flv.
*/
Expand All @@ -944,11 +930,6 @@ class SrsConfig
* whether wait keyframe to reap segment.
*/
virtual bool get_dvr_wait_keyframe(std::string vhost);
virtual void set_dvr_wait_keyframe(std::string vhost, bool wait_keyframe);
/**
* whether autostart for dvr. wait api to start dvr if false.
*/
virtual bool get_dvr_autostart(std::string vhost);
/**
* get the time_jitter algorithm for dvr.
*/
Expand Down
Loading

0 comments on commit fb3fced

Please sign in to comment.