use of javax.media.CaptureDeviceInfo in project Spark by igniterealtime.
the class MediaPreferencePanel method scanDevices.
@SuppressWarnings("unchecked")
public void scanDevices() {
// Remove all Items
audioDevice.removeAllItems();
videoDevice.removeAllItems();
playbackDevice.removeAllItems();
audioSystem.removeAllItems();
vectorPlaybackDevices.removeAllElements();
vectorAudioSystem.removeAllElements();
// FMJ
System.setProperty(ConfigurationService.PNAME_SC_HOME_DIR_LOCATION, Spark.getUserHome());
System.setProperty(ConfigurationService.PNAME_SC_HOME_DIR_NAME, ".");
System.setProperty(ConfigurationService.PNAME_SC_CACHE_DIR_LOCATION, Spark.getUserHome());
System.setProperty(ConfigurationService.PNAME_SC_LOG_DIR_LOCATION, Spark.getUserHome());
LibJitsi.start();
MediaType[] mediaTypes = MediaType.values();
MediaService mediaService = LibJitsi.getMediaService();
for (MediaType mediaType : mediaTypes) {
System.err.println("================================");
System.err.println("MediaType: " + mediaType);
System.out.println(mediaService);
MediaDevice device = mediaService.getDefaultDevice(mediaType, MediaUseCase.CALL);
if (device != null) {
System.out.println(device.getDirection());
}
System.err.println("Device: " + device);
System.err.println("================================");
}
vectorAudioDevices = CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));
for (CaptureDeviceInfo infoCaptureDevice : vectorAudioDevices) {
String protocol = infoCaptureDevice.getLocator().getProtocol();
audioDevice.addItem("[" + protocol + "]" + convertSysString(infoCaptureDevice.getName()));
}
vectorVideoDevices = CaptureDeviceManager.getDeviceList(new AVFrameFormat());
for (CaptureDeviceInfo infoCaptureDevice : vectorVideoDevices) {
videoDevice.addItem(convertSysString(infoCaptureDevice.getName()));
}
vectorVideoDevices.add(null);
videoDevice.addItem("<None>");
AudioSystem mediaAudioSystem = ((MediaServiceImpl) LibJitsi.getMediaService()).getDeviceConfiguration().getAudioSystem();
for (AudioSystem system : AudioSystem.getAudioSystems()) {
System.out.println(system);
vectorAudioSystem.add(system);
audioSystem.addItem(system);
}
for (CaptureDeviceInfo2 device : mediaAudioSystem.getDevices(DataFlow.PLAYBACK)) {
playbackDevice.addItem(convertSysString(device.getName()));
vectorPlaybackDevices.add(device);
}
}
use of javax.media.CaptureDeviceInfo in project Spark by igniterealtime.
the class AudioChannel method main.
public static void main(String[] args) {
InetAddress localhost;
try {
LibJitsi.start();
MediaType[] mediaTypes = MediaType.values();
MediaService mediaService = LibJitsi.getMediaService();
Vector<CaptureDeviceInfo> vectorAudioDevices = CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));
for (CaptureDeviceInfo infoCaptureDevice : vectorAudioDevices) {
System.out.println(infoCaptureDevice.getLocator());
}
localhost = InetAddress.getLocalHost();
byte format = 3;
AudioChannel audioChannel0 = new AudioChannel(vectorAudioDevices.get(0).getLocator(), localhost.getHostAddress(), localhost.getHostAddress(), 7002, -1, 7020, -1, MediaUtils.getMediaFormat(new AudioFormat(AudioFormat.GSM_RTP)));
AudioChannel audioChannel1 = new AudioChannel(vectorAudioDevices.get(0).getLocator(), localhost.getHostAddress(), localhost.getHostAddress(), 7020, -1, 7002, -1, MediaUtils.getMediaFormat(new AudioFormat(AudioFormat.GSM_RTP)));
audioChannel0.start();
audioChannel1.start();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
audioChannel0.setTrasmit(false);
audioChannel1.setTrasmit(false);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
audioChannel0.setTrasmit(true);
audioChannel1.setTrasmit(true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
audioChannel0.stop();
audioChannel1.stop();
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
use of javax.media.CaptureDeviceInfo in project Spark by igniterealtime.
the class VideoChannel method main.
public static void main(String[] args) {
InetAddress localhost;
try {
// FMJ
RegistryDefaults.registerAll(RegistryDefaults.FMJ | RegistryDefaults.FMJ_NATIVE);
// PlugInManager.addPlugIn(, in, out, type)
LibJitsi.start();
// Add Device
MediaType[] mediaTypes = MediaType.values();
MediaService mediaService = LibJitsi.getMediaService();
// LOG ALL Devices
final Vector<CaptureDeviceInfo> vectorDevices = CaptureDeviceManager.getDeviceList(null);
for (CaptureDeviceInfo infoCaptureDevice : vectorDevices) {
System.err.println("===========> " + infoCaptureDevice.getName());
for (Format format : infoCaptureDevice.getFormats()) {
System.err.println(format);
}
}
localhost = InetAddress.getLocalHost();
VideoChannel videoChannel0 = new VideoChannel(new MediaLocator("civil:/dev/video0"), localhost.getHostAddress(), localhost.getHostAddress(), 7002, 7020, new VideoFormat(VideoFormat.JPEG_RTP));
VideoChannel videoChannel1 = new VideoChannel(new MediaLocator("civil:/dev/video1"), localhost.getHostAddress(), localhost.getHostAddress(), 7020, 7002, new VideoFormat(VideoFormat.JPEG_RTP));
videoChannel0.start();
videoChannel1.start();
try {
Thread.sleep(50000);
} catch (InterruptedException e) {
e.printStackTrace();
}
videoChannel0.setTrasmit(false);
videoChannel1.setTrasmit(false);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
videoChannel0.setTrasmit(true);
videoChannel1.setTrasmit(true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
videoChannel0.stop();
videoChannel1.stop();
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
use of javax.media.CaptureDeviceInfo in project Spark by igniterealtime.
the class PhoneManager method getMediaLocator.
public static MediaLocator getMediaLocator(String locator) {
MediaLocator auxLocator;
System.out.println("--------------------------------");
System.out.println("locator: " + locator);
Vector<CaptureDeviceInfo> vectorAudioDevices = CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR));
for (CaptureDeviceInfo infoCaptureDevice : vectorAudioDevices) {
System.out.println(infoCaptureDevice.getLocator() + "-" + locator);
if (infoCaptureDevice.getLocator().toString().equals(locator)) {
System.out.println("Found: " + locator);
return infoCaptureDevice.getLocator();
}
}
Vector<CaptureDeviceInfo> vectorVideoDevices = CaptureDeviceManager.getDeviceList(new VideoFormat(VideoFormat.RGB));
for (CaptureDeviceInfo infoCaptureDevice : vectorVideoDevices) {
System.out.println(infoCaptureDevice.getLocator() + "-" + locator);
if (infoCaptureDevice.getLocator().toString().equals(locator)) {
System.out.println("Found: " + locator);
return infoCaptureDevice.getLocator();
}
}
if (useStaticLocator) {
if (mediaLocator == null) {
mediaLocator = new MediaLocator(locator);
}
auxLocator = mediaLocator;
// usingMediaLocator=true;
} else {
auxLocator = new MediaLocator(locator);
}
return auxLocator;
}
Aggregations