正在显示
3 个修改的文件
包含
21 行增加
和
5 行删除
| @@ -387,7 +387,8 @@ vhost http.remux.srs.com { | @@ -387,7 +387,8 @@ vhost http.remux.srs.com { | ||
| 387 | # the fast cache for audio stream(mp3/aac), | 387 | # the fast cache for audio stream(mp3/aac), |
| 388 | # to cache more audio and send to client in a time to make android(weixin) happy. | 388 | # to cache more audio and send to client in a time to make android(weixin) happy. |
| 389 | # @remark the flv stream ignore it | 389 | # @remark the flv stream ignore it |
| 390 | - # default: 30 | 390 | + # @remark 0 to disable fast cache for http audio stream. |
| 391 | + # default: 0 | ||
| 391 | fast_cache 30; | 392 | fast_cache 30; |
| 392 | # the stream mout for rtmp to remux to flv live streaming. | 393 | # the stream mout for rtmp to remux to flv live streaming. |
| 393 | # typical mount to [vhost]/[app]/[stream].flv | 394 | # typical mount to [vhost]/[app]/[stream].flv |
| @@ -68,7 +68,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -68,7 +68,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 68 | #define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/" | 68 | #define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/" |
| 69 | #define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv" | 69 | #define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv" |
| 70 | #define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH | 70 | #define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH |
| 71 | -#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 30 | 71 | +#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0 |
| 72 | 72 | ||
| 73 | #define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080 | 73 | #define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080 |
| 74 | #define SRS_CONF_DEFAULT_HTTP_API_PORT 1985 | 74 | #define SRS_CONF_DEFAULT_HTTP_API_PORT 1985 |
| @@ -165,13 +165,21 @@ int SrsStreamCache::start() | @@ -165,13 +165,21 @@ int SrsStreamCache::start() | ||
| 165 | int SrsStreamCache::dump_cache(SrsConsumer* consumer) | 165 | int SrsStreamCache::dump_cache(SrsConsumer* consumer) |
| 166 | { | 166 | { |
| 167 | int ret = ERROR_SUCCESS; | 167 | int ret = ERROR_SUCCESS; |
| 168 | + | ||
| 169 | + double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost); | ||
| 170 | + | ||
| 171 | + if (fast_cache <= 0) { | ||
| 172 | + srs_info("http: ignore dump fast cache."); | ||
| 173 | + return ret; | ||
| 174 | + } | ||
| 168 | 175 | ||
| 176 | + // TODO: FIXME: config it. | ||
| 169 | if ((ret = queue->dump_packets(consumer, false, 0, 0, SrsRtmpJitterAlgorithmOFF)) != ERROR_SUCCESS) { | 177 | if ((ret = queue->dump_packets(consumer, false, 0, 0, SrsRtmpJitterAlgorithmOFF)) != ERROR_SUCCESS) { |
| 170 | return ret; | 178 | return ret; |
| 171 | } | 179 | } |
| 172 | 180 | ||
| 173 | srs_trace("http: dump cache %d msgs, duration=%dms, cache=%.2fs", | 181 | srs_trace("http: dump cache %d msgs, duration=%dms, cache=%.2fs", |
| 174 | - queue->size(), queue->duration(), _srs_config->get_vhost_http_remux_fast_cache(req->vhost)); | 182 | + queue->size(), queue->duration(), fast_cache); |
| 175 | 183 | ||
| 176 | return ret; | 184 | return ret; |
| 177 | } | 185 | } |
| @@ -191,7 +199,10 @@ int SrsStreamCache::cycle() | @@ -191,7 +199,10 @@ int SrsStreamCache::cycle() | ||
| 191 | // TODO: FIMXE: add pithy print. | 199 | // TODO: FIMXE: add pithy print. |
| 192 | 200 | ||
| 193 | // TODO: FIXME: support reload. | 201 | // TODO: FIXME: support reload. |
| 194 | - queue->set_queue_size(_srs_config->get_vhost_http_remux_fast_cache(req->vhost)); | 202 | + double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost); |
| 203 | + if (fast_cache > 0) { | ||
| 204 | + queue->set_queue_size(fast_cache); | ||
| 205 | + } | ||
| 195 | 206 | ||
| 196 | while (true) { | 207 | while (true) { |
| 197 | // get messages from consumer. | 208 | // get messages from consumer. |
| @@ -216,7 +227,11 @@ int SrsStreamCache::cycle() | @@ -216,7 +227,11 @@ int SrsStreamCache::cycle() | ||
| 216 | // free the messages. | 227 | // free the messages. |
| 217 | for (int i = 0; i < count; i++) { | 228 | for (int i = 0; i < count; i++) { |
| 218 | SrsSharedPtrMessage* msg = msgs.msgs[i]; | 229 | SrsSharedPtrMessage* msg = msgs.msgs[i]; |
| 219 | - queue->enqueue(msg); | 230 | + if (fast_cache > 0) { |
| 231 | + queue->enqueue(msg); | ||
| 232 | + } else { | ||
| 233 | + srs_freep(msg); | ||
| 234 | + } | ||
| 220 | } | 235 | } |
| 221 | } | 236 | } |
| 222 | 237 |
-
请 注册 或 登录 后发表评论