ModuleBase class, onStreamCreate and onStreamDestroy Methods

Hi,

I am trying to understand how the Loop Until Live module (https://www.wowza.com/docs/how-to-loop-a-pre-roll-until-a-live-stream-starts-loopuntillive) works, and have several questions. Here’s the first one, and I’m sure there will be many to follow!

I can see that the class extends ModuleBase. I have looked up the ModuleBase class in the documentation and this does not have a onStreamCreate or onStreamDestroy method, so where do these actually get called from?

I see in the documentation there is a IModuleOnStream interface, and this specifies these methods, but this interface is not implemented by the class.

I have pasted the module code here for reference: https://gist.github.com/tjenkinson/cfa42ac2d377bcb5ec26

Thanks!

Hi,

The best place to start is probably the Extending Wowza Streaming Engine Using Java chapter in the User Guide. It gives a fairly high level description of the basic module structure.

When module are loaded for an application, they are parsed and any methods that match known method signatures are registered and event handlers. Later, when the methods need to be called, java reflection is used to call the methods.

The Interfaces in the com.wowza.wms.module package are just there for convenience to list each of the methods. You don’t need to implement the interfaces to use the methods. ModuleBase just contains some static convenience methods that are used with modules. You don’t strictly have to extend ModuleBase if you don’t want to however, you wouldn’t have access to these convenience methods.

ModuleCore is the main top level module that is required for an application to have basic functionality. It should be the first module in the list. You can override any of the methods in ModuleCore and you should use the invokePrevious(client, function, params); method (from ModuleBase) to call the ModuleCore method.

I hope this helps.

Roger.