StreamingProxy examples

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

StreamingProxy examples

Juan Diego
But this last example is outdated, and I am having problems with both examples in the part that says
stream.addStreamListener(this);
or
stream.removeStreamListener(this);

I get that the those methods are not applicable for the arguments the type IBroadcastStream.

Is there a better example?

Thanks

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: StreamingProxy examples

Juan Diego
So I forgot to implement IStreamListener,

Anyways I am having some problems, this is my function to restream a selected stream localy.

public void publishVideo(String streamName) {
        log.info("Publicar Video: " + streamName);
        IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
        IScope scope = stream.getScope();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        //streamer = new StreamingProxy();
       
        streamer.setHost("localhost");
        streamer.setApp("ramona");
        streamer.setPort(1935);
        streamer.init();
       
        bsScope.subscribe(streamer, null);
       
        streamer.start("publicado", PublishModes.LIVE, null);
        streamingProxyMap.put(stream.getPublishedName(), streamer);
       
        stream.addStreamListener(this);
       
        log.info("Publicar Videos");
    }

When ever I execute this function I get this error on my red5 server


[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
Exception in thread "pool-9-thread-1" java.lang.IncompatibleClassChangeError: Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
        at org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.<init>(RTMPClientProtocolDecoder.java:15)
        at org.red5.client.net.rtmp.codec.RTMPMinaCodecFactory.<init>(RTMPMinaCodecFactory.java:73)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.completeConnection(RTMPEIoFilter.java:222)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:184)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:947)
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:535)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:703)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:659)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:648)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1120)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


I dont know what I am doing wrong.

Thanks


On Sat, Nov 26, 2016 at 4:00 PM, Juan Diego <[hidden email]> wrote:
But this last example is outdated, and I am having problems with both examples in the part that says
stream.addStreamListener(this);
or
stream.removeStreamListener(this);

I get that the those methods are not applicable for the arguments the type IBroadcastStream.

Is there a better example?

Thanks

--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: StreamingProxy examples

Juan Diego
Ok so looking at the libraries I realize that was using 1.0.7 version and I downloaded the latest release or Red5 1.0.8, I downloaded red5 1.0.7 and I get no error.  But my restreaming is not working

I want to be able to select a stream and "publish" that stream as an output called "publicado"

I am calling the method publishVideo to restream but maybe I am not doing it right, because I dont see any new connection to my app.

This is my whole Application class,

package ec.com.mapachedev.ramona;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.red5.client.PublishModes;
import org.red5.proxy.StreamingProxy;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
import org.red5.server.api.scope.IBasicScope;
import org.red5.server.api.scope.IBroadcastScope;
import org.red5.server.api.scope.IScope;
import org.red5.server.api.scope.ScopeType;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.api.stream.IStreamListener;
import org.red5.server.api.stream.IStreamPacket;
import org.red5.server.net.rtmp.event.IRTMPEvent;
import org.red5.server.stream.ClientBroadcastStream;
import org.red5.server.stream.message.RTMPMessage;

public class Application extends ApplicationAdapter implements IStreamListener {

    private IScope appScope;

    private IServerStream serverStream;
   
    private Map<String, StreamingProxy> streamingProxyMap = new HashMap<String, StreamingProxy>();
   
    int limiter = 1024;
   
    StreamingProxy streamer= new StreamingProxy();


    /** {@inheritDoc} */
    @Override
    public boolean appStart(IScope app) {
        super.appStart(app);
        log.info("ramona appStart");
        System.out.println("ramona appStart");
        appScope = app;
        return true;
    }

    /** {@inheritDoc} */
    @Override
    public boolean appConnect(IConnection conn, Object[] params) {
        log.info("ramona appConnect");
        IScope appScope = conn.getScope();
        log.debug("App connect called for scope: {}", appScope.getName());
        // getting client parameters
        Map<String, Object> properties = conn.getConnectParams();
        if (log.isDebugEnabled()) {
            for (Map.Entry<String, Object> e : properties.entrySet()) {
                log.debug("Connection property: {} = {}", e.getKey(), e.getValue());
            }
        }

        return super.appConnect(conn, params);
    }

    /*
     * para grabar al publicar (non-Javadoc)
     *
     * @see org.red5.server.adapter.MultiThreadedApplicationAdapter#
     * streamPublishStart(org.red5.server.api.stream.IBroadcastStream)
     */

