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

73 lines
21 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="BMediaDecoder.html" title="BMediaDecoder" /><link rel="next" href="BMediaEventLooper.html" title="BMediaEventLooper" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BMediaDecoder.html" title="BMediaDecoder"><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="BMediaEventLooper.html" title="BMediaEventLooper"><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="BMediaDecoder.html">BMediaDecoder</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BMediaEventLooper.html">BMediaEventLooper</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="BMediaEncoder"></a>BMediaEncoder</h2></div></div></div><a id="id1137266" 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></td></tr><tr><td>Mix-in Classes:</td><td></td></tr><tr><td>Declared In:</td><td><code class="filename">media/MediaEncoder.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="BMediaEncoderDecoder_Overview.html" title="BMediaEncoder &amp; BMediaDecoder">Class Overview</a>
<div class="toc"><ul><li><span class="section"><a href="BMediaEncoder.html#BMediaEncoder_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BMediaEncoder.html#BMediaEncoder_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="BMediaEncoder_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="BMediaEncoder_Constructor"></a>BMediaEncoder()</h4></div></div></div><div class="synopsisgroup">
<code class="constructorsynopsis cpp"><span class="methodname">BMediaEncoder</span>();</code>
<code class="constructorsynopsis cpp"><span class="methodname">BMediaEncoder</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_format* </span><span class="parameter">outputFormat</span></span>);</code>
<code class="constructorsynopsis cpp"><span class="methodname">BMediaEncoder</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_codec_info* </span><span class="parameter">mci</span></span>);</code>
</div><p>The constructor sets up the <code class="classname">BMediaEncoder</code>.
If you use the empty form of the constructor, you'll have to call
<a class="link" href="BMediaEncoder.html#BMediaEncoder_SetTo" title="SetTo()"><code class="methodname">SetTo()</code></a>
to establish the format to be encoded before calling
<a class="link" href="BMediaEncoder.html#BMediaEncoder_Encode" title="Encode()"><code class="methodname">Encode()</code></a>.</p><p>The second form accepts a
<a class="link" href="TheMediaKit_DefinedTypes.html#media_format" title="media_format"><span class="type">media_format</span></a>
structure, <code class="parameter">inFormat</code>, that
indicates the type of media data that will be input into the encoder.</p><p>The third form of the constructor accepts a
<a class="link" href="BMediaFormats.html#media_codec_info" title="media_codec_info"><span class="type">media_codec_info</span></a>
structure, <code class="parameter">mci</code>, that determines which codec should be used.</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p>If you use either the
<a class="link" href="TheMediaKit_DefinedTypes.html#media_format" title="media_format"><span class="type">media_format</span></a> or
<a class="link" href="BMediaFormats.html#media_codec_info" title="media_codec_info"><span class="type">media_codec_info</span></a>
form of the constructor, you must call
<a class="link" href="BMediaEncoder.html#BMediaEncoder_InitCheck" title="InitCheck()"><code class="methodname">InitCheck()</code></a>
to ensure that construction was successful before using any other functions in this class.</p></div></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="BMediaEncoder_Destructor"></a>~BMediaEncoder()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="modifier">virtual </span><span class="methodname">~BMediaEncoder</span>();</code><p>Releases the encoder add-on being used by the
<code class="classname">BMediaEncoder</code>.</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="BMediaEncoder_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="BMediaEncoder_AddTrackInfo"></a>AddTrackInfo()</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="type">status_t </span><span class="methodname">AddTrackInfo</span>(<span class="methodparam"><span class="type">uint32 </span><span class="parameter">code</span></span>,<br />                      <span class="methodparam"><span class="modifier">const </span><span class="type">char* </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>In derived classes, you should implement this function to write track
information into the output file. <code class="parameter">code</code> indicates the type of information
being added, and <code class="parameter">data</code> is the information data itself.
<code class="parameter">size</code> indicates the
size of the data to be written.</p><p>By default, this function returns <code class="constant">B_ERROR</code>. Your implementation should
return <code class="constant">B_OK</code> if the information was written successfully; otherwise it
should return an appropriate 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="BMediaEncoder_Encode"></a>Encode()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">Encode</span>(<span class="methodparam"><span class="type">void* </span><span class="parameter">inBuffer</span></span>,<br />                <span class="methodparam"><span class="type">int64 </span><span class="parameter">frameCount</span></span>,<br />                <span class="methodparam"><span class="type">media_encode_info* </span><span class="parameter">info</span></span>);</code><p>Encodes a chunk of media data from the input buffer by <code class="parameter">inBuffer</code>, which
contains <code class="parameter">frameCount</code> frames of data.</p><p>The
<a class="link" href="TheMediaKit_DefinedTypes.html#media_encode_info" title="media_encode_info"><span class="type">media_encode_info</span></a>
structure info is used on input to specify encoding parameters.</p><p>After the data is encoded, the encoder will call the derived class'
<a class="link" href="BMediaEncoder.html#BMediaEncoder_WriteChunk" title="WriteChunk()"><code class="methodname">WriteChunk()</code></a>
function to write the data into the file.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p>No error.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_NO_INIT</code></span></p></td><td><p>The <code class="classname">BMediaEncoder</code> hasn't been initialized.</p></td></tr><tr><td><p><span class="term">Other errors.</span></p></td><td><p>The encoder's Encode() function can return errors.</p></td></tr></tbody></table></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="BMediaEncoder_GetEncodeParameters"></a><a id="BMediaEncoder_SetEncodeParameters"></a>
GetEncodeParameters(), SetEncodeParameters()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">GetEncodeParameters</span>(<span class="methodparam"><span class="type">encode_parameters* </span><span class="parameter">inParameters</span></span>) <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetEncodeParameters</span>(<span class="methodparam"><span class="type">encode_parameters* </span><span class="parameter">outParameters</span></span>);</code><p><code class="methodname">GetEncodeParameters()</code> returns in
<code class="parameter">inParameters</code> the
<a class="link" href="TheMediaKit_DefinedTypes.html#encode_parameters" title="encode_parameters"><span class="type">encode_parameters</span></a>
describing how the encoder add-on is configured.</p><p><code class="methodname">SetEncodeParameters()</code> let you specify the
<a class="link" href="TheMediaKit_DefinedTypes.html#encode_parameters" title="encode_parameters"><span class="type">encode_parameters</span></a>
for the add-on.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p>No error.</p></td></tr></tbody></table></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="BMediaEncoder_InitCheck"></a>InitCheck()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">InitCheck</span>() <span class="modifier">const</span>;</code><p>Returns a <span class="type">status_t</span> value indicating whether or not construction was
successful. You must call this function after construction before calling
any other <code class="classname">BMediaEncoder</code> functions.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p></p></td></tr><tr><td><p><span class="term">Other Errors</span></p></td><td><p>See <a class="link" href="BMediaEncoder.html#BMediaEncoder_SetTo" title="SetTo()"><code class="methodname">SetTo()</code></a></p></td></tr></tbody></table></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="BMediaEncoder_SetFormat"></a>SetFormat()</h4></div></div></div><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetFormat</span>(<span class="methodparam"><span class="type">media_format* </span><span class="parameter">inputFormat</span></span>,<br />                   <span class="methodparam"><span class="type">media_format* </span><span class="parameter">outputFormat</span></span>,<br />                   <span class="methodparam"><span class="type">media_file_format* </span><span class="parameter">mfi</span><span class="initializer"> = <span class="constant">NULL</span></span></span>);</code><p><code class="methodname">SetFormat()</code> sets the input and output formats to be used by the encoder,
as well as the
<a class="link" href="TheMediaKit_DefinedTypes.html#media_file_format" title="media_file_format"><span class="type">media_file_format</span></a>
describing the file to which the encoded data will be written.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p>No error.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_NO_INIT</code></span></p></td><td><p>The <code class="classname">BMediaEncoder</code> hasn't been initialized yet.</p></td></tr></tbody></table></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="BMediaEncoder_SetTo"></a>SetTo()</h4></div></div></div><div class="synopsisgroup">
<code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetTo</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_format* </span><span class="parameter">outputFormat</span></span>);</code>
<code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">SetTo</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">media_codec_info* </span><span class="parameter">mci</span></span>);</code>
</div><p><code class="methodname">SetTo()</code> sets the format of media data
that will be encoded by the <code class="classname">BMediaEncoder</code>
object. This also causes the <code class="classname">BMediaEncoder</code> to
locate an appropriate codec to use.</p><p>The first form accepts a
<a class="link" href="TheMediaKit_DefinedTypes.html#media_format" title="media_format"><span class="type">media_format</span></a>
structure, <code class="parameter">outputFormat</code>, that
indicates the type of media data that the encoder should output.</p><p>The second form of <code class="methodname">SetTo()</code> accepts a
<a class="link" href="BMediaFormats.html#media_codec_info" title="media_codec_info"><span class="type">media_codec_info</span></a>
structure, <code class="parameter">mci</code>,
that determines which codec should be used.</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p>No error.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_NO_INIT</code></span></p></td><td><p>The <code class="classname">BMediaEncoder</code> isn't initialized.</p></td></tr><tr><td><p><span class="term">Other Errors.</span></p></td><td><p>See
<a class="link" href="BMediaFormats.html#get_next_encoder" title="get_next_encoder()"><code class="function">get_next_encoder()</code></a> and
<a class="link" href="TheKernelKit_Images.html#get_image_symbol" title="get_image_symbol(), get_nth_image_symbol()"><code class="function">get_image_symbol()</code></a></p></td></tr></tbody></table></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="BMediaEncoder_WriteChunk"></a>WriteChunk()</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">SetTo</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">void* </span><span class="parameter">chunkData</span></span>,<br />                       <span class="methodparam"><span class="type">size_t </span><span class="parameter">chunkLength</span></span>,<br />                       <span class="methodparam"><span class="type">media_encode_info* </span><span class="parameter">info</span></span>) <span class="modifier"> = 0</span>;</code><p>In derived classes, you should implement this function to write the chunk
of encoded data pointed to by <code class="parameter">chunkData</code> into the destination file or
buffer. <code class="parameter">chunkLength</code> indicates the size of the buffer, and info provides
information about the encoding process that you might need to reference.</p><p>Return <code class="constant">B_OK</code> if the data is successfully written; otherwise return an
appropriate error code.</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BMediaDecoder.html">BMediaDecoder</a>  Up: <a href="TheMediaKit.html">The Media Kit</a>  Next: <a href="BMediaEventLooper.html">BMediaEventLooper</a> </div><div id="footerB"><div id="footerBL"><a href="BMediaDecoder.html" title="BMediaDecoder"><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="BMediaEventLooper.html" title="BMediaEventLooper"><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>