10-08-2009 06:54 AM
10-08-2009 06:54 AM
10-09-2009 05:17 PM
WOOOW, I just managed to record and play simultaneously!!! and also to get that recording asincronously (as it records), a lot of obscure details are needed in order to make the aplication work, however, quality is not the best yet.
If anyone wants to do it:
-Start two threads (at the same time!!!, for some reason it doesn't behave well if they're started too distant from each other), one for playing and one for recording, ah those threads will be the launchers for the players, and for some reason, they must be active, I just implemented a while(...) {... Thread.sleep ...} cycle, to keep them running while the session goes on.
-Never, eever try to stop any player, they become unstable, the idea is to keep allways runing and don't even have to manage players events, implement a class that loops the information input, you need to implement an InputStream, an OutputStream and a Datasource (optional, but adviced to).
-After both players start, you can access the information at the OutputStream, if you desire with another thread, that can write the recording to wherever you want, oh, commit isn't needed (actually, commit will cause you problems), don't commit until you finish the whole session.
That was tested on the 8320 and 8900, on the simulator doesn't work well, it records with plenty of noise.
I hope this helps another people to make tests, however, It doesn't means that a VoIP app can be made with this trick, because it stills very unstable, but, if you wanna try, take these hints.
Have fun!.
10-09-2009 08:11 PM - edited 10-09-2009 08:12 PM
Can you post the code? Like to see it in action.
P.S. Stoping the player causing it to become unstable is nonstarter for a real world application.
10-09-2009 11:45 PM
10-14-2009 10:41 AM
lol, mystery solved, I was able to do such by using different formats, wav to play and pcm to record, however, when using pcm for both streams it stops working, the code is not the great thing, you can do it yourself by following any media manual from BB, however, it seems there is some restriction in using pcm, I wonder why?, lol, just watch this thread: recording and playing pcm / pcm
Have fun!
10-14-2009 10:50 AM
10-14-2009 03:02 PM - edited 10-14-2009 03:04 PM
The cost of converting from PCM to Wave is very little.
Can you post the test code? The current project is demanding all of my time.
10-15-2009 10:44 AM
Hi Guys, as you may know, actually WAV is not a format, but a wrapper, and the most common format under the hood is PCM, so I tried wrapping the PCM I was using to test (16bit 8khz) into a WAV, and guess what?, it works, plays that WAV and records PCM, it seems it is not a hardware limitation then, why the BB can't support recording and playing in PCM directly?, you make a guess... lol.
So now there's three options, for those brave who want to use a BB for VoIP :
1) Cheat the player, making a WAV dynamically with the PCM you have for reading, the header must say it is an "infinite" WAV (actually there's a top of 6hs), and then make fixed size chunks of PCM with the data of the PCM, ah of course implementing a DataSource class that reads periodically and feeds the audio must be done (because you can't let the player goes ahead of the chunks of WAV you created). I don't like this option because WAV is not a good format for streaming, and maybe after doing all that work it would not be usable anyways.
2) Using AMR for recoding and playing (that works very good, I've tested) :
2.0) Adapting your whole platform to use AMR, by having a proxy RTP server that transcodes it to whatever you're using for your VoIP net. Of course you will need an AMR license, just look at the pricing... it is not a home solution, but if you have enough budget in your company it could be done, hmm, maybe that's what agito guys did?, and that's why they have the proxy..., I don't know.
2.1) Transcode the AMR just inside the phone, and sending ulaw over the net, that would be free
, but, I haven't found a library for decoding or encoding AMR in Java
, I've searched but everything I've found was in C or C++, so that solution will imply making a transcoding library for JavaME, which means months of work for a solution that maybe will not be efficient enough to be used (because the complexity of the algorithm, the Java VM, and the real time needs).
So, I don't know if I will go on this project, due to the limitations, if you have any questions, you can ask me, but I can't post my code right now, I have bosses
.
Have fun!.
PS: I'm finishing my University career, I'm hearing work offers
, in private.
10-19-2009 11:05 AM - edited 10-19-2009 11:07 AM
Guess what?, I did it,
, a bit unstable now... but is a working sip softphone
.
How I did it?, the wav trick I've mentioned earlier...
Is the most tricky development I've been into, I hope the hints help the people to save time and energy , it is a real pain developing only by try and error.
Any questions?
Have fun!