red5 設定 streams 目錄

Red5目前不能自己设定Stream目录,必须手动修改JAVA程序来实现.你看到的文档就是详细的修改方法了
以上文章的大体流程如下:

1.首先你需要有一个名为CustomFilenameGenerator的类文件,这个文件可以和你的Application放同个目录,内容如下复制内容到剪贴板代码:
import org.red5.server.api.IScope;
import org.red5.server.api.stream.IStreamFilenameGenerator;

public class CustomFilenameGenerator implements IStreamFilenameGenerator {
       /** Path that will store recorded videos. */
       public String recordPath = "recordedStreams/";
       /** Path that contains VOD streams. */
       public String playbackPath = "videoStreams/";
      
       public String generateFilename(IScope scope, String name,
            GenerationType type) {
         // Generate filename without an extension.
         return generateFilename(scope, name, null, type);
       }

       public String generateFilename(IScope scope, String name,
            String extension, GenerationType type) {
         String filename;
         if (type == GenerationType.RECORD)
            filename = recordPath + name;
         else
            filename = playbackPath + name;
         
         if (extension != null)
            // Add extension
            filename += extension;
         
         return filename;
       }
}
 有时候还会报错:没有实现 resolvesToAbsolutePath这个接口 ,加上去就OK了,记得要返回true哦
@Override
public boolean resolvesToAbsolutePath() {
// TODO Auto-generated method stub
return true;
}

2.既然有了类文件,那么就需要你配置它让它发挥作用,修改yourApp/WEB-INF/red5-web.xml,其中yourApp是你自己的应用目录名,在配置Application的下面增加一个bean复制内容到剪贴板代码:
<bean id="streamFilenameGenerator" 
      class="path.to.your.CustomFilenameGenerator" />
其中path.to.your.CustomFilenameGenerator是包名,比如我的是org.d5.server.CustomFilenameGenerator.如果不知道什么是配置Application,请查看本论坛的D5教程

3.向刚才的类中添加两个方法用来设置目标路径,代码如下复制内容到剪贴板代码:
public void setRecordPath(String path) {
       recordPath = path;
}

public void setPlaybackPath(String path) {
       playbackPath = path;
}
4.OK,现在可以通过设置刚才的bean来达到修改默认stream目录的目的了:复制内容到剪贴板代码:
<bean id="streamFilenameGenerator" 
      class="path.to.your.CustomFilenameGenerator">
       <property name="recordPath" value="recordedStreams/" />
       <property name="playbackPath" value="videoStreams/" />
</bean>
注意增加的两行

5,如果你觉得这样还不爽,可以在yourApp/WEB-INF/red5-web.properties增加两个属性复制内容到剪贴板代码:
recordPath=recordedStreams/
playbackPath=videoStreams/
而bean可以修改为复制内容到剪贴板代码: <bean id="streamFilenameGenerator" 
      class="path.to.your.CustomFilenameGenerator">
       <property name="recordPath" value="${recordPath}" />
       <property name="playbackPath" value="${playbackPath}" />
</bean>
这样就可以通过red5-web.properties来配置默认的路径了
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值