|
|
Hello All,
I need to know if there is a way to identify a call!
I want to open a window for each call, and close the correct window when the call is closed or terminated.
Normaly when there is only one call no problem, but I aspect a lot of calls during the same time.
Regards
Carsten
|
|
|
|
|
Hi,
first I'm a very early beginner with TAPI ad vb.net
In my testing code, I see incoming calls and can make a call.
But all events are triggerd very often. I can't see a system in this!
Is there a way to see, that this events are all based on the same call, if so?
My idea, I open a window for every call. But only for different calls.
regards
Carsten
modified on Thursday, June 5, 2008 1:03 PM
|
|
|
|
|
Hello Code Guru,
I'm currently working with your code example, but i encounter a strange error. I'm using visual studio 2005. When I first run my project the events fires as expected. I also got the disconnected event when I finish the phone call. But after that, nothing more happens. When the next call arrives NO event will be firing up and also no 3th party TAPI tool will get the next call. When I call the .shutdown method in the disconnected event handler, it's not getting much better, however 3th party TAPI tools will then get the next TAPI calls as usual. My program not ... But when I stop the project and run it again, it will work for the first call again. So I believe the call is not properly finished in some way, however, every code i found for .net has the same problems, but commercial 3th party tools don't. so there must be a way. Can you, or anyone other please point me in the right direction?. I've not much experience with TAPI at all, but this is a very strange behavior in my opinion. To be complete, I’m using the TAPI Drivers for Fritz BOX by AVM, a well known Manufacturer here in Germany.
Any help is greatly appreciated
Thanks
RoSch
|
|
|
|
|
I have the code verbatim as posted and I am getting a strange error when the following call is made:
CallInfoObject.Call.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNAME)
Error HRESULT E_FAIL has been returned from a call to a COM component...
The Trace stack portion is below:
at Herbalife.VBCity.TAPI.VBTAPI.CallStateEvent() in C:\Documents and Settings\Ken\My Documents\Visual Studio Projects\Copy of Herbalife\tapi.vb:line 159
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at TAPI3Lib.ITCallInfo.get_CallInfoString(CALLINFO_STRING CallInfoString)
Any Ideas?
TIA
Ken Yannitell
|
|
|
|
|
i run ur the projct in vs2005 . i got a message "Attempting Mannaged execution inside OS Loader Lock. do not attempt run a manage code inside a DllMain or image initialization function since doing so may cause the application to hang..
|
|
|
|
|
this is my last year project...i can answer the incoming call and also detect the DTMF tone but i dont hv any idea about how to play a WAVE file?? i am in a big problem..pls help me..if any body have sample code thn can u pls mail me at alok.dida@gmail.com or pls reply me..pls help me ..thnks in advance
|
|
|
|
|
Have u got any solution? if yes please can u post it here
Thanks in advance.
|
|
|
|
|
Greetings, thank you for such a solid work. I am trying to perform the SIMPLE task of calling a phone number and detecting the button that is pressed on the other end. I used the Julmar.ITAPI library at first but couldn't get it to work with events. I switched to the Tapi3Lib, and studied your code. It all works great, i can make the call. However, as soon as I add the Sub that handles the Tapi.Event, everything stops working! I get an error message about InteOp Services. If I take out the sub, everything works fine and I can make the call.
So -> Event Handler Sub, program crashes, Tapi_obj not initalized
-> No event handler sub, program proceeds, tapi_obj is initalized correctly, and call is made.
HELP!
I attached my code below
Imports TAPI3Lib
Public Class frmCallingNow
Private str_buzzer As String
Private call_obj As ITBasicCallControl
Private addr_obj As ITAddress
Private WithEvents tapi_obj As TAPI
Private Const MediaAudio As Integer = 8
Private Const MediaModem As Integer = 16
Private Const MediaFax As Integer = 32
Private Const MediaVideo As Integer = 32768
Private RegCookie As Integer
Public Sub New(ByVal hndlToGodModule As GodModule, ByVal buzzer As String)
.
.
.
'TAPI3 CODE
Try
Dim MediaTypes As Integer
tapi_obj = New TAPI3Lib.TAPI()
tapi_obj.Initialize()
Dim AddressCollection As ITCollection = tapi_obj.Addresses()
For Each Address As ITAddress In AddressCollection
If Address.State = TAPI3Lib.ADDRESS_STATE.AS_INSERVICE Then
Dim mediaSupport As ITMediaSupport = Address 'extract media support interface from the address
MediaTypes = mediaSupport.MediaTypes
mediaSupport = Nothing
If (MediaTypes And MediaModem) = MediaModem Then
'address is data modem
If (MediaTypes And MediaAudio) = MediaAudio Then
'this address is a voice-supporting fax/modem: SELECT THIS ADDRESS
addr_obj = Address
Exit For
End If
End If
End If
Next
If Not (addr_obj Is Nothing) Then 'If we have an address
RegCookie = tapi_obj.RegisterCallNotifications(addr_obj, True, False, MediaTypes, 1) 'Register the notifications for the selected address
'Specify which notifications we are interested in
tapi_obj.EventFilter = (TAPI_EVENT.TE_DIGITEVENT Or TAPI_EVENT.TE_TONEEVENT Or TAPI_EVENT.TE_CALLSTATE)
call_obj = addr_obj.CreateCall(buzzer, TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER, MediaTypes)
call_obj.Connect(False)
Else
MessageBox.Show("No Address Selected", "TAPI Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "TAPI Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'TAPI3Lib CODE
' IF I REMOVE THE COMMENTS OFF OF THE FOLLOWING BLOCK, THE APP CRASHES WITH INTEROP EXCEPTION
'Private Sub MY_TAPI_EVENTS(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles tapi_obj.Event
' Select Case TapiEvent
' Case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT
' MessageBox.Show("Digit input = " + pEvent.ToString)
' Case TAPI_EVENT.TE_TONEEVENT
' Case TAPI_EVENT.TE_CALLSTATE
' End Select
'End Sub
Private Sub lbl_CallingNowForm_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_CallingNowForm_Cancel.Click
If tapi_Obj Is Nothing Then
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Else
tapi_Obj.Dispose()
addr_obj.Dispose()
call_obj.Dispose()
Me.DialogResult = Windows.Forms.DialogResult.Cancel
End If
End Sub
End Class
|
|
|
|
|
Update:::
Ok, I fixed the InterOp Problem.. It seems that I couldn't instantiate a new TAPI object like this
tapi_obj = new TAPI3Lib.TAPIClass
Instead I had to do what is suggested in the article above.
I'm still trying to find which event is raised when a button is pressed on the phone... I'm testing with a Nokia Cell phone, and I'm switching to land line. will keep you guys posted
|
|
|
|
|
Abulfar wrote:
tapi_obj.EventFilter = (TAPI_EVENT.TE_DIGITEVENT Or TAPI_EVENT.TE_TONEEVENT Or TAPI_EVENT.TE_CALLSTATE)
that line should come before you register for call notification in order to receive your events.
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
Thank you for your reply. I found your suggestion kinda strange because my app registers CALLSTATE events (such as connected and disconnected), but I cannot -for the life of me- detect a digitevent or a toneevent. I did what you so kindly suggested, but it didn't seem to have an effect.
I tried scourging through the net for suggestions and I tried everything i can think of. If anyone has a working app that registers digits or tones PLEASE help!
|
|
|
|
|
did you try adding TAPI_EVENT.TE_GATHERDIGITS to the EventFilter ?
try it and tell me the results
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
I tried what you suggested, and still no-go.
I'm gonna paste my updated code to give you a better idea, but let me tell you what I did while trying to get this thing working.
- I tried Instantiating a ITLegacyCallMediaControl object by CTyping the ITBasicCallControl. The reason why I did this was to try to access the ITLegacyCallMediaControl::DetectDigits(), my code looked something like this
Dim legacy_obj as ITLegacyCallMediaControl
legacy_obj = CType(call_obj, ITLegacyCallMediaControl) 'This worked, no exceptions.
legacy_obj.DetectDigits(TapiConstants.LINEDIGITMODE_DTMF) ' This threw an Interop exception 'Object is not in any of the in place active states, HRESULT 0x80040010
Man, I tried SO MANY things... it's driving me insane. Pasted below is my code. Please help me, and if you can add me on to msn 'fayezelfar[at]hotmail.com'
With my deepest gratitude.
PS: Masr Um Al Dunia! (If you're egyptian, this'll make you laugh )
'TAPI3 CODE
Try
Dim MediaTypes As Integer
Dim m_tapi As New TAPI3Lib.TAPIClass
m_tapi.Initialize()
tapi_obj = m_tapi
Dim AddressCollection As ITCollection = tapi_obj.Addresses()
For Each Address As ITAddress In AddressCollection
If Address.State = TAPI3Lib.ADDRESS_STATE.AS_INSERVICE Then
Dim mediaSupport As ITMediaSupport = Address 'extract media support interface from the address
MediaTypes = mediaSupport.MediaTypes
mediaSupport = Nothing
If (MediaTypes And MediaModem) = MediaModem Then
'address is data modem
If (MediaTypes And MediaAudio) = MediaAudio Then
'this address is a voice-supporting fax/modem: SELECT THIS ADDRESS
addr_obj = Address
Exit For
End If
End If
End If
Next
If Not (addr_obj Is Nothing) Then 'If we have an address
'Specify which notifications we are interested in
tapi_obj.EventFilter = (TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_DIGITEVENT Or TAPI_EVENT.TE_GATHERDIGITS)
RegCookie = tapi_obj.RegisterCallNotifications(addr_obj, True, False, MediaTypes, 1) 'Register the notifications for the selected address
Dim legacy As TAPI3Lib.ITLegacyCallMediaControl
call_obj = addr_obj.CreateCall(buzzer, TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TapiConstants.TAPIMEDIATYPE_DATAMODEM)
call_obj.Connect(False)
Else
MessageBox.Show("No Address Selected", "TAPI Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "TAPI Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Private Sub TAPI_EVT_MGR(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles tapi_obj.Event
'Making a thread to asynchronously process the events
Dim thread_obj As System.Threading.Thread
Dim thread_obj2 As System.Threading.Thread
Select Case TapiEvent
Case TAPI_EVENT.TE_CALLSTATE
thread_obj = New Threading.Thread(AddressOf CallStateEventRaised)
CallStateObject = CType(pEvent, ITCallStateEvent)
thread_obj.Start()
Case TAPI_EVENT.TE_TONEEVENT
thread_obj2 = New Threading.Thread(AddressOf ToneEventRaised)
ToneEventObject = CType(pEvent, ITToneDetectionEvent)
thread_obj2.Start()
Case TAPI_EVENT.TE_DIGITEVENT
Console.WriteLine("hi")
Case TAPI_EVENT.TE_GATHERDIGITS
Console.WriteLine("gather digits triggered")
End Select
End Sub
|
|
|
|
|
Hi,
This application of yours can display video rite? I want to know what is your setup to make it working? Are you using modem? What kind of devices or equipments that you use?
Thanks
Kent
|
|
|
|
|
it can use and display video thru LAN (H323 VoIP Protocol), but with modem you can only use Audio (In / Out)
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
It is confirmed that with TAPI 3 application you can't have video conference by using modem.
Thanks for the Info.
Best Regards,
Kent
|
|
|
|
|
hey sir...i want some tutorial on this TAPI.. the project that i selected for final year project is based on TAPI...so can u help me how can u start with this project?? i really need help..
|
|
|
|
|
hello, i am really sorry as i will not be able to directly help you but if you face specific troubles with TAPI please post them and i will try to solve them for you.
"Imagination is more important than knowledge.."
{Albert Einstein}
|
|
|
|
|
Does anyone know why my playback terminal remains nothing after an assignment? Below is my code:
Private Sub OnDial(ByVal sender As Object, ByVal e As EventArgs)
Dim tapi As TTapi = New TTapi()
Dim addr As TAddress = Nothing
Dim CurrCall As TCall
tapi.Initialize()
For Each add As TAddress In tapi.Addresses
If (String.Compare(add.ServiceProviderName, "unimdm.tsp", True) = 0 And add.QueryMediaType(TAPIMEDIATYPES.AUDIO)) Then
addr = add
End If
Next
If addr IsNot Nothing Then
addr.Monitor(TAPIMEDIATYPES.AUDIO)
End If
Dim playbackTerminal As TTerminal
Dim Play_FileName As String = Server.MapPath(".\voices\test.wav")
' Create a call -- this should always succeed
CurrCall = addr.CreateCall("5551213", LINEADDRESSTYPES.PhoneNumber, TAPIMEDIATYPES.DATAMODEM)
If CurrCall IsNot Nothing Then
' Get the playback terminal from the call
Try
'THIS IS WHERE PLAYBACK IS UPDATED
playbackTerminal = CurrCall.RequestTerminal(TTerminal.FilePlaybackTerminal, TAPIMEDIATYPES.AUDIO, JulMar.Tapi3.TERMINAL_DIRECTION.TD_RENDER)
'BUT IT IS STILL NOTHING: Playback=Nothing
If playbackTerminal IsNot Nothing Then
playbackTerminal.MediaPlayList = New String() {Play_FileName}
CurrCall.SelectTerminalOnCall(playbackTerminal)
Else
MsgBox("Failed to retrieve playback terminal.")
CurrCall.Disconnect(JulMar.Tapi3.DISCONNECT_CODE.DC_REJECTED)
End If
Catch ex As TapiException
MsgBox(ex.Message)
End Try
|
|
|
|
|
What type is your modem? Make sure that you use VOICE modem.
>> CurrCall = addr.CreateCall("5551213", LINEADDRESSTYPES.PhoneNumber, TAPIMEDIATYPES.DATAMODEM)
it seems like you trying to create a call on DATAMODEM and run playback terminal as TAPIMEDIATYPES.AUDIO.
If you are trying to play a wav file it is supposes to be a playbackTerminal. But if you record voice, use recordingTerminal.
The initialization for playback would look like
ITBasicCallControl2 bc = (TAPI3Lib.ITBasicCallControl2)activeCall;
filePlayBackTerminal = bc.RequestTerminal(TapiConstants.CLSID_String_FilePlaybackTerminal, TapiConstants.TAPIMEDIATYPE_AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);
|
|
|
|
|
TAddress addr = tapi.Addresses[0] ;
LINEADDRESSTYPES addrType = LINEADDRESSTYPES.PhoneNumber ;
TAPIMEDIATYPES mediaType = TAPIMEDIATYPES.AUDIO;
if (addr.QueryMediaType(TAPIMEDIATYPES.VIDEO))
mediaType |= TAPIMEDIATYPES.VIDEO;
try
{
addr.Open(mediaType);
}
catch (TapiException ex)
{
if (ex.ErrorCode == unchecked((int)0x80040004))
{
try
{
addr.Open(TAPIMEDIATYPES.DATAMODEM);
}
catch
{
toolStripStatusLabel1.Text = ex.Message;
}
}
else
{
toolStripStatusLabel1.Text = ex.Message;
}
}
// Create a call -- this should always succeed
currCall = addr.CreateCall(phoneNumber, addrType, mediaType);
if (currCall != null)
{
// Get the playback terminal from the call
try
{
playbackTerminal = currCall.RequestTerminal(
TTerminal.FilePlaybackTerminal,
TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE );
if (playbackTerminal != null)
{
playbackTerminal.MediaPlayList = new string[] { PLAY_FILENAME };
//string[] names = playbackTerminal.MediaPlayList;
//playbackTerminal.Name;
currCall.SelectTerminalOnCall(playbackTerminal);
}
else
{
MessageBox.Show("Failed to retrieve playback terminal.");
}
}
catch (TapiException ex)
{
MessageBox.Show(ex.Message);
}
try
{
// Connect the call
currCall.Connect(false);
toolStripStatusLabel1.Text = "Placing call...";
}
catch (TapiException ex)
{
//toolStripStatusLabel1.Text = ex.Message;
}
}
this is my code, I am aiming to play a wav file as soon as call is connected but my playbackterminal remains null and I get an error Failed to retrieve playback terminal., I am using a voice modem ZOOM 3095, Please can anybody help me its really urgent for me. The same code if I use while connecting to data modem I can dial a call. please help me around waiting for reply. Thanks !!
|
|
|
|
|
Hi, I'm coding a simple answering machine service for Vista. I'm using Mark Smith's TAPIwrapper (TAPI 3.1) for .NET (in Visual Basic Express Edition 2008). The code looks very much like your example - same basic event handling structure - but with additional code to playback a welcome message when a call is answered and to record the caller's message after the welcome message finishes. Everything works nicely with one exception: when a remote caller hangs up, no event fires and the caller's message just keeps on recording. Eventually (after about a full minute), QWEST detects the line is idle and starts their "If you'd like to make a call, please hang up and dial again..." message. Eventually (after 2 minutes or so) QWEST kills the call and the code then finally gets the DISCONNECTED message and resets for another call. I've found several sources on the web that state this is a known issue with Unimodem drivers and voice modems - i.e. the driver does not detect remote hang-up. Many commercial PC answering machine programs apparently use some kind of line monitoring algorithm to work around the problem. If the line is "silent" for a set period of time, they force a disconnect.
My question: are there TAPI API's or other .NET methods that you know of for detecting a "silent" line. I've searched high and low and found nothing so far.
Thanks,
Clayton Gautier
|
|
|
|
|
Please find my code below. The problem is i need to initialize the bcc (basic call control) and ts (terminal support)
ERROR MESSAGE: OBJECT REFERENCE SET TO INSTANCE OF AN OBJECT.
'CODE STARTS HERE
Sub SendTapi(ByVal WavFileName As String)
Dim bcc As TAPI3Lib.ITBasicCallControl2=Nothing
Dim ts As ITTerminalSupport = Nothing
Dim fpbt As ITTerminal = ts.CreateTerminal
(TAPI3Lib.TapiConstants.CLSID_String_FilePlaybackTerminal,
TAPI3Lib.TapiConstants.TAPIMEDIATYPE_MULTITRACK,
TAPI3Lib.TERMINAL_DIRECTION.TD_BIDIRECTIONAL)
Dim mp As ITMediaPlayback = fpbt
Dim audiofile(1) As Object
audiofile(0) = Server.MapPath(WavFileName)
mp.PlayList = audiofile
bcc.unselectterminaloncall(fpbt)
bcc.selectterminaloncall(fpbt)
Dim mc As ITMediaControl = fpbt
mc.Start()
End Sub
PLEASE HELP.
ATOGWE
|
|
|
|
|
Hello,
i am a newbies in TAPI, and would like to know about setting up hardwares require for phone call(computer to phone call).i can do a IP call, but don't know how to do that. please kindly reply me the way to do that.
Thanks in advances,:->
John
|
|
|
|
|