• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>level: GStreamer Good Plugins 1.0 Plugins Reference Manual</title>
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="index.html" title="GStreamer Good Plugins 1.0 Plugins Reference Manual">
8<link rel="up" href="ch01.html" title="gst-plugins-good Elements">
9<link rel="prev" href="gst-plugins-good-plugins-lamemp3enc.html" title="lamemp3enc">
10<link rel="next" href="gst-plugins-good-plugins-matroskademux.html" title="matroskademux">
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">|</span18                  <a href="#gst-plugins-good-plugins-level.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span19                  <a href="#gst-plugins-good-plugins-level.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_properties">  <span class="dim">|</span20                  <a href="#gst-plugins-good-plugins-level.properties" class="shortcut">Properties</a></span>
21</td>
22<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
23<td><a accesskey="u" href="ch01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
24<td><a accesskey="p" href="gst-plugins-good-plugins-lamemp3enc.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
25<td><a accesskey="n" href="gst-plugins-good-plugins-matroskademux.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
26</tr></table>
27<div class="refentry">
28<a name="gst-plugins-good-plugins-level"></a><div class="titlepage"></div>
29<div class="refnamediv"><table width="100%"><tr>
30<td valign="top">
31<h2><span class="refentrytitle"><a name="gst-plugins-good-plugins-level.top_of_page"></a>level</span></h2>
32<p>level</p>
33</td>
34<td class="gallery_image" valign="top" align="right"></td>
35</tr></table></div>
36<div class="refsect1">
37<a name="gst-plugins-good-plugins-level.properties"></a><h2>Properties</h2>
38<div class="informaltable"><table class="informaltable" border="0">
39<colgroup>
40<col width="150px" class="properties_type">
41<col width="300px" class="properties_name">
42<col width="200px" class="properties_flags">
43</colgroup>
44<tbody>
45<tr>
46<td class="property_type"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint64"><span class="type">guint64</span></a></td>
47<td class="property_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--interval" title="The “interval” property">interval</a></td>
48<td class="property_flags">Read / Write</td>
49</tr>
50<tr>
51<td class="property_type"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td>
52<td class="property_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--message" title="The “message” property">message</a></td>
53<td class="property_flags">Read / Write</td>
54</tr>
55<tr>
56<td class="property_type"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a></td>
57<td class="property_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--peak-falloff" title="The “peak-falloff” property">peak-falloff</a></td>
58<td class="property_flags">Read / Write</td>
59</tr>
60<tr>
61<td class="property_type"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint64"><span class="type">guint64</span></a></td>
62<td class="property_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--peak-ttl" title="The “peak-ttl” property">peak-ttl</a></td>
63<td class="property_flags">Read / Write</td>
64</tr>
65<tr>
66<td class="property_type"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td>
67<td class="property_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--post-messages" title="The “post-messages” property">post-messages</a></td>
68<td class="property_flags">Read / Write</td>
69</tr>
70</tbody>
71</table></div>
72</div>
73<a name="GstLevel"></a><div class="refsect1">
74<a name="gst-plugins-good-plugins-level.other"></a><h2>Types and Values</h2>
75<div class="informaltable"><table class="informaltable" width="100%" border="0">
76<colgroup>
77<col width="150px" class="name">
78<col class="description">
79</colgroup>
80<tbody><tr>
81<td class="datatype_keyword">struct</td>
82<td class="function_name"><a class="link" href="gst-plugins-good-plugins-level.html#GstLevel-struct" title="struct GstLevel">GstLevel</a></td>
83</tr></tbody>
84</table></div>
85</div>
86<div class="refsect1">
87<a name="gst-plugins-good-plugins-level.object-hierarchy"></a><h2>Object Hierarchy</h2>
88<pre class="screen">    <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject-struct">GObject</a>
89    <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned">GInitiallyUnowned</a>
90        <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstObject.html#GstObject-struct">GstObject</a>
91            <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#GstElement-struct">GstElement</a>
92                <span class="lineart">╰──</span> <a href="/usr/share/gtk-doc/html/gstreamer-libs-1.0/GstBaseTransform.html#GstBaseTransform-struct">GstBaseTransform</a>
93                    <span class="lineart">╰──</span> GstLevel
94</pre>
95</div>
96<div class="refsect1">
97<a name="gst-plugins-good-plugins-level.description"></a><h2>Description</h2>
98<p>Level analyses incoming audio buffers and, if the <a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--message" title="The “message” property"><span class="type">“message”</span></a> property
99is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, generates an element message named</p>
100<code class="classname">"level"</code>:
101<p>after each interval of time given by the <a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--interval" title="The “interval” property"><span class="type">“interval”</span></a> property.
102The message's structure contains these fields:</p>
103<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
104<li class="listitem"><p>
105  <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
106  <code class="classname">"timestamp"</code>:
107  the timestamp of the buffer that triggered the message.
108  </p></li>
109<li class="listitem"><p>
110  <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
111  <code class="classname">"stream-time"</code>:
112  the stream time of the buffer.
113  </p></li>
114<li class="listitem"><p>
115  <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
116  <code class="classname">"running-time"</code>:
117  the running_time of the buffer.
118  </p></li>
119<li class="listitem"><p>
120  <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
121  <code class="classname">"duration"</code>:
122  the duration of the buffer.
123  </p></li>
124<li class="listitem"><p>
125  <a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
126  <code class="classname">"endtime"</code>:
127  the end time of the buffer that triggered the message as stream time (this
128  is deprecated, as it can be calculated from stream-time + duration)
129  </p></li>
130<li class="listitem"><p>
131  <a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#GValueArray-struct"><span class="type">GValueArray</span></a> of <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>
132  <code class="classname">"peak"</code>:
133  the peak power level in dB for each channel
134  </p></li>
135<li class="listitem"><p>
136  <a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#GValueArray-struct"><span class="type">GValueArray</span></a> of <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>
137  <code class="classname">"decay"</code>:
138  the decaying peak power level in dB for each channel
139  The decaying peak level follows the peak level, but starts dropping if no
140  new peak is reached after the time given by the <a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--peak-ttl" title="The “peak-ttl” property"><span class="type">“peak-ttl”</span></a>.
141  When the decaying peak level drops, it does so at the decay rate as
142  specified by the <a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--peak-falloff" title="The “peak-falloff” property"><span class="type">“peak-falloff”</span></a>.
143  </p></li>
144<li class="listitem"><p>
145  <a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#GValueArray-struct"><span class="type">GValueArray</span></a> of <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>
146  <code class="classname">"rms"</code>:
147  the Root Mean Square (or average power) level in dB for each channel
148  </p></li>
149</ul></div>
150<div class="refsect2">
151<a name="id-1.2.87.7.6"></a><h3>Example application</h3>
152<div class="informalexample">
153  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
154    <tbody>
155      <tr>
156        <td class="listing_lines" align="right"><pre>1
1572
1583
1594
1605
1616
1627
1638
1649
16510
16611
16712
16813
16914
17015
17116
17217
17318
17419
17520
17621
17722
17823
17924
18025
18126
18227
18328
18429
18530
18631
18732
18833
18934
19035
19136
19237
19338
19439
19540
19641
19742
19843
19944
20045
20146
20247
20348
20449
20550
20651
20752
20853
20954
21055
21156
21257
21358
21459
21560
21661
21762
21863
21964
22065
22166
22267
22368
22469
22570
22671
22772
22873
22974
23075
23176
23277
23378
23479
23580
23681
23782
23883
23984
24085
24186
24287
24388
24489
24590
24691
24792
24893
24994
25095
25196
25297
25398
25499
255100
256101
257102
258103
259104
260105
261106
262107
263108
264109
265110
266111
267112
268113
269114
270115
271116
272117
273118
274119
275120
276121
277122
278123
279124
280125
281126
282127
283128
284129
285130
286131
287132
288133
289134
290135
291136
292137
293138
294139
295140</pre></td>
296        <td class="listing_code"><pre class="programlisting"><span class="comment">/* GStreamer</span>
297<span class="comment"> * Copyright (C) 2000,2001,2002,2003,2005</span>
298<span class="comment"> *           Thomas Vander Stichele &lt;thomas at apestaart dot org&gt;</span>
299<span class="comment"> *</span>
300<span class="comment"> * This library is free software; you can redistribute it and/or</span>
301<span class="comment"> * modify it under the terms of the GNU Library General Public</span>
302<span class="comment"> * License as published by the Free Software Foundation; either</span>
303<span class="comment"> * version 2 of the License, or (at your option) any later version.</span>
304<span class="comment"> *</span>
305<span class="comment"> * This library is distributed in the hope that it will be useful,</span>
306<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
307<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
308<span class="comment"> * Library General Public License for more details.</span>
309<span class="comment"> *</span>
310<span class="comment"> * You should have received a copy of the GNU Library General Public</span>
311<span class="comment"> * License along with this library; if not, write to the</span>
312<span class="comment"> * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,</span>
313<span class="comment"> * Boston, MA 02110-1301, USA.</span>
314<span class="comment"> */</span>
315
316<span class="gtkdoc ppc">#include &lt;string.h&gt;</span>
317<span class="gtkdoc ppc">#include &lt;math.h&gt;</span>
318
319<span class="gtkdoc ppc">#define GLIB_DISABLE_DEPRECATION_WARNINGS</span>
320
321<span class="gtkdoc ppc">#include &lt;gst/gst.h&gt;</span>
322
323<span class="gtkdoc kwb">static</span> gboolean
324<span class="function">message_handler</span> <span class="gtkdoc opt">(</span>GstBus <span class="gtkdoc opt">*</span> bus<span class="gtkdoc opt">,</span> GstMessage <span class="gtkdoc opt">*</span> message<span class="gtkdoc opt">,</span> gpointer data<span class="gtkdoc opt">)</span>
325<span class="gtkdoc opt">{</span>
326
327  <span class="keyword">if</span> <span class="gtkdoc opt">(</span>message<span class="gtkdoc opt">-&gt;</span>type <span class="gtkdoc opt">==</span> GST_MESSAGE_ELEMENT<span class="gtkdoc opt">) {</span>
328    <span class="gtkdoc kwb">const</span> GstStructure <span class="gtkdoc opt">*</span>s <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstMessage.html#gst-message-get-structure">gst_message_get_structure</a></span> <span class="gtkdoc opt">(</span>message<span class="gtkdoc opt">);</span>
329    <span class="gtkdoc kwb">const</span> gchar <span class="gtkdoc opt">*</span>name <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstStructure.html#gst-structure-get-name">gst_structure_get_name</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">);</span>
330
331    <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function">strcmp</span> <span class="gtkdoc opt">(</span>name<span class="gtkdoc opt">,</span> <span class="string">&quot;level&quot;</span><span class="gtkdoc opt">) ==</span> <span class="number">0</span><span class="gtkdoc opt">) {</span>
332      gint channels<span class="gtkdoc opt">;</span>
333      GstClockTime endtime<span class="gtkdoc opt">;</span>
334      gdouble rms_dB<span class="gtkdoc opt">,</span> peak_dB<span class="gtkdoc opt">,</span> decay_dB<span class="gtkdoc opt">;</span>
335      gdouble rms<span class="gtkdoc opt">;</span>
336      <span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>array_val<span class="gtkdoc opt">;</span>
337      <span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>value<span class="gtkdoc opt">;</span>
338      GValueArray <span class="gtkdoc opt">*</span>rms_arr<span class="gtkdoc opt">, *</span>peak_arr<span class="gtkdoc opt">, *</span>decay_arr<span class="gtkdoc opt">;</span>
339      gint i<span class="gtkdoc opt">;</span>
340
341      <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstStructure.html#gst-structure-get-clock-time">gst_structure_get_clock_time</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;endtime&quot;</span><span class="gtkdoc opt">, &amp;</span>endtime<span class="gtkdoc opt">))</span>
342        <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Message-Logging.html#g-warning">g_warning</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;Could not parse endtime&quot;</span><span class="gtkdoc opt">);</span>
343
344      <span class="comment">/* the values are packed into GValueArrays with the value per channel */</span>
345      array_val <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstStructure.html#gst-structure-get-value">gst_structure_get_value</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;rms&quot;</span><span class="gtkdoc opt">);</span>
346      rms_arr <span class="gtkdoc opt">= (</span>GValueArray <span class="gtkdoc opt">*)</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-boxed">g_value_get_boxed</a></span> <span class="gtkdoc opt">(</span>array_val<span class="gtkdoc opt">);</span>
347
348      array_val <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstStructure.html#gst-structure-get-value">gst_structure_get_value</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;peak&quot;</span><span class="gtkdoc opt">);</span>
349      peak_arr <span class="gtkdoc opt">= (</span>GValueArray <span class="gtkdoc opt">*)</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-boxed">g_value_get_boxed</a></span> <span class="gtkdoc opt">(</span>array_val<span class="gtkdoc opt">);</span>
350
351      array_val <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstStructure.html#gst-structure-get-value">gst_structure_get_value</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;decay&quot;</span><span class="gtkdoc opt">);</span>
352      decay_arr <span class="gtkdoc opt">= (</span>GValueArray <span class="gtkdoc opt">*)</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-boxed">g_value_get_boxed</a></span> <span class="gtkdoc opt">(</span>array_val<span class="gtkdoc opt">);</span>
353
354      <span class="comment">/* we can get the number of channels as the length of any of the value</span>
355<span class="comment">       * arrays */</span>
356      channels <span class="gtkdoc opt">=</span> rms_arr<span class="gtkdoc opt">-&gt;</span>n_values<span class="gtkdoc opt">;</span>
357      <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;endtime: %&quot;</span> GST_TIME_FORMAT <span class="string">&quot;, channels: %d</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span>
358          <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/gstreamer-GstInfo.html#GST-TIME-ARGS:CAPS">GST_TIME_ARGS</a></span> <span class="gtkdoc opt">(</span>endtime<span class="gtkdoc opt">),</span> channels<span class="gtkdoc opt">);</span>
359      <span class="keyword">for</span> <span class="gtkdoc opt">(</span>i <span class="gtkdoc opt">=</span> <span class="number">0</span><span class="gtkdoc opt">;</span> i <span class="gtkdoc opt">&lt;</span> channels<span class="gtkdoc opt">; ++</span>i<span class="gtkdoc opt">) {</span>
360
361        <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;channel %d</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
362        value <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#g-value-array-get-nth">g_value_array_get_nth</a></span> <span class="gtkdoc opt">(</span>rms_arr<span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
363        rms_dB <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-double">g_value_get_double</a></span> <span class="gtkdoc opt">(</span>value<span class="gtkdoc opt">);</span>
364
365        value <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#g-value-array-get-nth">g_value_array_get_nth</a></span> <span class="gtkdoc opt">(</span>peak_arr<span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
366        peak_dB <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-double">g_value_get_double</a></span> <span class="gtkdoc opt">(</span>value<span class="gtkdoc opt">);</span>
367
368        value <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Value-arrays.html#g-value-array-get-nth">g_value_array_get_nth</a></span> <span class="gtkdoc opt">(</span>decay_arr<span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
369        decay_dB <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-double">g_value_get_double</a></span> <span class="gtkdoc opt">(</span>value<span class="gtkdoc opt">);</span>
370        <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;    RMS: %f dB, peak: %f dB, decay: %f dB</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span>
371            rms_dB<span class="gtkdoc opt">,</span> peak_dB<span class="gtkdoc opt">,</span> decay_dB<span class="gtkdoc opt">);</span>
372
373        <span class="comment">/* converting from dB to normal gives us a value between 0.0 and 1.0 */</span>
374        rms <span class="gtkdoc opt">=</span> <span class="function">pow</span> <span class="gtkdoc opt">(</span><span class="number">10</span><span class="gtkdoc opt">,</span> rms_dB <span class="gtkdoc opt">/</span> <span class="number">20</span><span class="gtkdoc opt">);</span>
375        <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;    normalized rms value: %f</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> rms<span class="gtkdoc opt">);</span>
376      <span class="gtkdoc opt">}</span>
377    <span class="gtkdoc opt">}</span>
378  <span class="gtkdoc opt">}</span>
379  <span class="comment">/* we handled the message we want, and ignored the ones we didn&apos;t want.</span>
380<span class="comment">   * so the core can unref the message for us */</span>
381  <span class="keyword">return</span> TRUE<span class="gtkdoc opt">;</span>
382<span class="gtkdoc opt">}</span>
383
384<span class="gtkdoc kwb">int</span>
385<span class="function">main</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">int</span> argc<span class="gtkdoc opt">,</span> <span class="gtkdoc kwb">char</span> <span class="gtkdoc opt">*</span>argv<span class="gtkdoc opt">[])</span>
386<span class="gtkdoc opt">{</span>
387  GstElement <span class="gtkdoc opt">*</span>audiotestsrc<span class="gtkdoc opt">, *</span>audioconvert<span class="gtkdoc opt">, *</span>level<span class="gtkdoc opt">, *</span>fakesink<span class="gtkdoc opt">;</span>
388  GstElement <span class="gtkdoc opt">*</span>pipeline<span class="gtkdoc opt">;</span>
389  GstCaps <span class="gtkdoc opt">*</span>caps<span class="gtkdoc opt">;</span>
390  GstBus <span class="gtkdoc opt">*</span>bus<span class="gtkdoc opt">;</span>
391  guint watch_id<span class="gtkdoc opt">;</span>
392  GMainLoop <span class="gtkdoc opt">*</span>loop<span class="gtkdoc opt">;</span>
393
394  <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/gstreamer-Gst.html#gst-init">gst_init</a></span> <span class="gtkdoc opt">(&amp;</span>argc<span class="gtkdoc opt">, &amp;</span>argv<span class="gtkdoc opt">);</span>
395
396  caps <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstCaps.html#gst-caps-from-string">gst_caps_from_string</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audio/x-raw,channels=2&quot;</span><span class="gtkdoc opt">);</span>
397
398  pipeline <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstPipeline.html#gst-pipeline-new">gst_pipeline_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">);</span>
399  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>pipeline<span class="gtkdoc opt">);</span>
400  audiotestsrc <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audiotestsrc&quot;</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
401  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>audiotestsrc<span class="gtkdoc opt">);</span>
402  audioconvert <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audioconvert&quot;</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
403  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>audioconvert<span class="gtkdoc opt">);</span>
404  level <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;level&quot;</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
405  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>level<span class="gtkdoc opt">);</span>
406  fakesink <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;fakesink&quot;</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
407  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>fakesink<span class="gtkdoc opt">);</span>
408
409  <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstBin.html#gst-bin-add-many">gst_bin_add_many</a></span> <span class="gtkdoc opt">(</span><span class="function">GST_BIN</span> <span class="gtkdoc opt">(</span>pipeline<span class="gtkdoc opt">),</span> audiotestsrc<span class="gtkdoc opt">,</span> audioconvert<span class="gtkdoc opt">,</span> level<span class="gtkdoc opt">,</span>
410      fakesink<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
411  <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#gst-element-link">gst_element_link</a></span> <span class="gtkdoc opt">(</span>audiotestsrc<span class="gtkdoc opt">,</span> audioconvert<span class="gtkdoc opt">))</span>
412    <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Message-Logging.html#g-error">g_error</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;Failed to link audiotestsrc and audioconvert&quot;</span><span class="gtkdoc opt">);</span>
413  <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#gst-element-link-filtered">gst_element_link_filtered</a></span> <span class="gtkdoc opt">(</span>audioconvert<span class="gtkdoc opt">,</span> level<span class="gtkdoc opt">,</span> caps<span class="gtkdoc opt">))</span>
414    <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Message-Logging.html#g-error">g_error</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;Failed to link audioconvert and level&quot;</span><span class="gtkdoc opt">);</span>
415  <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#gst-element-link">gst_element_link</a></span> <span class="gtkdoc opt">(</span>level<span class="gtkdoc opt">,</span> fakesink<span class="gtkdoc opt">))</span>
416    <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Message-Logging.html#g-error">g_error</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;Failed to link level and fakesink&quot;</span><span class="gtkdoc opt">);</span>
417
418  <span class="comment">/* make sure we&apos;ll get messages */</span>
419  <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-set">g_object_set</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#G-OBJECT:CAPS">G_OBJECT</a></span> <span class="gtkdoc opt">(</span>level<span class="gtkdoc opt">),</span> <span class="string">&quot;post-messages&quot;</span><span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
420  <span class="comment">/* run synced and not as fast as we can */</span>
421  <span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-set">g_object_set</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#G-OBJECT:CAPS">G_OBJECT</a></span> <span class="gtkdoc opt">(</span>fakesink<span class="gtkdoc opt">),</span> <span class="string">&quot;sync&quot;</span><span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
422
423  bus <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#gst-element-get-bus">gst_element_get_bus</a></span> <span class="gtkdoc opt">(</span>pipeline<span class="gtkdoc opt">);</span>
424  watch_id <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstBus.html#gst-bus-add-watch">gst_bus_add_watch</a></span> <span class="gtkdoc opt">(</span>bus<span class="gtkdoc opt">,</span> message_handler<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
425
426  <span class="function"><a href="/usr/share/gtk-doc/html/gstreamer-1.0/GstElement.html#gst-element-set-state">gst_element_set_state</a></span> <span class="gtkdoc opt">(</span>pipeline<span class="gtkdoc opt">,</span> GST_STATE_PLAYING<span class="gtkdoc opt">);</span>
427
428  <span class="comment">/* we need to run a GLib main loop to get the messages */</span>
429  loop <span class="gtkdoc opt">=</span> <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-main-loop-new">g_main_loop_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> FALSE<span class="gtkdoc opt">);</span>
430  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-main-loop-run">g_main_loop_run</a></span> <span class="gtkdoc opt">(</span>loop<span class="gtkdoc opt">);</span>
431
432  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-source-remove">g_source_remove</a></span> <span class="gtkdoc opt">(</span>watch_id<span class="gtkdoc opt">);</span>
433  <span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-main-loop-unref">g_main_loop_unref</a></span> <span class="gtkdoc opt">(</span>loop<span class="gtkdoc opt">);</span>
434  <span class="keyword">return</span> <span class="number">0</span><span class="gtkdoc opt">;</span>
435<span class="gtkdoc opt">}</span></pre></td>
436      </tr>
437    </tbody>
438  </table>
439</div>
440
441</div>
442<div class="refsynopsisdiv">
443<h2>Synopsis</h2>
444<div class="refsect2">
445<a name="id-1.2.87.7.7.1"></a><h3>Element Information</h3>
446<div class="variablelist"><table border="0" class="variablelist">
447<colgroup>
448<col align="left" valign="top">
449<col>
450</colgroup>
451<tbody>
452<tr>
453<td><p><span class="term">plugin</span></p></td>
454<td>
455            <a class="link" href="gst-plugins-good-plugins-plugin-level.html#plugin-level">level</a>
456          </td>
457</tr>
458<tr>
459<td><p><span class="term">author</span></p></td>
460<td>Thomas Vander Stichele &lt;thomas at apestaart dot org&gt;</td>
461</tr>
462<tr>
463<td><p><span class="term">class</span></p></td>
464<td>Filter/Analyzer/Audio</td>
465</tr>
466</tbody>
467</table></div>
468</div>
469<hr>
470<div class="refsect2">
471<a name="id-1.2.87.7.7.2"></a><h3>Element Pads</h3>
472<div class="variablelist"><table border="0" class="variablelist">
473<colgroup>
474<col align="left" valign="top">
475<col>
476</colgroup>
477<tbody>
478<tr>
479<td><p><span class="term">name</span></p></td>
480<td>sink</td>
481</tr>
482<tr>
483<td><p><span class="term">direction</span></p></td>
484<td>sink</td>
485</tr>
486<tr>
487<td><p><span class="term">presence</span></p></td>
488<td>always</td>
489</tr>
490<tr>
491<td><p><span class="term">details</span></p></td>
492<td>audio/x-raw, format=(string){ S8, S16LE, S32LE, F32LE, F64LE }, layout=(string)interleaved, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
493</tr>
494</tbody>
495</table></div>
496<div class="variablelist"><table border="0" class="variablelist">
497<colgroup>
498<col align="left" valign="top">
499<col>
500</colgroup>
501<tbody>
502<tr>
503<td><p><span class="term">name</span></p></td>
504<td>src</td>
505</tr>
506<tr>
507<td><p><span class="term">direction</span></p></td>
508<td>source</td>
509</tr>
510<tr>
511<td><p><span class="term">presence</span></p></td>
512<td>always</td>
513</tr>
514<tr>
515<td><p><span class="term">details</span></p></td>
516<td>audio/x-raw, format=(string){ S8, S16LE, S32LE, F32LE, F64LE }, layout=(string)interleaved, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
517</tr>
518</tbody>
519</table></div>
520</div>
521</div>
522</div>
523<div class="refsect1">
524<a name="gst-plugins-good-plugins-level.functions_details"></a><h2>Functions</h2>
525<p></p>
526</div>
527<div class="refsect1">
528<a name="gst-plugins-good-plugins-level.other_details"></a><h2>Types and Values</h2>
529<div class="refsect2">
530<a name="GstLevel-struct"></a><h3>struct GstLevel</h3>
531<pre class="programlisting">struct GstLevel;</pre>
532<p>Opaque data structure.</p>
533</div>
534</div>
535<div class="refsect1">
536<a name="gst-plugins-good-plugins-level.property-details"></a><h2>Property Details</h2>
537<div class="refsect2">
538<a name="GstLevel--interval"></a><h3>The <code class="literal">“interval”</code> property</h3>
539<pre class="programlisting">  “interval”                 <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint64"><span class="type">guint64</span></a></pre>
540<p>Interval of time between message posts (in nanoseconds).</p>
541<p>Flags: Read / Write</p>
542<p>Allowed values: &gt;= 1</p>
543<p>Default value: 100000000</p>
544</div>
545<hr>
546<div class="refsect2">
547<a name="GstLevel--message"></a><h3>The <code class="literal">“message”</code> property</h3>
548<pre class="programlisting">  “message”                  <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre>
549<p>Post a 'level' message for each passed interval (deprecated, use the post-messages property instead).</p>
550<p>Flags: Read / Write</p>
551<p>Default value: TRUE</p>
552</div>
553<hr>
554<div class="refsect2">
555<a name="GstLevel--peak-falloff"></a><h3>The <code class="literal">“peak-falloff”</code> property</h3>
556<pre class="programlisting">  “peak-falloff”             <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a></pre>
557<p>Decay rate of decay peak after TTL (in dB/sec).</p>
558<p>Flags: Read / Write</p>
559<p>Allowed values: &gt;= 0</p>
560<p>Default value: 10</p>
561</div>
562<hr>
563<div class="refsect2">
564<a name="GstLevel--peak-ttl"></a><h3>The <code class="literal">“peak-ttl”</code> property</h3>
565<pre class="programlisting">  “peak-ttl”                 <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint64"><span class="type">guint64</span></a></pre>
566<p>Time To Live of decay peak before it falls back (in nanoseconds).</p>
567<p>Flags: Read / Write</p>
568<p>Default value: 300000000</p>
569</div>
570<hr>
571<div class="refsect2">
572<a name="GstLevel--post-messages"></a><h3>The <code class="literal">“post-messages”</code> property</h3>
573<pre class="programlisting">  “post-messages”            <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre>
574<p>Post messages on the bus with level information.</p>
575<div class="warning">
576<p><code class="literal">GstLevel:post-messages</code> is deprecated and should not be used in newly-written code.</p>
577<p>use the <a class="link" href="gst-plugins-good-plugins-level.html#GstLevel--post-messages" title="The “post-messages” property"><span class="type">“post-messages”</span></a> property</p>
578</div>
579<p>Flags: Read / Write</p>
580<p>Default value: TRUE</p>
581<p class="since">Since: 1.1.0</p>
582</div>
583</div>
584</div>
585<div class="footer">
586<hr>Generated by GTK-Doc V1.28</div>
587</body>
588</html>