[asterisk-commits] file: branch file/pimp_sip_media r380891 - in /team/file/pimp_sip_media: conf...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 5 12:40:45 CST 2013
Author: file
Date: Tue Feb 5 12:40:41 2013
New Revision: 380891
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380891
Log:
Add support for hold/unhold.
Modified:
team/file/pimp_sip_media/configs/res_sip.conf.sample
team/file/pimp_sip_media/include/asterisk/res_sip.h
team/file/pimp_sip_media/include/asterisk/res_sip_session.h
team/file/pimp_sip_media/res/res_sip/sip_configuration.c
team/file/pimp_sip_media/res/res_sip_sdp_audio.c
Modified: team/file/pimp_sip_media/configs/res_sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/configs/res_sip.conf.sample?view=diff&rev=380891&r1=380890&r2=380891
==============================================================================
--- team/file/pimp_sip_media/configs/res_sip.conf.sample (original)
+++ team/file/pimp_sip_media/configs/res_sip.conf.sample Tue Feb 5 12:40:41 2013
@@ -18,3 +18,4 @@
;timers=yes ; Enable or disable session timers support - valid options are: yes, no, required, forced
;timers_min_se=90 ; Minimum session timers expiration period, in seconds
;timers_sess_expires=1800 ; Session timers expiration period, in seconds
+;mohsuggest=example ; What musiconhold class to suggest that the peer channel use when this endpoint places them on hold
Modified: team/file/pimp_sip_media/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/include/asterisk/res_sip.h?view=diff&rev=380891&r1=380890&r2=380891
==============================================================================
--- team/file/pimp_sip_media/include/asterisk/res_sip.h (original)
+++ team/file/pimp_sip_media/include/asterisk/res_sip.h Tue Feb 5 12:40:41 2013
@@ -183,6 +183,8 @@
AST_STRING_FIELD(context);
/*! Name of an explicit transport to use */
AST_STRING_FIELD(transport);
+ /*! Musiconhold class to suggest that the other side use when placing on hold */
+ AST_STRING_FIELD(mohsuggest);
);
/*! Identification information for this endpoint */
struct ast_party_id id;
Modified: team/file/pimp_sip_media/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/include/asterisk/res_sip_session.h?view=diff&rev=380891&r1=380890&r2=380891
==============================================================================
--- team/file/pimp_sip_media/include/asterisk/res_sip_session.h (original)
+++ team/file/pimp_sip_media/include/asterisk/res_sip_session.h Tue Feb 5 12:40:41 2013
@@ -55,6 +55,8 @@
struct ast_sip_session_media {
/*! \brief RTP instance itself */
struct ast_rtp_instance *rtp;
+ /*! \brief Stream is on hold */
+ unsigned int held:1;
};
/*!
Modified: team/file/pimp_sip_media/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_sip_media/res/res_sip/sip_configuration.c?view=diff&rev=380891&r1=380890&r2=380891
==============================================================================
--- team/file/pimp_sip_media/res/res_sip/sip_configuration.c (original)
+++ team/file/pimp_sip_media/res/res_sip/sip_configuration.c Tue Feb 5 12:40:41 2013
@@ -228,6 +228,7 @@
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "host", "", host_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmfmode", "rfc4733", dtmf_handler, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
+ ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mohsuggest", "default", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, mohsuggest));
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "100rel", "yes", prack_handler, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "timers", "yes", timers_handler, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_min_se", "90", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, min_se));
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=380891&r1=380890&r2=380891
==============================================================================
--- 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 12:40:41 2013
@@ -248,7 +248,7 @@
{
int res = 1, addrs_cnt, format, othercapability = 0;
char host[NI_MAXHOST];
- struct ast_sockaddr *addrs;
+ struct ast_sockaddr *addrs = NULL;
struct ast_rtp_codecs codecs;
const pjmedia_sdp_attr *attr;
struct ast_format_cap *cap, *jointcap = NULL, *peercap = NULL;
@@ -282,7 +282,6 @@
/* Apply connection information to the RTP instance */
ast_sockaddr_set_port(addrs, stream->desc.port);
ast_rtp_instance_set_remote_address(session->media[AST_SIP_MEDIA_AUDIO].rtp, addrs);
- ast_free(addrs);
ast_rtp_codecs_payloads_initialize(&codecs);
@@ -334,18 +333,37 @@
/* Apply the new formats to the channel, potentially changing read/write formats while doing so */
ast_format_cap_copy(ast_channel_nativeformats(session->channel), cap);
ast_codec_choose(&session->endpoint->prefs, cap, 1, &fmt);
- ast_set_read_format(session->channel, &fmt);
- ast_set_write_format(session->channel, &fmt);
+ ast_format_copy(ast_channel_rawwriteformat(session->channel), &fmt);
+ ast_format_copy(ast_channel_rawreadformat(session->channel), &fmt);
+ ast_set_read_format(session->channel, ast_channel_readformat(session->channel));
+ ast_set_write_format(session->channel, ast_channel_writeformat(session->channel));
ast_channel_set_fd(session->channel, 0, ast_rtp_instance_fd(session->media[AST_SIP_MEDIA_AUDIO].rtp, 0));
ast_channel_set_fd(session->channel, 1, ast_rtp_instance_fd(session->media[AST_SIP_MEDIA_AUDIO].rtp, 1));
- ast_rtp_instance_activate(session->media[AST_SIP_MEDIA_AUDIO].rtp);
+ if (session->media[AST_SIP_MEDIA_AUDIO].held && (!ast_sockaddr_isnull(addrs) ||
+ !pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL))) {
+ /* The remote side has taken us off hold */
+ ast_queue_control(session->channel, AST_CONTROL_UNHOLD);
+ ast_queue_frame(session->channel, &ast_null_frame);
+ session->media[AST_SIP_MEDIA_AUDIO].held = 0;
+ } else if (ast_sockaddr_isnull(addrs) || ast_sockaddr_is_any(addrs) || pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL)) {
+ /* The remote side has put us on hold */
+ ast_queue_control_data(session->channel, AST_CONTROL_HOLD, S_OR(session->endpoint->mohsuggest, NULL),
+ !ast_strlen_zero(session->endpoint->mohsuggest) ? strlen(session->endpoint->mohsuggest) + 1 : 0);
+ ast_rtp_instance_stop(session->media[AST_SIP_MEDIA_AUDIO].rtp);
+ ast_queue_frame(session->channel, &ast_null_frame);
+ session->media[AST_SIP_MEDIA_AUDIO].held = 1;
+ } else {
+ /* The remote side has not changed state, but make sure the instance is active */
+ ast_rtp_instance_activate(session->media[AST_SIP_MEDIA_AUDIO].rtp);
+ }
cleanup:
ast_format_cap_destroy(peercap);
ast_format_cap_destroy(jointcap);
ast_format_cap_destroy(cap);
+ ast_free(addrs);
ast_rtp_codecs_payloads_destroy(&codecs);
return res;
More information about the asterisk-commits
mailing list