• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
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 #include <stdio.h>
21 #include <string.h>
22 #include "gstopuscommon.h"
23 
24 /* http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9 */
25 /* copy of the same structure in the vorbis plugin */
26 const GstAudioChannelPosition gst_opus_channel_positions[][8] = {
27   {                             /* Mono */
28       GST_AUDIO_CHANNEL_POSITION_MONO},
29   {                             /* Stereo */
30         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
31       GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT},
32   {                             /* Stereo + Centre */
33         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
34         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
35       GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT},
36   {                             /* Quadraphonic */
37         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
38         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
39         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
40         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
41       },
42   {                             /* Stereo + Centre + rear stereo */
43         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
44         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
45         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
46         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
47         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
48       },
49   {                             /* Full 5.1 Surround */
50         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
51         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
52         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
53         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
54         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
55         GST_AUDIO_CHANNEL_POSITION_LFE1,
56       },
57   {                             /* 6.1 Surround, in Vorbis spec since 2010-01-13 */
58         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
59         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
60         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
61         GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
62         GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
63         GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
64       GST_AUDIO_CHANNEL_POSITION_LFE1},
65   {                             /* 7.1 Surround, in Vorbis spec since 2010-01-13 */
66         GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
67         GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
68         GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
69         GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
70         GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
71         GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
72         GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
73       GST_AUDIO_CHANNEL_POSITION_LFE1},
74 };
75 
76 const char *gst_opus_channel_names[] = {
77   "mono",
78   "front left",
79   "front right",
80   "rear center",
81   "rear left",
82   "rear right",
83   "lfe",
84   "front center",
85   "front left of center",
86   "front right of center",
87   "side left",
88   "side right",
89   "none"
90 };
91 
92 void
gst_opus_common_log_channel_mapping_table(GstElement * element,GstDebugCategory * category,const char * msg,int n_channels,const guint8 * table)93 gst_opus_common_log_channel_mapping_table (GstElement * element,
94     GstDebugCategory * category, const char *msg, int n_channels,
95     const guint8 * table)
96 {
97   int n;
98   GString *s;
99 
100   if (gst_debug_category_get_threshold (category) < GST_LEVEL_INFO)
101     return;
102 
103   s = g_string_new ("[ ");
104   for (n = 0; n < n_channels; ++n) {
105     g_string_append_printf (s, "%d ", table[n]);
106   }
107   g_string_append (s, "]");
108 
109   GST_CAT_LEVEL_LOG (category, GST_LEVEL_INFO, element, "%s: %s", msg, s->str);
110   g_string_free (s, TRUE);
111 }
112