Flash 通过RTMP协议 连接 Red5服务器

Flash code:

import flash.net.NetConnection;
import flash.events.NetStatusEvent;
//创建一个NetConnection对象
var nc:NetConnection = new NetConnection();
//给nc对象绑定一个事件句柄,用来跟踪netStatus
nc.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
//完成句柄对应的函数netStauts
function netStatus(event:NetStatusEvent):void
{
    trace(event.info.code);
}
//开始连接red5服务器承载的示范应用
nc.connect("rtmp://169.254.80.208/firstapp");

Java:
这里写图片描述

Application.java

/**
 * 
 */
package com.red5app;

import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.scope.IScope;

/**
 * @author L
 *
 */
public class Application extends ApplicationAdapter {
    @Override
    public boolean appStart(IScope arg0) {
        return true;
    }

    @Override
    public void appStop(IScope arg0) {
    }
}

red5-web.properties

webapp.contextPath=/firstapp
webapp.virtualHosts=169.254.80.208

red5-web.xml

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd                            
    http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">

    <bean id="placeholderConfig"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="/WEB-INF/red5-web.properties" />
    </bean>

    <bean id="web.context" class="org.red5.server.Context" autowire="byType" />

    <bean id="web.scope" class="org.red5.server.scope.WebScope"
        init-method="register">
        <property name="server" ref="red5.server" />
        <property name="parent" ref="global.scope" />
        <property name="context" ref="web.context" />
        <property name="handler" ref="web.handler" />
        <property name="contextPath" value="${webapp.contextPath}" />
        <property name="virtualHosts" value="${webapp.virtualHosts}" />
    </bean>

    <bean id="web.handler" class="com.red5app.Application" />


</beans>

web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>firstapp</display-name>



    <context-param>
        <param-name>globalScope</param-name>
        <param-value>default</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/red5-web.xml</param-value>
    </context-param>

    <context-param>
        <param-name>locatorFactorySelector</param-name>
        <param-value>red5.xml</param-value>
    </context-param>

    <context-param>
        <param-name>parentContextKey</param-name>
        <param-value>default.context</param-value>
    </context-param>

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>/firstapp</param-value>
    </context-param>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/streams/*</url-pattern>
        </web-resource-collection>
        <auth-constraint />
    </security-constraint>

</web-app>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值