Wowza Media Systems home
Wowza Pro is the best alternative to Adobe Flash Media Server. Try it today.
Now Hiring. Join the Wowza team!

Go Back   Wowza Media Server Forums > Wowza Media Server 2 Forums > General Forum

Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2010, 12:53 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Default client's ip address

Hi All,

I would like to retrieve the IP addresses from all connected client. I used:

IApplicationInstance applicationInstance = client.getAppInstance();
MediaStreamMap msm = (MediaStreamMap) applicationInstance.getStreams();
String ip = (String) msm.getStream(streams.get(index)).getHTTPStreamerS ession().getIpAddress();

but it threw a NullPointerException.

Can someone give me some advises?
Reply With Quote
  #2  
Old 02-08-2010, 01:15 PM
rrlanham rrlanham is offline
Senior Member
 
Join Date: Dec 2007
Posts: 9,420
Default

Try it like this:

Code:
public void getClientIps(IClient client, RequestFunction function,
			AMFDataList params) {

		List<IClient> clients = client.getAppInstance().getClients();
		Iterator<IClient> iter = clients.iterator();
		while(iter.hasNext())
		{
			IClient aclient = iter.next();
			if (!aclient.isConnected())
				continue;
			getLogger().info("Client IP" + aclient.getIp());
			
		}
}
Richard
Reply With Quote
  #3  
Old 02-08-2010, 01:39 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Thumbs up

Thank you Richard,

client.getIp() does well,
but I am just curious about my code. did anything go wrong. Since I would like to retrieve the ip address corresponding to each stream.
Reply With Quote
  #4  
Old 02-08-2010, 02:05 PM
rrlanham rrlanham is offline
Senior Member
 
Join Date: Dec 2007
Posts: 9,420
Default

Actually I think you want more that that, you also want the IP of all the HTTPStreamerSessions. I dont have the concise example right this minute, but take a look at this post and see if you can suss it out:

http://www.wowzamedia.com/forums/showthread.php?t=7097

Richard
Reply With Quote
  #5  
Old 02-08-2010, 03:52 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Thumbs up

Thank you Richard, you always been really helpful!!!
Reply With Quote
  #6  
Old 02-09-2010, 05:00 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Default

Hi Richard,

I found a funny thing while I tried to get the MediaStreamMap.

IApplicationInstance applicationInstance = client.getAppInstance();
MediaStreamMap msm = (MediaStreamMap) applicationInstance.getStreams();

msm contained all the connected streams, the funny thing is if only one stream in msm, it would just have one stream in the map. if there are two or more streams, each stream would have one duplicated stream. So say if there are 3 stream connected, there would have 6 streams in the msm. I wonder if you notice this?
Reply With Quote
  #7  
Old 02-09-2010, 09:48 PM
charlie charlie is offline
Administrator
 
Join Date: Nov 2006
Posts: 9,268
Default

Show the code you are using to count the number of streams.

Charlie
Reply With Quote
  #8  
Old 02-10-2010, 05:45 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Default

Here is my code:

public void getConnectedClientInfo(IClient client, RequestFunction function, AMFDataList params)
{
getLogger().info("getConnectedClinetInfo retrieving info.....");

AMFDataArray retArray = new AMFDataArray();
AMFDataObj retObj = null;

IApplicationInstance applicationInstance = client.getAppInstance();

List<String> streams = applicationInstance.getStreams().getPublishStreamN ames();
MediaStreamMap msm = (MediaStreamMap) applicationInstance.getStreams();

List<IMediaStream> streamList = new ArrayList<IMediaStream>();
streamList = msm.getStreams();

if(streamList.size()>0) {
for(int i=0;i<streamList.size();i++)
getLogger().info(streamList.size()+ ".."+streamList.get(i).getClientId());
}



getLogger().info("MSM COUNTER"+msm.getCount());



for(int i=0;i<streams.size();i++){
getLogger().info(streams.get(i)+" Streams size: "+streams.size());
retObj = new AMFDataObj();
if(streams.get(i)!=null) {

String str = new String(streams.get(i));
retObj.put("room", new AMFDataItem(str.substring(0,5)));
getLogger().info("Room number: "+str.substring(0,5));

String id = str.substring(str.lastIndexOf("_")+1,str.length()) ;
retObj.put("id", new AMFDataItem(id));
getLogger().info("User id : "+id);

String printip = "";
getLogger().info(streamList.get(i).getClient().get Ip());

for(int a=0;a<streamList.size();a++){
int streamId = streamList.get(a).getClientId();
getLogger().info("Streams "+ id+" streamList: "+streamId);
if(streamId==new Integer(id)) {
String ip = (String) streamList.get(a).getClient().getIp();
printip = ip;
retObj.put("ip", new AMFDataItem(ip));
}
}
getLogger().info("Room:"+str.substring(0,5)+" User ID:"+ id+" ip: "+printip);
}
retArray.add(retObj);
}

if(retArray!=null)
sendResult(client, params, retArray);
}

Here is the Wowza log

getConnectedClinetInfo retrieving info..... - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 4..1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 4..1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 4..1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 4..1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - MSM COUNTER4 - - - 77.203 - - - - - - - - - - - - - - - - -
- - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 99949_videoStream_1807759574 Streams size: 2 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Room number: 99949 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - User id : 1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 192.168.1.68 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1807759574 streamList: 1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1807759574 streamList: 1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1807759574 streamList: 1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1807759574 streamList: 1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Room:99949 User ID:1807759574 ip: 192.168.1.68 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 99949_videoStream_1015236877 Streams size: 2 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Room number: 99949 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - User id : 1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - 192.168.1.62 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1015236877 streamList: 1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1015236877 streamList: 1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1015236877 streamList: 1015236877 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Streams 1015236877 streamList: 1807759574 - - - 77.203 - - - - - - - - - - - - - - - - - - - - - - - - -
2010-02-11 14:37:19 NZDT comment server INFO 200 - Room:99949 User ID:1015236877 ip: 192.168.1.62

Last edited by lewyan13; 02-10-2010 at 06:07 PM.
Reply With Quote
  #9  
Old 02-10-2010, 06:03 PM
lewyan13 lewyan13 is offline
Member
 
Join Date: Jan 2010
Posts: 60
Default

Also, I have got another question about H.264. Wowza Media Server would encode the stream when gets it from client side and decode the stream when it pass to a destination. how do we know the server is using H.264?

Since we used red5 server before and just got into Wowza recently. The bandwidth of download or upload a stream is about the same as red5, so I am curious about how the wowza server uses the H264 to compress streams and reduce the bandwidth.
Reply With Quote
  #10  
Old 02-10-2010, 06:05 PM
rrlanham rrlanham is offline
Senior Member
 
Join Date: Dec 2007
Posts: 9,420
Default

Actually, Wowza doesn't do any encoding, transcoding or compression.

Richard
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:01 PM.


Copyright © 2006 - 2010, Wowza Media Systems
Wowza Media Systems