Wowza 的Http扩展

获取所有的发布的流以及该流的订阅情况

package zjzhang.wowza; import java.io.*; import java.util.*; import com.wowza.wms.vhost.*; import com.wowza.wms.logging.WMSLoggerFactory; import com.wowza.wms.rtp.model.RTPSession; import com.wowza.wms.server.*; import com.wowza.wms.stream.IMediaStream; import com.wowza.wms.stream.MediaStreamMap; import com.wowza.wms.application.*; import com.wowza.wms.http.*; import com.wowza.wms.client.*; import com.wowza.wms.http.*; import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession; public class GetList extends HTTProvider2Base { private void outputConnectionInfo(StringBuffer ret, ConnectionCounter counter) { ret.append("<ConnectionsCurrent>"+counter.getCurrent()+"</ConnectionsCurrent>"); ret.append("<ConnectionsTotal>"+counter.getTotal()+"</ConnectionsTotal>"); ret.append("<ConnectionsTotalAccepted>"+counter.getTotalAccepted()+"</ConnectionsTotalAccepted>"); ret.append("<ConnectionsTotalRejected>"+counter.getTotalRejected()+"</ConnectionsTotalRejected>"); } public void onHTTPRequest(IVHost inVhost, IHTTPRequest req, IHTTPResponse resp) { if (!doHTTPAuthentication(inVhost, req, resp)) return; StringBuffer ret = new StringBuffer(); try { List vhostNames = VHostSingleton.getVHostNames(); ret.append("<?xml version=/"1.0/"?>/n<WowzaMediaServerPro>"); Iterator<String> iter = vhostNames.iterator(); while (iter.hasNext()) { String vhostName = iter.next(); IVHost vhost = (IVHost)VHostSingleton.getInstance(vhostName); if (vhost != null) { ret.append("<VHost>"); ret.append("<Name>"+vhostName+"</Name>"); ret.append("<TimeRunning>"+vhost.getTimeRunningSeconds()+"</TimeRunning>"); ret.append("<ConnectionsLimit>"+vhost.getConnectionLimit()+"</ConnectionsLimit>"); outputConnectionInfo(ret, vhost.getConnectionCounter()); List appNames = vhost.getApplicationNames(); List<String> appFolders = vhost.getApplicationFolderNames(); Iterator<String> appNameIterator = appFolders.iterator(); while (appNameIterator.hasNext()) { String applicationName = appNameIterator.next(); ret.append("<Application>"); ret.append("<Name>"+applicationName+"</Name>"); boolean appExists = appNames.contains(applicationName); ret.append("<Status>"+(appExists?"loaded":"unloaded")+"</Status>"); if (appExists) { IApplication application = vhost.getApplication(applicationName); if (application == null) continue; ret.append("<TimeRunning>"+application.getTimeRunningSeconds()+"</TimeRunning>"); outputConnectionInfo(ret, application.getConnectionCounter()); List appInstances = application.getAppInstanceNames(); Iterator<String> iterAppInstances = appInstances.iterator(); while (iterAppInstances.hasNext()) { String appInstanceName = iterAppInstances.next(); IApplicationInstance appInstance = application.getAppInstance(appInstanceName); if (appInstance == null) continue; ret.append("<ApplicationInstance>"); ret.append("<Name>"+appInstance.getName()+"</Name>"); ret.append("<TimeRunning>"+appInstance.getTimeRunningSeconds()+"</TimeRunning>"); outputConnectionInfo(ret, appInstance.getConnectionCounter()); MediaStreamMap msm=appInstance.getStreams(); List<String> publishStreams =msm.getPublishStreamNames(); Iterator<String> iterPublish = publishStreams.iterator(); while(iterPublish.hasNext()) { IMediaStream stream = msm.getStream(iterPublish.next()); //appInstance.getClient(c); if (stream == null) continue; ret.append("<PublishStream>"); ret.append("<Name>"+stream.getName()+"</Name>"); ret.append("<Type>"+stream.getStreamType()+"</Type>"); ret.append("<PublishStreamReady>"+stream.isPublishStreamReady(false, true)+"</PublishStreamReady>"); ret.append("<PublishAudioCodecId>"+stream.getPublishAudioCodecId()+"</PublishAudioCodecId>"); ret.append("<PublishVideoCodecId>"+stream.getPublishVideoCodecId()+"</PublishVideoCodecId>"); List<IMediaStream> playStreams=appInstance.getPlayStreamsByName(stream.getName()); if(playStreams!=null) { ret.append("<SessionsFlash count=/""+playStreams.size()+"/">"); Iterator<IMediaStream> iterPlay=playStreams.iterator(); while(iterPlay.hasNext()) { IMediaStream playSession= iterPlay.next(); IClient playClient=playSession.getClient(); ret.append("<Session>"); ret.append("<ClientIP>"+playClient.getIp()+"</ClientIP>"); ret.append("<ClientFlashVer>"+playClient.getFlashVer()+"</ClientFlashVer>"); ret.append("<ClientConnectTime>"+playClient.getConnectTime()+"</ClientConnectTime>"); ret.append("</Session>"); } ret.append("</SessionsFlash>"); } else { ret.append("<SessionsFlash count=/"0/"/>"); } List<IHTTPStreamerSession> cupertinoSession=appInstance.getHTTPStreamerSessions(IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING, stream.getName()); if(cupertinoSession!=null) { ret.append("<SessionsCupertino count=/""+cupertinoSession.size()+"/">"); Iterator<IHTTPStreamerSession> iterPlay=cupertinoSession.iterator(); while(iterPlay.hasNext()) { IHTTPStreamerSession playSession= iterPlay.next(); ret.append("<Session>"); ret.append("<ClientIP>"+playSession.getIpAddress()+"</ClientIP>"); ret.append("<ClientUserAgent>"+playSession.getUserAgent()+"</ClientUserAgent>"); ret.append("<ClientConnectTime>"+playSession.getTimeRunning()+"</ClientConnectTime>"); ret.append("</Session>"); } ret.append("</SessionsCupertino>"); } else { ret.append("<SessionsCupertino count=/"0/"/>"); } List<IHTTPStreamerSession> smoothSession=appInstance.getHTTPStreamerSessions(IHTTPStreamerSession.SESSIONPROTOCOL_SMOOTHSTREAMING, stream.getName()); if(smoothSession!=null) { ret.append("<SessionsSmooth count=/""+smoothSession.size()+"/">"); Iterator<IHTTPStreamerSession> iterPlay=smoothSession.iterator(); while(iterPlay.hasNext()) { IHTTPStreamerSession playSession= iterPlay.next(); ret.append("<Session>"); ret.append("<ClientIP>"+playSession.getIpAddress()+"</ClientIP>"); ret.append("<ClientUserAgent>"+playSession.getUserAgent()+"</ClientUserAgent>"); ret.append("<ClientConnectTime>"+playSession.getTimeRunning()+"</ClientConnectTime>"); ret.append("</Session>"); } ret.append("</SessionsSmooth>"); } else { ret.append("<SessionsSmooth count=/"0/"/>"); } List<RTPSession> rtpStreams=appInstance.getRTPSessions(stream.getName()); if(rtpStreams!=null) { ret.append("<SessionsRTSP count=/""+rtpStreams.size()+"/">"); Iterator<RTPSession> iterPlay=rtpStreams.iterator(); while(iterPlay.hasNext()) { RTPSession playSession= iterPlay.next(); ret.append("<Session>"); ret.append("<ClientIP>"+playSession.getIp()+"</ClientIP>"); ret.append("<ClientUserAgent>"+playSession.getUserAgent()+"</ClientUserAgent>"); ret.append("</Session>"); //ret.append("<ClientConnectTime>"+playSession.get+"</ClientConnectTime>"); } ret.append("</SessionsRTSP>"); } else { ret.append("<SessionsRTSP count=/"0/"/>"); } ret.append("</PublishStream>"); } /* List<IClient> clients = appInstance.getClients(); Iterator<IClient> iterClient = clients.iterator(); while(iterClient.hasNext()) { IClient client = iterClient.next(); //appInstance.getClient(c); if (client == null) continue; ret.append("<Client>"); ret.append("<ClientId>"+client.getClientId()+"</ClientId>"); ret.append("<FlashVersion>"+client.getFlashVer()+"</FlashVersion>"); ret.append("<IpAddress>"+client.getIp()+"</IpAddress>"); ret.append("<Referrer>"+client.getReferrer()+"</Referrer>"); ret.append("<TimeRunning>"+client.getTimeRunningSeconds()+"</TimeRunning>"); //ret.append("<Duration>"+((double)(System.currentTimeMillis()-client.getConnectTime())/1000.0)+"</Duration>"); //ret.append("<DateStarted>"+client.getDateStarted()+"</DateStarted>"); ret.append("<URI>"+client.getUri()+"</URI>"); String protocolStr = "unknown"; switch(client.getProtocol()) { case RtmpSessionInfo.PROTOCOL_RTMP: protocolStr = client.isEncrypted()?"RTMPE":"RTMP"; break; case RtmpSessionInfo.PROTOCOL_RTMPT: protocolStr = client.isSSL()?"RTMPS":(client.isEncrypted()?"RTMPTE":"RTMPT"); break; } ret.append("<Protocol type=/""+client.getProtocol()+"/">"+protocolStr+"</Protocol>"); ret.append("<IsSSL>"+client.isSSL()+"</IsSSL>"); ret.append("<IsEncrypted>"+client.isEncrypted()+"</IsEncrypted>"); ret.append("<Port>"+client.getServerHostPort().getPort()+"</Port>"); ret.append("</Client>"); } */ ret.append("</ApplicationInstance>"); } } ret.append("</Application>"); } ret.append("</VHost>"); } } ret.append("</WowzaMediaServerPro>"); } catch (Exception e) { WMSLoggerFactory.getLogger(HTTPServerVersion.class).error("HTTPServerInfoXML.onHTTPRequest: "+e.toString()); e.printStackTrace(); } try { resp.setHeader("Content-Type", "text/xml"); OutputStream out = resp.getOutputStream(); byte[] outBytes = ret.toString().getBytes(); out.write(outBytes); } catch (Exception e) { WMSLoggerFactory.getLogger(HTTPServerVersion.class).error("HTTPServerInfoXML.onHTTPRequest: "+e.toString()); e.printStackTrace(); } } }

这是结果

<?xml version="1.0" ?> - <WowzaMediaServerPro> - <VHost> <Name>_defaultVHost_</Name> <TimeRunning>233.261</TimeRunning> <ConnectionsLimit>0</ConnectionsLimit> <ConnectionsCurrent>2</ConnectionsCurrent> <ConnectionsTotal>4</ConnectionsTotal> <ConnectionsTotalAccepted>4</ConnectionsTotalAccepted> <ConnectionsTotalRejected>0</ConnectionsTotalRejected> - <Application> <Name>live</Name> <Status>loaded</Status> <TimeRunning>205.952</TimeRunning> <ConnectionsCurrent>2</ConnectionsCurrent> <ConnectionsTotal>4</ConnectionsTotal> <ConnectionsTotalAccepted>4</ConnectionsTotalAccepted> <ConnectionsTotalRejected>0</ConnectionsTotalRejected> - <ApplicationInstance> <Name>_definst_</Name> <TimeRunning>205.922</TimeRunning> <ConnectionsCurrent>2</ConnectionsCurrent> <ConnectionsTotal>4</ConnectionsTotal> <ConnectionsTotalAccepted>4</ConnectionsTotalAccepted> <ConnectionsTotalRejected>0</ConnectionsTotalRejected> - <PublishStream> <Name>zzj</Name> <Type>live</Type> <PublishStreamReady>true</PublishStreamReady> <PublishAudioCodecId>-1</PublishAudioCodecId> <PublishVideoCodecId>7</PublishVideoCodecId> - <SessionsFlash count="1"> - <Session> <ClientIP>127.0.0.1</ClientIP> <ClientFlashVer>WIN 10,2,159,1</ClientFlashVer> <ClientConnectTime>1304925496758</ClientConnectTime> </Session> </SessionsFlash> <SessionsCupertino count="0" /> <SessionsSmooth count="0" /> <SessionsRTSP count="0" /> </PublishStream> </ApplicationInstance> </Application> - <Application> <Name>videochat</Name> <Status>unloaded</Status> </Application> - <Application> <Name>vod</Name> <Status>unloaded</Status> </Application> </VHost> </WowzaMediaServerPro>

Wowza 的Http扩展 (Publish State)相关推荐

  1. sitecore_扩展Sitecore批准工作流程

    sitecore 为什么要自定义默认的Sitecore工作流程? (Why customize the default Sitecore workflow?) Sitecore is by defau ...

  2. 【转】设计模式 ( 十七) 状态模式State(对象行为型)

    设计模式 ( 十七) 状态模式State(对象行为型) 1.概述 在软件开发过程中,应用程序可能会根据不同的情况作出不同的处理.最直接的解决方案是将这些所有可能发生的情况全都考虑到.然后使用if... ...

  3. java设计模式演示样例

    创建模式 1.工厂方法模式(Factory Method)  将程序中创建对象的操作,单独出来处理,创建一个产品的工厂接口,把实际的工作转移到详细的子类.大大提高了系统扩展的柔性,接口的抽象化处理给相 ...

  4. java设计模式示例

    创建模式 1.工厂方法模式(Factory Method)  将程序中创建对象的操作,单独出来处理,创建一个产品的工厂接口,把实际的工作转移到具体的子类.大大提高了系统扩展的柔性,接口的抽象化处理给相 ...

  5. StackStorm分析(四)Mistral说明

    StackStorm介绍 StackStorm是一个强大的自动化平台,结合DevOps和ChatOps,提供可扩展.灵活和健壮的工具链用于应用.服务和工作流的自动化能力. Mistral Mistra ...

  6. iptables使用方法

    iptables规则编写的通用格式:         iptables [-t table] COMMAND CHAIN [-m matchname] [per-match-options] -j t ...

  7. Iptables防火墙配置详解

    iptables防火墙配置详解 iptables简介 iptables是基于内核的防火墙,功能非常强大,iptables内置了filter,nat和mangle三张表. (1)filter表负责过滤数 ...

  8. DoS Deflate Iptables

    DoS Deflate 是一个轻量级阻止拒绝服务***的bash shell脚本.我们可以根据自己需要修改特定参数,来达到目的! 安装/卸载都很简单,分别执行下面三步就可以了: wget http:/ ...

  9. Linux防火墙详解(二)

    1 2 3 4 5 6 一.iptables命令基本语法 二.iptables语法进阶 三.iptables显示扩展 四.iptables简单案例 五.iptables之forward 六.iptab ...

最新文章

  1. intel最新的服务器芯片,Intel最新服务器CPU 芯片组Roadmap
  2. python语言入门w-Python完全小白入门指南
  3. Access2007中如何运行SQL执行SQl语句
  4. SqlServer 中Binary类型的数据如何转化为字符串
  5. 程序员面试题精选100题(23)-跳台阶问题[算法]
  6. maven 引入net.sf.json-lib依赖时报错(classifier)
  7. C++Template 模版的本质
  8. java流与文件——ZIP文档
  9. JDBC 出现references non-existing project XXX, launch configuration问题的解决办法
  10. 【网络流24题】星际转移问题(最大流)(网络判定)
  11. P问题、NP问题、NP完全问题和NP难问题
  12. java地铁最短距离_地铁线路最短路径
  13. C/C++ 编程 —— OpenCV API 学习 笔记(更新中...)
  14. fread, fwrite和fflush
  15. 作业python 内部小卖铺
  16. html实现网格布局排版整齐的表格,想要排版布局好看又整齐,用网格排一下就行了吗?...
  17. win7下安装ArcGIS9.3步骤与破解过程
  18. AI芯片:寒武纪PuDianNao结构分析
  19. 齐聚绿城 | 锦江都城酒店聚焦中高端酒店投资新方向
  20. 【HTML】表格标签,map,iframe,h5标签,语义化,标签分类,role,aria-*

热门文章

  1. 使用SfntTool制作字体剪辑工具1 - 直接使用sfnttool.jar
  2. a为实数java_Java 实数相加
  3. 【WIN10】如何关闭右下角输入法的“拼”字
  4. 安全多方计算之三:同态加密
  5. 生于忧患,死于安乐-时刻保持危机感
  6. 使用react-cropper结合图片压缩方法对图片进行裁剪压缩处理
  7. 【大数据存储技术】实验2:MongoDB数据库的部署和操作
  8. Python小游戏--数字“炸弹“
  9. 算法学习--排序算法--插入排序
  10. [每周心学]浙江大学公开课:王阳明心学