[asterisk-commits] oej: branch oej/roibos-cng-support-1.8 r376231 - in /team/oej/roibos-cng-supp...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 14 10:22:53 CST 2012


Author: oej
Date: Wed Nov 14 10:22:49 2012
New Revision: 376231

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376231
Log:
For now, we're generating music on hold... But at least we're filling the gaps

Modified:
    team/oej/roibos-cng-support-1.8/README.roibos-cng.txt
    team/oej/roibos-cng-support-1.8/channels/chan_sip.c
    team/oej/roibos-cng-support-1.8/configs/sip.conf.sample
    team/oej/roibos-cng-support-1.8/include/asterisk/frame.h
    team/oej/roibos-cng-support-1.8/main/channel.c
    team/oej/roibos-cng-support-1.8/main/features.c
    team/oej/roibos-cng-support-1.8/res/res_rtp_asterisk.c

Modified: team/oej/roibos-cng-support-1.8/README.roibos-cng.txt
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/README.roibos-cng.txt?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/README.roibos-cng.txt (original)
+++ team/oej/roibos-cng-support-1.8/README.roibos-cng.txt Wed Nov 14 10:22:49 2012
@@ -69,6 +69,7 @@
 
 - For inbound streams, generate noise in calls
 - For outbound we can as step 1 just never send any CNG packets
+  - Add CN support in SDP for outbound calls
   - As step 2, add silence detection to calls
   - Measure noise level
   - Start sending CNG
@@ -79,6 +80,7 @@
   - Added res_noise.c from cmantunes from https://issues.asterisk.org/jira/browse/ASTERISK-5263
     This includes a noise generator
   - Add SIP negotiation in SDP - done
+  - Support CN codec on incoming INVITEs - done
 
 References
 ----------
@@ -129,3 +131,13 @@
    u-law system, the reference would be a square wave with values +/-
    8031, and this square wave represents 0dBov.  This translates into
    6.18dBm0.
+
+Notes from chat with FILE (Joshua Colp) 2012-11-13:
+
+file:
+so yeah you'd have to add code to ast_bridge_call to check the CNG availability and add a frame hook to the appropriate channel
+[5:44pm] file:
+then once it returns to remove the frame hook
+[5:45pm] file:
+and by using a frame hook you can keep the associated code contained elsewhere and cause minimal changes to things as a whole
+

Modified: team/oej/roibos-cng-support-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/channels/chan_sip.c?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/channels/chan_sip.c (original)
+++ team/oej/roibos-cng-support-1.8/channels/chan_sip.c Wed Nov 14 10:22:49 2012
@@ -4707,8 +4707,7 @@
 		break;
 	case AST_OPTION_CNG_SUPPORT:
 		/* Check if the current dialog has agreed on Comfort Noise support */
-		*((unsigned int *) data) = (dialog->noncodeccapability & AST_RTP_CN);
-		res = 0;
+		res = (p->noncodeccapability & AST_RTP_CN);
 		break;
 	default:
 		break;

Modified: team/oej/roibos-cng-support-1.8/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/configs/sip.conf.sample?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/configs/sip.conf.sample (original)
+++ team/oej/roibos-cng-support-1.8/configs/sip.conf.sample Wed Nov 14 10:22:49 2012
@@ -305,6 +305,8 @@
 ;				; Available per device too
 ;				; Generating comfort noise is a burden to your CPU
 ;				; This should not be enabled on low-end devices.
+;				; You should not enable this unless you have internal
+;				; timing support enabled in asterisk.conf
 ;
 ; This option specifies a preference for which music on hold class this channel
 ; should listen to when put on hold if the music class has not been set on the

Modified: team/oej/roibos-cng-support-1.8/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/include/asterisk/frame.h?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/include/asterisk/frame.h (original)
+++ team/oej/roibos-cng-support-1.8/include/asterisk/frame.h Wed Nov 14 10:22:49 2012
@@ -338,6 +338,7 @@
 	AST_CONTROL_END_OF_Q = 29,		/*!< Indicate that this position was the end of the channel queue for a softhangup. */
 	AST_CONTROL_INCOMPLETE = 30,	/*!< Indication that the extension dialed is incomplete */
 	AST_CONTROL_UPDATE_RTP_PEER = 31, /*!< Interrupt the bridge and have it update the peer */
+	AST_CONTROL_CNG_END = 32,	/*!< Disable CNG playout in bridge */
 };
 
 enum ast_frame_read_action {

Modified: team/oej/roibos-cng-support-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/main/channel.c?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/main/channel.c (original)
+++ team/oej/roibos-cng-support-1.8/main/channel.c Wed Nov 14 10:22:49 2012
@@ -4375,6 +4375,7 @@
 	case AST_CONTROL_AOC:
 	case AST_CONTROL_END_OF_Q:
 	case AST_CONTROL_UPDATE_RTP_PEER:
+	case AST_CONTROL_CNG_END:
 		break;
 
 	case AST_CONTROL_INCOMPLETE:
@@ -4544,6 +4545,7 @@
 	case AST_CONTROL_SRCUPDATE:
 	case AST_CONTROL_SRCCHANGE:
 	case AST_CONTROL_RADIO_KEY:
+	case AST_CONTROL_CNG_END:
 	case AST_CONTROL_RADIO_UNKEY:
 	case AST_CONTROL_OPTION:
 	case AST_CONTROL_WINK:
@@ -7251,6 +7253,12 @@
 					ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
 				}
 				break;
