⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmfarchitecture.html

📁 奉献给多媒体java编程者们。JMF2.1.1最新版本的用户指南。JMF是java用于基于实时多媒体的开发工具
💻 HTML
📖 第 1 页 / 共 5 页
字号:


<p>
  <a name="104900"> </a><font face="Palatino, Times New Roman, Times, serif">If you extend JMF functionality by implementing a new plug-in, you can register it with the <code>PlugInManager</code> to make it available to <code>Processors</code> that support the plug-in API. To use a custom <code>Player</code>, <code>Processor</code>, <code>DataSource</code>, or <code>DataSink</code> with <code>JMF</code>, you register your unique package prefix with the <code>PackageManager</code>. </font>
</p>


<h4>
  <a name="104875"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Event Model</font>
</h4>


<p>
  <a name="104215"> </a><font face="Palatino, Times New Roman, Times, serif">JMF uses a structured event reporting mechanism to keep JMF-based programs informed of the current state of the media system and enable JMF-based programs to respond to media-driven error conditions, such as out-of data and resource unavailable conditions. Whenever a JMF object needs to report on the current conditions, it posts a <code>MediaEvent</code>. <code>MediaEvent</code> is subclassed to identify many particular types of events. These objects follow the established Java Beans patterns for events.</font>
</p>


<p>
  <a name="104254"> </a><font face="Palatino, Times New Roman, Times, serif">For each type of JMF object that can post <code>MediaEvents</code>, JMF defines a corresponding listener interface. To receive notification when a <code>MediaEvent</code> is posted, you implement the appropriate listener interface and register your listener class with the object that posts the event by calling its <code>add</code><em>Listener </em>method.</font>
</p>


<p>
  <a name="104374"> </a><font face="Palatino, Times New Roman, Times, serif"><code>Controller</code> objects (such as <code>Players</code> and <code>Processors</code>) and certain <code>Control</code> objects such as <code>GainControl</code> post media events. </font>
</p>


<a name="112430"> </a><font  size="1" face="Palatino, Times New Roman, Times, serif"> <img src="images/JMFArchitecture10a.gif" height="141" width="478">
<br></font>


<a name="112431"> </a><font  size="2" face="Palatino, Times New Roman, Times, serif">Figure 2-4:   JMF event model.<br></font>


<p>
  <a name="112680"> </a><font face="Palatino, Times New Roman, Times, serif"><code>RTPSessionManager</code> objects also post events. For more information, see <a href="RTPArchitecture.html#103790">RTP Events</a>.</font>
</p>


<h4>
  <a name="112436"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Data Model</font>
</h4>


<p>
  <a name="112432"> </a><font face="Palatino, Times New Roman, Times, serif">JMF media players<code> </code>usually use <code>DataSources</code> to manage the transfer of media-content. A <code>DataSource</code> encapsulates both the location of media and the protocol and software used to deliver the media. Once obtained, the source cannot be reused to deliver other media. </font>
</p>


<p>
  <a name="105918"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>DataSource</code> is identified by either a JMF <code>MediaLocator</code> or a <code>URL</code> (universal resource locator).<code> </code>A <code>MediaLocator</code> is similar to a <code>URL</code> and can be constructed from a <code>URL</code>, but can be constructed even if the corresponding protocol handler is not installed on the system. (In Java, a <code>URL</code> can only be constructed if the corresponding protocol handler is installed on the system.)</font>
</p>


<p>
  <a name="105919"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>DataSource</code> manages a set of <code>SourceStream</code> objects. A standard data source uses a byte array as the unit of transfer. A <em>buffer data source</em> uses a <code>Buffer</code> object as its unit of transfer. JMF defines several types of <code>DataSource</code> objects:</font>
</p>


<a name="111828"> </a><font  size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/JMFArchitecture20.gif" height="258" width="478">
<br></font>


<a name="106010"> </a><font  size="2" face="Palatino, Times New Roman, Times, serif">Figure 2-5:   JMF data model.<br></font>


