• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) 2000,2001,2002,2003,2005
4  *           Thomas Vander Stichele <thomas at apestaart dot org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 
23 #ifndef __GST_LEVEL_H__
24 #define __GST_LEVEL_H__
25 
26 
27 #include <gst/gst.h>
28 #include <gst/base/gstbasetransform.h>
29 #include <gst/audio/audio.h>
30 
31 G_BEGIN_DECLS
32 
33 
34 #define GST_TYPE_LEVEL \
35   (gst_level_get_type())
36 #define GST_LEVEL(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_LEVEL,GstLevel))
38 #define GST_LEVEL_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_LEVEL,GstLevelClass))
40 #define GST_LEVEL_GET_CLASS(obj) \
41   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_LEVEL,GstLevelClass))
42 #define GST_IS_LEVEL(obj) \
43   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_LEVEL))
44 #define GST_IS_LEVEL_CLASS(klass) \
45   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_LEVEL))
46 
47 
48 typedef struct _GstLevel GstLevel;
49 typedef struct _GstLevelClass GstLevelClass;
50 
51 /**
52  * GstLevel:
53  *
54  * Opaque data structure.
55  */
56 struct _GstLevel {
57   GstBaseTransform element;
58 
59   /* properties, protected by object lock */
60   gboolean post_messages;       /* whether or not to post messages */
61   guint64 interval;             /* how many nanoseconds between emits */
62   gdouble decay_peak_ttl;       /* time to live for peak in nanoseconds */
63   gdouble decay_peak_falloff;   /* falloff in dB/sec */
64   gboolean audio_level_meta; /* whether or not generate GstAudioLevelMeta */
65 
66   GstAudioInfo info;
67   gint num_frames;              /* frame count (1 sample per channel)
68                                  * since last emit */
69   gint interval_frames;         /* after how many frame to sent a message */
70   GstClockTime message_ts;      /* starttime for next message */
71 
72   /* per-channel arrays for intermediate values */
73   gdouble *CS;                  /* normalized Cumulative Square */
74   gdouble *peak;                /* normalized Peak value over buffer */
75   gdouble *last_peak;           /* last normalized Peak value over interval */
76   gdouble *decay_peak;          /* running decaying normalized Peak */
77   gdouble *decay_peak_base;     /* value of last peak we are decaying from */
78   GstClockTime *decay_peak_age; /* age of last peak */
79 
80   void (*process)(gpointer, guint, guint, gdouble*, gdouble*);
81 };
82 
83 struct _GstLevelClass {
84   GstBaseTransformClass parent_class;
85 };
86 
87 GType gst_level_get_type (void);
88 
89 GST_ELEMENT_REGISTER_DECLARE (level);
90 
91 G_END_DECLS
92 
93 
94 #endif /* __GST_LEVEL_H__ */
95