mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 12:21:55 +00:00
support config the chunk_size.
This commit is contained in:
parent
c78af697a1
commit
ed3525056c
5 changed files with 27 additions and 4 deletions
|
@ -48,6 +48,7 @@ url: rtmp://127.0.0.1:1935/live/livestream
|
|||
* nginx v1.5.0: 139524 lines <br/>
|
||||
|
||||
### History
|
||||
* v0.4, 2013-11-09, support config the chunk_size.
|
||||
* v0.4, 2013-11-09, support pause for live stream.
|
||||
* v0.3, 2013-11-04, v0.3 released. 11773 lines.
|
||||
* v0.3, 2013-11-04, support refer/play-refer/publish-refer.
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
# the listen ports, split by space.
|
||||
listen 1935 19350;
|
||||
# the default chunk size is 128, max is 65536,
|
||||
# some client does not support chunk size change,
|
||||
# however, most clients supports it and it can improve
|
||||
# performance about 10%.
|
||||
# if not specified, set to 4096.
|
||||
chunk_size 65000;
|
||||
# vhost list, the __defaultVhost__ is the default vhost
|
||||
# for which cannot identify the required vhost.
|
||||
vhost __defaultVhost__ {
|
||||
}
|
||||
# the vhost disabled.
|
||||
vhost removed.vhost.com {
|
||||
# whether the vhost is enabled.
|
||||
# if off, all request access denied.
|
||||
# default: on
|
||||
enabled off;
|
||||
}
|
||||
# the vhost for min delay, donot cache any stream.
|
||||
vhost min.delay.com {
|
||||
# whether cache the last gop.
|
||||
# if on, cache the last gop and dispatch to client,
|
||||
|
@ -18,6 +29,7 @@ vhost min.delay.com {
|
|||
# default: on
|
||||
gop_cache off;
|
||||
}
|
||||
# the vhost for antisuck.
|
||||
vhost refer.anti_suck.com {
|
||||
# the common refer for play and publish.
|
||||
# if the page url of client not in the refer, access denied.
|
||||
|
|
|
@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_core_client.hpp>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <srs_core_error.hpp>
|
||||
#include <srs_core_log.hpp>
|
||||
|
@ -135,20 +136,23 @@ int SrsClient::do_cycle()
|
|||
req->strip();
|
||||
srs_trace("identify client success. type=%d, stream_name=%s", type, req->stream.c_str());
|
||||
|
||||
// TODO: read from config.
|
||||
int chunk_size = 4096;
|
||||
SrsConfDirective* conf = config->get_chunk_size();
|
||||
if (conf && !conf->arg0().empty()) {
|
||||
chunk_size = ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {
|
||||
srs_error("set chunk size failed. ret=%d", ret);
|
||||
srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("set chunk size success");
|
||||
srs_trace("set chunk_size=%d success", chunk_size);
|
||||
|
||||
// find a source to publish.
|
||||
SrsSource* source = SrsSource::find(req->get_stream_url());
|
||||
srs_assert(source != NULL);
|
||||
|
||||
SrsConfDirective* conf = config->get_gop_cache(req->vhost);
|
||||
bool enabled_cache = true;
|
||||
conf = config->get_gop_cache(req->vhost);
|
||||
if (conf && conf->arg0() == "off") {
|
||||
enabled_cache = false;
|
||||
}
|
||||
|
|
|
@ -536,6 +536,11 @@ SrsConfDirective* Config::get_listen()
|
|||
return root->get("listen");
|
||||
}
|
||||
|
||||
SrsConfDirective* Config::get_chunk_size()
|
||||
{
|
||||
return root->get("chunk_size");
|
||||
}
|
||||
|
||||
int Config::parse_argv(int& i, char** argv)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
|
|
@ -102,6 +102,7 @@ public:
|
|||
virtual SrsConfDirective* get_refer_play(std::string vhost);
|
||||
virtual SrsConfDirective* get_refer_publish(std::string vhost);
|
||||
virtual SrsConfDirective* get_listen();
|
||||
virtual SrsConfDirective* get_chunk_size();
|
||||
private:
|
||||
virtual int parse_argv(int& i, char** argv);
|
||||
virtual void print_help(char** argv);
|
||||
|
|
Loading…
Reference in a new issue