    public void holaMundo(){
        System.out.println("Hola mundo");
        log.info("Hola Mundo");
    }
    /*
    @Override
    public void streamPublishStart(IBroadcastStream stream) {
        try {

            String fecha = new SimpleDateFormat("yyyyMMdd-hhmmss").format(new Date());
            stream.saveAs(stream.getPublishedName() + "-" + fecha, false);
            log.info("Empezamos a grabar");
            // //super.streamPublishStart(stream);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

    public void streamBroadcastStart(IBroadcastStream stream) {
        IConnection connection = Red5.getConnectionLocal();
        if (connection != null && stream != null) {
            System.out.println("Broadcast started for: " + stream.getPublishedName());
            connection.setAttribute("streamStart", System.currentTimeMillis());
            connection.setAttribute("streamName", stream.getPublishedName());
        }

    }

    /**
     *
     * @param streamName
     */
    public void startRecordingStream(String streamName) {
        log.info("Start Recording " + streamName);
        try {
            String date = new SimpleDateFormat("yyyyMMdd-hhmmss").format(new Date());
            IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
            String fileNameStream = stream.getPublishedName() + "-" + date;
            stream.saveAs(fileNameStream, false);
            log.info("Empezamos a grabar "+fileNameStream);
            // super.streamPublishStart(stream);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * TODO arregla para cerrar records
     */
    public void stopRecordingStream(String streamName) {
        log.info("Stop Recording " + streamName);
        // IConnection conn = Red5.getConnectionLocal();
        ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(appScope, streamName);
        // Stop recording.
        stream.stopRecording();
        stream.stop();
    }

    /**
     *
     * @return
     */
    public List<String> getLiveStreams() {
        log.info("Get Lista de Streams");
        // List<String>streams = getListStreams();

        Iterator<IClient> iter = scope.getClients().iterator();
        List<String> streams = new ArrayList<String>();

        THE_OUTER: while (iter.hasNext()) {

            IClient client = iter.next();
            Iterator<IConnection> cset = client.getConnections().iterator();

            THE_INNER: while (cset.hasNext()) {
                IConnection c = cset.next();
                if (c.hasAttribute("streamName")) {
                    if (!c.isConnected()) {
                        try {
                            c.close();
                            client.disconnect();
                        } catch (Exception e) {
                            // Failure to close/disconnect.
                        }
                        continue THE_OUTER;
                    }

                    if (streams.contains(c.getAttribute("streamName").toString())) {
                        continue THE_INNER;
                    }

                    streams.add(c.getAttribute("streamName").toString());
                }
            }
        }
//        log.info("Tam Lista de Streams " + streams.size());
        return streams;

    }
   
   

    public void publishVideo(String streamName) {
        log.info("Publicar Video: " + streamName);
        IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
        IScope scope = stream.getScope();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        //streamer = new StreamingProxy();
       
        streamer.setHost("localhost");
        streamer.setApp("ramona");
        streamer.setPort(1935);
        streamer.init();
       
        bsScope.subscribe(streamer, null);
       
        streamer.start("publicado", PublishModes.LIVE, null);
        streamingProxyMap.put(stream.getPublishedName(), streamer);
       
        stream.addStreamListener(this);
       
        log.info("Publicar Videos");
    }
   
    synchronized public void streamBroadcastClose(IBroadcastStream stream) {
        StreamingProxy proxy =
                streamingProxyMap.get(stream.getPublishedName());
        if (proxy != null) {
                proxy.stop();
                IScope scope = stream.getScope();
                IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
                if (bsScope != null) {
                    bsScope.unsubscribe(proxy);
            }
        }
    }
   
    public void packetReceived(IBroadcastStream stream, IStreamPacket packet)
    {
        RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet,packet.getTimestamp());
        try {
            streamer.pushMessage(null, m);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } 
    /*
    public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
        RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet, packet.getTimestamp());
        try {

            limiter--;
            if (limiter > 1) {
                streamer.pushMessage(null, m);
            } else {
                if (streamer != null) {
                    stream.removeStreamListener(this);
                    streamer.stop();
                    streamer = null;
                }
            }

        } catch (IOException e) {

            e.printStackTrace();
        }
    }*/
   
    public IBroadcastScope getBroadcastScope(IScope scope, String name) {
        IBasicScope basicScope = scope.getBasicScope(ScopeType.BROADCAST ,  name);
        if (!(basicScope instanceof IBroadcastScope)) {
            return null;
        } else {
            return (IBroadcastScope) basicScope;
        }
    }

    public void unPublishVideo(String stream) {
        log.info("desPublicar Videos");
    }

    public void publishToFaceBook(String stream) {
        log.info("Publicar Videos a FB");
    }

    public void unpublishFaceBook(String stream) {
        log.info("DesPublicar Videos a FB");
    }

    /** {@inheritDoc} */
    @Override
    public void appDisconnect(IConnection conn) {
        log.info("ramona appDisconnect");
        if (appScope == conn.getScope() && serverStream != null) {
            serverStream.close();
        }
        super.appDisconnect(conn);
    }
}


On Sun, Nov 27, 2016 at 6:14 PM, Juan Diego <[hidden email]> wrote:
So I forgot to implement IStreamListener,

Anyways I am having some problems, this is my function to restream a selected stream localy.

public void publishVideo(String streamName) {
        log.info("Publicar Video: " + streamName);
        IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
        IScope scope = stream.getScope();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        //streamer = new StreamingProxy();
       
        streamer.setHost("localhost");
        streamer.setApp("ramona");
        streamer.setPort(1935);
        streamer.init();
       
        bsScope.subscribe(streamer, null);
       
        streamer.start("publicado", PublishModes.LIVE, null);
        streamingProxyMap.put(stream.getPublishedName(), streamer);
       
        stream.addStreamListener(this);
       
        log.info("Publicar Videos");
    }

When ever I execute this function I get this error on my red5 server


[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
Exception in thread "pool-9-thread-1" java.lang.IncompatibleClassChangeError: Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
        at org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.<init>(RTMPClientProtocolDecoder.java:15)
        at org.red5.client.net.rtmp.codec.RTMPMinaCodecFactory.<init>(RTMPMinaCodecFactory.java:73)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.completeConnection(RTMPEIoFilter.java:222)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:184)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:947)
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:535)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:703)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:659)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:648)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1120)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


