Search in sources :

Example 1 with MediaDevice

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;
}
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 MediaDevice

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;
}
Also used : MediaFormat(org.jitsi.service.neomedia.format.MediaFormat) InetSocketAddress(java.net.InetSocketAddress) VideoEvent(org.jitsi.util.event.VideoEvent) UnknownHostException(java.net.UnknownHostException) MediaDeviceImpl(org.jitsi.impl.neomedia.device.MediaDeviceImpl) DatagramSocket(java.net.DatagramSocket) MediaDevice(org.jitsi.service.neomedia.device.MediaDevice) VideoListener(org.jitsi.util.event.VideoListener)

Example 3 with MediaDevice

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);
    }
}
Also used : CaptureDeviceInfo(javax.media.CaptureDeviceInfo) CaptureDeviceInfo2(org.jitsi.impl.neomedia.device.CaptureDeviceInfo2) MediaService(org.jitsi.service.neomedia.MediaService) AVFrameFormat(org.jitsi.impl.neomedia.codec.video.AVFrameFormat) AudioSystem(org.jitsi.impl.neomedia.device.AudioSystem) MediaType(org.jitsi.service.neomedia.MediaType) MediaDevice(org.jitsi.service.neomedia.device.MediaDevice) AudioFormat(javax.media.format.AudioFormat)

Example 4 with MediaDevice

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;
}
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

MediaDevice (org.jitsi.service.neomedia.device.MediaDevice)4 DatagramSocket (java.net.DatagramSocket)3 InetSocketAddress (java.net.InetSocketAddress)3 UnknownHostException (java.net.UnknownHostException)2 AudioMediaDeviceImpl (org.jitsi.impl.neomedia.device.AudioMediaDeviceImpl)2 MediaService (org.jitsi.service.neomedia.MediaService)2 MediaFormat (org.jitsi.service.neomedia.format.MediaFormat)2 CaptureDeviceInfo (javax.media.CaptureDeviceInfo)1 AudioFormat (javax.media.format.AudioFormat)1 AVFrameFormat (org.jitsi.impl.neomedia.codec.video.AVFrameFormat)1 AudioSystem (org.jitsi.impl.neomedia.device.AudioSystem)1 CaptureDeviceInfo2 (org.jitsi.impl.neomedia.device.CaptureDeviceInfo2)1 MediaDeviceImpl (org.jitsi.impl.neomedia.device.MediaDeviceImpl)1 DefaultStreamConnector (org.jitsi.service.neomedia.DefaultStreamConnector)1 MediaStreamTarget (org.jitsi.service.neomedia.MediaStreamTarget)1 MediaType (org.jitsi.service.neomedia.MediaType)1 VideoEvent (org.jitsi.util.event.VideoEvent)1 VideoListener (org.jitsi.util.event.VideoListener)1