1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-06 05:01:12 +01:00

Jingle Media Manager for Multiple Media Managers.

JIngle Media Manager Refactoring.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7361 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Thiago Camargo 2007-03-02 20:32:21 +00:00 committed by thiago
parent 18c14f70d4
commit 945561242a
8 changed files with 180 additions and 242 deletions

View file

@ -27,6 +27,8 @@ import org.jivesoftware.jingleaudio.JMFInit;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
/**
* Implements a jingleMediaManager using JMF based API and JSpeex.
@ -37,6 +39,8 @@ import java.io.IOException;
*/
public class SpeexMediaManager extends JingleMediaManager {
private List<PayloadType> payloads = new ArrayList<PayloadType>();
public SpeexMediaManager() {
setupPayloads();
setupJMF();
@ -50,7 +54,23 @@ public class SpeexMediaManager extends JingleMediaManager {
* Setup API supported Payloads
*/
private void setupPayloads() {
this.addPayloadType(new PayloadType.Audio(15, "speex"));
payloads.add(new PayloadType.Audio(15, "speex"));
}
/**
* Return all supported Payloads for this Manager
*
* @return The Payload List
*/
public List<PayloadType> getPayloads() {
return payloads;
}
/**
* Get the preferred Payload Type
*/
public PayloadType getPreferredPayloadType() {
return payloads.size() > 0 ? payloads.get(0) : null;
}
/**
@ -58,46 +78,39 @@ public class SpeexMediaManager extends JingleMediaManager {
* devices are properly detected and initialized by JMF.
*/
public static void setupJMF() {
try {
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
if (!jmfDir.exists())
jmfDir.mkdir();
if (!jmfDir.exists())
jmfDir.mkdir();
File jmfProperties = new File(jmfDir, "jmf.properties");
File jmfProperties = new File(jmfDir, "jmf.properties");
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
catch (IOException ex) {
System.out.println("Failed to create jmf.properties");
ex.printStackTrace();
}
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
if (jmfProperties.length() == 0) {
JMFInit init = new JMFInit(null, false);
catch (IOException ex) {
System.out.println("Failed to create jmf.properties");
ex.printStackTrace();
}
}
finally {
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
if (jmfProperties.length() == 0) {
new JMFInit(null, false);
}
}