com.wowza.wms.module
Class ModuleBase

Object
  extended by com.wowza.wms.module.ModuleBase
Direct Known Subclasses:
ModuleClientLogging, ModuleCore, ModuleFastPlay, ModuleMediaCaster, ModuleMediaCasterStreamMonitorAdvanced, ModuleProperties

public abstract class ModuleBase
extends Object

ModuleBase: Base class that all server side modules should extends. Provides basic utility functionality for handling function parameters and return data. Also provides a simplified API for logging.


Field Summary
static int CALLBACK_PARAM1
          Callback param: param1
static int CALLBACK_PARAM10
          Callback param: param10
static int CALLBACK_PARAM2
          Callback param: param2
static int CALLBACK_PARAM3
          Callback param: param3
static int CALLBACK_PARAM4
          Callback param: param4
static int CALLBACK_PARAM5
          Callback param: param5
static int CALLBACK_PARAM6
          Callback param: param6
static int CALLBACK_PARAM7
          Callback param: param7
static int CALLBACK_PARAM8
          Callback param: param8
static int CALLBACK_PARAM9
          Callback param: param9
static int PARAM1
          Method param: param1
static int PARAM10
          Method param: param10
static int PARAM2
          Method param: param2
static int PARAM3
          Method param: param3
static int PARAM4
          Method param: param4
static int PARAM5
          Method param: param5
static int PARAM6
          Method param: param6
static int PARAM7
          Method param: param7
static int PARAM8
          Method param: param8
static int PARAM9
          Method param: param9
static int PARAMMETHODNAME
          Method: method name
static int PLAYTRANSITION_APPEND
           
static int PLAYTRANSITION_APPEND_IMMEDIATE
           
static int PLAYTRANSITION_RESET
           
static int PLAYTRANSITION_RESET_IMMEDIATE
           
static int PLAYTRANSITION_STOP
           
static int PLAYTRANSITION_SWAP
           
static int PLAYTRANSITION_SWITCH
           
static int PLAYTRANSITION_UNKNOWN
           
static String PLAYTRANSITIONSTR_APPEND
          Play2 transition: APPEND
static String PLAYTRANSITIONSTR_RESET
          Play2 transition: RESET
static String PLAYTRANSITIONSTR_STOP
          Play2 transition: STOP
static String PLAYTRANSITIONSTR_SWAP
          Play2 transition: SWAP
static String PLAYTRANSITIONSTR_SWITCH
          Play2 transition: SWITCH
static String PLAYTRANSITIONSTR_UNKNOWN
          Play2 transition: UNKNOWN
 
Constructor Summary
ModuleBase()
           
 
Method Summary
protected static IApplicationInstance getAppInstance(IClient client)
          Get applicationInstace of a client.
protected static IApplication getApplication(IClient client)
          Get application of a client.
protected static int getCallbackParamCount(AMFDataList params)
          Get the total number of parameters passed to callback.
protected static WMSLogger getLogger()
          Get the logging interface.
protected static AMFData getParam(AMFDataList params, int index)
          Get parameter by index.
protected static boolean getParamBoolean(AMFDataList params, int index)
          Get parameter by index, Return as boolean.
protected static boolean getParamBoolean(AMFDataList params, int index, boolean defaultVal)
          Get parameter by index, Return as boolean.
protected static int getParamCount(AMFDataList params)
          Get the total number of parameters passed to method.
protected static java.util.Date getParamDate(AMFDataList params, int index)
          Get parameter by index, Return as Date.
protected static double getParamDouble(AMFDataList params, int index)
          Get parameter by index, Return as double.
protected static double getParamDouble(AMFDataList params, int index, double defaultVal)
          Get parameter by index, Return as double.
protected static int getParamInt(AMFDataList params, int index)
          Get parameter by index, Return as int.
protected static int getParamInt(AMFDataList params, int index, int defaultVal)
          Get parameter by index, Return as int.
protected static long getParamLong(AMFDataList params, int index)
          Get parameter by index, Return as long.
protected static long getParamLong(AMFDataList params, int index, long defaultVal)
          Get parameter by index, Return as long.
protected static AMFDataMixedArray getParamMixedArray(AMFDataList params, int index)
          Get parameter by index, Return as AMFDataMixedArray.
protected static AMFDataObj getParamObj(AMFDataList params, int index)
          Get parameter by index, Return as Object.
protected static String getParamString(AMFDataList params, int index)
          Get parameter by index, Return as String.
protected static String getParamString(AMFDataList params, int index, String defaultVal)
          Get parameter by index, Return as String.
protected static int getParamType(AMFDataList params, int index)
          Get parameter type.
protected static IMediaStream getStream(IClient client, com.wowza.wms.request.RequestFunction function)
          For methods called from the client side object NetStream (publish, play, deleteStream) get the IMediaStream object associated with the call.
