summaryrefslogtreecommitdiff
path: root/contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2015-04-10 17:56:47 +0000
committerMatthew Jordan <mjordan@digium.com>2015-04-10 17:56:47 +0000
commit8bae18ab9301a2e38fd414460fde8d6236f2162e (patch)
tree493944ba4e7f391ce8d12dce9d09d3aa6a9865aa /contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
parentf69e46de25d016dd1c173d9077a4b2eb3505b704 (diff)
res_pjsip: Add an 'auto' option for DTMF Mode
This patch adds support for automatically detecting the type of DTMF that a PJSIP endpoint supports. When the 'dtmf_mode' endpoint option is set to 'auto', the channel created for an endpoint will attempt to determine if RFC 4733 DTMF is supported. If so, it will use that DTMF type. If not, the DTMF type for the channel will be set to inband. Review: https://reviewboard.asterisk.org/r/4438 ASTERISK-24706 #close Reported by: yaron nahum patches: yaron_patch_3_Feb.diff submitted by yaron nahum (License 6676) ........ Merged revisions 434637 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py')
-rw-r--r--contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py b/contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
new file mode 100644
index 000000000..fd1b6c7d4
--- /dev/null
+++ b/contrib/ast-db-manage/config/versions/31cd4f4891ec_add_auto_dtmf_mode.py
@@ -0,0 +1,63 @@
+"""Add auto DTMF mode
+
+Revision ID: 31cd4f4891ec
+Revises: 23530d604b96
+Create Date: 2015-04-10 12:36:51.619419
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '31cd4f4891ec'
+down_revision = '23530d604b96'
+
+from alembic import op
+import sqlalchemy as sa
+
+OLD_ENUM = ['rfc4733', 'inband', 'info']
+NEW_ENUM = ['rfc4733', 'inband', 'info', 'auto']
+
+old_type = sa.Enum(*OLD_ENUM, name='pjsip_dtmf_mode_values')
+new_type = sa.Enum(*NEW_ENUM, name='pjsip_dtmf_mode_values_v2')
+
+tcr = sa.sql.table('ps_endpoints', sa.Column('dtmf_mode', new_type,
+ nullable=True))
+
+def upgrade():
+ context = op.get_context()
+
+ # Upgrading to this revision WILL clear your directmedia values.
+ if context.bind.dialect.name != 'postgresql':
+ op.alter_column('ps_endpoints', 'dtmf_mode',
+ type_=new_type,
+ existing_type=old_type)
+ else:
+ enum = ENUM('rfc4733', 'inband', 'info', 'auto',
+ name='pjsip_dtmf_mode_values_v2')
+ enum.create(op.get_bind(), checkfirst=False)
+
+ op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
+ ' pjsip_dtmf_mode_values_v2 USING'
+ ' dtmf_mode::text::pjsip_dtmf_mode_values_v2')
+
+ ENUM(name="pjsip_dtmf_mode_values").drop(op.get_bind(), checkfirst=False)
+
+def downgrade():
+ context = op.get_context()
+
+ op.execute(tcr.update().where(tcr.c.directmedia==u'outgoing')
+ .values(directmedia=None))
+
+ if context.bind.dialect.name != 'postgresql':
+ op.alter_column('ps_endpoints', 'dtmf_mode',
+ type_=old_type,
+ existing_type=new_type)
+ else:
+ enum = ENUM('rfc4733', 'inband', 'info',
+ name='pjsip_dtmf_mode_values')
+ enum.create(op.get_bind(), checkfirst=False)
+
+ op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
+ ' pjsip_dtmf_mode_values USING'
+ ' dtmf_mode::text::pjsip_dtmf_mode_values')
+
+ ENUM(name="pjsip_dtmf_mode_values_v2").drop(op.get_bind(), checkfirst=False)