+			case AST_CONTROL_CNG_END:
+				/* If we are playing out CNG noise on the bridged channel, stop it now. 
+				   otherwise, ignore this frame. */
+				ast_debug(1, "*** Bridge got CNG END frame \n");
+				ast_moh_stop(other);
+				break;
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
 			case AST_CONTROL_VIDUPDATE:
@@ -7271,6 +7279,21 @@
 			}
 			if (bridge_exit)
 				break;
+		}
+		if (f->frametype == AST_FRAME_CNG) {
+			/* We got a CNG frame 
+			  Check if the bridged channel has active CNG 
+			*/
+			int cngsupport = 0;
+			int len = sizeof(cngsupport);
+			ast_channel_queryoption(other, AST_OPTION_CNG_SUPPORT, &cngsupport, &len, 0);
+			if (cngsupport) {
+				ast_debug(1, "*** Bridge got CNG frame. Forwarding it \n");
+				ast_write(other, f);
+			} else {
+				ast_debug(1, "*** Bridge got CNG frame. Playing out noise. (CNG not supported by other channel) \n");
+				ast_moh_start(other, NULL, NULL);
+			}
 		}
 		if ((f->frametype == AST_FRAME_VOICE) ||
 		    (f->frametype == AST_FRAME_DTMF_BEGIN) ||

Modified: team/oej/roibos-cng-support-1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/main/features.c?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/main/features.c (original)
+++ team/oej/roibos-cng-support-1.8/main/features.c Wed Nov 14 10:22:49 2012
@@ -4234,6 +4234,12 @@
 				}
 				ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
 				break;
+			case AST_CONTROL_CNG_END:
+				/* If we are playing out CNG noise on the bridged channel, stop it now. 
+				   otherwise, ignore this frame. */
+				ast_debug(1, "*** Bridge got CNG END frame \n");
+				ast_moh_stop(other);
+				break;
 			case AST_CONTROL_AOC:
 			case AST_CONTROL_HOLD:
 			case AST_CONTROL_UNHOLD:
@@ -4353,6 +4359,21 @@
 					ast_debug(1, "Set feature timer to %ld ms\n", config->feature_timer);
 				}
 			}
+		} else if (f->frametype == AST_FRAME_CNG) {
+			/* We got a CNG frame 
+			  Check if the bridged channel has active CNG 
+			*/
+			int cngsupport = 0;
+			int len = sizeof(cngsupport);
+			ast_channel_queryoption(other, AST_OPTION_CNG_SUPPORT, &cngsupport, &len, 0);
+			if (cngsupport) {
+				ast_debug(1, "*** Bridge got CNG frame. Forwarding it \n");
+				ast_write(other, f);
+			} else {
+				ast_debug(1, "*** Bridge got CNG frame. Playing out noise. (CNG not supported by other channel) \n");
+				ast_moh_start(other, NULL, NULL);
+			}
+			
 		}
 		if (f)
 			ast_frfree(f);

Modified: team/oej/roibos-cng-support-1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/roibos-cng-support-1.8/res/res_rtp_asterisk.c?view=diff&rev=376231&r1=376230&r2=376231
==============================================================================
--- team/oej/roibos-cng-support-1.8/res/res_rtp_asterisk.c (original)
+++ team/oej/roibos-cng-support-1.8/res/res_rtp_asterisk.c Wed Nov 14 10:22:49 2012
@@ -2354,15 +2354,20 @@
 	/* If the payload is not actually an Asterisk one but a special one pass it off to the respective handler */
 	if (!payload.asterisk_format) {
 		struct ast_frame *f = NULL;
+		if (payload.code != AST_RTP_CN && ast_test_flag(rtp, FLAG_CN_ACTIVE)) {
+			/* Insert a control frame to indicate that we need to shut down Comfort Noise generators, if active */
+			struct ast_frame cngoff = { AST_FRAME_CONTROL, { AST_CONTROL_CNG_END, } };
+			ast_debug(0, "####### DEACTIVATING Comfort Noise \n");
+			ast_clear_flag(rtp, FLAG_CN_ACTIVE);
+			f = ast_frdup(&cngoff);
+			AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+			f = NULL;
+		}
 		if (payload.code == AST_RTP_DTMF) {
 			/* process_dtmf_rfc2833 may need to return multiple frames. We do this
 			 * by passing the pointer to the frame list to it so that the method
 			 * can append frames to the list as needed.
 			 */
-			if (ast_test_flag(rtp, FLAG_CN_ACTIVE)) {
-				ast_debug(0, "####### DEACTIVATING Comfort Noise \n");
-				ast_clear_flag(rtp, FLAG_CN_ACTIVE);
-			}
 			process_dtmf_rfc2833(instance, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno, timestamp, &addr, payloadtype, mark, &frames);
 		} else if (payload.code == AST_RTP_CISCO_DTMF) {
 			f = process_dtmf_cisco(instance, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno, timestamp, &addr, payloadtype, mark);
@@ -2386,8 +2391,13 @@
 		return &ast_null_frame;
 	}
 	if (ast_test_flag(rtp, FLAG_CN_ACTIVE)) {
+		struct ast_frame *f = NULL;
+		struct ast_frame cngoff = { AST_FRAME_CONTROL, { AST_CONTROL_CNG_END, } };
 		ast_debug(0, "####### DEACTIVATING Comfort Noise \n");
 		ast_clear_flag(rtp, FLAG_CN_ACTIVE);
+		f = ast_frdup(&cngoff);
+		AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+		f = NULL;
 	}
 
 	rtp->lastrxformat = rtp->f.subclass.codec = payload.code;




More information about the asterisk-commits mailing list