Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Problem with Stream Listener

  1. #1

    Default Problem with Stream Listener

    Hi !
    I am creating a new Module to Wowza, and i need use Listener Stream, but by some reason the events aren't called when start play video or stop.
    I added Module in Application.xml of my Application and i debbuged my code and saw that class is being calling, but events not

    Please, help me.
    My Code:

    package com.movile.wowza.session.user;
    
    import com.wowza.wms.application.*;
    import com.wowza.wms.amf.*;
    import com.wowza.wms.client.*;
    import com.wowza.wms.media.model.MediaCodecInfoAudio;
    import com.wowza.wms.media.model.MediaCodecInfoVideo;
    import com.wowza.wms.module.*;
    import com.wowza.wms.request.*;
    import com.wowza.wms.stream.*;
    import com.wowza.wms.rtp.model.*;
    import com.wowza.wms.httpstreamer.model.*;
    import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
    import com.wowza.wms.httpstreamer.smoothstreaming.httpstreamer.*;
    
    public class SessionUser extends ModuleBase {
    
        public void doSomething(IClient client, RequestFunction function, AMFDataList params) {
            getLogger().info("doSomething");
            sendResult(client, params, "Hello Wowza");
        }
    
        public void onAppStart(IApplicationInstance appInstance) {
            String fullname = appInstance.getApplication().getName() + "/" + appInstance.getName();
            getLogger().info("onAppStart: " + fullname);
        }
    
        public void onAppStop(IApplicationInstance appInstance) {
            String fullname = appInstance.getApplication().getName() + "/" + appInstance.getName();
            getLogger().info("onAppStop: " + fullname);
        }
    
        public void onConnect(IClient client, RequestFunction function, AMFDataList params) {
            getLogger().info("onConnect: " + client.getClientId());
        }
    
        public void onConnectAccept(IClient client) {
            getLogger().info("onConnectAccept: " + client.getClientId());
        }
    
        public void onConnectReject(IClient client) {
            getLogger().info("onConnectReject: " + client.getClientId());
        }
    
        public void onDisconnect(IClient client) {
            getLogger().info("onDisconnect: " + client.getClientId());
        }
    
        public void onStreamCreate(IMediaStream stream) {
            getLogger().info("onStreamCreate: " + stream.getSrc());
            
            IMediaStreamActionNotify2 actionNotify = new StreamListener();
            //StreamListener actionNotify = new StreamListener();
            WMSProperties props = stream.getProperties();
            synchronized (props)
            {
                    props.put("streamActionNotifier", actionNotify);
            }
            stream.addClientListener(actionNotify);
            
        }
    
        public void onStreamDestroy(IMediaStream stream) {
            getLogger().info("onStreamDestroy: " + stream.getSrc());
            
            
            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());
            }
        }
    
        public void onHTTPSessionCreate(IHTTPStreamerSession httpSession) {
            getLogger().info("onHTTPSessionCreate: " + httpSession.getSessionId());
            System.out.println("Query String Create " + httpSession.getQueryStr());
            //httpSession.setPlayStart(20000);
        }
    
        public void onHTTPSessionDestroy(IHTTPStreamerSession httpSession) {
            getLogger().info("onHTTPSessionDestroy: " + httpSession.getSessionId());
        }
        
        class StreamListener implements IMediaStreamActionNotify2
        {
    
            @Override
            public void onPause(IMediaStream stream, boolean isPause, double location) {
                System.out.println("onPause");
                
            }
    
            @Override
            public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset) {
    
                System.out.println("onPlay");
                
            }
    
            @Override
            public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
                
                System.out.println("onPublish");
                
            }
    
            @Override
            public void onSeek(IMediaStream stream, double location) {
    
                
                
            }
    
            @Override
            public void onStop(IMediaStream stream) {
    
                System.out.println("onStop");
                
            }
    
            @Override
            public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
                // TODO Auto-generated method stub
                
            }
    
            @Override
            public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket) {
                // TODO Auto-generated method stub
                
            }
    
            @Override
            public void onPauseRaw(IMediaStream stream, boolean isPause, double location) {
                // TODO Auto-generated method stub
                
            }
    
            
                
        }
        
        
        
    
    }

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

    Default

    Are you running Wowza in stand-alone (/bin/startup.bat) mode? Because that is the only way to see System.out.println() output. To see trace of these events in the logs, use getLogger():

    getLogger().info("onPlay");
    Richard

  3. #3

    Default

    thanks rrlanham!
    I put this line in my code, but not works yet.
    I put breakpoints inside events (onPlay, onStop) and when play video the event is not called. Other events like onStreamCreate works fine!
    Do you know what can be?

    Thanks!

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

    Default

    What encoder are you using? This works with RTMP live stream from encoder like Wirecast or FMLE, or a Flash application.

    Richard

  5. #5

    Default

    Said well! If i play video using RTSP the events works! But HLS doesn't works, this is correct?

    Are there some way to listen events of play and stop using HLS?

    I am using ffplay to test
    RTSP: rtsp://localhost:1935/sessiontest/mp4:sample.mp4 (Ok)
    HLS: http://localhost:1935/sessiontest/mp.../playlist.m3u8 (not works)

    Thanks Richard!

  6. #6

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

    Default

    No, it doesn't work for HLS, cupertinostreaming

    Richard

  8. #8

    Default

    Last question Richard.

    Are there some way to listen events of play and stop using HLS?

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

    Default

    Yes:

    package com.wowza.wms.example.module;
    
    import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
    import com.wowza.wms.module.*;
    import com.wowza.wms.application.*;
    
    public class ModuleAccessControlHTTPStreaming extends ModuleBase
    {
    	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
    	{
    		boolean isGood = true;
    		
    		String ipAddressClient = httpSession.getIpAddress();
    		String ipAddressServer = httpSession.getServerIp();
    		String queryStr = httpSession.getQueryStr();
    		String referrer = httpSession.getReferrer();
    		String cookieStr = httpSession.getCookieStr();
    		String userAgent = httpSession.getUserAgent();
    		
    		IApplicationInstance appInstance = httpSession.getAppInstance();
    		String streamName = httpSession.getStreamName();
    		
    		// Here you can use the request and session information above to determine 
    		// if you want to reject the connection
    		// isGood = true/false;
    		
    		getLogger().info("ModuleAccessControlHTTPStreaming.onHTTPSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);
    		
    		if (!isGood)
    			httpSession.rejectSession();
    	}
    
    public void onHTTPSessionDestroy(IHTTPStreamerSession httpSession)
    	{
    
    	}
    
    }
    Richard

  10. #10

    Default

    Richard,
    My objetive is have the time that user watched a video.
    Example: User richard watched a video during 43 seconds.

    For this, i had planned create a object Date into OnPlay Event, and to create other object in OnStop Event, after, i would take the difference between.
    onHTTPSessionDestroy is called some seconds after that video stop, so dont works for my problem.

    Sorry my english richard.

    Thanks for help.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 02-04-2013, 09:40 PM
  2. Listener: stream came to Wowza
    By Alex B in forum Live Streaming and Encoder Discussion
    Replies: 10
    Last Post: 03-26-2012, 04:53 AM
  3. Server Listener Stream Publish module (java error, should I be concerned?)
    By stefancaunter in forum Live Streaming and Encoder Discussion
    Replies: 3
    Last Post: 10-11-2011, 06:28 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
  •