Thread: Phones and C++

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905

    Phones and C++

    Is there an API out there or even just a program that can answer the phone when it's plugged in to the 56k port on your computer? Also is it possible to dial out using the 56k on your computer and send sound?

    To clarify, I do NOT want VoIP
    Last edited by jverkoey; 06-07-2005 at 07:52 PM.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    I don't think there is any API for it. Of course you can tell your modem to dial, its kinda worthless otherwise
    Windows used to have a phone dialer that would just dial, make a connection, and then sit there until you disconnected. You could then use the phone to talk.

    I'm not sure how feasible it is to send analog sound from the modem itself. I suppose it's possible.

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    If you are using Windows you can use the Telephony API which includes the ability to manage phone lines, answer phones, hang up phone lines, read caller id, etc.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Quote Originally Posted by jverkoey
    Is there an API out there or even just a program that can answer the phone when it's plugged in to the 56k port on your computer?
    Yes. There are several answering machine programs. The Windows API for this is called TAPI (Telephony API). Here is a good start page for TAPI applications. Be warned, it is somewhat complex.

    As a starter, to receive notification of a call and answer it, you should look at these topics:
    Code:
    lineInitializeEx
      lineOpen
        Monitor for LINE_CALLSTATE event with LINECALLSTATE_OFFERING
        lineAnswer
          // Do something
          // Monitor for LINE_CALLSTATE with LINECALLSTATE_DISCONNECTED 
        lineDrop
        lineDeallocateCall
      lineClose
    lineShutdown
    Also is it possible to dial out using the 56k on your computer and send sound?
    With a normal modem, you can send tones (such as digit tones). To send voice or other sound, I believe you need a voice modem. If I remember correctly, a voice modem would install itself as a sound device. Assumably, after establishing a call, you could use a sound API to play and record sound (you could also use the simpler MCI). You can dial out with lineMakeCall.

    There is a nifty utility, included with the platform SDK, called Tapi Browser (TB20.exe) that allows you to call TAPI functions. So you can try all this out without writing a line of code. Use lineGetDevCaps to get info on your modem. If it supports voice, it should include "wave/*" under the dwDeviceClassesOffset field.

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Awesome, yah I just found out all that TAPI stuff right after I posted and made the following program which calls my cell phone and just sits there....

    The callback function doesn't seem to do anything though for some reason....so I'm a big lost.

    Code:
    #include <iostream>
    #include <Tapi.h>
    #include <conio.h>
    
    #pragma comment(lib,"Tapi32.lib")
    
    using namespace std;
    
    VOID FAR PASCAL lineCallbackFunc(
      DWORD hDevice,
      DWORD dwMsg,
      DWORD dwCallbackInstance,
      DWORD dwParam1,
      DWORD dwParam2,
      DWORD dwParam3
    );
    
    int main()
    {
    	HLINEAPP hLineApp;
    	DWORD numDevices=0;
    	DWORD version=0x00020002;
    	ULONG result=0;
    	LINEINITIALIZEEXPARAMS lineInit;
    	memset(&lineInit,0,sizeof(lineInit));
    	lineInit.dwTotalSize=sizeof(lineInit);
    	lineInit.dwNeededSize=sizeof(lineInit);
    	lineInit.dwUsedSize=sizeof(lineInit);
    	lineInit.dwOptions=LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
    
    	if(!(result=lineInitializeEx(&hLineApp,GetModuleHandle(NULL),&lineCallbackFunc,"PhoneProgram",&numDevices,&version,&lineInit)))
    	{
    		cout << "Call center initialized Num Devices: " << numDevices << endl;
    
    //		lineGenerateDigits(hCall
    
    		HLINE hLine;
    		LINECALLPARAMS lineCall;
    		memset(&lineCall,0,sizeof(lineCall));
    		lineCall.dwTotalSize=sizeof(lineCall);
    		result=lineOpen(hLineApp,0,&hLine,version,0,0,LINECALLPRIVILEGE_OWNER,LINEMEDIAMODE_UNKNOWN,&lineCall);
    
    		if(!result)
    		{
    			cout << "Success" << endl;
    		
    			HCALL hCall;
    			memset(&lineCall,0,sizeof(lineCall));
    			lineCall.dwTotalSize=sizeof(lineCall);
    
    			if((result=lineMakeCall(hLine,&hCall,"619-8230",1,&lineCall))>0)
    			{
    				cout << "Success!" << endl;
    
    				result=lineDial(hCall,"+1 (403) 619-8230",0);
    
    				if(result>0)
    				{
    					cout << "Success! Calling!" << endl;
    				}
    				else
    				{
    					cout << "Error" << endl;
    				}
    			}
    			else
    				cout << result << endl;
    			while(getch()!=27);
    
    			lineShutdown(hLine);
    		}
    		else
    		{
    			cout << "Error\n" << result << endl;
    		}
    	}
    	else
    		cout << result << endl;
    	return 0;
    }
    
    VOID FAR PASCAL lineCallbackFunc(
      DWORD hDevice,
      DWORD dwMsg,
      DWORD dwCallbackInstance,
      DWORD dwParam1,
      DWORD dwParam2,
      DWORD dwParam3
    )
    {
    	cout << "Poll" << endl;
    }

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    That poor little lonely hidden window wants to pump some IRON (some messages would be second best, car tyres would be a poor third choice)!

Popular pages Recent additions subscribe to a feed