I dont know what I am doing wrong.

Thanks


On Sat, Nov 26, 2016 at 4:00 PM, Juan Diego <[hidden email]> wrote:
But this last example is outdated, and I am having problems with both examples in the part that says
stream.addStreamListener(this);
or
stream.removeStreamListener(this);

I get that the those methods are not applicable for the arguments the type IBroadcastStream.

Is there a better example?

Thanks


--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: StreamingProxy examples

Juan Diego
Ok so I am getting this on the logs

[INFO] [RTMPConnectionExecutor-2] ec.com.mapachedev.ramona.Application - Publicar Video: red5StreamDemo
[INFO] [RTMPConnectionExecutor-2] org.red5.client.net.rtmp.BaseRTMPClientHandler - rtmp://localhost:1935/ramona
[INFO] [RTMPConnectionExecutor-2] ec.com.mapachedev.ramona.Application - Publicar Videos
[INFO] [NioProcessor-1] ec.com.mapachedev.ramona.Application - W3C x-category:session x-event:disconnect c-ip:127.0.0.1 c-client-id:13
[INFO] [NioProcessor-1] ec.com.mapachedev.ramona.Application - ramona appDisconnect
[INFO] [NioProcessor-2] ec.com.mapachedev.ramona.Application - W3C x-category:session x-event:disconnect c-ip:127.0.0.1 c-client-id:14
[INFO] [NioProcessor-2] ec.com.mapachedev.ramona.Application - ramona appDisconnect

So it seems it is connecting and disconnecting


On Sun, Nov 27, 2016 at 6:44 PM, Juan Diego <[hidden email]> wrote:
Ok so looking at the libraries I realize that was using 1.0.7 version and I downloaded the latest release or Red5 1.0.8, I downloaded red5 1.0.7 and I get no error.  But my restreaming is not working

I want to be able to select a stream and "publish" that stream as an output called "publicado"

I am calling the method publishVideo to restream but maybe I am not doing it right, because I dont see any new connection to my app.

This is my whole Application class,

package ec.com.mapachedev.ramona;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.red5.client.PublishModes;
import org.red5.proxy.StreamingProxy;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IClient;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
import org.red5.server.api.scope.IBasicScope;
import org.red5.server.api.scope.IBroadcastScope;
import org.red5.server.api.scope.IScope;
import org.red5.server.api.scope.ScopeType;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.api.stream.IStreamListener;
import org.red5.server.api.stream.IStreamPacket;
import org.red5.server.net.rtmp.event.IRTMPEvent;
import org.red5.server.stream.ClientBroadcastStream;
import org.red5.server.stream.message.RTMPMessage;

