Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / media / base / channel_layout.h
blobb57f1529640fd94db0e911d38f815dc8e15fe95c
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_CHANNEL_LAYOUT_H_
6 #define MEDIA_BASE_CHANNEL_LAYOUT_H_
8 #include "media/base/media_export.h"
10 namespace media {
12 // Enumerates the various representations of the ordering of audio channels.
13 // Logged to UMA, so never reuse a value, always add new/greater ones!
14 enum ChannelLayout {
15 CHANNEL_LAYOUT_NONE = 0,
16 CHANNEL_LAYOUT_UNSUPPORTED = 1,
18 // Front C
19 CHANNEL_LAYOUT_MONO = 2,
21 // Front L, Front R
22 CHANNEL_LAYOUT_STEREO = 3,
24 // Front L, Front R, Back C
25 CHANNEL_LAYOUT_2_1 = 4,
27 // Front L, Front R, Front C
28 CHANNEL_LAYOUT_SURROUND = 5,
30 // Front L, Front R, Front C, Back C
31 CHANNEL_LAYOUT_4_0 = 6,
33 // Front L, Front R, Side L, Side R
34 CHANNEL_LAYOUT_2_2 = 7,
36 // Front L, Front R, Back L, Back R
37 CHANNEL_LAYOUT_QUAD = 8,
39 // Front L, Front R, Front C, Side L, Side R
40 CHANNEL_LAYOUT_5_0 = 9,
42 // Front L, Front R, Front C, Side L, Side R, LFE
43 CHANNEL_LAYOUT_5_1 = 10,
45 // Front L, Front R, Front C, Back L, Back R
46 CHANNEL_LAYOUT_5_0_BACK = 11,
48 // Front L, Front R, Front C, Back L, Back R, LFE
49 CHANNEL_LAYOUT_5_1_BACK = 12,
51 // Front L, Front R, Front C, Side L, Side R, Back L, Back R
52 CHANNEL_LAYOUT_7_0 = 13,
54 // Front L, Front R, Front C, Side L, Side R, LFE, Back L, Back R
55 CHANNEL_LAYOUT_7_1 = 14,
57 // Front L, Front R, Front C, Side L, Side R, LFE, Front LofC, Front RofC
58 CHANNEL_LAYOUT_7_1_WIDE = 15,
60 // Stereo L, Stereo R
61 CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
63 // Stereo L, Stereo R, LFE
64 CHANNEL_LAYOUT_2POINT1 = 17,
66 // Stereo L, Stereo R, Front C, LFE
67 CHANNEL_LAYOUT_3_1 = 18,
69 // Stereo L, Stereo R, Front C, Rear C, LFE
70 CHANNEL_LAYOUT_4_1 = 19,
72 // Stereo L, Stereo R, Front C, Side L, Side R, Back C
73 CHANNEL_LAYOUT_6_0 = 20,
75 // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
76 CHANNEL_LAYOUT_6_0_FRONT = 21,
78 // Stereo L, Stereo R, Side L, Side R, Front C, Rear C.
79 CHANNEL_LAYOUT_HEXAGONAL = 22,
81 // Stereo L, Stereo R, Side L, Side R, Front C, Rear Center, LFE
82 CHANNEL_LAYOUT_6_1 = 23,
84 // Stereo L, Stereo R, Back L, Back R, Front C, Rear Center, LFE
85 CHANNEL_LAYOUT_6_1_BACK = 24,
87 // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
88 CHANNEL_LAYOUT_6_1_FRONT = 25,
90 // Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
91 CHANNEL_LAYOUT_7_0_FRONT = 26,
93 // Front L, Front R, Front C, Back L, Back R, LFE, Front LofC, Front RofC
94 CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
96 // Front L, Front R, Front C, Side L, Side R, Rear C, Back L, Back R.
97 CHANNEL_LAYOUT_OCTAGONAL = 28,
99 // Channels are not explicitly mapped to speakers.
100 CHANNEL_LAYOUT_DISCRETE = 29,
102 // Front L, Front R, Front C. Front C contains the keyboard mic audio. This
103 // layout is only intended for input for WebRTC. The Front C channel
104 // is stripped away in the WebRTC audio input pipeline and never seen outside
105 // of that.
106 CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
108 // Front L, Front R, Side L, Side R, LFE
109 CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
111 // Max value, must always equal the largest entry ever logged.
112 CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_4_1_QUAD_SIDE
115 enum Channels {
116 LEFT = 0,
117 RIGHT,
118 CENTER,
119 LFE,
120 BACK_LEFT,
121 BACK_RIGHT,
122 LEFT_OF_CENTER,
123 RIGHT_OF_CENTER,
124 BACK_CENTER,
125 SIDE_LEFT,
126 SIDE_RIGHT,
127 CHANNELS_MAX = SIDE_RIGHT, // Must always equal the largest value ever logged.
130 // Returns the expected channel position in an interleaved stream. Values of -1
131 // mean the channel at that index is not used for that layout. Values range
132 // from 0 to ChannelLayoutToChannelCount(layout) - 1.
133 MEDIA_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel);
135 // Returns the number of channels in a given ChannelLayout.
136 MEDIA_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout);
138 // Given the number of channels, return the best layout,
139 // or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match.
140 MEDIA_EXPORT ChannelLayout GuessChannelLayout(int channels);
142 // Returns a string representation of the channel layout.
143 MEDIA_EXPORT const char* ChannelLayoutToString(ChannelLayout layout);
145 } // namespace media
147 #endif // MEDIA_BASE_CHANNEL_LAYOUT_H_