Skip to content

Commit

Permalink
for bug ossrs#293, refine for fast cache of http stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 22, 2015
1 parent 2167a83 commit 7d86c6d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ vhost http.remux.srs.com {
# the fast cache for audio stream(mp3/aac),
# to cache more audio and send to client in a time to make android(weixin) happy.
# @remark the flv stream ignore it
# default: 30
# @remark 0 to disable fast cache for http audio stream.
# default: 0
fast_cache 30;
# the stream mout for rtmp to remux to flv live streaming.
# typical mount to [vhost]/[app]/[stream].flv
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
#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_API_PORT 1985
Expand Down
21 changes: 18 additions & 3 deletions trunk/src/app/srs_app_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,21 @@ int SrsStreamCache::start()
int SrsStreamCache::dump_cache(SrsConsumer* consumer)
{
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) {
return ret;
}

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;
}
Expand All @@ -191,7 +199,10 @@ int SrsStreamCache::cycle()
// TODO: FIMXE: add pithy print.

// 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) {
// get messages from consumer.
Expand All @@ -216,7 +227,11 @@ int SrsStreamCache::cycle()
// free the messages.
for (int i = 0; i < count; i++) {
SrsSharedPtrMessage* msg = msgs.msgs[i];
queue->enqueue(msg);
if (fast_cache > 0) {
queue->enqueue(msg);
} else {
srs_freep(msg);
}
}
}

Expand Down

0 comments on commit 7d86c6d

Please sign in to comment.