xbmc
CoreAudioChannelLayout.h
1 /*
2  * Copyright (C) 2011-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <list>
12 #include <string>
13 #include <vector>
14 
15 #include <CoreAudio/CoreAudio.h>
16 
17 typedef std::vector<SInt32> CoreAudioChannelList;
18 typedef std::list<AudioChannelLayoutTag> AudioChannelLayoutList;
19 
20 const AudioChannelLayoutTag g_LayoutMap[] =
21 {
22  kAudioChannelLayoutTag_Stereo, // PCM_LAYOUT_2_0 = 0,
23  kAudioChannelLayoutTag_Stereo, // PCM_LAYOUT_2_0 = 0,
24  kAudioChannelLayoutTag_DVD_4, // PCM_LAYOUT_2_1,
25  kAudioChannelLayoutTag_MPEG_3_0_A, // PCM_LAYOUT_3_0,
26  kAudioChannelLayoutTag_DVD_10, // PCM_LAYOUT_3_1,
27  kAudioChannelLayoutTag_DVD_3, // PCM_LAYOUT_4_0,
28  kAudioChannelLayoutTag_DVD_6, // PCM_LAYOUT_4_1,
29  kAudioChannelLayoutTag_MPEG_5_0_A, // PCM_LAYOUT_5_0,
30  kAudioChannelLayoutTag_MPEG_5_1_A, // PCM_LAYOUT_5_1,
31  kAudioChannelLayoutTag_AudioUnit_7_0, // PCM_LAYOUT_7_0, ** This layout may be incorrect...no content to testß˚ **
32  kAudioChannelLayoutTag_MPEG_7_1_A, // PCM_LAYOUT_7_1
33 };
34 
35 const AudioChannelLabel g_LabelMap[] =
36 {
37  kAudioChannelLabel_Unused, // PCM_FRONT_LEFT,
38  kAudioChannelLabel_Left, // PCM_FRONT_LEFT,
39  kAudioChannelLabel_Right, // PCM_FRONT_RIGHT,
40  kAudioChannelLabel_Center, // PCM_FRONT_CENTER,
41  kAudioChannelLabel_LFEScreen, // PCM_LOW_FREQUENCY,
42  kAudioChannelLabel_LeftSurroundDirect, // PCM_BACK_LEFT, *** This is incorrect, but has been changed to match VideoPlayer
43  kAudioChannelLabel_RightSurroundDirect, // PCM_BACK_RIGHT, *** This is incorrect, but has been changed to match VideoPlayer
44  kAudioChannelLabel_LeftCenter, // PCM_FRONT_LEFT_OF_CENTER,
45  kAudioChannelLabel_RightCenter, // PCM_FRONT_RIGHT_OF_CENTER,
46  kAudioChannelLabel_CenterSurround, // PCM_BACK_CENTER,
47  kAudioChannelLabel_LeftSurround, // PCM_SIDE_LEFT, *** This is incorrect, but has been changed to match VideoPlayer
48  kAudioChannelLabel_RightSurround, // PCM_SIDE_RIGHT, *** This is incorrect, but has been changed to match VideoPlayer
49  kAudioChannelLabel_VerticalHeightLeft, // PCM_TOP_FRONT_LEFT,
50  kAudioChannelLabel_VerticalHeightRight, // PCM_TOP_FRONT_RIGHT,
51  kAudioChannelLabel_VerticalHeightCenter, // PCM_TOP_FRONT_CENTER,
52  kAudioChannelLabel_TopCenterSurround, // PCM_TOP_CENTER,
53  kAudioChannelLabel_TopBackLeft, // PCM_TOP_BACK_LEFT,
54  kAudioChannelLabel_TopBackRight, // PCM_TOP_BACK_RIGHT,
55  kAudioChannelLabel_TopBackCenter // PCM_TOP_BACK_CENTER
56 };
57 
59 {
60 public:
62  CCoreAudioChannelLayout(AudioChannelLayout &layout);
63  virtual ~CCoreAudioChannelLayout();
64 
65  operator AudioChannelLayout*() {return m_pLayout;}
66 
67  bool CopyLayout(AudioChannelLayout &layout);
68  bool CopyLayoutForStereo(UInt32 layout[2]);
69  static UInt32 GetChannelCountForLayout(AudioChannelLayout &layout);
70  static const char* ChannelLabelToString(UInt32 label);
71  static const char* ChannelLayoutToString(AudioChannelLayout &layout, std::string &str);
72  bool AllChannelUnknown();
73 protected:
74  AudioChannelLayout* m_pLayout;
75 };
Definition: CoreAudioChannelLayout.h:58