Home | History | Annotate | Download | only in base
      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.
      4 
      5 #ifndef MEDIA_BASE_CHANNEL_LAYOUT_H_
      6 #define MEDIA_BASE_CHANNEL_LAYOUT_H_
      7 
      8 #include "media/base/media_export.h"
      9 
     10 namespace media {
     11 
     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,
     17 
     18   // Front C
     19   CHANNEL_LAYOUT_MONO = 2,
     20 
     21   // Front L, Front R
     22   CHANNEL_LAYOUT_STEREO = 3,
     23 
     24   // Front L, Front R, Back C
     25   CHANNEL_LAYOUT_2_1 = 4,
     26 
     27   // Front L, Front R, Front C
     28   CHANNEL_LAYOUT_SURROUND = 5,
     29 
     30   // Front L, Front R, Front C, Back C
     31   CHANNEL_LAYOUT_4_0 = 6,
     32 
     33   // Front L, Front R, Side L, Side R
     34   CHANNEL_LAYOUT_2_2 = 7,
     35 
     36   // Front L, Front R, Back L, Back R
     37   CHANNEL_LAYOUT_QUAD = 8,
     38 
     39   // Front L, Front R, Front C, Side L, Side R
     40   CHANNEL_LAYOUT_5_0 = 9,
     41 
     42   // Front L, Front R, Front C, Side L, Side R, LFE
     43   CHANNEL_LAYOUT_5_1 = 10,
     44 
     45   // Front L, Front R, Front C, Back L, Back R
     46   CHANNEL_LAYOUT_5_0_BACK = 11,
     47 
     48   // Front L, Front R, Front C, Back L, Back R, LFE
     49   CHANNEL_LAYOUT_5_1_BACK = 12,
     50 
     51   // Front L, Front R, Front C, Side L, Side R, Back L, Back R
     52   CHANNEL_LAYOUT_7_0 = 13,
     53 
     54   // Front L, Front R, Front C, Side L, Side R, LFE, Back L, Back R
     55   CHANNEL_LAYOUT_7_1 = 14,
     56 
     57   // Front L, Front R, Front C, Side L, Side R, LFE, Front LofC, Front RofC
     58   CHANNEL_LAYOUT_7_1_WIDE = 15,
     59 
     60   // Stereo L, Stereo R
     61   CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
     62 
     63   // Stereo L, Stereo R, LFE
     64   CHANNEL_LAYOUT_2POINT1 = 17,
     65 
     66   // Stereo L, Stereo R, Front C, LFE
     67   CHANNEL_LAYOUT_3_1 = 18,
     68 
     69   // Stereo L, Stereo R, Front C, Rear C, LFE
     70   CHANNEL_LAYOUT_4_1 = 19,
     71 
     72   // Stereo L, Stereo R, Front C, Side L, Side R, Back C
     73   CHANNEL_LAYOUT_6_0 = 20,
     74 
     75   // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
     76   CHANNEL_LAYOUT_6_0_FRONT = 21,
     77 
     78   // Stereo L, Stereo R, Side L, Side R, Front C, Rear C.
     79   CHANNEL_LAYOUT_HEXAGONAL = 22,
     80 
     81   // Stereo L, Stereo R, Side L, Side R, Front C, Rear Center, LFE
     82   CHANNEL_LAYOUT_6_1 = 23,
     83 
     84   // Stereo L, Stereo R, Back L, Back R, Front C, Rear Center, LFE
     85   CHANNEL_LAYOUT_6_1_BACK = 24,
     86 
     87   // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
     88   CHANNEL_LAYOUT_6_1_FRONT = 25,
     89 
     90   // Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
     91   CHANNEL_LAYOUT_7_0_FRONT = 26,
     92 
     93   // Front L, Front R, Front C, Back L, Back R, LFE, Front LofC, Front RofC
     94   CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
     95 
     96   // Front L, Front R, Front C, Side L, Side R, Rear C, Back L, Back R.
     97   CHANNEL_LAYOUT_OCTAGONAL = 28,
     98 
     99   // Channels are not explicitly mapped to speakers.
    100   CHANNEL_LAYOUT_DISCRETE = 29,
    101 
    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,
    107 
    108   // Max value, must always equal the largest entry ever logged.
    109   CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC
    110 };
    111 
    112 enum Channels {
    113   LEFT = 0,
    114   RIGHT,
    115   CENTER,
    116   LFE,
    117   BACK_LEFT,
    118   BACK_RIGHT,
    119   LEFT_OF_CENTER,
    120   RIGHT_OF_CENTER,
    121   BACK_CENTER,
    122   SIDE_LEFT,
    123   SIDE_RIGHT,
    124   CHANNELS_MAX = SIDE_RIGHT, // Must always equal the largest value ever logged.
    125 };
    126 
    127 // Returns the expected channel position in an interleaved stream.  Values of -1
    128 // mean the channel at that index is not used for that layout.  Values range
    129 // from 0 to CHANNELS_MAX - 1.
    130 MEDIA_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel);
    131 
    132 // Returns the number of channels in a given ChannelLayout.
    133 MEDIA_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout);
    134 
    135 // Given the number of channels, return the best layout,
    136 // or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match.
    137 MEDIA_EXPORT ChannelLayout GuessChannelLayout(int channels);
    138 
    139 // Returns a string representation of the channel layout.
    140 MEDIA_EXPORT const char* ChannelLayoutToString(ChannelLayout layout);
    141 
    142 }  // namespace media
    143 
    144 #endif  // MEDIA_BASE_CHANNEL_LAYOUT_H_
    145