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>
问题内容: 我的Go Web应用程序中有一个相当快捷的错误处理程序,它会引发HTTP错误,记录响应的重要部分并提供错误模板。我想删除在处理程序中多次编写类似代码的重复: 我已经阅读了Error Handling and Go文章,其中定义了一个自定义HTTP处理程序类型,该类型将返回这样的错误类型/结构(甚至返回int,err): 但是我不确定如何保留现有的中间件功能/包装,使我可以像这样链接中间
本文向大家介绍Angular 2 简单类扩展angular的Http类,包括了Angular 2 简单类扩展angular的Http类的使用技巧和注意事项,需要的朋友参考一下 示例
扩展是专门设计的在 Yii 应用中随时可拿来使用的, 并可重发布的软件包。例如, yiisoft/yii2-debug 扩展在你的应用的每个页面底部添加一个方便用于调试的工具栏, 帮助你简单地抓取页面生成的情况。 你可以使用扩展来加速你的开发过程。 信息: 本文中我们使用的术语 "扩展" 特指 Yii 软件包。而用术语 "软件包" 和 "库" 指代非 Yii 专用的通常意义上的软件包。 使用扩展
vscode-react-native vscode-go
扩展为现有的类、结构体、枚举类型、或协议添加了新功能。这也包括了为无访问权限的源代码扩展类型的能力(即所谓的逆向建模)。扩展和 Objective-C 中的分类类似。(与 Objective-C 的分类不同的是,Swift 的扩展没有名字。) Swift 中的扩展可以: 添加计算实例属性和计算类型属性; 定义实例方法和类型方法; 提供新初始化器; 定义下标; 定义和使用新内嵌类型; 使现有的类型遵
概述 范例-hello-world 范例-word-count 范例-language-server 范例-调试器 调试-扩展 安装-扩展 范式-原则 测试-扩展 用我们的方法创造扩展
本页包含内容: 扩展语法 计算型属性 构造器 方法 下标 嵌套类型 扩展就是向一个已有的类、结构体或枚举类型添加新功能(functionality)。这包括在没有权限获取原始源代码的情况下扩展类型的能力(即逆向建模)。扩展和 Objective-C 中的分类(categories)类似。(不过与Objective-C不同的是,Swift 的扩展没有名字。) Swift 中的扩展可以: 添加计算型属
Jinja2 支持扩展来添加过滤器、测试、全局变量或者甚至是处理器。扩展的主要动力是 把诸如添加国际化支持的常用代码迁移到一个可重用的类。 添加扩展 扩展在 Jinja2 环境创建时被添加。一旦环境被创建,就不能添加额外的扩展。要添加 一个扩展,传递一个扩展类或导入路径的列表到 Environment 构造函数的 environment 参数。下面的例子创建了一个加载了 i18n 扩展的 Jinj