• How to use ModuleFCSubscribe (to send FCSubscribe to CDN)

    Note: This functionality is now built into Wowza Media Server 2.

    Some client side code that is intended for use in a CDN environment (such as the Open Video Player) require an implemenation of FCSubscribe to work properly. This module is a quick and dirty implementation of this server side method:

    Code:
    package com.wowza.wms.plugin.test.module;
    
    import com.wowza.wms.amf.*;
    import com.wowza.wms.client.*;
    import com.wowza.wms.request.*;
    import com.wowza.wms.response.*;
    import com.wowza.wms.module.*;
    import com.wowza.wms.stream.*;
    
    public class ModuleFCSubscribe extends ModuleBase
    {
    	public void FCSubscribe(IClient client, RequestFunction function, AMFDataList params)
    	{
    		String streamName = params.getString(PARAM1);
    		
    		IMediaStream stream = null;
    		if (streamName != null)
    			stream = client.getAppInstance().getStreams().getStream(streamName);
    		
    		String responseCode = (stream == null)?"NetStream.Play.StreamNotFound":"NetStream.Play.Start";
    		
    		AMFDataObj data = null;
    		ResponseFunction resp = null;
    		ResponseFunctions respFunctions = client.getRespFunctions();
    		double clientID = client.getClientId();
    
    		resp = new ResponseFunction(client);
    		resp.createDefaultMessage("onFCSubscribe", 0.0);
    		
    		data = new AMFDataObj();
    		data.put("level", new AMFDataItem("status"));
    		data.put("code", new AMFDataItem(responseCode));
    		data.put("clientid", new AMFDataItem((double)clientID));
    		resp.addBody(data);
    
    		respFunctions.add(resp);
    	}
    
    }
    Use the Wowza IDE to compile this into a module then add the following <Module> as the last entry in the <Modules> list.

    Code:
    <Module>
    	<Name>ModuleFCSubscribe</Name>
    	<Description>ModuleFCSubscribe</Description>
    	<Class>com.wowza.wms.plugin.test.module.ModuleFCSubscribe</Class>
    </Module>
    A compiled version of this module is included in a collection of utility modules that you can download here:
    http://www.wowzamedia.com/forums/content.php?113