Rivendellaudio/cae/session.cpp
Fred Gleason c8e6dd62e8 2023-09-09 Fred Gleason <fredg@paravelsystems.com>
* Modified the communications layer to use UDP command messaging.
	* Disabled the 'Meter Enable' ['ME'] CAE command.
	* Implemented the 'Start Playback' ['PY'] CAE command.
	* Implemented the modified 'Play Position' ['PP'] CAE command.
	* Implemented the modified 'Stop Playback' ['SP'] CAE command.
	* Stubbed out the new 'Pause Playback' ['PE'] CAE command.
	* Stubbed out the new 'Resume Playback' ['PR'] CAE command.
	* Implemented the modified 'Set Output Volume' ['OV'] CAE command.
	* Implemented the modified 'Fade Output Volume' ['FV'] CAE command.
	* Stubbed out the new 'Cue Recording' ['LR'] CAE command.
	* Stubbed out the new 'Start Recording' ['RD'] CAE command.
	* Stubbed out the new 'Cue and Start Recording' ['RC'] CAE command.
	* Stubbed out the modified 'Stop Recording' ['SR'] CAE command.
	* Implemented the modified 'Get Input Status' ['IS'] CAE command.
	* Implemented the modified 'Set Audio Passthrough Level' ['AL'] CAE
	command.
	* Implemented the new 'Update Audio Ports' ['AP'] CAE command.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
2023-09-08 15:09:47 -04:00

232 lines
3.5 KiB
C++

// session.cpp
//
// Persistent context for CAE protocol commands
//
// (C) Copyright 2023 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "session.h"
SessionId::SessionId(const QHostAddress &addr,uint16_t port,int pid,int serial)
{
d_address=addr;
d_port=port;
d_process_id=pid;
d_serial_number=serial;
}
SessionId::SessionId()
{
d_port=0;
d_process_id=0;
d_serial_number=0;
}
QHostAddress SessionId::address() const
{
return d_address;
}
uint16_t SessionId::port() const
{
return d_port;
}
int SessionId::processId() const
{
return d_process_id;
}
void SessionId::setProcessId(int pid)
{
d_process_id=pid;
}
int SessionId::serialNumber() const
{
return d_serial_number;
}
void SessionId::setSerialNumber(int serial)
{
d_serial_number=serial;
}
QString SessionId::dump() const
{
return address().toString()+
QString::asprintf(":%d:%d:%d",0xFFFF&port(),processId(),serialNumber());
}
bool SessionId::operator<(const SessionId &other) const
{
if(other.d_address!=d_address) {
return other.d_address.toIPv4Address()<d_address.toIPv4Address();
}
if(other.d_port!=d_port) {
return other.d_port<d_port;
}
if(other.d_process_id!=d_process_id) {
return other.d_process_id<d_process_id;
}
return other.d_serial_number<d_serial_number;
}
Session::Session(const QHostAddress &addr,uint16_t port,int pid,int serial)
{
d_session_id=SessionId(addr,port,pid,serial);
d_card_number=-1;
d_port_number=-1;
d_stream_number=-1;
d_start_position=-1;
d_end_position=-1;
d_speed=100000;
d_meter_port=0;
d_meters_enabled=false;
}
Session::Session(const SessionId &sid)
{
d_session_id=sid;
d_card_number=-1;
d_port_number=-1;
d_stream_number=-1;
d_start_position=-1;
d_end_position=-1;
d_speed=100000;
d_meter_port=0;
d_meters_enabled=false;
}
SessionId Session::sessionId() const
{
return d_session_id;
}
int Session::cardNumber() const
{
return d_card_number;
}
void Session::setCardNumber(int cardnum)
{
d_card_number=cardnum;
}
int Session::portNumber() const
{
return d_port_number;
}
void Session::setPortNumber(int portnum)
{
d_port_number=portnum;
}
int Session::streamNumber() const
{
return d_stream_number;
}
void Session::setStreamNumber(int streamnum)
{
d_stream_number=streamnum;
}
int Session::startPosition() const
{
return d_start_position;
}
void Session::setStartPosition(int pos)
{
d_start_position=pos;
}
int Session::endPosition() const
{
return d_end_position;
}
void Session::setEndPosition(int pos)
{
d_end_position=pos;
}
int Session::speed() const
{
return d_speed;
}
void Session::setSpeed(int speed)
{
d_speed=speed;
}
uint16_t Session::meterPort() const
{
return d_meter_port;
}
void Session::setMeterPort(uint16_t port)
{
d_meter_port=port;
}
bool Session::metersEnabled()
{
return d_meters_enabled;
}
void Session::setMetersEnabled(bool state)
{
d_meters_enabled=state;
}