16 #ifndef ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_BLUEZDEVICEMANAGER_H_ 17 #define ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_BLUEZDEVICEMANAGER_H_ 39 namespace bluetoothImplementations {
43 class BlueZBluetoothDevice;
51 ,
public std::enable_shared_from_this<BlueZDeviceManager> {
59 static std::shared_ptr<BlueZDeviceManager>
create(
60 std::shared_ptr<avsCommon::utils::bluetooth::BluetoothEventBus> eventBus);
70 std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothHostControllerInterface>
getHostController()
override;
71 std::list<std::shared_ptr<avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface>>
getDiscoveredDevices()
73 std::shared_ptr<avsCommon::utils::bluetooth::BluetoothEventBus>
getEventBus()
override;
107 explicit BlueZDeviceManager(
const std::shared_ptr<avsCommon::utils::bluetooth::BluetoothEventBus>& eventBus);
121 bool initializeMedia();
128 bool finalizeMedia();
137 std::shared_ptr<BlueZBluetoothDevice> addDeviceFromDBusObject(
const char* objectPath, GVariant* dbusObject);
150 static void interfacesAddedCallback(
151 GDBusConnection* conn,
152 const gchar* sender_name,
153 const gchar* object_path,
154 const gchar* interface_name,
155 const gchar* signal_name,
156 GVariant* parameters,
170 static void interfacesRemovedCallback(
171 GDBusConnection* conn,
172 const gchar* sender_name,
173 const gchar* object_path,
174 const gchar* interface_name,
175 const gchar* signal_name,
176 GVariant* parameters,
190 static void propertiesChangedCallback(
191 GDBusConnection* conn,
192 const gchar* sender_name,
193 const gchar* object_path,
194 const gchar* interface_name,
195 const gchar* signal_name,
196 GVariant* parameters,
205 void addDevice(
const char* devicePath, std::shared_ptr<BlueZBluetoothDevice> device);
212 void removeDevice(
const char* devicePath);
219 void notifyDeviceAdded(std::shared_ptr<BlueZBluetoothDevice> device);
227 void onInterfaceAdded(
const char* objectPath,
ManagedGVariant& interfacesChangedMap);
234 void onInterfaceRemoved(
const char* objectPath);
265 std::shared_ptr<BlueZHostController> initializeHostController();
274 void onPropertiesChanged(
282 bool getStateFromBlueZ();
290 std::shared_ptr<BlueZBluetoothDevice> getDeviceByPath(
const std::string& path)
const;
293 void mainLoopThread();
299 std::shared_ptr<DBusProxy> m_objectManagerProxy;
302 std::shared_ptr<DBusProxy> m_mediaProxy;
305 std::map<std::string, std::shared_ptr<BlueZBluetoothDevice>> m_devices;
308 std::shared_ptr<MediaEndpoint> m_mediaEndpoint;
311 std::shared_ptr<PairingAgent> m_pairingAgent;
314 std::shared_ptr<MPRISPlayer> m_mediaPlayer;
317 std::shared_ptr<avsCommon::utils::bluetooth::BluetoothEventBus> m_eventBus;
321 GMainLoop* m_eventLoop;
324 GMainContext* m_workerContext;
327 std::shared_ptr<DBusConnection> m_connection;
333 mutable std::mutex m_devicesMutex;
336 std::shared_ptr<BlueZHostController> m_hostController;
339 std::promise<bool> m_mainLoopInitPromise;
342 std::thread m_eventThread;
349 #endif // ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_BLUEZDEVICEMANAGER_H_
std::list< std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothDeviceInterface > > getDiscoveredDevices() override
std::shared_ptr< avsCommon::sdkInterfaces::bluetooth::BluetoothHostControllerInterface > getHostController() override
::std::string string
Definition: gtest-port.h:1097
MediaStreamingState
An Enum representing the current state of the stream.
Definition: MediaStreamingState.h:25
Definition: RequiresShutdown.h:32
std::string getAdapterPath() const
void doShutdown() override
Definition: ManagedGVariant.h:33
Definition: GVariantMapReader.h:36
static std::shared_ptr< BlueZDeviceManager > create(std::shared_ptr< avsCommon::utils::bluetooth::BluetoothEventBus > eventBus)
std::shared_ptr< MediaEndpoint > getMediaEndpoint()
std::shared_ptr< avsCommon::utils::bluetooth::BluetoothEventBus > getEventBus() override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
virtual ~BlueZDeviceManager() override
Definition: BlueZDeviceManager.h:48
Definition: BluetoothDeviceManagerInterface.h:36
avsCommon::utils::bluetooth::MediaStreamingState getMediaStreamingState()