提交 4bb76831 authored 作者: Anthony Minessale's avatar Anthony Minessale

flush buffer to avoid lag and enable plc

上级 6f49e6ba
......@@ -152,6 +152,8 @@ switch_status_t rtmp_on_init(switch_core_session_t *session)
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_channel_set_flag(channel, CF_CNG_PLC);
rtmp_notify_call_state(session);
......
......@@ -518,6 +518,8 @@ struct rtmp_private {
const char *auth_user;
const char *auth_domain;
const char *auth;
uint16_t maxlen;
};
struct rtmp_reg;
......
......@@ -848,9 +848,19 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession)
case RTMP_TYPE_AUDIO: /* Audio data */
if (rsession->tech_pvt) {
uint16_t len = state->origlen;
switch_mutex_lock(rsession->tech_pvt->readbuf_mutex);
if (rsession->tech_pvt->maxlen && switch_buffer_inuse(rsession->tech_pvt->readbuf) > rsession->tech_pvt->maxlen * 3) {
switch_buffer_zero(rsession->tech_pvt->readbuf);
#ifdef RTMP_DEBUG_IO
fprintf(rsession->io_debug_in, "[chunk_stream=%d type=0x%x ts=%d stream_id=0x%x] FLUSH BUFFER [exceeded %u]\n", rsession->amfnumber, state->type, (int)state->ts, state->stream_id, rsession->tech_pvt->maxlen * 3);
#endif
}
switch_buffer_write(rsession->tech_pvt->readbuf, &len, 2);
switch_buffer_write(rsession->tech_pvt->readbuf, state->buf, len);
if (len > rsession->tech_pvt->maxlen) {
rsession->tech_pvt->maxlen = len;
}
switch_mutex_unlock(rsession->tech_pvt->readbuf_mutex);
}
break;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论