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

84 lines
11 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.

<?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 - System Overview - 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_Overview.html" title="The Media Kit" /><link rel="prev" href="BBufferGroup_Overview.html" title="BBufferGroup" /><link rel="next" href="BContinuousParameter_Overview.html" title="BContinuousParameter" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BBufferGroup_Overview.html" title="BBufferGroup"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheMediaKit_Overview.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BContinuousParameter_Overview.html" title="BContinuousParameter"><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 - System Overview - The Media Kit</div></div><div id="headerB">Prev: <a href="BBufferGroup_Overview.html">BBufferGroup</a>  Up: <a href="TheMediaKit_Overview.html">The Media Kit</a>  Next: <a href="BContinuousParameter_Overview.html">BContinuousParameter</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="BBufferProducer_Overview"></a>BBufferProducer</h2></div></div></div><a id="id584364" class="indexterm"></a><p>A <a class="link" href="BBufferProducer.html" title="BBufferProducer"><code class="classname">BBufferProducer</code></a>
is a
<a class="link" href="BMediaNode.html" title="BMediaNode"><code class="classname">BMediaNode</code></a>
that emits buffers containing media data that other nodes
(<a class="link" href="BBufferConsumer.html" title="BBufferConsumer"><code class="classname">BBufferConsumer</code></a>s
in particular) will receive and, potentially, process. If
your node wants to emit buffers, it must be derived from
<a class="link" href="BBufferProducer.html" title="BBufferProducer"><code class="classname">BBufferProducer</code></a>
and override the hook functions to implement the
<a class="link" href="BBufferProducer.html" title="BBufferProducer"><code class="classname">BBufferProducer</code></a>
protocol.</p><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="BBufferProducer_Overview_VideoClipping"></a>Video Clipping</h3></div></div></div><p>Currently, the only video clipping format supported by the Media Kit is
<code class="constant">B_CLIP_SHORT_RUNS</code>, although there is a function in this class for
converting between this format and
<a class="link" href="BRegion.html" title="BRegion"><code class="classname">BRegion</code></a>s.</p><p>This format begins with a header, consisting of two <span class="type">int16</span> values:</p><table class="variablelist fields"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="varname">offsetX</code></span></p></td><td><p>X offset for all following coordinates.</p></td></tr><tr><td><p><span class="term"><code class="varname">offsetY</code></span></p></td><td><p>Y offset for all following coordinates.</p></td></tr></tbody></table><p>These values indicate the offset for the X and Y coordinates indicated
throughout the rest of the clipping data.</p><p>The remainder of the clipping data consists of entries indicating each
line of video data, as follows:</p><table class="variablelist fields"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="varname">numShorts</code></span></p></td><td><p>The number of values in the <code class="varname">coordList</code>. Always an even number.
If negative, repeats the previous entry <code class="varname">numShorts</code> times.</p></td></tr><tr><td><p><span class="term"><code class="varname">coordList…</code></span></p></td><td><p>List of coordinates. Even entries are left-edge X
coordinates, odd entries are right-edge X coordinates.</p></td></tr></tbody></table><p>The clipping data contains one of these entries for each time the
clipping information changes.</p><p>For example, if the clipping is a rectangle with the left edge at 100,
top edge at 50, right edge at 300, and bottom edge at 200, the clipping
data for a 640x480 display might be:</p><pre class="screen">header
offsetX: 0
offsetY: 50
entry 1
numShorts: 2
coordList: 100, 300
entry 2
numShorts: -150
entry 3
numShorts: 2
coordList: 0, 639
entry 4
numShorts: -280</pre><p>The header indicates that the clipping data begins at row 50.</p><p>The first entry indicates that clipping should span from column 100 to
column 300 on the first row of clipping (row 50). The second entry says
to repeat this 150 times.</p><p>Entry 3 indicates that clipping from that point on should be from column
0 to column 639 (the entire width of the display). Entry 4 causes this to
repeat 280 times, to the bottom of the display.</p></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="BBufferProducer_Overview_SeekTags"></a>Seek Tags</h3></div></div></div><p>In order to support media formats that don't provide timing information
in their outer encapsulation layer, or to provide enhanced seeking
performance for media formats that support key frames, the Media Kit
supports the concept of seek tags. Producers that know their data doesn't
have timing information, or that can provide enhanced seeking using
special tags, should put a tag in the <code class="varname">user_data</code> field of the buffer
headers it sends. This tag can contain any data the producer wants.</p><p>Consumers that can derive good timing information from these packets
after decoding them should then choose appropriate seek points (usually
key frames) and cache the performance time and tag values of the first
buffer that arrives at that seek point.</p><p>Producers that can't seek without help from the decoder can then query
the consumer by calling
<a class="link" href="BBufferProducer.html#BBufferProducer_FindSeekTag" title="FindSeekTag()"><code class="methodname">FindSeekTag()</code></a>.
This causes the consumer's
<a class="link" href="BBufferConsumer.html#BBufferConsumer_SeekTagRequested" title="SeekTagRequested()"><code class="methodname">SeekTagRequested()</code></a>
function to be called. This returns the seek tag and
time that are closest to the requested time. The producer can then use
this information locate the appropriate point in the media data.</p><p>The easiest way to use this is to use the file offset as the tag data,
but any value that makes sense to the producer can be used, since the
consumer just saves a copy of the data and passes it back without looking
at it.</p><pre class="screen">Time Seek Tag
0.0 seconds 0
0.1 seconds &lt;none&gt;
0.2 seconds 2
0.3 seconds &lt;none&gt;</pre><p>In this simple example, we have four buffers, two of which have seek tags
recorded (at 0.0 seconds and 0.3 seconds). If the producer is seeking to
0.2 seconds, it would call
<a class="link" href="BBufferProducer.html#BBufferProducer_FindSeekTag" title="FindSeekTag()"><code class="methodname">FindSeekTag()</code></a>,
like this:</p><pre class="programlisting example cpp"><span class="type">media_seek_tag</span> <code class="varname">tag</code>;
<span class="type">bigtime_t</span> <code class="varname">time</code>;
<code class="methodname">FindSeekTag</code>(&amp;<code class="varname">destination</code>, 0.2*1000000, &amp;<code class="varname">tag</code>, &amp;<code class="varname">time</code>);
<span class="comment">/* now we can use the tag to seek */</span></pre><p>If the tag contains a file offset, we can simply seek to that offset in
the file and we're ready to go.</p><p>In this example, the returned tag is "2" and the time is 0.2 seconds,
because there's a seek tag located precisely at the requested time.
However, if we look for a seek tag for 0.1 seconds, we get a returned tag
of "0" and a time of 0.0 seconds, because that's the closest matching tag
to the requested time.</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BBufferGroup_Overview.html">BBufferGroup</a>  Up: <a href="TheMediaKit_Overview.html">The Media Kit</a>  Next: <a href="BContinuousParameter_Overview.html">BContinuousParameter</a> </div><div id="footerB"><div id="footerBL"><a href="BBufferGroup_Overview.html" title="BBufferGroup"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheMediaKit_Overview.html" title="The Media Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BContinuousParameter_Overview.html" title="BContinuousParameter"><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>