1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

merge from wenjie: support set chunk size at vhost level

This commit is contained in:
winlin 2013-12-22 12:23:20 +08:00
parent 309322fd5c
commit 725ff8e5a5
4 changed files with 41 additions and 8 deletions

View file

@ -26,6 +26,7 @@ vhost __defaultVhost__ {
# for which cannot identify the required vhost. # for which cannot identify the required vhost.
# for default demo. # for default demo.
vhost demo.srs.com { vhost demo.srs.com {
chunk_size 4096;
enabled on; enabled on;
gop_cache on; gop_cache on;
queue_length 30; queue_length 30;
@ -138,6 +139,7 @@ vhost players_pub {
hls_window 30; hls_window 30;
} }
} }
# for development # for development
vhost dev { vhost dev {
enabled on; 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. # the http hook callback vhost, srs will invoke the hooks for specified events.
vhost hooks.callback.vhost.com { vhost hooks.callback.vhost.com {
http_hooks { 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; 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 # the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction
vhost mirror.transcode.vhost.com { vhost mirror.transcode.vhost.com {
transcode { transcode {
@ -668,6 +680,7 @@ vhost stream.transcode.vhost.com {
} }
} }
} }
# the vhost which forward publish streams. # the vhost which forward publish streams.
vhost same.vhost.forward.vhost.com { vhost same.vhost.forward.vhost.com {
# forward all publish stream to the specified server. # forward all publish stream to the specified server.
@ -683,6 +696,7 @@ vhost same.vhost.forward.vhost.com {
vhost change.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; forward 127.0.0.1:1936?vhost=forward2.vhost.com 127.0.0.1:1937?vhost=forward3.vhost.com;
} }
# the vhost disabled. # the vhost disabled.
vhost removed.vhost.com { vhost removed.vhost.com {
# whether the vhost is enabled. # whether the vhost is enabled.
@ -690,6 +704,7 @@ vhost removed.vhost.com {
# default: on # default: on
enabled off; enabled off;
} }
# the vhost with hls specified. # the vhost with hls specified.
vhost with-hls.vhost.com { vhost with-hls.vhost.com {
hls { hls {
@ -726,6 +741,7 @@ vhost no-hls.vhost.com {
enabled off; enabled off;
} }
} }
# the vhost for min delay, donot cache any stream. # the vhost for min delay, donot cache any stream.
vhost min.delay.com { vhost min.delay.com {
# whether cache the last gop. # whether cache the last gop.
@ -743,6 +759,7 @@ vhost min.delay.com {
# default: 30 # default: 30
queue_length 10; queue_length 10;
} }
# the vhost for antisuck. # the vhost for antisuck.
vhost refer.anti_suck.com { vhost refer.anti_suck.com {
# the common refer for play and publish. # the common refer for play and publish.
@ -761,6 +778,7 @@ vhost refer.anti_suck.com {
# default: not specified. # default: not specified.
refer_play github.com github.io; refer_play github.com github.io;
} }
# config for the pithy print, # config for the pithy print,
# which always print constant message specified by interval, # which always print constant message specified by interval,
# whatever the clients in concurrency. # whatever the clients in concurrency.

View file

@ -173,7 +173,7 @@ int SrsClient::service_cycle()
req->strip(); req->strip();
srs_trace("identify client success. type=%d, stream_name=%s", type, req->stream.c_str()); 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) { if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {
srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret); srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
return ret; return ret;

View file

@ -2,6 +2,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2013 winlin Copyright (c) 2013 winlin
Copyright (c) 2013 wenjiegit
Permission is hereby granted, free of charge, to any person obtaining a copy of 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 this software and associated documentation files (the "Software"), to deal in
@ -1442,13 +1443,26 @@ SrsConfDirective* SrsConfig::get_listen()
return root->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) { if (!conf) {
return SRS_CONF_DEFAULT_CHUNK_SIZE; 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()); return ::atoi(conf->arg0().c_str());
} }

View file

@ -2,6 +2,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2013 winlin Copyright (c) 2013 winlin
Copyright (c) 2013 wenjiegit
Permission is hereby granted, free of charge, to any person obtaining a copy of 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 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_play(std::string vhost);
virtual SrsConfDirective* get_refer_publish(std::string vhost); virtual SrsConfDirective* get_refer_publish(std::string vhost);
virtual SrsConfDirective* get_listen(); 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_publish();
virtual int get_pithy_print_forwarder(); virtual int get_pithy_print_forwarder();
virtual int get_pithy_print_encoder(); virtual int get_pithy_print_encoder();