[asterisk-commits] mmichelson: branch mmichelson/direct_media r382761 - in /team/mmichelson/dire...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Mar 8 15:44:05 CST 2013
Author: mmichelson
Date: Fri Mar 8 15:44:01 2013
New Revision: 382761
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382761
Log:
Allow for direct media to be accomplished using UPDATE instead of INVITE.
This introduced a new function in order to be able to send UPDATEs. I plan
to combine this with the reinvite function into a session refresh function.
Modified:
team/mmichelson/direct_media/channels/chan_gulp.c
team/mmichelson/direct_media/include/asterisk/res_sip.h
team/mmichelson/direct_media/include/asterisk/res_sip_session.h
team/mmichelson/direct_media/res/res_sip/sip_configuration.c
team/mmichelson/direct_media/res/res_sip_session.c
team/mmichelson/direct_media/res/res_sip_session.exports.in
Modified: team/mmichelson/direct_media/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/channels/chan_gulp.c?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/channels/chan_gulp.c (original)
+++ team/mmichelson/direct_media/channels/chan_gulp.c Fri Mar 8 15:44:01 2013
@@ -121,10 +121,7 @@
struct ast_sip_session *session = ast_channel_tech_pvt(chan);
struct ast_sip_endpoint *endpoint = session->endpoint;
- ast_log(LOG_NOTICE, "Trying the get_rtp_peer method for endpoint %s\n", ast_sorcery_object_get_id(endpoint));
-
if (!session || !session->media[AST_SIP_MEDIA_AUDIO].rtp) {
- ast_log(LOG_NOTICE, "Big time failure for direct media...\n");
return AST_RTP_GLUE_RESULT_FORBID;
}
@@ -133,11 +130,8 @@
ast_assert(endpoint != NULL);
if (endpoint->direct_media) {
- ast_log(LOG_NOTICE, "Saying that remote bridging will work\n");
return AST_RTP_GLUE_RESULT_REMOTE;
}
-
- ast_log(LOG_NOTICE, "Remote bridgin won't work...\n");
return AST_RTP_GLUE_RESULT_LOCAL;
}
@@ -147,14 +141,14 @@
{
}
-static int send_direct_media_reinvite(void *data)
+static int send_direct_media_request(void *data)
{
RAII_VAR(struct ast_sip_session *, session, data, ao2_cleanup);
-
- ast_log(LOG_NOTICE, "Should be calling method to send a reinvite now to %s\n",
- S_OR(ast_sorcery_object_get_id(session->endpoint), "outbound"));
-
- return ast_sip_session_send_reinvite(session, NULL);
+ if (session->endpoint->direct_media_method == AST_SIP_DIRECT_MEDIA_METHOD_INVITE) {
+ return ast_sip_session_send_reinvite(session, NULL);
+ } else {
+ return ast_sip_session_send_update(session);
+ }
}
/*! \brief Function called by RTP engine to change where the remote party should send media */
@@ -202,7 +196,7 @@
* comes up
*/
ao2_ref(session, +1);
- ast_sip_push_task(session->serializer, send_direct_media_reinvite, session);
+ ast_sip_push_task(session->serializer, send_direct_media_request, session);
} else {
ast_log(LOG_NOTICE, "No change detected. Not doing anathin\n");
}
@@ -745,6 +739,7 @@
endpoint->min_se = 90;
endpoint->sess_expires = 1800;
endpoint->direct_media = 1;
+ endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_UPDATE;
if (!(session = ast_sip_session_create_outgoing(endpoint, req_data->dest))) {
return -1;
Modified: team/mmichelson/direct_media/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/include/asterisk/res_sip.h?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip.h Fri Mar 8 15:44:01 2013
@@ -211,6 +211,13 @@
AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME = (1 << 0),
/*! Identify based on source location of the SIP message */
AST_SIP_ENDPOINT_IDENTIFY_BY_LOCATION = (1 << 1),
+};
+
+enum ast_sip_direct_media_method {
+ /*! Use reinvite to negotiate direct media */
+ AST_SIP_DIRECT_MEDIA_METHOD_INVITE,
+ /*! Use UPDATE to negotiate direct media */
+ AST_SIP_DIRECT_MEDIA_METHOD_UPDATE,
};
/*!
@@ -262,6 +269,8 @@
enum ast_sip_endpoint_identifier_type ident_method;
/*! Boolean indicating if direct_media is permissible */
unsigned int direct_media;
+ /*! When using direct media, which method should be used */
+ enum ast_sip_direct_media_method direct_media_method;
};
/*!
Modified: team/mmichelson/direct_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/include/asterisk/res_sip_session.h?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/include/asterisk/res_sip_session.h (original)
+++ team/mmichelson/direct_media/include/asterisk/res_sip_session.h Fri Mar 8 15:44:01 2013
@@ -381,6 +381,15 @@
int ast_sip_session_send_reinvite(struct ast_sip_session *session, int (*response_cb)(struct ast_sip_session *session, struct pjsip_rx_data *rdata));
/*!
+ * \brief Send an UPDATE on a session
+ *
+ * \param session The session on which to send the UPDATE
+ * \retval 0 Successfully sent UPDATE
+ * \retval -1 Failure to send UPDATE
+ */
+int ast_sip_session_send_update(struct ast_sip_session *session);
+
+/*!
* \brief Send a SIP response
*
* This will send the SIP response specified in tdata and
Modified: team/mmichelson/direct_media/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip/sip_configuration.c?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/direct_media/res/res_sip/sip_configuration.c Fri Mar 8 15:44:01 2013
@@ -250,6 +250,22 @@
val, ast_sorcery_object_get_id(endpoint));
return -1;
}
+ }
+ return 0;
+}
+
+static int direct_media_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+ struct ast_sip_endpoint *endpoint = obj;
+
+ if (!strcasecmp(var->value, "invite") || !strcasecmp(var->value, "reinvite")) {
+ endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_INVITE;
+ } else if (!strcasecmp(var->value, "update")) {
+ endpoint->direct_media_method = AST_SIP_DIRECT_MEDIA_METHOD_UPDATE;
+ } else {
+ ast_log(LOG_NOTICE, "Unrecognized option value %s for %s on endpoint %s\n",
+ var->value, var->name, ast_sorcery_object_get_id(endpoint));
+ return -1;
}
return 0;
}
@@ -308,6 +324,7 @@
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "auth", "", auth_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "identify_by", "username,location", ident_handler, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "direct_media", "yes", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, direct_media));
+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_method", "invite", direct_media_method_handler, NULL, 0, 0);
if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");
Modified: team/mmichelson/direct_media/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.c?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.c (original)
+++ team/mmichelson/direct_media/res/res_sip_session.c Fri Mar 8 15:44:01 2013
@@ -428,6 +428,35 @@
reinvite_sdp = create_local_sdp(inv_session, session, last_sdp);
if (pjsip_inv_reinvite(inv_session, NULL, reinvite_sdp, &tdata)) {
ast_log(LOG_WARNING, "Failed to create reinvite properly.\n");
+ return -1;
+ }
+ ast_sip_session_send_request(session, tdata);
+ return 0;
+}
+
+int ast_sip_session_send_update(struct ast_sip_session *session)
+{
+ pjsip_inv_session *inv_session = session->inv_session;
+ pjmedia_sdp_session *update_sdp;
+ const pjmedia_sdp_session *last_sdp;
+ pjsip_tx_data *tdata;
+
+ if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
+ /* Don't try to do anything with a hung-up call */
+ ast_debug(3, "Not sending reinvite to %s because of disconnected state...\n",
+ S_OR(ast_sorcery_object_get_id(session->endpoint), "outbound"));
+ return 0;
+ }
+
+ if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
+ pjmedia_sdp_neg_get_active_remote(inv_session->neg, &last_sdp);
+ } else {
+ pjmedia_sdp_neg_get_active_local(inv_session->neg, &last_sdp);
+ }
+
+ update_sdp = create_local_sdp(inv_session, session, last_sdp);
+ if (pjsip_inv_update(inv_session, NULL, update_sdp, &tdata)) {
+ ast_log(LOG_WARNING, "Failed to create UPDATE properly.\n");
return -1;
}
ast_sip_session_send_request(session, tdata);
Modified: team/mmichelson/direct_media/res/res_sip_session.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/direct_media/res/res_sip_session.exports.in?view=diff&rev=382761&r1=382760&r2=382761
==============================================================================
--- team/mmichelson/direct_media/res/res_sip_session.exports.in (original)
+++ team/mmichelson/direct_media/res/res_sip_session.exports.in Fri Mar 8 15:44:01 2013
@@ -9,6 +9,7 @@
LINKER_SYMBOL_PREFIXast_sip_session_remove_datastore;
LINKER_SYMBOL_PREFIXast_sip_session_get_identity;
LINKER_SYMBOL_PREFIXast_sip_session_send_reinvite;
+ LINKER_SYMBOL_PREFIXast_sip_session_send_update;
LINKER_SYMBOL_PREFIXast_sip_session_send_response;
LINKER_SYMBOL_PREFIXast_sip_session_send_request;
LINKER_SYMBOL_PREFIXast_sip_session_create_outgoing;
More information about the asterisk-commits
mailing list