Giter Club home page Giter Club logo

red5-server-common's Introduction

red5-server-common

Old source moved to legacy branch; project source moved to server repo

red5-server-common's People

Contributors

andy--s avatar jjaaddiicc avatar marcus-nl avatar maritelle avatar mondain avatar nateroe avatar octavn avatar pyvesb avatar ritzalam avatar solomax avatar tiagojacobs avatar vbence avatar yinzara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

red5-server-common's Issues

Incorrect usage of ScheduledExecutorService in org.red5.server.stream.consumer.FileConsumer

Hello,
Creation 'scheduledExecutorService' is on line 180:

scheduledExecutorService = Executors.newScheduledThreadPool(schedulerThreadSize, new CustomizableThreadFactory("FileConsumerExecutor-"));

There is no shutdown for this service.
Solution: make FileConsumer extends AutoCloseable and shutdown service in close method.

Also whole architecture of this FileConsumer isn't right, there should be some solution for Java IO Streaming to save data, not only to file.

Ping Request not sent with Full header

I had noticed that whilst receiving data from a sample Red5 server, the ping request event from the server had been sent with the header type as continuation. This meant that it contained no data-type/timestamp or body length.

I am not sure if this is the case with all versions but is the ping request is supposed to be sent with full header type instead?

Thanks ๐Ÿ˜ƒ

Fix for RTMPProtocolDecoder failure when media chunks cross RTMPT requests

The bug can be reproduced as follows:

  1. Connect to Red5 using RTMPT or RTMPS:
var nc:NetConnection = new NetConnection();
nc.connect('rtmpt://example.com:5080/application');
  1. After the connection is made, start recording video using a buffer:
var ns:NetStream = new NetStream(nc);
ns.bufferTime(60);
ns.attachCamera(camera);
ns.attachAudio(mic);
ns.publish('streamid', 'record');
  1. Record until there are few seconds of buffer (it helps to slow down your upload speed with tc or similar), then stop and wait for the buffer to drain as follows:
// disconnect sources to allow buffer to drain
ns.attachCamera(null);
ns.attachAudio(null);
// wait for the buffer to be empty and close the stream
setInterval(function():void {
  if (! (ns.bufferLength > 0.0)) {
    ns.close();
  }
}, 500);
  1. Note that Red5 does not close and finalize the stream until the connection closes.

After examining trace output, I understand the mechanism like this:

When the connection begins draining in step 3, it's no longer bound by real-time constraints, so chunks are sent as fast as possible. There seems to be a size limit of 8192 bytes per request, and the Flash client will fill this completely if it can. Since this is not an even multiple of common chunk sizes (e.g. 258 bytes), partial chunks appear at the ends of requests.

In the main loop of RTMPProtocolDecoder.decodeBuffer, an instance of RTMPDecodeState is used to track state. This state persists across calls, and the only place it's cleared is here:

if (state.canStartDecoding(remaining)) {
  log.trace("Can start decoding");
  state.startDecoding();
} else {
  log.trace("Cannot start decoding");
  break;
}

Now, suppose a large buffer is decoded and goes into the buffered state on its final chunk. After the final chunk has been processed, the state is left in RTMPDecodeState.DECODER_BUFFER for the next chunk, since we exit the loop and state.startDecoding() is not called again. If the next buffer is sufficiently large, there's no problem, but suppose we get a small buffer containing the closeStream command, which is what happens in the reproduction method above. The state.canStartDecoding test fails, and we wind up waiting until more data comes in, which it won't since recording is finished, so the closeStream call is never parsed.

I can't claim to understand this state machine well enough to suggest a perfect fix, but I've made a patch that seems to work by calling state.startDecoding() before entering the decode loop, like so:

// get the local decode state
RTMPDecodeState state = conn.getDecoderState();
state.startDecoding(); // <= add this line to initialize the state
log.trace("RTMP decode state {}", state);

This does seem to fix the issue without causing other problems. Since the unparsed portion of the previous buffer should be available at this point, I think the only consequence will be to re-read the chunk header at the start of the buffer, and only on the first pass through the loop. However, I haven't tested extensively enough to rule out unintended side effects, which is why I'm filing this as an issue rather than a fork and pull request.

Maven build issue (jaudiotagger)

I remember seeing a similar report in one of the subprojects, but could not find it now. Since this is the package I,m trying to build I will post my workaround here.

Compiling will fail because maven can not find the following dependency:

jaudiotagger-2.0.4-SNAPSHOT.pom

After googleing for it and finding a repository (grails.org's) I added it to the project's POM:

        <repository>
            <id>grails</id>
            <name>Grails</name>
            <url>http://repo.grails.org/grails/repo/</url>
        </repository> 

Again, this is a workaround if you want to compile the project, until the good people at Red5 fix the dependency issue.

StreamService.receiveAudio/Video calls before StreamService.publish finshed

Hello, I have updated to Red5 Version 1.0.8. and I have now the follwing Porblem.

In my client (Flash App) I call this:
ns_publish = new NetStream(nc);
...
cam = Camera.getCamera();
ns_publish.attachCamera(cam);
ns_publish.publish(myUrl, "record");

In very rare cases, the method streamRecordStart is not called on the server side.
My investigation has shown that in this situations the method org.red5.server.stream.StreamService.receiveVideo / receiveAudio is called before the call to the org.red5.server.stream.StreamService.publish method is completed.
At this time the initiation is not completed and the method streamRecordStart is not called.
Here some Infos from log:

2016-12-31 17:05:59,347 [RTMPConnectionExecutor-4] TRACE o.r.server.net.rtmp.BaseRTMPHandler - messageReceived connection: DVO5MCVH0OFMM
2016-12-31 17:05:59,347 [RTMPConnectionExecutor-4] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Message received - header: Header [streamId=1, channelId=8, dataType=20, timerBase=4934, timerDelta=0, size=39, extendedTimestamp=0]
2016-12-31 17:05:59,347 [RTMPConnectionExecutor-4] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Header / message data type: 20

start org.red5.server.stream.StreamService.publish with Thread RTMPConnectionExecutor-4

2016-12-31 17:05:59,347 [RTMPConnectionExecutor-4] DEBUG o.red5.server.stream.StreamService - publish called with name rec_id2 and mode record
2016-12-31 17:05:59,365 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - setPublishedName: rec_id2
2016-12-31 17:05:59,367 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Provider connect
2016-12-31 17:05:59,368 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Provider: org.red5.server.messaging.InMemoryPushPushPipe
2016-12-31 17:05:59,368 [RTMPConnectionExecutor-4] INFO org.red5.server.scope.BasicScope - ClientBroadcastStream already exists: org.red5.server.stream.ClientBroadcastStream@7ef40385 new: org.red5.server.stream.ClientBroadcastStream@7ef40385
2016-12-31 17:05:59,368 [RTMPConnectionExecutor-4] DEBUG o.red5.server.stream.StreamService - Mode: record
2016-12-31 17:05:59,368 [RTMPConnectionExecutor-4] INFO o.r.s.stream.ClientBroadcastStream - Stream start: rec_id2
2016-12-31 17:05:59,368 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Provider connect
2016-12-31 17:05:59,369 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - SaveAs - name: rec_id2 append: false
2016-12-31 17:05:59,370 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Created: org.red5.server.stream.RecordingListener@216713f0
2016-12-31 17:05:59,373 [RTMPConnectionExecutor-4] DEBUG o.r.server.stream.RecordingListener - Recording file: .....\streams\room\rec_id2.flv

start org.red5.server.stream.StreamService.receiveVideo with Thread RTMPConnectionExecutor-2 and
org.red5.server.stream.StreamService.publish is running

2016-12-31 17:05:59,373 [RTMPConnectionExecutor-2] TRACE o.r.server.net.rtmp.BaseRTMPHandler - messageReceived connection: DVO5MCVH0OFMM
2016-12-31 17:05:59,373 [RTMPConnectionExecutor-2] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Message received - header: Header [streamId=1, channelId=7, dataType=9, timerBase=354, timerDelta=0, size=7327, extendedTimestamp=0]
2016-12-31 17:05:59,373 [RTMPConnectionExecutor-2] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Header / message data type: 9

org.red5.server.stream.StreamService.publish is running
2016-12-31 17:05:59,374 [RTMPConnectionExecutor-4] DEBUG o.r.server.stream.RecordingListener - Context contains a file consumer

start org.red5.server.stream.StreamService.receiveAudio with Thread RTMPConnectionExecutor-1 and
org.red5.server.stream.StreamService.publish is running

2016-12-31 17:05:59,385 [RTMPConnectionExecutor-1] TRACE o.r.server.net.rtmp.BaseRTMPHandler - messageReceived connection: DVO5MCVH0OFMM
2016-12-31 17:05:59,386 [RTMPConnectionExecutor-1] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Message received - header: Header [streamId=1, channelId=5, dataType=8, timerBase=4974, timerDelta=0, size=65, extendedTimestamp=0]
2016-12-31 17:05:59,386 [RTMPConnectionExecutor-1] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Header / message data type: 8

org.red5.server.stream.StreamService.publish is running
2016-12-31 17:05:59,392 [RTMPConnectionExecutor-4] DEBUG o.r.server.stream.RecordingListener - File name: rec_id2.flv
2016-12-31 17:05:59,392 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Codec info: org.red5.codec.StreamCodecInfo@1a71c2f8
2016-12-31 17:05:59,392 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Video codec: org.red5.codec.SorensonVideo@73a5e4c
2016-12-31 17:05:59,392 [NioProcessor-4] TRACE o.r.server.net.rtmp.BaseRTMPHandler - Message sent
2016-12-31 17:05:59,392 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - Audio codec: null
2016-12-31 17:05:59,392 [RTMPConnectionExecutor-4] DEBUG o.r.s.stream.ClientBroadcastStream - No decoder configuration available, audioCodec is null.

org.red5.server.stream.StreamService.publish completed.

2016-12-31 17:05:59,418 [RTMPConnectionExecutor-3] TRACE o.r.server.net.rtmp.BaseRTMPHandler - messageReceived connection: DVO5MCVH0OFMM

Audio Only Stream - ClassCastException (AudioData -> VideoData) in RTMPProtocolEncoder

I was streaming audio through red5 and occasionaly getting ClassCastException in RTMPProtocolEncoder in line 316 when it was trying to drop frames of video which didn't exist.

I added if( message instanceof VideoData) in line 316, and it solved the problem. But maybe you want to look into the process of dropping frames if the stream is only audio.

            if (isDroppable) {

                if(message instanceof VideoData) {

                    VideoData video = (VideoData) message;

Red 5 is realy great! Thank you all for doing so good job :)

Best Regards,
Marta Kalamar

Problem with checking bandwidth

I ma trying to run checkBandwidthUp on my Red5 server. I've tried running on Java 1.7 and 1.8. I've tried running Red5 in versions 1.0.7 and 1.0.8.

In both I am hitting the same problem. Might be something that I am doing wrong, but I am not sure what else could be wrong if not code. Basically when I am calling NetConnection I am not passing any parameters, but it says that I've passed Double and its trying to cast Integer out of it in line 65 of ClientServerDetection.java file.

I have tried calling

nc.call(_service, res, 1);

as well as

var test:int = 1;
nc.call(_service, res, test);

Both result in the same error.

If I pass null it throw null exception error.

Would it be possible to update code in that line to parse Double into int? Or just parse whatever parameter [0] is into int?

Or help with telling me how to pass 1 second to the nc.call method.

Any help would be appreciated.

This his how I am invoking the call:

oCS:ClientServerBandwidth = new ClientServerBandwidth(); oCS.connection = oRTMPConn; oCS.service = "checkBandwidthUp"; oCS.addEventListener(BandwidthDetectEvent.DETECT_COMPLETE,fUpCompleted); oCS.addEventListener(BandwidthDetectEvent.DETECT_STATUS,fUpStatus); oCS.addEventListener(BandwidthDetectEvent.DETECT_FAILED,fUpFailed); oCS.start();

public function start():void { nc.client = this; var obj:Array = new Array(); nc.call(_service, res); }

Here is the error I am getting:

[ERROR] [RTMPConnectionExecutor-4] org.red5.server.service.ServiceInvoker - Error executing call: Service: null Method: checkBandwidthUp Num Params: 1 0: 1.0 java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:192) at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:114) at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:191) at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:289) at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:116) at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:72) at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:38) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer at org.red5.server.stream.bandwidth.ClientServerDetection.checkBandwidth(ClientServerDetection.java:65) at org.red5.server.Client.checkBandwidthUp(Client.java:359) at org.red5.server.adapter.AbstractScopeAdapter.checkBandwidthUp(AbstractScopeAdapter.java:297) ... 17 common frames omitted

Configuring SharedObjectScope class using beans

Hi,

I want to add some other data along with SharedObjectScope. For that I want to extend it in my custom class in red5 application and create object of custom classs say MySOScope when SharedObjectService#createSharedObject() is called.

As of now, instance of SharedObjectScope is directly created here, but can I change code in way:

  1. SharedObjectScope will not be created directly.
  2. Its mapping will be in red5-default.xml. By reading, beans id & class, instance for SharedObjectScope will be created.
  3. Then further if I want to implement any custom class in my application, I can extend SharedObjectScope in MySOScope, and override that beans id and class with reference to MySOScope as value of class attribute.
  4. Then it should be able to create instance of MySOScope instead of SharedObjectScope.

Are there any cons in these modifications? Please help me to see wide picture if I am implementing these modifications.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.