winlin

support config the chunk_size.

@@ -48,6 +48,7 @@ url: rtmp://127.0.0.1:1935/live/livestream @@ -48,6 +48,7 @@ url: rtmp://127.0.0.1:1935/live/livestream
48 * nginx v1.5.0: 139524 lines <br/> 48 * nginx v1.5.0: 139524 lines <br/>
49 49
50 ### History 50 ### History
  51 +* v0.4, 2013-11-09, support config the chunk_size.
51 * v0.4, 2013-11-09, support pause for live stream. 52 * v0.4, 2013-11-09, support pause for live stream.
52 * v0.3, 2013-11-04, v0.3 released. 11773 lines. 53 * v0.3, 2013-11-04, v0.3 released. 11773 lines.
53 * v0.3, 2013-11-04, support refer/play-refer/publish-refer. 54 * v0.3, 2013-11-04, support refer/play-refer/publish-refer.
  1 +# the listen ports, split by space.
1 listen 1935 19350; 2 listen 1935 19350;
  3 +# the default chunk size is 128, max is 65536,
  4 +# some client does not support chunk size change,
  5 +# however, most clients supports it and it can improve
  6 +# performance about 10%.
  7 +# if not specified, set to 4096.
  8 +chunk_size 65000;
  9 +# vhost list, the __defaultVhost__ is the default vhost
  10 +# for which cannot identify the required vhost.
2 vhost __defaultVhost__ { 11 vhost __defaultVhost__ {
3 } 12 }
  13 +# the vhost disabled.
4 vhost removed.vhost.com { 14 vhost removed.vhost.com {
5 # whether the vhost is enabled. 15 # whether the vhost is enabled.
6 # if off, all request access denied. 16 # if off, all request access denied.
7 # default: on 17 # default: on
8 enabled off; 18 enabled off;
9 } 19 }
  20 +# the vhost for min delay, donot cache any stream.
10 vhost min.delay.com { 21 vhost min.delay.com {
11 # whether cache the last gop. 22 # whether cache the last gop.
12 # if on, cache the last gop and dispatch to client, 23 # if on, cache the last gop and dispatch to client,
@@ -18,6 +29,7 @@ vhost min.delay.com { @@ -18,6 +29,7 @@ vhost min.delay.com {
18 # default: on 29 # default: on
19 gop_cache off; 30 gop_cache off;
20 } 31 }
  32 +# the vhost for antisuck.
21 vhost refer.anti_suck.com { 33 vhost refer.anti_suck.com {
22 # the common refer for play and publish. 34 # the common refer for play and publish.
23 # if the page url of client not in the refer, access denied. 35 # 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. @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include <srs_core_client.hpp> 24 #include <srs_core_client.hpp>
25 25
26 #include <arpa/inet.h> 26 #include <arpa/inet.h>
  27 +#include <stdlib.h>
27 28
28 #include <srs_core_error.hpp> 29 #include <srs_core_error.hpp>
29 #include <srs_core_log.hpp> 30 #include <srs_core_log.hpp>
@@ -135,20 +136,23 @@ int SrsClient::do_cycle() @@ -135,20 +136,23 @@ int SrsClient::do_cycle()
135 req->strip(); 136 req->strip();
136 srs_trace("identify client success. type=%d, stream_name=%s", type, req->stream.c_str()); 137 srs_trace("identify client success. type=%d, stream_name=%s", type, req->stream.c_str());
137 138
138 - // TODO: read from config.  
139 int chunk_size = 4096; 139 int chunk_size = 4096;
  140 + SrsConfDirective* conf = config->get_chunk_size();
  141 + if (conf && !conf->arg0().empty()) {
  142 + chunk_size = ::atoi(conf->arg0().c_str());
  143 + }
140 if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) { 144 if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {
141 - srs_error("set chunk size failed. ret=%d", ret); 145 + srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
142 return ret; 146 return ret;
143 } 147 }
144 - srs_verbose("set chunk size success"); 148 + srs_trace("set chunk_size=%d success", chunk_size);
145 149
146 // find a source to publish. 150 // find a source to publish.
147 SrsSource* source = SrsSource::find(req->get_stream_url()); 151 SrsSource* source = SrsSource::find(req->get_stream_url());
148 srs_assert(source != NULL); 152 srs_assert(source != NULL);
149 153
150 - SrsConfDirective* conf = config->get_gop_cache(req->vhost);  
151 bool enabled_cache = true; 154 bool enabled_cache = true;
  155 + conf = config->get_gop_cache(req->vhost);
152 if (conf && conf->arg0() == "off") { 156 if (conf && conf->arg0() == "off") {
153 enabled_cache = false; 157 enabled_cache = false;
154 } 158 }
@@ -536,6 +536,11 @@ SrsConfDirective* Config::get_listen() @@ -536,6 +536,11 @@ SrsConfDirective* Config::get_listen()
536 return root->get("listen"); 536 return root->get("listen");
537 } 537 }
538 538
  539 +SrsConfDirective* Config::get_chunk_size()
  540 +{
  541 + return root->get("chunk_size");
  542 +}
  543 +
539 int Config::parse_argv(int& i, char** argv) 544 int Config::parse_argv(int& i, char** argv)
540 { 545 {
541 int ret = ERROR_SUCCESS; 546 int ret = ERROR_SUCCESS;
@@ -102,6 +102,7 @@ public: @@ -102,6 +102,7 @@ public:
102 virtual SrsConfDirective* get_refer_play(std::string vhost); 102 virtual SrsConfDirective* get_refer_play(std::string vhost);
103 virtual SrsConfDirective* get_refer_publish(std::string vhost); 103 virtual SrsConfDirective* get_refer_publish(std::string vhost);
104 virtual SrsConfDirective* get_listen(); 104 virtual SrsConfDirective* get_listen();
  105 + virtual SrsConfDirective* get_chunk_size();
105 private: 106 private:
106 virtual int parse_argv(int& i, char** argv); 107 virtual int parse_argv(int& i, char** argv);
107 virtual void print_help(char** argv); 108 virtual void print_help(char** argv);