Posted April 3, 2011 by TheUberOverLord in Free VoIP Software | No comments yet
// Created/Copyright by TheUberOverLord, for public domain use, please don’t remove this line.
// Example of using the Skype public API, Skype4COM, asynchronous TCP sockets and DTMF recognition
// This rough example is meant to be used in debug mode.
// Version 3.0.0.1
// Purpose:
// To demonstrate remote calling from mobiles and landlines or Skype name to Skype name
// using the Skype public API with Skype4COM to process voice data via a Asynchronous TCP
// port interface to call Skype names and telephone numbers with and without speeddial
// numbers using both Skype call transfer methods for inbound calls and Skype conference
// calls for outbound (“Call Me Back”) mode calls as well as playback Skype voicemails
// by using DTMF command recognition methods while providing limited access ability on
// what Skype names or telephone numbers (“PSTN Caller Id’s”) are allowed to use these
// remote calling services using Microsoft C# and no managed threads.
// Features:
// Skype inbound/outbound Skype call processing including:
// Skype to Skype calls
// PSTN to Skype calls
// Skype to PSTN calls
// Skype conference calls using both PSTN to Skype and Skype to Skype
// Skype call transfer
// Voicemail playback in calls
// Skype Speed-Dial Numbers
// Asynchronous TCP port processing using Skype public API methods
// DTMF recognition for both inbound and outbound calls using the Goertzel algorithm
// Same call recovery logic for DTMF commands. No need to hang up and try again
// “Call Me Back” mode
// This example allows you to call your Online Number(s) (“Formally called SkypeIn”)
// or Skype name(s) remotely and make Skype calls using telephone numbers or Skype names
// and telephone numbers using speeddial numbers from other phones or other Skype names.
// It’s “Skype To Go” on Steroids.
// There are many areas of the world where “Skype To Go” is not available yet but
// Skype Online numbers are. This example shows how to create your own extended version
// of “Skype To Go” like features with added features of being able to call thousands of
// Skype names or telephone numbers using Speeddial numbers and any telephone number of
// your choice as well as use a “Call Me Back” mode if it would be cheaper to have a Skype
// conference call, so that your mobile is using a inbound call
// (“Some Mobile plans don’t charge for inbound calls”) than do the same as an outbound call.
// “Call Me Back” mode has some addtional features that all users of this example may choose
// to use as well, and not because of cost.
// NOTE: “Call Me Back” mode uses Skype conference calling, so be aware that if you are
// calling a telephone number, that is using Skype credits, that you will be charged
// normal Skype rates for both the call back to you, as well as the call made to
// the other party.
// This is not an issue if you have a Skype subscription that covers both calls
// or the called party is a Skype name and the phone you called from is covered
// by a subscription. If you are calling a Skype name, and do not have a subscription
// that covers the call back to you, in that case, you would be charged normal Skype
// rates for only the call back to you from Skype.
// Call Transfer (“Which is used in this example for Normal mode processing”) will NOT
// transfer a call to a Skype user that is Offline and that does not have Skype voicemail.
// Even if that Skype user has call forwaring active and even if you have voicemail. Normally
// if you have Skype voicemail and you call another Skype user that does not, you can still
// leave a Skype voicemail. This is not the case when using call transfer.
// So you can use the “Call Me Back” mode, when/if needed to Call a Skype user that
// happens to be offline but does have call forwarding activated. Because “Call Me Back”
// mode uses Skype conference calls to do processing for this example and Skype conference
// calls do support calling a Skype user who is Offline but has call forwarding activated.
// However, Skype conference calls (“Which are used for “Call Me Back”) mode do not support
// creating a conference call with a Skype user who is Offline and does not have call
// forwarding activated.
// So you might be asking yourself, how would you know to use Normal mode or “Call Me Back”
// mode using this example. The answer is that if a call to a Offline Skype name fails
// using this example in either mode you will receive DTMF response tones that will inform
// you of if the other mode could in fact make the call using the other mode
// successfully or not to that Skype name. If the call could not be made successfully in
// either mode for that Skype name, you can then try calling their Home, Mobile or Office
// number, if that information is found in that Skype users profile data.
// While in “Call Me Back” mode there is no need to hang up every time you wish to make
// another call. Once the current call is finished. If you wish, you can wait until the
// current called party you called hangs up and wait about 5 seconds and start a new call,
// I say about 5 seconds, because it can take about that time for the API to process that
// the called party has indeed hung up.
// This example has error-recovery for every situation possible so that you do not need
// to hang up and call back because you entered a bad speeddial number or a bad phone
// number. Instead you will receive DTMF responses to tell you what happened. So that you
// can continue in the same call.
// NOTE: To receive PSTN calls you will need a Online Number (“Formally called SkypeIn”).
// If you don’t have an Online Number, you can still use the example by calling
// a Skype name instead of your Online Numbers. In both cases you can call other Skype
// names using speeddial numbers and/or if you have a Skype subscription or Skype
// credit you can also call telephone numbers using this example as well.
// If you have a Skype subscription calls transferred or created using Skype conference
// calls covered by your Skype subscription are at no cost using this example.
// Calls not covered by a Skype subscription will be at normal Skype rates.
// DTMF commands supported:
// # Playback unread voicemail messages.
// *# Call Me Back – Some Mobile plans don’t charge for inbound calls.
// This allows you to be called back and use the same features.
// 1# This calls speeddial 1. Which could be a Skype name or SkypeOut Contact.
// 1*1# If speeddial number is a Skype name the profile data for that Skype name will be
// looked at and if possible be used to call the Skype name Home number.
// 1*2# If speeddial number is a Skype name the profile data for that Skype name will be
// looked at and if possible be used to call the Skype name Mobile number.
// 1*3# If speeddial number is a Skype name the profile data for that Skype name will be
// looked at and if possible be used to call the Skype name Office number.
// *13126784527# Telephone number with no sequential same digit DTMF = 1 (312) 678-4257
// *3125*52*2*# Telephone number with sequential same digit DTMF = 1 (312) 555-2222.
// NOTE: Processing sequential same digit DTMF is virtually impossible at any
// industry standard because PSTN calls currently use the G729a codec
// which compresses silence and there is no out-of-band DTMF so we need to use
// in-band DTMF. This is why this odd sequential same digit DTMF method is used.
// Speeddial numbers can be easily created to avoid any need to remember this odd
// method, if needed. Simply create a SkypeOut contact for that telephone number.
// If any errors are encountered during processing, DTMF is returned and there is
// no need to hang up if for example you entered an invalid speeddial or
// telephone number, or if a Home, Mobile, Office phone was not found.
// DTMF returned codes to the caller:
// 1 Tone response – Completed Voicemail processing.
// 2 tone response – Voicemail processing is not enabled. See enablevoicemail.
// 3 tone response – Speeddial number not found in speeddial list.
// 4 tone response – Invalid speedial index x*(y)# Allowed y values are x*1# = Home, x*2# = Mobile, x*3# = Office.
// 5 tone response – No Home x*1# or no Mobile x*2# or no Office x*3# found for speeddial number in contact profile data.
// 6 tone response – Cannot try to find a Home, Mobile or Office number for a SkypeOut contact.
// 7 tone response – Speeddial x number requested is larger than contact list.
// 8 tone response – Call cannot be completed but using the other mode it could be.
// 9 tone response – Call cannot be completed even using the other mode it would fail.
// 10 tone response – Unable to transfer call, invalid telephone number.
// 11 tone response – Unable to transfer call, Skype denied the call transfer request.
// 12 tone response – Skype4COM exception. You can still continue.
// This can be caused while in Normal mode for invalid telephone
// number entered or not enough Skype credit to make the call if
// the call is not covered already by a subscription.
// 13 tone response – The call was not answered by the distant end.
// 14 tone response – If callbackonfailedconferencecalls is true. Invalid telephone number
// or not enough Skype credit to make the call if the call is not
// covered by a subscription.
// 15 tone response – “Call Me Back” mode – Skype conference calls disabled.
// 17 tone response – Normal mode – Skype Call Transfer disabled.
// 18 tone response – Calls to telephone numbers disabled.
// 19 tone response – Only speeddial numbers allowed. You can still use SkypeOut contacts.
// 20 tone response – Called party call terminated due to onlyallowfreecalls = true.
// There is a switch for testing that allows you to assign speeddial numbers “0″ – “9″
// as authorized users of this example. The default is process all calls for DTMF. See
// answerallcalls.
// NOTE: If you leave answersallcalls set to true any and all inbound calls you have
// Will be auto-answered and be allowed to enter DTMF commands using this example.
// Known Issues fixed in Version 3.0.0.1
// 1. While in “Call Me Back” mode an invalid telephone number will cause the conference
// call attempt to fail. This is because conference calls are used vs
// call transfer for “Call me Back” mode and since there is no way to validate the
// telephone number prior to making the conference call if a bad telephone number
// is used, you will never get called back with a conference call, in those cases.
// Solution: There is a switch called callbackonfailedconferencecalls if set to true
// this example will call back the caller when/if any conference calls fail
// while in “Call Me Back” mode. True is the default.
// How to use this example:
// Simply create a C#.NET Form project use the default name for the project and
// delete the entire contents of Form1.cs Add these contents and right click
// on Your C# project solution and add a reference using the COM tab to Skype4COM,
// build then debug. There are many MessageBox’s that can be uncommented
// to help you test. The lastest version of the Skype4COM.dll can be found here:
// http://developer.skype.com/accessories you need to have it and register the .dll
// NOTE: If you are using Visual Studio 2005, remove System.Linq above
// If your solution/project name is not WindowsFormsApplication1 then change
// namespace below to match your solution/project name.
// If you would like to see what is going on behind the scenes with this example
// you can monitor what is going on between this example and the Skype public API
// by installing SEHE (“Skype4COM Event Handler Example”) as a monitor from here:
// http://www.saveontelephonebills.com/skype/SEHE/ SEHE can be removed at any time
// using your Windows control panel Add/Remove programs. To also learm more about
// SEHE Please go here as well: http://forum.skype.com/index.php?showtopic=142821
// Please go here for any questions about this example:
// http://forum.skype.com/index.php?showtopic=807811