<!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][16858] </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=16858">16858</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-03-01 19:11:15 -0600 (Mon, 01 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>add events for bug start and stop</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibseslsrcesl_eventc">freeswitch/trunk/libs/esl/src/esl_event.c</a></li>
<li><a href="#freeswitchtrunklibseslsrcincludeesl_eventh">freeswitch/trunk/libs/esl/src/include/esl_event.h</a></li>
<li><a href="#freeswitchtrunksrcincludeprivateswitch_core_pvth">freeswitch/trunk/src/include/private/switch_core_pvt.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_faxmod_faxc">freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_snapshotmod_snapshotc">freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_shoutmod_shoutc">freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_media_bugc">freeswitch/trunk/src/switch_core_media_bug.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_eventc">freeswitch/trunk/src/switch_event.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_asyncc">freeswitch/trunk/src/switch_ivr_async.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibseslsrcesl_eventc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/esl/src/esl_event.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/esl/src/esl_event.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/libs/esl/src/esl_event.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -131,6 +131,8 @@
</span><span class="cx">         &quot;CALL_UPDATE&quot;,
</span><span class="cx">         &quot;FAILURE&quot;,
</span><span class="cx">         &quot;SOCKET_DATA&quot;,
</span><ins>+        &quot;MEDIA_BUG_START&quot;,
+        &quot;MEDIA_BUG_START&quot;,
</ins><span class="cx">         &quot;ALL&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunklibseslsrcincludeesl_eventh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/esl/src/include/esl_event.h (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/esl/src/include/esl_event.h        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/libs/esl/src/include/esl_event.h        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -119,6 +119,8 @@
</span><span class="cx">         ESL_EVENT_CALL_UPDATE,
</span><span class="cx">         ESL_EVENT_FAILURE,
</span><span class="cx">         ESL_EVENT_SOCKET_DATA,
</span><ins>+        ESL_EVENT_MEDIA_BUG_START,
+        ESL_EVENT_MEDIA_BUG_STOP,
</ins><span class="cx">         ESL_EVENT_ALL
</span><span class="cx"> } esl_event_types_t;
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeprivateswitch_core_pvth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -177,6 +177,8 @@
</span><span class="cx">         int16_t tmp[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">         time_t stop_time;
</span><span class="cx">         switch_thread_id_t thread_id;
</span><ins>+        char *function;
+        char *target;
</ins><span class="cx">         struct switch_media_bug *next;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/include/switch_core.h        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -147,6 +147,8 @@
</span><span class="cx">   \return SWITCH_STATUS_SUCCESS if the operation was a success
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(_In_ switch_core_session_t *session,
</span><ins>+                                                                                                                  _In_ const char *function,
+                                                                                                                  _In_ const char *target,
</ins><span class="cx">                                                                                                                   _In_ switch_media_bug_callback_t callback,
</span><span class="cx">                                                                                                                   _In_opt_ void *user_data,
</span><span class="cx">                                                                                                                   _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/include/switch_types.h        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -1350,6 +1350,8 @@
</span><span class="cx">         SWITCH_EVENT_CALL_UPDATE,
</span><span class="cx">         SWITCH_EVENT_FAILURE,
</span><span class="cx">         SWITCH_EVENT_SOCKET_DATA,
</span><ins>+        SWITCH_EVENT_MEDIA_BUG_START,
+        SWITCH_EVENT_MEDIA_BUG_STOP,
</ins><span class="cx">         SWITCH_EVENT_ALL
</span><span class="cx"> } switch_event_types_t;
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_faxmod_faxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -843,7 +843,8 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;spandsp_dtmf_detect&quot;, NULL,
+                                            inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_snapshotmod_snapshotc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">         switch_buffer_create_dynamic(&amp;cb-&gt;buffer, bytes, bytes, bytes);
</span><span class="cx">         switch_mutex_init(&amp;cb-&gt;mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, capture_callback, cb, 0, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;snapshot&quot;, NULL, capture_callback, cb, 0, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_shoutmod_shoutc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -1187,7 +1187,8 @@
</span><span class="cx">                 switch_buffer_create_dynamic(&amp;buffer, 1024, 2048, 0);
</span><span class="cx">                 switch_buffer_add_mutex(buffer, mutex);
</span><span class="cx"> 
</span><del>-                if (switch_core_media_bug_add(tsession, telecast_callback, buffer, 0,
</del><ins>+                if (switch_core_media_bug_add(tsession, &quot;telecast&quot;, NULL,
+                                                                          telecast_callback, buffer, 0,
</ins><span class="cx">                                                                           SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING, &amp;bug) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/switch_channel.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -1652,7 +1652,11 @@
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_API ||
</span><span class="cx">                 event-&gt;event_id == SWITCH_EVENT_RECORD_START ||
</span><del>-                event-&gt;event_id == SWITCH_EVENT_RECORD_STOP || event-&gt;event_id == SWITCH_EVENT_CALL_UPDATE || event-&gt;event_id == SWITCH_EVENT_CUSTOM) {
</del><ins>+                event-&gt;event_id == SWITCH_EVENT_RECORD_STOP || 
+                event-&gt;event_id == SWITCH_EVENT_CALL_UPDATE || 
+                event-&gt;event_id == SWITCH_EVENT_MEDIA_BUG_START || 
+                event-&gt;event_id == SWITCH_EVENT_MEDIA_BUG_STOP || 
+                event-&gt;event_id == SWITCH_EVENT_CUSTOM) {
</ins><span class="cx"> 
</span><span class="cx">                 x = 0;
</span><span class="cx">                 /* Index Variables */
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_media_bugc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_media_bug.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_media_bug.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/switch_core_media_bug.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -240,13 +240,19 @@
</span><span class="cx"> 
</span><span class="cx"> #define MAX_BUG_BUFFER 1024 * 512
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
</span><ins>+                                                                                                                  const char *function,
+                                                                                                                  const char *target,
</ins><span class="cx">                                                                                                                   switch_media_bug_callback_t callback,
</span><del>-                                                                                                                  void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
</del><ins>+                                                                                                                  void *user_data, time_t stop_time, 
+                                                                                                                  switch_media_bug_flag_t flags, 
+                                                                                                                  switch_media_bug_t **new_bug)
</ins><span class="cx"> {
</span><span class="cx">         switch_media_bug_t *bug;        //, *bp;
</span><span class="cx">         switch_size_t bytes;
</span><span class="cx">         switch_codec_implementation_t read_impl = { 0 };
</span><span class="cx">         switch_codec_implementation_t write_impl = { 0 };
</span><ins>+        switch_event_t *event;
+
</ins><span class="cx">         const char *p;
</span><span class="cx"> 
</span><span class="cx">         if (!switch_channel_media_ready(session-&gt;channel)) {
</span><span class="lines">@@ -298,7 +304,17 @@
</span><span class="cx">         bug-&gt;user_data = user_data;
</span><span class="cx">         bug-&gt;session = session;
</span><span class="cx">         bug-&gt;flags = flags;
</span><ins>+        bug-&gt;function = &quot;N/A&quot;;
+        bug-&gt;target = &quot;N/A&quot;;
</ins><span class="cx"> 
</span><ins>+        if (function) {
+                bug-&gt;function = switch_core_session_strdup(session, function);
+        }
+
+        if (target) {
+                bug-&gt;target = switch_core_session_strdup(session, target);
+        }
+        
</ins><span class="cx">         bug-&gt;stop_time = stop_time;
</span><span class="cx">         bytes = read_impl.decoded_bytes_per_packet;
</span><span class="cx"> 
</span><span class="lines">@@ -340,6 +356,14 @@
</span><span class="cx">         switch_thread_rwlock_unlock(session-&gt;bug_rwlock);
</span><span class="cx">         *new_bug = bug;
</span><span class="cx"> 
</span><ins>+        if (switch_event_create(&amp;event, SWITCH_EVENT_MEDIA_BUG_START) == SWITCH_STATUS_SUCCESS) {
+                switch_channel_event_set_data(session-&gt;channel, event);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Media-Bug-Function&quot;, &quot;%s&quot;, bug-&gt;function);
+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Media-Bug-Target&quot;, &quot;%s&quot;, bug-&gt;target);
+                switch_event_fire(&amp;event);
+        }
+
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -437,7 +461,17 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_thread_rwlock_unlock(session-&gt;bug_rwlock);
</span><span class="cx">                 if (bp) {
</span><del>-                        status = switch_core_media_bug_close(&amp;bp);
</del><ins>+                        switch_event_t *event;
+
+                        if ((status = switch_core_media_bug_close(&amp;bp)) == SWITCH_STATUS_SUCCESS) {
+                                if (switch_event_create(&amp;event, SWITCH_EVENT_MEDIA_BUG_STOP) == SWITCH_STATUS_SUCCESS) {
+                                        switch_channel_event_set_data(session-&gt;channel, event);
+                                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Media-Bug-Function&quot;, &quot;%s&quot;, bp-&gt;function);
+                                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, &quot;Media-Bug-Target&quot;, &quot;%s&quot;, bp-&gt;target);
+                                        switch_event_fire(&amp;event);
+                                }
+
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_eventc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_event.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_event.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/switch_event.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -187,6 +187,8 @@
</span><span class="cx">         &quot;CALL_UPDATE&quot;,
</span><span class="cx">         &quot;FAILURE&quot;,
</span><span class="cx">         &quot;SOCKET_DATA&quot;,
</span><ins>+        &quot;MEDIA_BUG_START&quot;,
+        &quot;MEDIA_BUG_STOP&quot;,
</ins><span class="cx">         &quot;ALL&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_asyncc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_async.c (16857 => 16858)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_async.c        2010-03-02 01:08:31 UTC (rev 16857)
+++ freeswitch/trunk/src/switch_ivr_async.c        2010-03-02 01:11:15 UTC (rev 16858)
</span><span class="lines">@@ -403,9 +403,11 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (flags &amp;&amp; strchr(flags, 'r')) {
</span><del>-                status = switch_core_media_bug_add(session, read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &amp;bug);
</del><ins>+                status = switch_core_media_bug_add(session, &quot;displace&quot;, file,
+                                                                                   read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &amp;bug);
</ins><span class="cx">         } else {
</span><del>-                status = switch_core_media_bug_add(session, write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &amp;bug);
</del><ins>+                status = switch_core_media_bug_add(session, &quot;displace&quot;, file,
+                                                                                   write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &amp;bug);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -728,7 +730,8 @@
</span><span class="cx">                 switch_buffer_add_mutex(ep-&gt;r_buffer, ep-&gt;r_mutex);
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-                if (switch_core_media_bug_add(tsession, eavesdrop_callback, ep, 0,
</del><ins>+                if (switch_core_media_bug_add(tsession, &quot;eavesdrop&quot;, uuid,
+                                                                          eavesdrop_callback, ep, 0,
</ins><span class="cx">                                                                           SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_READ_PING | SMBF_THREAD_LOCK,
</span><span class="cx">                                                                           &amp;bug) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Cannot attach bug\n&quot;);
</span><span class="lines">@@ -1052,7 +1055,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, record_callback, rh, to, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;session_record&quot;, file,
+                                                                                        record_callback, rh, to, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error adding media bug for file %s\n&quot;, file);
</span><span class="cx">                 switch_core_file_close(fh);
</span><span class="cx">                 return status;
</span><span class="lines">@@ -1332,7 +1336,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, preprocess_callback, cb, to, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;preprocess&quot;, NULL,
+                                                                                        preprocess_callback, cb, to, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, &quot;Error adding media bug.\n&quot;);
</span><span class="cx">                 if (cb-&gt;read_st) {
</span><span class="cx">                         speex_preprocess_state_destroy(cb-&gt;read_st);
</span><span class="lines">@@ -1488,9 +1493,9 @@
</span><span class="cx"> 
</span><span class="cx">         if (existing) {
</span><span class="cx">                 switch_core_media_bug_set_flag(bug, flags);
</span><del>-
</del><span class="cx">         } else {
</span><del>-                if ((status = switch_core_media_bug_add(session, session_audio_callback, pvt, 0, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if ((status = switch_core_media_bug_add(session, &quot;audio&quot;, cmd,
+                                                                                                session_audio_callback, pvt, 0, flags, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         return status;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -1582,7 +1587,8 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;inband_dtmf&quot;, NULL,
+                                                                                        inband_dtmf_callback, pvt, 0, SMBF_READ_REPLACE, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1781,7 +1787,8 @@
</span><span class="cx">         pvt-&gt;session = session;
</span><span class="cx">         pvt-&gt;read = !!read_stream;
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, inband_dtmf_generate_callback, pvt, 0,
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;inband_dtmf_generate&quot;, NULL,
+                                                                                        inband_dtmf_generate_callback, pvt, 0,
</ins><span class="cx">                                                                                         pvt-&gt;read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &amp;bug)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="lines">@@ -2091,7 +2098,8 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, &quot;%s bug already running\n&quot;, switch_channel_get_name(channel));
</span><span class="cx">         } else {
</span><span class="cx">                 cont-&gt;bug_running = 1;
</span><del>-                if ((status = switch_core_media_bug_add(session, tone_detect_callback, cont, timeout, bflags, &amp;cont-&gt;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if ((status = switch_core_media_bug_add(session, &quot;tone_detect&quot;, key,
+                                                                                                tone_detect_callback, cont, timeout, bflags, &amp;cont-&gt;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         cont-&gt;bug_running = 0;
</span><span class="cx">                         return status;
</span><span class="cx">                 }
</span><span class="lines">@@ -2622,8 +2630,12 @@
</span><span class="cx">         struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
</span><span class="cx">         switch_codec_implementation_t read_impl = { 0 };
</span><span class="cx">         const char *p;
</span><ins>+        char key[512] = &quot;&quot;;
+
</ins><span class="cx">         switch_core_session_get_read_impl(session, &amp;read_impl);
</span><span class="cx"> 
</span><ins>+        switch_snprintf(key, sizeof(key), &quot;%s/%s/%s/%s&quot;, mod_name, grammar, name, dest);
+
</ins><span class="cx">         if (!ah) {
</span><span class="cx">                 if (!(ah = switch_core_session_alloc(session, sizeof(*ah)))) {
</span><span class="cx">                         return SWITCH_STATUS_MEMERR;
</span><span class="lines">@@ -2668,7 +2680,8 @@
</span><span class="cx">                 switch_set_flag(ah, SWITCH_ASR_FLAG_FIRE_EVENTS);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((status = switch_core_media_bug_add(session, speech_callback, sth, 0, SMBF_READ_STREAM, &amp;sth-&gt;bug)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = switch_core_media_bug_add(session, &quot;detect_speech&quot;, key,
+                                                                                        speech_callback, sth, 0, SMBF_READ_STREAM, &amp;sth-&gt;bug)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_core_asr_close(ah, &amp;flags);
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>