mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +01:00
New Media Manager
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7405 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
65b38e647b
commit
082cc06b72
1 changed files with 64 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
|||
package org.jivesoftware.jingleaudio.multi;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
|
||||
import org.jivesoftware.smackx.jingle.media.JingleMediaSession;
|
||||
import org.jivesoftware.smackx.jingle.media.PayloadType;
|
||||
import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Implements a MultiMediaManager using other JingleMediaManager implementations.
|
||||
* It supports every Codecs that JingleMediaManagers added has.
|
||||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
|
||||
public class MultiMediaManager extends JingleMediaManager {
|
||||
|
||||
private List<JingleMediaManager> managers = new ArrayList<JingleMediaManager>();
|
||||
|
||||
public MultiMediaManager() {
|
||||
}
|
||||
|
||||
public void addMediaManager(JingleMediaManager manager) {
|
||||
managers.add(manager);
|
||||
}
|
||||
|
||||
public void removeMediaManager(JingleMediaManager manager) {
|
||||
managers.remove(manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all supported Payloads for this Manager.
|
||||
*
|
||||
* @return The Payload List
|
||||
*/
|
||||
public List<PayloadType> getPayloads() {
|
||||
List<PayloadType> list = new ArrayList<PayloadType>();
|
||||
for (JingleMediaManager manager : managers) {
|
||||
for (PayloadType payloadType : manager.getPayloads()) {
|
||||
if (!list.contains(payloadType))
|
||||
list.add(payloadType);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new JingleMediaSession
|
||||
*
|
||||
* @param payloadType
|
||||
* @param remote
|
||||
* @param local
|
||||
* @return JingleMediaSession
|
||||
*/
|
||||
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) {
|
||||
for (JingleMediaManager manager : managers) {
|
||||
if (manager.getPayloads().contains(payloadType)) {
|
||||
return manager.createMediaSession(payloadType, remote, local);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue