GridData alignTop = new GridData();
alignTop.verticalAlignment = SWT.TOP;
Composite outGroup = new Composite(gui,SWT.NULL);
outGroup.setLayout(new GridLayout(2,false));
outbound = new List(outGroup,SWT.SINGLE | SWT.V_SCROLL);
outbound.setLayoutData(listSize);
Composite outGroupButtons = new Composite(outGroup,SWT.NULL);
outGroupButtons.setLayoutData(alignTop);
outGroupButtons.setLayout(new GridLayout(1,true));
Button addOutbound = new Button(outGroupButtons,SWT.PUSH);
addOutbound.setText("Add target...");
addOutbound.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("XCDEVoice","icons/newaudio.png").createImage());
addOutbound.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
XCDEAudioRemoteHostDialog d = new XCDEAudioRemoteHostDialog(new Shell());
ServerInfo info = d.open(new ServerInfo("",64656));
if (info == null || info.server.equals("") || info.port < 1 || info.port > 65536)
{
MessageDialog.openError(new Shell(),"Invalid Connection Configuration", "The connction configuaration you specified is invalid, please try again.");
return;
}
InetAddress addr = null;
try
{
addr = InetAddress.getByName(info.server);
}
catch (UnknownHostException e)
{
MessageDialog.openError(new Shell(),"Unknown Host", "The host " + info.server + " could not be found, please try again.");
return;
}
try
{
rtpManager.addTarget(new SessionAddress(addr,info.port));
}
catch (IOException e)
{
MessageDialog.openError(new Shell(),"I/O Exception", "An I/O Exception occured while trying to connect the audio");
e.printStackTrace(System.err);
return;
}
catch (InvalidSessionAddressException e)
{
MessageDialog.openError(new Shell(),"Invalid Session ADdress", "The session address specified is invalid");
e.printStackTrace(System.err);
return;
}
AudioTransmit at = new AudioTransmit(cdi.getLocator(),addr.getHostAddress(),Integer.toString(info.port));
// Start the transmission
String result = at.start();
// result will be non-null if there was an error. The return
// value is a String describing the possible error. Print it.
if (result != null)
{
MessageDialog.openError(new Shell(),"Error Starting Audio Stream","Error: " + result);
return;
}
out.put(info,at);
updateOutList();
}
});
Button removeOutbound = new Button(outGroupButtons,SWT.PUSH);
removeOutbound.setText("Remove target...");
removeOutbound.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("XCDEVoice","icons/removeaudio.png").createImage());
removeOutbound.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
int selIndex = outbound.getSelectionIndex();
if (selIndex == -1)
return;
String item = outbound.getItem(selIndex);
String[] parts = item.split(":");
ServerInfo toRemove = new ServerInfo(parts[0],Integer.parseInt(parts[1]));
AudioTransmit at = (AudioTransmit)out.get(toRemove);
if (at == null)
return;
at.stop();
try
{
rtpManager.removeTarget(new SessionAddress(InetAddress.getByName(parts[0]),Integer.parseInt(parts[1])), "disconnecting");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
out.remove(toRemove);
updateOutList();
// if (outbound.getItemCount() < 1)
// {
// for (Iterator i = in.values().iterator(); i.hasNext(); )
// {
// ((Player)i.next()).stop();
// }
// inbound.removeAll();
// in.clear();
// }
}
});
Composite inGroup = new Composite(gui,SWT.NULL);
inGroup.setLayout(new GridLayout(2,false));
inbound = new List(inGroup,SWT.SINGLE | SWT.V_SCROLL);
inbound.setLayoutData(listSize);
Composite inGroupButtons = new Composite(inGroup,SWT.NULL);
inGroupButtons.setLayoutData(alignTop);
inGroupButtons.setLayout(new GridLayout(1,true));
Button stopListening = new Button(inGroupButtons,SWT.PUSH);