Results 1 to 3 of 3

Thread: one stream per ip address?

  1. #1
    Join Date
    Apr 2010
    Posts
    4

    Default one stream per ip address?

    is there any way to keep a viewer from streaming multiple videos simultaneously? i just noticed someone was streaming 10-12 videos all at the same time all on the same account/ip address (no reason to do that unless they're ripping the videos with a software) and im trying to keep that from happening

  2. #2

    Default

    you would need to write a module to not allow new connections if the IP is already connected.

    Quite simple to do, but a little time consuming.

  3. #3
    Join Date
    Dec 2007
    Posts
    25,690

    Default

    You could do something like this:

    client-side when you connect pass a username:
    Code:
    netconnection.connect("rtmp://[wowza-address]:1935/vod","joeuser");
    Then using onConnect, play, and the IMediaStreamActionNotify onStop event, do something like this:
    Code:
    package com.wowza.wms.example.module;
    
    import com.wowza.wms.amf.*;
    import com.wowza.wms.client.*;
    import com.wowza.wms.module.*;
    import com.wowza.wms.request.*;
    import com.wowza.wms.amf.AMFPacket;
    import com.wowza.wms.application.WMSProperties;
    import com.wowza.wms.stream.IMediaStream;
    import com.wowza.wms.stream.IMediaStreamActionNotify2;
    
    public class T2 extends ModuleBase {
    	
    	public void onConnect(IClient client,  RequestFunction function, AMFDataList params)
    	{
    		String userName = getParamString(params, PARAM1);
    		
    		client.getProperties().setProperty("username", "");
    	}
    	
    	public void play(IClient client, RequestFunction function,
    	        AMFDataList params) {
    		getLogger().info("Overriding Play");
    		
    		String playing = client.getProperties().getPropertyStr("username");
    		
    		if (playing.equals(""))
    		{
    		ModuleCore.play(client, function, params);
    		client.getProperties().setProperty("username", "playing");
    		}
    	}
    
    	
    	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());
    			stream.getClient().getProperties().setProperty("username", "");
    		}
    		
    		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");
    		}
    	}
    
    }
    Richard

Posting Permissions

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