channel_layout.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #ifndef MEDIA_BASE_CHANNEL_LAYOUT_H_
  5. #define MEDIA_BASE_CHANNEL_LAYOUT_H_
  6. #include "media/base/media_shmem_export.h"
  7. namespace media {
  8. // Enumerates the various representations of the ordering of audio channels.
  9. // Logged to UMA, so never reuse a value, always add new/greater ones!
  10. enum ChannelLayout {
  11. CHANNEL_LAYOUT_NONE = 0,
  12. CHANNEL_LAYOUT_UNSUPPORTED = 1,
  13. // Front C
  14. CHANNEL_LAYOUT_MONO = 2,
  15. // Front L, Front R
  16. CHANNEL_LAYOUT_STEREO = 3,
  17. // Front L, Front R, Back C
  18. CHANNEL_LAYOUT_2_1 = 4,
  19. // Front L, Front R, Front C
  20. CHANNEL_LAYOUT_SURROUND = 5,
  21. // Front L, Front R, Front C, Back C
  22. CHANNEL_LAYOUT_4_0 = 6,
  23. // Front L, Front R, Side L, Side R
  24. CHANNEL_LAYOUT_2_2 = 7,
  25. // Front L, Front R, Back L, Back R
  26. CHANNEL_LAYOUT_QUAD = 8,
  27. // Front L, Front R, Front C, Side L, Side R
  28. CHANNEL_LAYOUT_5_0 = 9,
  29. // Front L, Front R, Front C, LFE, Side L, Side R
  30. CHANNEL_LAYOUT_5_1 = 10,
  31. // Front L, Front R, Front C, Back L, Back R
  32. CHANNEL_LAYOUT_5_0_BACK = 11,
  33. // Front L, Front R, Front C, LFE, Back L, Back R
  34. CHANNEL_LAYOUT_5_1_BACK = 12,
  35. // Front L, Front R, Front C, Side L, Side R, Back L, Back R
  36. CHANNEL_LAYOUT_7_0 = 13,
  37. // Front L, Front R, Front C, LFE, Side L, Side R, Back L, Back R
  38. CHANNEL_LAYOUT_7_1 = 14,
  39. // Front L, Front R, Front C, LFE, Side L, Side R, Front LofC, Front RofC
  40. CHANNEL_LAYOUT_7_1_WIDE = 15,
  41. // Stereo L, Stereo R
  42. CHANNEL_LAYOUT_STEREO_DOWNMIX = 16,
  43. // Stereo L, Stereo R, LFE
  44. CHANNEL_LAYOUT_2POINT1 = 17,
  45. // Stereo L, Stereo R, Front C, LFE
  46. CHANNEL_LAYOUT_3_1 = 18,
  47. // Stereo L, Stereo R, Front C, Rear C, LFE
  48. CHANNEL_LAYOUT_4_1 = 19,
  49. // Stereo L, Stereo R, Front C, Side L, Side R, Back C
  50. CHANNEL_LAYOUT_6_0 = 20,
  51. // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC
  52. CHANNEL_LAYOUT_6_0_FRONT = 21,
  53. // Stereo L, Stereo R, Front C, Rear L, Rear R, Rear C
  54. CHANNEL_LAYOUT_HEXAGONAL = 22,
  55. // Stereo L, Stereo R, Front C, LFE, Side L, Side R, Rear Center
  56. CHANNEL_LAYOUT_6_1 = 23,
  57. // Stereo L, Stereo R, Front C, LFE, Back L, Back R, Rear Center
  58. CHANNEL_LAYOUT_6_1_BACK = 24,
  59. // Stereo L, Stereo R, Side L, Side R, Front LofC, Front RofC, LFE
  60. CHANNEL_LAYOUT_6_1_FRONT = 25,
  61. // Front L, Front R, Front C, Side L, Side R, Front LofC, Front RofC
  62. CHANNEL_LAYOUT_7_0_FRONT = 26,
  63. // Front L, Front R, Front C, LFE, Back L, Back R, Front LofC, Front RofC
  64. CHANNEL_LAYOUT_7_1_WIDE_BACK = 27,
  65. // Front L, Front R, Front C, Side L, Side R, Rear L, Back R, Back C.
  66. CHANNEL_LAYOUT_OCTAGONAL = 28,
  67. // Channels are not explicitly mapped to speakers.
  68. CHANNEL_LAYOUT_DISCRETE = 29,
  69. // Deprecated, but keeping the enum value for UMA consistency.
  70. // Front L, Front R, Front C. Front C contains the keyboard mic audio. This
  71. // layout is only intended for input for WebRTC. The Front C channel
  72. // is stripped away in the WebRTC audio input pipeline and never seen outside
  73. // of that.
  74. CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC = 30,
  75. // Front L, Front R, Side L, Side R, LFE
  76. CHANNEL_LAYOUT_4_1_QUAD_SIDE = 31,
  77. // Actual channel layout is specified in the bitstream and the actual channel
  78. // count is unknown at Chromium media pipeline level (useful for audio
  79. // pass-through mode).
  80. CHANNEL_LAYOUT_BITSTREAM = 32,
  81. // Front L, Front R, Front C, LFE, Side L, Side R,
  82. // Front Height L, Front Height R, Rear Height L, Rear Height R
  83. // Will be represented as six channels (5.1) due to eight channel limit
  84. // kMaxConcurrentChannels
  85. CHANNEL_LAYOUT_5_1_4_DOWNMIX = 33,
  86. // Max value, must always equal the largest entry ever logged.
  87. CHANNEL_LAYOUT_MAX = CHANNEL_LAYOUT_5_1_4_DOWNMIX
  88. };
  89. // Note: Do not reorder or reassign these values; other code depends on their
  90. // ordering to operate correctly. E.g., CoreAudio channel layout computations.
  91. enum Channels {
  92. LEFT = 0,
  93. RIGHT,
  94. CENTER,
  95. LFE,
  96. BACK_LEFT,
  97. BACK_RIGHT,
  98. LEFT_OF_CENTER,
  99. RIGHT_OF_CENTER,
  100. BACK_CENTER,
  101. SIDE_LEFT,
  102. SIDE_RIGHT,
  103. CHANNELS_MAX = SIDE_RIGHT, // Must always equal the largest value ever logged.
  104. };
  105. // The maximum number of concurrently active channels for all possible layouts.
  106. // ChannelLayoutToChannelCount() will never return a value higher than this.
  107. constexpr int kMaxConcurrentChannels = 8;
  108. // Returns the expected channel position in an interleaved stream. Values of -1
  109. // mean the channel at that index is not used for that layout. Values range
  110. // from 0 to ChannelLayoutToChannelCount(layout) - 1.
  111. MEDIA_SHMEM_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel);
  112. // Returns the number of channels in a given ChannelLayout or 0 if the
  113. // channel layout can't be mapped to a valid value. Currently, 0
  114. // is returned for CHANNEL_LAYOUT_NONE, CHANNEL_LAYOUT_UNSUPPORTED,
  115. // CHANNEL_LAYOUT_DISCRETE, and CHANNEL_LAYOUT_BITSTREAM. For these cases,
  116. // additional steps must be taken to manually figure out the corresponding
  117. // number of channels.
  118. MEDIA_SHMEM_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout);
  119. // Given the number of channels, return the best layout,
  120. // or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match.
  121. MEDIA_SHMEM_EXPORT ChannelLayout GuessChannelLayout(int channels);
  122. // Returns a string representation of the channel layout.
  123. MEDIA_SHMEM_EXPORT const char* ChannelLayoutToString(ChannelLayout layout);
  124. } // namespace media
  125. #endif // MEDIA_BASE_CHANNEL_LAYOUT_H_