Results 1 to 5 of 5

Thread: Rest api >> wowza 4

  1. #1
    Join Date
    May 2009
    Posts
    9

    Default Rest api >> wowza 4

    Our linux application server is running apache and we control all other boxes from this point using php. We have a RTP >> RTMP audio stream conversion happening successfully on our separate Wowza 4 server.

    I'm unsure the best place to look in order to initiate and terminate streams via a RESTful call to wowza from my application server.

    From what I could tell in the WowzaStreamingEngine_ServerSideAPI.pdf was that there are http utilities to use to call outside of the wowza box, but I didn't see any entry points from another server. It seemed like the HTTPProviders don't work with RTP / RTMP from what I read.

    Can you please point me in the right direction on how best to build an HTTP or HTTPS RESTful API from my wowza box that is exposed to HTTP calls from my application server so that I can take my 10+ wowza instances and manage hundreds of streams from my application server?

    Many thanks.

  2. #2
    Join Date
    Jun 2011
    Posts
    1,047

    Default

    Hi,
    The REST API is not yet available/exposed. This may be available in the future though, so I will inform our product management team of your interest.

    To control streams you could take this approach, that allows you to start and stop streams among other functions.
    and to use that effectively review this guide.

    Daren

  3. #3
    Join Date
    May 2009
    Posts
    9

    Default So confirming

    Daren,

    Just to confirm then: it is not possible to create my own HTTProviders that could start and stop an RTP pull stream or update SDP files?

    Thank you.

  4. #4
    Join Date
    Jun 2011
    Posts
    1,047

    Default

    Hi,
    Actually yes you can.

    This is a very good HTTPProvider example starting point:

    That example uses old mediacaster methods, here are more recent examples.

    We don't have a PHP interface example, but this is an example of a Web Service Interface using .NET, just to show you what's possible and you could just as easily make one for PHP.

    Daren
    Last edited by daren_j; 07-18-2014 at 03:56 PM. Reason: corrected typo

  5. #5
    Join Date
    May 2009
    Posts
    9

    Default

    Daren - I've been able to start and stop a stream using the following code. Can you please let me know if you see any red flags?

    package wowzaAPI;
    
    import java.io.*;
    
    import com.wowza.wms.http.*;
    import com.wowza.wms.logging.*;
    import com.wowza.wms.vhost.*;
    import com.wowza.wms.application.*;
    
    public class API extends HTTProvider2Base {
    
    	public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
    		if (!doHTTPAuthentication(vhost, req, resp))
    			return;
    		
    		String action = req.getParameter("action");
    		String streamName = req.getParameter("streamName");
    		String applicationName = req.getParameter("applicationName");
    		
    		String retStr = "";
    		
    		if( streamName == null)
    		{
    			retStr = "<html><head><title>streamName is Required</title></head><body>streamName is Required</body></html>";
    		}
    		else
    		{
    			
    			if( action == null)
    			{
    				retStr = "<html><head><title>action parameter is required</title></head><body>action parameter is required</body></html>";
    			}
    			else if( action.equals( "start" ) )
    			{
    			
    				startMediaCasterStream(vhost, "_definst", streamName, "rtp", applicationName);
    				retStr = "<html><head><title>" + streamName
    						+ "</title></head><body>" + streamName + " has been started</body></html>";
    				
    			}
    			else if( action.equals( "stop" ) )
    			{
    				stopMediaCasterStream(vhost, "_definst", streamName, "rtp", applicationName);
    				retStr = "<html><head><title>" + streamName
    						+ "</title></head><body>" + streamName + " has been stopped</body></html>";
    			}
    			
    		}
    		try {
    			OutputStream out = resp.getOutputStream();
    			byte[] outBytes = retStr.getBytes();
    			out.write(outBytes);
    		} catch (Exception e) {
    			WMSLoggerFactory.getLogger(null).error("API: " + e.toString());
    		}
    
    	}
    	
    	public void startMediaCasterStream(IVHost vhost, String appInstanceStr, String streamName, String mediaCasterType, String applicationName)
    	{
    		WMSLoggerFactory.getLogger(null).info("WowzaServerWebService.startMediaCasterStream: appInstance:"+appInstanceStr+" streamName:"+streamName+" mediaCasterType:"+mediaCasterType);
    
    		try
    		{
    			while(true)
    			{
    				vhost = VHostSingleton.getInstance("_defaultVHost_");
    				if (vhost == null)
    				{
    					WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: vhost missing: _defaultVHost_");
    					break;
    				}
    				
    				vhost.startApplicationInstance(applicationName, "_definst_");
    				
    				
    				IApplication application = null;
    				IApplicationInstance appInstance = null;
    				try
    				{
    					
    					application = vhost.getApplication(applicationName);
    					if (application == null)
    						WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: application missing:" + applicationName);
    					else
    						appInstance = application.getAppInstance("_definst_");
    					
    					if (appInstance == null)
    						WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: appInstance missing: _definst_");
    				}
    				catch(Exception e)
    				{	
    				}
    				
    				
    				if (appInstance == null)
    					break;
    				
    				appInstance.startMediaCasterStream(streamName, mediaCasterType);
    				break;
    			}
    		}
    		catch(Exception e)
    		{
    			WMSLoggerFactory.getLogger(null).error("WowzaServerWebService.startMediaCasterStream: "+e.toString());
    		}		
    	}
    
    	public void stopMediaCasterStream(IVHost vhost, String appInstanceStr, String streamName, String mediaCasterType, String applicationName)
    	{
    		WMSLoggerFactory.getLogger(null).info("WowzaServerWebService.startMediaCasterStream: appInstance:"+appInstanceStr+" streamName:"+streamName+" mediaCasterType:"+mediaCasterType);
    
    		try
    		{
    			while(true)
    			{
    				vhost = VHostSingleton.getInstance("_defaultVHost_");
    				if (vhost == null)
    				{
    					WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: vhost missing: _defaultVHost_");
    					break;
    				}
    				
    				IApplication application = null;
    				IApplicationInstance appInstance = null;
    				try
    				{
    					
    					application = vhost.getApplication(applicationName);
    					if (application == null)
    						WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: application missing:" + applicationName);
    					else
    						appInstance = application.getAppInstance("_definst_");
    					
    					if (appInstance == null)
    						WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: appInstance missing: _definst_");
    				}
    				catch(Exception e)
    				{	
    				}
    				
    				
    				if (appInstance == null)
    					break;
    				
    				appInstance.stopMediaCasterStream(streamName);
    				break;
    			}
    		}
    		catch(Exception e)
    		{
    			WMSLoggerFactory.getLogger(null).error("WowzaServerWebService.startMediaCasterStream: "+e.toString());
    		}		
    	}
    }


    For reference here is a photo of what I see in the GUI that does start the stream.
    Last edited by angelfilm; 07-24-2014 at 11:59 AM.

Similar Threads

  1. Rest API available?
    By simone.andrioletti in forum Wowza Streaming Engine REST API
    Replies: 1
    Last Post: 09-24-2014, 03:07 PM
  2. Add a REST Webservice interface to Wowza Media Server
    By sujilsekhar in forum Wowza Streaming Server Java API
    Replies: 1
    Last Post: 04-26-2014, 12:05 AM
  3. Wowza Streaming Engine Manager & REst API
    By gary4gar in forum Wowza Streaming Engine REST API
    Replies: 3
    Last Post: 03-05-2014, 02:52 PM
  4. REST API for interrogating settings like transcoder formats/endpoints
    By piers7 in forum Server Administration Discussion
    Replies: 2
    Last Post: 08-16-2012, 06:58 PM

Posting Permissions

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