mixer/src/back/backlasses.h

87 lines
1.9 KiB
C++

#pragma once
#define WIN32_LEAN_AND_MEAN
#include "debug.h"
#include "global.h"
#include <vector>
#include <iostream>
#include <Windows.h>
#include <mmdeviceapi.h>
#include <combaseapi.h>
#include <initguid.h>
#include <functiondiscoverykeys_devpkey.h>
#include <endpointvolume.h>
#include <audiopolicy.h>
#include <audioclient.h>
//#include <comdef.h>
//#include <comip.h>
#include <Winerror.h>
class EndpointWidget;
class EndpointCallback : public IAudioEndpointVolumeCallback {
public:
EndpointCallback();
ULONG AddRef();
ULONG Release();
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
HRESULT OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA update);
~EndpointCallback();
private:
ULONG ref;
PAUDIO_VOLUME_NOTIFICATION_DATA update;
};
class Endpoint {
public:
Endpoint(IMMDevice* endpoint);
void setVolume(int channel, float volume);
/* float getLeftChannelVolume(); */
/* float getRightChannelVolume(); */
float getVolume(int channel);
void setMute();
bool getMute();
LPWSTR getName();
void setCallback(EndpointCallback *epc);
void removeCallback(EndpointCallback *epc);
~Endpoint();
private:
IMMDevice* endpoint;
IAudioEndpointVolume *endpointVolume ;
IPropertyStore *properties;
LPWSTR friendlyName;
// LPWSTR endpointID = NULL;
};
class Overseer {
//TODO singleton?
public:
Overseer();
std::vector<Endpoint*> getPlaybackEndpoints();
void reloadEndpoints();
LPGUID getGuid();
//~Overseer();
//int getDefaultPlaybackEndpoint(Endpoint** defaultEndpoint);
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
//int getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
//IMMDeviceEnumerator** setOrigin();
~Overseer();
private:
LPGUID guid;
unsigned int numPlaybackEndpoints;
IMMDeviceEnumerator *deviceEnumerator;
std::vector<Endpoint*> playbackDevices;
void initCOMLibrary();
//IMMDeviceCollection *deviceCollection;
//int numCaptureEndpoints;
//std::vector<Endpoint*> *captureDevices;
};