poll merge squash
This commit is contained in:
parent
308a0486b6
commit
40bee90610
21 changed files with 2753 additions and 261 deletions
|
|
@ -1,50 +1,337 @@
|
|||
#include "backlasses.h"
|
||||
#include "contclasses.h"
|
||||
//TODO: pragma once
|
||||
|
||||
Overseer OverseerHandler::os;
|
||||
|
||||
EndpointHandler::EndpointHandler(Endpoint *ept, QObject *parent) : QObject(parent) {
|
||||
this->ept = ept;
|
||||
eptName = QString::fromStdWString(ept->getName());
|
||||
EndpointHandler::EndpointHandler(uint64_t idx, Flows flow) {
|
||||
//std::vector<Endpoint*> endpoints = osh->getPlaybackEndpoints().at(idx);
|
||||
this->idx = idx;
|
||||
this->flow = flow;
|
||||
this->ep = (flow == Flows::FLOW_PLAYBACK ? osh->getPlaybackEndpoints().at(idx) : osh->getCaptureEndpoints().at(idx));
|
||||
|
||||
epc = new EndpointVolumeCallback(ep);
|
||||
ensc = new EndpointNewSessionCallback(this);
|
||||
this->callbackInfo.caller = osh->getGuid();
|
||||
ep->registerNewSessionNotification(ensc);
|
||||
//epName = ep->getName();
|
||||
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
|
||||
osh->pushBackEndpointHandler(this, flow);
|
||||
|
||||
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||
for (int i = 0; i < this->getSessionCount(); i++) {
|
||||
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
|
||||
sessionHandlers.push_back(sessionHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverseerHandler::pushBackEndpointHandler(EndpointHandler* eph, Flows flow) {
|
||||
if (eph == nullptr) return;
|
||||
if (flow == Flows::FLOW_PLAYBACK)
|
||||
this->playbackEndpointHandlers.push_back(eph);
|
||||
else
|
||||
this->captureEndpointHandlers.push_back(eph);
|
||||
return;
|
||||
}
|
||||
|
||||
void EndpointHandler::setFrontVisibilityInfo(EndpointState state, uint64_t frontIdx){
|
||||
ephfv.visibility = state;
|
||||
ephfv.frontIdx = frontIdx;
|
||||
}
|
||||
|
||||
uint64_t EndpointHandler::getFrontVisibilityIndex(){
|
||||
return ephfv.frontIdx;
|
||||
}
|
||||
|
||||
EndpointState EndpointHandler::getFrontVisibilityState(){
|
||||
return ephfv.visibility;
|
||||
}
|
||||
|
||||
Flows EndpointHandler::getFlow(){
|
||||
return ep->getFlow();
|
||||
}
|
||||
|
||||
/* these two, currently unused. If I use them, I should feel bad.
|
||||
* Endpoint* EndpointHandler::getEndpoint() {
|
||||
* return this->ep;
|
||||
* }
|
||||
*
|
||||
* EndpointVolumeCallback* EndpointHandler::getEndpointVolumeCallback() {
|
||||
* return this->epc;
|
||||
* }
|
||||
*/
|
||||
|
||||
BackEndpointVolumeCallbackInfo* EndpointHandler::getCallbackInfo(){
|
||||
return &this->callbackInfo;
|
||||
}
|
||||
|
||||
uint32_t EndpointHandler::getChannelCount(){
|
||||
return ep->getChannelCount();
|
||||
}
|
||||
|
||||
void EndpointHandler::setIndex(uint64_t idx){
|
||||
this->idx = idx;
|
||||
}
|
||||
|
||||
uint64_t EndpointHandler::getIndex(){
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
* -1 for master volume
|
||||
*/
|
||||
void EndpointHandler::setValue(int channel, int value){
|
||||
if (channel == ENDPOINT_MASTER_VOLUME)
|
||||
ept->setVolume(channel, (float)value / 100);
|
||||
else ept->setVolume(channel, (float)value / 100);
|
||||
void EndpointHandler::setVolume(NGuid guid, int channel, int value){
|
||||
if (channel == AudioChannel::CHANNEL_MAIN)
|
||||
ep->setVolume(guid, channel, (float)value / 100);
|
||||
else ep->setVolume(guid, channel, (float)value / 100);
|
||||
}
|
||||
|
||||
void EndpointHandler::setMute(){
|
||||
//Qt momento, de ahi el param?
|
||||
log_debugcpp("kinda handling the muting tbh");
|
||||
ept->setMute();
|
||||
void EndpointHandler::setMute(NGuid guid, bool muted){
|
||||
ep->setMute(guid, muted);
|
||||
}
|
||||
|
||||
QString EndpointHandler::getName(){
|
||||
return eptName;
|
||||
std::wstring EndpointHandler::getName(){
|
||||
return ep->getName();
|
||||
}
|
||||
|
||||
std::wstring EndpointHandler::getId(){
|
||||
return ep->getId();
|
||||
}
|
||||
|
||||
float EndpointHandler::getVolume(int channel){
|
||||
return ept->getVolume(channel);
|
||||
return ep->getVolume(channel);
|
||||
}
|
||||
|
||||
bool EndpointHandler::getMute(){
|
||||
return ept->getMute();
|
||||
return ep->getMute();
|
||||
}
|
||||
|
||||
Overseer* OverseerHandler::getOverseer(){
|
||||
return &os;
|
||||
size_t EndpointHandler::getState(){
|
||||
return ep->getState();
|
||||
}
|
||||
|
||||
OverseerHandler::OverseerHandler(QObject *parent) : QObject(parent) {
|
||||
void EndpointHandler::setBackEndpointVolumeCallbackInfoContent(uint8_t state) {
|
||||
if(state == EndpointState::ENDPOINT_ACTIVE) {
|
||||
callbackInfo.muted = this->getMute();
|
||||
callbackInfo.mainVolume = this->getVolume(AudioChannel::CHANNEL_MAIN);
|
||||
callbackInfo.channels = this->getChannelCount();
|
||||
ep->setVolumeCallback(epc);
|
||||
callbackInfo.channelVolumes.resize(this->callbackInfo.channels);
|
||||
for(uint32_t i = 0; i < this->getChannelCount(); i++){
|
||||
callbackInfo.channelVolumes.at(i) = this->getVolume(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EndpointHandler::setState(uint8_t state){
|
||||
ep->setState(state);
|
||||
this->setBackEndpointVolumeCallbackInfoContent(state);
|
||||
}
|
||||
|
||||
void EndpointHandler::setState(uint8_t state, uint64_t index){
|
||||
ep->setState(state);
|
||||
this->setFrontVisibilityInfo((EndpointState)state, index);
|
||||
this->setBackEndpointVolumeCallbackInfoContent(state);
|
||||
}
|
||||
|
||||
uint8_t EndpointHandler::getRoles(){
|
||||
return ep->getRoles();
|
||||
}
|
||||
|
||||
void EndpointHandler::setRoles(Roles newRole){
|
||||
ep->setRoles(newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::assignRoles(Roles newRole){
|
||||
ep->assignRoles(newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::removeRoles(Roles newRole){
|
||||
ep->removeRoles(newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::setAddSessionWidgetFunction(std::function<void(SessionHandler*)> addSessionWidget) {
|
||||
this->addSessionWidget = addSessionWidget;
|
||||
}
|
||||
|
||||
void EndpointHandler::setRemoveSessionWidgetFunction(std::function<void(SessionHandler*)> removeSessionWidget) {
|
||||
this->removeSessionWidget = removeSessionWidget;
|
||||
}
|
||||
|
||||
/* sessions */
|
||||
size_t EndpointHandler::getSessionCount() {
|
||||
return ep->getSessionCount();
|
||||
}
|
||||
|
||||
std::vector<Session*> EndpointHandler::getSessions(){
|
||||
return ep->getSessions();
|
||||
}
|
||||
|
||||
std::vector<SessionHandler*> EndpointHandler::getSessionHandlers(){
|
||||
return this->sessionHandlers;
|
||||
}
|
||||
|
||||
Endpoint* EndpointHandler::getEndpoint() {
|
||||
return this->ep;
|
||||
}
|
||||
|
||||
void EndpointHandler::addSessionSendFront(Session* session) {
|
||||
ep->addSession(session);
|
||||
|
||||
SessionHandler* sessionHandler = new SessionHandler(this, session, (getSessionCount() - 1));
|
||||
sessionHandlers.push_back(sessionHandler);
|
||||
this->addSessionWidget(sessionHandler);
|
||||
}
|
||||
|
||||
void EndpointHandler::sendSessionToFront(SessionHandler* sh) {
|
||||
this->addSessionWidget(sh);
|
||||
}
|
||||
|
||||
void EndpointHandler::removeSessionFromFront(SessionHandler* sh) {
|
||||
this->removeSessionWidget(sh);
|
||||
}
|
||||
|
||||
EndpointHandler::~EndpointHandler() {
|
||||
ep->removeVolumeCallback(epc);
|
||||
ep->unregisterNewSessionNotification(ensc);
|
||||
epc->Release();
|
||||
delete ep;
|
||||
}
|
||||
|
||||
OverseerHandler::OverseerHandler() {
|
||||
this->os = new Overseer();
|
||||
}
|
||||
|
||||
std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
|
||||
return this->os->getPlaybackEndpoints();
|
||||
}
|
||||
|
||||
std::vector<Endpoint*> OverseerHandler::getCaptureEndpoints() {
|
||||
return this->os->getCaptureEndpoints();
|
||||
}
|
||||
|
||||
std::vector<EndpointHandler*> OverseerHandler::getPlaybackEndpointHandlers(){
|
||||
return playbackEndpointHandlers;
|
||||
}
|
||||
|
||||
std::vector<EndpointHandler*> OverseerHandler::getCaptureEndpointHandlers(){
|
||||
return captureEndpointHandlers;
|
||||
}
|
||||
|
||||
uint64_t OverseerHandler::getPlaybackEndpointsCount(){
|
||||
return this->os->getPlaybackEndpoints().size();
|
||||
}
|
||||
|
||||
uint64_t OverseerHandler::getCaptureEndpointsCount(){
|
||||
return this->os->getCaptureEndpoints().size();
|
||||
}
|
||||
|
||||
void OverseerHandler::reloadEndpointHandlers(){
|
||||
//todo: add capture
|
||||
|
||||
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
|
||||
log_debugcpp("Playback VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
|
||||
|
||||
for(uint64_t i = 0; i < this->getPlaybackEndpointsCount(); i++){
|
||||
log_debugcpp("Creating Playback handler " + std::to_string(i));
|
||||
|
||||
EndpointHandler* ephexx = new EndpointHandler(i, Flows::FLOW_PLAYBACK);
|
||||
//this->playbackEndpointHandlers.push_back(ephexx);
|
||||
log_debugcpp("Created Playback handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->playbackEndpointHandlers.size()));
|
||||
|
||||
}
|
||||
|
||||
log_debugcpp("Capture VSize: " +
|
||||
std::to_string(this->getCaptureEndpointsCount()));
|
||||
|
||||
for(uint64_t i = 0; i < this->getCaptureEndpointsCount(); i++){
|
||||
log_debugcpp("Creating Capture handler " + std::to_string(i));
|
||||
|
||||
/*
|
||||
* if(i < (this->captureEndpointHandlers.size()) &&
|
||||
* this->captureEndpointHandlers.at(i) != nullptr)
|
||||
* delete captureEndpointHandlers.at(i);
|
||||
*/
|
||||
|
||||
EndpointHandler* ephoo = new EndpointHandler(i, Flows::FLOW_CAPTURE);
|
||||
//this->captureEndpointHandlers.push_back(ephoo);
|
||||
log_debugcpp("Created Capture handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->captureEndpointHandlers.size()));
|
||||
|
||||
/*
|
||||
* if (i >= this->captureEndpointHandlers.size())
|
||||
* captureEndpointHandlers.push_back(eph);
|
||||
* else captureEndpointHandlers.at(i) = eph;
|
||||
*/
|
||||
}
|
||||
//setEndpointHandlers(ephs);
|
||||
}
|
||||
|
||||
std::vector<EndpointHandler*>* OverseerHandler::getEndpointHandlers(){
|
||||
return endpointHandlers;
|
||||
EndpointHandler* OverseerHandler::addEndpoint(std::wstring endpointId, /* out */ Flows *flow = nullptr){
|
||||
Flows localFlow;
|
||||
Endpoint* newEp = this->os->addEndpoint(endpointId, &localFlow);
|
||||
|
||||
uint64_t ephIdx = (localFlow == Flows::FLOW_PLAYBACK ? this->getPlaybackEndpointsCount() : this->getCaptureEndpointsCount()) - 1;
|
||||
|
||||
EndpointHandler* newEph = new EndpointHandler(ephIdx, localFlow);
|
||||
// std::vector<EndpointHandler*> getPlaybackEndpointHandlers();
|
||||
//std::vector<EndpointHandler*> getCaptureEndpointHandlers();
|
||||
if (flow != nullptr) *flow = localFlow;
|
||||
return newEph;
|
||||
}
|
||||
|
||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> *ephs){
|
||||
this->endpointHandlers = ephs;
|
||||
NGuid OverseerHandler::getGuid() {
|
||||
return this->os->getGuid();
|
||||
}
|
||||
|
||||
void OverseerHandler::setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults){
|
||||
this->changeFrontDefaults = changeFrontDefaults;
|
||||
}
|
||||
|
||||
void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpointId) {
|
||||
this->changeFrontDefaults(role, endpointId);
|
||||
}
|
||||
|
||||
void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointState state) {
|
||||
std::vector<EndpointHandler*> allHandlers;
|
||||
allHandlers.insert(allHandlers.end(), this->captureEndpointHandlers.begin(), this->captureEndpointHandlers.end());
|
||||
allHandlers.insert(allHandlers.end(), this->playbackEndpointHandlers.begin(), this->playbackEndpointHandlers.end());
|
||||
EndpointHandler* eph = nullptr;
|
||||
for (auto loopEph : allHandlers) {
|
||||
if (loopEph->getId() == endpointId) {
|
||||
eph = loopEph;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//debug
|
||||
Flows flow;
|
||||
if (!eph) {
|
||||
if (state ^ EndpointState::ENDPOINT_ACTIVE) return;
|
||||
//return;
|
||||
//flow = Flows::FLOW_CAPTURE;
|
||||
eph = osh->addEndpoint(endpointId, &flow);
|
||||
} else
|
||||
flow = eph->getFlow();
|
||||
|
||||
//todo: mic done but disabled. Tab-kun will come...
|
||||
if (flow == Flows::FLOW_CAPTURE) return;
|
||||
|
||||
|
||||
if(eph && EndpointState::ENDPOINT_ACTIVE & state) {
|
||||
this->addEndpointWidget(eph);
|
||||
} else if (eph && eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
|
||||
this->removeEndpointWidget(eph->getFrontVisibilityIndex());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void OverseerHandler::setAddEndpointWidgetFunction(std::function<void(EndpointHandler*)> addEndpointWidget){
|
||||
this->addEndpointWidget = addEndpointWidget;
|
||||
}
|
||||
|
||||
void OverseerHandler::setRemoveEndpointWidgetFunction(std::function<void(uint64_t)> removeEndpointWidget){
|
||||
this->removeEndpointWidget = removeEndpointWidget;
|
||||
}
|
||||
|
||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
||||
this->playbackEndpointHandlers = ephs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue