Pessoal,

Estou fazendo a transmissão de um vídeo usando como red5.

Então, tenho a minha aplicação em flex rodando em um tomcat6 e uso a
aplicação oflaDemo que já vem com o Red5 conectar minha tarnsmissão.

Conectar:
private function init():void
            {
                if(bConectar.label == "Conectado")
                {
                    bConectar.label = "Conectar ao servidor";
                    statusImage.source = "off.png";
                } else {
                        if(nc != null)
                    nc = null;
                nc = new NetConnection();
                nc.addEventListener( NetStatusEvent.NET_STATUS,
netStatus );
                nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
onSecurityError);
                                trace("Connecting to Red5...");
                nc.connect("rtmp://localhost/oflaDemo/test");
                // Este aplicxativo contém os métodos chamados pelo
servidor
                nc.client = this;
                usuario.editable = true;
                }
            }

Transmitir:
private function controlador():void
            {
                if(controller.source == "play.png"){
                         controller.source = "stop.png";
                    nsPub = new NetStream (nc);
                    nsPub.addEventListener(NetStatusEvent.NET_STATUS,
netStatus);
                        nsPub.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
onAsyncError);
                    var camera:Camera = Camera.getCamera();
                        camera.setMode(320, 240, 15, false);
                                        camera.setQuality(0, 80);
                                        camera.setKeyFrameInterval(15);
                        nsPub.attachCamera(camera);
                        var microphone:Microphone = Microphone.getMicrophone
();
                    nsPub.attachAudio(microphone);
                    // nome que será publicado
                    nsPub.publish("hostStream", "live");
                } else {
                        controller.source = "play.png";
                        nsPub.close()
                    nsPub = null
                }
            }

Para fazer a gravação estou tentando fazer o que mostrar estes link:
http://sziebert.net/posts/server-side-stream-recording-with-red5/
http://sziebert.net/posts/server-side-stream-recording-updated/

Então adicionei essas classes no projeto oflaDemo:

public class ApplicationX extends ApplicationAdapter {

        protected static Logger log = LoggerFactory.getLogger
(DemoService.class);

        /* ----- ApplicationAdapter delegate methods ----- */

        /**
         * Delegate method used to accept/reject incoming connection
requests.
         *
         * @param conn
         * @param params
         * @return true/false
         */
        @Override
        public boolean roomConnect(IConnection conn, Object[] params) {
                log.debug("New connection attempt from {}...", 
conn.getRemoteAddress
());
                System.out.println("New connection attempt from {}..."+
conn.getRemoteAddress());
                // Insure that the listeners are properly attached.
                return super.roomConnect(conn, params);
        }

        /**
         * Delegate method which logs connection/client/user disconnections.
         *
         * @param conn
         */
        @Override
        public void roomDisconnect(IConnection conn) {
                log.debug("Connection closed by {}...", 
conn.getRemoteAddress());
                System.out.println("Connection closed by {}..."+
conn.getRemoteAddress());
                // Call the super class to insure that all listeners are 
properly
dismissed.
                super.roomDisconnect(conn);
        }

        /* ----- Application utility methods ----- */
}

public class StreamManager {

        protected static Logger log = LoggerFactory.getLogger
(DemoService.class);

        // Application components
        private ApplicationX app;

        /**
         * Start recording the publishing stream for the specified
         * <code>IConnection</code>.
         *
         * @param conn
         */
        public void recordShow(IConnection conn) {
                log.debug("Recording show for: {}", 
conn.getScope().getContextPath
());
                System.out.println("Recording show for: {}"+ conn.getScope
().getContextPath());
                String streamName = String.valueOf(System.currentTimeMillis());
                // Get a reference to the current broadcast stream.
                ClientBroadcastStream stream = (ClientBroadcastStream)
app.getBroadcastStream(conn.getScope(), "hostStream");
                try {
                        // Save the stream to disk.
                        stream.saveAs(streamName, false);
                } catch (Exception e) {
                        //logger.error("Error while saving stream: {}", 
streamName);
                        System.out.println("Error while saving stream: {}"+ 
streamName);
                }
        }

        /**
         * Stops recording the publishing stream for the specified
         * <code>IConnection</code>.
         *
         * @param conn
         */
        public void stopRecordingShow(IConnection conn) {
                log.debug("Recording show for: {}", 
conn.getScope().getContextPath
());
                System.out.println("Stop recording show for: {}"+ conn.getScope
().getContextPath());
                // Get a reference to the current broadcast stream.
                ClientBroadcastStream stream = (ClientBroadcastStream)
app.getBroadcastStream(conn.getScope(), "hostStream");
                // Stop recording.
                stream.stopRecording();
        }

        /* ----- Spring injected dependencies ----- */

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

E editei o arquivo red5-web.xml adicionando:
<bean id="streamManager.service"
class="org.red5.server.webapp.oflaDemo.StreamManager">
        <property name="applicationX" ref="web.handlerX"/>
    </bean>

    <bean id="web.handlerX"
class="org.red5.server.webapp.oflaDemo.ApplicationX"/>

Agora no Flex criei uma função para tentar gravar:

private function onClick():void {
                        // Record the stream by triggering a server event.
                                if (record.label == "Record") {
                                        // Tell the remote server to start 
recording.
                                        nc.call("streamManager.recordShow", 
null);
                                        // Re-label the button.
                                        record.label = "Stop";
                                // Stop recording the stream.
                                } else if (record.label == "Stop") {
                                        // Tell the remote server to stop 
recording.
                                        
nc.call("streamManager.stopRecordingShow", null);
                                        // Re-label the button.
                                        record.label = "Record";
                                }
                        }

Mas nada acontece, gostaria de saber se alguém pode me ajudar. O Erko
me ajudou a entender algumas coisas, mas ainda não consegui fazer isso
funcionar.

Aguardo a ajuda de vocês.
Obrigado,
Vinicius.

--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
Para sair da lista, envie um email em branco para 
flexdev-unsubscr...@googlegroups.com
Mais opções estão disponíveis em http://groups.google.com/group/flexdev
-~----------~----~----~----~------~----~------~--~---

Responder a