How to create SIP server for my android? - android

I am developing an Android application, in which I want to make a calls using internet using SIP in android. So I need to maintain my own SIP sever for my app users, how can I create my own SIP server?

I would not advise creating your our sip server as it would take a large number of man years of development and there are a lot of pitfalls.
There are some open source implementations that you could install and setup yourself. Like FreeSwitch or Asterisk. Both are large and complete to setup as there is a lot of domain knowledge required to understand how to set them up correctly.
There are also free server that you could try out as well like Sip2Sip.
Then there is the job of creating a sip client on Android. Again it's not that simple either. I would look at using a open source library here as well, like pjsip. This gives you the advantage of being able to look at examples of full sip clients already developed for Android like csipsimple. pjsip also has the advantage of being cross-platform, so you could reuse it in IOS for example.
Good luck.

The Server
As a communication server, choose for example sip:providerCE v2.6. The easiest way to get started with it is to download the VMware or Virtualbox image and fire it up on a suitable machine. If you get more serious, you want to install the system from scratch on a dedicated server with a public static IP. If you’re new to VoIP and SIP, do NOT try to install it on an Amazon EC2 instance, as they’re using destination NAT, which is a big pain for SIP and needs some experience with the SPCE to tweak it properly for that scenario.
Note that the SPCE is a 64bit system, so in order to run the VM images, you need to turn on 64bit CPU virtualization in your BIOS if VMware or Virtualbox warns you about it.
...There is very good tutorial HERE! on how to set things up.
...Don't forget there is a technical advise concerning SIP check the accepted ANS!
...Least but not last check THIS! VOIP Wiki, It covers everything related to VOIP.

SIP RFC is very easy protocol to implement. Just create a socket listener and implement RFC-3261. Start with with a basic codec GSM, then move up to A-LAW (G.711), as needed.
The tricky parts with SIP are (A) ensuring your call flows are correct (RFC-3665) and (B) media encoding/compresion. Use Asterisk (FreeSwitch) and WireShark to test your call flow. If you need DTMF support you'll need RFC-2833. If you need advanced codecs, consider using open-source library like FFMPEG.

I used uSIPserver on android. It works well and support video call. If you use client app which supports video then you can video call eachother on wifi.
It is so simple to use.
Good luck :-)

Related

Tcp/IP socket programming in python

I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Any one can help?
Android gives you options to connect via HTTP.
http://developer.android.com/guide/topics/connectivity/index.html
So I would probably go with a REST type implementation
https://en.wikipedia.org/wiki/Representational_state_transfer
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
Here is a tutorial for Android and REST
http://www.majidkhosravi.com/android-rest/
But you are dealing with pictures. Here is a SO talking about that.
POSTing image from Android to WCF Rest Service
On the Python side you have multiple choices, but the main ones I would consider:
Twisted (or maybe Tornado) if you want Asynch.
http://twistedmatrix.com/trac/wiki/WebDevelopmentWithTwisted
http://zenmachine.wordpress.com/web-services-and-twisted/
Flask for Synch.
http://flask-restful.readthedocs.org/en/latest/quickstart.html
Maybe Nginx/Apache + Django
http://django-rest-framework.org/
SO post about Python and REST
Recommendations of Python REST (web services) framework?
If you want to implement this at the socket level, this book would be a great resource:
http://www.amazon.com/Foundations-Python-Network-Programming-Goerzen/dp/1590593715
Hope this helps provide you some directions to explore.
poof's answer is a good overview, but here are some notes on the various options:
Option 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django. It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code).
The upside is that the low-level "Glue" is written for you, and it scales easily. The downside is that HTTP has some overhead.
Option 2: Have your Android talk a custom TCP protocol to a custom TCP application.
This is more work, so you should avoid it unless you need it. It will be more efficient and have lower latency, especially if you're sending multiple pictures. The response can also be much smaller without HTTP headers.
In either option, you don't have to send a JPEG, you could send any custom format you want (there is a trade-off between compression on Android and size of file).
I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Start where everyone else started - by reading a lot and playing a lot. You can find plenty of introductions to Socket programming in Python on the web. Go thru the tutorials, and start modifying them to see how they work. Read up on TCP/IP itself -- there are a lot of dark corners (Nagel, fragmentation, slow start) that can affect how you write the app when you get to a low level.

Questions for VoIP app development (SIP etc.)

