流媒体传输知识整理(五)

来源:互联网 发布:存活的数据叫删失数据 编辑:程序博客网 时间:2024/06/05 04:57

基于red5框架的RTMP协议流媒体数据传输

服务器端代码设计

(1)  主程序类:Application.java

 

public class Application extends ApplicationAdapter {

private static final Logger LOGGER = Logger.getLogger(Application.class);

    /**

     *

     * @author linfenliang

     * @date 2012-11-23

     * @version V1.0.0

     * @param args

     * void

     

     */

    public static void main(String[] args) {

       // TODO Auto-generated method stub

 

    }

 

 

    public String test(String val) {

       LOGGER.info("test called on: " + getName());

       return val + val;

    }

 

    public String getit(String value){

       LOGGER.info("flex调用成功,传入的参数: " + value);

       return value+":"+UUID.randomUUID().toString().toUpperCase();

    }

    @Override

    public synchronized boolean connect(IConnection conn, IScope scope,

           Object[] params) {

       LOGGER.info("---------connect---------");

       return super.connect(conn, scope, params);

    }

 

 

    @Override

    public synchronized void disconnect(IConnection conn, IScope scope) {

       // TODO Auto-generated method stub

       LOGGER.info("..........disconnect.........");

       super.disconnect(conn, scope);

    }

 

 

    @Override

    public synchronized boolean join(IClient client, IScope scope) {

       LOGGER.info("---------join---------");

       return super.join(client, scope);

    }

 

 

    @Override

    public synchronized void leave(IClient client, IScope scope) {

       LOGGER.info("---------leave---------");

       super.leave(client, scope);

    }

 

 

    @Override

    public synchronized boolean start(IScope scope) {

       LOGGER.info(".........start.......");

       return super.start(scope);

    }

 

 

    @Override

    public synchronized void stop(IScope scope) {

       LOGGER.info("---------stop---------");

       super.stop(scope);

    }

 

(2)  配置文件(WEB-INF目录下)

red5-web.prperties

 

webapp.contextPath=/Red5Test

webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088

 

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.sides.red5.app.Application" />

 

</beans>

 


0 0
原创粉丝点击