// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_BASE_CHANNEL_LAYOUT_H_ #define MEDIA_BASE_CHANNEL_LAYOUT_H_ #include "media/base/media_shmem_export.h" namespace media { // Enumerates the various representations of the ordering of audio channels. // Logged to UMA, so never reuse a value, always add new/greater ones! enum ChannelLayout { … }; // Note: Do not reorder or reassign these values; other code depends on their // ordering to operate correctly. E.g., CoreAudio channel layout computations. enum Channels { … }; // The maximum number of concurrently active channels for all possible layouts. // ChannelLayoutToChannelCount() will never return a value higher than this. constexpr int kMaxConcurrentChannels = …; // Returns the expected channel position in an interleaved stream. Values of -1 // mean the channel at that index is not used for that layout. Values range // from 0 to ChannelLayoutToChannelCount(layout) - 1. MEDIA_SHMEM_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel); // Returns the number of channels in a given ChannelLayout or 0 if the // channel layout can't be mapped to a valid value. Currently, 0 // is returned for CHANNEL_LAYOUT_NONE, CHANNEL_LAYOUT_UNSUPPORTED, // CHANNEL_LAYOUT_DISCRETE, and CHANNEL_LAYOUT_BITSTREAM. For these cases, // additional steps must be taken to manually figure out the corresponding // number of channels. MEDIA_SHMEM_EXPORT int ChannelLayoutToChannelCount(ChannelLayout layout); // Given the number of channels, return the best layout, // or return CHANNEL_LAYOUT_UNSUPPORTED if there is no good match. MEDIA_SHMEM_EXPORT ChannelLayout GuessChannelLayout(int channels); // Returns a string representation of the channel layout. MEDIA_SHMEM_EXPORT const char* ChannelLayoutToString(ChannelLayout layout); } // namespace media #endif // MEDIA_BASE_CHANNEL_LAYOUT_H_