1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>GstDmaBufAllocator: GStreamer Base Plugins 1.0 Library Reference Manual</title> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="index.html" title="GStreamer Base Plugins 1.0 Library Reference Manual"> 8<link rel="up" href="gstreamer-allocators.html" title="Allocators Library"> 9<link rel="prev" href="gstreamer-allocators.html" title="Allocators Library"> 10<link rel="next" href="gst-plugins-base-libs-fdmemory.html" title="GstFdAllocator"> 11<meta name="generator" content="GTK-Doc V1.28 (XML mode)"> 12<link rel="stylesheet" href="style.css" type="text/css"> 13</head> 14<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 15<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> 16<td width="100%" align="left" class="shortcuts"> 17<a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span> 18 <a href="#gst-plugins-base-libs-dmabuf.description" class="shortcut">Description</a></span><span id="nav_hierarchy"> <span class="dim">|</span> 19 <a href="#gst-plugins-base-libs-dmabuf.object-hierarchy" class="shortcut">Object Hierarchy</a></span> 20</td> 21<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> 22<td><a accesskey="u" href="gstreamer-allocators.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> 23<td><a accesskey="p" href="gstreamer-allocators.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> 24<td><a accesskey="n" href="gst-plugins-base-libs-fdmemory.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> 25</tr></table> 26<div class="refentry"> 27<a name="gst-plugins-base-libs-dmabuf"></a><div class="titlepage"></div> 28<div class="refnamediv"><table width="100%"><tr> 29<td valign="top"> 30<h2><span class="refentrytitle"><a name="gst-plugins-base-libs-dmabuf.top_of_page"></a>GstDmaBufAllocator</span></h2> 31<p>GstDmaBufAllocator — Memory wrapper for Linux dmabuf memory</p> 32</td> 33<td class="gallery_image" valign="top" align="right"></td> 34</tr></table></div> 35<div class="refsect1"> 36<a name="gst-plugins-base-libs-dmabuf.functions"></a><h2>Functions</h2> 37<div class="informaltable"><table class="informaltable" width="100%" border="0"> 38<colgroup> 39<col width="150px" class="functions_return"> 40<col class="functions_name"> 41</colgroup> 42<tbody> 43<tr> 44<td class="function_type"> 45<a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstAllocator.html#GstAllocator-struct"><span class="returnvalue">GstAllocator</span></a> * 46</td> 47<td class="function_name"> 48<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-dmabuf-allocator-new" title="gst_dmabuf_allocator_new ()">gst_dmabuf_allocator_new</a> <span class="c_punctuation">()</span> 49</td> 50</tr> 51<tr> 52<td class="function_type"> 53<a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="returnvalue">GstMemory</span></a> * 54</td> 55<td class="function_name"> 56<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-dmabuf-allocator-alloc" title="gst_dmabuf_allocator_alloc ()">gst_dmabuf_allocator_alloc</a> <span class="c_punctuation">()</span> 57</td> 58</tr> 59<tr> 60<td class="function_type"> 61<a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="returnvalue">GstMemory</span></a> * 62</td> 63<td class="function_name"> 64<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-dmabuf-allocator-alloc-with-flags" title="gst_dmabuf_allocator_alloc_with_flags ()">gst_dmabuf_allocator_alloc_with_flags</a> <span class="c_punctuation">()</span> 65</td> 66</tr> 67<tr> 68<td class="function_type"> 69<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> 70</td> 71<td class="function_name"> 72<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-dmabuf-memory-get-fd" title="gst_dmabuf_memory_get_fd ()">gst_dmabuf_memory_get_fd</a> <span class="c_punctuation">()</span> 73</td> 74</tr> 75<tr> 76<td class="function_type"> 77<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> 78</td> 79<td class="function_name"> 80<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-is-dmabuf-memory" title="gst_is_dmabuf_memory ()">gst_is_dmabuf_memory</a> <span class="c_punctuation">()</span> 81</td> 82</tr> 83</tbody> 84</table></div> 85</div> 86<a name="GstDmaBufAllocator"></a><div class="refsect1"> 87<a name="gst-plugins-base-libs-dmabuf.other"></a><h2>Types and Values</h2> 88<div class="informaltable"><table class="informaltable" width="100%" border="0"> 89<colgroup> 90<col width="150px" class="name"> 91<col class="description"> 92</colgroup> 93<tbody><tr> 94<td class="define_keyword">#define</td> 95<td class="function_name"><a class="link" href="gst-plugins-base-libs-dmabuf.html#GST-CAPS-FEATURE-MEMORY-DMABUF:CAPS" title="GST_CAPS_FEATURE_MEMORY_DMABUF">GST_CAPS_FEATURE_MEMORY_DMABUF</a></td> 96</tr></tbody> 97</table></div> 98</div> 99<div class="refsect1"> 100<a name="gst-plugins-base-libs-dmabuf.object-hierarchy"></a><h2>Object Hierarchy</h2> 101<pre class="screen"> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject-struct">GObject</a> 102 <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned">GInitiallyUnowned</a> 103 <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstObject.html#GstObject-struct">GstObject</a> 104 <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstAllocator.html#GstAllocator-struct">GstAllocator</a> 105 <span class="lineart">╰──</span> <a class="link" href="gst-plugins-base-libs-fdmemory.html#GstFdAllocator">GstFdAllocator</a> 106 <span class="lineart">╰──</span> GstDmaBufAllocator 107</pre> 108</div> 109<div class="refsect1"> 110<a name="gst-plugins-base-libs-dmabuf.includes"></a><h2>Includes</h2> 111<pre class="synopsis">#include <gst/allocators/allocators.h> 112</pre> 113</div> 114<div class="refsect1"> 115<a name="gst-plugins-base-libs-dmabuf.description"></a><h2>Description</h2> 116</div> 117<div class="refsect1"> 118<a name="gst-plugins-base-libs-dmabuf.functions_details"></a><h2>Functions</h2> 119<div class="refsect2"> 120<a name="gst-dmabuf-allocator-new"></a><h3>gst_dmabuf_allocator_new ()</h3> 121<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstAllocator.html#GstAllocator-struct"><span class="returnvalue">GstAllocator</span></a> * 122gst_dmabuf_allocator_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre> 123<p>Return a new dmabuf allocator.</p> 124<div class="refsect3"> 125<a name="gst-dmabuf-allocator-new.returns"></a><h4>Returns</h4> 126<p>a new dmabuf allocator, or NULL if the allocator 127isn't available. Use <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstObject.html#gst-object-unref"><code class="function">gst_object_unref()</code></a> to release the allocator after 128usage. </p> 129<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> 130</div> 131<p class="since">Since: <a class="link" href="ix14.html#api-index-1.2">1.2</a></p> 132</div> 133<hr> 134<div class="refsect2"> 135<a name="gst-dmabuf-allocator-alloc"></a><h3>gst_dmabuf_allocator_alloc ()</h3> 136<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="returnvalue">GstMemory</span></a> * 137gst_dmabuf_allocator_alloc (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstAllocator.html#GstAllocator-struct"><span class="type">GstAllocator</span></a> *allocator</code></em>, 138 <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>, 139 <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>);</pre> 140<p>Return a <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><code class="literal">GstMemory</code></a> that wraps a dmabuf file descriptor.</p> 141<div class="refsect3"> 142<a name="gst-dmabuf-allocator-alloc.parameters"></a><h4>Parameters</h4> 143<div class="informaltable"><table class="informaltable" width="100%" border="0"> 144<colgroup> 145<col width="150px" class="parameters_name"> 146<col class="parameters_description"> 147<col width="200px" class="parameters_annotations"> 148</colgroup> 149<tbody> 150<tr> 151<td class="parameter_name"><p>allocator</p></td> 152<td class="parameter_description"><p>allocator to be used for this memory</p></td> 153<td class="parameter_annotations"> </td> 154</tr> 155<tr> 156<td class="parameter_name"><p>fd</p></td> 157<td class="parameter_description"><p>dmabuf file descriptor</p></td> 158<td class="parameter_annotations"> </td> 159</tr> 160<tr> 161<td class="parameter_name"><p>size</p></td> 162<td class="parameter_description"><p>memory size</p></td> 163<td class="parameter_annotations"> </td> 164</tr> 165</tbody> 166</table></div> 167</div> 168<div class="refsect3"> 169<a name="gst-dmabuf-allocator-alloc.returns"></a><h4>Returns</h4> 170<p>a GstMemory based on <em class="parameter"><code>allocator</code></em> 171. 172When the buffer will be released dmabuf allocator will close the <em class="parameter"><code>fd</code></em> 173. 174The memory is only mmapped on <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstBuffer.html#gst-buffer-map"><code class="function">gst_buffer_map()</code></a> request. </p> 175<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> 176</div> 177<p class="since">Since: <a class="link" href="ix14.html#api-index-1.2">1.2</a></p> 178</div> 179<hr> 180<div class="refsect2"> 181<a name="gst-dmabuf-allocator-alloc-with-flags"></a><h3>gst_dmabuf_allocator_alloc_with_flags ()</h3> 182<pre class="programlisting"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="returnvalue">GstMemory</span></a> * 183gst_dmabuf_allocator_alloc_with_flags (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstAllocator.html#GstAllocator-struct"><span class="type">GstAllocator</span></a> *allocator</code></em>, 184 <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>, 185 <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, 186 <em class="parameter"><code><a class="link" href="gst-plugins-base-libs-fdmemory.html#GstFdMemoryFlags" title="enum GstFdMemoryFlags"><span class="type">GstFdMemoryFlags</span></a> flags</code></em>);</pre> 187<p>Return a <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><code class="literal">GstMemory</code></a> that wraps a dmabuf file descriptor.</p> 188<div class="refsect3"> 189<a name="gst-dmabuf-allocator-alloc-with-flags.parameters"></a><h4>Parameters</h4> 190<div class="informaltable"><table class="informaltable" width="100%" border="0"> 191<colgroup> 192<col width="150px" class="parameters_name"> 193<col class="parameters_description"> 194<col width="200px" class="parameters_annotations"> 195</colgroup> 196<tbody> 197<tr> 198<td class="parameter_name"><p>allocator</p></td> 199<td class="parameter_description"><p>allocator to be used for this memory</p></td> 200<td class="parameter_annotations"> </td> 201</tr> 202<tr> 203<td class="parameter_name"><p>fd</p></td> 204<td class="parameter_description"><p>dmabuf file descriptor</p></td> 205<td class="parameter_annotations"> </td> 206</tr> 207<tr> 208<td class="parameter_name"><p>size</p></td> 209<td class="parameter_description"><p>memory size</p></td> 210<td class="parameter_annotations"> </td> 211</tr> 212<tr> 213<td class="parameter_name"><p>flags</p></td> 214<td class="parameter_description"><p>extra <a class="link" href="gst-plugins-base-libs-fdmemory.html#GstFdMemoryFlags" title="enum GstFdMemoryFlags"><span class="type">GstFdMemoryFlags</span></a></p></td> 215<td class="parameter_annotations"> </td> 216</tr> 217</tbody> 218</table></div> 219</div> 220<div class="refsect3"> 221<a name="gst-dmabuf-allocator-alloc-with-flags.returns"></a><h4>Returns</h4> 222<p>a GstMemory based on <em class="parameter"><code>allocator</code></em> 223.</p> 224<p>When the buffer will be released the allocator will close the <em class="parameter"><code>fd</code></em> 225unless 226the <a class="link" href="gst-plugins-base-libs-fdmemory.html#GST-FD-MEMORY-FLAG-DONT-CLOSE:CAPS"><code class="literal">GST_FD_MEMORY_FLAG_DONT_CLOSE</code></a> flag is specified. 227The memory is only mmapped on <code class="function">gst_buffer_mmap()</code> request. </p> 228<p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> 229</div> 230<p class="since">Since: <a class="link" href="ix03.html#api-index-1.16">1.16</a></p> 231</div> 232<hr> 233<div class="refsect2"> 234<a name="gst-dmabuf-memory-get-fd"></a><h3>gst_dmabuf_memory_get_fd ()</h3> 235<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> 236gst_dmabuf_memory_get_fd (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="type">GstMemory</span></a> *mem</code></em>);</pre> 237<p>Return the file descriptor associated with <em class="parameter"><code>mem</code></em> 238.</p> 239<div class="refsect3"> 240<a name="gst-dmabuf-memory-get-fd.parameters"></a><h4>Parameters</h4> 241<div class="informaltable"><table class="informaltable" width="100%" border="0"> 242<colgroup> 243<col width="150px" class="parameters_name"> 244<col class="parameters_description"> 245<col width="200px" class="parameters_annotations"> 246</colgroup> 247<tbody><tr> 248<td class="parameter_name"><p>mem</p></td> 249<td class="parameter_description"><p>the memory to get the file descriptor</p></td> 250<td class="parameter_annotations"> </td> 251</tr></tbody> 252</table></div> 253</div> 254<div class="refsect3"> 255<a name="gst-dmabuf-memory-get-fd.returns"></a><h4>Returns</h4> 256<p> the file descriptor associated with the memory, or -1. The file 257descriptor is still owned by the GstMemory. Use dup to take a copy 258if you intend to use it beyond the lifetime of this GstMemory.</p> 259</div> 260<p class="since">Since: <a class="link" href="ix14.html#api-index-1.2">1.2</a></p> 261</div> 262<hr> 263<div class="refsect2"> 264<a name="gst-is-dmabuf-memory"></a><h3>gst_is_dmabuf_memory ()</h3> 265<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> 266gst_is_dmabuf_memory (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="type">GstMemory</span></a> *mem</code></em>);</pre> 267<p>Check if <em class="parameter"><code>mem</code></em> 268 is dmabuf memory.</p> 269<div class="refsect3"> 270<a name="gst-is-dmabuf-memory.parameters"></a><h4>Parameters</h4> 271<div class="informaltable"><table class="informaltable" width="100%" border="0"> 272<colgroup> 273<col width="150px" class="parameters_name"> 274<col class="parameters_description"> 275<col width="200px" class="parameters_annotations"> 276</colgroup> 277<tbody><tr> 278<td class="parameter_name"><p>mem</p></td> 279<td class="parameter_description"><p>the memory to be check</p></td> 280<td class="parameter_annotations"> </td> 281</tr></tbody> 282</table></div> 283</div> 284<div class="refsect3"> 285<a name="gst-is-dmabuf-memory.returns"></a><h4>Returns</h4> 286<p> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>mem</code></em> 287is dmabuf memory, otherwise <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a></p> 288</div> 289<p class="since">Since: <a class="link" href="ix14.html#api-index-1.2">1.2</a></p> 290</div> 291</div> 292<div class="refsect1"> 293<a name="gst-plugins-base-libs-dmabuf.other_details"></a><h2>Types and Values</h2> 294<div class="refsect2"> 295<a name="GST-CAPS-FEATURE-MEMORY-DMABUF:CAPS"></a><h3>GST_CAPS_FEATURE_MEMORY_DMABUF</h3> 296<pre class="programlisting">#define GST_CAPS_FEATURE_MEMORY_DMABUF "memory:DMABuf" 297</pre> 298<p>Constant that defines the caps feature name for DMA buffer sharing.</p> 299<p>It has to be used for non-mappable dma-buf only, i.e. when the underlying 300memory is not mappable to user space. Or when the mapped memory contains 301non meaningful data. It can be the case for protected content or when the 302user wants explicitly avoid any software post processing.</p> 303<p>In these cases all elements between the exported and the importer has to work 304in passthrough mode. This is done by adding this caps feature.</p> 305<p>When the memory is mappable for read and write requests then it is assumes 306to be a fast path and so this caps feature should not be used. Though 307according to the dma-buf protocal, while it is mapped it prevents the 308exporter to migrate the buffer.</p> 309<p>This caps feature should not serve at all the purpose of selecting the 310<em class="parameter"><code>GST_ALLOCATOR_DMABUF</code></em> 311 allocator during caps negotiation. 312When the exporter is the upstream element from the importer point of view, 313the exporter should try to map the dma buffer at runtime (preferrably during 314decide_allocation phase). When it succeeds for <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GST-MAP-READWRITE:CAPS"><span class="type">GST_MAP_READWRITE</span></a> this caps 315feature should not be used. This allows scalers, color converts and any image 316processing filters to work directly on the dma buffer. 317In this case the importer element should check all incomming memory using 318<a class="link" href="gst-plugins-base-libs-dmabuf.html#gst-is-dmabuf-memory" title="gst_is_dmabuf_memory ()"><code class="function">gst_is_dmabuf_memory()</code></a>.</p> 319<p class="since">Since: <a class="link" href="ix05.html#api-index-1.12">1.12</a></p> 320</div> 321</div> 322<div class="refsect1"> 323<a name="gst-plugins-base-libs-dmabuf.see-also"></a><h2>See Also</h2> 324<p><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMemory.html#GstMemory-struct"><span class="type">GstMemory</span></a></p> 325</div> 326</div> 327<div class="footer"> 328<hr>Generated by GTK-Doc V1.28</div> 329</body> 330</html>