throw new IllegalArgumentException("No Stream found for " + streamName );
cpe.addChildExtension(ext);
}
}
public IceUdpTransportPacketExtension getLocalCandidatePacketExtensionForStream( String streamName ) {
IceUdpTransportPacketExtension transport = new IceUdpTransportPacketExtension();
transport.setPassword( agent.getLocalPassword() );
transport.setUfrag( agent.getLocalUfrag() );
try {
IceMediaStream ims = agent.getStream(streamName);
if( ims == null )
return null;
for( Component c : ims.getComponents() ) {
for( Candidate<?> can : c.getLocalCandidates() ) {
CandidatePacketExtension candidate = new CandidatePacketExtension();
candidate.setComponent(c.getComponentID());
candidate.setFoundation(Integer.parseInt(can.getFoundation()));
candidate.setGeneration(agent.getGeneration());
candidate.setID(nextCandidateId());
candidate.setNetwork(0); //FIXME: we need to identify the network card properly.
TransportAddress ta = can.getTransportAddress();
candidate.setIP( ta.getHostAddress() );
candidate.setPort( ta.getPort() );
candidate.setPriority(can.getPriority());
candidate.setProtocol(can.getTransport().toString());
if( can.getRelatedAddress() != null ) {
candidate.setRelAddr(can.getRelatedAddress().getHostAddress());
candidate.setRelPort(can.getRelatedAddress().getPort());
}
candidate.setType(convertType(can.getType()));
transport.addCandidate(candidate);
}
}
} catch( Exception e ) {
e.printStackTrace();
System.exit(0);