Code Repo    |     RSS
MD's Technical Sharing



Thursday, May 28, 2009

callwithus.com: SIP Server with concurrent incoming & outgoing calls

If you're looking for a SIP server that can handle concurrent calls, I'd recommend www.callwithus.com which I have tried. Some of its outstanding features include:
  • There is theoretically no limit on the number of concurrent outgoing SIP calls. You can have as many concurrent ougoing calls as you want, subject to your available balance. Each outgoing call requires a minimum balance of 1 USD, so to make 10 concurrent outgoing calls you'll need at least 10 USD available balance. I have myself tested up to 10 concurrent calls using PJSIP with no issues.
  • Good web interface. A lot of things can be customized from the web interface. You can check rate, perform a call via callback between 2 phones without the need for a SIP client. You can also set a caller-ID which will be displayed as your number when you call. However, caller-ID is not reliable for countries other than US and Canada. In my tests, I call a Singapore number. Out of 10 calls, the caller-ID only showed for only 2 calls.
  • Support for DID (Direct Inward Dialing) number. You can purchase a DID number for people to call you on your SIP phone. Max. 4 concurrent DID incoming calls.
  • Low calling rate. Rate to Singapore is only 0.02 USD/minute.
  • Easy to top-up credit. You can purchase credits via Google Checkout (supports VISA, Mastercard and other major credit cards). It's on a prepaid basis and not a subscription. You don't have to worry about monthly charge to your credit card; the service won't renew automatically - but remember to topup when you run low on credits
  • Good customer support. I received a reply within an hour upon submitting my query.
To me, the most useful features is the unlimited number of concurrent outgoing calls. Very few other SIP service providers offer this.
Read More »

Monday, May 25, 2009

Accessing wifi hardware status via Microsoft.WindowsMobile.Status.SystemState

The State and Notification Broker in WM6 supports the following new properties (not present in WM5 SDK)

* BluetoothStateA2DPConnected
* BluetoothStateDiscoverable
* BluetoothStateHandsFreeAudio
* BluetoothStateHandsFreeControl
* BluetoothStateHardwarePresent
* BluetoothStatePowerOn

and

* WiFiStateConnected
* WiFiStateConnecting
* WiFiStateHardwarePresent
* WiFiStateNetworksAvailable
* WiFiStatePowerOn

To use these properties, you must add a reference to Microsoft.WindowsMobile.Status found in C:\Program Files\Windows Mobile 6 SDK\Managed Libraries\Microsoft.WindowsMobile.Status.dll (that is, the WM6 SDK), and not another DLL having the same name found in C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\DesignTimeReferences\Microsoft.WindowsMobile.PocketOutlook.dll (which is for WM5 SDK). If you mistakenly add the WM5 SDK's DLL, you won't be able to access these properties.

Reference:

What's New For Managed Developers In Windows Mobile 6
Read More »

Sunday, May 24, 2009

Create a table of contents in Blogger.com

Well, there seems to be no built-in gadget to insert a table of contents of your blog. The 'Blog Archive' gadget can be customized a bit but that does not suit my needs. Luckily there is a simple way to do it:

1. Go to http://feedburner.com/and sign up for a free account. You can use your existing Google account.
2. Use your blog address as a feed.
3. Then, click on the Publicize tab. Then click on Buzz Boost. Configure the settings so that it'll only show the post title (e.g. uncheck everything). Then click 'Activate'.
4. You'll be given an HTML code. Go to your blog settings and create a gadget containing this HTML code.
5. Done! Now you'll alwayshave an updated TOC for your blog.
Read More »

Inconveniences while posting to blogger

This post summarizes some of the inconveniences I faced as a new user of Blogger.

Source code

I almost never posted source code to blogger before, so I did not anticipate this problem in advance. After a few hours creating posts containing code snippets, I decided to have a look at my blog's home page. Unfortunately the home page was distored! I had a hard time figuring out what the culprit might be, and in the end it turns out that the 'less than sign', or '<' is causing the problem. Obviously, the Google WYSIWYG editor does not automatically convert the "less than" (and other) symbols into their html equivalent in some cases. The symbol remains as-is in the HTML of the post and conflicts with other HTML tags, thus causing the distortion.

Captcha while posting

To prevent spam, if you made more than 50 posts per day, you'll have to enter a captcha every time you post.



Email posting is also disabled. You'll receive a delivery failure notification similar to below:

From: Mail Delivery Subsystem [mailer-daemon@google.com] This is an automatically generated Delivery Status Notification Delivery to the following recipient failed permanently: mdanh20021.mail2blogger@blogger.com Technical details of permanent failure: You have exceeded the the allowable number of posts without solving a captcha.

Auto-identification of spam blogs

This surprised me. After I made a few post, some of which contains link to my favourite websites, I received the following email:



When I visit my blog home page, there is also a warning that my blog is a spam blog. I clicked the link inside the email and stopped making more posts. Luckily, the following morning, the spam warning disappeared. I am just praying hard that this won't happen again!
Read More »

Wednesday, May 13, 2009

P/Invoking C++ callback functions crashes when .NET application is not in focus

A C++ DLL exports one function having its only parameter as a pointer to another function:


#define AFX_EXT_CLASS __declspec(dllexport)
typedef void (CALLBACK* CALLBACKFUNC)(INT param1);
AFX_EXT_CLASS INT
TestCallback(CALLBACKFUNC lpCallback);

INT
TestCallback(CALLBACKFUNC lpCallback)
{
MessageBox(GetActiveWindow(), L"Press OK to make the callback", L"Testing", MB_OK);
lpCallback(1);
}


From .NET code, P/invoke the function TestCallback()


Public Delegate Sub MyCallback(ByVal param1 As Integer)

<DllImport(DllName)> _
Public Function TestCallback(ByVal lpCallback as MyCallback) As Integer
End Function

Public Function MyCallbackFunc(ByVal param1 As Integer) As Integer
MessageBox.Show("Callback works. Param = " + param1.ToString)
End sub

TestCallback(
AddressOf MyCallbackFunc)


It seems to work fine for a while. However, if the C++ function TestCallback calls lpCallback() when the .NET application does not have focus, or after it's been running for sometime, the .NET application will crash.


The reason is probably that the callback delegate has been garbage collected and the function pointer that was passed to unmanaged code has been invalidated. You have to ensure that the delegate is alive for as long as the function pointer is used, by holding a reference to it. This means you can't create the delegate inline in the same way it's done in the above code sample:


TestCallback(AddressOf MyCallback) 'VB.NET

TestCallback(new MyCallback(MyCallback) //C#

The correct declaration would be:

Dim MyCallbackEvent As MyCallback = AddressOf CallbackHandler
TestCallback(MyCallbackEvent)


It is advised to keep these delegate as global variables, otherwise GC.Collect() and GC.KeepAlive() may be needed

Read More »