HTTP extension of wowza (publish state)

Source: Internet
Author: User
Tags wowza

HTTP extension of wowza

 

Obtain all published streams and their subscriptions

 

 

Package zjzhang. wowza; <br/> Import Java. io. *; <br/> Import Java. util. *; <br/> Import COM. wowza. WMS. vhost. *; <br/> Import COM. wowza. WMS. logging. wmsloggerfactory; <br/> Import COM. wowza. WMS. RTP. model. rtpsession; <br/> Import COM. wowza. WMS. server. *; <br/> Import COM. wowza. WMS. stream. imediastream; <br/> Import COM. wowza. WMS. stream. mediastreammap; <br/> Import COM. wowza. WMS. application. *; <br/> Import COM. wowza. WMS. HTTP. *; <br/> Import COM. wowza. WMS. client. *; <br/> Import COM. wowza. WMS. HTTP. *; <br/> Import COM. wowza. WMS. httpstreamer. model. ihttpstreamersession; <br/> public class getlist extends httprovider2base <br/> {<br/> private void outputconnectioninfo (stringbuffer ret, connectioncounter counter) <br/> {<br/> ret. append ("<connectionscurrent>" + counter. getcurrent () + "</connectionscurrent>"); <br/> ret. append ("<Connectionstotal>" + counter. gettotal () + "</connectionstotal>"); <br/> ret. append ("<connectionstotalaccepted>" + counter. gettotalaccepted () + "</connectionstotalaccepted>"); <br/> ret. append ("<connectionstotalrejected>" + counter. gettotalrejected () + "</connectionstotalrejected>"); <br/>}</P> <p> Public void onhttprequest (ivhost invhost, ihttprequest req, ihttpresponse resp) <br/>{< br/> If (! Dohttpauthentication (invhost, req, resp) <br/> return; <br/> stringbuffer ret = new stringbuffer (); </P> <p> try <br/> {<br/> List vhostnames = vhostsingleton. getvhostnames (); <br/> ret. append ("<? XML version =/"1.0/"?> /N <wowzamediaserverpro> "); </P> <p> iterator <string> iter = vhostnames. iterator (); <br/> while (ITER. hasnext () <br/>{< br/> string vhostname = ITER. next (); <br/> ivhost vhost = (ivhost) vhostsingleton. getinstance (vhostname); <br/> If (vhost! = NULL) <br/>{< br/> ret. append ("<vhost>"); <br/> ret. append ("<Name>" + vhostname + "</Name>"); <br/> ret. append ("<timerunning>" + vhost. gettimerunningseconds () + "</timerunning>"); <br/> ret. append ("<connectionslimit>" + vhost. getconnectionlimit () + "</connectionslimit>"); </P> <p> outputconnectioninfo (Ret, vhost. getconnectioncounter (); </P> <p> List appnames = vhost. getapplicationnames (); <br/> List <string> appfolders = Vhost. getapplicationfoldernames (); <br/> iterator <string> appnameiterator = appfolders. iterator (); <br/> while (appnameiterator. hasnext () <br/>{< br/> string applicationname = appnameiterator. next (); <br/> ret. append ("<Application>"); <br/> ret. append ("<Name>" + applicationname + "</Name>"); <br/> Boolean appexists = appnames. contains (applicationname); <br/> ret. append ("<status>" + (appexists? "Loaded": "unloaded") + "</status>"); <br/> If (appexists) <br/>{< br/> iapplication application = vhost. getapplication (applicationname); <br/> If (Application = NULL) <br/> continue; </P> <p> ret. append ("<timerunning>" + application. gettimerunningseconds () + "</timerunning>"); <br/> outputconnectioninfo (Ret, application. getconnectioncounter (); </P> <p> List appinstances = application. getappinstancenames (); <br/> I Terator <string> iterappinstances = appinstances. iterator (); <br/> while (iterappinstances. hasnext () <br/>{< br/> string appinstancename = iterappinstances. next (); <br/> iapplicationinstance appinstance = application. getappinstance (appinstancename); <br/> If (appinstance = NULL) <br/> continue; </P> <p> ret. append ("<applicationinstance>"); <br/> ret. append ("<Name>" + appinstance. getname () + "</Name>"); <br/> r ET. append ("<timerunning>" + appinstance. gettimerunningseconds () + "</timerunning>"); </P> <p> outputconnectioninfo (Ret, appinstance. getconnectioncounter (); <br/> mediastreammap MSM = appinstance. getstreams (); </P> <p> List <string> publishstreams = MSM. getpublishstreamnames (); <br/> iterator <string> iterpublish = publishstreams. iterator (); </P> <p> while (iterpublish. hasnext () <br/>{< br/> imediastream stream = MSM. Getstream (iterpublish. next (); // appinstance. getclient (c); <br/> If (Stream = NULL) <br/> continue; </P> <p> ret. append ("<publishstream>"); <br/> ret. append ("<Name>" + stream. getname () + "</Name>"); <br/> ret. append ("<type>" + stream. getstreamtype () + "</type>"); <br/> ret. append ("<publishstreamready>" + stream. ispublishstreamready (false, true) + "</publishstreamready>"); <br/> ret. append ("<publishaudiocodecid>" + stre Am. getpublishaudiocodecid () + "</publishaudiocodecid>"); <br/> ret. append ("<publishvideocodecid>" + stream. getpublishvideocodecid () + "</publishvideocodecid>"); <br/> List <imediastream> playstreams = appinstance. getplaystreamsbyname (stream. getname (); <br/> If (playstreams! = NULL) <br/>{< br/> ret. append ("<sessionsflash COUNT =/" "+ playstreams. size () + "/"> "); <br/> iterator <imediastream> iterplay = playstreams. iterator (); <br/> while (iterplay. hasnext () <br/>{< br/> imediastream playsession = iterplay. next (); <br/> iclient playclient = playsession. getclient (); <br/> ret. append ("<session>"); <br/> ret. append ("<clientip>" + playclient. getip () + "</clientip>"); <br/> ret. append ("<clientflas Hver> "+ playclient. getflashver () + "</clientflashver>"); <br/> ret. append ("<clientconnecttime>" + playclient. getconnecttime () + "</clientconnecttime>"); <br/> ret. append ("</session>"); <br/>}< br/> ret. append ("</sessionsflash>"); <br/>}< br/> else <br/>{< br/> ret. append ("<sessionsflash COUNT =/" 0/"/>"); <br/>}</P> <p> List <ihttpstreamersession> cupertinosession = appinstance. gethttpstreamersessions (ihttpstreamers Ession. sessionprotocol_cupertinostreaming, stream. getname (); <br/> If (cupertinosession! = NULL) <br/>{< br/> ret. append ("<sessionscupertino COUNT =/" "+ cupertinosession. size () + "/"> "); <br/> iterator <ihttpstreamersession> iterplay = cupertinosession. iterator (); <br/> while (iterplay. hasnext () <br/>{< br/> ihttpstreamersession playsession = iterplay. next (); <br/> ret. append ("<session>"); <br/> ret. append ("<clientip>" + playsession. getipaddress () + "</clientip>"); <br/> ret. append ("<clientuseragent>" + PLA Ysession. getuseragent () + "</clientuseragent>"); <br/> ret. append ("<clientconnecttime>" + playsession. gettimerunning () + "</clientconnecttime>"); <br/> ret. append ("</session>"); <br/>}</P> <p> ret. append ("</sessionscupertino>"); <br/>}< br/> else <br/>{< br/> ret. append ("<sessionscupertino COUNT =/" 0/"/>"); <br/>}</P> <p> List <ihttpstreamersession> smoothsession = appinstance. gethttpstreamersessions (ihttpstreamers Ession. sessionprotocol_smoothstreaming, stream. getname (); <br/> If (smoothsession! = NULL) <br/>{< br/> ret. append ("<sessionssmooth COUNT =/" "+ smoothsession. size () + "/"> "); <br/> iterator <ihttpstreamersession> iterplay = smoothsession. iterator (); <br/> while (iterplay. hasnext () <br/>{< br/> ihttpstreamersession playsession = iterplay. next (); <br/> ret. append ("<session>"); <br/> ret. append ("<clientip>" + playsession. getipaddress () + "</clientip>"); <br/> ret. append ("<clientuseragent>" + playsession. Getuseragent () + "</clientuseragent>"); <br/> ret. append ("<clientconnecttime>" + playsession. gettimerunning () + "</clientconnecttime>"); <br/> ret. append ("</session>"); <br/>}< br/> ret. append ("</sessionssmooth>"); <br/>}< br/> else <br/>{< br/> ret. append ("<sessionssmooth COUNT =/" 0/"/>"); <br/>}</P> <p> List <rtpsession> rtpstreams = appinstance. getrtpsessions (stream. getname (); <br/> If (rtpstreams! = NULL) <br/>{< br/> ret. append ("<sessionsrtsp COUNT =/" "+ rtpstreams. size () + "/"> "); <br/> iterator <rtpsession> iterplay = rtpstreams. iterator (); <br/> while (iterplay. hasnext () <br/>{< br/> rtpsession playsession = iterplay. next (); <br/> ret. append ("<session>"); <br/> ret. append ("<clientip>" + playsession. getip () + "</clientip>"); <br/> ret. append ("<clientuseragent>" + playsession. getuseragent () + "</clientuseragent>" ); <Br/> ret. append ("</session>"); <br/> // ret. append ("<clientconnecttime>" + playsession. get + "</clientconnecttime>"); <br/>}< br/> ret. append ("</sessionsrtsp>"); <br/>}< br/> else <br/>{< br/> ret. append ("<sessionsrtsp COUNT =/" 0/"/>"); <br/>}</P> <p> ret. append ("</publishstream>"); </P> <p >}</P> <p>/* <br/> List <iclient> clients = appinstance. getclients (); <br/> iterator <iclient> iterclient = clients. iterator (); <Br/> while (iterclient. hasnext () <br/>{< br/> iclient client = iterclient. next (); // appinstance. getclient (c); <br/> If (client = NULL) <br/> continue; <br/> ret. append ("<client>"); <br/> ret. append ("<clientid>" + client. getclientid () + "</clientid>"); <br/> ret. append ("<flashversion>" + client. getflashver () + "</flashversion>"); <br/> ret. append ("<IPaddress>" + client. getip () + "</IPaddress>"); <br/> ret. append (" <Referrer> "+ client. getreferrer () + "</referrer>"); <br/> ret. append ("<timerunning>" + client. gettimerunningseconds () + "</timerunning>"); <br/> // ret. append ("<duration>" + (double) (system. currenttimemillis ()-client. getconnecttime ()/1000.0) + "</duration>"); <br/> // ret. append ("<datestarted>" + client. getdatestarted () + "</datestarted>"); <br/> ret. append ("<URI>" + client. geturi () + "</uri>"); </P> <p> string protocolstr = "Unknown"; <br/> switch (client. getprotocol () <br/>{< br/> case rtmpsessioninfo. protocol_rtmp: <br/> protocolstr = client. isencrypted ()? "Rtmpe": "rtmp"; <br/> break; <br/> case rtmpsessioninfo. protocol_rtmpt: <br/> protocolstr = client. isssl ()? "Rtmps" :( client. isencrypted ()? "Rtmpte": "rtmpt"); <br/> break; <br/>}</P> <p> ret. append ("<protocol type =/" "+ client. getprotocol () + "/"> "+ protocolstr +" </protocol> "); <br/> ret. append ("<isssl>" + client. isssl () + "</isssl>"); <br/> ret. append ("<isencrypted>" + client. isencrypted () + "</isencrypted>"); <br/> ret. append ("<port>" + client. getserverhostport (). getport () + "</port>"); <br/> ret. append ("</client>"); <br/>}< br/> */<br/> ret. append ("</applicationinstance>"); <br/>}</P> <p> ret. append ("</Application>"); <br/>}</P> <p> ret. append ("</vhost>"); <br/>}</P> <p> ret. append ("</wowzamediaserverpro>"); <br/>}< br/> catch (exception e) <br/>{< br/> wmsloggerfactory. getlogger (httpserverversion. class ). error ("httpserverinfoxml. onhttprequest: "+ E. tostring (); <br/> E. printstacktrace (); <br/>}</P> <p> try <br/>{< br/> resp. setheader ("Content-Type", "text/XML"); </P> <p> outputstream out = resp. getoutputstream (); <br/> byte [] outbytes = ret. tostring (). getbytes (); <br/> out. write (outbytes); <br/>}< br/> catch (exception e) <br/>{< br/> wmsloggerfactory. getlogger (httpserverversion. class ). error ("httpserverinfoxml. onhttprequest: "+ E. tostring (); <br/> E. printstacktrace (); <br/>}</P> <p >}< br/>} 

 

This is the result

 

<? XML version = "1.0"?> <Br/>-<wowzamediaserverpro> <br/>-<vhost> <br/> <Name> _ defaultvhost _ </Name> <br/> <timerunning> 233.261 </ timerunning> <br/> <connectionslimit> 0 </connectionslimit> <br/> <connectionscurrent> 2 </connectionscurrent> <br/> <connectionstotal> 4 </connectionstotal> <br /> <connectionstotalaccepted> 4 </connectionstotalaccepted> <br/> <connectionstotalrejected> 0 </connectionstotalrejected> <br/>-<Application> <br/> <Name> live </ name> <br/> <status> loaded </status> <br/> <timerunning> 205.952 </timerunning> <br/> <connectionscurrent> 2 </connectionscurrent> <br /> <connectionstotal> 4 </connectionstotal> <br/> <connectionstotalaccepted> 4 </connectionstotalaccepted> <br/> <connectionstotalrejected> 0 </connectionstotalrejected> <br/> applicationinstance> <br/> <Name> _ definst _ </Name> <br/> <timerunning> 205.922 </timerunning> <br/> <connectionscurrent> 2 </connectionscurrent> <br/> <connectionstotal> 4 </connectionstotal> <br/> <connectionstotalaccepted> 4 </connectionstotalaccepted> <br/> <connectionstotalrejected> 0 </connectionstotalreject> <br/> -<publishstream> <br/> <Name> zzj </Name> <br/> <type> live </type> <br/> <publishstreamready> true </publishstreamready> <br/> <publishaudiocodecid>-1 </publishaudiocodecid> <br/> <publishvideocodecid> 7 </publishvideocodecid> <br/>-<sessionsflash COUNT = "1"> <br />-<session> <br/> <clientip> 127.0.0.1 </clientip> <br/> <clientflashver> win, 1304925496758 </clientflashver> <br/> <clientconnecttime> </clientconnecttime> <br/> </session> <br/> </sessionsflash> <br/> <sessionscupertino count = "0"/> <br/> <sessionssmooth COUNT = "0"/> <br/> <sessionsrtsp COUNT = "0"/> <br/> </publishstream> <br/> </applicationinstance> <br/> </Application> <br/>-<Application> <br/> <Name> videochat </Name> <br/> <status> unloaded </status> <br/> </Application> <br/>-<Application> <br/> <Name> VOD </Name> <br/> <status> unloaded </status> <br/> </Application> <br/> </vhost> <br/> </wowzamediaserverpro> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.