kodi
AESinkFactory.h
1 /*
2  * Copyright (C) 2010-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 "Utils/AEAudioFormat.h"
12 #include "Utils/AEDeviceInfo.h"
13 
14 #include <functional>
15 #include <map>
16 #include <memory>
17 #include <stdint.h>
18 #include <string>
19 #include <vector>
20 
21 class IAESink;
22 
23 namespace AE
24 {
25 
26 struct AESinkInfo
27 {
28  std::string m_sinkName;
29  AEDeviceInfoList m_deviceInfoList;
30 };
31 
32 using CreateSink =
33  std::function<std::unique_ptr<IAESink>(std::string& device, AEAudioFormat& desiredFormat)>;
34 using Enumerate = std::function<void(AEDeviceInfoList& list, bool force)>;
35 using Cleanup = std::function<void()>;
36 
38 {
39  std::string sinkName;
40  CreateSink createFunc;
41  Enumerate enumerateFunc;
42  Cleanup cleanupFunc;
43 };
44 
46 {
47  std::string driver;
48  std::string name;
49  std::string friendlyName;
50 
51  bool IsSameDeviceAs(const AESinkDevice& d) const
52  {
53  return driver == d.driver && (name == d.name || friendlyName == d.friendlyName);
54  }
55 };
56 
58 {
59 public:
60  static void RegisterSink(const AESinkRegEntry& regEntry);
61  static void ClearSinks();
62  static bool HasSinks();
63 
64  static AESinkDevice ParseDevice(const std::string& device);
65  static std::unique_ptr<IAESink> Create(const std::string& device, AEAudioFormat& desiredFormat);
66  static void EnumerateEx(std::vector<AESinkInfo>& list, bool force, const std::string& driver);
67  static void Cleanup();
68 
69 protected:
70  static std::map<std::string, AESinkRegEntry> m_AESinkRegEntry;
71 };
72 
73 }
Definition: AESinkFactory.h:26
Definition: AESinkFactory.h:23
Definition: AESink.h:18
Definition: AESinkFactory.h:57
The audio format structure that fully defines a stream&#39;s audio information.
Definition: AEAudioFormat.h:19
Definition: AESinkFactory.h:45
Definition: AESinkFactory.h:37