📄 rtparchitecture.html
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher 5.0.2">
<meta name="TEMPLATEBASE" content="Portable HTML">
<meta name="LASTUPDATED" content="11/23/99 11:48:09">
<title>Understanding the JMF RTP API </title>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><a href="JMFTOC.html">CONTENTS</a> |
<a href="RTPRealTime.html">PREV </a> |
<a href="RTPPresenting.html">NEXT</a> |
<a href="JMFIX.html">INDEX</a></td>
<td align="right"><em>JMF 2.0 API Guide</em>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<div align="right">
<a name="97773"> </a><font size="3" face="Palatino, Times New Roman, Times, serif">8 <br></font>
</div>
<div align="right">
<h2>
<a name="105171"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Understanding the JMF RTP API</font>
</h2>
</div>
<p>
<a name="101424"> </a><font face="Palatino, Times New Roman, Times, serif">JMF enables the playback and transmission of RTP streams through the APIs defined in the <code>javax.media.rtp</code>, <code>javax.media.rtp.event</code>, and <code>javax.media.rtp.rtcp </code>packages. JMF can be extended to support additional RTP-specific formats and dynamic payloads through the standard JMF plug-in mechanism. </font>
</p>
<p>
<a name="105802"> </a><font face="Palatino, Times New Roman, Times, serif">Note: <strong>JMF-compliant implementations are not required to support the RTP APIs in</strong><code> </code><strong>javax.media.rtp,</strong><code> </code><strong>javax.media.rtp.event, and javax.media.rtp.rtcp.</strong> The reference implementations of JMF provided by Sun Microsystems, Inc. and IBM Corporation fully support these APIs. </font>
</p>
<p>
<a name="101918"> </a><font face="Palatino, Times New Roman, Times, serif">You can play incoming RTP streams locally, save them to a file, or both. </font>
</p>
<a name="105199"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><br></font>
<a name="103304"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/RTPArchitecture2.gif" height="89" width="480">
<br></font>
<a name="100622"> </a><font size="2" face="Palatino, Times New Roman, Times, serif">Figure 8-1: RTP reception.<br></font>
<p>
<a name="105181"> </a><font face="Palatino, Times New Roman, Times, serif">For example, the RTP APIs could be used to implement a telephony application that answers calls and records messages like an answering machine. </font>
</p>
<p>
<a name="101984"> </a><font face="Palatino, Times New Roman, Times, serif">Similarly, you can use the RTP APIs to transmit captured or stored media streams across the network. Outgoing RTP streams can originate from a file or a capture device. The outgoing streams can also be played locally, saved to a file, or both.</font>
</p>
<a name="105195"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><br></font>
<a name="105208"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/RTPArchitecturea.gif" height="91" width="480">
<br></font>
<a name="101977"> </a><font size="2" face="Palatino, Times New Roman, Times, serif">Figure 8-2: RTP transmission.<br></font>
<p>
<a name="105211"> </a><font face="Palatino, Times New Roman, Times, serif">For example, you could implement a video conferencing application that captures live audio and video and transmits it across the network using a separate RTP session for each media type. </font>
</p>
<p>
<a name="103436"> </a><font face="Palatino, Times New Roman, Times, serif">Similarly, you might record a conference for later broadcast or use a prerecorded audio stream as "hold music" in a conferencing application. </font>
</p>
<h3>
<a name="98397"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">RTP Architecture</font>
</h3>
<p>
<a name="97800"> </a><font face="Palatino, Times New Roman, Times, serif">The JMF RTP APIs are designed to work seamlessly with the capture, presentation, and processing capabilities of JMF. Players and processors are used to present and manipulate RTP media streams just like any other media content. You can transmit media streams that have been captured from a local capture device using a capture <code>DataSource</code> or that have been stored to a file using a <code>DataSink</code>. Similarly, JMF can be extended to support additional RTP formats and payloads through the standard plug-in mechanism.</font>
</p>
<a name="105218"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/RTPArchitecture3.gif" height="205" width="478">
<br></font>
<a name="102046"> </a><font size="2" face="Palatino, Times New Roman, Times, serif">Figure 8-3: High-level JMF RTP architecture.<br></font>
<h4>
<a name="105222"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Session Manager</font>
</h4>
<p>
<a name="103809"> </a><font face="Palatino, Times New Roman, Times, serif">In JMF, a <code>SessionManager</code> is used to coordinate an RTP session. The session manager keeps track of the session participants and the streams that are being transmitted. </font>
</p>
<p>
<a name="103490"> </a><font face="Palatino, Times New Roman, Times, serif">The session manager maintains the state of the session as viewed from the local participant. In effect, a session manager is a local representation of a distributed entity, the RTP session. The session manager also handles the <em>RTCP </em>control channel, and supports RTCP for both senders and receivers. </font>
</p>
<p>
<a name="102442"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>SessionManager</code> interface defines methods that enable an application to initialize and start participating in a session, remove individual streams created by the application, and close the entire session.</font>
</p>
<h5>
<a name="104767"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Session Statistics </font></i>
</h5>
<p>
<a name="104768"> </a><font face="Palatino, Times New Roman, Times, serif">The session manager maintains statistics on all of the RTP and RTCP packets sent and received in the session. Statistics are tracked for the entire session on a per-stream basis. The session manager provides access to global reception and transmission statistics:</font>
</p>
<ul>
<li><a name="104769"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>GlobalReceptionStats</strong>: Maintains global reception statistics for the session.</font>
<li><a name="104770"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>GlobalTransmissionStat</strong><code>s</code>: Maintains cumulative transmission statistics for all local senders.</font>
</ul>
<p>
<a name="104771"> </a><font face="Palatino, Times New Roman, Times, serif">Statistics for a particular recipient or outgoing stream are available from the stream:</font>
</p>
<ul>
<li><a name="104772"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>ReceptionStats</strong>: Maintains source reception statistics for an individual participant.</font>
<li><a name="104773"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>TransmissionStats</strong>: Maintains transmission statistics for an individual send stream.</font>
</ul>
<h5>
<a name="104792"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Session Participants</font></i>
</h5>
<p>
<a name="104793"> </a><font face="Palatino, Times New Roman, Times, serif">The session manager keeps track of all of the participants in a session. Each participant is represented by an instance of a class that implements the <code>Participant</code> interface. <code>SessionManager</code>s create a <code>Participant</code> whenever an RTCP packet arrives that contains a source description (SDES) with a canonical name<code>(CNAME)</code> that has not been seen before in the session (or has timed-out since its last use). Participants can be passive (sending control packets only) or active (also sending one or more RTP data streams).</font>
</p>
<p>
<a name="104794"> </a><font face="Palatino, Times New Roman, Times, serif">There is exactly one <em>local</em> <em>participant</em> that represents the local client/server participant. A local participant indicates that it will begin sending RTCP control messages or data and maintain state on incoming data and control messages by starting a session. </font>
</p>
<p>
<a name="104795"> </a><font face="Palatino, Times New Roman, Times, serif">A participant can own more than one stream, each of which is identified by the synchronization source identifier (SSRC) used by the source of the stream. </font>
</p>
<h5>
<a name="104796"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Session Streams</font></i>
</h5>
<p>
<a name="104797"> </a><font face="Palatino, Times New Roman, Times, serif">The <code>SessionManager</code> maintains an <code>RTPStream</code> object for each stream of RTP data packets in the session. There are two types of RTP streams:</font>
</p>
<ul>
<li><a name="104798"> </a><font face="Palatino, Times New Roman, Times, serif"><code>ReceiveStream</code> represents a stream that's being received from a remote participant. </font>
<li><a name="104799"> </a><font face="Palatino, Times New Roman, Times, serif"><code>SendStream</code> represents a stream of data coming from the <code>Processor</code> or input <code>DataSource</code> that is being sent over the network.</font>
</ul>
<p>
<a name="104800"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>ReceiveStream </code>is constructed automatically whenever the session manager detects a new source of RTP data. To create a new <code>SendStream</code>, you call the <code>SessionManager</code> <code>createSendStream</code> method.</font>
</p>
<h4>
<a name="103790"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">RTP Events</font>
</h4>
<p>
<a name="103840"> </a><font face="Palatino, Times New Roman, Times, serif">Several RTP-specific events are defined in <code>javax.media.rtp.event</code>. These events are used to report on the state of the RTP session and streams.</font>
</p>
<a name="103851"> </a><font size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/RTPArchitectureb.gif" height="596" width="478">
<br></font>
<a name="103852"> </a><font size="2" face="Palatino, Times New Roman, Times, serif">Figure 8-4: RTP events.<br></font>
<p>
<a name="105229"> </a><font face="Palatino, Times New Roman, Times, serif">To receive notification of RTP events, you implement the appropriate RTP listener and register it with the session manager:</font>
</p>
<ul>
<li><a name="103853"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>SessionListener</strong>: Receives notification of changes in the state of the session.</font>
<li><a name="103925"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>SendStreamListener</strong>: Receives notification of changes in the state of an RTP stream that's being transmitted.</font>
<li><a name="103929"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>ReceiveStreamListener</strong>: Receives notification of changes in the state of an RTP stream that's being received.</font>
<li><a name="103933"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>RemoteListener</strong>: Receives notification of events or RTP control messages received from a remote participant.</font>
</ul>
<h5>
<a name="104171"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Session Listener</font></i>
</h5>
<p>
<a name="104172"> </a><font face="Palatino, Times New Roman, Times, serif">You can implement <code>SessionListener</code> to receive notification about events that pertain to the RTP session as a whole, such as the addition of new participants.</font>
</p>
<p>
<a name="104173"> </a><font face="Palatino, Times New Roman, Times, serif">There are two types of session-wide events: </font>
</p>
<ul>
<li><a name="104174"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>NewParticipantEvent</strong>: Indicates that a new participant has joined the session.</font>
<li><a name="104175"> </a><font face="Palatino, Times New Roman, Times, serif"><strong>LocalCollisionEvent</strong>: Indicates that the participant's synchronization source is already in use.</font>
</ul>
<h5>
<a name="103854"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Send Stream Listener</font></i>
</h5>
<p>
<a name="103855"> </a><font face="Palatino, Times New Roman, Times, serif">You can implement <code>SendStreamListener</code> to receive notification whenever:</font>
</p>
<ul>
<li><a name="103856"> </a><font face="Palatino, Times New Roman, Times, serif">New send streams are created by the local participant.</font>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -