![]() |
Streaming Audio over network
I am in the process of building a simple Voice Chat application in C++ with WINAPI. Im now in the process of formulating a method of streaming the the audio data. I have searched google but haven't found a whole lot, and was wondering if anyone knows of a good way to approach this or knows of any articles that could help me out. I am using an Open Watcom compiler on Windows XP. Thanks in advance for any help.
Brent |
Re: Streaming Audio over network
As far as I understand, streaming audio is a matter of how the client decides to handle the socket stream. The audio information, as it's being sent through, is already being streamed. But whether or not the client decides to save the chunks into memory and then play it, as opposed to playing it as it comes in (streaming it), is strictly up to what the client does with the socket stream.
This is why different applications, ranging from VLC to Windows Media Player, all stream media a little differently (sometimes less effectively). The audio is sent in discrete packets by default, and so the streaming is left completely up to how the application decides to handle these packets. This may be why you've been having a difficult time finding information on it. What this means for you, is you have to make your client efficiently insert each packet into a queue, and constantly playback the audio from the queue. This gets tricky, so someone might be able to recommend some prexisting libraries, or coding tips, to help you with this task. Have you at least been able to send an audio file, or a chunk of information, over? That would be a good start. |
Re: Streaming Audio over network
Thank you for the quick response Sane, it was very helpful. And yes, the program sends and receives audio data fine, but there is an annoying gap between each audio chunk. I am currently in the process of programming a queue class, when I have finished it and implemented it in my program, I will post some code.
|
Re: Streaming Audio over network
And while I'm still here, if you have constant playback from a queue, but still get gaps in the audio, it could mean a number of things:
|
Re: Streaming Audio over network
1 Attachment(s)
I have created a quick solution. Took about 5 minutes, heh. And I am experiencing very choppy playback. Im going to look into your solutions. And by the way, thanks a bunch for your help, I really appreciate it.
The source code is attached. Brent |
Re: Streaming Audio over network
No problem. And for clarification, I meant "until its length exceeds a defined threshold". In other words, only start the playback when your queue gets to a certain size. After it starts playing, withold from asserting the threshold. Then don't enforce the size restriciton again until your queue runs out (it may eventually run out if there's lag, disconnection, or simply a slow connection).
I'll let someone strong in C++ take over and point out what could be inefficient about your implementation. It's all very finicky stuff that you will need to play around with, and test strenuously, to get just right. |
Re: Streaming Audio over network
I didn't look at your code, but I'd suggest using UDP rather than TCP, as UDP does not wait on confirmation of successful packet and just sends and sends.
|
Re: Streaming Audio over network
Yes, The program does use UDP.
|
Re: Streaming Audio over network
@brent, Sorry then. Other the other hand, Great Job.
|
Re: Streaming Audio over network
Heh, it's alright. The program isn't all that great at this point. The streaming is an utter disaster, but its coming along.
|
| All times are GMT -5. The time now is 3:54 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC