001/** 002 * 003 * Copyright 2003-2006 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smackx.jingle.media; 019 020import org.jivesoftware.smackx.jingle.JingleSession; 021import org.jivesoftware.smackx.jingle.nat.JingleTransportManager; 022import org.jivesoftware.smackx.jingle.nat.TransportCandidate; 023 024import java.util.List; 025 026/** 027 * This class provides necessary Jingle Session jmf methods and behavior. 028 * <p/> 029 * The goal of this class is to provide a flexible way to make JingleManager control jmf streaming APIs without implement them. 030 * For instance you can implement a file transfer using java sockets or a VOIP Media Manager using JMF. 031 * You can implement many JingleMediaManager according to you necessity. 032 * 033 * @author Thiago Camargo 034 */ 035public abstract class JingleMediaManager { 036 037 public static final String MEDIA_NAME = "JingleMediaManager"; 038 039 // Each media manager must keep track of the transport manager that it uses. 040 private JingleTransportManager transportManager; 041 042 public JingleMediaManager(JingleTransportManager transportManager) { 043 this.transportManager = transportManager; 044 } 045 046 /** 047 * Return The transport manager that goes with this media manager. 048 */ 049 public JingleTransportManager getTransportManager() { 050 return transportManager; 051 } 052 053 /** 054 * Return all supported Payloads for this Manager 055 * 056 * @return The Payload List 057 */ 058 public abstract List<PayloadType> getPayloads(); 059 060 /** 061 * Returns the Preferred PayloadType of the Media Manager 062 * 063 * @return The PayloadType 064 */ 065 public PayloadType getPreferredPayloadType() { 066 return getPayloads().size() > 0 ? getPayloads().get(0) : null; 067 } 068 069 /** 070 * Create a Media Session Implementation 071 * 072 * @param payloadType 073 * @param remote 074 * @param local 075 * @return the media session 076 */ 077 public abstract JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, 078 final TransportCandidate local, JingleSession jingleSession); 079 080 // This is to set the attributes of the <content> element of the Jingle packet. 081 public String getName() { 082 return MEDIA_NAME; 083 } 084 085}