[英]TAPI application, can't send DTMF signal
我正在嘗試編寫一個使用調制解調器連接的應用程序,然后發送一個dtmf信號。 我的應用程序創建一個調用,但它不發送該DTMF信號。
我是用CAPI用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)
{
}
}
您可以將ATAPI庫用於.Net TAPI庫。 它還包含一些示例,以便您可以了解TAPI的工作原理。 ATAPI托管在CodePlex中並獲得MIT許可。 搜索谷歌的ATAPI codeplex來獲取庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.