protected static IVHost getVHost(IClient client)
          Get vHost of a client.
protected  void invokePrevious(IClient client, com.wowza.wms.request.RequestFunction function, AMFDataList params)
          Wowza Pro will determine command priority based on the order of the modules in the module list.
protected static void invokePrevious(Object instance, IClient client, com.wowza.wms.request.RequestFunction function, AMFDataList params)
          Wowza Pro will determine command priority based on the order of the modules in the module list.
protected static boolean isSendResult(AMFDataList params)
          Is this method call expecting sendResult to be called.
protected static void sendClientOnStatusError(IClient client, String code, String description)
          Send an error message to the client-side client.onStatus handler
protected static boolean sendResult(IClient client, AMFDataList params, AMFData data)
          Send a result to client method call as a AMFData object.
protected static boolean sendResult(IClient client, AMFDataList params, boolean value)
          Send a result to client method call as a single boolean value.
protected static boolean sendResult(IClient client, AMFDataList params, double value)
          Send a result to client method call as a single boolean value.
protected static boolean sendResult(IClient client, AMFDataList params, int value)
          Send a result to client method call as a single int value.
protected static boolean sendResult(IClient client, AMFDataList params, String value)
          Send a result to client method call as a single String value.
protected static void sendStreamOnStatusError(IMediaStream stream, String code, String description)
          Send an error to the client-side NetStream.onStatus handler
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CALLBACK_PARAM1

public static final int CALLBACK_PARAM1
Callback param: param1

See Also:
Constant Field Values

CALLBACK_PARAM10

public static final int CALLBACK_PARAM10
Callback param: param10

See Also:
Constant Field Values

CALLBACK_PARAM2

public static final int CALLBACK_PARAM2
Callback param: param2

See Also:
Constant Field Values

CALLBACK_PARAM3

public static final int CALLBACK_PARAM3
Callback param: param3

See Also:
Constant Field Values

CALLBACK_PARAM4

public static final int CALLBACK_PARAM4
Callback param: param4

See Also:
Constant Field Values

CALLBACK_PARAM5

public static final int CALLBACK_PARAM5
Callback param: param5

See Also:
Constant Field Values

CALLBACK_PARAM6

public static final int CALLBACK_PARAM6
Callback param: param6

See Also:
Constant Field Values

CALLBACK_PARAM7

public static final int CALLBACK_PARAM7
Callback param: param7

See Also:
Constant Field Values

CALLBACK_PARAM8

public static final int CALLBACK_PARAM8
Callback param: param8

See Also:
Constant Field Values

CALLBACK_PARAM9

public static final int CALLBACK_PARAM9
Callback param: param9

See Also:
Constant Field Values

PARAM1

public static final int PARAM1
Method param: param1

See Also:
Constant Field Values

PARAM10

public static final int PARAM10
Method param: param10

See Also:
Constant Field Values

PARAM2

public static final int PARAM2
Method param: param2

See Also:
Constant Field Values

PARAM3

public static final int PARAM3
Method param: param3

See Also:
Constant Field Values

PARAM4

public static final int PARAM4
Method param: param4

See Also:
Constant Field Values

PARAM5

public static final int PARAM5
Method param: param5

See Also:
Constant Field Values

PARAM6

public static final int PARAM6
Method param: param6

See Also:
Constant Field Values

PARAM7

public static final int PARAM7
Method param: param7

See Also:
Constant Field Values

PARAM8

public static final int PARAM8
Method param: param8

See Also:
Constant Field Values

PARAM9

public static final int PARAM9
Method param: param9

See Also:
Constant Field Values

PARAMMETHODNAME

public static final int PARAMMETHODNAME
Method: method name

See Also:
Constant Field Values

PLAYTRANSITION_APPEND

public static final int PLAYTRANSITION_APPEND
See Also:
Constant Field Values

PLAYTRANSITION_APPEND_IMMEDIATE

public static final int PLAYTRANSITION_APPEND_IMMEDIATE
See Also:
Constant Field Values

PLAYTRANSITION_RESET

public static final int PLAYTRANSITION_RESET
See Also:
Constant Field Values

PLAYTRANSITION_RESET_IMMEDIATE

public static final int PLAYTRANSITION_RESET_IMMEDIATE
See Also:
Constant Field Values

PLAYTRANSITION_STOP

public static final int PLAYTRANSITION_STOP
See Also:
Constant Field Values

PLAYTRANSITION_SWAP

public static final int PLAYTRANSITION_SWAP
See Also:
Constant Field Values

PLAYTRANSITION_SWITCH

public static final int PLAYTRANSITION_SWITCH
See Also:
Constant Field Values

PLAYTRANSITION_UNKNOWN

