Streaming 使用red5重新进行光照

Streaming 使用red5重新进行光照,streaming,red5,icecast,Streaming,Red5,Icecast,我有一台服务器运行Red5,另外大约有5-6台服务器运行icecast2作为通道 现在我想使用Red5从icecast2重新播放流媒体 当用户请求内容时,Red5将知道该内容属于哪个icecast2服务器,它将连接到已更正的服务器以获取媒体并重新流式传输给用户 我的问题是,通常情况下,Red5流式传输静态内容,但在我的情况下,我必须以指定的速度和带宽从icecast2重新流式传输动态内容?可能吗? 是否有任何示例可以让我了解这一点?用于将一台服务器重新组合到另一台服务器使用 import jav

我有一台服务器运行Red5,另外大约有5-6台服务器运行icecast2作为通道 现在我想使用Red5从icecast2重新播放流媒体

当用户请求内容时,Red5将知道该内容属于哪个icecast2服务器,它将连接到已更正的服务器以获取媒体并重新流式传输给用户

我的问题是,通常情况下,Red5流式传输静态内容,但在我的情况下,我必须以指定的速度和带宽从icecast2重新流式传输动态内容?可能吗?
是否有任何示例可以让我了解这一点?

用于将一台服务器重新组合到另一台服务器使用

import java.util.HashMap;
导入java.util.Map;
导入org.red5.server.adapter.multi-threadedapplicationadapter;
导入org.red5.server.api.IBasicScope;
导入org.red5.server.api.i连接;
导入org.red5.server.api.IScope;
导入org.red5.server.api.stream.IBroadcastStream;
导入org.red5.server.stream.IBroadcastScope;
导入org.red5.server.stream.StreamingProxy;
公共类应用程序扩展多线程应用程序适配器实现IStreamListener{
私有映射streamingProxyMap=newhashmap();
公共IBroadcastScope getBroadcastScope(IScope作用域,字符串名称){
IBasicScope basicScope=scope.getBasicScope(IBroadcastScope.TYPE,
姓名);
if(!(IBroadcastScope的基本作用域实例)){
返回null;
}否则{
返回(IBroadcastScope)基本范围;
}
}
/**{@inheritardoc}*/
@凌驾
公共布尔连接(IConnection conn、IScope作用域、对象[]参数){
返回true;
}
公共void streamBroadcastStart(IBroadcastStream流)
{
IScope scope=stream.getScope();
IBroadcastScope bsScope=getBroadcastScope(scope,stream.getPublishedName());
StreamingProxy=newstreamingproxy();
proxy.setHost(“live.justin.tv”);
proxy.setApp(“app”);
setPort代理(1935年);
proxy.init();
订阅(代理,空);
proxy.start(“我的字符串”,StreamingProxy.LIVE,null);
streamingProxyMap.put(stream.getPublishedName(),代理);
addStreamListener(this);
}
收到公共无效数据包(IBroadcastStream流、IStreamPacket数据包)
{
RTMPMessage m=RTMPMessage.build((IRTMPEvent)包,packet.getTimestamp());
拖缆推送消息(空,m);
}       
同步的公共void streamBroadcastClose(IBroadcastStream){
StreamingProxy代理=
streamingProxyMap.get(stream.getPublishedName());
如果(代理!=null){
proxy.stop();
IScope scope=stream.getScope();
IBroadcastScope bsScope=getBroadcastScope(scope,stream.getPublishedName());
如果(bsScope!=null){
b.退订(代理);
}
}
}
/**{@inheritardoc}*/
@凌驾
公共无效断开连接(IConnection conn,IScope范围){
超级断开(连接,范围);
}
}

您有新版本的吗this@JuanDiego我不知道如果我想随意重新对所选流进行分组,它在任何方法中都应该以相同的方式工作?在这段代码中,StreamingProxy如何知道它应该广播哪个流?每当新流开始发布时,都将调用
streamBroadcastStart
函数。从
stream.getPublishedName()
您将了解流的名称。更多关于
import java.util.HashMap;
import java.util.Map;

import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IBasicScope;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.stream.IBroadcastScope;
import org.red5.server.stream.StreamingProxy;

public class Application extends MultiThreadedApplicationAdapter implements IStreamListener {

private Map<String, StreamingProxy> streamingProxyMap = new HashMap<String, StreamingProxy>();

public IBroadcastScope getBroadcastScope(IScope scope, String name) {
    IBasicScope basicScope = scope.getBasicScope(IBroadcastScope.TYPE,
            name);
    if (!(basicScope instanceof IBroadcastScope)) {
        return null;
    } else {
        return (IBroadcastScope) basicScope;
    }
}

/** {@inheritDoc} */
@Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
    return true;
}

public void streamBroadcastStart(IBroadcastStream stream)
{
    IScope scope = stream.getScope();
    IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
    StreamingProxy proxy = new StreamingProxy();
    proxy.setHost("live.justin.tv");
    proxy.setApp("app");
    proxy.setPort(1935);
    proxy.init();
    bsScope.subscribe(proxy, null);
    proxy.start("MY_STRING", StreamingProxy.LIVE, null);
    streamingProxyMap.put(stream.getPublishedName(), proxy);
    stream.addStreamListener(this);
}

public void packetReceived(IBroadcastStream stream, IStreamPacket packet) 
{
    RTMPMessage m = RTMPMessage.build((IRTMPEvent) packet,packet.getTimestamp());
    streamer.pushMessage(null, m);
}       

synchronized public void streamBroadcastClose(IBroadcastStream stream) {
    StreamingProxy proxy =
            streamingProxyMap.get(stream.getPublishedName());
    if (proxy != null) {
            proxy.stop();
            IScope scope = stream.getScope();
            IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
            if (bsScope != null) {
                bsScope.unsubscribe(proxy);
        }
    }
}

/** {@inheritDoc} */
@Override
public void disconnect(IConnection conn, IScope scope) {
    super.disconnect(conn, scope);
}

}