📄 jmfprocessing.html
字号:
</p>
<p>
<a name="96219"> </a><font face="Palatino, Times New Roman, Times, serif">You can also select the output format that you want by using a <code>ProcessorModel</code> to create the <code>Processor</code>. (See <a href="JMFPresenting.html#97813">Using a ProcessorModel to Create a Processor</a> for more information.) </font>
</p>
<p>
<a name="96223"> </a><font face="Palatino, Times New Roman, Times, serif">Specifying an output data format automatically selects the default processing options for this format, overriding the previous processing options selected through the <code>TrackControls</code>. Setting the output data format to <code>null</code> causes the media data to be rendered instead of output to the <code>Processor</code> object's output <code>DataSource</code>.</font>
</p>
<h3>
<a name="96155"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Specifying the Media Destination</font>
</h3>
<p>
<a name="96444"> </a><font face="Palatino, Times New Roman, Times, serif">You can specify a destination for the media stream by selecting a particular <code>Renderer</code> for a track through its <code>TrackControl</code>, or by using the output from a <code>Processor</code> as the input to a particular <code>DataSink</code>. You can also use the <code>Processor</code> output as the input to another <code>Player</code> or <code>Processor</code> that has a different destination.</font>
</p>
<h4>
<a name="96547"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Selecting a Renderer</font>
</h4>
<p>
<a name="96548"> </a><font face="Palatino, Times New Roman, Times, serif">To select the <code>Renderer</code> that you want to use, you:</font>
</p>
<ol type="1">
<li value="1"><a name="96549"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>getTrackControls</code> on the <code>Processor</code> to get a <code>TrackControl</code> for each track in the media stream. The <code>Processor</code> must in the <em>Configured</em> state before you call <code>getTrackControls</code>.</font>
<li value="2"><a name="96550"> </a><font face="Palatino, Times New Roman, Times, serif">Call the <code>TrackControl</code> <code>setRenderer</code> method to specify the <code>Renderer</code> plug-in.</font>
</ol>
<h4>
<a name="96157"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Writing Media Data to a File</font>
</h4>
<p>
<a name="96269"> </a><font face="Palatino, Times New Roman, Times, serif">You can use a <code>DataSink</code> to read media data from <code>Processor </code>object's output <code>DataSource</code> and render the data to a file. </font>
</p>
<ol type="1">
<li value="1"><a name="96270"> </a><font face="Palatino, Times New Roman, Times, serif">Get the output <code>DataSource</code> from the <code>Processor</code> by calling <code>getDataOutput.</code></font>
<li value="2"><a name="97335"> </a><font face="Palatino, Times New Roman, Times, serif">Construct a file writer <code>DataSink</code> by calling <code>Manager.createDataSink. </code>Pass in the output <code>DataSource</code> and a <code>MediaLocator</code> that specifies the location of the file to which you want to write.</font>
<li value="3"><a name="96271"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>open</code> on the <code>DataSink</code> to open the file.</font>
<li value="4"><a name="96272"> </a><font face="Palatino, Times New Roman, Times, serif">Call <code>start</code> on the <code>DataSink</code> to begin writing data.</font>
</ol>
<p>
<a name="97456"> </a><font face="Palatino, Times New Roman, Times, serif">The format of the data written to the specified file is controlled through the <code>Processor</code>. By default, a <code>Processor</code> outputs raw data. To change the content type of a <code>Processor</code> object's output <code>DataSource</code>, you use the <code>setContentDescriptor</code> method.</font>
</p>
<a name="97227"> </a><font size="1" face="Palatino, Times New Roman, Times, serif">
<table border="1" bordercolorlight="#FFFFFF" bordercolordark="#000000"
cellpadding="5" cellspacing="0">
<caption><b><i><font face="Palatino, Times New Roman, Times, serif"><a name="97233"> </a>Example 4-1: Using a DataSink to write media data to a file.</font></i></b></caption>
<tr>
<td><font face="Palatino, Times New Roman, Times, serif"><pre>
<a name="97241"> </a>DataSink sink;
<a name="97242"> </a>MediaLocator dest = new MediaLocator(file://newfile.wav);
<a name="97243"> </a>try{
<a name="97244"> </a> sink = Manager.createDataSink(p.getDataOutput(), dest);
<a name="97245"> </a> sink.open();
<a name="97246"> </a> sink.start();
<a name="97247"> </a>} catch (Exception) {}
</pre>
</font></td>
</tr>
</table>
<br></font>
<p>
<a name="97479"> </a><font face="Palatino, Times New Roman, Times, serif">A <code>Processor</code> can enable user control over the maximum number of bytes that it can write to its destination by implementing the <code>StreamWriterControl</code>. You find out if a <code>Processor</code> provides a <code>StreamWriterControl</code> by calling <code>getControl("javax.media.datasink.StreamWriterControl")</code> on the <code>Processor</code>. </font>
</p>
<h4>
<a name="97481"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Connecting a Processor to another Player</font>
</h4>
<p>
<a name="96309"> </a><font face="Palatino, Times New Roman, Times, serif">The output from a <code>Processor</code> can be used as the input to another <code>Player</code>. To get the output from a <code>Processor</code>, you call <code>getDataOutput</code>, which returns a <code>DataSource</code>. This <code>DataSource</code> can in turn be used to construct a <code>Player</code> or <code>Processor</code> through the <code>Manager</code>.</font>
</p>
<h3>
<a name="96323"> </a><font color="#003366" face="Palatino, Times New Roman, Times, serif">Using JMF Plug-Ins as Stand-alone Processing Modules</font>
</h3>
<p>
<a name="96492"> </a><font face="Palatino, Times New Roman, Times, serif">JMF Plug-ins can also be used outside of the JMF framework. You can instantiate the plug-in directly and call its processing method to perform the processing operation.</font>
</p>
<p>
<a name="96499"> </a><font face="Palatino, Times New Roman, Times, serif">You might want to do this to encode or decode a media stream, or convert a stream from one format to another.</font>
</p>
</blockquote>
<br clear="all">
<hr>
<a href="JMFTOC.html">CONTENTS</a> |
<a href="JMFPresenting.html">PREV </a> |
<a href="JMFCapturing.html">NEXT</a> |
<a href="JMFIX.html">INDEX</a></td>
<br>
<hr>
<em>
<a href="copyright.html">Copyright</a> ©
1998-1999 Sun Microsystems, Inc. All Rights Reserved.
</em>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -