TAPI ?
Posted: Wed Nov 11, 2009 7:02 pm
Ok I have followed threw coding for sending a phone call thru my V.92 modem.
I am trying to code my V.92modem to dial a phone number
Here is the link on the msdn site that talks you thru the code
http://msdn.microsoft.com/en-us/library ... de_samples
just cann't get all the pieces to work. Any help would be great. It compiles and links fine however I get an access violation if I proceed between these lines in the code
So the real problem is the unablety to create/initialize the pStreamControl in my program???
If I can get this then the only other thing that can go wrong would be the TERMINAL part4 of the examples.
Curious though what the difference is in using connect or dial functions of ITBasicCallControl to place the phone call? Maybe I should be using dial to use it with V.92 modem and connect if I was useing H323 or SIP or VOIP app...etc.
Thanks again for any help
I know it is alot to look at.
Remember it is this
that makes the whole thing fail hr is not OK
Cann't establish what why it is not ok am I not seting the parameters correctly if so what do I use?
Note also that if you want to download and test it you will have to change the 5555555 to a vailed phone number. And I was in VS2005 studio , windows XP SP 2 with DirectX 2008 installed ....
Code: Select all
#define _WIN32_WINNT 0x0400
#define WIN32 0
#include <Tapi3.h>
#include <Objbase.h>
#include <iostream>
int main()
{
printf("hello" );
// Initialize COM.
HRESULT hr = CoInitializeEx( NULL , COINIT_MULTITHREADED );
if(hr != S_OK)
{
printf("error occured in initializing com ... " ) ;
return 0 ;
}
// Create a TAPI entry point object.
ITTAPI *gpTapi; // globally allocated
hr = CoCreateInstance( CLSID_TAPI, NULL, CLSCTX_INPROC_SERVER, IID_ITTAPI, (LPVOID *)&gpTapi );
if(hr != S_OK)
{
printf("error occured in creating tapi entry point ... " ) ;
return 0 ;
}
// Initialize TAPI.
hr = gpTapi->Initialize();
if(hr != S_OK)
{
printf("error occured in initializing tapi entry point ... " ) ;
return 0 ;
}
IEnumAddress * pIEnumAddress;
ITAddress * pAddress;
ITMediaSupport * pMediaSupport;
VARIANT_BOOL bSupport ;
// Use the TAPI object to enumerate available addresses.
hr = gpTapi->EnumerateAddresses( &pIEnumAddress );
if(hr != S_OK)
{
printf( "error in gpTapi ...." ) ;
system("PAUSE") ;
}
printf("got here " ) ;
system("PAUSE" ) ;
// Locate an address that can support the media type the application needs.
while ( S_OK == pIEnumAddress->Next(1, &pAddress, NULL) )
{
// Determine the media support.
hr = pAddress->QueryInterface(
IID_ITMediaSupport,
(void **)&pMediaSupport
);
if(hr != S_OK)
{
printf( " pAddress QueryInterface error .... ") ;
system("PAUSE" ) ;
}
// In this example, the required media type is already known.
// The application can also use the address object to
// enumerate the media supported, then choose from there.
hr = pMediaSupport->QueryMediaType(
TAPIMEDIATYPE_AUDIO|TAPIMEDIATYPE_VIDEO,
&bSupport
);
if(hr != S_OK)
{
printf("pMediaSupport error...") ;
system("PAUSE");
}
if (bSupport)
{
break;
}
}
// pAddress is now a usable address.
system("PAUSE" ) ;
// Specify the destination address.
//
//const OLECHAR * szAddressToCall = CA2W("5555555");
const wchar_t szAddressToCall[] = L"5555555";
long dwAddressType = 0;
long mediatype = 0;
// retrieved from a user interface.
ITBasicCallControl * pBasicCall ;
BSTR bstrAddressToCall = SysAllocString( szAddressToCall );
if( bstrAddressToCall == NULL )
{
printf( "BSTR is NUll ... " ) ;
system("PAUSE" ) ;
}
hr = pAddress->CreateCall(
bstrAddressToCall,
dwAddressType,
mediatype ,
&pBasicCall
);
if( hr != S_OK )
{
printf("pAddress-> CreateCall error...") ;
system("PAUSE") ;
}
SysFreeString(bstrAddressToCall);
// Create the required terminals for this call.
// See the Select a Terminal code example.
// pAddress is an ITAddress interface pointer.
// pBasicCall is an ITBasicCallControl interface pointer.
// Get the ITStreamControl interface.
//ITBasicCallControl * pBasicCall = 0;
ITStreamControl * pStreamControl;
hr = pBasicCall->QueryInterface(
IID_ITStreamControl,
(void **) &pStreamControl
);
if( hr != S_OK )
{
[b]printf("error in pStreamControl ... ") ; // Problem is here it fails get the intialize the pStreamControl?[/b]
system("PAUSE") ;
}
system("PAUSE" ) ;
// Enumerate the streams and select
// terminals onto them.
IEnumStream * pEnumStreams;
ITStream * pStream;
system("PAUSE" ) ;
hr = pStreamControl->EnumerateStreams(&pEnumStreams);
// If ( hr != S_OK ) process the error here.
system("PAUSE" ) ;
while ( S_OK == pEnumStreams->Next(1, &pStream, NULL) )
{
// Get the media type and direction of this stream.
long lMediaType;
TERMINAL_DIRECTION dir;
hr = pStream->get_MediaType( &lMediaType );
// If ( hr != S_OK ) process the error here.
hr = pStream->get_Direction( &dir );
// If ( hr != S_OK ) process the error here.
// Create the default terminal for this media type and direction.
// If lMediaType == TAPIMEDIATYPE_VIDEO and
// dir == TD_RENDER, a dynamic video render terminal
// is required. Please see Incoming.cpp in
// the samples section of the SDK.
// For all other terminals, get the default static terminal.
ITTerminal * pTerminal;
ITTerminalSupport * pTerminalSupport;
hr = pAddress->QueryInterface(
IID_ITTerminalSupport,
(void **)&pTerminalSupport
);
// If ( hr != S_OK ) process the error here.
hr = pTerminalSupport->GetDefaultStaticTerminal(
lMediaType,
dir,
&pTerminal
);
// If ( hr != S_OK ) process the error here.
// Select the terminal on the stream.
hr = pStream->SelectTerminal(pTerminal);
// If ( hr != S_OK ) process the error here.
}
// Make the connection.
pBasicCall->Connect( TRUE );
return 0 ;
}
Here is the link on the msdn site that talks you thru the code
http://msdn.microsoft.com/en-us/library ... de_samples
just cann't get all the pieces to work. Any help would be great. It compiles and links fine however I get an access violation if I proceed between these lines in the code
Code: Select all
system("PAUSE" ) ;
// Enumerate the streams and select
// terminals onto them.
IEnumStream * pEnumStreams;
ITStream * pStream;
system("PAUSE" ) ;
hr = pStreamControl->EnumerateStreams(&pEnumStreams);
// If ( hr != S_OK ) process the error here.
system("PAUSE" ) ;
If I can get this then the only other thing that can go wrong would be the TERMINAL part4 of the examples.
Curious though what the difference is in using connect or dial functions of ITBasicCallControl to place the phone call? Maybe I should be using dial to use it with V.92 modem and connect if I was useing H323 or SIP or VOIP app...etc.
Thanks again for any help
I know it is alot to look at.
Remember it is this
Code: Select all
hr = pBasicCall->QueryInterface(
IID_ITStreamControl,
(void **) &pStreamControl
);
Cann't establish what why it is not ok am I not seting the parameters correctly if so what do I use?
Note also that if you want to download and test it you will have to change the 5555555 to a vailed phone number. And I was in VS2005 studio , windows XP SP 2 with DirectX 2008 installed ....