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   // Total number of layouts.
    103   CHANNEL_LAYOUT_MAX  // Must always be last!
    104 };
    105 
    106 enum Channels {
    107   LEFT = 0,
    108   RIGHT,
    109   CENTER,
    110   LFE,
    111   BACK_LEFT,
    112   BACK_RIGHT,
    113   LEFT_OF_CENTER,
    114   RIGHT_OF_CENTER,
    115   BACK_CENTER,
    116   SIDE_LEFT,
    117   SIDE_RIGHT,
    118   CHANNELS_MAX
    119 };
    120 
    121 // Returns the expected channel position in an interleaved stream.  Values of -1
    122 // mean the channel at that index is not used for that layout.  Values range
    123 // from 0 to CHANNELS_MAX - 1.
    124 MEDIA_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel);
    125 
    126 // Returns the number of channels in a given ChannelLayout.
    127 MEDIA_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout);
    128 
    129 // Given the number of channels, return the best layout,
    130 // or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match.
    131 MEDIA_EXPORT ChannelLayout GuessChannelLayout(int channels);
    132 
    133 }  // namespace media
    134 
    135 #endif  // MEDIA_BASE_CHANNEL_LAYOUT_H_
    136