Skip to content
Snippets Groups Projects
Commit 54250f18 authored by Vincent Lucas's avatar Vincent Lucas
Browse files

Adds the device name and its state (connected or disconnected) for the "Device...

Adds the device name and its state (connected or disconnected) for the "Device configuration has changed" pop-up notification. Adds a "New selected device" pop-up notification when the selected audio device has changed (for audio in, audio out and notifications).
parent c6c114e5
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,18 @@ public abstract class DeviceSystem
public static final String PROP_DEVICES = "devices";
/**
* The list of devices connected at the last preInitialize.
*/
private static Vector<CaptureDeviceInfo> propertyChangeOldDevices
= new Vector<CaptureDeviceInfo>();
/**
* The list of devices connected at the last postInitialize.
*/
private static Vector<CaptureDeviceInfo> propertyChangeNewDevices
= new Vector<CaptureDeviceInfo>();
/**
* The list of <tt>DeviceSystem</tt>s which have been initialized.
*/
......@@ -423,7 +435,38 @@ protected final void initialize()
*/
protected void postInitialize()
{
firePropertyChange(PROP_DEVICES, null, null);
Format format = this.getFormat();
if (format != null)
{
// Gets the list of the actual connected devices.
propertyChangeNewDevices.removeAllElements();
propertyChangeNewDevices.addAll(
CaptureDeviceManager.getDeviceList(format));
// Compares the previous conencted device list with the current one,
// in order to detect new connected or disconnected devices.
for(int i = 0; i < propertyChangeOldDevices.size(); ++i)
{
if(!propertyChangeNewDevices.remove(
propertyChangeOldDevices.get(i)))
{
// Old device is removed.
firePropertyChange(
PROP_DEVICES,
propertyChangeOldDevices.get(i),
null);
}
}
for(int i = 0; i < propertyChangeNewDevices.size(); ++i)
{
// New device is plugged in.
firePropertyChange(
PROP_DEVICES,
null,
propertyChangeNewDevices.get(i));
}
}
}
/**
......@@ -435,26 +478,15 @@ protected void postInitialize()
*/
protected void preInitialize()
{
Format format;
switch (getMediaType())
{
case AUDIO:
format = new AudioFormat(null);
break;
case VIDEO:
format = new VideoFormat(null);
break;
default:
format = null;
break;
}
Format format = this.getFormat();
if (format != null)
{
@SuppressWarnings("unchecked")
Vector<CaptureDeviceInfo> cdis
= CaptureDeviceManager.getDeviceList(format);
propertyChangeOldDevices.removeAllElements();
propertyChangeOldDevices.addAll(cdis);
if ((cdis != null) && (cdis.size() > 0))
{
......@@ -503,4 +535,31 @@ public String toString()
{
return getLocatorProtocol();
}
/**
* Returns the format depending on the media type: AudioFormat for AUDIO,
* VideoFormat for VIDEO. Otherwise, returns null.
*
* @return The format depending on the media type: AudioFormat for AUDIO,
* VideoFormat for VIDEO. Otherwise, returns null.
*/
public Format getFormat()
{
Format format = null;
switch (getMediaType())
{
case AUDIO:
format = new AudioFormat(null);
break;
case VIDEO:
format = new VideoFormat(null);
break;
default:
format = null;
break;
}
return format;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment