Thanks for the quick reply rrlanham.
I’ve tried like this:
- Start Wowza IDE 2, File->New->Wowza Media Server Project.
Project name: starvstreamactionnotify
Package: com.mycompany.wms.streamactionnotify
Name: ModuleMediaStreamActionNotify2
- Past following code into the “ModuleMediaStreamActionNotify2.java” tab window.
package com.mycompany.wms.streamactionnotify;
import com.wowza.wms.amf.AMFPacket;
import com.wowza.wms.application.WMSProperties;
import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.IMediaStreamActionNotify2;
public class ModuleMediaStreamActionNotify2 extends ModuleBase {
public void onStreamCreate(IMediaStream stream) {
getLogger().info("onStreamCreate by: " + stream.getClientId());
IMediaStreamActionNotify2 actionNotify = new StreamListener();
WMSProperties props = stream.getProperties();
synchronized(props)
{
props.put("streamActionNotifier", actionNotify);
}
stream.addClientListener(actionNotify);
}
public void onStreamDestroy(IMediaStream stream) {
getLogger().info("onStreamDestroy by: " + stream.getClientId());
IMediaStreamActionNotify2 actionNotify = null;
WMSProperties props = stream.getProperties();
synchronized(props)
{
actionNotify = (IMediaStreamActionNotify2)stream.getProperties().get("streamActionNotifier");
}
if (actionNotify != null)
{
stream.removeClientListener(actionNotify);
getLogger().info("removeClientListener: "+stream.getSrc());
}
}
class StreamListener implements IMediaStreamActionNotify2
{
public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset)
{
streamName = stream.getName();
getLogger().info("Stream Name: " + streamName);
}
public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket)
{
getLogger().info("onMetaData By: " + stream.getClientId());
}
public void onPauseRaw(IMediaStream stream, boolean isPause, double location)
{
getLogger().info("onPauseRaw By: " + stream.getClientId());
}
public void onSeek(IMediaStream stream, double location)
{
getLogger().info("onSeek");
}
public void onStop(IMediaStream stream)
{
getLogger().info("onStop By: " + stream.getClientId());
}
public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
{
getLogger().info("onUNPublish");
}
public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
{
getLogger().info("onPublish");
}
public void onPause(IMediaStream stream, boolean isPause, double location)
{
getLogger().info("onPause");
}
}
}
-
Ctrl+S, then the IDE create a file named ‘starvstreamactionnotify.jar’ into ‘[install-dir]/lib/’.
-
create folder ‘[install-dir]/conf/starvstreamactionnotify’, and copy 'Application.xml under ‘[install-dir]/conf’ into the new folder.
-
Add this module entry as the last entry in the list in my new copied Application.xml file:
<Module>
<Name>ModuleMediaStreamActionNotify2</Name>
<Description>ModuleMediaStreamActionNotify2</Description>
<Class>com.mycompany.wms.streamactionnotify</Class>
</Module>
After these, I restart Wowza Media Server 2, and watching a media stream for serveral minutes. I can see the log infomation by Wowza self outputed on the Wowza Media Server 2 window such as:
…
INFO stream create - -
…
…
INFO stream play vlc.sdp -
…
…
INFO stream stop vlc.sdp -
INFO stream destroy vlc.sdp -
…
But I can’t find any infomation that should be display such as ‘onStreamCreate by:’ defined in onStreamCreate funciton or ‘onStop by:’ defined in onStop function.
Any step error? please help me