2

Today I see a lot of people who are interested in looking for solutions of video streaming over bluetooth using mobile devices, but I haven't found any convenient opinion which describes what should be done to implement such functionality.

On one hand I have rather abstract information that for successful video streaming both devices should conform Video Distribution Profile (VDP) which is one from the amount of bluetooth profiles.

On the other hand I know that neither iOS nor Android provide an API for working with VDP.

There is WiFi Camera app in App Store which allows to stream video over bluetooth from one ios device to another, so I wonder how does this functionality implemented and is there any way to do the same using Android and iOS APIs?

teoREtik
  • 7,886
  • 15
  • 46
  • 65

1 Answers1

7

VPD lies in the lower protocol of Bluetooth called L2CAP, which is kinda like UDP (in the terms that it is conectionless and thus faster), and uses SDP records to broadcast the information about the services on the device. L2CAP/SDP is accessible on Android via BlueZ stack. All the VDP, A2DP and other services live at this level. I've done video streaming from Android phone to Windows via L2CAP encoded in VP8 so that is possible, but there are limitations depending on the manufacturer - e.g., HTC at least in 2.1 didn't allow access to the bluetooth daemon, all BlueZ calls failed with access restriction errors, while the same code worked fine on Motorola and Sony Ericsson. Regarding iOS, as far as I've looked into it, they do not allow direct interaction with L2CAP, i guess that is due to the fact that OS may want to publish it's own services at the L2CAP level, and if 3rd party software starts adding too much records there, they might start to conflict. So your best shot for iOS is RFCOMM protocol which is higher in the stack and is similar to TCP. Basically it is somewhat a serial connection between 2 nodes, no service entries or whatever, so you will need to create your own protocol. If there is any other knowledge to share, I can help, i can also provide some speed benchmarks from my thesis on this topic.

Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
  • Thanks for your respond. Wonderful job you did. Let me guess, did you use NDK to communicate with L2CAP part of BlueZ stack for immediate interaction? And also as I understand correctly, Apple doesn't provide a framework for interacting with RFCOMM, so it should be done in some other way? – teoREtik Nov 01 '12 at 08:15
  • 1
    Yes, on Android I did all the coding via NDK. I don't wan't to mislead you, I actually don't remember if iOS had direct API's for RFCOMM or not, but you can take a look at BTstack project (http://code.google.com/p/btstack/), it claims to have support for iOS. – Rudolfs Bundulis Nov 01 '12 at 08:23
  • hey How did you use the L2CAP to send and receive data on Windows? Did you have to write a profile driver? – thunderbird Feb 05 '15 at 09:02
  • 1
    @thunderbird yes, wdk has a sample for this actually, I don't remember the name by heart but you should be able to find it – Rudolfs Bundulis Feb 05 '15 at 09:06
  • @RudolfsBundulis did you encounter any endianness problem? I am think I am receiving the data sent from android to Windows in big endian format. – thunderbird Feb 10 '15 at 11:15
  • @thunderbird not sure at the moment, I need to dig up my old code then, but I think that as long as you use `htons` and friends properly this should not be an issue. – Rudolfs Bundulis Feb 10 '15 at 22:15
  • @RudolfsBundulis did you experience any initial lag when streaming video over BT. I am getting a lag of around 500ms- 1s. I am using RFCOMM instead of VDP as the BlueZ stack was removed from android and the current BT stack does not support VDP. – thunderbird Mar 03 '15 at 09:28
  • @thunderbird nope, I don't remember anything like that, definitely not something that noticeable, might be because RFCOMM is used instead of L2CAP. So you are saying now there is now way to use L2CAP on Android? – Rudolfs Bundulis Mar 03 '15 at 10:59
  • @RudolfsBundulis Its probably because of RFCOMM . I am simply encoding the camera data in jpeg format and streaming it over RFCOMM . There is about 300 ms - 500 ms initial delay though the streaming is quite smooth at 640 x 480 resolution except for that delay. Regarding L2CAP on android > 4.2 , i am not really sure but there is probably no easy solution to use vdp. However, A2DP support is included at App level. – thunderbird Mar 03 '15 at 11:41
  • @RudolfsBundulis Hey what kind of codec did you use to decode the h264 stream you send from your andorid device. I can play the streamed data on vlc(after saving it to a file) but cant seem to decode and display it in my app. – thunderbird Mar 12 '15 at 11:17
  • @thunderbird I used VP8 and decoding was done through the DirectShow filters from Google – Rudolfs Bundulis Mar 12 '15 at 12:51
  • Any sample for VDP Bluetooth profile implementation – Vineesh TP Dec 13 '16 at 06:10
  • @VineeshTP sadly I think I've deleted it. – Rudolfs Bundulis Dec 13 '16 at 10:31