|

Introduction
This is a C# program which will exemplify the procedure which needs to be followed while doing TAPI programming using TAPI 3.0. Hence it can also be useful for VB.NET developers seeking TAPI 3.0 sample code for .NET. Here basic knowledge about TAPI and other related terms is assumed. To have more knowledge on TAPI 3.0, contact me on my email address or refer to the help provided in MSDN.
Background
Hello, myself Gohel Devang M., 20 years old, Information Technology student. This is my first attempt to put some sample code on any site so if you do have any problems mail me at devang.mg@gmail.com.
This is a sample code to interface TAPI 3.0 API using .NET platform and C# as language. So people interested in developing telephony applications using C# will find this very useful. I was inspired to do this because I was not able to find such code on this site.
Initial steps
The first thing you need to start working on TAPI 3.0 API is to add the references to your project. To do that first create a new project or open an existing project, then right click on the solution file in Solution Explorer. This will open a dialog box showing three tabs as below:

Then click on Browse button and select the tapi3.dll file from your windows\system32 or windows\system directory and click OK. Then press OK in the dialog box that had popped when you select Add references from the right click popup menu of the Solution Explorer.
Now you are ready to work with TAPI 3.0.
Using the code
The second thing you need to do is create the TAPI objects to initialize the TAPI 3.0 TSP (TAPI Service Providers). To have more information on TSP and what TAPI is all about, please refer to help provided in the MSDN .NET documentation. The code below is a declaration of the TAPI object and addresses the interfaces that will hold the addresses which are responsible for call handling, and basic call control interface which will hold the reference to the object that will be responsible for handling basic operations of the call. private TAPIClass tobj;
private ITAddress[] ia=new TAPI3Lib.ITAddress[10];
private ITBasicCallControl bcc;
The code below is responsible for initializing a TAPI object so that it can be used by our application. The main functions are:
Initialize() will initialize TAPI.
EnumerateAddresses() will give the list of available TSPs. void initializetapi3()
{
try
{
tobj = new TAPIClass();
tobj.Initialize();
IEnumAddress ea=tobj.EnumerateAddresses();
ITAddress ln;
uint arg3=0;
lines=0;
cn=new callnotification();
cn.addtolist=new callnotification.listshow(this.status);
tobj.ITTAPIEventNotification_Event_Event+= new
TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event);
tobj.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);
for(int i=0;i<10;i++)
{
ea.Next(1,out ln,ref arg3);
ia[i]=ln;
if(ln!=null)
{
comboBox1.Items.Add(ia[i].AddressName);
lines++;
}
else
break;
}
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
The code below is responsible for registering incoming calls so that they can be handled by our application. For that you need to select the line on which you want to receive calls and press the Register button. try
{
registertoken[line]=tobj.RegisterCallNotifications(ia[line],
true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2);
MessageBox.Show("Registration token : "+
registertoken[line],
"Registration Succeed for line "+line);
}
catch(Exception ein)
{
MessageBox.Show("Failed to register on line "+line,"Registration for calls");
}
The class given below is to be added depending upon your TAPI event handling requirements. This is specially designed according to the requirements of the application. class callnotification:TAPI3Lib.ITTAPIEventNotification
{
public delegate void listshow(string str);
public listshow addtolist;
public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
{
switch(te)
{
case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
addtolist("call notification event has occured");
break;
case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
TAPI3Lib.ITDigitDetectionEvent dd =
(TAPI3Lib.ITDigitDetectionEvent)eobj;
addtolist("Dialed digit"+dd.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
TAPI3Lib.ITDigitGenerationEvent dg =
(TAPI3Lib.ITDigitGenerationEvent)eobj;
MessageBox.Show("digit dialed!");
addtolist("Dialed digit"+dg.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
addtolist("A phone event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
addtolist("Gather digit event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
TAPI3Lib.ITCallStateEvent a=
(TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo b=a.Call;
switch(b.CallState)
{
case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
addtolist("dialing");
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
addtolist("Connected");
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
addtolist("A party wants to communicate with you!");
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
addtolist("Call is created!");
break;
}
break;
}
}
}
How to handle H.323 or IP calls?
To do IP calls or H.323 calls, you need to make a checkbox named H.323 call(IP call) enabled and enter the IP address of the destination and press the Call button. Otherwise it will not succeed in calling to the remote destination. To receive H.323 calls or IP calls, you need to first register on the line on which you want to receive IP calls and check the checkbox named h.323 call(IP call).
How to answer an incoming call
The incoming calls will give notification in the call status area. Then according to whether you want to accept or reject the call, you check the checkbox named Reject to reject incoming calls, and press Answer or simply press Disconnect. To accept calls, do not check Reject checkbox and simply press Answer button which will connect to the call.
How to transfer a call
To transfer a call, first there should be one active call existing. Then you can specify the address to which the call is to be transferred to, as shown in the figure:

Here I have specified the internet address since the call was an IP call. To provide this functionality, there is one function in IBasicCallControl named BlindTransfer(String transfferaddress). Refer the MSDN documents for more information on that!
Points of Interest
My interest is in developing more and more TAPI 3.0 applications using .NET as the platform. I am also interested in J2EE application development. My other areas of interest are:
and many other thing in my reach.
History
Latest revised version. This is the first release of this code so if you do have any suggestions they are always welcomed by me.
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 286 (Total in Forum: 286) (Refresh) | FirstPrevNext |
|
 |
|
|
May I please have some pointers that where can i download TAPI SDK. What are the steps to follow to write a TAPI App to connect to TSP to get call information. Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
hi, in my application there is no problem for out going call ,but for incoming call the exception occurs .
error is like this: there may not be any call to answer system.nullreferecne: object reference not set to an instance of an object,. at tapi3_button_click(object sender,eventargs e)) in path... line no
thanks jugal
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi. I'm using TAPI 3.1 .NET Wrapper from JulMar ( http://www.julmar.com/tapi/ ), and try record conversations. I can do it. But conversations was recorded in AVI format, not WAVE. I don't understand why...
I wrote code like in this example ( http://www.julmar.com/blog/mark/PermaLink,guid,a080551e-30d1-47d5-b8a... ), but begin of my recorded RIFF-file looks like: "RIFF@%... AVI LISTa~ hdrlavih8 ..." - this is AVI-format.
Can anybody help me?
I try ask this question on groups.google.com, but doesn't get any decision still
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am new to TAPI, and i dont know how to play an audio file using Tapi. i m using the same code given bye 'hafz' in this forum,but it is not working
private void tapieventhandler(object sender,eventargs e) { .... case TE_CALL_STATE : ITCallStateEvent cse=(ITCallStateEvent)sender; if (cse.State = CALL_STATE.CS_CONNECTED) { ITBasicCallControl2 bcc = cse.Call; ITTerminalSupport ts = ia[i]; ITTerminal fpbt = ts.CreateTerminal(TAPI3Lib.TapiConstants.CLSID_String_FilePlaybackTerminal, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_MULTITRACK, TAPI3Lib.TERMINAL_DIRECTION.TD_CAPTURE);
ITMediaPlayback mp = fpbt; object audiofile(1); audiofile(0)="file name"; mp.PlayList=audiofile; bcc.SelectTerminalOnCall(fpbt);
ITMediaConrol mc=fpbt; mc.start();\\will start playing the audiofile. }
this gives me exception at "bcc.SelectTerminalOnCall(fpbt)" line as -Error HRESULT E_FAIL has been returned from a call to a COM component
Dont know, why this is so?  Can u help me for the same? Will you please suggest some easy documents or links for playing audio file
Thanks in advance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
All who don'w get answer event must know. To get answer event you need to use data/fax/voice modem not a data/fax modem!!! But anyway i still don't know how to answer it.
call notification event has occured; A party wants to communicate with you! ... but after a button click a getting:
There may not be any calls to answer! System.NullReferenceExeption: Object reference not set to an instance of an object...
private void atsiliepti_Click(object sender, EventArgs e) { uint argument = 0; ITCallInfo callinfo; IEnumCall enumcall = line.EnumerateCalls(); try { enumcall.Next(1, out callinfo, ref argument); enumcall.Next(1, out callinfo, ref argument); ITBasicCallControl controleris = (TAPI3Lib.ITBasicCallControl)callinfo;
controleris.Answer(); } catch (Exception exept) { MessageBox.Show("There may not be any calls to answer! " +exept.ToString()); } }
line is ITAddress data/fax/voice modem.
If someone can help me please send a email savartynas@yahoo.com or post here. thanks 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
When I made a call pc to phone, I cannot get sound for the call. someone know what is the problem?
"To the shadow of the last tree will be a son of the bitch"
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Hi devang,
I hope that you can help me, I have to develop an application that dial a phone number via IP. In my job we have a Samsung PBX and the application need to call a specific phone number retrieved from a database, I was reading into msdn documentation and I found info about the ITTAPICalCenter, but cannot implement it. I don't know if it's necessary to make a call to a phone number. by other side when I implement your example, I can call to the PBX using H323 line with the IP Address, but I would like to know if I can dial using a Phone Number.
I hope the you can help me and excuse my poor English
"To the shadow of the last tree will be a son of the bitch"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,I used your source code(in C#),but it doesn't answer incomming call?! i cant find out why! i think it's from eventhandler,that do not do any things for incomming calls! Can u help me please?(I need an Auto Answering machine) 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, I need help cause I'm stuck with Tapi3lib and I'm going against time.
If someone got an application that is fully functional with TAPI3 and C# please contact me at unchorritomas(at)hotmail.com. My application and devang_bison's one has the same problem with events notification and other calling stuff.
Thanks so much.
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
|
Hai Devang,
I am a developer in c#.Net .Now using Visual Studio 2005 . I have downloaded TAPI 3.0. but i am unable to make a call or get an incoming call. Do we need any external settings . Please help me.
|
| Sign In·View Thread·PermaLink | 2.00/5 (9 votes) |
|
|
|
 |
|
|
i m trying to run tapi application on windows 2003 server and vs 2008, digit event is not called. but application works fine on windows XP with visual studio 2005. what is the problem??
thanks Khurram
|
| Sign In·View Thread·PermaLink | 1.33/5 (3 votes) |
|
|
|
 |
|
|
Hello,
i lost my call if i close my application.
the application use the TAPI.
it is possible that the does not hang up?
greetz poohley
|
| Sign In·View Thread·PermaLink | 1.67/5 (3 votes) |
|
|
|
 |
|
|
this is my last year project,basically i am making an application to get result on phone..means to get ur result call on ur university number and after when university receive call press ur exam no so it ll tell ur marks. i am stuck in problem. i want to accept call automatically but i cant do tht. can anybody help me out?? i also find problem to play a wave file??? pls help me out.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hey !! I' m trying using your application in Windows VISTA with funkwerk ELMEG T240 (Tapi driver from http://www.funkwerk-ec.com/portal/downloadcenter/dateien/elmeg_T444-T240/Treiber(Driver)/LAN-TAPI-ICT-Txxx-V131beta-3L.exe) and I became very strange error. After invoking registertoken[line]=tobj.RegisterCallNotifications(ia[line],true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2); I became an error (Exception from HRESULT: 0x80040005 (OLE_E_NOTRUNNING)) w TAPI3Lib.TAPIClass.RegisterCallNotifications(ITAddress pAddress, Boolean fMonitor, Boolean fOwner, Int32 lMediaTypes, Int32 lCallbackInstance) w tapi3_dev.Form1.button6_Click(Object sender, EventArgs e) w C:\tapi3\Form1.cs:line 461
Can anybody help me ??
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi All
I am trying to play a sound modem device. Could you please give me some hints on that? Thanks!
|
| Sign In·View Thread·PermaLink | 2.20/5 (5 votes) |
|
|
|
 |
|
|
Hi All,
I am trying to play a sound modem device. Could you please give me some hints on that? Thanks!
|
| Sign In·View Thread·PermaLink | 2.60/5 (5 votes) |
|
|
|
 |
|
|
Hi ,
Is it possible to send data or file to another PC after connection has been established .... regards....
Mani
|
| Sign In·View Thread·PermaLink | 2.00/5 (5 votes) |
|
|
|
 |
|
|
i don't know how i can play modem wave if any one know how done please send me my email asnabani_th@yahoo.com
|
| Sign In·View Thread·PermaLink | 2.20/5 (5 votes) |
|
|
|
 |
|
|
hi,
i am using Agere System PCI soft Modem
i try to register the line it throws the Exception like connection null...
also i cant get any status on incoming call ,i think this is due to not register the line...
Please help me , how to register the line
Thank You
Mani
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
I've started to create a TAPI 3 Wrapper, using yourCode as a Base....
But i'm still having Problems with Events from TAPI.
I your Version i tryed it with invoke an it worked verry well. But my Wrapper Control is a nonGUI Version, So I tryed it with a Synchronisation Context, but it doesn't work. Maybe you can help me.
I have attached my Source Code so you can see...
If someone else is interested, I will open a SourceForge or Codeplex Project soon.
[code] using System; using System.Collections.Generic; using System.Linq; using System.Text;
using TAPI3Lib;
using System.Threading;
namespace jkTAPI3Wrapper { /// /// The MAIN Tapi Object. /// It listens for the Event's /// public class TAPI3 {
[Flags()] public enum TAPIMediaTypes { MediaType_Audio = TapiConstants.TAPIMEDIATYPE_AUDIO, MediaType_Video = TapiConstants.TAPIMEDIATYPE_VIDEO, MediaType_DataModem = TapiConstants.TAPIMEDIATYPE_DATAMODEM, MediaType_G3Fax = TapiConstants.TAPIMEDIATYPE_G3FAX, MediaType_MultiTrack = TapiConstants.TAPIMEDIATYPE_MULTITRACK } public enum TAPIAddressTypes { AddressType_DOMAINNAME = TapiConstants.LINEADDRESSTYPE_DOMAINNAME, AddressType_EMAILNAME = TapiConstants.LINEADDRESSTYPE_EMAILNAME, AddressType_IPADDRESS = TapiConstants.LINEADDRESSTYPE_IPADDRESS, AddressType_PHONENUMBER = TapiConstants.LINEADDRESSTYPE_PHONENUMBER, AddressType_SDP = TapiConstants.LINEADDRESSTYPE_SDP }
//internal COM Classes are also Public, if someone needs them! internal TAPIClass _internal_TAPI;
//public list of aviable TAPI Devices... public List Devices;
//SnchronizationContext for the Event Call's protected SynchronizationContext context;
#region EventHandling //Event Handling... private callnotification cn;
//Common Delegat for all Tapi Events //public delegate void TapiHandler(String aa); //The Events....
public delegate void CallNotificationEvent(object sender, CallNotificationEventArgs e); public delegate void CallStateEvent(object sender, CallStateEventArgs e); public delegate void DigitEvent(object sender, DigitEventArgs e); public delegate void DigitGenerationEvent(object sender, DigitGenerationEventArgs e);
public event CallNotificationEvent event_CallNotification; public event CallStateEvent event_CallState; public event DigitEvent event_Digit; public event DigitGenerationEvent event_DigitGeneration;
#region EventArgs //Event Args Definitions public class CallNotificationEventArgs : EventArgs { public TCall Call; public TAPI3 TAPIobj;
public CallNotificationEventArgs(ITCallNotificationEvent e) { Call = new TCall(TAPIobj, (ITBasicCallControl)e.Call); } }
public class DigitEventArgs : EventArgs { public TCall Call; public TAPI3 TAPIobj; byte Digit;
public DigitEventArgs(ITDigitDetectionEvent e) { Call = new TCall(TAPIobj, (ITBasicCallControl)e.Call); Digit = e.Digit; } } public class DigitGenerationEventArgs : EventArgs { public TCall Call; public TAPI3 TAPIobj;
public DigitGenerationEventArgs(ITDigitGenerationEvent e) { Call = new TCall(TAPIobj, (ITBasicCallControl)e.Call); } }
public class CallStateEventArgs : EventArgs { public TCall Call; public TAPI3 TAPIobj; public CALL_STATE CallState;
public CallStateEventArgs(ITCallStateEvent e) { Call = new TCall(TAPIobj, (ITBasicCallControl)e.Call); // ITCallInfo callinfo = (ITCallInfo)e.Call; CallState = callinfo.CallState; } } #endregion
protected void raiseEvent(object e) { if (e is CallNotificationEventArgs) event_CallNotification(this,(CallNotificationEventArgs)e); if (e is CallStateEventArgs) event_CallState(this, (CallStateEventArgs)e); if (e is DigitEventArgs) event_Digit(this, (DigitEventArgs)e); if (e is DigitGenerationEventArgs) event_DigitGeneration(this, (DigitGenerationEventArgs)e); }
//A privat Class to process the TAPI Events and Call .net Events with invoke! private class callnotification : TAPI3Lib.ITTAPIEventNotification { //public delegate void listshow(string str); //public listshow addtolist;
private TAPI3 outerClass; public callnotification(TAPI3 obj) { outerClass = obj; }
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj) { switch (te) { case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION: CallNotificationEventArgs e_callNotification = new CallNotificationEventArgs((ITCallNotificationEvent)eobj); e_callNotification.TAPIobj = outerClass; outerClass.context.Send(outerClass.raiseEvent, e_callNotification); break;
case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT: DigitEventArgs e_Digit = new DigitEventArgs((ITDigitDetectionEvent)eobj); e_Digit.TAPIobj = outerClass; outerClass.context.Send(outerClass.raiseEvent, e_Digit); break;
case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT: DigitGenerationEventArgs e_DigitGeneration = new DigitGenerationEventArgs((ITDigitGenerationEvent)eobj); e_DigitGeneration.TAPIobj = outerClass; outerClass.context.Send(outerClass.raiseEvent, e_DigitGeneration); break;
case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT: //addtolist("A phone event!"); break;
case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS: //addtolist("Gather digit event!"); break;
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE: CallStateEventArgs e_CallState = new CallStateEventArgs((ITCallStateEvent)eobj); e_CallState.TAPIobj = outerClass; outerClass.context.Send(outerClass.raiseEvent, e_CallState); break; } } }
#endregion
//Constructor of the TAPI3 Class! public TAPI3() { //Create TAPI Object and Initialize it! _internal_TAPI = new TAPIClass(); _internal_TAPI.Initialize();
//Create the Synchronisation Context context = SynchronizationContext.Current; if (context == null) { context = new SynchronizationContext(); } //Create a List of TAPI Devices Devices = new List();
IEnumAddress ea = _internal_TAPI.EnumerateAddresses(); ITAddress ln;
uint tmp = 0; ea.Next(1, out ln, ref tmp); while (ln != null) { Devices.Add(new TAddress(this, ln)); ea.Next(1, out ln, ref tmp); }
//Register Tapi 3 Eventhandler... cn = new callnotification(this); _internal_TAPI.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event); _internal_TAPI.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); }
protected void Dispose(bool disposing) { _internal_TAPI.Shutdown(); } }
/// /// The TAPI Devices are Represented by a TAddress Object /// public class TAddress { internal ITAddress _internal_Address; internal ITTerminalSupport _internal_Terminal_Support;
public String AddressName; public String ServiceProviderName; public List RegisteredTokens; private TAPI3 TAPIobj; public TAddress(TAPI3 outerObj, ITAddress obj) { _internal_Address = obj;
AddressName = _internal_Address.AddressName; ServiceProviderName = _internal_Address.ServiceProviderName;
//Try if the ITTerminalSupport is supported... try { _internal_Terminal_Support = (ITTerminalSupport)obj; } catch (Exception) {} TAPIobj = outerObj; RegisteredTokens = new List(); }
public List StaticTerminals { get { List retVal = new List(); if (_internal_Terminal_Support != null) { { //Static Terminals IEnumTerminal ea; ITTerminal ln; ea = _internal_Terminal_Support.EnumerateStaticTerminals(); uint tmp = 0; ea.Next(1, out ln, ref tmp); while (ln != null) { retVal.Add(new TTerminal(TAPIobj, ln)); ea.Next(1, out ln, ref tmp); } } } return retVal; } }
public List Calls { get { List retVal = new List(); { IEnumCall ea; ITCallInfo ln; ea = _internal_Address.EnumerateCalls(); uint tmp = 0; ea.Next(1, out ln, ref tmp); while (ln != null) { retVal.Add(new TCall(TAPIobj, (ITBasicCallControl)ln)); ea.Next(1, out ln, ref tmp); } } return retVal; } }
/// /// Registeres the Line so that Events are Collected /// /// Should Events be Monitored /// /// On Which Mediatypes should be listened public void RegisterLine(bool fMonitor, bool fOwner, TAPI3.TAPIMediaTypes MediaTypes) { try { int tmp = TAPIobj._internal_TAPI.RegisterCallNotifications(_internal_Address, fMonitor, fOwner, (int)MediaTypes, 2); RegisteredTokens.Add(tmp); } catch (Exception) { } }
public TCall CreateCall(String destAddress, TAPI3.TAPIAddressTypes AddressType, TAPI3.TAPIMediaTypes MediaTypes) { return new TCall(TAPIobj, _internal_Address.CreateCall(destAddress, (int)AddressType, (int)MediaTypes)); }
public void UnregisterToken(int token) {
if (RegisteredTokens.Contains(token)) { RegisteredTokens.Remove(token); TAPIobj._internal_TAPI.UnregisterNotifications(token); } } public void UnregisterAllTokens() { foreach (int token in RegisteredTokens) UnregisterToken(token); } /*public TTerminal CreateTerminal() {
}*/
public override string ToString() { return _internal_Address.AddressName; } }
//Klasse TCall public class TCall { //Basisobjekte internal ITBasicCallControl _internal_Call; internal ITCallInfo _internal_CallInfo; internal ITStreamControl _internal_StreamControl;
public TAPI3 TAPIobj; public String Number; public CALL_STATE CallState;
public String CallerIDNumber; public String CalledIDNumber;
public TCall(TAPI3 outerObj, ITBasicCallControl obj) { _internal_Call = obj; _internal_CallInfo = (ITCallInfo)obj; TAPIobj = outerObj;
//Copy Callinfo Fields CallState = _internal_CallInfo.CallState;
CallerIDNumber = _internal_CallInfo.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); //CalledIDNumber = _internal_CallInfo.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER); //List up Streams... _internal_StreamControl = (ITStreamControl)obj; }
public TAddress Address { get { return new TAddress(TAPIobj, _internal_CallInfo.Address); } }
public List Streams { get { List retVal = new List();
//Enumerate Streams... { IEnumStream ea; _internal_StreamControl.EnumerateStreams(out ea); ITStream ln; uint tmp = 0; ea.Next(1, out ln, ref tmp); while (ln != null) { retVal.Add(new TStream(TAPIobj, ln)); ea.Next(1, out ln, ref tmp); } } return retVal; } } public void Answer() { _internal_Call.Answer(); } public void BlidTransfer(String DestinationAddress) { _internal_Call.BlindTransfer(DestinationAddress); } public void Connect(bool fSync) { _internal_Call.Connect(fSync); } public void Conference(TCall myCall, bool fSync) { _internal_Call.Conference(myCall._internal_Call, fSync); } public void Dial() { _internal_Call.Dial(Number); } public void Disconnect(DISCONNECT_CODE dCode) { _internal_Call.Disconnect(dCode); } public void Finish(FINISH_MODE finishMode) { _internal_Call.Finish(finishMode); } public void Hold(bool fHold) { _internal_Call.Hold(fHold); }
public void Dial(String akNumber) { Number = akNumber; Dial(); }
/// /// Get's a TTS Stream from the Call wich can be used for a SAPI Custom Stream /// /// public STCUSTOMSTREAMLib.TTSStream GetTTSStream() { ITTerminalSupport tmpTermSupp = (ITTerminalSupport)_internal_CallInfo.Address;
ITTerminal tmpTerm = tmpTermSupp.CreateTerminal(TapiConstants.CLSID_String_MediaStreamTerminal, TapiConstants.TAPIMEDIATYPE_AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);
ITStreamControl tmpStream = (ITStreamControl)_internal_Call; STCUSTOMSTREAMLib.TTSStream objTTS = new STCUSTOMSTREAMLib.TTSStream();
//Enumerate Streams... { IEnumStream ea; tmpStream.EnumerateStreams(out ea); ITStream ln; uint tmp = 0; ea.Next(1, out ln, ref tmp); while (ln != null) { if (ln.MediaType == TapiConstants.TAPIMEDIATYPE_AUDIO) if (ln.Direction == TERMINAL_DIRECTION.TD_CAPTURE) ln.SelectTerminal(tmpTerm); ea.Next(1, out ln, ref tmp); } }
objTTS.InitTTSCaptureStream(tmpTerm); return objTTS; } }
//Klasse TStream public class TStream { internal ITStream _internal_Stream; public TAPI3 TAPIobj; public String Name; public TAPI3.TAPIMediaTypes MediaType; public TERMINAL_DIRECTION Direction;
public TStream(TAPI3 outerObj, ITStream objStream) { TAPIobj = outerObj; _internal_Stream = objStream; Name = _internal_Stream.Name; MediaType = (TAPI3.TAPIMediaTypes)_internal_Stream.MediaType; Direction = _internal_Stream.Direction; } public void SelectTerminal(TTerminal objTerm) { _internal_Stream.SelectTerminal(objTerm._internal_Terminal); } public void UnselcetTerminal(TTerminal objTerm) { _internal_Stream.UnselectTerminal(objTerm._internal_Terminal); } }
//Klasse TTerminal public class TTerminal { internal ITTerminal _internal_Terminal; public TAPI3 TAPIobj;
public TTerminal(TAPI3 outerObj, ITTerminal objTerm) { TAPIobj = outerObj; _internal_Terminal = objTerm; } } } [/code]
|
| | | | |