diff --git a/ChangeLog b/ChangeLog index 65696524..1c580e61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23596,3 +23596,6 @@ 2022-10-31 Fred Gleason * Refactored rdcatch(1) to use the notification mechanism instead of the 'StopDeck' catch command. +2022-11-01 Fred Gleason + * Refactored rdcatch(1) to use the notification mechanism instead of + the 'Input Monitor State' catch command. diff --git a/docs/apis/catchd.xml b/docs/apis/catchd.xml index e9316bf3..f64f2eef 100644 --- a/docs/apis/catchd.xml +++ b/docs/apis/catchd.xml @@ -131,36 +131,6 @@ - - Input Monitor State - - Turn the input monitor on or off. - - - MN deck-num - state! - - - - deck-num - - - The number of the deck. - - - - - state - - - 1 = Enabled, - 0 = Disabled. - - - - - - Set Exit Code diff --git a/docs/apis/notification.xml b/docs/apis/notification.xml index 478dc827..ab8acda0 100644 --- a/docs/apis/notification.xml +++ b/docs/apis/notification.xml @@ -643,7 +643,7 @@ Operation 2 - Integer. 1 [RDCatchEvent::StopDeckOp] + Integer. 4 [RDCatchEvent::StopDeckOp] Target Hostname @@ -663,6 +663,117 @@ + + Set Input Monitor + + Emitted by rdcatch1 to + turn a deck input monitor on or off. + + + RDCatch Set Input Monitor Fields + + + + + + + Field + Offset + Value + + + Keyword + 0 + CATCH + + + Originating Hostname + 1 + String, from STATIONS.NAME + + + Operation + 2 + Integer. 5 [RDCatchEvent::SetInputMonitorOp] + + + Target Hostname + 3 + String, from STATIONS.NAME + + + Deck Channel + 4 + + Integer. Record decks have values in the range 1-127, + while play decks have values in the range 128-254. + + + + State + 5 + + Boolean. 0=False, 1=True. + + + + +
+
+ + + Set Input Monitor Response + + Emitted by rdcatchd8 to + signal change of a deck input monitor. + + + RDCatch Set Input Monitor Fields + + + + + + + Field + Offset + Value + + + Keyword + 0 + CATCH + + + Originating Hostname + 1 + String, from STATIONS.NAME + + + Operation + 2 + Integer. 6 [RDCatchEvent::SetInputMonitorResponseOp] + + + Deck Channel + 3 + + Integer. Record decks have values in the range 1-127, + while play decks have values in the range 128-254. + + + + State + 4 + + Boolean. 0=False, 1=True. + + + + +
+
+ diff --git a/lib/rdcatch_connect.cpp b/lib/rdcatch_connect.cpp index fa1d0fbe..9daeb961 100644 --- a/lib/rdcatch_connect.cpp +++ b/lib/rdcatch_connect.cpp @@ -89,7 +89,7 @@ void RDCatchConnect::reloadDropboxes() SendCommand("RX!"); } - +/* void RDCatchConnect::monitor(int deck,bool state) { SendCommand(QString::asprintf("MN %d %d!",deck,state)); @@ -105,7 +105,7 @@ void RDCatchConnect::toggleMonitor(int deck) SendCommand(QString::asprintf("MN %d 1!",deck)); } } - +*/ void RDCatchConnect::setExitCode(int id,RDRecording::ExitCode code, const QString &msg) @@ -277,6 +277,7 @@ void RDCatchConnect::DispatchCommand() cc_heartbeat_timer->start(CC_HEARTBEAT_INTERVAL); } */ + /* if(!strcmp(args[0],"MN")) { // Monitor State if(sscanf(args[1],"%d",&deck)!=1) { return; @@ -290,6 +291,7 @@ void RDCatchConnect::DispatchCommand() emit monitorChanged(cc_serial,deck,false); } } + */ } diff --git a/lib/rdcatch_connect.h b/lib/rdcatch_connect.h index 555455dc..dae288be 100644 --- a/lib/rdcatch_connect.h +++ b/lib/rdcatch_connect.h @@ -49,15 +49,15 @@ class RDCatchConnect : public QObject void reloadDropboxes(); public slots: - void monitor(int deck,bool state); - void toggleMonitor(int deck); + // void monitor(int deck,bool state); + // void toggleMonitor(int deck); void setExitCode(int id,RDRecording::ExitCode code,const QString &msg); signals: void connected(int serial,bool state); void statusChanged(int serial,unsigned channel,RDDeck::Status status, int id,const QString &cutname); - void monitorChanged(int serial,unsigned channel,bool state); + // void monitorChanged(int serial,unsigned channel,bool state); void meterLevel(int serial,int deck,int chan,int level); void eventUpdated(int id); void eventPurged(int id); diff --git a/lib/rdcatchevent.cpp b/lib/rdcatchevent.cpp index ddcc9503..e921b91f 100644 --- a/lib/rdcatchevent.cpp +++ b/lib/rdcatchevent.cpp @@ -145,9 +145,15 @@ void RDCatchEvent::setDeckStatus(RDDeck::Status status) } -bool RDCatchEvent::isValid() const +bool RDCatchEvent::inputMonitorActive() const { - return true; + return d_input_monitor_active; +} + + +void RDCatchEvent::setInputMonitorActive(bool state) +{ + d_input_monitor_active=state; } @@ -157,6 +163,11 @@ bool RDCatchEvent::read(const QString &str) RDCatchEvent::Operation op=RDCatchEvent::NullOp; QStringList f0=str.split(" "); + + unsigned chan=0; + unsigned num=0; + RDDeck::Status status=RDDeck::Offline; + int state=0; bool ok=false; clear(); @@ -168,19 +179,24 @@ bool RDCatchEvent::read(const QString &str) return false; } op=(RDCatchEvent::Operation)f0.at(2).toUInt(&ok); + if(!ok) { + return false; + } // // Operation-specific Fields // - if(ok&&(op==RDCatchEvent::DeckEventProcessedOp)) { + rda->syslog(LOG_NOTICE,"HERE0 op: %u",op); + switch(op) { + case RDCatchEvent::DeckEventProcessedOp: if(f0.size()!=5) { return false; } - unsigned chan=f0.at(3).toUInt(&ok); + chan=f0.at(3).toUInt(&ok); if(!ok) { return false; } - unsigned num=f0.at(4).toUInt(&ok); + num=f0.at(4).toUInt(&ok); if(ok) { d_operation=op; d_host_name=f0.at(1); @@ -188,24 +204,24 @@ bool RDCatchEvent::read(const QString &str) d_event_number=num; return true; } - } + break; - if(ok&&(op==RDCatchEvent::DeckStatusQueryOp)) { + case RDCatchEvent::DeckStatusQueryOp: if(f0.size()!=3) { return false; } d_operation=op; d_host_name=f0.at(1); return true; - } + break; - if(ok&&(op==RDCatchEvent::DeckStatusResponseOp)) { + case RDCatchEvent::DeckStatusResponseOp: if(f0.size()!=8) { return false; } - int chan=f0.at(3).toUInt(&ok); + chan=f0.at(3).toUInt(&ok); if(ok&&(chan<255)) { - RDDeck::Status status=(RDDeck::Status)f0.at(4).toUInt(&ok); + status=(RDDeck::Status)f0.at(4).toUInt(&ok); if(ok&&(statusstation()->name(); + d_target_host_name=""; d_event_id=0; d_cart_number=0; d_cut_number=0; d_deck_channel=0; d_event_number=0; + d_input_monitor_active=false; d_deck_status=RDDeck::Offline; } diff --git a/lib/rdcatchevent.h b/lib/rdcatchevent.h index e804d844..226630da 100644 --- a/lib/rdcatchevent.h +++ b/lib/rdcatchevent.h @@ -31,7 +31,8 @@ class RDCatchEvent public: enum Operation {NullOp=0,DeckEventProcessedOp=1, DeckStatusQueryOp=2,DeckStatusResponseOp=3, - StopDeckOp=5,LastOp=6}; + StopDeckOp=4,SetInputMonitorOp=5,SetInputMonitorResponseOp=6, + LastOp=7}; RDCatchEvent(RDDeck::Status status); RDCatchEvent(); Operation operation() const; @@ -52,7 +53,8 @@ class RDCatchEvent void setEventNumber(int num); RDDeck::Status deckStatus() const; void setDeckStatus(RDDeck::Status status); - bool isValid() const; + bool inputMonitorActive() const; + void setInputMonitorActive(bool state); bool read(const QString &str); QString write() const; QString dump() const; @@ -67,6 +69,7 @@ class RDCatchEvent int d_cut_number; unsigned d_deck_channel; int d_event_number; + bool d_input_monitor_active; RDDeck::Status d_deck_status; }; diff --git a/rdcatch/deckmon.cpp b/rdcatch/deckmon.cpp index 4aec1095..71f1baf6 100644 --- a/rdcatch/deckmon.cpp +++ b/rdcatch/deckmon.cpp @@ -29,6 +29,7 @@ DeckMon::DeckMon(QString station,unsigned channel,QWidget *parent) { mon_station=station; mon_channel=channel; + mon_monitor_state=false; setFrameStyle(Box|Raised); setLineWidth(1); @@ -139,17 +140,6 @@ void DeckMon::enableMonitorButton(bool state) } -void DeckMon::setMonitor(bool state) -{ - if(state) { - mon_monitor_button->setPalette(*mon_monitor_palette); - } - else { - mon_monitor_button->setPalette(palette()); - } -} - - void DeckMon::setStatus(RDDeck::Status status,int id,const QString &cutname) { if(id==0) { @@ -231,13 +221,38 @@ void DeckMon::setRightMeter(int level) void DeckMon::processCatchEvent(RDCatchEvent *evt) { if((evt->hostName()==mon_station)&&(evt->deckChannel()==mon_channel)) { - if(evt->operation()==RDCatchEvent::DeckEventProcessedOp) { + switch(evt->operation()) { + case RDCatchEvent::DeckEventProcessedOp: mon_event_light->trigger(evt->eventNumber()); - } + break; - if(evt->operation()==RDCatchEvent::DeckStatusResponseOp) { + case RDCatchEvent::DeckStatusResponseOp: setStatus(evt->deckStatus(),evt->eventId(), RDCut::cutName(evt->cartNumber(),evt->cutNumber())); + break; + + case RDCatchEvent::SetInputMonitorResponseOp: + if((evt->hostName()==mon_station)&& + (evt->deckChannel()==mon_channel)&& + (evt->inputMonitorActive()!=mon_monitor_state)) { + mon_monitor_state=evt->inputMonitorActive(); + if(mon_monitor_state) { + mon_monitor_button->setPalette(mon_red_palette); + mon_monitor_button->setStyleSheet(mon_red_stylesheet); + } + else { + mon_monitor_button->setPalette(palette()); + mon_monitor_button->setStyleSheet(""); + } + } + break; + + case RDCatchEvent::DeckStatusQueryOp: + case RDCatchEvent::StopDeckOp: + case RDCatchEvent::SetInputMonitorOp: + case RDCatchEvent::NullOp: + case RDCatchEvent::LastOp: + break; } } } @@ -245,7 +260,15 @@ void DeckMon::processCatchEvent(RDCatchEvent *evt) void DeckMon::monitorButtonData() { - emit monitorClicked(); + RDCatchEvent *evt=new RDCatchEvent(); + + evt->setOperation(RDCatchEvent::SetInputMonitorOp); + evt->setTargetHostName(mon_station); + evt->setDeckChannel(mon_channel); + evt->setInputMonitorActive(!mon_monitor_state); + rda->ripc()->sendCatchEvent(evt); + + delete evt; } diff --git a/rdcatch/deckmon.h b/rdcatch/deckmon.h index 1f96f941..98749766 100644 --- a/rdcatch/deckmon.h +++ b/rdcatch/deckmon.h @@ -2,7 +2,7 @@ // // Monitor a Rivendell Netcatcher Deck // -// (C) Copyright 2002-2019 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // 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 @@ -42,16 +42,11 @@ class DeckMon : public RDFrame void enableMonitorButton(bool state); public slots: - void setMonitor(bool state); void setStatus(RDDeck::Status status,int id,const QString &cutname); void setLeftMeter(int level); void setRightMeter(int level); void processCatchEvent(RDCatchEvent *evt); - signals: - void monitorClicked(); - // void abortClicked(); - protected: void resizeEvent(QResizeEvent *e); @@ -67,6 +62,7 @@ class DeckMon : public RDFrame QLabel *mon_status_label; QPushButton *mon_abort_button; QPushButton *mon_monitor_button; + bool mon_monitor_state; QPalette *mon_monitor_palette; RDPlayMeter *mon_left_meter; RDPlayMeter *mon_right_meter; @@ -80,5 +76,5 @@ class DeckMon : public RDFrame }; -#endif +#endif // DECKMON_H diff --git a/rdcatch/rdcatch.cpp b/rdcatch/rdcatch.cpp index 4a588947..ec351b50 100644 --- a/rdcatch/rdcatch.cpp +++ b/rdcatch/rdcatch.cpp @@ -181,10 +181,6 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent) catch_monitor_vbox->setSpacing(2); catch_monitor_area->setWidget(catch_monitor_vbox); - // QSignalMapper *mapper=new QSignalMapper(this); - // connect(mapper,SIGNAL(mapped(int)),this,SLOT(abortData(int))); - QSignalMapper *mon_mapper=new QSignalMapper(this); - connect(mon_mapper,SIGNAL(mapped(int)),this,SLOT(monitorData(int))); QString sql; RDSqlQuery *q1; sql=QString("select `NAME`,`IPV4_ADDRESS` from `STATIONS` where ")+ @@ -196,18 +192,12 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent) SIGNAL(statusChanged(int,unsigned,RDDeck::Status,int,const QString &)), this, SLOT(statusChangedData(int,unsigned,RDDeck::Status,int,const QString &))); - connect(catch_connect.back()->connector(), - SIGNAL(monitorChanged(int,unsigned,bool)), - this,SLOT(monitorChangedData(int,unsigned,bool))); connect(catch_connect.back()->connector(), SIGNAL(connected(int,bool)), this,SLOT(connectedData(int,bool))); connect(catch_connect.back()->connector(), SIGNAL(meterLevel(int,int,int,int)), this,SLOT(meterLevelData(int,int,int,int))); - connect(catch_connect.back()->connector(), - SIGNAL(heartbeatFailed(int)), - this,SLOT(heartbeatFailedData(int))); catch_connect.back()->connector()-> connectHost(q->value(1).toString(),RDCATCHD_TCP_PORT, rda->config()->password()); @@ -239,10 +229,6 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent) (rda->config()->stationName().toLower()== q->value(0).toString().toLower())); catch_monitor.back()->deckMon()->show(); - mon_mapper->setMapping(catch_monitor.back()->deckMon(), - catch_monitor.size()-1); - connect(catch_monitor.back()->deckMon(),SIGNAL(monitorClicked()), - mon_mapper,SLOT(map())); } delete q1; } @@ -761,16 +747,6 @@ void MainWidget::statusChangedData(int serial,unsigned chan, } -void MainWidget::monitorChangedData(int serial,unsigned chan,bool state) -{ - // printf("monitorChangedData(%d,%u,%d)\n",serial,chan,state); - int mon=GetMonitor(serial,chan); - if(mon>=0) { - catch_monitor[mon]->deckMon()->setMonitor(state); - } -} - - void MainWidget::catchEventReceivedData(RDCatchEvent *evt) { // printf("catchEventReceivedData()\n"); @@ -789,6 +765,8 @@ void MainWidget::catchEventReceivedData(RDCatchEvent *evt) case RDCatchEvent::DeckEventProcessedOp: case RDCatchEvent::DeckStatusQueryOp: case RDCatchEvent::StopDeckOp: + case RDCatchEvent::SetInputMonitorOp: + case RDCatchEvent::SetInputMonitorResponseOp: case RDCatchEvent::NullOp: case RDCatchEvent::LastOp: break; @@ -942,13 +920,6 @@ void MainWidget::meterLevelData(int serial,int deck,int l_r,int level) } -void MainWidget::monitorData(int id) -{ - catch_connect[catch_monitor[id]->serialNumber()]->connector()-> - toggleMonitor(catch_monitor[id]->channelNumber()); -} - - void MainWidget::selectionChangedData(const QItemSelection &before, const QItemSelection &after) { @@ -1000,17 +971,6 @@ void MainWidget::eventUpdatedData(int id) } -void MainWidget::heartbeatFailedData(int id) -{ - if(!catch_host_warnings) { - return; - } - QString msg=tr("Control connection timed out to host")+ - " `"+catch_connect[id]->stationName()+"'?"; - QMessageBox::warning(this,"RDCatch - "+tr("Connection Error"),msg); -} - - void MainWidget::quitMainWidget() { catch_db->removeDatabase(rda->config()->mysqlDbname()); diff --git a/rdcatch/rdcatch.h b/rdcatch/rdcatch.h index d773695d..1ea8a635 100644 --- a/rdcatch/rdcatch.h +++ b/rdcatch/rdcatch.h @@ -81,8 +81,6 @@ class MainWidget : public RDMainWindow void ripcUserData(); void statusChangedData(int,unsigned,RDDeck::Status,int, const QString &cutname); - void monitorChangedData(int serial,unsigned chan,bool state); - // void deckEventSentData(int serial,int chan,int number); void catchEventReceivedData(RDCatchEvent *evt); void scrollButtonData(); void reportsButtonData(); @@ -93,8 +91,6 @@ class MainWidget : public RDMainWindow void playedData(int); void playStoppedData(int); void meterLevelData(int,int,int,int); - // void abortData(int); - void monitorData(int); void selectionChangedData(const QItemSelection &before, const QItemSelection &after); void doubleClickedData(const QModelIndex &index); @@ -103,7 +99,6 @@ class MainWidget : public RDMainWindow void clockData(); void midnightData(); void eventUpdatedData(int id); - void heartbeatFailedData(int id); void quitMainWidget(); protected: diff --git a/rdcatchd/rdcatchd.cpp b/rdcatchd/rdcatchd.cpp index b414b568..eaefe0fa 100644 --- a/rdcatchd/rdcatchd.cpp +++ b/rdcatchd/rdcatchd.cpp @@ -455,6 +455,8 @@ void MainObject::catchEventReceivedData(RDCatchEvent *evt) rda->syslog(LOG_NOTICE,"catchEventReceivedData(): %s", evt->dump().toUtf8().constData()); + RDCatchEvent *resp=NULL; + switch(evt->operation()) { case RDCatchEvent::DeckStatusQueryOp: SendFullEventResponse(rda->station()->address()); @@ -489,8 +491,37 @@ void MainObject::catchEventReceivedData(RDCatchEvent *evt) } break; + case RDCatchEvent::SetInputMonitorOp: + if((evt->targetHostName()==rda->station()->name())&& + (evt->deckChannel()>0)&&(evt->deckChannel()<(MAX_DECKS+1))&& + (catch_monitor_port[evt->deckChannel()-1]>=0)) { + int chan=evt->deckChannel(); + if(evt->inputMonitorActive()) { + rda->cae()->setPassthroughVolume(catch_record_card[chan-1], + catch_record_stream[chan-1], + catch_monitor_port[chan-1],0); + catch_monitor_state[chan-1]=true; + } + else { + rda->cae()->setPassthroughVolume(catch_record_card[chan-1], + catch_record_stream[chan-1], + catch_monitor_port[chan-1], + RD_MUTE_DEPTH); + catch_monitor_state[chan-1]=false; + } + + resp=new RDCatchEvent(); + resp->setOperation(RDCatchEvent::SetInputMonitorResponseOp); + resp->setDeckChannel(chan); + resp->setInputMonitorActive(catch_monitor_state[chan-1]); + rda->ripc()->sendCatchEvent(resp); + delete resp; + } + break; + case RDCatchEvent::DeckEventProcessedOp: case RDCatchEvent::DeckStatusResponseOp: + case RDCatchEvent::SetInputMonitorResponseOp: case RDCatchEvent::NullOp: case RDCatchEvent::LastOp: break; @@ -1729,12 +1760,12 @@ void MainObject::SendFullEventResponse(const QHostAddress &addr) // // Decks // - evt->clear(); - evt->setOperation(RDCatchEvent::DeckStatusResponseOp); for(int i=0;iclear(); + evt->setOperation(RDCatchEvent::DeckStatusResponseOp); evt->setDeckChannel(i+1); evt->setDeckStatus(catch_record_deck_status[i]); evt->setEventId(catch_record_id[i]); @@ -1748,9 +1779,17 @@ void MainObject::SendFullEventResponse(const QHostAddress &addr) } rda->ripc()->sendCatchEvent(evt); + evt->clear(); + evt->setOperation(RDCatchEvent::SetInputMonitorResponseOp); + evt->setDeckChannel(i+1); + evt->setInputMonitorActive(catch_monitor_state[i]); + rda->ripc()->sendCatchEvent(evt); + // // Play Decks // + evt->clear(); + evt->setOperation(RDCatchEvent::DeckStatusResponseOp); evt->setDeckChannel(i+129); evt->setDeckStatus(catch_playout_deck_status[i]); evt->setEventId(catch_playout_id[i]); @@ -1823,7 +1862,7 @@ void MainObject::ParseCommand(int ch) void MainObject::DispatchCommand(ServerConnection *conn) { - int chan; + // int chan; int id; int event; int code; @@ -1877,32 +1916,6 @@ void MainObject::DispatchCommand(ServerConnection *conn) conn->setMeterEnabled(cmds.at(1).trimmed()!="0"); } - if((cmds.at(0)=="MN")&&(cmds.size()==3)) { // Monitor State - chan=cmds.at(1).toInt(&ok); - if(!ok) { - return; - } - if((chan>0)&&(chan<(MAX_DECKS+1))) { - if(catch_monitor_port[chan-1]>=0) { - if(cmds.at(2).toInt()!=0) { - rda->cae()->setPassthroughVolume(catch_record_card[chan-1], - catch_record_stream[chan-1], - catch_monitor_port[chan-1],0); - catch_monitor_state[chan-1]=true; - BroadcastCommand(QString::asprintf("MN %d 1!",chan)); - } - else { - rda->cae()->setPassthroughVolume(catch_record_card[chan-1], - catch_record_stream[chan-1], - catch_monitor_port[chan-1], - RD_MUTE_DEPTH); - catch_monitor_state[chan-1]=false; - BroadcastCommand(QString::asprintf("MN %d 0!",chan)); - } - } - } - } - if((cmds.at(0)=="SC")&&(cmds.size()>=4)) { // Set Exit Code id=cmds.at(1).toInt(&ok); if(!ok) {