Results 1 to 3 of 3

Thread: onMetaData event not triggered.

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Default onMetaData event not triggered.

    I can capture all other events but not the injection of metadata. I am certain that the metadata is passed , since the flex AS3 viewer(developed in house) that displays this stream is able to read the metadata from the stream. Here is my module:

    import com.wowza.wms.application.WMSProperties;
    import com.wowza.wms.module.*;
    import com.wowza.wms.stream.IMediaStream;
    import com.wowza.wms.stream.IMediaStreamActionNotify2;
    
    public class ModuleStreamStats extends ModuleBase {
    
    	public void onStreamCreate(IMediaStream stream) {
    		getLogger().info("MODULE STREAM STATS 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("MODULE STREAM STATS 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("MODULE STREAM STATS removeClientListener: "+stream.getSrc());
    		}
    	}
    }
    --------------------------------------------------------

    import com.xxxxxx.util.MetadataPropertyUtil;
    import com.wowza.util.IOPerformanceCounter;
    import com.wowza.wms.amf.AMFPacket;
    import com.wowza.wms.application.IApplicationInstance;
    import com.wowza.wms.logging.WMSLoggerFactory;
    import com.wowza.wms.stream.IMediaStream;
    import com.wowza.wms.stream.IMediaStreamActionNotify2;
    
    import java.io.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Timer;
    import java.util.TimerTask;
    
    /**
     * Created by IntelliJ IDEA.
     * User: u0107567
     * Date: 1/17/12
     * Time: 3:06 PM
     * To change this template use File | Settings | File Templates.
     */
    public class StreamListener implements IMediaStreamActionNotify2 {
    
        private static String SYNCH_EVENT_LOG_FILE_DIRECTORY = MetadataPropertyUtil.getInstance().getProperty("synch.event.log.file.directory", "c:/temp/pptSynchEvents");
    
        public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset) {
            streamName = stream.getName();
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS Stream Name: " + streamName);
        }
    
        public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket) {
            WMSLoggerFactory.getLogger(null).info("-------------------------------------------------------");
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS INSIDE ON META DATA.......");
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS MetaData By: " + stream.getClientId());
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS MetaDataProvider: " + stream.getMetaDataProvider());
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS MetaDataContent: " + metaDataPacket.getData().toString());
            WMSLoggerFactory.getLogger(null).info("-------------------------------------------------------");
    
            try{
                Date eventDate = new Date();
    
                writeSynchEventToFile(stream.getName(), "Ani Trial", metaDataPacket.getData().toString(),
                        Math.round(stream.getElapsedTime().getTime()), eventDate);
    
                WMSLoggerFactory.getLogger(null).debug("MODULE STREAM STATS writeSynchEventToFileAndDatabase() - Stream: "
                        + stream.getName() + ", Course Id: Ani Trial Course "
                        + ", Page Number: " + metaDataPacket.getData().toString() + ", Elapsed Time: "
                        + Math.round(stream.getElapsedTime().getTime()) + ", Date/Time: " + eventDate);
            }catch(Exception ex){
                WMSLoggerFactory.getLogger(null).error("MODULE STREAM STATS Unable to write synch event to file", ex);
            }
        }
    
        public void onPauseRaw(IMediaStream stream, boolean isPause, double location) {
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS onPauseRaw By: " + stream.getClientId());
        }
    
        public void onStop(IMediaStream stream) {
            WMSLoggerFactory.getLogger(null).info("MODULE STREAM STATS onStop By: " + stream.getClientId());
        }
    
        public void onSeek(IMediaStream stream, double location) { }
    
        public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) { }
    
        public  void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) { }
    
        public void onPause(IMediaStream stream, boolean isPause, double location){ }
    
        /**
         * Write synch events to local log file (one per course).
         * @param streamName
         * @param courseId
         * @param pageNumber
         * @param elapsedSeconds
         * @param dateTime
         * @throws java.io.IOException
         * @throws java.io.FileNotFoundException
         */
        private void writeSynchEventToFile(String streamName, String courseId, String pageNumber, int elapsedSeconds, Date dateTime)
            throws IOException, FileNotFoundException
        {
    
            final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
    
            // Also Write Out Log to Local File (Failsafe)
            File logDirectory = new File(SYNCH_EVENT_LOG_FILE_DIRECTORY);
            if (!logDirectory.exists())
            {
                logDirectory.mkdirs();
            }
    
            File logFile = new File(logDirectory, "Course" + courseId + ".log");
            BufferedWriter writer = new BufferedWriter(new FileWriter(logFile, true)); // Open in Append Mode
            writer.write(sdf.format(dateTime) + ": To Page " + pageNumber + " @ " + elapsedSeconds + " ms into stream : " + streamName);
            writer.newLine();
            writer.close();
        }
    
    }
    Last edited by deshani; 01-24-2012 at 11:56 AM.

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    Default

    Hi,
    Could someone please look at my code and see what I may be missing? Is there any method in there that is version specific for the WOWZA server?

  3. #3
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Take a look at this example, which shows how to implement IMediaStreamActionNotify2 interface, which includes onMetaData event handler:

    http://www.wowza.com/forums/content....-of-codec-info

    Richard

Similar Threads

  1. WOWZ™ protocol triggered by upgrade to all v3.5
    By rainman in forum General Forum
    Replies: 12
    Last Post: 01-04-2013, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •