[asterisk-commits] file: branch group/pimp_my_sip r379119 - in /team/group/pimp_my_sip: channels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 15 12:40:30 CST 2013


Author: file
Date: Tue Jan 15 12:40:26 2013
New Revision: 379119

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379119
Log:
Add preliminary media related stuff.

Modified:
    team/group/pimp_my_sip/channels/chan_gulp.c
    team/group/pimp_my_sip/include/asterisk/res_sip_session.h

Modified: team/group/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=379119&r1=379118&r2=379119
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Tue Jan 15 12:40:26 2013
@@ -148,13 +148,59 @@
 /*! \brief Function called by core to read any waiting frames */
 static struct ast_frame *gulp_read(struct ast_channel *ast)
 {
-	return NULL;
+	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	struct ast_frame *f;
+
+	switch (ast_channel_fdno(ast)) {
+	case 0:
+		f = ast_rtp_instance_read(session->media.audio, 0);
+		break;
+	case 1:
+		f = ast_rtp_instance_read(session->media.audio, 1);
+		break;
+	default:
+		f = &ast_null_frame;
+	}
+
+	if (f->frametype == AST_FRAME_VOICE) {
+		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
+			ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
+			ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
+			ast_set_read_format(ast, ast_channel_readformat(ast));
+			ast_set_write_format(ast, ast_channel_writeformat(ast));
+		}
+	}
+
+	return f;
 }
 
 /*! \brief Function called by core to write frames */
 static int gulp_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-	return -1;
+	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+	int res = 0;
+
+	switch (frame->frametype) {
+	case AST_FRAME_VOICE:
+		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
+			char buf[256];
+
+			ast_log(LOG_WARNING,
+				"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
+				ast_getformatname(&frame->subclass.format),
+				ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
+				ast_getformatname(ast_channel_readformat(ast)),
+				ast_getformatname(ast_channel_writeformat(ast)));
+			return 0;
+		}
+		res = ast_rtp_instance_write(session->media.audio, frame);
+		break;
+	default:
+		ast_log(LOG_WARNING, "Can't send %d type frames with Gulp\n", frame->frametype);
+		break;
+	}
+
+	return res;
 }
 
 /*! \brief Function called by core to change the underlying owner channel */
@@ -255,13 +301,21 @@
 /*! \brief Function called by core to start a DTMF digit */
 static int gulp_digit_begin(struct ast_channel *chan, char digit)
 {
-	return -1;
+	struct ast_sip_session *session = ast_channel_tech_pvt(chan);
+
+	ast_rtp_instance_dtmf_begin(session->media.audio, digit);
+
+	return 0;
 }
 
 /*! \brief Function called by core to stop a DTMF digit */
 static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-	return -1;
+	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+
+	ast_rtp_instance_dtmf_end_with_duration(session->media.audio, digit, duration);
+
+	return 0;
 }
 
 /*! \brief Function called by core to actually start calling a remote party */

Modified: team/group/pimp_my_sip/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip_session.h?view=diff&rev=379119&r1=379118&r2=379119
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip_session.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip_session.h Tue Jan 15 12:40:26 2013
@@ -33,6 +33,15 @@
 struct ast_party_id;
 struct pjmedia_sdp_media;
 struct pjmedia_sdp_session;
+struct ast_rtp_instance;
+
+/*!
+ * \brief A structure containing SIP session media information
+ */
+struct ast_sip_session_media {
+    /* RTP instance for audio */
+    struct ast_rtp_instance *audio;
+};
 
 /*!
  * \brief A structure describing a SIP session
@@ -48,6 +57,8 @@
 	AST_LIST_HEAD(, ast_sip_session_supplement) supplements;
     /* Datastores added to the session by supplements to the session */
 	struct ao2_container *datastores;
+    /* Media information */
+    struct ast_sip_session_media media;
 };
 
 /*!




More information about the asterisk-commits mailing list