<h5>
  <a name="112684"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Push and Pull Data Sources</font></i>
</h5>


<p>
  <a name="106012"> </a><font face="Palatino, Times New Roman, Times, serif">Media data can be obtained from a variety of sources, such as local or network files and live broadcasts. JMF data sources can be categorized according to how data transfer is initiated:</font>
</p>

<ul>
  <li><a name="106014"> </a><font face="Palatino, Times New Roman, Times, serif"><em>Pull Data-Source</em>--the client initiates the data transfer and controls the flow of data from pull data-sources. Established protocols for this type of data include Hypertext Transfer Protocol (HTTP) and FILE. JMF defines two types of pull data sources: <code>PullDataSource</code> and <code>PullBufferDataSource</code>, which uses a <code>Buffer</code> object as its unit of transfer.</font>
  <li><a name="106016"> </a><font face="Palatino, Times New Roman, Times, serif"><em>Push Data-Source</em>--the server initiates the data transfer and controls the flow of data from a push data-source. Push data-sources include broadcast media, multicast media, and video-on-demand (VOD). For broadcast data, one protocol is the Real-time Transport Protocol (RTP), under development by the Internet Engineering Task Force (IETF). The MediaBase protocol developed by SGI is one protocol used for VOD. JMF defines two types of push data sources: <code>PushDataSource</code> and <code>PushBufferDataSource</code>, which uses a <code>Buffer</code> object as its unit of transfer.</font>
</ul>

<p>
  <a name="106022"> </a><font face="Palatino, Times New Roman, Times, serif">The degree of control that a client program can extend to the user depends on the type of data source being presented. For example, an MPEG file can be repositioned and a client program could allow the user to replay the video clip or seek to a new position in the video. In contrast, broadcast media is under server control and cannot be repositioned. Some VOD protocols might support limited user control--for example, a client program might be able to allow the user to seek to a new position, but not fast forward or rewind.</font>
</p>


<h5>
  <a name="110594"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Specialty DataSources</font></i>
</h5>


<p>
  <a name="111982"> </a><font face="Palatino, Times New Roman, Times, serif">JMF defines two types of specialty data sources, cloneable data sources  and merging data sources.</font>
</p>


<p>
  <a name="112019"> </a><font face="Palatino, Times New Roman, Times, serif">A cloneable data source can be used to create clones of either a pull or push <code>DataSource</code>. To create a cloneable<code> DataSource</code>, you call the <code>Manager</code> <code>createCloneableDataSource</code> method and pass in the <code>DataSource</code> you want to clone. Once a <code>DataSource</code> has been passed to <code>createCloneableDataSource</code>, you should only interact with the cloneable <code>DataSource</code> and its clones; the original <code>DataSource</code> should no longer be used directly.</font>
</p>


<p>
  <a name="113957"> </a><font face="Palatino, Times New Roman, Times, serif">Cloneable data sources implement the <code>SourceCloneable</code> interface, which defines one method, <code>createClone</code>. By calling <code>createClone</code>, you can create any number of clones of the <code>DataSource that was </code>used to construct the<code> </code>cloneable<code> DataSource</code>. The clones can be controlled through the cloneable<code> DataSource</code> used to create them-- when <code>connect</code>, <code>disconnect</code>, <code>start</code>, or <code>stop</code> is called on the cloneable<code> DataSource</code>, the method calls are propagated to the clones. </font>
</p>


<p>
  <a name="113996"> </a><font face="Palatino, Times New Roman, Times, serif">The clones don't necessarily have the same properties as the cloneable data source used to create them or the  original <code>DataSource</code>. For example, a cloneable data source created for a capture device might function as a master data source for its clones--in this case, unless the cloneable data source is used, the clones won't produce any data. If you hook up both the cloneable data source and one or more clones, the clones will produce data at the same rate as the master.</font>
</p>


