
org.jitsi.impl.neomedia.rtp.StreamRTPManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libjitsi Show documentation
Show all versions of libjitsi Show documentation
libjitsi is an advanced Java media library for secure real-time audio/video
communication
The newest version!
/*
* Copyright @ 2015 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.impl.neomedia.rtp;
import java.io.*;
import java.util.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.rtp.*;
import net.sf.fmj.media.rtp.*;
import org.jitsi.impl.neomedia.rtp.translator.*;
import org.jitsi.service.neomedia.*;
/**
* Implements the RTPManager interface as used by a
* MediaStream.
*
* @author Lyubomir Marinov
*/
public class StreamRTPManager
{
/**
* The MediaStream that uses this StreamRTPManager
*/
private final MediaStream stream;
/**
* The RTPManager this instance is to delegate to when it is not
* attached to an RTPTranslator.
*/
private final RTPManager manager;
/**
* The RTPTranslator which this instance is attached to and which
* forwards the RTP and RTCP flows of the MediaStream associated
* with this instance to other MediaStreams.
*/
private final RTPTranslatorImpl translator;
/**
* Initializes a new StreamRTPManager instance which is,
* optionally, attached to a specific RTPTranslator which is to
* forward the RTP and RTCP flows of the associated MediaStream to
* other MediaStreams.
*
* @param stream the MediaStream that created this
* StreamRTPManager.
* @param translator the RTPTranslator to attach the new instance
* to or null if the new instance is to not be attached to any
* RTPTranslator
*/
public StreamRTPManager(MediaStream stream, RTPTranslator translator)
{
this.stream = stream;
this.translator = (RTPTranslatorImpl) translator;
manager = (this.translator == null) ? RTPManager.newInstance() : null;
}
public void addFormat(Format format, int payloadType)
{
if (translator == null)
manager.addFormat(format, payloadType);
else
translator.addFormat(this, format, payloadType);
}
public void addReceiveStreamListener(ReceiveStreamListener listener)
{
if (translator == null)
manager.addReceiveStreamListener(listener);
else
translator.addReceiveStreamListener(this, listener);
}
public void addRemoteListener(RemoteListener listener)
{
if (translator == null)
manager.addRemoteListener(listener);
else
translator.addRemoteListener(this, listener);
}
public void addSendStreamListener(SendStreamListener listener)
{
if (translator == null)
manager.addSendStreamListener(listener);
else
translator.addSendStreamListener(this, listener);
}
public void addSessionListener(SessionListener listener)
{
if (translator == null)
manager.addSessionListener(listener);
else
translator.addSessionListener(this, listener);
}
public SendStream createSendStream(DataSource dataSource, int streamIndex)
throws IOException,
UnsupportedFormatException
{
if (translator == null)
return manager.createSendStream(dataSource, streamIndex);
else
return translator.createSendStream(this, dataSource, streamIndex);
}
public void dispose()
{
if (translator == null)
manager.dispose();
else
translator.dispose(this);
}
/**
* Gets a control of a specific type over this instance. Invokes
* {@link #getControl(String)}.
*
* @param controlType a Class which specifies the type of the
* control over this instance to get
* @return a control of the specified controlType over this
* instance if this instance supports such a control; otherwise,
* null
*/
@SuppressWarnings("unchecked")
public T getControl(Class controlType)
{
return (T) getControl(controlType.getName());
}
/**
* Gets a control of a specific type over this instance.
*
* @param controlType a String which specifies the type (i.e. the
* name of the class) of the control over this instance to get
* @return a control of the specified controlType over this
* instance if this instance supports such a control; otherwise,
* null
*/
public Object getControl(String controlType)
{
if (translator == null)
return manager.getControl(controlType);
else
return translator.getControl(this, controlType);
}
public GlobalReceptionStats getGlobalReceptionStats()
{
if (translator == null)
return manager.getGlobalReceptionStats();
else
return translator.getGlobalReceptionStats(this);
}
public GlobalTransmissionStats getGlobalTransmissionStats()
{
if (translator == null)
return manager.getGlobalTransmissionStats();
else
return translator.getGlobalTransmissionStats(this);
}
public long getLocalSSRC()
{
if (translator == null)
{
return
((net.sf.fmj.media.rtp.RTPSessionMgr) manager).getLocalSSRC();
}
else
return translator.getLocalSSRC(this);
}
/**
* Returns the MediaStream that uses this StreamRTPManager
* @return the MediaStream that uses this StreamRTPManager
*/
public MediaStream getMediaStream()
{
return stream;
}
@SuppressWarnings("rawtypes")
public Vector getReceiveStreams()
{
if (translator == null)
return manager.getReceiveStreams();
else
return translator.getReceiveStreams(this);
}
@SuppressWarnings("rawtypes")
public Vector getSendStreams()
{
if (translator == null)
return manager.getSendStreams();
else
return translator.getSendStreams(this);
}
public void initialize(RTPConnector connector)
{
if (translator == null)
manager.initialize(connector);
else
translator.initialize(this, connector);
}
public void removeReceiveStreamListener(ReceiveStreamListener listener)
{
if (translator == null)
manager.removeReceiveStreamListener(listener);
else
translator.removeReceiveStreamListener(this, listener);
}
public void removeRemoteListener(RemoteListener listener)
{
if (translator == null)
manager.removeRemoteListener(listener);
else
translator.removeRemoteListener(this, listener);
}
public void removeSendStreamListener(SendStreamListener listener)
{
if (translator == null)
manager.removeSendStreamListener(listener);
else
translator.removeSendStreamListener(this, listener);
}
public void removeSessionListener(SessionListener listener)
{
if (translator == null)
manager.removeSessionListener(listener);
else
translator.removeSessionListener(this, listener);
}
/**
* Sets the SSRCFactory to be utilized by this instance to generate
* new synchronization source (SSRC) identifiers.
*
* @param ssrcFactory the SSRCFactory to be utilized by this
* instance to generate new synchronization source (SSRC) identifiers or
* null if this instance is to employ internal logic to generate
* new synchronization source (SSRC) identifiers
*/
public void setSSRCFactory(SSRCFactory ssrcFactory)
{
if (translator == null)
{
RTPManager m = this.manager;
if (m instanceof
org.jitsi.impl.neomedia.jmfext.media.rtp.RTPSessionMgr)
{
org.jitsi.impl.neomedia.jmfext.media.rtp.RTPSessionMgr sm
= (org.jitsi.impl.neomedia.jmfext.media.rtp.RTPSessionMgr) m;
sm.setSSRCFactory(ssrcFactory);
}
}
else
{
translator.setSSRCFactory(ssrcFactory);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy