Search in sources :

Example 1 with CaptureDeviceInfo

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);
    }
}
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 2 with CaptureDeviceInfo

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();
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) CaptureDeviceInfo(javax.media.CaptureDeviceInfo) MediaService(org.jitsi.service.neomedia.MediaService) MediaType(org.jitsi.service.neomedia.MediaType) AudioFormat(javax.media.format.AudioFormat) InetAddress(java.net.InetAddress)

Example 3 with CaptureDeviceInfo

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();
    }
}
Also used : Format(javax.media.Format) MediaFormat(org.jitsi.service.neomedia.format.MediaFormat) VideoFormat(javax.media.format.VideoFormat) MediaLocator(javax.media.MediaLocator) UnknownHostException(java.net.UnknownHostException) CaptureDeviceInfo(javax.media.CaptureDeviceInfo) VideoFormat(javax.media.format.VideoFormat) InetAddress(java.net.InetAddress)

Example 4 with CaptureDeviceInfo

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;
}
Also used : MediaLocator(javax.media.MediaLocator) CaptureDeviceInfo(javax.media.CaptureDeviceInfo) AudioFormat(javax.media.format.AudioFormat) VideoFormat(javax.media.format.VideoFormat)

Aggregations

CaptureDeviceInfo (javax.media.CaptureDeviceInfo)4 AudioFormat (javax.media.format.AudioFormat)3 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 MediaLocator (javax.media.MediaLocator)2 VideoFormat (javax.media.format.VideoFormat)2 MediaService (org.jitsi.service.neomedia.MediaService)2 MediaType (org.jitsi.service.neomedia.MediaType)2 Format (javax.media.Format)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 MediaDevice (org.jitsi.service.neomedia.device.MediaDevice)1 MediaFormat (org.jitsi.service.neomedia.format.MediaFormat)1