0

I want to write a program to access my Android phone's camera on my laptop wirelessly, so, my phone will act like a wireless webcam. I want to implement the UDP ( or TCP ) protocol in Java to communicate between my laptop and phone.

I was thinking of making an ad-hoc wireless network in my laptop and connecting my phone to it first, and then write the code to create a server socket on my laptop and client socket on my phone. I know this code will work for a "direct communication" between server and client. but will this method of ad-hoc network communication count as a "direct communication" ? If not, what do I do to achieve this ?

Thank you, firstly for reading my whole problem, and, thanks a lot if you can answer this for me

:)

Deepun
  • 1
  • 1
  • 1
  • It might be easier to answer this question if I knew what you meant by 'direct communication'. This is certainly one of the more direct ways to communicate between your phone and computer, although I suppose USB or something might be closer to what you call 'direct communication', but then you wouldn't be using either UDP or TCP. – waxspin Jun 01 '12 at 16:24
  • how about the gc2dm or the way ESfileExplorer app connects with computer via LAN. – drulabs Jun 01 '12 at 17:35

1 Answers1

0

First of all: Don't concentrate on ad-hoc networks. In most cases WiFi with infrastructure mode access points will be available. If on the road, all recent versions of Android are able to act as a wireless access point.

So let's assume both devices are connected to the same network and are able to reach each other (using the IP protocol) - in other word they are able to ping each other. The next issue you have to solve is: How do both applications find each other? Bonjour/Zeroconf might be a solution (see Are there any other Java libraries for bonjour/zeroconf apart from JMDNS?).

The next question is: What protocol you want to use? You mentioned TCP and UDP. In most cases UDP will be used for transmitting video data, because you have a lower latency and the video codecs are tolerant on missing packets.

With this information you can create a ServerSocket and (from the client side) know where to connect to it.

Community
  • 1
  • 1
Thor
  • 6,607
  • 13
  • 62
  • 96
  • thank you. I was thinking in a similar way, to implement sockets in java via. UDP. I was thinking of using the 'vlcj' libraries to reconstruct the frames that are sent. – Deepun Jun 06 '12 at 13:17