Search in sources :

Example 1 with AudioFormat

use of javax.media.format.AudioFormat in project Spark by igniterealtime.

the class SipCodecs method allCodecs.

/**
 * gets all the codecs from the fmjMediaManager and put them into a string
 * (seperated by SEPERATOR)
 *
 * @return
 */
private String allCodecs() {
    String all = "";
    List<AudioFormat> codecs = SoftPhoneManager.getInstance().getJmfMediaManager().getAudioFormats();
    for (AudioFormat audio : codecs) {
        all = all + audio.getEncoding() + SEP;
    }
    return all;
}
Also used : AudioFormat(javax.media.format.AudioFormat)

Example 2 with AudioFormat

use of javax.media.format.AudioFormat in project Spark by igniterealtime.

the class JMFInit method detectDirectAudio.

private void detectDirectAudio() {
    Class<?> cls;
    int plType = PlugInManager.RENDERER;
    String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
    try {
        // Check if this is the Windows Performance Pack - hack
        Class.forName("VFWAuto");
        // Check if DS capture is supported, otherwise fail DS renderer
        // since NT doesn't have capture
        Class.forName("com.sun.media.protocol.dsound.DSound");
        // Find the renderer class and instantiate it.
        cls = Class.forName(dar);
        Renderer rend = (Renderer) cls.newInstance();
        try {
            // Set the format and open the device
            AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2);
            rend.setInputFormat(af);
            rend.open();
            Format[] inputFormats = rend.getSupportedInputFormats();
            // Register the device
            PlugInManager.addPlugIn(dar, inputFormats, new Format[0], plType);
            // Move it to the top of the list
            Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
            int listSize = rendList.size();
            if (rendList.elementAt(listSize - 1).equals(dar)) {
                rendList.removeElementAt(listSize - 1);
                rendList.insertElementAt(dar, 0);
                PlugInManager.setPlugInList(rendList, plType);
                PlugInManager.commit();
            // Log.debug("registered");
            }
            rend.close();
        } catch (Throwable t) {
        // Log.debug("Error " + t);
        }
    } catch (Throwable tt) {
    // Nothing to do
    }
}
Also used : Format(javax.media.Format) AudioFormat(javax.media.format.AudioFormat) Renderer(javax.media.Renderer) AudioFormat(javax.media.format.AudioFormat)

Example 3 with AudioFormat

use of javax.media.format.AudioFormat in project Spark by igniterealtime.

the class JmfMediaManager method setupAudioFormats.

/**
 * Setup API supported AudioFormats
 */
private void setupAudioFormats() {
    // audioFormats.add(new AudioFormat(Constants.SPEEX_RTP));
    audioFormats.add(new AudioFormat(Constants.ALAW_RTP));
    audioFormats.add(new AudioFormat(AudioFormat.ULAW_RTP));
    audioFormats.add(new AudioFormat(AudioFormat.GSM_RTP));
    audioFormats.add(new AudioFormat(AudioFormat.G723_RTP));
}
Also used : AudioFormat(javax.media.format.AudioFormat)

Example 4 with AudioFormat

use of javax.media.format.AudioFormat in project Spark by igniterealtime.

the class JmfMediaManager method getSelectedFormats.

private List<AudioFormat> getSelectedFormats() {
    List<AudioFormat> format = new ArrayList<AudioFormat>();
    List<AudioFormat> all = getAudioFormats();
    LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
    // gets the selected order from preferences
    String[] codecs = localPreferences.getSelectedCodecs().split("\\^");
    for (AudioFormat form : all) {
        for (String codec : codecs) {
            if (form.getEncoding().toLowerCase().equals(codec.toLowerCase())) {
                format.add(form);
            }
        }
    }
    System.out.println("FORMATE NEU: " + format);
    return format;
}
Also used : ArrayList(java.util.ArrayList) AudioFormat(javax.media.format.AudioFormat) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences)

Example 5 with AudioFormat

use of javax.media.format.AudioFormat in project Spark by igniterealtime.

the class JmfMediaManager method getPreferredFormat.

/**
 * reads the codec-order from the user-preferences
 *
 * @return
 */
// TODO REMOVE
@SuppressWarnings("unused")
private AudioFormat getPreferredFormat(ArrayList<String> formate) {
    LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
    // gets the selected order from preferences
    String[] codecs = localPreferences.getSelectedCodecs().split("\\^");
    for (String codec : codecs) {
        for (String format : formate) {
            if (format != null && format.toLowerCase().equals(codec.toLowerCase()))
                return new AudioFormat(format);
        }
    }
    // this return shouldn't be executed, but if no codec was found, then use the first
    return new AudioFormat(formate.get(0));
}
Also used : LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) AudioFormat(javax.media.format.AudioFormat)

Aggregations

AudioFormat (javax.media.format.AudioFormat)15 MediaLocator (javax.media.MediaLocator)5 InetAddress (java.net.InetAddress)4 UnknownHostException (java.net.UnknownHostException)3 CaptureDeviceInfo (javax.media.CaptureDeviceInfo)3 Format (javax.media.Format)3 Inet6Address (java.net.Inet6Address)2 InetSocketAddress (java.net.InetSocketAddress)2 Vector (java.util.Vector)2 Renderer (javax.media.Renderer)2 VideoFormat (javax.media.format.VideoFormat)2 MediaService (org.jitsi.service.neomedia.MediaService)2 MediaType (org.jitsi.service.neomedia.MediaType)2 XMPPException (org.jivesoftware.smack.XMPPException)2 AudioChannel (org.jivesoftware.smackx.jingle.mediaimpl.jmf.AudioChannel)2 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Codec (javax.media.Codec)1 NoProcessorException (javax.media.NoProcessorException)1