diff --git a/README.md b/README.md
index 9c5c9593f..a5ca1f7dc 100755
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ url: rtmp://127.0.0.1:1935/live/livestream
* nginx v1.5.0: 139524 lines
### 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.
diff --git a/trunk/conf/srs.conf b/trunk/conf/srs.conf
index df5c00f38..9066be600 100755
--- a/trunk/conf/srs.conf
+++ b/trunk/conf/srs.conf
@@ -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.
diff --git a/trunk/src/core/srs_core_client.cpp b/trunk/src/core/srs_core_client.cpp
index cf64c7299..ebcc9e541 100755
--- a/trunk/src/core/srs_core_client.cpp
+++ b/trunk/src/core/srs_core_client.cpp
@@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include
#include
+#include
#include
#include
@@ -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;
}
diff --git a/trunk/src/core/srs_core_config.cpp b/trunk/src/core/srs_core_config.cpp
index 3a183e14b..d366a09f4 100755
--- a/trunk/src/core/srs_core_config.cpp
+++ b/trunk/src/core/srs_core_config.cpp
@@ -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;
diff --git a/trunk/src/core/srs_core_config.hpp b/trunk/src/core/srs_core_config.hpp
index 189e8411e..3baa0a11c 100755
--- a/trunk/src/core/srs_core_config.hpp
+++ b/trunk/src/core/srs_core_config.hpp
@@ -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);