haiku-website/static/legacy-docs/bebook/BFileInterface.html

60 lines
17 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Media Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheMediaKit.html" title="The Media Kit" /><link rel="prev" href="BDiscreteParameter.html" title="BDiscreteParameter" /><link rel="next" href="BMediaAddOn.html" title="BMediaAddOn" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BDiscreteParameter.html" title="BDiscreteParameter"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheMediaKit.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BMediaAddOn.html" title="BMediaAddOn"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Media Kit</div></div><div id="headerB">Prev: <a href="BDiscreteParameter.html">BDiscreteParameter</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BMediaAddOn.html">BMediaAddOn</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface"></a>BFileInterface</h2></div></div></div><a id="id1130545" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td><a class="link" href="BMediaNode.html" title="BMediaNode"><code class="classname">BMediaNode</code></a></td></tr><tr><td>Mix-in Classes:</td><td></td></tr><tr><td>Declared In:</td><td><code class="filename">media/FileInterface.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libmedia.so</code></td></tr><tr><td>Allocation:</td><td>Constructor only</td></tr></tbody></table></td><td>
<a class="link overview" href="BFileInterface_Overview.html" title="BFileInterface">Class Overview</a>
<div class="toc"><ul><li><span class="section"><a href="BFileInterface.html#BFileInterface_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BFileInterface.html#BFileInterface_MemberFunctions">Member Functions</a></span></li></ul></div>
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_Constructor"></a>BFileInterface()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="constructorsynopsis cpp"><span class="methodname">BFileInterface</span>();</code><p>Constructor.</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_DisposeFileFormatCookie"></a>DisposeFileFormatCookie()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="void">void </span><span class="methodname">DisposeFileFormatCookie</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">cookie</span></span>) <span class="modifier"> = 0</span>;</code><p>This function must be implemented to dispose of a <code class="parameter">cookie</code> used for
iterating over file formats your node supports. If the cookie is a
reference to a data block, you should free it; otherwise, you can just
return without doing anything.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_HandleMessage"></a>HandleMessage()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">HandleMessage</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">message</span></span>,<br />                               <span class="methodparam"><span class="modifier">const </span><span class="type">void* </span><span class="parameter">data</span></span>,<br />                               <span class="methodparam"><span class="type">size_t </span><span class="parameter">size</span></span>);</code><p>Implement this function to handle messages that arrive on your control
port; see
<a class="link" href="BMediaNode.html#BMediaNode_HandleMessage" title="HandleMessage()"><code class="methodname">BMediaNode::HandleMessage()</code></a>
for details.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_GetDuration"></a>GetDuration()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">GetDuration</span>(<span class="methodparam"><span class="type">bigtime_t* </span><span class="parameter">outDuration</span></span>) <span class="modifier"> = 0</span>;</code><p>Implement this function to return in <code class="parameter">outDuration</code> the duration, in
microseconds of the media data in the file currently being worked on.</p><p>If there is no file in use, or the file isn't valid, return a negative
error code; otherwise, return <code class="constant">B_OK</code>.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_GetNextFileFormat"></a>GetNextFileFormat()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">GetNextFileFormat</span>(<span class="methodparam"><span class="type">int32* </span><span class="parameter">cookie</span></span>,<br />                                   <span class="methodparam"><span class="type">media_file_format* </span><span class="parameter">outFormat</span></span>) <span class="modifier"> = 0</span>;</code><p>The first time this function is called, <code class="parameter">cookie</code> will be 0. Return
information about the first file format you support in <code class="parameter">outFormat</code> and set
cookie to some meaningful (non-zero) value that you can use to track
where you are in the list of formats you support, then return <code class="constant">B_OK</code>.</p><p>On successive calls to <code class="methodname">GetNextFileFormat()</code>, you should return successive
file format information and change <code class="parameter">cookie</code> as necessary to remember where
you are in the list. Return <code class="constant">B_OK</code> each time you successfully return
information about a file format.</p><p>Once you run out of formats, return <code class="constant">B_ERROR</code>.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_GetRef"></a><a id="BFileInterface_SetRef"></a>
GetRef(), SetRef()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">GetRef</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">entry_ref* </span><span class="parameter">outRef</span></span>,<br />                        <span class="methodparam"><span class="type"><span class="classname">BMimeType</span>* </span><span class="parameter">outMimeType</span></span>) <span class="modifier"> = 0</span>;</code><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SetRef</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">entry_ref&amp; </span><span class="parameter">file</span></span>,<br />                        <span class="methodparam"><span class="type">bool </span><span class="parameter">create</span></span>,<br />                        <span class="methodparam"><span class="type">bigtime_t* </span><span class="parameter">outDuration</span></span>) <span class="modifier"> = 0</span>;</code><p>Implement <code class="methodname">GetRef()</code> function to return,
in <code class="parameter">outRef</code>, the <span class="type">entry_ref</span> of the
file with which the node is currently working. You should also return the
MIME type of the file in <code class="parameter">outMimeType</code>.</p><p>When an application or other client wants your node to use a specific
file, the <code class="methodname">SetRef()</code> function will be called. The file to be used is
specified by <code class="parameter">file</code>, which may or may not exist.
If <code class="parameter">create</code> is <code class="constant">true</code>, you
should create a new file (erasing an existing file, if one's already
there), initialize the file for writing, then store 0 in <code class="parameter">outDuration</code>.</p><p>If <code class="parameter">create</code> is <code class="constant">false</code>,
you should open the existing file and put the actual
running time of the file into <code class="parameter">outDuration</code>.</p><p>Return <code class="constant">B_OK</code> if successful; otherwise, return a negative error code, as
appropriate. If you forget to implement these functions, they'll always
return <code class="constant">B_ERROR</code>.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BFileInterface_SniffRef"></a>SniffRef()</h4></div><div xmlns:d="http://docbook.org/ns/docbook"><h5 xmlns="http://www.w3.org/1999/xhtml" class="subtitle">protected</h5></div></div></div><code class="methodsynopsis cpp"><span class="modifier">virtual </span><span class="type">status_t </span><span class="methodname">SniffRef</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">entry_ref* </span><span class="parameter">file</span></span>,<br />                          <span class="methodparam"><span class="type">char* </span><span class="parameter">outMimeType</span></span>,<br />                          <span class="methodparam"><span class="type">float* </span><span class="parameter">outQuality</span></span>) <span class="modifier"> = 0</span>;</code><p>When the system (or an application program) finds an unknown file, it can
call <a class="link" href="BMediaRoster.html" title="BMediaRoster"><code class="classname">BMediaRoster</code></a>
to try to identify the file. Your node's <code class="methodname">SniffRef()</code>
function will be called so your node can look at the file.</p><p>Inspect the file referenced by file. If you can handle the format, set
<code class="parameter">outMimeType</code> to the <acronym class="acronym">MIME</acronym>
type of the file format (the buffer is 256 bytes
long), and set <code class="parameter">outQuality</code> to indicate how well you can process the file
(where 0.0 means you can't handle it at all and 1.0 means the file format
is a privately-owned format that your application handles perfectly).</p><p>If you know how to identify the file, but not how to play or record it,
return 0.0 for <code class="parameter">outQuality</code>.</p><p>If you know how to decode only some parts of the file, but not all of
them, set <code class="parameter">outQuality</code> to 0.4 or to 0.6 if you can handle both audio and
video contained in the file, but not other forms of media data that are
present.</p><p>Set <code class="parameter">outQuality</code> to 0.9 if
you can handle the format very well, but it's a
publicly-defined format whose specifications you don't control. You
should only return an <code class="parameter">outQuality</code> value of 1.0 if the file format
specifications are in your control and you implement them perfectly.</p><p>Interpolate between these values to give the best estimate you can of
your ability to handle the file, so selection of the most suitable node
can be made. For instance, if your node does low-quality but high-speed
processing of an audio format, you might subtract a little bit from the
<code class="parameter">outQuality</code> value you might otherwise return.</p><p>Return <code class="constant">B_OK</code> if you successfully sniff the file and have something to say
about its contents; otherwise return an appropriate error code. If you
don't know the file format at all, you should return <code class="constant">B_MEDIA_NO_HANDLER</code>.</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BDiscreteParameter.html">BDiscreteParameter</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BMediaAddOn.html">BMediaAddOn</a> </div><div id="footerB"><div id="footerBL"><a href="BDiscreteParameter.html" title="BDiscreteParameter"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheMediaKit.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BMediaAddOn.html" title="BMediaAddOn"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>