2011-12-23 8 views
3

マイクのライブストリーミングにred5とflexの組み合わせを使用しています。シナリオは、Webクライアントのマイクストリームをサーバーに送信し、サーバー側でストリームを再生しています。同様に、逆の処理、すなわちサーバからクライアントへのマイクストリームの送信と、クライアント側でのストリームの再生とを行う。red5:サーバーサイドのライブストリーミングはどうすればできますか?

私は、スタックオーバーフローの上に類似したクエリを掲載しているリンクは以下の通りです:

red5: how can i send microphone stream?

私は、クライアント側のコードを持っていると私はそれはまた別のブログで利用可能だと思います。しかし、私の問題は、どのように私はred5サーバー側でコードを記述することです。私は自分のマシンにred5サーバーをインストールし、red5 APIも読み込んでいます。しかしそこから、サーバー側でライブストリームにどのように取り組んでいるかははっきりしない。

私もred5サンプルコードを作成しました。

Application.java

public class Application extends ApplicationAdapter { 

    @Override 
    public boolean appConnect(IConnection arg0, Object[] arg1) { 
     out.println("appConnect"); 
     return super.appConnect(arg0, arg1); 
    } 

    @Override 
    public void appDisconnect(IConnection arg0) { 
     out.println("appConnect"); 
     super.appDisconnect(arg0); 
    } 

} 

StreamManager.java

public class StreamManager { 

    private static final Log log = LogFactory.getLog(StreamManager.class); 
    private Application app; 

    /** 
    * Start recording the publishing stream for the specified IConnection. 
    * 
    * @param conn 
    */ 

    private ClientBroadcastStream stream; 

    public void recordShow(IConnection conn) { 
     try { 
      log.debug("Recording show for: " + conn.getScope().getContextPath()); 
      String streamName = String.valueOf(System.currentTimeMillis()); 
      log.debug("Stream Name : " + streamName); 
      // Get a reference to the current broadcast stream. 
      stream = (ClientBroadcastStream) app.getBroadcastStream(conn.getScope(), "hostStream"); 
      // Save the stream to disk. 
      stream.saveAs(streamName, false); 

     } catch (Exception e) { 
      log.error(e.getMessage(), e); 
     } 
    } 

    public void setApplication(Application app) { 
     this.app = app; 
    } 

} 

samplescope-のcontext.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:lang="http://www.springframework.org/schema/lang" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
          http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"> 
     <bean id="samplescope.context" class="org.red5.server.Context" autowire="byType" /> 
      <bean id="samplescope.scope" class="org.red5.server.WebScope" 
       init-method="register"> 
         <property name="server" ref="red5.server" /> 
         <property name="parent" ref="global.scope" /> 
         <property name="context" ref="samplescope.context" /> 
         <property name="handler" ref="samplescope.handler" /> 
         <property name="contextPath" value="/samplescope" /> 
         <property name="virtualHosts" 
          value="*,localhost, localhost:5080, 127.0.0.1:5080" />     
      </bean> 
    <bean id="samplescope.handler" class="my.first.Application" /> 
    <bean id="streamManager.service" class="my.first.StreamManager"> 
     <property name="application" ref="samplescope.handler"/> 
    </bean> 
</beans> 

上記のコードは、サーバー側のFLVファイルにストリームを保存していますが、サーバーにストリームを保存する代わりに、生データストリームを取得してストリームを簡単にエンコードすることができます。同様に、サーバ上でストリームを送信する前に、ストリームをデコードします。 red5でどうすればいいですか?

答えて

2

「デコードされた」メディアバイトにアクセスする場合は、Red5がメディアをデコードしないため、Xugglerのようなものを使用する必要があります。 Red5の「コーデック」クラスは、単にエンコードされたデータを格納し、必要な場所に送信します。

関連する問題