Results 1 to 4 of 4

Thread: HTTPServerInfoXML reports "loaded" even after encoder stopped

  1. #1

    Default HTTPServerInfoXML reports "loaded" even after encoder stopped

    Hi again guys,

    I'm using the com.wowza.wms.http.HTTPServerInfoXML class
    to get the status of the "live" streaming app. When I start a
    stream with the encoder, it does what I expect and reports the app's
    status as "loaded". However, when the encoder is no longer
    broadcasting (I stop Wirecast), theHTTPProvider for the live app
    continues to report "loaded" looooong after stream has stopped,
    for well over an hour after the encoder stream has ceased.

    What I expect to get is a status of "unloaded" as soon as Wirecast
    (the encoder) stops sending a stream. So, one of these two options
    could really help me out of this bind::

    1. Is there a way (class?) to get a status from the "live" app
    that returns something like true if the app is receiving a stream
    and false if it is not?

    Or...

    2. If there's not a live *stream*, have the app roll-over
    to some on-demand media?

    I'm using WMS 2.0.0.8 on ec2, in case it matters.

    Thanks much,

    Kurt

  2. #2

    Default

    At the API level if you call:

    appInstance.getStreams().getStream(streamName);

    and it returns null then the stream is not being published.

    Charlie

  3. #3

    Default solved: return live streaming status from a wowza app - code example

    Thanks Charlie,

    Your `appInstance.getStreams().getStream(streamName);` clue, along
    with this post by rrlanham:
    http://www.wowzamedia.com/forums/showthread.php?t=7652

    ...got me to the following code, which, although surely improper
    (I've never touched java before), renders a json response that
    instantly returns whether the app is actually receiving a stream
    from the encoder or not (in case anyone else needs the same
    and does not fear noob code).

    I created a Wowza Class called "ITDLiveStatus" in eclipse, and then
    somehow, and thankfully to all who have posted before, cobbled
    the following together from various examples:

    Code:
    package com.itd.wms.httpdlistener;
    
    import java.io.*;
    import com.wowza.wms.http.*;
    import com.wowza.wms.vhost.IVHost;
    import com.wowza.wms.stream.*;
    import com.wowza.wms.http.IHTTPRequest;
    import com.wowza.wms.http.IHTTPResponse;
    import com.wowza.wms.logging.*;
    
    
    public class ITDLiveStatus extends HTTProvider2Base 
    {
     
    	public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp)
        {
            StringBuffer ret = new StringBuffer();
    
            String statusResult = new String("False");
            IMediaStream stream = vhost.getApplication("live").getAppInstance("_definst_").getStreams().getStream("kylive.sdp");
            if(stream != null)
            {
                statusResult = "True";
            }
            // build a JSON response...
            ret.append("{\"streaming\"" + " : " + "\"" + statusResult +"\"}");
            
            try
            {
    		resp.setHeader("Content-Type", "application/json");
    		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();
    		}
    
        }
    
    }

    ...and then (in my test instance), I added a hostPort
    entry into my VHost.xml file:

    Code:
    <!-- add the following HostPort definition to ./conf/VHost.xml -->
    
    <!-- connectioninfo HostPort -->
    <HostPort>
            <ProcessorCount>1</ProcessorCount>
            <IpAddress>192.168.0.100</IpAddress>
            <Port>8880</Port>
            <SocketConfiguration>
                    <ReuseAddress>true</ReuseAddress>
                    <ReceiveBufferSize>16000</ReceiveBufferSize>
                    <SendBufferSize>16000</SendBufferSize>
                    <KeepAlive>true</KeepAlive>
                    <AcceptorBackLog>100</AcceptorBackLog>
            </SocketConfiguration>
            <HTTPStreamerAdapterIDs></HTTPStreamerAdapterIDs>
            <HTTPProviders>
                    <HTTPProvider>
                            <BaseClass>com.itd.wms.httpdlistener.ITDLiveStatus</BaseClass>
                            <RequestFilters>*</RequestFilters>
                            <AuthenticationMethod>none</AuthenticationMethod>
                    </HTTPProvider>
            </HTTPProviders>
    </HostPort>
    Thanks a million Charlie and rrlanham!

    -kb
    Last edited by kurtbendl; 03-22-2010 at 08:28 AM.

  4. #4
    Join Date
    Dec 2007
    Posts
    25,673

    Default

    Cool, you're welcome. Thanks for sharing the result.

    Richard

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •