Monitor and control connections made via MediaCaster with the Wowza Streaming Engine Java API

The ModuleMediaCasterNotifyExample module for the Wowza Streaming Engine™ Java API adds an event listener to MediaCaster requests, providing an opportunity to monitor and control connections made via the MediaCaster system.

Code example


package com.wowza.wms.example.module;

import com.wowza.wms.application.*;
import com.wowza.wms.mediacaster.IMediaCaster;
import com.wowza.wms.mediacaster.IMediaCasterNotify2;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.IMediaStreamPlay;

public class ModuleMediaCasterNotifyExample extends ModuleBase {

	public void onAppStart(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		getLogger().info("onAppStart: " + fullname);
		appInstance.addMediaCasterListener(new mediacasterNotify());
	}

	public void onAppStop(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		getLogger().info("onAppStop: " + fullname);
	}

	class mediacasterNotify implements  IMediaCasterNotify2
	{

		public void onConnectFailure(IMediaCaster mediaCaster) {

			getLogger().info("onConnectFailure");
		}

		public void onConnectStart(IMediaCaster mediaCaster) {

			getLogger().info("onConnectStart");

		}

		public void onConnectSuccess(IMediaCaster mediaCaster) {

			getLogger().info("onConnectSuccess");
		}

		public void onStreamStart(IMediaCaster mediaCaster) {

			getLogger().info("onStreamStart");
		}

		public void onStreamStop(IMediaCaster mediaCaster) {

			getLogger().info("onStreamStop");
		}

		public void onMediaCasterCreate(IMediaCaster mediaCaster) {

			getLogger().info("onMediaCasterCreate");
		}

		public void onMediaCasterDestroy(IMediaCaster mediaCaster) {

			getLogger().info("onMediaCasterDestroy");
		}

		public void onRegisterPlayer(IMediaCaster mediaCaster,
				IMediaStreamPlay player) {

			getLogger().info("onRegisterPlayer");
		}

		public void onSetSourceStream(IMediaCaster mediaCaster,
				IMediaStream stream) {

			getLogger().info("onSetSourceStream");
		}

		public void onUnRegisterPlayer(IMediaCaster mediaCaster,
				IMediaStreamPlay player) {

			getLogger().info("onUnRegisterPlayer");
		}

	}

}

Use the module


Use the ModuleMediaCasterNotifyExample module with the live application. To install and configure the module, do the following:

  1. Compile the above code and then copy the .jar file to the [install-dir]/lib/ folder.
  2. Create an application folder named [install-dir]/applications/live.
  3. Create a configuration folder [install-dir]/conf/live and copy [install-dir]/conf/Application.xml to this new folder.
  4. Open [install-dir]/conf/live/Application.xml in a text editor then specify the StreamType as live.
  5. Add the following module definition as the last entry in the <Modules> list:
    <Module>
         <Name>ModuleMediaCasterNotifyExample</Name>
         <Description>ModuleMediaCasterNotifyExample</Description>
         <Class>com.wowza.wms.example.module.ModuleMediaCasterNotifyExample</Class>
    </Module>
  6. Restart Wowza Streaming Engine if it was running.