Transferring image via mobile peer to peer - android

I have a requirement to transfer images between two devices which do not have access to the internet/cellular data and are not on the same network.
I need this to work across Android and iOS, which rules out wifi-direct (Android) and multi-peer connectivity (iOS).
After lots of research, I've concluded that the p2pkit library is my best bet, however data transfer is limited to just 440 bytes which is nothing for an image.
What I'm about to do is create a process that splits images into chunks and transfers via p2pkit, but wanted to double check if anyone is aware of a better way/alternative libraries for achieving this? (Please don't suggest AllJoyn as I painfully learned devices must be on the same network!)
Thanks.

Related

How to use WebRTC on Android for Real Time Communication?

I'm working on a simple project in which i need to control a Arduino Robot (2-servo motors) through an Android Phone's Gyroscope Sensor, via Internet.
As you can visualize, 3-axis Gyroscopic Coordinates change quite sensitively even with little change in Phone's orientation in 3D space, so i want to minimize the Lag to milliseconds.
Now aside from hardware, my first milestone is to send Gyroscope coordinates from Android to a computer through internet as Fast and Continuously as possible (like a RealTime stream of Numeric data). I know traditional HTTP based Client-Server mechanism will be quite slow therefore i've looked into following:
Google's Chanel API
WebRTC
WebSockets
According to my research, Channel API shows latency that from 10ms to even in Seconds. Also GAE limits requests to 30 seconds. Here is a Channels API stress test:
http://channelapistresstest.appspot.com/
Try clicking "send 5"-button a lot, and you will see latency numbers going up to several seconds.
Now WebRTC sounds most promising and faster than WebSockets. I'll be really grateful if someone can guide me about practical implementation of WebRTC in Native JAVA and Native Android (Any good libraries? i want to send coords. from Android and Receive via a JAVA-SE client on Desktop). I'm not interested in Hybrid App solutions (like Crosswalk). I would also like to know about How should i setup a Signalling Server. Summing it up i have following questions:
Which method should i use? (Channel API, WebSockets, WebRTC or something else) with native Java and android support?
Incase of WebRTC, how should i setup a Signalling server? (just brief description) or a WebSocket Server for WebSockets?
Can i make use of Google's Cloud platform or something similar to reduce complexity at my end?
Any overall suggestion?
Thanks in advance.
You do not want to use WebRTC. WebRTC requires you to setup a separate signaling channel like WebSockets anyway, so it is needlessly complex and very heavyweight for what you are trying to do.
If your requirement is simply to communicate a series of gyroscope values from an device to another, I recommend:
Start with a simple socket server
Connect your clients to this server via a socket
Relay messages from one client to the other
A simple server to print socket input to standard output is just a few lines of Python, for example. This does require you to learn to use sockets because your clients need to be interpreting the byte stream in the same way. You can also use WebSockets, but this may increase the complexity of your server significantly; Java EE is significantly more complex than Java SE, for example.
If you want data integrity (I imagine you do), you should use TCP.
If you are really worried about latency, you should also skip going to the Internet. Run everything on a LAN. I imagine you have to see the device under control anyway, so there's no point on going out to the Internet.
I would ignore WebRTC for this project. It is more complicated to setup and requires a special server.
WebSocket should be just fine for this project. It is as fast as TCP.
If you would like to avoid even this delay at all cost, but packet loss is not a problem, then I would go for simple UDP. For all these, you don't need any library, just a few lines of code.

Working behind the NATs - a scheme for device communication