I am looking for general advice (technologies, best practice etc.) regarding the development of a VoIP application for Android. Similar questions have been posted, but I included specific questions.
I did quite some research and I noticed that there are several possible solutions (of course I know about the SIP stack in the SDK (also that it includes even voice transmission), but since it's not available on most devices, I don't intend to use it. Also, I read about Adobe Flex implementations but I would like to stick to something native).
What stuck to my mind is the following:
initiate the session using SIP (the server exists). Use SDP in the messages to discribe the session.
establish p2p connection (firewalls/routing may be a problem - STUN could be used - DNS may be involced than)
make actual transmission, I believe that the packets/procols involved are (payload) in -> RTP in -> UDP in -> IP.
This seems quite complicated at the moment so my first question is:
1)is this a standard approach? Is it best practice? I got some hints that, instead, MSRP could be used to transmit content, but I have read that it is only for IM, files etc.
2) Which SIP stack should I use for the best results/performance? I can use Java/Eclipse for development. I was thiking to choose JSIP (or tinysip, based on jsip) but am not sure.
3) Please give me a few hints about how to implement the data transmission in Java for Android (RTP)
As a last note, I am not excluding at all pjsip. I am thinking that it may be actually faster since it uses the NDK (I could switch to C++, np) . I also read that it already includes audio/video transmission.
I just don't know how easy it is to use and extend it and how good it really is. If you have used it, please let me know!
Thank you.
PS: Although not urgent or certain, portability may be an important factor for future.
I will need video transmission as well in the near future.
You should check out the IMSDROID project. It uses Doubango Framework which is written in C and is highly portable. What more, it is open sourced too so you can play around with their code and possibly contribute towards the community.
http://code.google.com/p/imsdroid/
cheers :)
Take a look at teamSpeak. They provide native sdk-s. But they aren't free.
It's not P2P, requires a server (at least as I know)
May worth a minute.
http://www.teamspeak.com/?page=teamspeak3sdk
Writing your own SIP stack takes a few months with only basic features.
I would recommend to use an existing sip stack. There are a few opensource discussed here.

What options exist to update Android app setting remotely?

I have an Android device that I'm using to monitor a couple of sensors with an app that I created. What useful ways are there to update the settings in my app (while it's running at a remote location) from my computer? I'm interested in sending a message to my app to tell it to email a screenshot, change sample rate, etc. Creative workarounds are encouraged.
I've already looked into C2DM and unfortunately have no experience with setting up the required third-party application server.
[EDIT] It just occurred to me that I may have grossly over simplified what you were trying to do. If this is the case my answer probably wont be of much if any help to you. The original answer follows though.
You could use TCP sockets to set up a client/server interface between your app and a command program on your computer. Then just send a set of predefined messages/commands. Two tutorials I used for learning this are Here and Here. This wont help with the computer side of the sockets code per se although if you write the computer program in Java it should effectively be the same. This is something we are doing at my company to create a custom command interface for a product we have in development.

How can i transfer data from an android device to a C++ PC program?

I want to connect an android mobile program to a C++ program, and i dont really know how it should be done.
I was thinking about a Bluetooth connection, but i dont really know how to handle bluetooth in C++. Could you give me some general advice about this?
If you think that i should use another kind of connection, like tpc-ip based, please, let me know and give me some general advices too.
I need the data transfer to be fast, because im trying to use the android device as an interactor, so i need a fast feedback from the C++ program.
Thanx.
If I were you, I would use a TCP/IP connection. It is very easy to implement in Java (Android) and also in C++. Besides, it makes it easy to change the frontend later on. And it is as fast as your network connection, which is usually faster than bluetooth.
Just make sure you put enough effort in the design of your protocol.
There are a lot of resources to be found on the internet on how to create TCP/IP connections, both in Java and C/C++.
If you wanted to have a client server model kind of an use here. Better is to host your Server app(Port your C++ app to Java servlets) & access the Server app via http via Android client. Webviews in android are very useful in doing these.

controling network communication

I need to develop an Android application that sets up connection via WiFi with computer and then sends packets with data. Jowever, I need to control send packets, not only theirs data but also headers, there should be possible to modify any field in their header as well. In windows in it is possible with use of winpcap and jpcap, and I wonder if sth similar I may find on Android. Is there any ready API that will help with my problem?
There's no API available to a Java/Dalvik app on Android which would allow you to do that.
Android is a Linux system, though. So you could try to find/write one or two Linux applications to support your effort - or use JNI.
Bottomline: Native code will definitely be necessary to achieve what you want, no way to do this in Java alone.

Categories

Resources