Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gstreamer.git] / gst / rtp / gstrtpchannels.h
1 /* GStreamer
2  * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <string.h>
21 #include <stdlib.h>
22
23 #include <gst/audio/audio.h>
24
25 #ifndef __GST_RTP_CHANNELS_H__
26 #define __GST_RTP_CHANNELS_H__
27
28 typedef struct
29 {
30   const gchar                   *name;
31   gint                           channels;
32   const GstAudioChannelPosition *pos;
33 } GstRTPChannelOrder;
34
35 static const GstAudioChannelPosition pos_4_1[] = {
36   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
37   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
38   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
39   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
40 };
41
42 static const GstAudioChannelPosition pos_4_2[] = {
43   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
44   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
45   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
46   GST_AUDIO_CHANNEL_POSITION_LFE1
47 };
48
49 static const GstAudioChannelPosition pos_4_3[] = {
50   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
51   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
52   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
53   GST_AUDIO_CHANNEL_POSITION_LFE1
54 };
55
56 static const GstAudioChannelPosition pos_5_1[] = {
57   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
58   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
59   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
60   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
61   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER
62 };
63
64 static const GstAudioChannelPosition pos_6_1[] = {
65   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
66   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
67   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
68   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
69   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
70   GST_AUDIO_CHANNEL_POSITION_LFE1
71 };
72
73 static const GstAudioChannelPosition pos_6_2[] = {
74   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
75   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
76   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
77   GST_AUDIO_CHANNEL_POSITION_LFE1,
78   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
79   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
80 };
81
82 static const GstAudioChannelPosition pos_8_1[] = {
83   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
84   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
85   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
86   GST_AUDIO_CHANNEL_POSITION_LFE1,
87   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
88   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
89   GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
90   GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
91 };
92
93 static const GstAudioChannelPosition pos_8_2[] = {
94   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
95   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
96   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
97   GST_AUDIO_CHANNEL_POSITION_LFE1,
98   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
99   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
100   GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
101   GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
102 };
103
104 static const GstAudioChannelPosition pos_8_3[] = {
105   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
106   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
107   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
108   GST_AUDIO_CHANNEL_POSITION_LFE1,
109   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
110   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
111   GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
112   GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT
113 };
114
115 static const GstAudioChannelPosition pos_def_1[] = {
116   GST_AUDIO_CHANNEL_POSITION_MONO
117 };
118
119 static const GstAudioChannelPosition pos_def_2[] = {
120   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
121   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
122 };
123
124 static const GstAudioChannelPosition pos_def_3[] = {
125   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
126   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
127   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER
128 };
129
130 static const GstAudioChannelPosition pos_def_4[] = {
131   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
132   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
133   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
134   GST_AUDIO_CHANNEL_POSITION_LFE1
135 };
136
137 static const GstAudioChannelPosition pos_def_5[] = {
138   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
139   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
140   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
141   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
142   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
143 };
144
145 static const GstAudioChannelPosition pos_def_6[] = {
146   GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
147   GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
148   GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
149   GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
150   GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
151   GST_AUDIO_CHANNEL_POSITION_LFE1
152 };
153
154 static const GstRTPChannelOrder channel_orders[] =
155 {
156   /* 4 channels */
157   { "DV.LRLsRs",            4, pos_4_1 },
158   { "DV.LRCS",              4, pos_4_2 },
159   { "DV.LRCWo",             4, pos_4_3 },
160   /* 5 channels */
161   { "DV.LRLsRsC",           5, pos_5_1 },
162   /* 6 channels */
163   { "DV.LRLsRsCS",          6, pos_6_1 },
164   { "DV.LmixRmixTWoQ1Q2",   6, pos_6_2 },
165   /* 8 channels */
166   { "DV.LRCWoLsRsLmixRmix", 8, pos_8_1 },
167   { "DV.LRCWoLs1Rs1Ls2Rs2", 8, pos_8_2 },
168   { "DV.LRCWoLsRsLcRc",     8, pos_8_3 },
169
170   /* default layouts */
171   { NULL,                   1, pos_def_1 },
172   { NULL,                   2, pos_def_2 },
173   { NULL,                   3, pos_def_3 },
174   { NULL,                   4, pos_def_4 },
175   { NULL,                   5, pos_def_5 },
176   { NULL,                   6, pos_def_6 },
177
178   /* terminator, invalid entry */
179   { NULL,                   0, NULL },
180 };
181
182 const GstRTPChannelOrder *   gst_rtp_channels_get_by_pos     (gint channels,
183                                                               const GstAudioChannelPosition *pos);
184 const GstRTPChannelOrder *   gst_rtp_channels_get_by_order   (gint channels,
185                                                               const gchar *order);
186 const GstRTPChannelOrder *   gst_rtp_channels_get_by_index   (gint channels, guint idx);
187
188 void                         gst_rtp_channels_create_default (gint channels, GstAudioChannelPosition *pos);
189
190 #endif /* __GST_RTP_CHANNELS_H__ */