]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7500: reduce CNG frames on video and move debug from mod_fsv to the core with...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 20 Nov 2014 22:30:19 +0000 (16:30 -0600)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:47 +0000 (12:46 -0500)
src/include/switch_types.h
src/mod/applications/mod_fsv/mod_fsv.c
src/mod/codecs/mod_vpx/mod_vpx.c
src/switch_core_media.c
src/switch_core_session.c
src/switch_rtp.c

index 4c3a0b9b821f314704eec7baad822960ddd34750..6062f3ef4b1dbc0a00c913e0a272ea7e2ebdae1f 100644 (file)
@@ -1451,6 +1451,8 @@ typedef enum {
        CF_HANGUP_HELD,
        CF_CONFERENCE_RESET_MEDIA,
        CF_VIDEO_DECODED_READ,
+       CF_VIDEO_DEBUG_READ,
+       CF_VIDEO_DEBUG_WRITE,
        /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
        /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
        CF_FLAG_MAX
index c544abcaa7a70dfea0a56a581d2eed2cdd1e7a8d..21e1fc4d84070bcb4849d5fd2098711798817913 100644 (file)
@@ -723,6 +723,7 @@ static void decode_video_thread(switch_core_session_t *session, void *obj)
        }
 
        switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
+       switch_channel_set_flag(channel, CF_VIDEO_DEBUG_READ);
        
        while (switch_channel_ready(channel)) {
                switch_status_t status = switch_core_session_read_video_frame(session, &frame, SWITCH_IO_FLAG_NONE, 0);
@@ -742,15 +743,6 @@ static void decode_video_thread(switch_core_session_t *session, void *obj)
                        continue;
                }
 
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "seq: %d ts: %ld len: %4d %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d %s\n",
-                       frame->seq, frame->timestamp, frame->datalen,
-                       *((uint8_t *)frame->data), *((uint8_t *)frame->data + 1),
-                       *((uint8_t *)frame->data + 2), *((uint8_t *)frame->data + 3),
-                       *((uint8_t *)frame->data + 4), *((uint8_t *)frame->data + 5),
-                       *((uint8_t *)frame->data + 6), *((uint8_t *)frame->data + 7),
-                       *((uint8_t *)frame->data + 8), *((uint8_t *)frame->data + 9),
-                       *((uint8_t *)frame->data + 10), frame->m, switch_test_flag(frame, SFF_CNG) ? " CNG" : "");
-
                if (switch_test_flag(frame, SFF_CNG) || frame->datalen < 3) {
                        continue;
                }
index 70ee6b41234d9c2029b8a5c6a86c8a237effc7dc..77ce0fcb39b6016f6d0b29cb47a9872987dd99f8 100644 (file)
@@ -315,16 +315,19 @@ static switch_status_t switch_vpx_init(switch_codec_t *codec, switch_codec_flag_
 
 static switch_status_t consume_partition(vpx_context_t *context, switch_frame_t *frame)
 {
-       if (!context->pkt) context->pkt = vpx_codec_get_cx_data(&context->encoder, &context->iter);
+       if (!context->pkt) {
+               context->pkt = vpx_codec_get_cx_data(&context->encoder, &context->iter);
+               context->pkt_pos = 0;
+       }
 
-       if (context->pkt) {
+       //      if (context->pkt) {
                // if (context->pkt->kind == VPX_CODEC_CX_FRAME_PKT && (context->pkt->data.frame.flags & VPX_FRAME_IS_KEY) && context->pkt_pos == 0) {
                //      switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "============================Got a VP8 Key Frame size:[%d]===================================\n", (int)context->pkt->data.frame.sz);
                // }
 
                // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "size:%d flag: %x part_id: %d pts: %lld duration:%ld\n",
                //      (int)context->pkt->data.frame.sz, context->pkt->data.frame.flags, context->pkt->data.frame.partition_id, context->pkt->data.frame.pts, context->pkt->data.frame.duration);
-       }
+               //}
 
        if (!context->pkt || context->pkt_pos >= context->pkt->data.frame.sz - 1 || context->pkt->kind != VPX_CODEC_CX_FRAME_PKT) {
                frame->datalen = 0;
index 1a45579aae0f5330e48cb123b0b21df1da23fd61..88896f712c247d75344c7744ffca415a8cb080a2 100644 (file)
@@ -1849,7 +1849,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
                                        switch_channel_execute_on(session->channel, "execute_on_media_timeout");
                                        switch_goto_status(SWITCH_STATUS_SUCCESS, end);
                                }
-
+                               
 
                                switch_channel_hangup(session->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
                        }
@@ -9686,6 +9686,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
        if (!(*frame)) {
                goto done;
        }
+       
+       if (switch_channel_test_flag(session->channel, CF_VIDEO_DEBUG_READ)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "seq: %d ts: %ld len: %4d %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d %s\n",
+                                                 (*frame)->seq, (*frame)->timestamp, (*frame)->datalen,
+                                                 *((uint8_t *)(*frame)->data), *((uint8_t *)(*frame)->data + 1),
+                                                 *((uint8_t *)(*frame)->data + 2), *((uint8_t *)(*frame)->data + 3),
+                                                 *((uint8_t *)(*frame)->data + 4), *((uint8_t *)(*frame)->data + 5),
+                                                 *((uint8_t *)(*frame)->data + 6), *((uint8_t *)(*frame)->data + 7),
+                                                 *((uint8_t *)(*frame)->data + 8), *((uint8_t *)(*frame)->data + 9),
+                                                 *((uint8_t *)(*frame)->data + 10), (*frame)->m, switch_test_flag((*frame), SFF_CNG) ? " CNG" : "");
+       }
+
 
        if (switch_test_flag(*frame, SFF_CNG)) {
                status = SWITCH_STATUS_SUCCESS;
index ea5259db1c514af23560d8ffc3462e79aa0b828e..96b7bc0e9b8a28c0173512740efac5c6248342ef 100644 (file)
@@ -2680,6 +2680,7 @@ SWITCH_DECLARE(void) switch_core_session_video_reset(switch_core_session_t *sess
        switch_channel_clear_flag(session->channel, CF_VIDEO_ECHO);
        switch_channel_clear_flag(session->channel, CF_VIDEO_PASSIVE);
        switch_channel_clear_flag(session->channel, CF_VIDEO_DECODED_READ);
+       switch_channel_clear_flag(session->channel, CF_VIDEO_DEBUG_READ);
        switch_core_session_refresh_video(session);
        session->image_write_callback = NULL;
        session->image_write_callback_user_data = NULL;
index 924a083dea47ba191df1df597a56a73bd2d5472f..31a043dc3d4c925f5e7037ce8b7cf2e568776e43 100644 (file)
@@ -5578,17 +5578,16 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                        }
 
                        if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) {
-                               pt = 100000;
+                               pt = 200000;
                        }
 
-                       if (using_ice(rtp_session)) {
-                               pt = 20000;
-                       }
+                       //if (using_ice(rtp_session)) {
+                       //      pt = 20000;
+                       //}
 
                        poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
 
-
-                       if (rtp_session->dtmf_data.out_digit_dur > 0) {
+                       if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->dtmf_data.out_digit_dur > 0) {
                                return_cng_frame();
                        }