主题:[讨论]C# TAPI 语音猫拨打电话请教
有没有用过语音猫的朋友。
最近弄到一块语音猫,在语音猫的speaker、MIC插孔上插上我的耳机和麦克风,通过超级终端可以拨出电话号码,对方可以接听,我可以听到对方的讲话,但是对方听不到我的麦克风里的声音。
我用C# 通过TAPI3写了一段拨号程序,可以正常拨号,对方也可以接听,但是却听不到我的声音,我可以听到他的。和用超级终端一样,我觉得不应该是程序的问题,应该是我的硬件设置的问题。请教有过这种应用的朋友,你们是怎么做的。
C#代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TAPI3Lib;
namespace MyTAPI_CS_1
{
public partial class Form1 : Form
{
public delegate void eventHandler(TAPI3Lib.CALL_STATE cs, string str);
private TAPIClass tapiclass;
private ITAddress[] itaddress=new ITAddress[10];
private IEnumAddress ienumaddress;
private ITBasicCallControl itbasiccallctrl;
private int currentline=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
uint reg=0;
tapiclass = new TAPIClass();
tapiclass.Initialize();
//添加TAPI事件处理
tapiclass.ITTAPIEventNotification_Event_Event += new ITTAPIEventNotification_EventEventHandler(this.Event);
tapiclass.EventFilter = (int)(TAPI_EVENT.TE_CALLNOTIFICATION |
TAPI_EVENT.TE_DIGITEVENT |
TAPI_EVENT.TE_PHONEEVENT |
TAPI_EVENT.TE_CALLSTATE |
TAPI_EVENT.TE_GENERATEEVENT |
TAPI_EVENT.TE_GATHERDIGITS |
TAPI_EVENT.TE_REQUEST);
groupBox1.Enabled = false;
ienumaddress = tapiclass.EnumerateAddresses();
for (int i = 0; i < 10; i++)
{
ienumaddress.Next(1, out itaddress[i], ref reg);
if (itaddress[i] != null)
{
comboBox1.Items.Add(itaddress[i].AddressName);
}
else
break;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int reg;
currentline = comboBox1.SelectedIndex;
reg=tapiclass.RegisterCallNotifications(itaddress[currentline], true, true, TapiConstants.TAPIMEDIATYPE_AUDIO, 2);
MessageBox.Show("注册线路的事件处理,返回值:"+reg.ToString());
groupBox1.Enabled = true;
}
//拨号
private void button1_Click(object sender, EventArgs e)
{
itbasiccallctrl = itaddress[currentline].CreateCall(textBox1.Text, TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TapiConstants.TAPIMEDIATYPE_AUDIO);
itbasiccallctrl.Connect(false);
}
//挂机
private void button2_Click(object sender, EventArgs e)
{
itbasiccallctrl.Disconnect(DISCONNECT_CODE.DC_NORMAL);
}
public void eventdispose(TAPI3Lib.CALL_STATE cs, string str)
{
listBox1.Items.Add(str);
}
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
string str = "";
switch (te)
{
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
TAPI3Lib.ITCallStateEvent itcallstateevent = (TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo itcallinfo = itcallstateevent.Call;
switch (itcallinfo.CallState)
{
case TAPI3Lib.CALL_STATE.CS_OFFERING:
str = "ring";
Invoke(new eventHandler(eventdispose), TAPI3Lib.TAPI_EVENT.TE_CALLSTATE, str);
break;
}
break;
}
}
}
}
最近弄到一块语音猫,在语音猫的speaker、MIC插孔上插上我的耳机和麦克风,通过超级终端可以拨出电话号码,对方可以接听,我可以听到对方的讲话,但是对方听不到我的麦克风里的声音。
我用C# 通过TAPI3写了一段拨号程序,可以正常拨号,对方也可以接听,但是却听不到我的声音,我可以听到他的。和用超级终端一样,我觉得不应该是程序的问题,应该是我的硬件设置的问题。请教有过这种应用的朋友,你们是怎么做的。
C#代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TAPI3Lib;
namespace MyTAPI_CS_1
{
public partial class Form1 : Form
{
public delegate void eventHandler(TAPI3Lib.CALL_STATE cs, string str);
private TAPIClass tapiclass;
private ITAddress[] itaddress=new ITAddress[10];
private IEnumAddress ienumaddress;
private ITBasicCallControl itbasiccallctrl;
private int currentline=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
uint reg=0;
tapiclass = new TAPIClass();
tapiclass.Initialize();
//添加TAPI事件处理
tapiclass.ITTAPIEventNotification_Event_Event += new ITTAPIEventNotification_EventEventHandler(this.Event);
tapiclass.EventFilter = (int)(TAPI_EVENT.TE_CALLNOTIFICATION |
TAPI_EVENT.TE_DIGITEVENT |
TAPI_EVENT.TE_PHONEEVENT |
TAPI_EVENT.TE_CALLSTATE |
TAPI_EVENT.TE_GENERATEEVENT |
TAPI_EVENT.TE_GATHERDIGITS |
TAPI_EVENT.TE_REQUEST);
groupBox1.Enabled = false;
ienumaddress = tapiclass.EnumerateAddresses();
for (int i = 0; i < 10; i++)
{
ienumaddress.Next(1, out itaddress[i], ref reg);
if (itaddress[i] != null)
{
comboBox1.Items.Add(itaddress[i].AddressName);
}
else
break;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int reg;
currentline = comboBox1.SelectedIndex;
reg=tapiclass.RegisterCallNotifications(itaddress[currentline], true, true, TapiConstants.TAPIMEDIATYPE_AUDIO, 2);
MessageBox.Show("注册线路的事件处理,返回值:"+reg.ToString());
groupBox1.Enabled = true;
}
//拨号
private void button1_Click(object sender, EventArgs e)
{
itbasiccallctrl = itaddress[currentline].CreateCall(textBox1.Text, TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TapiConstants.TAPIMEDIATYPE_AUDIO);
itbasiccallctrl.Connect(false);
}
//挂机
private void button2_Click(object sender, EventArgs e)
{
itbasiccallctrl.Disconnect(DISCONNECT_CODE.DC_NORMAL);
}
public void eventdispose(TAPI3Lib.CALL_STATE cs, string str)
{
listBox1.Items.Add(str);
}
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
string str = "";
switch (te)
{
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
TAPI3Lib.ITCallStateEvent itcallstateevent = (TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo itcallinfo = itcallstateevent.Call;
switch (itcallinfo.CallState)
{
case TAPI3Lib.CALL_STATE.CS_OFFERING:
str = "ring";
Invoke(new eventHandler(eventdispose), TAPI3Lib.TAPI_EVENT.TE_CALLSTATE, str);
break;
}
break;
}
}
}
}