flush buffer to avoid lag and enable plc

This commit is contained in:
Anthony Minessale 2011-06-21 11:43:37 -05:00
parent 6f49e6ba9e
commit 4bb768311e
3 changed files with 14 additions and 0 deletions

View File

@ -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);

View File

@ -518,6 +518,8 @@ struct rtmp_private {
const char *auth_user;
const char *auth_domain;
const char *auth;
uint16_t maxlen;
};
struct rtmp_reg;

View File

@ -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;