RTMP audio/video client

272 views
Skip to first unread message

solomax

unread,
Apr 15, 2013, 8:39:17 AM4/15/13
to red5in...@googlegroups.com
Hello Paul,

The colleague of mine Artem Horuzhenko currently implementing video support for red5sip [0]
On certain circumstances (red5sip sends and receives both audio and H264 video) Red5 (r4393) crashes while decoding video packets:

org.red5.server.net.protocol.ProtocolException: Header is null, check for error
at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodePacket(RTMPProtocolDecoder.java:321) ~[red5.jar:na]
at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtocolDecoder.java:183) ~[red5.jar:na]
at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeBuffer(RTMPProtocolDecoder.java:118) ~[red5.jar:na]
at org.red5.server.net.rtmp.codec.RTMPMinaProtocolDecoder.decode(RTMPMinaProtocolDecoder.java:57) [red5.jar:na]
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:241) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796) [red5.jar:na]
at org.red5.server.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:124) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796) [red5.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) [red5.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426) [red5.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:697) [red5.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:651) [red5.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:640) [red5.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:67) [red5.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1111) [red5.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [red5.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_09]

After several such Exception server starts to get OutOfMemoryException(s).
Red5 (r4604) seems to disconnect client

While debugging Artyom found video packet is not fully read since chunkSize on server is less than on client (at least while packet was encoded).
BaseRTMPClientHandler.onChunkSize() contains the following line:

log.info("ChunkSize is not fully implemented: {}", chunkSize);

Maybe you can take a look at the code [1] and give us a hint how this can be fixed?
Maybe we are using client API somehow wrong?

I would really appreciate your help
Thanks in advance

PS red5 r4604 compatible version can be found here: [2] and it also doesn't work :(


akhor666

unread,
Apr 17, 2013, 1:39:02 AM4/17/13
to red5in...@googlegroups.com
Server is falling when flash client sets chunkSize to 257. I overrided onChunkSize() method:

@Override
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
log.debug("onChunkSize");
// set read and write chunk sizes
RTMP state = conn.getState();
state.setReadChunkSize(chunkSize.getSize());
        // state.setWriteChunkSize(chunkSize.getSize());
log.info("ChunkSize is not fully implemented: {}", chunkSize);
}

and all works fine.

Mondain

unread,
Apr 17, 2013, 11:00:17 AM4/17/13
to red5in...@googlegroups.com
Thanks for finding that, I'll add it right away.

Paul


--
 
---
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 red5interest...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
http://gregoire.org/
http://code.google.com/p/red5/

solomax

unread,
Apr 18, 2013, 9:58:16 AM4/18/13
to red5in...@googlegroups.com
Hello Paul,

was it addressed in r4616?

Mondain

unread,
Apr 18, 2013, 10:18:10 AM4/18/13
to red5in...@googlegroups.com
Yes and it was tested with xsplit client (since it had issues with chunk handling as well).

Paul

solomax

unread,
May 6, 2013, 2:54:45 AM5/6/13
to red5in...@googlegroups.com
Unfortunately with you patch (red5 r4638)

we still got 
[WARN] [NioProcessor-8] org.red5.server.net.rtmp.RTMPMinaIoHandler - Exception caught on session: 7
org.apache.mina.core.write.WriteToClosedSessionException: null

With the patch proposed by Atryom (akhor666) everything works as expected
Reply all
Reply to author
Forward
0 new messages