[asterisk-commits] oej: branch oej/pinefrog-rtcp-1.8 r382682 - in /team/oej/pinefrog-rtcp-1.8: i...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 8 08:45:31 CST 2013


Author: oej
Date: Fri Mar  8 08:45:26 2013
New Revision: 382682

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382682
Log:
Implement RTP hold, but don't bother with using it.

Modified:
    team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h
    team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c
    team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c

Modified: team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h?view=diff&rev=382682&r1=382681&r2=382682
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h (original)
+++ team/oej/pinefrog-rtcp-1.8/include/asterisk/rtp_engine.h Fri Mar  8 08:45:26 2013
@@ -355,6 +355,9 @@
 	int (*destroy)(struct ast_rtp_instance *instance);
 	/*! Callback for writing out a frame */
 	int (*write)(struct ast_rtp_instance *instance, struct ast_frame *frame);
+	/*! Callback for stopping the outbound RTP media for an instance,
+	    but keeping the RTCP flow (and the RTP keepalives if needed) */
+	void (*hold)(struct ast_rtp_instance *instance, int status);
 	/*! Callback for stopping the RTP instance */
 	void (*stop)(struct ast_rtp_instance *instance);
 	/*! Callback for starting RFC2833 DTMF transmission */
@@ -1357,6 +1360,26 @@
 int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
 
 /*!
+ * \brief Stop the RTP outbound media in a stream, but keep the RTCP flow going
+ * 	  And propably RTP keepalives too.
+ *
+ * \param instance Instance that media is no longer going to at this time
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_rtp_instance_stop(instance);
+ * \endcode
+ *
+ * This tells the RTP engine being used for the instance pointed to by instance
+ * that media is no longer going to it at this time, but may in the future.
+ * Keep the RTCP flow happy
+ *
+ * \since 1.42
+ */
+void ast_rtp_instance_hold(struct ast_rtp_instance *instance, int status);
+
+/*!
  * \brief Stop an RTP instance
  *
  * \param instance Instance that media is no longer going to at this time

Modified: team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c?view=diff&rev=382682&r1=382681&r2=382682
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c (original)
+++ team/oej/pinefrog-rtcp-1.8/main/rtp_engine.c Fri Mar  8 08:45:26 2013
@@ -21,6 +21,9 @@
  * \brief Pluggable RTP Architecture
  *
  * \author Joshua Colp <jcolp at digium.com>
+ *
+ * Improved RTCP support by
+ * \author Olle E. Johansson  <oej at edvina.net>
  */
 
 /*** MODULEINFO
@@ -774,6 +777,13 @@
 int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
 {
 	return instance->engine->qos ? instance->engine->qos(instance, tos, cos, desc) : -1;
+}
+
+void ast_rtp_instance_hold(struct ast_rtp_instance *instance, int status)
+{
+	if (instance->engine->hold) {
+		instance->engine->hold(instance, status);
+	}
 }
 
 void ast_rtp_instance_stop(struct ast_rtp_instance *instance)

Modified: team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c?view=diff&rev=382682&r1=382681&r2=382682
==============================================================================
--- team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c (original)
+++ team/oej/pinefrog-rtcp-1.8/res/res_rtp_asterisk.c Fri Mar  8 08:45:26 2013
@@ -132,6 +132,7 @@
 #define FLAG_NAT_INACTIVE_NOWARN        (1 << 1)
 #define FLAG_NEED_MARKER_BIT            (1 << 3)
 #define FLAG_DTMF_COMPENSATE            (1 << 4)
+#define FLAG_HOLD	        	(1 << 4)	/* This RTP stream is put on hold by someone else, a:sendonly */
 
 /*! \brief RTP session description */
 struct ast_rtp {
@@ -173,10 +174,11 @@
 	unsigned int dtmf_timeout;        /*!< When this timestamp is reached we consider END frame lost and forcibly abort digit */
 	unsigned int dtmfsamples;
 	enum ast_rtp_dtmf_mode dtmfmode;  /*!< The current DTMF mode of the RTP stream */
+
 	/* DTMF Transmission Variables */
 	unsigned int lastdigitts;
-	char sending_digit;	/*!< boolean - are we sending digits */
-	char send_digit;	/*!< digit we are sending */
+	char sending_digit;		  /*!< boolean - are we sending digits */
+	char send_digit;		  /*!< digit we are sending */
 	int send_payload;
 	int send_duration;
 	unsigned int flags;
@@ -186,6 +188,7 @@
 	struct timeval start;           /*!< When the stream started (we can't depend on CDRs) */
 	struct timeval lastrx;          /*!< timeval when we last received a packet */
 	struct timeval dtmfmute;
+	struct timeval holdstart;       /*!< When the stream was put on hold */
 	struct ast_smoother *smoother;
 	int *ioid;
 	int *ioidrtcp;
@@ -193,7 +196,6 @@
 	unsigned short rxseqno;
 	struct sched_context *sched;
 	struct io_context *io;
-	struct io_context *iortcp;      /*!< for RTCP callback */
 	void *data;
 	struct ast_rtcp *rtcp;
 	struct ast_rtp *bridged;        /*!< Who we are Packet bridged to */
@@ -330,6 +332,7 @@
 static int ast_rtp_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
 static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
 static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
+static void ast_rtp_hold(struct ast_rtp_instance *instance, int status);
 static void ast_rtp_stop(struct ast_rtp_instance *instance);
 static int ast_rtp_qos_set(struct ast_rtp_instance *instance, int tos, int cos, const char* desc);
 static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level);
@@ -366,6 +369,7 @@
 	.get_stat = ast_rtp_get_stat,
 	.dtmf_compatible = ast_rtp_dtmf_compatible,
 	.stun_request = ast_rtp_stun_request,
+	.hold = ast_rtp_hold,
 	.stop = ast_rtp_stop,
 	.qos = ast_rtp_qos_set,
 	.sendcng = ast_rtp_sendcng,
@@ -1397,6 +1401,12 @@
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
 	struct ast_sockaddr remote_address = { {0,} };
 	format_t codec, subclass;
+
+	if (ast_test_flag(rtp, FLAG_HOLD)) {
+		/* This stream is on hold, just keep on happily and don't do anything */
+		ast_debug(1, "** Frame muted since we're on hold. \n");
+		return 0;
+	}
 
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
@@ -3061,6 +3071,20 @@
 	ast_sockaddr_from_sin(suggestion, &suggestion_tmp);
 }
 
+/* \brief Put stream on/off hold, mute outbound RTP but keep
+	RTP keepalives and RTCP going
+ */
+static void ast_rtp_hold(struct ast_rtp_instance *instance, int status)
+{
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	if (status) {
+		ast_set_flag(rtp, FLAG_HOLD);
+	} else {
+		/* CLEAR */
+		ast_clear_flag(rtp, FLAG_HOLD);
+	}
+}
+
 static void ast_rtp_stop(struct ast_rtp_instance *instance)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);




More information about the asterisk-commits mailing list