]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
flush buffer to avoid lag and enable plc
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 21 Jun 2011 16:43:37 +0000 (11:43 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 21 Jun 2011 16:43:37 +0000 (11:43 -0500)
src/mod/endpoints/mod_rtmp/mod_rtmp.c
src/mod/endpoints/mod_rtmp/mod_rtmp.h
src/mod/endpoints/mod_rtmp/rtmp.c

index 99eef07057bd0b171da748aef973ff68ce39eca1..45daf7bfeaeba9fff5f203004bf451e04f21a858 100644 (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);
        
index 0fddb44cddb0a1283752db689ed68b33edfafe2f..aec0430b560b4edfdc4787f171d3513eef10cf66 100644 (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;
index 724e1b064fff4217bf14a232f5cee138460d9d80..1db027405c863dd09fc58a5991e62e26b98d902b 100644 (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;