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