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:
- Create a custom IBroadcasService perhaps extending/reimplementing a class like ServerStream, ClientBroadcastStream or AbstractStream..
Q1) Which class is the most suitable to use/extend in your opinion?
- 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?
- 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();
}
}
The above code comes from the sources of MultiThreadedApplicationAdapter.
Q3) Is this ok?
- 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?
- 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