From 4020f66315129d9b8d4f4439259395a82b44882c Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 9 Mar 2020 21:38:30 +0100 Subject: [PATCH] REST API device and channel actions: FileSource: added seek millis --- plugins/channeltx/filesource/filesource.cpp | 15 +++++++++++++++ plugins/channeltx/filesource/filesourcegui.cpp | 10 ++++++++++ .../sdrangel/api/swagger/include/FileSource.yaml | 3 +++ 3 files changed, 28 insertions(+) diff --git a/plugins/channeltx/filesource/filesource.cpp b/plugins/channeltx/filesource/filesource.cpp index 693e724a2..00c3164a0 100644 --- a/plugins/channeltx/filesource/filesource.cpp +++ b/plugins/channeltx/filesource/filesource.cpp @@ -400,6 +400,21 @@ int FileSource::webapiActionsPost( } } + if (channelActionsKeys.contains("seekMillis")) + { + int seekMillis = swgFileSourceActions->getSeekMillis(); + seekMillis = seekMillis < 0 ? 0 : seekMillis > 1000 ? 1000 : seekMillis; + FileSourceBaseband::MsgConfigureFileSourceSeek *msg + = FileSourceBaseband::MsgConfigureFileSourceSeek::create(seekMillis); + m_basebandSource->getInputMessageQueue()->push(msg); + + if (getMessageQueueToGUI()) + { + MsgConfigureFileSourceSeek *msgToGUI = MsgConfigureFileSourceSeek::create(seekMillis); + getMessageQueueToGUI()->push(msgToGUI); + } + } + return 202; } else diff --git a/plugins/channeltx/filesource/filesourcegui.cpp b/plugins/channeltx/filesource/filesourcegui.cpp index 8f866d0fc..40809c71a 100644 --- a/plugins/channeltx/filesource/filesourcegui.cpp +++ b/plugins/channeltx/filesource/filesourcegui.cpp @@ -163,6 +163,16 @@ bool FileSourceGUI::handleMessage(const Message& message) return true; } + else if (FileSource::MsgConfigureFileSourceSeek::match(message)) // API action "seekms" feedback + { + const FileSource::MsgConfigureFileSourceSeek& notif = (FileSource::MsgConfigureFileSourceSeek&) message; + int seekMillis = notif.getMillis(); + ui->navTime->blockSignals(true); + ui->navTime->setValue(seekMillis); + ui->navTime->blockSignals(false); + + return true; + } else { return false; diff --git a/swagger/sdrangel/api/swagger/include/FileSource.yaml b/swagger/sdrangel/api/swagger/include/FileSource.yaml index ea78881de..7bde851de 100644 --- a/swagger/sdrangel/api/swagger/include/FileSource.yaml +++ b/swagger/sdrangel/api/swagger/include/FileSource.yaml @@ -69,3 +69,6 @@ FileSourceActions: Play or Pause stream * 0 - Pause * 1 - Play + seekMillis: + description: Move play cursor to this thousands of total time from the start + type: integer