基于WOWZA的录制开发和rtsp流的发布:
public class WowzaLiveStreamRecord extends HTTProvider2Base {
private static final Class<WowzaLiveStreamRecord> CLASS = WowzaLiveStreamRecord.class;
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
if (!doHTTPAuthentication(vhost, req, resp))
return;
IApplication application=vhost.getApplication("live");
IApplicationInstance appInstance=application.getAppInstance("_definst_");
OutputStream out = resp.getOutputStream();
String action=req.getParameter("action");
String fileformat=req.getParameter("fileformat");
String filepath=req.getParameter("filepath");
String parameters=req.getParameter("parameters");
StringBuffer resstr=new StringBuffer();
WowzaDaoImpl wowza=new WowzaDaoImpl();
try{
if(action==null || action.equals("")){
Common.setRetInfo(resstr,"","fail","action is required");
out.write(resstr.toString().getBytes());
resstr=null;
return;
}
if(action.equals("startRecording") || action.equals("stopRecording") || action.equals("streamInfo")){
if(parameters==null || parameters.equals("")){
Common.setRetInfo(resstr,"","fail","parameters is required");
out.write(resstr.toString().getBytes());
resstr=null;
return;
}
List l=Common.jsonToList(parameters,Response.class);
for(int i=0;i<l.size();i++){
Response p=(Response)l.get(i);
String streamname=p.getStreamname();
if(streamname==null || streamname.equals("")){
Common.setRetInfo(resstr,"","fail","streamname is required");
out.write(resstr.toString().getBytes());
resstr=null;
return;
}
}
for(int j=0;j<l.size();j++){
Response p=(Response)l.get(j);
String streamname=p.getStreamname();
//开始录制
if(action.equals("startRecording")){
String filename=p.getFilename();
if(filename==null || filename.equals("")) filename=Common.getFileName();
StreamRecorderParameters recordParams = new StreamRecorderParameters(appInstance);
if(fileformat==null ||fileformat.equals("")) fileformat="1";
if(filepath!=null && !filepath.equals("")){
recordParams.outputPath=filepath;
//若文件路径不存在,自行建立
File fDir = new File(filepath);
if (!fDir.exists()) {
fDir.mkdir();
}
File file = new File(filepath);
if(!file.exists()) file.mkdirs();
}
if(fileformat.equals("1")) recordParams.fileFormat=IStreamRecorderConstants.FORMAT_FLV;
if(fileformat.equals("2")) recordParams.fileFormat=IStreamRecorderConstants.FORMAT_MP4;
recordParams.outputFile=filename;
recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_NONE;
recordParams.versioningOption = IStreamRecorderConstants.OVERWRITE_FILE;
IStreamRecorder rec=vhost.getLiveStreamRecordManager().getRecorder(appInstance,streamname);
if(rec==null){
vhost.getLiveStreamRecordManager().startRecording(appInstance,streamname,recordParams);
Common.setRetInfo(resstr,streamname,"succ","");
}else{
Common.setRetInfo(resstr,streamname,"fail","record stream exist");
}
resstr.append(",");
}
//结束录制
if(action.equals("stopRecording")){
IStreamRecorder rec=vhost.getLiveStreamRecordManager().getRecorder(appInstance,streamname);
if(rec==null){//判断是否有录制流
Common.setRetStreamInfo(resstr,streamname, "","record stream not exist", "", "");
resstr.append(",");
continue;
}
wowza.streamInfo(rec,resstr);
resstr.append(",");
vhost.getLiveStreamRecordManager().stopRecording(appInstance,streamname);
}
//流信息查询
if(action.equals("streamInfo")){
IStreamRecorder rec=vhost.getLiveStreamRecordManager().getRecorder(appInstance,streamname);
if(rec==null){//判断是否有录制流
Common.setRetStreamInfo(resstr,streamname, "","record stream not exist", "", "");
resstr.append(",");
continue;
}
wowza.streamInfo(rec,resstr);
resstr.append(",");
}
}
String resstrs=resstr.toString();
if(!resstrs.toString().equals("")) resstrs=resstrs.substring(0,resstrs.length()-1);
out.write(resstrs.getBytes());
resstr=null;
}
//录制流列表
if(action.equals("streamRecordList")){
List lx=vhost.getLiveStreamRecordManager().getRecordersList(appInstance);
for(int i=0;i<lx.size();i++){
IStreamRecorder rec=(IStreamRecorder)lx.get(i);
if(rec.getStream()==null){//判断是否有录制流
Common.setRetStreamInfo(resstr,rec.getStreamName(), "","record stream not exist", "", "");
resstr.append(",");
continue;
}
wowza.streamInfo(rec,resstr);
resstr.append(",");
}
String resstrs=resstr.toString();
if(!resstrs.toString().equals("")) resstrs=resstrs.substring(0,resstrs.length()-1);
out.write(resstrs.getBytes());
resstr=null;
}
// 添加流文件,0文件已存在,1添加成功
if(action.toLowerCase().equals("addstreamfile")){
String filesName = req.getParameter("filesName");
String url = req.getParameter("url");
String streamFilePath = new File(appInstance.getStreamStoragePath()).getAbsolutePath() + "/" + filesName;
File streamFile = new File(streamFilePath);
if(streamFile.exists()) {// 流文件存在
out.write("0".getBytes());
} else {
BufferedWriter bos = new BufferedWriter(new FileWriter(streamFile));
bos.write(url);
bos.flush();
bos.close();
out.write("1".getBytes());
}
}
// 删除流文件,0流文件不存在,1删除成功
if(action.toLowerCase().equals("delstreamfile")){
String filesName = req.getParameter("filesName");
appInstance.stopMediaCasterStream(filesName);
String streamFilePath = new File(appInstance.getStreamStoragePath()).getAbsolutePath() + "/" + filesName;
File streamFile = new File(streamFilePath);
if(!streamFile.exists()) {// 流文件不存在
out.write("0".getBytes());
} else {
streamFile.delete();
out.write("1".getBytes());
}
}
// 发布流文件,0发布失败,1发布成功
if(action.toLowerCase().equals("startstreamfile")){
String filesName = req.getParameter("filesName");
String streamFilePath = new File(appInstance.getStreamStoragePath()).getAbsolutePath() + "/" + filesName;
File streamFile = new File(streamFilePath);
if(!streamFile.exists()) {// 流文件存在
out.write("0".getBytes());
} else {
appInstance.startMediaCasterStream(filesName, "rtp");
out.write("1".getBytes());
}
com.wowza.wms.vhost.StartupStream stream = new com.wowza.wms.vhost.StartupStream();
stream.setApplicationName(application.getName() + "/" + appInstance.getName());
stream.setMediaCasterType("rtp");
stream.setStreamName(filesName);
vhost.addStartupStream(stream);
}
}catch(Exception e){
StringWriter sw=new StringWriter();
PrintWriter pw=new PrintWriter(sw);
e.printStackTrace(pw);
try {
Common.setRetInfo(resstr,"","exception",sw.toString());
out.write(resstr.toString().getBytes());
resstr=null;
} catch (IOException ex) {
ex.printStackTrace();
}
WMSLoggerFactory.getLogger(CLASS).info("WowzaLiveStreamRecord:"+sw.toString());
}
}
}
相关推荐
这篇文档将深入探讨WOWAPI的开发知识,帮助初学者快速掌握这一领域的核心概念。 首先,了解WOWAPI的基础是非常重要的。它主要分为几个部分:事件系统、对象模型、战斗记录以及控制台命令。事件系统允许插件监听并...
WoW API(World of Warcraft Application Programming Interface),即魔兽世界应用程序接口,是暴雪娱乐为《魔兽世界》这款游戏所提供的一个编程接口。它允许玩家和开发者使用Lua脚本来扩展游戏的功能、创建插件...
Arctium WoW Client Launcher 27377版本。 HOWTO: 安装方法: 1.Use 7zip/WinRAR to extract the archive into your wow folder. 1.用解压软件将压缩包内容解压到WOW文件夹内,即将Arctium WoW Client Launcher....
传统隐写算法WOW,对文件夹下图像进行隐写,可以是3通道图像
- **版本更新**:WMV_Binary_v0701_r482表明这是WoWModelViewer的一个开发版本,r482代表了第482次修订。 - **平台兼容**:Win32表示该版本适用于32位Windows系统,适应不同的用户需求。 - **开发工作**:DevWork...
本指南将带你深入理解WOW插件的制作过程,并介绍如何利用WOW的APIs(应用程序编程接口)来创建自定义功能。 首先,了解基础概念至关重要。WOW插件是由一系列lua脚本和XML文件组成的,这些文件定义了插件的行为和...
数据库对照表则是为了方便开发人员和玩家理解这些数据结构而设计的工具,它提供了一种直观的方式,将数据库内部的编码与游戏中的实际表现相对应。 二、数据库结构 WOW数据库通常由多个表格组成,每个表格对应游戏...
Flutter(抖动)、Wow(晃动)、Drift(漂移)、Scrape Flutter(刮颤)是以移动介质为记录材料做模拟录制和回放的系统所需要面对的几种失真。这些失真是在录制、复制、回放过程中,由记录介质不规则的运动而导致的...
6. **前端开发**:WOW.js是前端开发中的一个工具,用于提升用户体验。在实际项目中,开发者通常将它与HTML、CSS和其它JavaScript库(如jQuery)一起使用,构建动态且引人入胜的网页。 7. **Animate.css**:WOW.js...
3. API接口:WOW提供了一套丰富的API接口,允许插件访问游戏数据、操作UI元素等,深入研究这些函数能实现更多功能。 4. 用户交互:设计友好的用户界面,考虑用户的操作习惯,合理安排控件布局,提供清晰的提示信息。...
WOW.js 是一款流行的JavaScript库,由Matteo Spinelli开发,主要用于实现网页上的滚动动画效果。原版的WOW.js主要关注于当用户向下滚动页面时,元素进入视口(viewport)时触发动画。然而,这个改良版的WOW.js引入了...
在网页设计和开发中,视觉效果的呈现是至关重要的,特别是在吸引用户注意力和提升用户体验方面。"wow.min.js" 和 "animate.css" ...在压缩包中,"wow"文件很可能包含了这些库的源代码,方便开发者进行本地开发和调试。
在深入学习魔兽世界(WOW)插件编写之前,首先要明白,尽管它在游戏领域,但本质上仍然是一种软件开发。本文将引导程序员们以熟悉的视角理解并掌握WOW插件的编写,旨在简化学习过程。 1. **引言** 魔兽插件的编写...
**Wow.js** 是一个JavaScript库,由Matteo Spinelli开发,主要用于检测用户的滚动行为并触发CSS动画。它的主要功能是当元素进入浏览器的视口时,自动启动预定义的CSS动画。Wow.js简化了将动画添加到页面上的过程,...
在魔兽世界(World of Warcraft,简称WOW)这款大型多人在线角色扮演游戏(MMORPG)中,为了提供更丰富的玩家交互体验,暴雪娱乐公司开放了一套API(应用程序接口),使得玩家可以通过编写脚本来自定义用户界面(UI...
"Wow"(Whirlwind Optimized Watermarking)是一种著名的自适应隐写算法,特别适用于空域图像,其主要特点是高度的安全性和难以检测性。 在图像处理领域,空域指的是像素直接表示的二维空间。Wow算法利用空域像素的...
Visual Studio是微软出品的一款强大的开发环境,支持多种编程语言,包括C++,并且提供了丰富的调试和测试工具,对于开发和调试WoW UI模拟器这样的项目非常便利。 通过深入研究这份WoW UI模拟器源码,开发者可以了解...
在IT行业中,网络游戏的开发与运营一直是热门话题,而魔兽世界(World of Warcraft,简称WoW)作为一款全球知名的游戏,其服务器架构和实现技术吸引了众多开发者研究。本文将深入探讨如何使用C#编程语言来构建一个...
wow.min.js,wow.js