Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiple sources with different bitrates

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Thu Jan 04, 2007 2:22 pm    Post subject: Multiple sources with different bitrates Reply with quote

Hi,
I've created a multithreaded "source-server" that sends to different mounts on the Icecast server. Everything work ok if all sources sends with the same bitrate. If the sources sends at different bitrates the listening clients "overhear" other "channels" (mounts). What is wrong? Can't I do like this?

Regards Toni
Back to top
Anonymous
Guest





PostPosted: Fri Jan 05, 2007 11:15 am    Post subject: Update Reply with quote

Update: seems to be the same problem when sending with same bitrate but the problem is less frequent.
Back to top
Anonymous
Guest





PostPosted: Fri Jan 05, 2007 2:33 pm    Post subject: Update again! Reply with quote

I can get rid of the problem if I move the streamsource from different threads to different processes. Is there a threadsafety issue in libshout?

ANYBODY! if you know anything of this please share it!
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jan 05, 2007 2:48 pm    Post subject: Reply with quote

libshout does not do mixing. The only thing you have to do is use a shout_t for each stream. Anything else must be occurring before libshout gets hold of it.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Fri Jan 05, 2007 11:18 pm    Post subject: Que? Reply with quote

Every thread hold it's own shout_t var, what do u mean?
Back to top
Anonymous
Guest





PostPosted: Fri Jan 05, 2007 11:35 pm    Post subject: More info Reply with quote

while( !m_StopRequest )
{
if( f )
{
read = fread( buff, 1, sizeof(buff), f );
total = total + read;
}

if (read > 0)
{
s.send(buff, read);
s.sync();

if( f && newsong )
{
newsong = false;
if( http )
server.updateSong( m_User, m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
else
{
md.add( "song", m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
s.set_metadata( &md );
}
}
}
else
{
f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();
//s.set_audio_info( SHOUT_AI_BITRATE, CzzString::Format( "%d", m_PlayListHandler->getPlayList(m_User)->getBitRate() ).c_str() );
newsong = true;
}
}
Back to top
Anonymous
Guest





PostPosted: Fri Jan 05, 2007 11:38 pm    Post subject: More info Reply with quote

Extract of the code looks like this:
If in a thread = not OK, in it's own process = OK,.


f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();

while( !m_StopRequest )
{
if( f )
read = fread( buff, 1, sizeof(buff), f );

if (read > 0)
{
s.send(buff, read);
s.sync();

if( f && newsong )
{
newsong = false;
if( http )
server.updateSong( m_User, m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
else
{
md.add( "song", m_PlayListHandler->getPlayList(m_User)->nowPlaying().c_str() );
s.set_metadata( &md );
}
}
}
else
{
f = m_PlayListHandler->getPlayList(m_User)->getNextStreamHandle();
newsong = true;
}
}
Back to top
Anonymous
Guest





PostPosted: Sat Jan 06, 2007 1:44 pm    Post subject: Reply with quote

To explain the problem by saying that I get "overhearing" between the channels was not a good way of putting it. The sound isn't mixed it's "chopped", for a split second you hear a different channel (mount) than the one you have choosen and in the next split second you hear the one choosen again. But like I said the problem only occurs when I stream in separate threads, if the code is moved to separate processes the problem disappear.

Toni
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sat Jan 06, 2007 3:39 pm    Post subject: Reply with quote

we know per shout_t seperation works because apps like ices 0.4 and ices 2 work within the same process, in the latter case, with threads as well.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Sat Jan 06, 2007 4:01 pm    Post subject: Reply with quote

Is there anything other than setting up the connection to the icecast server and make calls to shout_send and shout_sync that you have to do when you stream in a thread?

Toni
Back to top
Anonymous
Guest





PostPosted: Sun Jan 07, 2007 3:22 pm    Post subject: Reply with quote

I've studied the source code for both ices-0.4 and ices-2. ice 0.4 is not threaded. Ices-2 doesn't use shout_send and shout_sync, it uses shout_send_raw and has it's own timing implementation. libshout shout_send and shout_sync doen't seem to work properly in a threaded environment. I had to leave my threaded solution for the "heavier" process solution Sad

Toni
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Jan 07, 2007 3:42 pm    Post subject: Reply with quote

What is your reasoning for shout_sync not being thread safe?, after all it doesn't deal with any stream data, it only sleeps for a duration. shout_send_raw is called by shout_send, the latter does timing checks for the shout_sync to work on.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anonymous
Guest





PostPosted: Tue Jan 09, 2007 7:43 am    Post subject: Reply with quote

Finally found the solution Very Happy. Came back to work and tested my multithreaded solution and couldn't repeat the problems. So after comparing my environments at home and in the office a found that I was using VS6SP3 at home and VS6SP6 at work. After installing VS6SP6 the problem goes away!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber