From 082cc06b729fa993a43b0ae81f2c32ec4fe98bc9 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Thu, 8 Mar 2007 00:09:20 +0000 Subject: [PATCH] New Media Manager git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7405 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jingleaudio/multi/MultiMediaManager.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 jingle/media/source/org/jivesoftware/jingleaudio/multi/MultiMediaManager.java diff --git a/jingle/media/source/org/jivesoftware/jingleaudio/multi/MultiMediaManager.java b/jingle/media/source/org/jivesoftware/jingleaudio/multi/MultiMediaManager.java new file mode 100644 index 000000000..590d84888 --- /dev/null +++ b/jingle/media/source/org/jivesoftware/jingleaudio/multi/MultiMediaManager.java @@ -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 managers = new ArrayList(); + + 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 getPayloads() { + List list = new ArrayList(); + 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; + } +}