我正在尝试使用 Flex 将视频流发送到 Red5 服务器。
我的 Red5 设置似乎适用于远程方法调用和共享对象,但我还没有成功地让视频工作。
这是连接 Red5 的 AS3 代码:
# connect to RTMP server
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netConnection.connect("rtmp://localhost/context_name");
# omitted code for waiting for connection success, and setting up shared
# objects (which works fine - the Red5 setup is hence OK)
当NetConnection.Connect.Success
收到时,运行以下代码开始发送流:
# when NetConnection.Connect.Success then the following code is run:
var netStream:NetStream = new NetStream(netConnection);
netStream.publish("name_of_stream", "live");
netStream.attachCamera(Camera.getCamera());
但是,这不起作用,所以我做错了什么。
这是绑定到我要连接的 Red5 上下文的 Java 应用程序:
package com.company;
public class NameOfApplication extends ApplicationAdapter {
// Empty class.
}
WEB-INF/red5-web.xml
我正在运行 Red5 0.9.1,我所做的唯一配置是通过编辑和添加来设置我的应用程序:
<bean id="context_name.context" class="org.red5.server.Context" autowire="byType" />
<bean id="context_name.scope" class="org.red5.server.WebScope" init-method="register">
<property name="server" ref="red5.server" />
<property name="parent" ref="global.scope" />
<property name="context" ref="context_name.context" />
<property name="handler" ref="context_name.handler" />
<property name="contextPath" value="/context_name" />
<property name="virtualHosts" value="*,localhost, localhost:5080, 127.0.0.1:5080" />
</bean>
<bean id="context_name.handler" class="com.company.NameOfApplication" />
这些是我在连接并尝试发送视频时在 Red5 控制台中收到的日志消息:
org.red5.server.net.rtmp.RTMPHandler - Connecting to: [WebScope@68e0ada6 Depth = 1, Path = '/default', Name = 'application_name']
org.red5.server.net.rtmp.RTMPHandler - Remembering client buffer on stream: 0
org.red5.server.stream.ClientBroadcastStream - Provider connect
org.red5.server.stream.ClientBroadcastStream - Stream start
org.red5.server.stream.ClientBroadcastStream - Provider connect
org.red5.server.stream.ClientBroadcastStream - Close
org.red5.server.stream.ClientBroadcastStream - Provider disconnect
org.red5.server.stream.ClientBroadcastStream - Provider disconnect
我究竟做错了什么?如前所述,请注意 Red5 设置对于远程方法调用和共享对象完美无缺,但不适用于奇怪的视频。