pali / hsphfpd-prototype

Prototype of Bluetooth HSP/HFP daemon
135 stars 16 forks source link

Establish audio connection from a custom AudioAgent #4

Closed smikesmike closed 4 years ago

smikesmike commented 4 years ago

Hi, I'am trying to integrate your daemon into a java application. I've already registered my own app and audio agent on the DBus and registered it at hsphfpd. This means when I call my phone I get a method request to AudioAgent::NewConnection. But here I am stucking as I have no idea how to establish the audio connection. My first idea was, that the given file descriptor is pointing to an audio socket but it doesn't look like an audio protocol. Could you please provide a hint how I could acquire an input and output audio stream from audio agent? BR Marc

pali commented 4 years ago

My first idea was, that the given file descriptor is pointing to an audio socket but it doesn't look like an audio protocol.

It is SCO bluetooth socket. If you have registered audio agent with PCM_s16le_8kHz codec, then data on this socket are really PCM, signed 16bit little endian, sampled at 8000 Hz. You just need to know what SCO socket is synchronous of SOCK_SEQPACKET type, you need write data synchronously (e.g. if you read packet of N bytes, you need to write packet of N bytes too). Therefore you have to always transmit data and you have to always also receive data. You cannot do just one direction. You can look for inspiration at audio_client.pl example client.

smikesmike commented 4 years ago

Ah, great. Now I was able to read and write some bytes;) Thank you very much