![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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. Last edited by Sane; Feb 7th, 2008 at 7:25 PM. |
|
|
|
|
|
#3 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
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:
|
|
|
|
|
|
#5 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
Re: Streaming Audio over network
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 |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
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. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
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.
|
|
|
|
|
|
#8 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
Re: Streaming Audio over network
Yes, The program does use UDP.
|
|
|
|
|
|
#9 |
|
Hobbyist Programmer
|
Re: Streaming Audio over network
@brent, Sorry then. Other the other hand, Great Job.
|
|
|
|
|
|
#10 |
|
Highly Adaptive Penguin
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4
![]() |
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.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Network Simulator design | renato | Software Design and Algorithms | 2 | Dec 11th, 2007 10:54 PM |
| An Audio and Video class for ruby | Master | Ruby | 3 | Mar 24th, 2006 5:49 AM |
| Streaming audio songs? | java_roshan | Coder's Corner Lounge | 1 | Oct 27th, 2005 1:35 PM |
| Code Request - Onboard Audio | Meecher | Other Programming Languages | 7 | Sep 20th, 2005 1:53 AM |
| Checking source codes of image, audio and video files | on_auc | C++ | 3 | Feb 21st, 2005 8:36 PM |