diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index 99eef07057..45daf7bfea 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -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); diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.h b/src/mod/endpoints/mod_rtmp/mod_rtmp.h index 0fddb44cdd..aec0430b56 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.h +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.h @@ -518,6 +518,8 @@ struct rtmp_private { const char *auth_user; const char *auth_domain; const char *auth; + + uint16_t maxlen; }; struct rtmp_reg; diff --git a/src/mod/endpoints/mod_rtmp/rtmp.c b/src/mod/endpoints/mod_rtmp/rtmp.c index 724e1b064f..1db027405c 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp.c +++ b/src/mod/endpoints/mod_rtmp/rtmp.c @@ -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;