mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-14 14:41:13 +02:00
2023-09-20 Fred Gleason <fredg@paravelsystems.com>
* Removed definition of CAED_TCP_PORT from 'lib/rd.h'. * Added definition of RD_CAED_PORT to 'lib/rd.h'. * Added definition of RD_CAED_TIMEOUT_INTERVAL to 'lib/rd.h'. * Fixed a bug in caed(8) that broke metering CAE commands. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -24424,3 +24424,8 @@
|
||||
2023-09-15 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'Set Timeout' ['TO'] CAE command.
|
||||
* Added a 'Touch' ['TH'] CAE command.
|
||||
2023-09-20 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Removed definition of CAED_TCP_PORT from 'lib/rd.h'.
|
||||
* Added definition of RD_CAED_PORT to 'lib/rd.h'.
|
||||
* Added definition of RD_CAED_TIMEOUT_INTERVAL to 'lib/rd.h'.
|
||||
* Fixed a bug in caed(8) that broke metering CAE commands.
|
||||
|
48
cae/cae.cpp
48
cae/cae.cpp
@@ -145,8 +145,8 @@ MainObject::MainObject(QObject *parent)
|
||||
// Server Front End
|
||||
//
|
||||
cae_server=new CaeServer(this);
|
||||
if(!cae_server->bind(QHostAddress::Any,CAED_TCP_PORT)) {
|
||||
rda->syslog(LOG_ERR,"caed: failed to bind port %d",CAED_TCP_PORT);
|
||||
if(!cae_server->bind(QHostAddress::Any,RD_CAED_PORT)) {
|
||||
rda->syslog(LOG_ERR,"caed: failed to bind port %d",RD_CAED_PORT);
|
||||
exit(1);
|
||||
}
|
||||
// connect(cae_server,SIGNAL(connectionDropped(int)),
|
||||
@@ -1242,10 +1242,11 @@ void MainObject::openRtpCaptureChannelData(int id,unsigned card,unsigned port,
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
void MainObject::meterEnableData(const QHostAddress &addr,uint16_t udp_port,
|
||||
const QList<unsigned> &cards)
|
||||
{
|
||||
/*
|
||||
QString cmd=QString::asprintf("ME %u",0xFFFF&udp_port);
|
||||
for(int i=0;i<cards.size();i++) {
|
||||
cmd+=QString::asprintf(" %u",cards.at(i));
|
||||
@@ -1260,9 +1261,10 @@ void MainObject::meterEnableData(const QHostAddress &addr,uint16_t udp_port,
|
||||
}
|
||||
|
||||
// cae_server->sendCommand(id,cmd+" +!");
|
||||
*/
|
||||
SendMeterOutputStatusUpdate();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void MainObject::connectionDroppedData(int id)
|
||||
{
|
||||
@@ -1866,13 +1868,12 @@ void MainObject::SendMeterLevelUpdate(const QString &type,int cardnum,
|
||||
{
|
||||
for(QMap<SessionId,Session *>::const_iterator it=cae_play_sessions.begin();
|
||||
it!=cae_play_sessions.end();it++) {
|
||||
if((it.value()->cardNumber()==cardnum)&&(it.value()->meterPort()>0)&&
|
||||
(it.value()->metersEnabled())) {
|
||||
if((it.value()->cardNumber()==cardnum)&&
|
||||
(cae_server->meterPort(it.key())>0)) {
|
||||
SendMeterUpdate(QString::asprintf("ML %s %d %d %d %d",
|
||||
type.toUtf8().constData(),
|
||||
cardnum,portnum,levels[0],levels[1]),
|
||||
it.value());
|
||||
|
||||
it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1883,11 +1884,11 @@ void MainObject::SendStreamMeterLevelUpdate(int cardnum,int streamnum,
|
||||
{
|
||||
for(QMap<SessionId,Session *>::const_iterator it=cae_play_sessions.begin();
|
||||
it!=cae_play_sessions.end();it++) {
|
||||
if((it.value()->cardNumber()==cardnum)&&(it.value()->meterPort()>0)&&
|
||||
(it.value()->metersEnabled())) {
|
||||
if((it.value()->cardNumber()==cardnum)&&
|
||||
(cae_server->meterPort(it.key())>0)) {
|
||||
SendMeterUpdate(QString::asprintf("MO %d %d %d %d",
|
||||
cardnum,streamnum,levels[0],levels[1]),
|
||||
it.value());
|
||||
it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1898,10 +1899,10 @@ void MainObject::SendMeterPositionUpdate(int cardnum,unsigned pos[])
|
||||
for(unsigned k=0;k<RD_MAX_STREAMS;k++) {
|
||||
for(QMap<SessionId,Session *>::const_iterator it=cae_play_sessions.begin();
|
||||
it!=cae_play_sessions.end();it++) {
|
||||
if((it.value()->cardNumber()==cardnum)&&(it.value()->meterPort()>0)&&
|
||||
(it.value()->metersEnabled())) {
|
||||
if((it.value()->cardNumber()==cardnum)&&
|
||||
(cae_server->meterPort(it.key())>0)) {
|
||||
SendMeterUpdate(QString::asprintf("MP %d %d %d",cardnum,k,pos[k]),
|
||||
it.value());
|
||||
it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1917,10 +1918,10 @@ void MainObject::SendMeterOutputStatusUpdate()
|
||||
for(QMap<SessionId,Session *>::const_iterator it=cae_play_sessions.begin();
|
||||
it!=cae_play_sessions.end();it++) {
|
||||
if((it.value()->cardNumber()==i)&&
|
||||
(it.value()->meterPort()>0)&&(it.value()->metersEnabled())) {
|
||||
(cae_server->meterPort(it.key())>0)) {
|
||||
SendMeterUpdate(QString::asprintf("MS %d %d %d %d",i,j,k,
|
||||
output_status_flag[i][j][k]),
|
||||
it.value());
|
||||
it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1934,20 +1935,23 @@ void MainObject::SendMeterOutputStatusUpdate(int card,int port,int stream)
|
||||
{
|
||||
for(QMap<SessionId,Session *>::const_iterator it=cae_play_sessions.begin();
|
||||
it!=cae_play_sessions.end();it++) {
|
||||
if((it.value()->streamNumber()==stream)&&(it.value()->meterPort()>0)&&
|
||||
(it.value()->metersEnabled())) {
|
||||
if((it.value()->streamNumber()==stream)&&
|
||||
(cae_server->meterPort(it.key())>0)) {
|
||||
SendMeterUpdate(QString::asprintf("MS %d %d %d %d",card,port,stream,
|
||||
output_status_flag[card][port][stream]),
|
||||
it.value());
|
||||
it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::SendMeterUpdate(const QString &msg,Session *sess)
|
||||
void MainObject::SendMeterUpdate(const QString &msg,const SessionId &sid)
|
||||
{
|
||||
meter_socket->writeDatagram(msg.toUtf8(),sess->sessionId().address(),
|
||||
sess->meterPort());
|
||||
printf("SendMeterUpdate(\"%s\",%s:%u)\n",msg.toUtf8().constData(),
|
||||
sid.address().toString().toUtf8().constData(),
|
||||
0xffff&cae_server->meterPort(sid));
|
||||
meter_socket->
|
||||
writeDatagram(msg.toUtf8(),sid.address(),cae_server->meterPort(sid));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -123,8 +123,8 @@ class MainObject : public QObject
|
||||
void openRtpCaptureChannelData(int id,unsigned card,unsigned port,
|
||||
uint16_t udp_port,unsigned samprate,
|
||||
unsigned chans);
|
||||
// void meterEnableData(const QHostAddress &addr,uint16_t udp_port,
|
||||
// const QList<unsigned> &cards);
|
||||
void meterEnableData(const QHostAddress &addr,uint16_t udp_port,
|
||||
const QList<unsigned> &cards);
|
||||
void statePlayUpdate(int card,int stream,int state);
|
||||
void stateRecordUpdate(int card,int stream,int state);
|
||||
void updateMeters();
|
||||
@@ -149,8 +149,7 @@ class MainObject : public QObject
|
||||
void SendMeterPositionUpdate(int cardnum,unsigned pos[]);
|
||||
void SendMeterOutputStatusUpdate();
|
||||
void SendMeterOutputStatusUpdate(int card,int port,int stream);
|
||||
// void SendMeterUpdate(const QString &msg,int conn_id);
|
||||
void SendMeterUpdate(const QString &msg,Session *sess);
|
||||
void SendMeterUpdate(const QString &msg,const SessionId &sid);
|
||||
Driver *GetDriver(unsigned card) const;
|
||||
void MakeDriver(unsigned *next_card,RDStation::AudioDriver type);
|
||||
QList<Driver *> d_drivers;
|
||||
|
@@ -42,6 +42,17 @@ CaeServer::CaeServer(QObject *parent)
|
||||
}
|
||||
|
||||
|
||||
uint16_t CaeServer::meterPort(const SessionId &sid) const
|
||||
{
|
||||
Connection *conn=NULL;
|
||||
|
||||
if((conn=cae_connections.value(sid.normalized()))==NULL) {
|
||||
return 0;
|
||||
}
|
||||
return conn->meterPort();
|
||||
}
|
||||
|
||||
|
||||
bool CaeServer::bind(const QHostAddress &addr,uint16_t port)
|
||||
{
|
||||
return d_server_socket->bind(port);
|
||||
@@ -145,6 +156,8 @@ bool CaeServer::ProcessCommand(const QHostAddress &src_addr,uint16_t src_port,
|
||||
if((f0.at(0)=="TO")&&(f0.size()==2)) { // Set Timeout
|
||||
interval=f0.at(1).toInt(&ok);
|
||||
if(ok&&(interval>=0)) {
|
||||
Connection *conn=GetConnection(origin);
|
||||
/*
|
||||
Connection *conn=cae_connections.value(origin);
|
||||
if(conn==NULL) {
|
||||
conn=new Connection(origin,this);
|
||||
@@ -152,6 +165,7 @@ bool CaeServer::ProcessCommand(const QHostAddress &src_addr,uint16_t src_port,
|
||||
this,SLOT(connectionExpiredData(const SessionId &)));
|
||||
cae_connections[origin]=conn;
|
||||
}
|
||||
*/
|
||||
conn->setTimeout(interval);
|
||||
was_processed=true;
|
||||
}
|
||||
@@ -414,6 +428,8 @@ bool CaeServer::ProcessCommand(const QHostAddress &src_addr,uint16_t src_port,
|
||||
for(int i=2;i<f0.size();i++) {
|
||||
cards.push_back(f0.at(i).toUInt());
|
||||
}
|
||||
Connection *conn=GetConnection(origin);
|
||||
conn->setMeterPort(udp_port);
|
||||
emit meterEnableReq(src_addr,udp_port,cards);
|
||||
}
|
||||
}
|
||||
@@ -694,3 +710,17 @@ bool CaeServer::ProcessCommand(const QHostAddress &src_addr,uint16_t src_port,
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Connection *CaeServer::GetConnection(const SessionId &sid)
|
||||
{
|
||||
Connection *conn=cae_connections.value(sid);
|
||||
if(conn==NULL) {
|
||||
conn=new Connection(sid,this);
|
||||
printf("Added connection %s\n",conn->sessionId().dump().toUtf8().constData());
|
||||
connect(conn,SIGNAL(connectionExpired(const SessionId &)),
|
||||
this,SLOT(connectionExpiredData(const SessionId &)));
|
||||
cae_connections[sid]=conn;
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
@@ -39,8 +39,9 @@ class CaeServer : public QObject
|
||||
Q_OBJECT;
|
||||
public:
|
||||
CaeServer(QObject *parent=0);
|
||||
bool metersEnabled(int id,unsigned card) const;
|
||||
void setMetersEnabled(int id,unsigned card,bool state);
|
||||
// bool metersEnabled(int id,unsigned card) const;
|
||||
// void setMetersEnabled(int id,unsigned card,bool state);
|
||||
uint16_t meterPort(const SessionId &sid) const;
|
||||
bool bind(const QHostAddress &addr,uint16_t port);
|
||||
void sendCommand(const QString &cmd);
|
||||
void sendCommand(const SessionId &dest,const QString &cmd);
|
||||
@@ -115,6 +116,7 @@ class CaeServer : public QObject
|
||||
private:
|
||||
bool ProcessCommand(const QHostAddress &src_addr,uint16_t src_port,
|
||||
const QString &cmd);
|
||||
Connection *GetConnection(const SessionId &sid);
|
||||
QMap<SessionId,Connection *> cae_connections;
|
||||
QSignalMapper *cae_ready_read_mapper;
|
||||
QUdpSocket *d_server_socket;
|
||||
|
@@ -18,6 +18,8 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <rdapplication.h>
|
||||
|
||||
#include "connection.h"
|
||||
|
||||
Connection::Connection(const SessionId &sid,QObject *parent)
|
||||
@@ -25,6 +27,7 @@ Connection::Connection(const SessionId &sid,QObject *parent)
|
||||
{
|
||||
d_session_id=sid;
|
||||
d_interval=0;
|
||||
d_meter_port=0;
|
||||
|
||||
d_timer=new QTimer(this);
|
||||
d_timer->setSingleShot(true);
|
||||
@@ -44,6 +47,20 @@ SessionId Connection::sessionId() const
|
||||
}
|
||||
|
||||
|
||||
uint16_t Connection::meterPort() const
|
||||
{
|
||||
return d_meter_port;
|
||||
}
|
||||
|
||||
|
||||
void Connection::setMeterPort(uint16_t udp_port)
|
||||
{
|
||||
printf("setMeterPort(%s::setMeterPort(%u)\n",
|
||||
dump().toUtf8().constData(),0xffff&udp_port);
|
||||
d_meter_port=udp_port;
|
||||
}
|
||||
|
||||
|
||||
QString Connection::dump() const
|
||||
{
|
||||
return d_session_id.dump();
|
||||
@@ -79,5 +96,7 @@ void Connection::touch()
|
||||
|
||||
void Connection::timerData()
|
||||
{
|
||||
rda->syslog(LOG_WARNING,"connection %s timed out",
|
||||
d_session_id.dump().toUtf8().constData());
|
||||
emit connectionExpired(d_session_id);
|
||||
}
|
||||
|
@@ -36,6 +36,8 @@ class Connection : public QObject
|
||||
Connection(const SessionId &sid,QObject *parent);
|
||||
~Connection();
|
||||
SessionId sessionId() const;
|
||||
uint16_t meterPort() const;
|
||||
void setMeterPort(uint16_t udp_port);
|
||||
QString dump() const;
|
||||
bool operator!=(const Connection &other) const;
|
||||
bool operator<(const Connection &other) const;
|
||||
@@ -52,6 +54,7 @@ class Connection : public QObject
|
||||
|
||||
private:
|
||||
SessionId d_session_id;
|
||||
uint16_t d_meter_port;
|
||||
QTimer *d_timer;
|
||||
int d_interval;
|
||||
};
|
||||
|
@@ -71,6 +71,12 @@ bool SessionId::belongsTo(const SessionId &other) const
|
||||
}
|
||||
|
||||
|
||||
SessionId SessionId::normalized() const
|
||||
{
|
||||
return SessionId(d_address,d_port);
|
||||
}
|
||||
|
||||
|
||||
bool SessionId::operator!=(const SessionId &other) const
|
||||
{
|
||||
return (other.d_address!=d_address)||(other.d_port!=d_port)||
|
||||
@@ -103,8 +109,8 @@ Session::Session(const QHostAddress &addr,uint16_t port,int serial)
|
||||
d_end_position=-1;
|
||||
d_speed=100000;
|
||||
|
||||
d_meter_port=0;
|
||||
d_meters_enabled=false;
|
||||
// d_meter_port=0;
|
||||
// d_meters_enabled=false;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +125,8 @@ Session::Session(const SessionId &sid)
|
||||
d_end_position=-1;
|
||||
d_speed=100000;
|
||||
|
||||
d_meter_port=0;
|
||||
d_meters_enabled=false;
|
||||
// d_meter_port=0;
|
||||
// d_meters_enabled=false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -219,7 +225,7 @@ void Session::setSpeed(int speed)
|
||||
d_speed=speed;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
uint16_t Session::meterPort() const
|
||||
{
|
||||
return d_meter_port;
|
||||
@@ -242,3 +248,4 @@ void Session::setMetersEnabled(bool state)
|
||||
{
|
||||
d_meters_enabled=state;
|
||||
}
|
||||
*/
|
||||
|
@@ -36,6 +36,7 @@ class SessionId
|
||||
void setSerialNumber(int serial);
|
||||
QString dump() const;
|
||||
bool belongsTo(const SessionId &other) const;
|
||||
SessionId normalized() const;
|
||||
bool operator!=(const SessionId &other) const;
|
||||
bool operator<(const SessionId &other) const;
|
||||
|
||||
@@ -60,16 +61,16 @@ class Session
|
||||
void setPortNumber(int portnum);
|
||||
int streamNumber() const;
|
||||
void setStreamNumber(int streamnum);
|
||||
uint16_t meterPort() const;
|
||||
void setMeterPort(uint16_t port);
|
||||
// uint16_t meterPort() const;
|
||||
// void setMeterPort(uint16_t port);
|
||||
int startPosition() const;
|
||||
void setStartPosition(int pos);
|
||||
int endPosition() const;
|
||||
void setEndPosition(int pos);
|
||||
int speed() const;
|
||||
void setSpeed(int speed);
|
||||
bool metersEnabled();
|
||||
void setMetersEnabled(bool state);
|
||||
// bool metersEnabled();
|
||||
// void setMetersEnabled(bool state);
|
||||
|
||||
private:
|
||||
SessionId d_session_id;
|
||||
@@ -79,8 +80,8 @@ class Session
|
||||
int d_start_position;
|
||||
int d_end_position;
|
||||
int d_speed;
|
||||
uint16_t d_meter_port;
|
||||
bool d_meters_enabled;
|
||||
// uint16_t d_meter_port;
|
||||
// bool d_meters_enabled;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user