Results 1 to 8 of 8

Thread: Get Live Stream Name Using Shared Objects

  1. #1

    Default Get Live Stream Name Using Shared Objects

    Hi,
    i have created live video chat app. i could able to chat. but i have done this based on saved file name.due to stream delay now i have to get live stream names and store it in shared objects (example like text chat). i have tried the method they have specified in text chat but its not working for video chat. (In Flash i have to specify like netstream.play("other side chat publish name")). any other idea?
    Last edited by malarprathap; 08-22-2012 at 06:35 AM.

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

    Default

    Use this example as a starting place:

    http://www.wowza.com/forums/content....a-SharedObject

    Then you can add publish command

    public void publish(IClient client, RequestFunction function,
    	        AMFDataList params) {
    		String streamName = getParamString(params, PARAM1);
    		
    		// add SO lines here
    		
    		invokePrevious(client, function, params); //don't remove this line
    	}
    Richard

  3. #3

    Default

    Quote Originally Posted by rrlanham View Post
    Use this example as a starting place:

    http://www.wowza.com/forums/content....a-SharedObject

    Then you can add publish command

    public void publish(IClient client, RequestFunction function,
    	        AMFDataList params) {
    		String streamName = getParamString(params, PARAM1);
    		
    		// add SO lines here
    		
    		invokePrevious(client, function, params); //don't remove this line
    	}
    Richard

    Thanks for your reply.
    i have tried as per the above link

    package com.mips.wms.module;
    
    import com.wowza.wms.application.*;
    import com.wowza.wms.amf.*;
    import com.wowza.wms.client.*;
    import com.wowza.wms.module.*;
    import com.wowza.wms.request.*;
    import com.wowza.wms.sharedobject.ISharedObject;
    import com.wowza.wms.sharedobject.ISharedObjects;
    import com.wowza.wms.sharedobject.SharedObject;
    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 ModuleConnectedUserSO extends ModuleBase {
    
    	static public final String CONNECTEDUSERS_SONAME = "connectedUsersSO";
    	String AppPath;
    	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);
    		AppPath = appInstance.getApplication().getApplicationPath();
    		getLogger().info("onAppStart: ");
    
    		// Create a shared object to keep track of the connected users
    		ISharedObjects sharedObjects = appInstance.getSharedObjects(false);
    		ISharedObject connectedUsersSO = new SharedObject(CONNECTEDUSERS_SONAME);
    		sharedObjects.put(CONNECTEDUSERS_SONAME, connectedUsersSO);
    		
    		connectedUsersSO.lock();	
    		try
    		{
    			connectedUsersSO.acquire();
    		}
    		catch (Exception e)
    		{
    			
    		}
    		finally
    		{
    			connectedUsersSO.unlock();
    		}
    		getLogger().info("onAppStart: create shared object: "+CONNECTEDUSERS_SONAME);
    	}
    
    	public void onAppStop(IApplicationInstance appInstance) {
    		String fullname = appInstance.getApplication().getName() + "/"
    				+ appInstance.getName();
    		getLogger().info("onAppStop: " + fullname);
    		
    		getLogger().info("onAppStop: ");
    
    		// release the shared object when the application stops
    		ISharedObjects sharedObjects = appInstance.getSharedObjects(false);
    		ISharedObject connectedUsersSO = sharedObjects.get(CONNECTEDUSERS_SONAME);
    		if (connectedUsersSO != null)
    		{
    			getLogger().info("onAppStart: release shared object: "+CONNECTEDUSERS_SONAME);
    			connectedUsersSO.lock();
    			try
    			{
    				connectedUsersSO.release();
    			}
    			catch (Exception e)
    			{
    				
    			}
    			finally
    			{
    				connectedUsersSO.unlock();
    			}
    		}
    	}
    
    	public void onConnect(IClient client, RequestFunction function,
    			AMFDataList params) {
    		getLogger().info("onConnect: " + client.getClientId());
    		//userId= getParamString(params,PARAM1);
    	   
    		String userName = getParamString(params, PARAM1);
    		 client.getAppInstance().setStreamStorageDir(AppPath+"/"+userName);
    		String publishName = getParamString(params,PARAM2);
    		client.getProperties().setProperty("userName", userName);
    		client.getProperties().setProperty("publishName", publishName);
    	}
    
    	public void onConnectAccept(IClient client) {
    		getLogger().info("onConnectAccept: " + client.getClientId());
    		// when a client connection is accepted add a property to the shared object
    				// that notifies all connections of new client
    				getLogger().info("onConnectAccept: "+client.getClientId());
    				ISharedObjects sharedObjects = getAppInstance(client).getSharedObjects(false);
    				ISharedObject connectedUsersSO = sharedObjects.get(CONNECTEDUSERS_SONAME);
    				if (connectedUsersSO != null)
    				{
    					connectedUsersSO.lock();
    					try
    					{
    						getLogger().info("onConnectAccept: add property: "+client.getClientId());
    						String userName = client.getProperties().getPropertyStr("userName");
    						String publishName = client.getProperties().getPropertyStr("publishName");
    						String propName = publishName+ ": " + client.getClientId();
    						connectedUsersSO.setProperty(propName, publishName);
    					}
    					catch (Exception e)
    					{
    						
    					}
    					finally
    					{
    						connectedUsersSO.unlock();
    					}
    				}
    	}
    
    	public void onConnectReject(IClient client) {
    		getLogger().info("onConnectReject: " + client.getClientId());
    	}
    
    	public void onDisconnect(IClient client) {
    		getLogger().info("onDisconnect: " + client.getClientId());
    		// When the client is disconnected remove the property from the shared object
    				getLogger().info("onDisconnect: "+client.getClientId());
    				ISharedObjects sharedObjects = getAppInstance(client).getSharedObjects(false);
    				ISharedObject connectedUsersSO = sharedObjects.get(CONNECTEDUSERS_SONAME);
    				if (connectedUsersSO != null)
    				{
    					synchronized(connectedUsersSO)
    					{
    						connectedUsersSO.lock();
    						try
    						{
    							getLogger().info("onDisconnect: remove property: "+client.getClientId());
    							String propName = "c"+client.getClientId();
    							connectedUsersSO.deleteSlot(propName);
    							connectedUsersSO.purge(connectedUsersSO.getVersion()-1);
    						}
    						catch (Exception e)
    						{
    							
    						}
    						finally
    						{
    							connectedUsersSO.unlock();
    						}
    					}
    				}
    	}
    
    }
    in flash side i have used

    netConnection.connect(connectionUrl+"/"+MeetingId,MeetingId,publishName);
    netConnection.addEventListener (NetStatusEvent.NET_STATUS,checkForConnection);
    function checkForConnection(event:NetStatusEvent):void
    		{
    			
    	        event.info.code == "NetConnection.Connect.Success";
    			if (event.info.code)
    			{
                                   connectedUsersSO = SharedObject.getRemote("connectedUsersSO", netConnection.uri, false);
    				connectedUsersSO.addEventListener(SyncEvent.SYNC, streamSynch);
    				connectedUsersSO.connect(netConnection);
    				
    			}
    }
    private function streamSynch(event:SyncEvent):void
    {
    	
    	var results:Object = event.target.data;
    	trace("conuser"+connectedUsersSO.data["publishName"]);
            var array:Array = new Array();
            for( var item:String in results ) 
    	{              
    		var obj:Object = new Object();
    		obj.label = results[ item ];
    		obj.value = item;
    		array.push( obj );
    		trace("item"+results[item]);
    		trace(item.length);
    		soname_txt.text = String(item.length);
    		nsSubscribe=new NetStream(netConnection);
    				if(results[item]!= publishName)
    				{
    				nsSubscribe.play(playUser);
    				user2video.attachNetStream(nsSubscribe);
    				myTimer.start();
    				user2video.width = camera.width;
    				user2video.height = camera.height;
    				//clearInterval(interval);
    				}
    	}
    }
    but i am not able to get subscribe video unable to find where i am wrong. any help?

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

    Default

    You will have to override publish as I have shown. When a Flash RTMP client does NetConnection.connect() (which invokes onConnect server-side) there is no stream name.

    Richard

  5. #5

    Default

    Quote Originally Posted by rrlanham View Post
    You will have to override publish as I have shown. When a Flash RTMP client does NetConnection.connect() (which invokes onConnect server-side) there is no stream name.

    Richard
    Thanks again richard, I have tried like
    public void publish(IClient client, RequestFunction function,
    	        AMFDataList params) {
    		String streamName = getParamString(params, PARAM1);
    		getLogger().info("streamName:"+streamName);
    		ISharedObjects sharedObjects = getAppInstance(client).getSharedObjects(false);
    		ISharedObject connectedUsersSO = sharedObjects.get(CONNECTEDUSERS_SONAME);
    		if (connectedUsersSO != null)
    		{
    			connectedUsersSO.lock();
    			try
    			{
    				getLogger().info("onConnectAccept: add property: "+client.getClientId());
    				String userName = client.getProperties().getPropertyStr("userName");
    				//String publishName = client.getProperties().getPropertyStr("publishName");
    				String propName = userName+ ": " + client.getClientId();
    				connectedUsersSO.setProperty(propName, streamName);
    			}
    			catch (Exception e)
    			{
    				
    			}
    			finally
    			{
    				connectedUsersSO.unlock();
    			}
    		}
    		invokePrevious(client, function, params); 
    	}
    but still i face the same problem.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,934

    Default

    Hi
    Try adding some debug into the "publish" code shown above to see what actions are being taken and what the problem may be.

    Jason

  7. #7

    Default

    hi,
    I have tried and i could able to get stream name. but now i have one problem. i am getting my own video on two video object even i have checked conditions on flash like
    private function streamSynch(event:SyncEvent):void
    {
    	
          var results:Object = event.target.data;
           var array:Array = new Array();
    		
            for( var item:String in results ) 
    	{  
    		
    		var obj:Object = new Object();
    		obj.label = results[ item ];
    		obj.value = item;
    		array.push( obj );
    		nsSubscribe=new NetStream(netConnection);
    		//soname_txt.text = results[ item ];
    		if(item != publishName) //here if i specify (results [ item] != publishName) i am not getting any video to play for(if(item != publishName) i am getting same video on both sides
    		{
    		soname_txt.text = results[ item ];
    				nsSubscribe.play(results[ item ]);
    				user2video.attachNetStream(nsSubscribe);
    				user2video.width = camera.width;
    				user2video.height = camera.height;
    				myTimer.start();
    				clearInterval(interval);
    				
    		}
    		
    	}
    where i am doing wrong?

  8. #8

    Default

    Quote Originally Posted by malarprathap View Post
    hi,
    I have tried and i could able to get stream name. but now i have one problem. i am getting my own video on two video object even i have checked conditions on flash like
    private function streamSynch(event:SyncEvent):void
    {
    	
          var results:Object = event.target.data;
           var array:Array = new Array();
    		
            for( var item:String in results ) 
    	{  
    		
    		var obj:Object = new Object();
    		obj.label = results[ item ];
    		obj.value = item;
    		array.push( obj );
    		nsSubscribe=new NetStream(netConnection);
    		//soname_txt.text = results[ item ];
    		if(item != publishName) //here if i specify (results [ item] != publishName) i am not getting any video to play for(if(item != publishName) i am getting same video on both sides
    		{
    		soname_txt.text = results[ item ];
    				nsSubscribe.play(results[ item ]);
    				user2video.attachNetStream(nsSubscribe);
    				user2video.width = camera.width;
    				user2video.height = camera.height;
    				myTimer.start();
    				clearInterval(interval);
    				
    		}
    		
    	}
    where i am doing wrong?
    I have got working. thanks for your great support.

Similar Threads

  1. Shared Objects across applications
    By GraemeBull in forum General Forum
    Replies: 12
    Last Post: 10-23-2011, 02:50 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
  •