mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for bug #293, refine for fast cache of http stream.
This commit is contained in:
parent
2167a8385c
commit
7d86c6d9e9
3 changed files with 21 additions and 5 deletions
|
@ -387,7 +387,8 @@ vhost http.remux.srs.com {
|
||||||
# the fast cache for audio stream(mp3/aac),
|
# the fast cache for audio stream(mp3/aac),
|
||||||
# to cache more audio and send to client in a time to make android(weixin) happy.
|
# to cache more audio and send to client in a time to make android(weixin) happy.
|
||||||
# @remark the flv stream ignore it
|
# @remark the flv stream ignore it
|
||||||
# default: 30
|
# @remark 0 to disable fast cache for http audio stream.
|
||||||
|
# default: 0
|
||||||
fast_cache 30;
|
fast_cache 30;
|
||||||
# the stream mout for rtmp to remux to flv live streaming.
|
# the stream mout for rtmp to remux to flv live streaming.
|
||||||
# typical mount to [vhost]/[app]/[stream].flv
|
# typical mount to [vhost]/[app]/[stream].flv
|
||||||
|
|
|
@ -68,7 +68,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
|
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
|
||||||
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
|
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
|
||||||
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
||||||
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 30
|
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
|
||||||
|
|
||||||
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080
|
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080
|
||||||
#define SRS_CONF_DEFAULT_HTTP_API_PORT 1985
|
#define SRS_CONF_DEFAULT_HTTP_API_PORT 1985
|
||||||
|
|
|
@ -165,13 +165,21 @@ int SrsStreamCache::start()
|
||||||
int SrsStreamCache::dump_cache(SrsConsumer* consumer)
|
int SrsStreamCache::dump_cache(SrsConsumer* consumer)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost);
|
||||||
|
|
||||||
|
if (fast_cache <= 0) {
|
||||||
|
srs_info("http: ignore dump fast cache.");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: FIXME: config it.
|
||||||
if ((ret = queue->dump_packets(consumer, false, 0, 0, SrsRtmpJitterAlgorithmOFF)) != ERROR_SUCCESS) {
|
if ((ret = queue->dump_packets(consumer, false, 0, 0, SrsRtmpJitterAlgorithmOFF)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("http: dump cache %d msgs, duration=%dms, cache=%.2fs",
|
srs_trace("http: dump cache %d msgs, duration=%dms, cache=%.2fs",
|
||||||
queue->size(), queue->duration(), _srs_config->get_vhost_http_remux_fast_cache(req->vhost));
|
queue->size(), queue->duration(), fast_cache);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +199,10 @@ int SrsStreamCache::cycle()
|
||||||
// TODO: FIMXE: add pithy print.
|
// TODO: FIMXE: add pithy print.
|
||||||
|
|
||||||
// TODO: FIXME: support reload.
|
// TODO: FIXME: support reload.
|
||||||
queue->set_queue_size(_srs_config->get_vhost_http_remux_fast_cache(req->vhost));
|
double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost);
|
||||||
|
if (fast_cache > 0) {
|
||||||
|
queue->set_queue_size(fast_cache);
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// get messages from consumer.
|
// get messages from consumer.
|
||||||
|
@ -216,7 +227,11 @@ int SrsStreamCache::cycle()
|
||||||
// free the messages.
|
// free the messages.
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
SrsSharedPtrMessage* msg = msgs.msgs[i];
|
SrsSharedPtrMessage* msg = msgs.msgs[i];
|
||||||
queue->enqueue(msg);
|
if (fast_cache > 0) {
|
||||||
|
queue->enqueue(msg);
|
||||||
|
} else {
|
||||||
|
srs_freep(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue