pulseutil: Add API for setting volume ratio
[platform/upstream/gst-plugins-good.git] / ext / pulse / pulseutil.h
1 /*
2  *  GStreamer pulseaudio plugin
3  *
4  *  Copyright (c) 2004-2008 Lennart Poettering
5  *
6  *  gst-pulse is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU Lesser General Public License as
8  *  published by the Free Software Foundation; either version 2.1 of the
9  *  License, or (at your option) any later version.
10  *
11  *  gst-pulse is distributed in the hope that it will be useful, but
12  *  WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with gst-pulse; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19  *  USA.
20  */
21
22 #ifndef __GST_PULSEUTIL_H__
23 #define __GST_PULSEUTIL_H__
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include <gst/gst.h>
30 #include <pulse/pulseaudio.h>
31 #include <gst/audio/gstaudioringbuffer.h>
32 #include <gst/audio/gstaudiosink.h>
33
34
35 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
36 # define _PULSE_FORMATS   "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, " \
37                      "S24LE, S24BE, S24_32LE, S24_32BE, U8 }"
38 #else
39 # define _PULSE_FORMATS   "{ S16BE, S16LE, F32BE, F32LE, S32BE, S32LE, " \
40                      "S24BE, S24LE, S24_32BE, S24_32LE, U8 }"
41 #endif
42
43 #define _PULSE_CAPS_LINEAR \
44     "audio/x-raw, " \
45       "format = (string) " _PULSE_FORMATS ", " \
46       "layout = (string) interleaved, " \
47       "rate = (int) [ 1, MAX ], " \
48       "channels = (int) [ 1, 32 ]; "
49 #define _PULSE_CAPS_ALAW \
50     "audio/x-alaw, " \
51       "rate = (int) [ 1, MAX], " \
52       "channels = (int) [ 1, 32 ]; "
53 #define _PULSE_CAPS_MULAW \
54     "audio/x-mulaw, " \
55       "rate = (int) [ 1, MAX], " \
56       "channels = (int) [ 1, 32 ]; "
57
58 #define _PULSE_CAPS_AC3 "audio/x-ac3, framed = (boolean) true; "
59 #define _PULSE_CAPS_EAC3 "audio/x-eac3, framed = (boolean) true; "
60 #define _PULSE_CAPS_DTS "audio/x-dts, framed = (boolean) true, " \
61     "block-size = (int) { 512, 1024, 2048 }; "
62 #define _PULSE_CAPS_MP3 "audio/mpeg, mpegversion = (int) 1, " \
63     "mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;"
64 #define _PULSE_CAPS_AAC "audio/mpeg, mpegversion = (int) { 2, 4 }, " \
65     "framed = (boolean) true, stream-format = (string) adts;"
66
67 #define _PULSE_CAPS_PCM \
68   _PULSE_CAPS_LINEAR \
69   _PULSE_CAPS_ALAW \
70   _PULSE_CAPS_MULAW
71
72
73 gboolean gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec,
74     pa_sample_spec * ss);
75 gboolean gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec,
76     pa_format_info ** f, guint * channels);
77 const char * gst_pulse_sample_format_to_caps_format (pa_sample_format_t sf);
78
79 gchar *gst_pulse_client_name (void);
80
81 pa_channel_map *gst_pulse_gst_to_channel_map (pa_channel_map * map,
82     const GstAudioRingBufferSpec * spec);
83
84 GstAudioRingBufferSpec *gst_pulse_channel_map_to_gst (const pa_channel_map * map,
85     GstAudioRingBufferSpec * spec);
86
87 void gst_pulse_cvolume_from_linear (pa_cvolume *v, unsigned channels, gdouble volume);
88
89 pa_proplist *gst_pulse_make_proplist (const GstStructure *properties);
90 GstStructure *gst_pulse_make_structure (pa_proplist *properties);
91
92 GstCaps * gst_pulse_format_info_to_caps (pa_format_info * format);
93
94 #ifdef __TIZEN__
95 void gst_pulse_set_volume_ratio (uint32_t stream_index, const char *direction, double ratio);
96 #endif
97 #endif