use of org.jitsi.service.neomedia.device.MediaDevice in project Spark by igniterealtime.
the class AudioReceiverChannel method start.
/**
* Starts the transmission. Returns null if transmission started ok.
* Otherwise it returns a string with the reason why the setup failed.
* Starts receive also.
*/
public synchronized String start() {
try {
MediaService mediaService = LibJitsi.getMediaService();
MediaDevice device = mediaService.getDefaultDevice(MediaType.AUDIO, MediaUseCase.CALL);
List<MediaDevice> devices = mediaService.getDevices(MediaType.AUDIO, MediaUseCase.CALL);
for (MediaDevice foundDevice : devices) {
if (foundDevice instanceof AudioMediaDeviceImpl) {
AudioMediaDeviceImpl amdi = (AudioMediaDeviceImpl) foundDevice;
if (inLocator == amdi.getCaptureDeviceInfo().getLocator()) {
System.out.println("Test" + inLocator + "-" + amdi.getCaptureDeviceInfo().getLocator());
device = foundDevice;
}
}
System.out.println(foundDevice.getClass() + "-" + inLocator);
}
mediaStream = mediaService.createMediaStream(device);
mediaStream.setDirection(MediaDirection.RECVONLY);
System.out.println("TEST");
MediaFormat format = mediaService.getFormatFactory().createMediaFormat("PCMA", 8000);
mediaStream.setFormat(format);
StreamConnector connector = new DefaultStreamConnector(new DatagramSocket(this.localPort), new DatagramSocket(this.localPort + 1));
mediaStream.setConnector(connector);
mediaStream.setTarget(new MediaStreamTarget(new InetSocketAddress(this.remoteIpAddress, this.remotePort), new InetSocketAddress(this.remoteIpAddress, this.remotePort + 1)));
mediaStream.setName(MediaType.AUDIO.toString());
mediaStream.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.jitsi.service.neomedia.device.MediaDevice in project Spark by igniterealtime.
the class VideoChannel method start.
/**
* Starts the transmission. Returns null if transmission started ok.
* Otherwise it returns a string with the reason why the setup failed.
* Starts receive also.
*/
public synchronized String start() {
try {
MediaService mediaService = LibJitsi.getMediaService();
MediaDevice device = mediaService.getDefaultDevice(MediaType.VIDEO, MediaUseCase.ANY);
List<MediaDevice> devices = mediaService.getDevices(MediaType.VIDEO, MediaUseCase.ANY);
for (MediaDevice foundDevice : devices) {
if (foundDevice instanceof MediaDeviceImpl) {
MediaDeviceImpl amdi = (MediaDeviceImpl) foundDevice;
if (locator.equals(amdi.getCaptureDeviceInfo().getLocator())) {
System.out.println("Test" + locator + "-" + amdi.getCaptureDeviceInfo().getLocator());
device = foundDevice;
}
}
}
System.out.println("Device:" + device);
mediaStream = mediaService.createMediaStream(device);
mediaStream.setDirection(MediaDirection.SENDRECV);
MediaFormat usedformat = mediaService.getFormatFactory().createMediaFormat("H264", MediaFormatFactory.CLOCK_RATE_NOT_SPECIFIED);
byte dynamicRTPPayloadType = 99;
mediaStream.addDynamicRTPPayloadType(dynamicRTPPayloadType, usedformat);
mediaStream.setFormat(usedformat);
connector = new DefaultStreamConnector(new DatagramSocket(this.localPort), new DatagramSocket(this.localRTCPPort));
mediaStream.setConnector(connector);
mediaStream.setTarget(new MediaStreamTarget(new InetSocketAddress(this.ipAddress, this.remotePort), new InetSocketAddress(this.ipAddress, this.remoteRTCPPort)));
mediaStream.setName(MediaType.VIDEO.toString());
((VideoMediaStream) mediaStream).addVideoListener(new VideoListener() {
@Override
public void videoAdded(VideoEvent arg0) {
checkVideo();
}
@Override
public void videoRemoved(VideoEvent arg0) {
}
@Override
public void videoUpdate(VideoEvent arg0) {
}
});
mediaStream.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.jitsi.service.neomedia.device.MediaDevice 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 org.jitsi.service.neomedia.device.MediaDevice in project Spark by igniterealtime.
the class AudioChannel method start.
/**
* Starts the transmission. Returns null if transmission started ok.
* Otherwise it returns a string with the reason why the setup failed.
* Starts receive also.
*/
public synchronized String start() {
try {
MediaService mediaService = LibJitsi.getMediaService();
MediaDevice device = null;
List<MediaDevice> devices = mediaService.getDevices(MediaType.AUDIO, MediaUseCase.CALL);
for (MediaDevice foundDevice : devices) {
if (foundDevice instanceof AudioMediaDeviceImpl) {
AudioMediaDeviceImpl amdi = (AudioMediaDeviceImpl) foundDevice;
if (inLocator == amdi.getCaptureDeviceInfo().getLocator()) {
System.out.println("Test" + inLocator + "-" + amdi.getCaptureDeviceInfo().getLocator());
device = foundDevice;
}
}
System.out.println(foundDevice.getClass() + "-" + inLocator);
}
mediaStream = mediaService.createMediaStream(device);
mediaStream.setDirection(MediaDirection.SENDRECV);
mediaStream.setFormat(format);
connector = new DefaultStreamConnector(new DatagramSocket(this.localPort), new DatagramSocket(this.localRTCPPort));
mediaStream.setConnector(connector);
mediaStream.setTarget(new MediaStreamTarget(new InetSocketAddress(this.ipAddress, this.remotePort), new InetSocketAddress(this.ipAddress, this.remoteRTCPPort)));
mediaStream.setName(MediaType.AUDIO.toString());
mediaStream.start();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations