<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15524] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15524">15524</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-11-18 13:22:45 -0600 (Wed, 18 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>video improvements</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_bridgec">freeswitch/trunk/src/switch_ivr_bridge.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/include/switch_types.h        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -515,7 +515,8 @@
</span><span class="cx">         SWITCH_ZRTP_FLAG_SECURE_MITM_SEND = (1 << 25),
</span><span class="cx">         SWITCH_ZRTP_FLAG_SECURE_MITM_RECV = (1 << 26),
</span><span class="cx">         SWITCH_RTP_FLAG_DEBUG_RTP_READ = (1 << 27),
</span><del>-        SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 << 28)
</del><ins>+        SWITCH_RTP_FLAG_DEBUG_RTP_WRITE = (1 << 28),
+        SWITCH_RTP_FLAG_VIDEO = (1 << 29)
</ins><span class="cx"> } switch_rtp_flag_enum_t;
</span><span class="cx"> typedef uint32_t switch_rtp_flag_t;
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -293,6 +293,14 @@
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (switch_core_codec_ready(&tech_pvt->video_read_codec)) {
+                        switch_core_codec_destroy(&tech_pvt->video_read_codec);
+                }
+                
+                if (switch_core_codec_ready(&tech_pvt->video_write_codec)) {
+                        switch_core_codec_destroy(&tech_pvt->video_write_codec);
+                }
+
</ins><span class="cx">                 switch_core_session_unset_read_codec(session);
</span><span class="cx">                 switch_core_session_unset_write_codec(session);
</span><span class="cx">
</span><span class="lines">@@ -685,7 +693,7 @@
</span><span class="cx"> {
</span><span class="cx">         private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-        switch_status_t status = SWITCH_STATUS_SUCCESS;
</del><ins>+        int wrote = 0;
</ins><span class="cx">
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx">
</span><span class="lines">@@ -710,10 +718,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!switch_test_flag(frame, SFF_CNG)) {
</span><del>-                switch_rtp_write_frame(tech_pvt->video_rtp_session, frame);
</del><ins>+                wrote = switch_rtp_write_frame(tech_pvt->video_rtp_session, frame);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        return status;
</del><ins>+        return wrote > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -2565,7 +2565,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "rtp-ip")) {
</span><span class="cx">                                                 char *ip = mod_sofia_globals.guess_ip;
</span><del>-
</del><ins>+                                                
</ins><span class="cx">                                                 if (!strcmp(val, "0.0.0.0")) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -4057,12 +4057,11 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><span class="cx">                                 
</span><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
</ins><span class="cx">                                 if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
</span><span class="cx">                                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                                         goto done;
</span><del>-                                } else {
-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
</del><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -2537,6 +2537,86 @@
</span><span class="cx">
</span><span class="cx">                 sofia_glue_check_video_codecs(tech_pvt);
</span><span class="cx">
</span><ins>+                /******************************************************************************************/
+                if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
+                        //const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
+                        //const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
+                        char *remote_host = switch_rtp_get_remote_host(tech_pvt->video_rtp_session);
+                        switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->video_rtp_session);
+
+                        if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_video_ip) && remote_port == tech_pvt->remote_sdp_video_port) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n", switch_channel_get_name(tech_pvt->channel));
+                                goto video_up;
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n",
+                                                                 switch_channel_get_name(tech_pvt->channel),
+                                                                 remote_host, remote_port, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
+                        }
+                }
+
+                if (!switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n",
+                                                         switch_channel_get_name(tech_pvt->channel),
+                                                         tech_pvt->local_sdp_audio_ip,
+                                                         tech_pvt->local_sdp_video_port,
+                                                         tech_pvt->remote_sdp_video_ip,
+                                                         tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
+                }
+
+                switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_video_port);
+                switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+                switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
+
+                if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
+                        sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+                
+                        if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) !=
+                                SWITCH_STATUS_SUCCESS) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
+                                                                 tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
+                                if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
+                                        !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
+                                        /* Reactivate the NAT buster flag. */
+                                        switch_rtp_set_flag(tech_pvt->video_rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+                                }
+                        }
+                        goto video_up;
+                }
+
+                if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+                        if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+                                goto end;
+                        }
+
+                        if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
+                                !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
+                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT);
+                        } else {
+                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_PROXY_MEDIA | SWITCH_RTP_FLAG_DATAWAIT);
+                        }
+                        timer_name = NULL;
+
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
+                                                         "PROXY VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
+                                                         switch_channel_get_name(tech_pvt->channel),
+                                                         tech_pvt->local_sdp_audio_ip,
+                                                         tech_pvt->local_sdp_video_port,
+                                                         tech_pvt->remote_sdp_video_ip,
+                                                         tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
+
+                } else {
+                        timer_name = tech_pvt->profile->timer_name;
+
+                        if ((var = switch_channel_get_variable(tech_pvt->channel, "rtp_timer_name"))) {
+                                timer_name = (char *) var;
+                        }
+                }
+
+                /******************************************************************************************/
+
+
</ins><span class="cx">                 if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
</span><span class="cx">                         if (!tech_pvt->local_sdp_video_port) {
</span><span class="cx">                                 sofia_glue_tech_choose_video_port(tech_pvt, 1);
</span><span class="lines">@@ -2545,9 +2625,9 @@
</span><span class="cx">                         if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
</span><span class="cx">                                 !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
</span><span class="cx">                                 flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ |
</span><del>-                                                                                          SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE);
</del><ins>+                                                                                          SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
</ins><span class="cx">                         } else {
</span><del>-                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_NOBLOCK | SWITCH_RTP_FLAG_RAW_WRITE);
</del><ins>+                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
</span><span class="lines">@@ -2555,13 +2635,15 @@
</span><span class="cx">                         }
</span><span class="cx">                         sofia_glue_tech_set_video_codec(tech_pvt, 0);
</span><span class="cx">
</span><del>-                        /* set video timer to 10ms so it can co-exist with audio */
</del><ins>+                        flags &= ~(SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_NOBLOCK);
+                        flags |= SWITCH_RTP_FLAG_VIDEO | SWITCH_RTP_FLAG_PROXY_MEDIA;
+
</ins><span class="cx">                         tech_pvt->video_rtp_session = switch_rtp_new(tech_pvt->local_sdp_audio_ip,
</span><span class="cx">                                                                                                                  tech_pvt->local_sdp_video_port,
</span><span class="cx">                                                                                                                  tech_pvt->remote_sdp_video_ip,
</span><span class="cx">                                                                                                                  tech_pvt->remote_sdp_video_port,
</span><span class="cx">                                                                                                                  tech_pvt->video_agreed_pt,
</span><del>-                                                                                                                 1, 10000, (switch_rtp_flag_t) flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session));
</del><ins>+                                                                                                                 1, 90000, (switch_rtp_flag_t) flags, NULL, &err, switch_core_session_get_pool(tech_pvt->session));
</ins><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%sVIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
</span><span class="cx">                                                          switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA) ? "PROXY " : "",
</span><span class="lines">@@ -2580,6 +2662,7 @@
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
</span><span class="cx">                 switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -2588,6 +2671,8 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+ video_up:
+
</ins><span class="cx">         sofia_set_flag(tech_pvt, TFLAG_IO);
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_bridgec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_bridge.c (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_bridge.c        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/switch_ivr_bridge.c        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -59,22 +59,29 @@
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0);
</del><ins>+                if (!switch_test_flag(read_frame, SFF_CNG)) {
+                        if (switch_core_session_write_video_frame(vh->session_b, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
+                                break;
+                        }
+                }
</ins><span class="cx">
</span><span class="cx">         }
</span><ins>+        
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s video thread ended.\n", switch_channel_get_name(channel));
+
</ins><span class="cx">         vh->up = 0;
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void launch_video(struct vid_helper *vh)
</del><ins>+static switch_thread_t *launch_video(struct vid_helper *vh)
</ins><span class="cx"> {
</span><span class="cx">         switch_thread_t *thread;
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">
</span><span class="cx">         switch_threadattr_create(&thd_attr, switch_core_session_get_pool(vh->session_a));
</span><del>-        switch_threadattr_detach_set(thd_attr, 1);
</del><span class="cx">         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><span class="cx">         switch_thread_create(&thread, thd_attr, video_bridge_thread, vh, switch_core_session_get_pool(vh->session_a));
</span><ins>+        return thread;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -172,6 +179,7 @@
</span><span class="cx">         time_t answer_limit = 0;
</span><span class="cx">         
</span><span class="cx"> #ifdef SWITCH_VIDEO_IN_THREADS
</span><ins>+        switch_thread_t *vid_thread = NULL;
</ins><span class="cx">         struct vid_helper vh = { 0 };
</span><span class="cx">         uint32_t vid_launch = 0;
</span><span class="cx"> #endif
</span><span class="lines">@@ -325,7 +333,7 @@
</span><span class="cx">                         vid_launch++;
</span><span class="cx">                         vh.session_a = session_a;
</span><span class="cx">                         vh.session_b = session_b;
</span><del>-                        launch_video(&vh);
</del><ins>+                        vid_thread = launch_video(&vh);
</ins><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -468,17 +476,6 @@
</span><span class="cx">                 switch_core_codec_destroy(&silence_codec);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-
-#ifdef SWITCH_VIDEO_IN_THREADS
-        if (vh.up) {
-                vh.up = -1;
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
-                while (vh.up) {
-                        switch_yield(100000);
-                }
-        }
-#endif
-
</del><span class="cx">         if (!inner_bridge) {
</span><span class="cx">                 hook_var = switch_channel_get_variable(chan_a, SWITCH_API_BRIDGE_END_VARIABLE);
</span><span class="cx">         }
</span><span class="lines">@@ -530,6 +527,19 @@
</span><span class="cx">
</span><span class="cx"> end:
</span><span class="cx">
</span><ins>+#ifdef SWITCH_VIDEO_IN_THREADS
+        if (vid_thread) {
+                switch_status_t st;
+                vh.up = -1;
+                switch_core_session_kill_channel(session_a, SWITCH_SIG_BREAK);
+                switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ending video thread.\n");
+                switch_thread_join(&st, vid_thread);
+        }
+#endif
+
+
+
</ins><span class="cx">         switch_core_session_reset(session_a, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">         switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (15523 => 15524)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2009-11-18 16:08:36 UTC (rev 15523)
+++ freeswitch/trunk/src/switch_rtp.c        2009-11-18 19:22:45 UTC (rev 15524)
</span><span class="lines">@@ -1997,7 +1997,7 @@
</span><span class="cx">
</span><span class="cx">                 if (!bytes && (io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
</span><span class="cx">                         return_cng_frame();
</span><del>-        }
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 
</span><span class="cx">                 if (check && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &&
</span><span class="lines">@@ -2896,23 +2896,33 @@
</span><span class="cx">         uint8_t fwd = 0;
</span><span class="cx">         void *data = NULL;
</span><span class="cx">         uint32_t len, ts = 0;
</span><del>-        switch_payload_t payload;
</del><ins>+        switch_payload_t payload = 0;
</ins><span class="cx">         rtp_msg_t *send_msg = NULL;
</span><del>-
</del><ins>+        
</ins><span class="cx">         if (!switch_rtp_ready(rtp_session) || !rtp_session->remote_addr) {
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
</span><span class="cx">                 switch_size_t bytes;
</span><del>-
</del><ins>+                char bufa[30];
+                const char *tx_host;
</ins><span class="cx">                 /* Fast PASS! */
</span><span class="cx">                 if (!switch_test_flag(frame, SFF_PROXY_PACKET)) {
</span><span class="cx">                         return 0;
</span><span class="cx">                 }
</span><span class="cx">                 bytes = frame->packetlen;
</span><del>-                if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, frame->packet, &bytes) != SWITCH_STATUS_SUCCESS) {
-                        return -1;
</del><ins>+                tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->remote_addr);
+                
+
+                send_msg = frame->packet;
+
+                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
+                        send_msg->header.pt = rtp_session->payload;
+
+                        if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, frame->packet, &bytes) != SWITCH_STATUS_SUCCESS) {
+                                return -1;
+                        }
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 rtp_session->stats.outbound.raw_bytes += bytes;
</span><span class="lines">@@ -2947,7 +2957,11 @@
</span><span class="cx">         switch_assert(frame != NULL);
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(frame, SFF_CNG)) {
</span><del>-                payload = rtp_session->cng_pt;
</del><ins>+                if (rtp_session->cng_pt) {
+                        payload = rtp_session->cng_pt;
+                } else {
+                        return (int)frame->packetlen;
+                }
</ins><span class="cx">         } else {
</span><span class="cx">                 payload = rtp_session->payload;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>