[asterisk-commits] file: branch file/pimp_sip_media r380916 - /team/file/pimp_sip_media/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 5 15:38:50 CST 2013
Author: file
Date: Tue Feb 5 15:38:47 2013
New Revision: 380916
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380916
Log:
Use a session supplement to destroy the audio RTP instance when a session ends.
Modified:
team/file/pimp_sip_media/res/res_sip_sdp_audio.c
Modified: team/file/pimp_sip_media/res/res_sip_sdp_audio.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip_sdp_audio.c?view=diff&rev=380916&r1=380915&r2=380916
==============================================================================
--- team/file/pimp_sip_media/res/res_sip_sdp_audio.c (original)
+++ team/file/pimp_sip_media/res/res_sip_sdp_audio.c Tue Feb 5 15:38:47 2013
@@ -58,12 +58,20 @@
static int audio_create_outgoing_sdp_stream(struct ast_sip_session *session, struct pjmedia_sdp_session *sdp);
static int audio_apply_negotiated_sdp_stream(struct ast_sip_session *session, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream);
+/*! \brief Forward declaration for session supplement functions */
+static void audio_session_end(struct ast_sip_session *session);
+
/*! \brief SDP handler for 'audio' media stream */
static struct ast_sip_session_sdp_handler audio_sdp_handler = {
.id = "audio",
.negotiate_incoming_sdp_stream = audio_negotiate_incoming_sdp_stream,
.create_outgoing_sdp_stream = audio_create_outgoing_sdp_stream,
.apply_negotiated_sdp_stream = audio_apply_negotiated_sdp_stream,
+};
+
+/*! \brief Session supplement for 'audio' media stream */
+static struct ast_sip_session_supplement audio_session_supplement = {
+ .session_end = audio_session_end,
};
/*! \brief Internal function which creates an RTP instance */
@@ -397,6 +405,17 @@
return res;
}
+/*! \brief Function which destroys the audio RTP instance when session ends */
+static void audio_session_end(struct ast_sip_session *session)
+{
+ if (!session->media[AST_SIP_MEDIA_AUDIO].rtp) {
+ return;
+ }
+
+ ast_rtp_instance_stop(session->media[AST_SIP_MEDIA_AUDIO].rtp);
+ ast_rtp_instance_destroy(session->media[AST_SIP_MEDIA_AUDIO].rtp);
+}
+
/*!
* \brief Load the module
*
@@ -419,6 +438,11 @@
goto end;
}
+ if (ast_sip_session_register_supplement(&audio_session_supplement)) {
+ ast_log(LOG_ERROR, "Unable to register session supplement for audio media stream\n");
+ goto end;
+ }
+
if (ast_sip_session_register_sdp_handler(&audio_sdp_handler, "audio")) {
ast_log(LOG_ERROR, "Unable to register SDP handler for 'audio' stream type\n");
goto end;
@@ -430,6 +454,7 @@
ast_sched_context_destroy(sched);
}
+ ast_sip_session_unregister_supplement(&audio_session_supplement);
return AST_MODULE_LOAD_FAILURE;
}
@@ -438,6 +463,7 @@
static int unload_module(void)
{
ast_sip_session_unregister_sdp_handler(&audio_sdp_handler, "audio");
+ ast_sip_session_unregister_supplement(&audio_session_supplement);
ast_sched_context_destroy(sched);
return 0;
}
More information about the asterisk-commits
mailing list