public static final int PLAYTRANSITION_UNKNOWN
See Also:
Constant Field Values

PLAYTRANSITIONSTR_APPEND

public static final String PLAYTRANSITIONSTR_APPEND
Play2 transition: APPEND

See Also:
Constant Field Values

PLAYTRANSITIONSTR_RESET

public static final String PLAYTRANSITIONSTR_RESET
Play2 transition: RESET

See Also:
Constant Field Values

PLAYTRANSITIONSTR_STOP

public static final String PLAYTRANSITIONSTR_STOP
Play2 transition: STOP

See Also:
Constant Field Values

PLAYTRANSITIONSTR_SWAP

public static final String PLAYTRANSITIONSTR_SWAP
Play2 transition: SWAP

See Also:
Constant Field Values

PLAYTRANSITIONSTR_SWITCH

public static final String PLAYTRANSITIONSTR_SWITCH
Play2 transition: SWITCH

See Also:
Constant Field Values

PLAYTRANSITIONSTR_UNKNOWN

public static final String PLAYTRANSITIONSTR_UNKNOWN
Play2 transition: UNKNOWN

See Also:
Constant Field Values
Constructor Detail

ModuleBase

public ModuleBase()
Method Detail

getAppInstance

protected static IApplicationInstance getAppInstance(IClient client)
Get applicationInstace of a client.

Parameters:
client - client
Returns:
applicationInstance

getApplication

protected static IApplication getApplication(IClient client)
Get application of a client.

Parameters:
client - client
Returns:
application

getCallbackParamCount

protected static int getCallbackParamCount(AMFDataList params)
Get the total number of parameters passed to callback.

Parameters:
params - parameters
Returns:
total number of parameters

getLogger

protected static WMSLogger getLogger()
Get the logging interface.

See Also:
WMSLogger

getParam

protected static AMFData getParam(AMFDataList params,
                                  int index)
Get parameter by index. Return as AMFData object.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as AMFData object, null if out of bounds

getParamBoolean

protected static boolean getParamBoolean(AMFDataList params,
                                         int index)
Get parameter by index, Return as boolean.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as boolean, false if out of bounds

getParamBoolean

protected static boolean getParamBoolean(AMFDataList params,
                                         int index,
                                         boolean defaultVal)
Get parameter by index, Return as boolean.

Parameters:
params - parameters
index - parameter index
defaultVal - default value
Returns:
parameter value as boolean, defaultVal if out of bounds

getParamCount

protected static int getParamCount(AMFDataList params)
Get the total number of parameters passed to method.

Parameters:
params - parameters
Returns:
total number of parameters

getParamDate

protected static java.util.Date getParamDate(AMFDataList params,
                                             int index)
Get parameter by index, Return as Date.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as Date object, null if out of bounds

getParamDouble

protected static double getParamDouble(AMFDataList params,
                                       int index)
Get parameter by index, Return as double.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as double, 0 if out of bounds

getParamDouble

protected static double getParamDouble(AMFDataList params,
                                       int index,
                                       double defaultVal)
Get parameter by index, Return as double.

Parameters:
params - parameters
index - parameter index
defaultVal - default value
Returns:
parameter value as double, 0 if out of bounds

getParamInt

protected static int getParamInt(AMFDataList params,
                                 int index)
Get parameter by index, Return as int.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as int, 0 if out of bounds

getParamInt

protected static int getParamInt(AMFDataList params,
                                 int index,
                                 int defaultVal)
Get parameter by index, Return as int.

Parameters:
params - parameters
index - parameter index
defaultVal - default value
Returns:
parameter value as int, defaultVal if out of bounds

getParamLong

protected static long getParamLong(AMFDataList params,
                                   int index)
Get parameter by index, Return as long.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as long, 0 if out of bounds

getParamLong

protected static long getParamLong(AMFDataList params,
                                   int index,
                                   long defaultVal)
Get parameter by index, Return as long.

Parameters:
params - parameters
index - parameter index
defaultVal - default value
Returns:
parameter value as long, defaultVal if out of bounds

getParamMixedArray

protected static AMFDataMixedArray getParamMixedArray(AMFDataList params,
                                                      int index)
Get parameter by index, Return as AMFDataMixedArray.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as AMFDataMixedArray object, null if out of bounds

getParamObj

protected static AMFDataObj getParamObj(AMFDataList params,
                                        int index)
Get parameter by index, Return as Object.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as Object object, null if out of bounds

getParamString

protected static String getParamString(AMFDataList params,
                                       int index)
Get parameter by index, Return as String.

Parameters:
params - parameters
index - parameter index
Returns:
parameter value as String object, null if out of bounds

getParamString

protected static String getParamString(AMFDataList params,
                                       int index,
                                       String defaultVal)