<p>
  <a name="110846"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>MergingDataSource</code> can be used to combine the <code>SourceStreams</code> from several <code>DataSources</code> into a single <code>DataSource</code>. This enables a set of <code>DataSources</code> to be managed from a single point of control--when <code>connect</code>, <code>disconnect</code>, <code>start</code>, or <code>stop</code> is called on the <code>MergingDataSource</code>, the method calls are propagated to the merged <code>DataSources</code>.</font>
</p>


<p>
  <a name="111989"> </a><font face="Palatino, Times New Roman, Times, serif">To construct a <code>MergingDataSource</code>, you call the <code>Manager</code> <code>createMergingDataSource</code> method and pass in an array that contains the data sources you want to merge. To be merged, all of the <code>DataSources</code> must be of the same type; for example, you cannot merge a <code>PullDataSource</code> and a <code>PushDataSource</code>. The duration of the merged <code>DataSource</code> is the maximum of the merged <code>DataSource </code>objects' durations. The <code>ContentType</code> is <code>application/mixed-media</code>.</font>
</p>


<h5>
  <a name="110802"> </a><i><font color="#003366" face="Palatino, Times New Roman, Times, serif">Data Formats</font></i>
</h5>


<p>
  <a name="108211"> </a><font face="Palatino, Times New Roman, Times, serif">The exact media format of an object is represented by a <code>Format</code> object. The format itself carries no encoding-specific parameters or global timing information, it describes the format's encoding name and the type of data the format requires.</font>
</p>


<p>
  <a name="108308"> </a><font face="Palatino, Times New Roman, Times, serif">JMF extends <code>Format</code> to define audio- and video-specific formats. </font>
</p>


<a name="108448"> </a><font  size="1" face="Palatino, Times New Roman, Times, serif"><img src="images/JMFArchitecture10.gif" height="265" width="485">
<br></font>


<a name="108386"> </a><font  size="2" face="Palatino, Times New Roman, Times, serif">Figure 2-6:   JMF media formats.<br></font>


<p>
  <a name="112695"> </a><font face="Palatino, Times New Roman, Times, serif">An <code>AudioFormat</code> describes the attributes specific to an audio format, such as sample rate, bits per sample, and number of channels. A <code>VideoFormat </code>encapsulates information relevant to video data<code>. </code>Several formats are derived from<code> VideoFormat </code>to describe the attributes of common video formats, including:</font>
</p>

<ul>
  <li><a name="108324"> </a><font face="Palatino, Times New Roman, Times, serif"><code>IndexedColorFormat</code></font>
  <li><a name="108318"> </a><font face="Palatino, Times New Roman, Times, serif"><code>RGBFormat</code></font>
  <li><a name="108342"> </a><font face="Palatino, Times New Roman, Times, serif"><code>YUVFormat</code></font>
  <li><a name="112085"> </a><font face="Palatino, Times New Roman, Times, serif"><code>JPEGFormat</code></font>
  <li><a name="112092"> </a><font face="Palatino, Times New Roman, Times, serif"><code>H261Format</code></font>
  <li><a name="112093"> </a><font face="Palatino, Times New Roman, Times, serif"><code>H263Format</code></font>
</ul>

<p>
  <a name="112158"> </a><font face="Palatino, Times New Roman, Times, serif">To receive notification of format changes from a <code>Controller</code>, you implement the <code>ControllerListener</code> interface and listen for <code>FormatChangeEvents</code>. (For more information, see <a href="JMFPresenting.html#94440">Responding to Media Events</a>.)</font>
</p>


<h4>
  <a name="97527"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Controls</font>
</h4>


<p>
  <a name="105000"> </a><font face="Palatino, Times New Roman, Times, serif">JMF <code>Control</code> provides a mechanism for setting and querying attributes of an object. A <code>Control</code> often provides access to a corresponding user interface component that enables user control over an object's attributes. Many JMF objects expose <code>Controls</code>, including <code>Controller</code> objects, <code>DataSource </code>objects, <code>DataSink</code> objects, and JMF plug-ins. </font>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -