• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer StreamVolume
2  * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __GST_STREAM_VOLUME_H__
21 #define __GST_STREAM_VOLUME_H__
22 
23 #include <gst/gst.h>
24 #include <gst/audio/audio-prelude.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GST_TYPE_STREAM_VOLUME (gst_stream_volume_get_type ())
29 GST_AUDIO_API
30 G_DECLARE_INTERFACE (GstStreamVolume, gst_stream_volume, GST, STREAM_VOLUME,
31     GObject)
32 
33 #define GST_STREAM_VOLUME_GET_INTERFACE(obj) GST_STREAM_VOLUME_GET_IFACE(obj)
34 
35 struct _GstStreamVolumeInterface {
36   GTypeInterface iface;
37 };
38 
39 /**
40  * GstStreamVolumeFormat:
41  * @GST_STREAM_VOLUME_FORMAT_LINEAR: Linear scale factor, 1.0 = 100%
42  * @GST_STREAM_VOLUME_FORMAT_CUBIC: Cubic volume scale
43  * @GST_STREAM_VOLUME_FORMAT_DB: Logarithmic volume scale (dB, amplitude not power)
44  *
45  * Different representations of a stream volume. gst_stream_volume_convert_volume()
46  * allows to convert between the different representations.
47  *
48  * Formulas to convert from a linear to a cubic or dB volume are
49  * cbrt(val) and 20 * log10 (val).
50  */
51 typedef enum {
52   GST_STREAM_VOLUME_FORMAT_LINEAR = 0,
53   GST_STREAM_VOLUME_FORMAT_CUBIC,
54   GST_STREAM_VOLUME_FORMAT_DB
55 } GstStreamVolumeFormat;
56 
57 GST_AUDIO_API
58 void            gst_stream_volume_set_volume      (GstStreamVolume *volume,
59                                                    GstStreamVolumeFormat format,
60                                                    gdouble val);
61 
62 GST_AUDIO_API
63 gdouble         gst_stream_volume_get_volume      (GstStreamVolume *volume,
64                                                    GstStreamVolumeFormat format);
65 
66 GST_AUDIO_API
67 void            gst_stream_volume_set_mute        (GstStreamVolume *volume,
68                                                    gboolean mute);
69 
70 GST_AUDIO_API
71 gboolean        gst_stream_volume_get_mute        (GstStreamVolume *volume);
72 
73 GST_AUDIO_API
74 gdouble         gst_stream_volume_convert_volume  (GstStreamVolumeFormat from,
75                                                    GstStreamVolumeFormat to,
76                                                    gdouble val) G_GNUC_CONST;
77 
78 G_END_DECLS
79 
80 #endif /* __GST_STREAM_VOLUME_H__ */
81