Get parameter by index, Return as String.

Parameters:
params - parameters
index - parameter index
defaultVal - default value
Returns:
parameter value as String object, defaultVal if out of bounds

getParamType

protected static int getParamType(AMFDataList params,
                                  int index)
Get parameter type.

Parameters:
params - parameters
index - parameter index
Returns:
parameter type (AMFData.DATA_TYPE_*)

getStream

protected static IMediaStream getStream(IClient client,
                                        com.wowza.wms.request.RequestFunction function)
For methods called from the client side object NetStream (publish, play, deleteStream) get the IMediaStream object associated with the call.

Parameters:
client - client
function - functions
Returns:
media stream

getVHost

protected static IVHost getVHost(IClient client)
Get vHost of a client.

Parameters:
client - client
Returns:
vHost

invokePrevious

protected void invokePrevious(IClient client,
                              com.wowza.wms.request.RequestFunction function,
                              AMFDataList params)
Wowza Pro will determine command priority based on the order of the modules in the module list. Wowza Pro by default will only invoke the last module that defines a given command. This method enables you to call the method by the same name in the previous module that defines that command. For example if you have three modules defined in the module list; ModuleCore, ModuleSecureURLParams and ModuleMyModule and all three modules implement the "play" command. When "play" is invoked it will invoke the "play" command in ModuleMyModule. If in ModuleMyModule you would like to call the "play" command in ModuleSecureURLParams, you can call: this.invokePrevious(client, function, params); and it will invoke the "play" command defined in ModuleSecureURLParams.

Parameters:
client - client object passed into command
function - function passed into command
params - parameters passed into command

invokePrevious

protected static void invokePrevious(Object instance,
                                     IClient client,
                                     com.wowza.wms.request.RequestFunction function,
                                     AMFDataList params)
Wowza Pro will determine command priority based on the order of the modules in the module list. Wowza Pro by default will only invoke the last module that defines a given command. This method enables you to call the method by the same name in the previous module that defines that command. For example if you have three modules defined in the module list; ModuleCore, ModuleSecureURLParams and ModuleMyModule and all three modules implement the "play" command. When "play" is invoked it will invoke the "play" command in ModuleMyModule. If in ModuleMyModule you would like to call the "play" command in ModuleSecureURLParams, you can call: invokePrevious(this, client, function, params); and it will invoke the "play" command defined in ModuleSecureURLParams.

Parameters:
instance - instance of the current module
client - client object passed into command
function - function passed into command
params - parameters passed into command

isSendResult

protected static boolean isSendResult(AMFDataList params)
Is this method call expecting sendResult to be called. If on the client side the call to NetConnection.call("handlerName", resultObj, param1...); had a value for resultObj (non-null), then the method is expecting some type of result or return data. Calling a variant of sendResult will provide this callback.

Parameters:
params - parameters
Returns:
true if client side call is expecting call to sendResult

sendClientOnStatusError

protected static void sendClientOnStatusError(IClient client,
                                              String code,
                                              String description)
Send an error message to the client-side client.onStatus handler

Parameters:
client - destination client
code - code
description - description

sendResult

protected static boolean sendResult(IClient client,
                                    AMFDataList params,
                                    AMFData data)
Send a result to client method call as a AMFData object. This can be a single AMFData value like new AMFDataItem((double)1.234) or a complex type like AMFDataMixedArray, AMFDataArray or AMFDataObj.

Parameters:
client - client
params - parameters
data - return value
Returns:
true if client side call is expecting call to sendResult

sendResult

protected static boolean sendResult(IClient client,
                                    AMFDataList params,
                                    boolean value)
Send a result to client method call as a single boolean value.

Parameters:
client - client
params - parameters
value - return value
Returns:
true if client side call is expecting call to sendResult

sendResult

protected static boolean sendResult(IClient client,
                                    AMFDataList params,
                                    double value)
Send a result to client method call as a single boolean value.

Parameters:
client - client
params - parameters
value - return value
Returns:
true if client side call is expecting call to sendResult

sendResult

protected static boolean sendResult(IClient client,
                                    AMFDataList params,
                                    int value)
Send a result to client method call as a single int value.

Parameters:
client - client
params - parameters
value - return value
Returns:
true if client side call is expecting call to sendResult

sendResult

protected static boolean sendResult(IClient client,
                                    AMFDataList params,
                                    String value)
Send a result to client method call as a single String value.

Parameters:
client - client
params - parameters
value - return value
Returns:
true if client side call is expecting call to sendResult

sendStreamOnStatusError

protected static void sendStreamOnStatusError(IMediaStream stream,
                                              String code,
                                              String description)
Send an error to the client-side NetStream.onStatus handler

Parameters:
stream - destination stream
code - code
description - description