diff options
author | Scott Murray <scott.murray@konsulko.com> | 2017-05-22 18:05:21 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2017-05-23 18:53:26 -0400 |
commit | 9aebdfa77d57426fdaaab123d7c91c32a20e87be (patch) | |
tree | 68215fa3a0f70171bf0e05a2ce41ac2e924939ce /app/main.cpp | |
parent | 9f227dc72607106641269560608b0297358adfa8 (diff) |
Rework to add and use a binding for radio controldab_3.99.1dab/3.99.13.99.1
A radio binding has been added in the new binding directory, and the
application has been reworked to use it. The binding uses a modified
version of the rtl_fm code used in the qtmultimedia radio plugin that
was previously used, and some new code has been added to output to
PulseAudio using the asynchronous API to ensure compatibility with
stream corking. The rtl_fm code has been enhanced to add seeking
support, and the application has been tweaked to use it.
Bug-AGL: SPEC-581
Change-Id: I011e98374accc2cad2b36c93ac800948ee51f2aa
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'app/main.cpp')
-rw-r--r-- | app/main.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/app/main.cpp b/app/main.cpp index 9d2785e..e430099 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2016 Scott Murray <scott.murray@konsulko.com> + * Copyright (C) 2016, 2017 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,13 @@ */ #include <QtCore/QDebug> +#include <QtCore/QCommandLineParser> +#include <QtCore/QUrlQuery> #include <QtCore/QSettings> #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> #include <QtQml/QQmlContext> #include <QtQuickControls2/QQuickStyle> -#include <QtMultimedia/QRadioTunerControl> #include <stdlib.h> #include "PresetDataObject.h" @@ -45,6 +46,14 @@ int main(int argc, char *argv[]) QQuickStyle::setStyle("AGL"); + QCommandLineParser parser; + parser.addPositionalArgument("port", app.translate("main", "port for binding")); + parser.addPositionalArgument("secret", app.translate("main", "secret for binding")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + QStringList positionalArguments = parser.positionalArguments(); + // Read presets from configuration file // // If HOME is set, use $HOME/app-data/radio/presets.conf, else fall back @@ -70,13 +79,26 @@ int main(int argc, char *argv[]) pSettings->setArrayIndex(i); presetDataList.append(new PresetDataObject(pSettings->value("title").toString(), pSettings->value("frequency").toInt(), - QRadioTuner::FM)); + 1)); } pSettings->endArray(); QQmlApplicationEngine engine; QQmlContext *context = engine.rootContext(); context->setContextProperty("presetModel", QVariant::fromValue(presetDataList)); + if (positionalArguments.length() == 2) { + int port = positionalArguments.takeFirst().toInt(); + QString secret = positionalArguments.takeFirst(); + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), secret); + bindingAddress.setQuery(query); + context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); + } engine.load(QUrl(QStringLiteral("qrc:/Radio.qml"))); return app.exec(); |