Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 8
Registered: ‎05-21-2010
My Device: Blackberry bold
My Carrier: swisscom

how to capture voice and stream it live?

Hey,

 

I am trying to stream audio packets captured by the blackberry microphone to my server.

 

To do so, I am using a player and a record control with a ByteArrayOutputStream but instead of recording the stream in a file, I am reading the buffer continuously and send the packets over the network. It works fine but I get a 500ms delay at the receiver side.

 

The problem is that the recordControl only write chunks of 1024 byte at once (which is about 600ms of voice), and thus streaming of the voice is delayed by half a second.

 

DO you know if I can have the recordControl write smaller chunks? Is there another library that I can use which does not have that defect?

 

THanks for your help.

 

 

 

 

Developer
Posts: 102
Registered: ‎07-15-2008
My Device: Not Specified

Re: how to capture voice and stream it live?

I don't really have an answer for you, but I do have a question.

 

How (on the server end) are you translating packets and streaming them...I always wondered how this was done.

 

Also what format are you streaming AMR ?

 

Thanks.

New Contributor
Posts: 8
Registered: ‎05-21-2010
My Device: Blackberry bold
My Carrier: swisscom

Re: how to capture voice and stream it live?

I am sending datagram from bb which consists of AMR packets with a proprietary header. On the server side, I have an open UDP socket and I am parsing the packets and then decoding them with AMR codec.

 

Does it answer your question?

 

 

Developer
Posts: 86
Registered: ‎01-09-2009
My Device: Not Specified

Re: how to capture voice and stream it live?

Try the following method in RecordControl class

public int setRecordSizeLimit(int size)
throws MediaException
Set the record size limit. This limits the size of the recorded media to the number of bytes specified.

When recording is in progress, commit will be called implicitly in the following cases:

  • Record size limit is reached
  • If the requested size is less than the already recorded size
  • No more space is available.

Once a record size limit has been set, it will remain so for future recordings until it is changed by anothersetRecordSizeLimit call.

 

Because of the underline reason, I would recommend to save the original limit somewhere, and save it.  So you can revert it back to original limit after you are done.

 

Let me know if it works out.

New Contributor
Posts: 8
Registered: ‎05-21-2010
My Device: Blackberry bold
My Carrier: swisscom

Re: how to capture voice and stream it live?

I left this problem aside for a moment but I tried again today and I can confirm that in my implementation it does not work.

 

I can set the size to let's say 384 and I do get that number into my buffer instead of the usual 1024. However, I can not continue streaming afterwards. The recorder stops and I can not restart it even if I restart the entire player. I got the event "Device Unavailable".

 

Did anyone else manage to stream using a recordControl?