public class Application extends ApplicationAdapter implements IStreamListener {

    private IScope appScope;

    private IServerStream serverStream;
   
    private Map<String, StreamingProxy> streamingProxyMap = new HashMap<String, StreamingProxy>();
   
    int limiter = 1024;
   
    StreamingProxy streamer= new StreamingProxy();


    /** {@inheritDoc} */
    @Override
    public boolean appStart(IScope app) {
        super.appStart(app);
        log.info("ramona appStart");
        System.out.println("ramona appStart");
        appScope = app;
        return true;
    }

    /** {@inheritDoc} */
    @Override
    public boolean appConnect(IConnection conn, Object[] params) {
        log.info("ramona appConnect");
        IScope appScope = conn.getScope();
        log.debug("App connect called for scope: {}", appScope.getName());
        // getting client parameters
        Map<String, Object> properties = conn.getConnectParams();
        if (log.isDebugEnabled()) {
            for (Map.Entry<String, Object> e : properties.entrySet()) {
                log.debug("Connection property: {} = {}", e.getKey(), e.getValue());
            }
        }

        return super.appConnect(conn, params);
    }

    /*
     * para grabar al publicar (non-Javadoc)
     *
     * @see org.red5.server.adapter.MultiThreadedApplicationAdapter#
     * streamPublishStart(org.red5.server.api.stream.IBroadcastStream)
     */

