mixer/src/cont/contsessionclasses.cpp
2024-04-30 23:40:52 +02:00

87 lines
2 KiB
C++

#include "contsessionclasses.h"
#include "backsessionclasses.h"
SessionHandler::SessionHandler(EndpointHandler* eph, Session* session, size_t idx) {
this->eph = eph;
this->idx = idx;
this->session = session;
this->svi.mainVolume = session->getVolume(AudioChannel::CHANNEL_MAIN);
this->svi.muted = session->getMute();
this->svi.caller = osh->getGuid();
ssc = new SessionStateCallback(this);
this->session->setStateCallback(ssc);
}
void SessionHandler::setVolume(NGuid guid, int channel, int value){
if (channel == AudioChannel::CHANNEL_MAIN)
session->setVolume(guid, channel, (float)value / 100);
else session->setVolume(guid, channel, (float)value / 100);
}
float SessionHandler::getVolume(int channel){
return session->getVolume(channel);
}
void SessionHandler::setMute(NGuid guid, bool muted){
session->setMute(guid, muted);
}
std::wstring SessionHandler::getName(){
return session->getName();
}
void SessionHandler::setName(std::wstring newName){
session->setName(newName);
}
float SessionHandler::getPeakVolume(){
return session->getPeakVolume();
}
bool SessionHandler::getMute(){
return session->getMute();
}
void SessionHandler::setFrontIndex(uint64_t frontIdx) {
this->frontIdx = frontIdx;
}
uint64_t SessionHandler::getFrontIndex() {
return frontIdx;
}
SessionVolumeInfo* SessionHandler::getVolumeInfo() {
return &svi;
}
SessionState SessionHandler::getState() {
return session->getState();
}
void SessionHandler::setState(SessionState state) {
session->setState(state);
}
void SessionHandler::reviseSessionShowing(SessionState state) {
SessionState currentState = this->getState();
switch (currentState) {
case SessionState::ACTIVE:
case SessionState::INACTIVE:
if (state == SessionState::EXPIRED) {
eph->removeSessionFromFront(this);
}
break;
case SessionState::EXPIRED:
if (state == SessionState::ACTIVE || INACTIVE) {
eph->sendSessionToFront(this);
}
break;
case SessionState::DISCONNECTED:
if (frontIdx != INT_MAX)
eph->removeSessionFromFront(this);
break;
}
}