22 #include <QNetworkReply> 42 m_deviceAPI(deviceAPI),
49 m_sampleSourceFifo.resize(96000 * 4);
50 m_deviceAPI->setNbSinkStreams(1);
51 m_networkManager =
new QNetworkAccessManager();
52 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(networkManagerFinished(QNetworkReply*)));
74 qDebug() <<
"LocalOutput::start";
80 qDebug() <<
"LocalOutput::stop";
167 qDebug() <<
"LocalOutput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
189 qDebug() <<
"LocalOutput::handleMessage:" << message.
getIdentifier();
202 QMutexLocker mutexLocker(&
m_mutex);
203 std::ostringstream os;
204 QString remoteAddress;
205 QList<QString> reverseAPIKeys;
219 qDebug() <<
"LocalOutput::applySettings: " 225 QString& errorMessage)
235 QString& errorMessage)
253 QString& errorMessage)
264 const QStringList& deviceSettingsKeys,
266 QString& errorMessage)
271 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
274 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
277 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
280 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
313 QString& errorMessage)
330 (void) deviceSettingsKeys;
340 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
345 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
347 QBuffer *buffer=
new QBuffer();
348 buffer->open((QBuffer::ReadWrite));
349 buffer->write(swgDeviceSettings->
asJson().toUtf8());
355 delete swgDeviceSettings;
365 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
370 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
372 QBuffer *buffer=
new QBuffer();
373 buffer->open((QBuffer::ReadWrite));
374 buffer->write(swgDeviceSettings->
asJson().toUtf8());
383 delete swgDeviceSettings;
388 QNetworkReply::NetworkError replyError = reply->error();
392 qWarning() <<
"LocalOutput::networkManagerFinished:" 393 <<
" error(" << (int) replyError
394 <<
"): " << replyError
395 <<
": " << reply->errorString();
399 QString answer = reply->readAll();
401 qDebug(
"LocalOutput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
QString * getReverseApiAddress()
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
virtual void setMessageQueueToGUI(MessageQueue *queue)
void setSampleRate(qint32 sample_rate)
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
void applySettings(const LocalOutputSettings &settings, bool force=false)
static MsgStartStop * create(bool startStop)
QByteArray serialize() const
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
virtual QString asJson() override
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
void setLocalOutputReport(SWGLocalOutputReport *local_output_report)
QNetworkRequest m_networkRequest
qint32 getReverseApiDeviceIndex()
virtual void setCenterFrequency(qint64 centerFrequency)
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiAddress(QString *reverse_api_address)
void setOriginatorIndex(qint32 originator_index)
QString m_deviceDescription
void setCenterFrequency(qint32 center_frequency)
MessageQueue m_inputMessageQueue
Input queue to the sink.
bool getStartStop() const
void webapiReverseSendStartStop(bool start)
SWGLocalOutputSettings * getLocalOutputSettings()
int getDeviceSetIndex() const
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void setLocalOutputSettings(SWGLocalOutputSettings *local_output_settings)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalOutputSettings &settings)
virtual bool deserialize(const QByteArray &data)
LocalOutputSettings m_settings
qint32 getReverseApiPort()
uint16_t m_reverseAPIDeviceIndex
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
static bool match(const Message *message)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
bool deserialize(const QByteArray &data)
virtual const QString & getDeviceDescription() const
virtual int getSampleRate() const
Sample rate exposed by the sink.
void getDeviceEngineStateStr(QString &state)
QNetworkAccessManager * m_networkManager
uint16_t m_reverseAPIPort
void setUseReverseApi(qint32 use_reverse_api)
virtual const char * getIdentifier() const
void networkManagerFinished(QNetworkReply *reply)
qint32 getUseReverseApi()
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
MessageQueue * getMessageQueueToGUI()
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
void setDirection(qint32 direction)
virtual QByteArray serialize() const
QString m_reverseAPIAddress
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LocalOutputSettings &settings, bool force)
SWGLocalOutputReport * getLocalOutputReport()
virtual bool handleMessage(const Message &message)
void setDeviceHwType(QString *device_hw_type)