Stream audio to several client

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1376 Views - Last Post: 05 March 2013 - 08:15 AM Rate Topic: -----

#16 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Stream audio to several client

Posted 05 March 2013 - 07:22 AM

View Postpepsy11, on 05 March 2013 - 08:53 AM, said:

View Postpepsy11, on 05 March 2013 - 06:00 AM, said:

View PostSkydiver, on 05 March 2013 - 05:51 AM, said:

For your first question, you can write either run multiple threads or write chunks out asynchronously. I would recommend writing out chunks asynchronously.


Ahh.. Thanks.. I'll look into that..


How would i be able to do this when all the sockets should get the same data? A socket should be able to be created and connected mid-play in a song, and then just hear from that point of the song?


So send the same data to all clients for a given time frame. As long as the data that gets sent out lets clients get enough context and start playing back there shouldn't be any issues. I could be mistaken, but I believe that the MP3 data stream format (and most other modern streaming data formats) let clients receive data midstream. I think that the issue will be if your clients can handle data sent that way, or if they assume they are downloading a complete .MP3 file instead of an MP3 encoded data.
Was This Post Helpful? 0
  • +
  • -

#17 pepsy11  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 11-October 10

Re: Stream audio to several client

Posted 05 March 2013 - 07:49 AM

View PostSkydiver, on 05 March 2013 - 07:16 AM, said:

View Postpepsy11, on 05 March 2013 - 08:00 AM, said:

Well.. I am writing, or my team, is writing a ASP.NET site which should be able to play the bytes which it receives

Play it for whom? An ASP.NET web server can be just a box sitting on a rack somewhere with no video or audio. Who would be listening to it? If two or more people upload at the same time, what would be played back?

I think what you are trying to say is that the web site can share data uploaded to it to other clients.


Play it for the client with the loaded website..
We are developing a website where you can choose a channel and listen to the music playing on that? That is the plan anyway..


View PostSkydiver, on 05 March 2013 - 07:22 AM, said:

View Postpepsy11, on 05 March 2013 - 08:53 AM, said:

View Postpepsy11, on 05 March 2013 - 06:00 AM, said:

View PostSkydiver, on 05 March 2013 - 05:51 AM, said:

For your first question, you can write either run multiple threads or write chunks out asynchronously. I would recommend writing out chunks asynchronously.


Ahh.. Thanks.. I'll look into that..


How would i be able to do this when all the sockets should get the same data? A socket should be able to be created and connected mid-play in a song, and then just hear from that point of the song?


So send the same data to all clients for a given time frame. As long as the data that gets sent out lets clients get enough context and start playing back there shouldn't be any issues. I could be mistaken, but I believe that the MP3 data stream format (and most other modern streaming data formats) let clients receive data midstream. I think that the issue will be if your clients can handle data sent that way, or if they assume they are downloading a complete .MP3 file instead of an MP3 encoded data.


We would write the client so that it knew it would get MP3 encoded data, given we can find a way to use the data in the website.. Mot post on google regarding that are some years old now..
And yeah, they let clients start playing midstream.. My question is regarding how to implement it on the server..
Right now we are going for an individual byte-array for each output/channel, and then we will start beginsend() method on the sockets and give them the buffer for the channel they belong to. And while doing that, there will be a thread checking if a buffer is running dry(the song is almost done), and then start filling the buffer with the bytes for the next song
Was This Post Helpful? 0
  • +
  • -

#18 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Stream audio to several client

Posted 05 March 2013 - 08:04 AM

View Postpepsy11, on 05 March 2013 - 09:49 AM, said:

View PostSkydiver, on 05 March 2013 - 07:16 AM, said:

View Postpepsy11, on 05 March 2013 - 08:00 AM, said:

Well.. I am writing, or my team, is writing a ASP.NET site which should be able to play the bytes which it receives

Play it for whom? An ASP.NET web server can be just a box sitting on a rack somewhere with no video or audio. Who would be listening to it? If two or more people upload at the same time, what would be played back?

I think what you are trying to say is that the web site can share data uploaded to it to other clients.


Play it for the client with the loaded website..
We are developing a website where you can choose a channel and listen to the music playing on that? That is the plan anyway..

In general, you still can't play it for the client. Even if you are doing the MP3 decoding on the server and just sending down the raw frequencies in real time to the client (which would be become prohibitive in terms of bandwidth, and be affected very badly by network latency), it is still the client that needs to render the sound to the client machine's speakers. All you can do is serve up the data for clients to play. You can throttle this down to a single note if you wanted to and make it look like you are playing the data for the client, but ultimately, it is still the client that is playing the sound, not the server.
Was This Post Helpful? 1
  • +
  • -

#19 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Stream audio to several client

Posted 05 March 2013 - 08:15 AM

View Postpepsy11, on 05 March 2013 - 09:49 AM, said:

My question is regarding how to implement it on the server..
Right now we are going for an individual byte-array for each output/channel, and then we will start beginsend() method on the sockets and give them the buffer for the channel they belong to. And while doing that, there will be a thread checking if a buffer is running dry(the song is almost done), and then start filling the buffer with the bytes for the next song


Why do you even need another thread to monitor if the buffer is running dry? You are supposed to call EndSend() to match your BeginSend() call, and EndSend() will block. When in unblocks, you can send the next song data, or set an event that cues the next song should be started.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2