• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Library       <2001> Thomas Vander Stichele <thomas@apestaart.org>
4  *               <2011> Wim Taymans <wim.taymans@gmail.com>
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 #ifndef __GST_AUDIO_AUDIO_H__
23 #include <gst/audio/audio.h>
24 #endif
25 
26 #ifndef __GST_AUDIO_CHANNELS_H__
27 #define __GST_AUDIO_CHANNELS_H__
28 
29 G_BEGIN_DECLS
30 
31 /**
32  * GstAudioChannelPosition:
33  * @GST_AUDIO_CHANNEL_POSITION_MONO: Mono without direction;
34  *     can only be used with 1 channel
35  * @GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT: Front left
36  * @GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT: Front right
37  * @GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER: Front center
38  * @GST_AUDIO_CHANNEL_POSITION_LFE1: Low-frequency effects 1 (subwoofer)
39  * @GST_AUDIO_CHANNEL_POSITION_REAR_LEFT: Rear left
40  * @GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT: Rear right
41  * @GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: Front left of center
42  * @GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: Front right of center
43  * @GST_AUDIO_CHANNEL_POSITION_REAR_CENTER: Rear center
44  * @GST_AUDIO_CHANNEL_POSITION_LFE2: Low-frequency effects 2 (subwoofer)
45  * @GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT: Side left
46  * @GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT: Side right
47  * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT: Top front left
48  * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT: Top front right
49  * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER: Top front center
50  * @GST_AUDIO_CHANNEL_POSITION_TOP_CENTER: Top center
51  * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT: Top rear left
52  * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT: Top rear right
53  * @GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT: Top side right
54  * @GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT: Top rear right
55  * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER: Top rear center
56  * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER: Bottom front center
57  * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT: Bottom front left
58  * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT: Bottom front right
59  * @GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT: Wide left (between front left and side left)
60  * @GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT: Wide right (between front right and side right)
61  * @GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT: Surround left (between rear left and side left)
62  * @GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT: Surround right (between rear right and side right)
63  * @GST_AUDIO_CHANNEL_POSITION_NONE: used for position-less channels, e.g.
64  *     from a sound card that records 1024 channels; mutually exclusive with
65  *     any other channel position
66  * @GST_AUDIO_CHANNEL_POSITION_INVALID: invalid position
67  *
68  * Audio channel positions.
69  *
70  * These are the channels defined in SMPTE 2036-2-2008
71  * Table 1 for 22.2 audio systems with the Surround and Wide channels from
72  * DTS Coherent Acoustics (v.1.3.1) and 10.2 and 7.1 layouts. In the caps the
73  * actual channel layout is expressed with a channel count and a channel mask,
74  * which describes the existing channels. The positions in the bit mask correspond
75  * to the enum values.
76  * For negotiation it is allowed to have more bits set in the channel mask than
77  * the number of channels to specify the allowed channel positions but this is
78  * not allowed in negotiated caps. It is not allowed in any situation other
79  * than the one mentioned below to have less bits set in the channel mask than
80  * the number of channels.
81  *
82  * @GST_AUDIO_CHANNEL_POSITION_MONO can only be used with a single mono channel that
83  * has no direction information and would be mixed into all directional channels.
84  * This is expressed in caps by having a single channel and no channel mask.
85  *
86  * @GST_AUDIO_CHANNEL_POSITION_NONE can only be used if all channels have this position.
87  * This is expressed in caps by having a channel mask with no bits set.
88  *
89  * As another special case it is allowed to have two channels without a channel mask.
90  * This implicitly means that this is a stereo stream with a front left and front right
91  * channel.
92  */
93 typedef enum {
94   /* These get negative indices to allow to use
95    * the enum values of the normal cases for the
96    * bit-mask position */
97   GST_AUDIO_CHANNEL_POSITION_NONE = -3,
98   GST_AUDIO_CHANNEL_POSITION_MONO = -2,
99   GST_AUDIO_CHANNEL_POSITION_INVALID = -1,
100 
101   /* Normal cases */
102   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT = 0,
103   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
104   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
105   GST_AUDIO_CHANNEL_POSITION_LFE1,
106   GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
107   GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
108   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
109   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
110   GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
111   GST_AUDIO_CHANNEL_POSITION_LFE2,
112   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
113   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
114   GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT,
115   GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT,
116   GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER,
117   GST_AUDIO_CHANNEL_POSITION_TOP_CENTER,
118   GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT,
119   GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT,
120   GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT,
121   GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT,
122   GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER,
123   GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER,
124   GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT,
125   GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT,
126   GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT,
127   GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT,
128   GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT,
129   GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT
130 } GstAudioChannelPosition;
131 
132 #define GST_AUDIO_CHANNEL_POSITION_MASK(pos) (G_GUINT64_CONSTANT(1)<< GST_AUDIO_CHANNEL_POSITION_ ## pos)
133 
134 GST_AUDIO_API
135 gboolean       gst_audio_buffer_reorder_channels (GstBuffer * buffer,
136                                                   GstAudioFormat format,
137                                                   gint channels,
138                                                   const GstAudioChannelPosition * from,
139                                                   const GstAudioChannelPosition * to);
140 
141 GST_AUDIO_API
142 gboolean       gst_audio_reorder_channels        (gpointer data, gsize size,
143                                                   GstAudioFormat format,
144                                                   gint channels,
145                                                   const GstAudioChannelPosition * from,
146                                                   const GstAudioChannelPosition * to);
147 
148 GST_AUDIO_API
149 gboolean       gst_audio_channel_positions_to_valid_order (GstAudioChannelPosition *position,
150                                                            gint channels);
151 
152 GST_AUDIO_API
153 gboolean       gst_audio_check_valid_channel_positions (const GstAudioChannelPosition *position,
154                                                         gint channels, gboolean force_order);
155 
156 GST_AUDIO_API
157 gboolean       gst_audio_channel_positions_to_mask  (const GstAudioChannelPosition *position,
158                                                      gint channels, gboolean force_order,
159                                                      guint64 *channel_mask);
160 
161 GST_AUDIO_API
162 gboolean       gst_audio_channel_positions_from_mask (gint channels, guint64 channel_mask,
163                                                       GstAudioChannelPosition * position);
164 
165 GST_AUDIO_API
166 gboolean       gst_audio_get_channel_reorder_map (gint channels,
167                                                   const GstAudioChannelPosition * from,
168                                                   const GstAudioChannelPosition * to,
169                                                   gint *reorder_map);
170 
171 GST_AUDIO_API
172 guint64        gst_audio_channel_get_fallback_mask (gint channels);
173 
174 GST_AUDIO_API
175 gchar*         gst_audio_channel_positions_to_string (const GstAudioChannelPosition * position,
176                                                       gint channels);
177 
178 G_END_DECLS
179 
180 #endif /* __GST_AUDIO_CHANNELS_H__ */
181