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 /* NOTE! that we do NOT actually support rate=MAX. This must be fixed up using
44  * gst_pulse_fix_pcm_caps() before being used. */
45 #define _PULSE_CAPS_LINEAR \
46     "audio/x-raw, " \
47       "format = (string) " _PULSE_FORMATS ", " \
48       "layout = (string) interleaved, " \
49       "rate = (int) [ 1, MAX ], " \
50       "channels = (int) [ 1, 32 ]; "
51 #define _PULSE_CAPS_ALAW \
52     "audio/x-alaw, " \
53       "rate = (int) [ 1, MAX], " \
54       "channels = (int) [ 1, 32 ]; "
55 #define _PULSE_CAPS_MULAW \
56     "audio/x-mulaw, " \
57       "rate = (int) [ 1, MAX], " \
58       "channels = (int) [ 1, 32 ]; "
59 
60 #define _PULSE_CAPS_AC3 "audio/x-ac3, framed = (boolean) true; "
61 #define _PULSE_CAPS_EAC3 "audio/x-eac3, framed = (boolean) true; "
62 #define _PULSE_CAPS_DTS "audio/x-dts, framed = (boolean) true, " \
63     "block-size = (int) { 512, 1024, 2048 }; "
64 #define _PULSE_CAPS_MP3 "audio/mpeg, mpegversion = (int) 1, " \
65     "mpegaudioversion = (int) [ 1, 3 ], parsed = (boolean) true;"
66 #define _PULSE_CAPS_AAC "audio/mpeg, mpegversion = (int) { 2, 4 }, " \
67     "framed = (boolean) true, stream-format = (string) adts;"
68 
69 #define _PULSE_CAPS_PCM \
70   _PULSE_CAPS_LINEAR \
71   _PULSE_CAPS_ALAW \
72   _PULSE_CAPS_MULAW
73 
74 
75 gboolean gst_pulse_fill_sample_spec (GstAudioRingBufferSpec * spec,
76     pa_sample_spec * ss);
77 gboolean gst_pulse_fill_format_info (GstAudioRingBufferSpec * spec,
78     pa_format_info ** f, guint * channels);
79 const char * gst_pulse_sample_format_to_caps_format (pa_sample_format_t sf);
80 
81 gchar *gst_pulse_client_name (void);
82 
83 pa_channel_map *gst_pulse_gst_to_channel_map (pa_channel_map * map,
84     const GstAudioRingBufferSpec * spec);
85 
86 GstAudioRingBufferSpec *gst_pulse_channel_map_to_gst (const pa_channel_map * map,
87     GstAudioRingBufferSpec * spec);
88 
89 void gst_pulse_cvolume_from_linear (pa_cvolume *v, unsigned channels, gdouble volume);
90 
91 pa_proplist *gst_pulse_make_proplist (const GstStructure *properties);
92 GstStructure *gst_pulse_make_structure (pa_proplist *properties);
93 
94 GstCaps * gst_pulse_format_info_to_caps (pa_format_info * format);
95 GstCaps * gst_pulse_fix_pcm_caps (GstCaps * incaps);
96 
97 #endif
98