winlin

merge from wenjie: support set chunk size at vhost level

... ... @@ -26,6 +26,7 @@ vhost __defaultVhost__ {
# for which cannot identify the required vhost.
# for default demo.
vhost demo.srs.com {
chunk_size 4096;
enabled on;
gop_cache on;
queue_length 30;
... ... @@ -138,6 +139,7 @@ vhost players_pub {
hls_window 30;
}
}
# for development
vhost dev {
enabled on;
... ... @@ -198,6 +200,15 @@ vhost dev {
}
}
# set the chunk size of vhost.
vhost chunksize.vhost.com {
# the default chunk size is 128, max is 65536,
# some client does not support chunk size change,
# vhost chunk size will override the global value.
# default: global chunk size.
chunk_size 128;
}
# the http hook callback vhost, srs will invoke the hooks for specified events.
vhost hooks.callback.vhost.com {
http_hooks {
... ... @@ -289,6 +300,7 @@ vhost hooks.callback.vhost.com {
on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
}
}
# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction
vhost mirror.transcode.vhost.com {
transcode {
... ... @@ -668,6 +680,7 @@ vhost stream.transcode.vhost.com {
}
}
}
# the vhost which forward publish streams.
vhost same.vhost.forward.vhost.com {
# forward all publish stream to the specified server.
... ... @@ -683,6 +696,7 @@ vhost same.vhost.forward.vhost.com {
vhost change.vhost.forward.vhost.com {
forward 127.0.0.1:1936?vhost=forward2.vhost.com 127.0.0.1:1937?vhost=forward3.vhost.com;
}
# the vhost disabled.
vhost removed.vhost.com {
# whether the vhost is enabled.
... ... @@ -690,6 +704,7 @@ vhost removed.vhost.com {
# default: on
enabled off;
}
# the vhost with hls specified.
vhost with-hls.vhost.com {
hls {
... ... @@ -726,6 +741,7 @@ vhost no-hls.vhost.com {
enabled off;
}
}
# the vhost for min delay, donot cache any stream.
vhost min.delay.com {
# whether cache the last gop.
... ... @@ -743,6 +759,7 @@ vhost min.delay.com {
# default: 30
queue_length 10;
}
# the vhost for antisuck.
vhost refer.anti_suck.com {
# the common refer for play and publish.
... ... @@ -761,6 +778,7 @@ vhost refer.anti_suck.com {
# default: not specified.
refer_play github.com github.io;
}
# config for the pithy print,
# which always print constant message specified by interval,
# whatever the clients in concurrency.
... ...
... ... @@ -173,7 +173,7 @@ int SrsClient::service_cycle()
req->strip();
srs_trace("identify client success. type=%d, stream_name=%s", type, req->stream.c_str());
int chunk_size = config->get_chunk_size();
int chunk_size = config->get_chunk_size(req->vhost);
if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {
srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
return ret;
... ...
... ... @@ -2,6 +2,7 @@
The MIT License (MIT)
Copyright (c) 2013 winlin
Copyright (c) 2013 wenjiegit
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
... ... @@ -1442,14 +1443,27 @@ SrsConfDirective* SrsConfig::get_listen()
return root->get("listen");
}
int SrsConfig::get_chunk_size()
int SrsConfig::get_chunk_size(const std::string &vhost)
{
SrsConfDirective* conf = root->get("chunk_size");
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return SRS_CONF_DEFAULT_CHUNK_SIZE;
}
conf = conf->get("chunk_size");
if (!conf) {
// vhost does not specify the chunk size,
// use the global instead.
conf = root->get("chunk_size");
if (!conf) {
return SRS_CONF_DEFAULT_CHUNK_SIZE;
}
return ::atoi(conf->arg0().c_str());
}
return ::atoi(conf->arg0().c_str());
}
int SrsConfig::get_pithy_print_publish()
... ...
... ... @@ -2,6 +2,7 @@
The MIT License (MIT)
Copyright (c) 2013 winlin
Copyright (c) 2013 wenjiegit
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
... ... @@ -162,7 +163,7 @@ public:
virtual SrsConfDirective* get_refer_play(std::string vhost);
virtual SrsConfDirective* get_refer_publish(std::string vhost);
virtual SrsConfDirective* get_listen();
virtual int get_chunk_size();
virtual int get_chunk_size(const std::string& vhost);
virtual int get_pithy_print_publish();
virtual int get_pithy_print_forwarder();
virtual int get_pithy_print_encoder();
... ...