mondain / red5

Automatically exported from code.google.com/p/red5
3 stars 8 forks source link

Unable to pass custom object using StreamingProxy class #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We have two red5 applications (Live and Proxy) and try to establish 
communication between them. Each app has custom class Publisher.

What steps will reproduce the problem?
1. Proxy streams of Live app to Proxy app with StreamingProxy:
    public void streamBroadcastStart(IBroadcastStream stream)
    {
        <...>
        IBroadcastScope bsScope = getBroadcastScope(publishedName);
        if (bsScope != null) {
            StreamingProxy proxy = new StreamingProxy();
            bsScope.subscribe(proxy, null);
            proxy.setApp(PROXY_APP_NAME);
            proxy.setHost(PROXY_ADDRESS);
            proxy.setPort(PROXY_PORT);
            proxy.init();
            proxy.start(publishedName,
                        StreamingProxy.LIVE,
                        new Object[]{PROXY_ID, new Publisher(nick, streamName)});
            proxies.put(publishedName, proxy);
        }
        <...>
    }
2. Try to get the Publisher object in appConnect method of Proxy:
    public boolean appConnect(IConnection conn, Object[] params)
    {
        <...>

        if (params.length > 1) {
            Publisher p = (Publisher)params[1];
            <...>
        }

        return super.appConnect(conn, params);
    }

What is the expected output? What do you see instead?

Expected: normal cast of objects.

Instead: ERROR o.red5.server.net.rtmp.RTMPHandler - Error connecting {}
java.lang.ClassCastException: com.vda.transport.Publisher cannot be cast to 
com.vda.transport.Publisher
        at com.vda.proxy.controllers.ProxyApplication.appConnect(ProxyApplication.java:107) ~[na:na]
        at org.red5.server.adapter.MultiThreadedApplicationAdapter.connect(MultiThreadedApplicationAdapter.java:332) ~[red5.jar:na]
        at org.red5.server.Scope.connect(Scope.java:335) ~[red5.jar:na]
        at org.red5.server.BaseConnection.connect(BaseConnection.java:336) ~[red5.jar:na]
        at org.red5.server.net.rtmp.RTMPConnection.connect(RTMPConnection.java:261) ~[red5.jar:na]
        at org.red5.server.net.rtmp.RTMPMinaConnection.connect(RTMPMinaConnection.java:121) ~[red5.jar:na]
        at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:280) ~[red5.jar:na]
        at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:134) [red5.jar:na]
        at org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived(RTMPMinaIoHandler.java:206) [red5.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796) [mina-core-2.0.3.jar:na]
        at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427) [mina-core-2.0.3.jar:na]
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796) [mina-core-2.0.3.jar:na]
        at org.red5.server.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:125) [red5.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:715) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68) [mina-core-2.0.3.jar:na]
        at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141) [mina-core-2.0.3.jar:na]
        at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.3.jar:na]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_24]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_24]
        at java.lang.Thread.run(Thread.java:680) [na:1.6.0_24]

What version of the product are you using? On what operating system?

Mac OS X 10.6.7
Red5 Server 1.0.0 RC1 $Rev: 4219

Please provide any additional information below.

1. Publisher has default constructor and setters/getters for each field.

2. On the contrary, when app Proxy connects to Live with RTMPClient and then 
invokes method from Live, everything is ok: Publisher object of Live app casts 
to Publisher object of Proxy app.

public void resultReceived(IPendingServiceCall call)
{
    Object result = call.getResult();
    if (result instanceof Map) {
        String code = (String)((Map<String, Object>)result).get("code");
        if (StatusCodes.NC_CONNECT_SUCCESS.equals(code)) {
            client.invoke("listLiveArchive", new Object[] {50}, this);
        }
    } else if ("listLiveArchive".equals(call.getServiceMethodName())) {
        if (result instanceof List) {
            archive = new ArrayList<Publisher>((List<Publisher>)result);
        }
    }
}

Original issue reported on code.google.com by m.e.plat...@gmail.com on 5 May 2011 at 9:00

GoogleCodeExporter commented 9 years ago
Sorry for off topic. See there 
http://livertmpjavapublisher.blogspot.com/2011/06/release-10.html

Original comment by vadym.vi...@gmail.com on 20 Jun 2011 at 3:23

GoogleCodeExporter commented 9 years ago
Copy the jar or class files that represent your Publisher into the common 
library directory (ex. c:\red5\lib); by doing this your applications will be 
able to accept instances of the Publisher as being the same and thus you should 
see no further errors related to this.

Original comment by mondain on 27 Jul 2011 at 9:37