    public void holaMundo(){
        System.out.println("Hola mundo");
        log.info("Hola Mundo");
    }
    /*
    @Override
    public void streamPublishStart(IBroadcastStream stream) {
        try {

            String fecha = new SimpleDateFormat("yyyyMMdd-hhmmss").format(new Date());
            stream.saveAs(stream.getPublishedName() + "-" + fecha, false);
            log.info("Empezamos a grabar");
            // //super.streamPublishStart(stream);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

    public void streamBroadcastStart(IBroadcastStream stream) {
        IConnection connection = Red5.getConnectionLocal();
        if (connection != null && stream != null) {
            System.out.println("Broadcast started for: " + stream.getPublishedName());
            connection.setAttribute("streamStart", System.currentTimeMillis());
            connection.setAttribute("streamName", stream.getPublishedName());
        }

    }

    /**
     *
     * @param streamName
     */
    public void startRecordingStream(String streamName) {
        log.info("Start Recording " + streamName);
        try {
            String date = new SimpleDateFormat("yyyyMMdd-hhmmss").format(new Date());
            IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
            String fileNameStream = stream.getPublishedName() + "-" + date;
            stream.saveAs(fileNameStream, false);
            log.info("Empezamos a grabar "+fileNameStream);
            // super.streamPublishStart(stream);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * TODO arregla para cerrar records
     */
    public void stopRecordingStream(String streamName) {
        log.info("Stop Recording " + streamName);
        // IConnection conn = Red5.getConnectionLocal();
        ClientBroadcastStream stream = (ClientBroadcastStream) getBroadcastStream(appScope, streamName);
        // Stop recording.
        stream.stopRecording();
        stream.stop();
    }

    /**
     *
     * @return
     */
    public List<String> getLiveStreams() {
        log.info("Get Lista de Streams");
        // List<String>streams = getListStreams();

        Iterator<IClient> iter = scope.getClients().iterator();
        List<String> streams = new ArrayList<String>();

        THE_OUTER: while (iter.hasNext()) {

            IClient client = iter.next();
            Iterator<IConnection> cset = client.getConnections().iterator();

            THE_INNER: while (cset.hasNext()) {
                IConnection c = cset.next();
                if (c.hasAttribute("streamName")) {
                    if (!c.isConnected()) {
                        try {
                            c.close();
                            client.disconnect();
                        } catch (Exception e) {
                            // Failure to close/disconnect.
                        }
                        continue THE_OUTER;
                    }

                    if (streams.contains(c.getAttribute("streamName").toString())) {
                        continue THE_INNER;
                    }

                    streams.add(c.getAttribute("streamName").toString());
                }
            }
        }
//        log.info("Tam Lista de Streams " + streams.size());
        return streams;

    }
   
   

    public void publishVideo(String streamName) {
        log.info("Publicar Video: " + streamName);
        IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
        IScope scope = stream.getScope();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        //streamer = new StreamingProxy();
       
        streamer.setHost("localhost");
        streamer.setApp("ramona");
        streamer.setPort(1935);
        streamer.init();
       
        bsScope.subscribe(streamer, null);
       
        streamer.start("publicado", PublishModes.LIVE, null);
        streamingProxyMap.put(stream.getPublishedName(), streamer);
       
        stream.addStreamListener(this);
       
        log.info("Publicar Videos");
    }
   
    synchronized public void streamBroadcastClose(IBroadcastStream stream) {
        StreamingProxy proxy =
                streamingProxyMap.get(stream.getPublishedName());
        if (proxy != null) {
                proxy.stop();
                IScope scope = stream.getScope();
                IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
                if (bsScope != null) {
                    bsScope.unsubscribe(proxy);
            }
        }
    }
   
    public void packetReceived(IBroadcastStream stream, IStreamPacket packet)
    {
        RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet,packet.getTimestamp());
        try {
            streamer.pushMessage(null, m);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } 
    /*
    public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
        RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet, packet.getTimestamp());
        try {

            limiter--;
            if (limiter > 1) {
                streamer.pushMessage(null, m);
            } else {
                if (streamer != null) {
                    stream.removeStreamListener(this);
                    streamer.stop();
                    streamer = null;
                }
            }

        } catch (IOException e) {

            e.printStackTrace();
        }
    }*/
   
    public IBroadcastScope getBroadcastScope(IScope scope, String name) {
        IBasicScope basicScope = scope.getBasicScope(ScopeType.BROADCAST ,  name);
        if (!(basicScope instanceof IBroadcastScope)) {
            return null;
        } else {
            return (IBroadcastScope) basicScope;
        }
    }

    public void unPublishVideo(String stream) {
        log.info("desPublicar Videos");
    }

    public void publishToFaceBook(String stream) {
        log.info("Publicar Videos a FB");
    }

    public void unpublishFaceBook(String stream) {
        log.info("DesPublicar Videos a FB");
    }

    /** {@inheritDoc} */
    @Override
    public void appDisconnect(IConnection conn) {
        log.info("ramona appDisconnect");
        if (appScope == conn.getScope() && serverStream != null) {
            serverStream.close();
        }
        super.appDisconnect(conn);
    }
}


On Sun, Nov 27, 2016 at 6:14 PM, Juan Diego <[hidden email]> wrote:
So I forgot to implement IStreamListener,

Anyways I am having some problems, this is my function to restream a selected stream localy.

public void publishVideo(String streamName) {
        log.info("Publicar Video: " + streamName);
        IBroadcastStream stream = this.getBroadcastStream(appScope, streamName);
        IScope scope = stream.getScope();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        //streamer = new StreamingProxy();
       
        streamer.setHost("localhost");
        streamer.setApp("ramona");
        streamer.setPort(1935);
        streamer.init();
       
        bsScope.subscribe(streamer, null);
       
        streamer.start("publicado", PublishModes.LIVE, null);
        streamingProxyMap.put(stream.getPublishedName(), streamer);
       
        stream.addStreamListener(this);
       
        log.info("Publicar Videos");
    }

When ever I execute this function I get this error on my red5 server


[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
[WARN] [NioProcessor-33] org.red5.client.net.rtmp.RTMPMinaIoHandler - Exception caught Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
Exception in thread "pool-9-thread-1" java.lang.IncompatibleClassChangeError: Expected non-static field org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.log
        at org.red5.client.net.rtmp.codec.RTMPClientProtocolDecoder.<init>(RTMPClientProtocolDecoder.java:15)
        at org.red5.client.net.rtmp.codec.RTMPMinaCodecFactory.<init>(RTMPMinaCodecFactory.java:73)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.completeConnection(RTMPEIoFilter.java:222)
        at org.red5.client.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:184)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:947)
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:535)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:703)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:659)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:648)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1120)
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


I dont know what I am doing wrong.

Thanks


On Sat, Nov 26, 2016 at 4:00 PM, Juan Diego <[hidden email]> wrote:
But this last example is outdated, and I am having problems with both examples in the part that says
stream.addStreamListener(this);
or
stream.removeStreamListener(this);

I get that the those methods are not applicable for the arguments the type IBroadcastStream.

Is there a better example?

Thanks



--

---
You received this message because you are subscribed to the Google Groups "red5" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.