Newer
Older
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jitsi.impl.neomedia;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.media.*;
import javax.media.control.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.rtp.*;
import javax.media.rtp.event.*;
import javax.media.rtp.rtcp.*;
import org.jitsi.impl.neomedia.device.*;
import org.jitsi.impl.neomedia.format.*;
import org.jitsi.impl.neomedia.protocol.*;
import org.jitsi.impl.neomedia.transform.*;
import org.jitsi.impl.neomedia.transform.csrc.*;
import org.jitsi.impl.neomedia.transform.dtmf.*;
import org.jitsi.impl.neomedia.transform.rtcp.*;
import org.jitsi.impl.neomedia.transform.zrtp.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.control.*;
import org.jitsi.service.neomedia.device.*;
import org.jitsi.service.neomedia.format.*;
import org.jitsi.util.*;
/**
* Implements <tt>MediaStream</tt> using JMF.
*
* @author Lyubomir Marinov
* @author Emil Ivov
* @author Sebastien Vincent
*/
public class MediaStreamImpl
extends AbstractMediaStream
implements ReceiveStreamListener,
SendStreamListener,
SessionListener,
RemoteListener
{
/**
* The <tt>Logger</tt> used by the <tt>MediaStreamImpl</tt> class and its
* instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(MediaStreamImpl.class);
/**
* The name of the property indicating the length of our receive buffer.
*/
protected static final String PROPERTY_NAME_RECEIVE_BUFFER_LENGTH

Lyubomir Marinov
committed
= "net.java.sip.communicator.impl.neomedia.RECEIVE_BUFFER_LENGTH";
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**
* The session with the <tt>MediaDevice</tt> this instance uses for both
* capture and playback of media.
*/
private MediaDeviceSession deviceSession;
/**
* The <tt>PropertyChangeListener</tt> which listens to
* {@link #deviceSession} and changes in the values of its
* {@link MediaDeviceSession#OUTPUT_DATA_SOURCE} property.
*/
private final PropertyChangeListener deviceSessionPropertyChangeListener
= new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent event)
{
String propertyName = event.getPropertyName();
if (MediaDeviceSession.OUTPUT_DATA_SOURCE.equals(propertyName))
deviceSessionOutputDataSourceChanged();
else if (MediaDeviceSession.SSRC_LIST.equals(propertyName))
deviceSessionSsrcListChanged(event);
}
};
/**
* The <tt>MediaDirection</tt> in which this <tt>MediaStream</tt> is allowed
* to stream media.
*/
private MediaDirection direction;
/**
* The <tt>Map</tt> of associations in this <tt>MediaStream</tt> and the
* <tt>RTPManager</tt> it utilizes of (dynamic) RTP payload types to
* <tt>MediaFormat</tt>s.
*/
private final Map<Byte, MediaFormat> dynamicRTPPayloadTypes
= new HashMap<Byte, MediaFormat>();
/**
* The <tt>ReceiveStream</tt>s this instance plays back on its associated
* <tt>MediaDevice</tt>.
*/
private final List<ReceiveStream> receiveStreams
= new LinkedList<ReceiveStream>();
/**
* The <tt>RTPConnector</tt> through which this instance sends and receives
* RTP and RTCP traffic. The instance is a <tt>TransformConnector</tt> in
* order to also enable packet transformations.
*/
private AbstractRTPConnector rtpConnector;
/**
* The one and only <tt>MediaStreamTarget</tt> this instance has added as a
* target in {@link #rtpConnector}.
*/
private MediaStreamTarget rtpConnectorTarget;
/**
* The <tt>RTPManager</tt> which utilizes {@link #rtpConnector} and sends
* and receives RTP and RTCP traffic on behalf of this <tt>MediaStream</tt>.
*/
private StreamRTPManager rtpManager;
/**
* The <tt>RTPTranslator</tt>, if any, which forwards RTP and RTCP traffic
* between this and other <tt>MediaStream</tt>s.
*/
private RTPTranslator rtpTranslator;
/**
* The indicator which determines whether {@link #createSendStreams()} has
* been executed for {@link #rtpManager}. If <tt>true</tt>, the
* <tt>SendStream</tt>s have to be recreated when the <tt>MediaDevice</tt>,
* respectively the <tt>MediaDeviceSession</tt>, of this instance is
* changed.
*/
private boolean sendStreamsAreCreated = false;
/**
* The indicator which determines whether {@link #start()} has been called
* on this <tt>MediaStream</tt> without {@link #stop()} or {@link #close()}.
*/
private boolean started = false;
/**
* The <tt>MediaDirection</tt> in which this instance is started. For
* example, {@link MediaDirection#SENDRECV} if this instances is both
* sending and receiving data (e.g. RTP and RTCP) or
* {@link MediaDirection#SENDONLY} if this instance is only sending data.
*/
private MediaDirection startedDirection;
/**
* The SSRC identifiers of the party that we are exchanging media with.
*/
private final Vector<Long> remoteSourceIDs = new Vector<Long>(1, 1);
/**
* Our own SSRC identifier.
*/
private long localSourceID = -1;
/**
* The list of CSRC IDs contributing to the media that this
* <tt>MediaStream</tt> is sending to its remote party.
*/
private long[] localContributingSourceIDList = null;
/**
* The indicator which determines whether this <tt>MediaStream</tt> is set
* to transmit "silence" instead of the actual media fed from its
* <tt>MediaDevice</tt>.
*/
private boolean mute = false;
/**
* The map of currently active <tt>RTPExtension</tt>s and the IDs that they
* have been assigned for the lifetime of this <tt>MediaStream</tt>.
*/
private final Map<Byte, RTPExtension> activeRTPExtensions
= new Hashtable<Byte, RTPExtension>();
/**
* The engine that we are using in order to add CSRC lists in conference
* calls, send CSRC sound levels, and handle incoming levels and CSRC lists.
*/
private CsrcTransformEngine csrcEngine;
/**
* The <tt>SrtpControl</tt> which controls the SRTP functionality of this
* <tt>MediaStream</tt>.
*/
private final SrtpControl srtpControl;
/**
* Number of received sender reports. Used for logging and debugging only.
Loading
Loading full blame...