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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 22 11:37:57 CST 2013


Author: file
Date: Tue Jan 22 11:37:54 2013
New Revision: 379881

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379881
Log:
For testing purposes allow calling any given SIP URI.

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

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=379881&r1=379880&r2=379881
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Tue Jan 22 11:37:54 2013
@@ -469,9 +469,19 @@
 /*! \brief Function called by core to create a new outgoing Gulp session */
 static struct ast_channel *gulp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause)
 {
+	struct ast_sip_endpoint *endpoint = ast_sip_endpoint_alloc("constant");
 	struct ast_sip_session *session = NULL;
 
-	/* TODO: Add call which sets up session, dialog, UAC, etc etc */
+	if (!endpoint) {
+		return NULL;
+	}
+
+	ast_string_field_set(endpoint, context, "default");
+	ast_parse_allow_disallow(&endpoint->prefs, endpoint->codecs, "ulaw", 1);
+
+	if (!(session = ast_sip_session_create_outgoing(endpoint, data))) {
+		return NULL;
+	}
 
 	if (!(session->channel = gulp_new(session, AST_STATE_DOWN, NULL, NULL, requestor ? ast_channel_linkedid(requestor) : NULL, NULL))) {
 		/* Session needs to be terminated prematurely */

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=379881&r1=379880&r2=379881
==============================================================================
--- 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 22 11:37:54 2013
@@ -139,6 +139,14 @@
 struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, pjsip_inv_session *inv);
 
 /*!
+ * \brief Create a new outgoing SIP session
+ *
+ * \param endpoint The endpoint that this session uses for settings
+ * \param uri The URI to call
+ */
+struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *uri);
+
+/*!
  * \brief Register an SDP handler
  *
  * An SDP handler is responsible for parsing incoming SDP streams and ensuring that

Modified: team/group/pimp_my_sip/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.c?view=diff&rev=379881&r1=379880&r2=379881
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Tue Jan 22 11:37:54 2013
@@ -453,6 +453,42 @@
 	}
 	inv_session->mod_data[session_module.id] = session;
 	ao2_ref(session, +1);
+	return session;
+}
+
+struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *uri)
+{
+	/* TODO: The local URI needs to be dynamically constructed based on different things */
+	pj_str_t local_uri = pj_str("sip:test at local"), remote_uri = pj_str((char*)uri);
+	pjsip_dialog *dlg = NULL;
+	pjsip_inv_session *inv_session = NULL;
+	struct ast_sip_session *session = NULL;
+	pjmedia_sdp_session *offer = NULL;
+
+	if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, NULL, &dlg) != PJ_SUCCESS) {
+		return NULL;
+	}
+
+	if (pjsip_inv_create_uac(dlg, NULL, 0, &inv_session) != PJ_SUCCESS) {
+		pjsip_dlg_terminate(dlg);
+		return NULL;
+	}
+	
+	if (pjsip_dlg_add_usage(dlg, &session_module, NULL) != PJ_SUCCESS) {
+		pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
+		return NULL;
+	}
+
+	if (!(session = ast_sip_session_alloc(endpoint, inv_session))) {
+		pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
+		return NULL;
+	}
+
+	if ((offer = create_local_sdp(inv_session, session, NULL))) {
+		/* TODO: If this fails the session is useless, we need to stop it */
+		pjsip_inv_set_local_sdp(inv_session, offer);
+	}
+
 	return session;
 }
 
@@ -817,6 +853,7 @@
 	pjsip_tsx_layer_init_module(endpt);
 	pjsip_ua_init_module(endpt, NULL);
 	pjsip_inv_usage_init(endpt, &inv_callback);
+	pjsip_100rel_init_module(endpt);
 	if (ast_sip_register_service(&session_module)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}

Modified: team/group/pimp_my_sip/res/res_sip_session.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.exports.in?view=diff&rev=379881&r1=379880&r2=379881
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.exports.in (original)
+++ team/group/pimp_my_sip/res/res_sip_session.exports.in Tue Jan 22 11:37:54 2013
@@ -10,6 +10,7 @@
 		LINKER_SYMBOL_PREFIXast_sip_session_get_identity;
 		LINKER_SYMBOL_PREFIXast_sip_session_send_reinvite;
 		LINKER_SYMBOL_PREFIXast_sip_session_send_response;
+		LINKER_SYMBOL_PREFIXast_sip_session_create_outgoing;
 		LINKER_SYMBOL_PREFIXpjsip_inv_*;
 	local:
 		*;




More information about the asterisk-commits mailing list