Search in sources :

Example 1 with AudioMediaDeviceImpl

use of org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl 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;
}
Also used : MediaFormat(org.jitsi.service.neomedia.format.MediaFormat) DatagramSocket(java.net.DatagramSocket) InetSocketAddress(java.net.InetSocketAddress) AudioMediaDeviceImpl(org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl) MediaDevice(org.jitsi.service.neomedia.device.MediaDevice)

Example 2 with AudioMediaDeviceImpl

use of org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl 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;
}
Also used : MediaStreamTarget(org.jitsi.service.neomedia.MediaStreamTarget) DatagramSocket(java.net.DatagramSocket) InetSocketAddress(java.net.InetSocketAddress) MediaService(org.jitsi.service.neomedia.MediaService) AudioMediaDeviceImpl(org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl) MediaDevice(org.jitsi.service.neomedia.device.MediaDevice) DefaultStreamConnector(org.jitsi.service.neomedia.DefaultStreamConnector) UnknownHostException(java.net.UnknownHostException)

Aggregations

DatagramSocket (java.net.DatagramSocket)2 InetSocketAddress (java.net.InetSocketAddress)2 AudioMediaDeviceImpl (org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl)2 MediaDevice (org.jitsi.service.neomedia.device.MediaDevice)2 UnknownHostException (java.net.UnknownHostException)1 DefaultStreamConnector (org.jitsi.service.neomedia.DefaultStreamConnector)1 MediaService (org.jitsi.service.neomedia.MediaService)1 MediaStreamTarget (org.jitsi.service.neomedia.MediaStreamTarget)1 MediaFormat (org.jitsi.service.neomedia.format.MediaFormat)1