One stream name for consumers, multiple providers

128 views
Skip to first unread message

Giordano

unread,
Sep 9, 2013, 5:23:52 AM9/9/13
to red5in...@googlegroups.com
Hello everyone :)

please consider this use case:
  1. Several providers are publishing streams to URLs such as rtmp://myserver/myapp/scope-22/1 rtmp://myserver/myapp/scope-22/2 rtmp://myserver/myapp/scope-22/3 ...
  2. Several consumers are connecting to the url rtmp://myserver/myapp/scope-22/
  3. An operator (director is a better name) decides which one of the streams provided by the providers should be sent to the consumers
For example:
  1. 2 providers connect, URLs rtmp://myserver/myapp/scope-22/1 and rtmp://myserver/myapp/scope-22/2 become active
  2. Director issues an API call and consumers that connect to rtmp://myserver/myapp/scope-22/ see the video from rtmp://myserver/myapp/scope-22/1
  3. After some time director decides that rtmp://myserver/myapp/scope-22/2 is the one that has to go live and issues a new API call that makes the change.
  4. Consumers see that the video that they are watching changes from rtmp://myserver/myapp/scope-22/1 to rtmp://myserver/myapp/scope-22/2 (ideally the transition among the streams should happen with no interruption/reconnection---the consumer's player should see one unique flow of packets)
My question is... how can I achieve this?
What classes or documentation can I consult to have an idea on how to implement this feature?
I tried few links on Red5 website but some of the links seem to be broken and I'm having some hard time finding documentation about server APIs and internal working of it.

Thanks a lot in advance.
Giordano

Giordano

unread,
Sep 9, 2013, 5:43:07 AM9/9/13
to red5in...@googlegroups.com
A minor update

 
I tried few links on Red5 website but some of the links seem to be broken and I'm having some hard time finding documentation about server APIs and internal working of it.


I noticed that today red5.org is reachable and I managed to download some documentation :)
I can surely start from there, though if you have any suggestion it will be very much appreciated.

Giordano

Giordano

unread,
Sep 9, 2013, 11:26:58 AM9/9/13
to red5in...@googlegroups.com
I searched more thoroughly through the previous posts and found an inspiring one from Andy.
This is what he suggests:

1. Create your own broadcast stream on the red5 server and register it with the IProvider service.
 
2. Allow each user to publish on their own individual stream.
 
3. Intercept Stream packets, copy the packets and change the time-stamps to your broadcast stream's live delta.
 
4 Push packets into broadcast stream.


This is a draft plan about what I'm willing to do:
  1. Create a custom IBroadcasService perhaps extending/reimplementing a class like ServerStreamClientBroadcastStream or AbstractStream..
    Q1) Which class is the most suitable to use/extend in your opinion?

  2. Register such broadcast stream at the parent scope (in my example "scope-22"). To do so I guess it is enough to write something like this (taken from ServerStream sources) :
    IScope scope = getScope();
    IContext context = scope.getContext();
    providerService = (IProviderService) context.getBean(IProviderService.BEAN_NAME);
    // publish this server-side stream
    providerService.registerBroadcastStream(scope, publishedName, this);
    scheduler = (ISchedulingService) context.getBean(ISchedulingService.BEAN_NAME);
    Q2) Is this ok?

  3. Get the ClientBroadcastStream of one of the "provider" scopes (like the one for url rtmp://myserver/myapp/scope-22/2) with code like this:
    public IBroadcastStream getBroadcastStream(IScope scope, String name) {
    IStreamService service = (IStreamService) ScopeUtils.getScopeService(scope, IStreamService.class, StreamService.class);
    if (service instanceof StreamService) {
    IBroadcastScope bs = ((StreamService) service).getBroadcastScope(scope, name);
    if (bs != null) {
    return bs.getClientBroadcastStream();
    }
    }
    return null;
    }
    The above code comes from the sources of MultiThreadedApplicationAdapter.
    Q3) Is this ok?

  4. With some "sorcery" code copy the audio/video data from the ClientBroadcastStream to my CustomBroadcastStream implemented at point 1).
    Obviously I need to change the timestamp to have it follow a unique and consistent timeline.
    Q4) Any example/idea on how to do this? Any hints?

  5. Hopefully consumers that will connect to the CustomBroadcastStream will see the video as if it was a unique stream.

Please let me know if you can respond to any of the questions above ^^
In the meantime I'll be investigating further.

Thanks, have a good day
Giordano

Andy Shaules

unread,
Sep 9, 2013, 12:39:52 PM9/9/13
to red5in...@googlegroups.com
1) ClientBroadcastStream


2) Looks ok..

3) I use IConnection.setAttribute('cutomStrea', impl), on the current pusher.

4) on original incoming stream, set IStreamListener and copy packets.
http://code.google.com/p/comserver/source/browse/trunk/demo/demo4/java/demo/WEB-INF/src/comdemo/internal/feeds/AVFeed.java#55

Nothing in that last link matters but delta math, and that you initiate a switch to a new stream on a vid key frame.

Andy
--
 
---
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.

Giordano

unread,
Sep 25, 2013, 5:46:46 AM9/25/13
to red5in...@googlegroups.com
Thanks a lot for the feedback!

Sorry for the late reply but I was working on other projects in the last couple of weeks.

Giordano

Piotr M.

unread,
Oct 11, 2013, 4:57:34 AM10/11/13
to red5in...@googlegroups.com
Hi, I have the same problem and solved it succefuly. It works even without extending ClientBroadcastStream, just add stream listener to your source stream and cast
IStreamPacket to IRTMPEvent and put it to ClientBroadcastStream.dispatchEvent( ).

You start your main stream as such:

            liveTVClientStream = new ClientBroadcastStream();
            liveTVClientStream
.setScope( app);
           
           
           
IContext context = scope.getContext();
           
IProviderService providerService = (IProviderService) context.getBean( IProviderService.BEAN_NAME );
            providerService
.registerBroadcastStream( scope , "livetv" , liveTVClientStream );
           
             liveTVClientStream
.setPublishedName( "livetv");
            liveTVClientStream
.setName( "livetv");


Reply all
Reply to author
Forward
0 new messages