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 */ 017package org.jivesoftware.smackx.jingleold.mediaimpl.test; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.jivesoftware.smackx.jingleold.JingleSession; 023import org.jivesoftware.smackx.jingleold.media.JingleMediaManager; 024import org.jivesoftware.smackx.jingleold.media.JingleMediaSession; 025import org.jivesoftware.smackx.jingleold.media.PayloadType; 026import org.jivesoftware.smackx.jingleold.nat.JingleTransportManager; 027import org.jivesoftware.smackx.jingleold.nat.TransportCandidate; 028 029/** 030 * Implements a MediaManager for test purposes. 031 * 032 * @author Thiago Camargo 033 */ 034 035public class TestMediaManager extends JingleMediaManager { 036 037 public static final String MEDIA_NAME = "TestMedia"; 038 039 private List<PayloadType> payloads = new ArrayList<PayloadType>(); 040 041 private PayloadType preferredPayloadType = null; 042 043 public TestMediaManager(JingleTransportManager transportManager) { 044 super(transportManager); 045 } 046 047 /** 048 * Return all supported Payloads for this Manager. 049 * 050 * @return The Payload List 051 */ 052 public List<PayloadType> getPayloads() { 053 return payloads; 054 } 055 056 public void setPayloads(List<PayloadType> payloads) { 057 this.payloads.addAll(payloads); 058 } 059 060 /** 061 * Returns a new JingleMediaSession 062 * 063 * @param payloadType payloadType 064 * @param remote remote Candidate 065 * @param local local Candidate 066 * @return JingleMediaSession JingleMediaSession 067 */ 068 public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, 069 final TransportCandidate local, final JingleSession jingleSession) { 070 TestMediaSession session = null; 071 072 session = new TestMediaSession(payloadType, remote, local, "", jingleSession); 073 074 return session; 075 } 076 077 public PayloadType getPreferredPayloadType() { 078 if (preferredPayloadType != null) 079 return preferredPayloadType; 080 return super.getPreferredPayloadType(); 081 } 082 083 public void setPreferredPayloadType(PayloadType preferredPayloadType) { 084 this.preferredPayloadType = preferredPayloadType; 085 } 086 087 public String getName() { 088 return MEDIA_NAME; 089 } 090}