I'm trying to come up with a solution enabling data exchange between an embedded device (xMega128(C) based) and an Android apps. The catch is the data exchange must be conducted via the Internet and both the embedded device and the mobile device running the app can be behind different NATs, connecting using different ISPs, 3G, LTE, etc.
I tried UDP hole punching, but it does not work with symmetric NATs. Multi hole punching with prediction also does not guarantee 100% reliabilty. I also considered using ICE, but ICE C libraries (pjnath, libnice) are incompatible with the hardware chosen (libs require os). Right now I'm considering implementing or use (if exists) traffic relay server, but that just seems like a hack to me.
Are there any other options I hadn't considered? Any help will be appreciated.
Ideally, the communication scheme would be:
100% reliable
relatively low-latency (3 seconds absolute max)
scalable (say up to 500k devices in the future)
initializable by both the app and the device
multi-user – one device would connect to many android apps
Also, if this helps, the data exchange between the device and the app is not very high-intensity – roughly 1 session per hour, ~50 messages per session with 10-20 seconds between them, each message weighing around 100 bytes.
What you're describing is effectively peer to peer or a subset thereof and to get that working reliably is a lot of work. Where peer to peer fails you normally fall back to a relay server. It can be done but the amount work to do it is quite large. Your list of requirements is also quite steep...
100% reliable
There's no such thing as a reliable connection. You need to build in fault tolerance to the app to make it reliable.
relatively low-latency (3 seconds absolute max)
Quite often you will be limited by physics ie speed of light. Low latency is hard.
scalable (say up to 500k devices in the future)
I don't know what this means ie is this concurrent connections?
From wikipedia on NAT Traversal
Many techniques exist, but no single method works in every situation
since NAT behavior is not standardized. Many NAT traversal techniques
require assistance from a server at a publicly routable IP address.
Some methods use the server only when establishing the connection,
while others are based on relaying all data through it, which adds
bandwidth costs and increases latency, detrimental to real-time voice
and video communications.
ie it will work sometimes ie it will be unreliable so you need to user several methods to make it reliable.
As long as both endpoints are behind different NATs you don't control, it won't work reliably. No way. You need a relay.

methods to do a web conference Camera and microphone for ipad, android as a web based solution

I am currently building a virtual class room and I need to stream the camera and microphone to many students.
Previously I used red5 server, but due to the lack in the support for ipad, iphone and android, had to remove red5. I have abandoned webrtc since it is a peer to peer solution (Due to bandwith problems in client side).
The solution I am looking for is a web based solution and a non peer to peer solution is the preference. Is there a way to accomplish my task? I'd like to do this as an open source project.
Any help is greatly appreciated.
Your best option may be to reexamine the webrtc route. You don't have to do peer-to-peer, you could in fact use your server to relay the streams. I can't think of any servers that do this off the top of my head, but I am certain that I've seen them while doing my research.

Sending large files with Android Beam (or S-Beam)

I've been tasked with adding support to an app for beaming large data files (tens of megabytes) from device to device via 'NFC' on Android.
I'm aware that genuine NFC on Android is painfully slow, but I know that ICS has support for doing hand-off of the bulk data transfer to Bluetooth; and Samsung have a proprietary mechanism for doing the same via Wifi Direct (S-Beam). So that's the approach I'd want to take.
Unfortunately I cannot find any information on how to actually do this.
I've looked at the Android Beam documentation, and there's no mention of special mechanisms to support large bulk data; so I took the standard AndroidBeamDemo app and simply added a large byte array to the packet size, in the hope that it would all Just Work. It seems not to --- sending a 10kB message takes about five seconds, and trying to send a 1MB message just doesn't do anything at all (although it tells me the message was sent successfully).
For Samsung's S-Beam, I simply cannot find any documentation whatsoever.
Has anybody made this work, and if so, can they point me at an example?
For Android Beam, you need to provide URIs to the files with the data using setBeamPushUris() (or setBeamPushUrisCallback() if the data is not fixed).
For S-Beam, I am not aware of any API that can be used. AFAICT, S-Beam only works with the built-in apps for pictures, video and music.

Sending large data packet to server

Having a design discussion with some co-workers about our app. Looking for the best way to transfer large data files on a, say, weekly basis from a phone to a remote server. Server will
be in the DMZ and phone will either be in WiFi mode or GSM. Some of the files will be 100Mb can even get up to 400Mb. Just not sure of the best way to approach this in my Android code. I was looking at
MTOM or even just pure FTP. Any advice would be appreciated.
I have investiagated about the use of MTOM under Android but I found nothing. I don't know whether there's any implementation working with Android yet.
But this is something you can do by FTP, which would be a good choice I think. And you could check the integrity of the file using a checksum (calculated on both sides and then compared).
Using 3G for huge files is likely to take long and to be expensive, so to me the best is to use WiFi. You can detect whether your device is connected thru WiFi as described here.

Categories

Resources