File indexing completed on 2024-05-05 04:58:54

0001 /**
0002  * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
0003  * SPDX-FileCopyrightText: 2019 Piyush Aggarwal <piyushaggarwal002@gmail.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 #pragma once
0009 
0010 #include <QHash>
0011 #include <QObject>
0012 #include <QSet>
0013 #include <QString>
0014 
0015 #include <winrt/Windows.ApplicationModel.h>
0016 #include <winrt/Windows.Foundation.Collections.h>
0017 #include <winrt/Windows.Media.Control.h>
0018 
0019 #include <core/kdeconnectplugin.h>
0020 
0021 #include <endpointvolume.h>
0022 #include <mmdeviceapi.h>
0023 
0024 using namespace winrt;
0025 using namespace Windows::Media::Control;
0026 using namespace Windows::ApplicationModel;
0027 
0028 class PauseMusicPlugin : public KdeConnectPlugin
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit PauseMusicPlugin(QObject *parent, const QVariantList &args);
0034     ~PauseMusicPlugin();
0035 
0036     void receivePacket(const NetworkPacket &np) override;
0037 
0038 private:
0039     void updatePlayersList();
0040     bool updateSinksList();
0041 
0042     bool valid;
0043     IMMDeviceEnumerator *deviceEnumerator;
0044     QHash<QString, IAudioEndpointVolume *> sinksList;
0045 
0046     GlobalSystemMediaTransportControlsSessionManager sessionManager;
0047     QHash<QString, GlobalSystemMediaTransportControlsSession> playersList;
0048 
0049     QSet<QString> pausedSources;
0050     QSet<QString> mutedSinks;
0051 };