Hi, everybody.

I'm have to set up some sort of virtual (net) TV and I have an audio
problem.

When I create  some live channels (RTMP streams) with Red5, after a while
the sound quality degrades considerably. Hissing and noise, and.. so on. It
may impove for while and degrade again later.

I'l paste bellow the code of a Red5 Application which shows what I'm doing.


---8<-------------8<-------------8<-------------8<-------------8<-------------8<-------------8<----------

package see.red5.audiobug;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.api.stream.support.SimplePlayItem;
import org.red5.server.api.stream.support.StreamUtils;
import org.springframework.core.io.Resource;

public class AudioBug extends ApplicationAdapter {

    @Override
    public boolean appStart( IScope app ) {
        _Log.info( "Let's go for noise and fury.." );

        createAndStartStreams( );

        return super.appStart( app );
    }

    @Override
    public boolean appConnect( IConnection connection, Object[] params ) {
        _Log.info( "welcome " + connection.getClient( ).getId( ) );
        return super.appConnect( connection, params );
    }

    private void createAndStartStreams( ) {
        getListOfResources( );

        streams = new IServerStream[ COUNT ];
        for( int i = 0; i < COUNT; i++ ) {
            streams[ i ] = StreamUtils.createServerStream( getScope( ),
CHANNEL + i );
            for( SimplePlayItem item : _list ) {
                streams[ i ].addItem( item );
            }
            streams[ i ].setRandom( true );
            streams[ i ].nextItem( );
            streams[ i ].start( );
        }
    }

    private void getListOfResources( ) {
        _list = new ArrayList<SimplePlayItem>( );
        try {
            Resource[] resources = getScope( ).getResources( RESOURSES );
            if( resources != null ) {
                for( Resource resource : resources ) {
                    String filename = resource.getFile( ).getName( );
                    _Log.info( "getting " + filename );

                    SimplePlayItem item = new SimplePlayItem( );
                    item.setName( filename );
                    _list.add( item );
                }
            }
        }
        catch( IOException e ) {
            _Log.error( e );
        }
    }

    // internal stuff
    private final static int COUNT = 3;
    private final static String CHANNEL = "live";
    private static final String RESOURSES = "streams/*.flv";

    private final static Log _Log = LogFactory.getLog( AudioBug.class );

    private List<SimplePlayItem> _list;
    private IServerStream[] streams;

}

---8<-------------8<-------------8<-------------8<-------------8<-------------8<-------------8<----------
_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to