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.jingle.mediaimpl.sshare; 018 019import org.jivesoftware.smackx.jingle.JingleSession; 020import org.jivesoftware.smackx.jingle.media.JingleMediaManager; 021import org.jivesoftware.smackx.jingle.media.JingleMediaSession; 022import org.jivesoftware.smackx.jingle.media.PayloadType; 023import org.jivesoftware.smackx.jingle.mediaimpl.sshare.api.ImageDecoder; 024import org.jivesoftware.smackx.jingle.mediaimpl.sshare.api.ImageEncoder; 025import org.jivesoftware.smackx.jingle.nat.JingleTransportManager; 026import org.jivesoftware.smackx.jingle.nat.TransportCandidate; 027 028import java.util.ArrayList; 029import java.util.List; 030 031/** 032 * Implements a JingleMediaManager for ScreenSharing. 033 * It currently uses an Audio payload Type. Which needs to be fixed in the next version. 034 * 035 * @author Thiago Camargo 036 */ 037 038public class ScreenShareMediaManager extends JingleMediaManager { 039 040 public static final String MEDIA_NAME = "ScreenShare"; 041 042 private List<PayloadType> payloads = new ArrayList<PayloadType>(); 043 044 private ImageDecoder decoder = null; 045 private ImageEncoder encoder = null; 046 047 public ScreenShareMediaManager(JingleTransportManager transportManager) { 048 super(transportManager); 049 setupPayloads(); 050 } 051 052 /** 053 * Setup API supported Payloads 054 */ 055 private void setupPayloads() { 056 payloads.add(new PayloadType.Audio(30, "sshare")); 057 } 058 059 /** 060 * Return all supported Payloads for this Manager. 061 * 062 * @return The Payload List 063 */ 064 public List<PayloadType> getPayloads() { 065 return payloads; 066 } 067 068 /** 069 * Returns a new JingleMediaSession 070 * 071 * @param payloadType payloadType 072 * @param remote remote Candidate 073 * @param local local Candidate 074 * @return JingleMediaSession JingleMediaSession 075 */ 076 public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) { 077 ScreenShareSession session = null; 078 session = new ScreenShareSession(payloadType, remote, local, "Screen", jingleSession); 079 if (encoder != null) { 080 session.setEncoder(encoder); 081 } 082 if (decoder != null) { 083 session.setDecoder(decoder); 084 } 085 return session; 086 } 087 088 public PayloadType getPreferredPayloadType() { 089 return super.getPreferredPayloadType(); 090 } 091 092 public ImageDecoder getDecoder() { 093 return decoder; 094 } 095 096 public void setDecoder(ImageDecoder decoder) { 097 this.decoder = decoder; 098 } 099 100 public ImageEncoder getEncoder() { 101 return encoder; 102 } 103 104 public void setEncoder(ImageEncoder encoder) { 105 this.encoder = encoder; 106 } 107 108 public String getName() { 109 return MEDIA_NAME; 110 } 111}