TAPI应用程序,无法发送DTMF信号
我正在尝试编写一个应用程序来建立调制解调器连接,然后发送 dtmf 信号。我的应用程序创建了一个呼叫,但它不发送 DTMF 信号。
我正在使用 TAPI 用 C# 编写它。
该代码有什么问题? 在按钮3处您可以看到DTMF功能。
我的申请:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using TAPI3Lib;
namespace dialer
{
public partial class MainForm : Form
{
private TAPIClass tapi;
private ITAddress[] adresy = new ITAddress[10];
private ITBasicCallControl polaczenie = null;
private int wybrany = -1;
public MainForm()
{
InitializeComponent();
ZainicjalizujTAPI();
}
private void ZainicjalizujTAPI()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
IEnumAddress ea = tapi.EnumerateAddresses();
ITAddress adres;
uint arg = 0;
for(uint i = 0; i < 10; ++i)
{
ea.Next(1, out adres, ref arg);
if(adres == null) break;
adresy[i] = adres;
listaLinii.Items.Add(adres.AddressName);
}
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
void Button1Click(object sender, EventArgs e)
{
if(listaLinii.SelectedIndex < 0)
{
MessageBox.Show("Nie wybrano linii", "Błąd!");
return;
}
if(polaczenie != null)
{
MessageBox.Show("Połączenie już istnieje", "Błąd!");
return;
}
wybrany = listaLinii.SelectedIndex;
try
{
polaczenie = adresy[wybrany].CreateCall("12345678",
TapiConstants.LINEADDRESSTYPE_PHONENUMBER,
TapiConstants.TAPIMEDIATYPE_DATAMODEM | TapiConstants.TAPIMEDIATYPE_AUDIO);
polaczenie.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM | TapiConstants.TAPIMEDIATYPE_AUDIO,
QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
polaczenie.Connect(false);
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
polaczenie = null;
}
}
void Button2Click(object sender, EventArgs e)
{
if(polaczenie == null) return;
try
{
polaczenie.Disconnect(DISCONNECT_CODE.DC_NORMAL);
polaczenie = null;
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
// HERE is the button responsible for sending DTMF signal (doesn't work)
void Button3Click(object sender, EventArgs e)
{
if(polaczenie == null) return;
try
{
ITLegacyCallMediaControl2 cmc = (ITLegacyCallMediaControl2) polaczenie;
cmc.GenerateDigits("246", TapiConstants.LINEDIGITMODE_DTMF);
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
void ListaLiniiSelectedIndexChanged(object sender, EventArgs e)
{
}
}
I'm trying to write an aplication that makes a modem connection and after that sends a dtmf signal. My application creates a call but it doesnt send that DTMF signal.
I'm writing it in C# using TAPI.
What is wrong in that code ??
At button 3 u can see DTMF function.
My application :
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using TAPI3Lib;
namespace dialer
{
public partial class MainForm : Form
{
private TAPIClass tapi;
private ITAddress[] adresy = new ITAddress[10];
private ITBasicCallControl polaczenie = null;
private int wybrany = -1;
public MainForm()
{
InitializeComponent();
ZainicjalizujTAPI();
}
private void ZainicjalizujTAPI()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
IEnumAddress ea = tapi.EnumerateAddresses();
ITAddress adres;
uint arg = 0;
for(uint i = 0; i < 10; ++i)
{
ea.Next(1, out adres, ref arg);
if(adres == null) break;
adresy[i] = adres;
listaLinii.Items.Add(adres.AddressName);
}
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
void Button1Click(object sender, EventArgs e)
{
if(listaLinii.SelectedIndex < 0)
{
MessageBox.Show("Nie wybrano linii", "Błąd!");
return;
}
if(polaczenie != null)
{
MessageBox.Show("Połączenie już istnieje", "Błąd!");
return;
}
wybrany = listaLinii.SelectedIndex;
try
{
polaczenie = adresy[wybrany].CreateCall("12345678",
TapiConstants.LINEADDRESSTYPE_PHONENUMBER,
TapiConstants.TAPIMEDIATYPE_DATAMODEM | TapiConstants.TAPIMEDIATYPE_AUDIO);
polaczenie.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM | TapiConstants.TAPIMEDIATYPE_AUDIO,
QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
polaczenie.Connect(false);
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
polaczenie = null;
}
}
void Button2Click(object sender, EventArgs e)
{
if(polaczenie == null) return;
try
{
polaczenie.Disconnect(DISCONNECT_CODE.DC_NORMAL);
polaczenie = null;
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
// HERE is the button responsible for sending DTMF signal (doesn't work)
void Button3Click(object sender, EventArgs e)
{
if(polaczenie == null) return;
try
{
ITLegacyCallMediaControl2 cmc = (ITLegacyCallMediaControl2) polaczenie;
cmc.GenerateDigits("246", TapiConstants.LINEDIGITMODE_DTMF);
}
catch(Exception wyj)
{
MessageBox.Show(wyj.ToString(), "Błąd!");
}
}
void ListaLiniiSelectedIndexChanged(object sender, EventArgs e)
{
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 ATAPI 库用于 .Net TAPI 库。它还包含一些示例,以便您可以了解 TAPI 的工作原理。 ATAPI 托管在 CodePlex 中并获得 MIT 许可。在 google 中搜索 ATAPI codeplex 以获取该库。
You can use ATAPI library for .Net TAPI library. It also has some example included so that you can understand how TAPI works. ATAPI is hosted in CodePlex and is MIT licensed. Search google for ATAPI codeplex to get the library.