From 849d751ba71d038b3428b6337bb2ba0e42b666d5 Mon Sep 17 00:00:00 2001 From: Adrian Scarlat Date: Wed, 4 Feb 2015 11:47:48 +0100 Subject: AudioManagerPoC: GENIVI Alliance Audio Manager proof-of-concept The Audio Manager Proof of Concept (AM PoC) is an application that uses the GENIVI AudioManager capabilities to demonstrate how audio sources are managed based on mixing rules that are defined in the configuration file for AM Control Plugin "libPluginControlInterface.conf". For a details description please consult the "libPluginControlInterface.conf", "libPluginRoutingInterfacePulse.conf" and AudioManager documentation. This AudioManager PoC is based on AM ver 3.0 and Qt 5. It will be a simple application that will demonstrate a few of the AM capabilities: 1. source playing; 2. volume changing; 3. source switching based on source priorities; 4. automatic volume handeling based on source priorities. Signed-off-by: Adrian Scarlat Signed-off-by: Holger Behrens --- AudioManagerPoC/AudioManager_PoC.pro | 76 ++++++ AudioManagerPoC/AudioManager_PoC.qrc | 40 +++ AudioManagerPoC/README | 78 ++++++ .../business_logic/include/audioManagerInterface.h | 114 ++++++++ .../include/qmlbuttoneventsreceiver.h | 72 +++++ .../business_logic/include/volumechart.h | 41 +++ .../business_logic/src/audioManagerInterface.cpp | 230 ++++++++++++++++ AudioManagerPoC/business_logic/src/main.cpp | 87 ++++++ .../business_logic/src/qmlbuttoneventsreceiver.cpp | 298 +++++++++++++++++++++ AudioManagerPoC/business_logic/src/volumechart.cpp | 86 ++++++ .../presentation_layer/AudioManager.qml | 183 +++++++++++++ AudioManagerPoC/presentation_layer/Button.qml | 121 +++++++++ AudioManagerPoC/presentation_layer/Clock.qml | 131 +++++++++ AudioManagerPoC/presentation_layer/HomePage.qml | 53 ++++ AudioManagerPoC/presentation_layer/Slider.qml | 125 +++++++++ AudioManagerPoC/presentation_layer/Tab.qml | 135 ++++++++++ AudioManagerPoC/presentation_layer/main.qml | 163 +++++++++++ AudioManagerPoC/resources/audio/car_reverse.wav | Bin 0 -> 1801796 bytes AudioManagerPoC/resources/audio/navigation.wav | Bin 0 -> 328370 bytes AudioManagerPoC/resources/audio/telephone-ring.wav | Bin 0 -> 4894540 bytes AudioManagerPoC/resources/audio/tts.wav | Bin 0 -> 2051370 bytes .../resources/pics/WindRiver_red_lrg.png | Bin 0 -> 67921 bytes AudioManagerPoC/resources/pics/bg.png | Bin 0 -> 111940 bytes AudioManagerPoC/resources/pics/bg_homepage.png | Bin 0 -> 211 bytes AudioManagerPoC/resources/pics/clock.png | Bin 0 -> 19863 bytes AudioManagerPoC/resources/pics/clock_glass.png | Bin 0 -> 4407 bytes AudioManagerPoC/resources/pics/genivi_logo.png | Bin 0 -> 60335 bytes AudioManagerPoC/resources/pics/home.png | Bin 0 -> 671 bytes AudioManagerPoC/resources/pics/sound.png | Bin 0 -> 800 bytes .../resources/scripts/getconnections.sh | 22 ++ .../resources/scripts/getvolumes_val.sh | 22 ++ .../resources/scripts/playCarReverse.sh | 22 ++ AudioManagerPoC/resources/scripts/playmusic.sh | 22 ++ AudioManagerPoC/resources/scripts/playnav.sh | 22 ++ AudioManagerPoC/resources/scripts/playtel.sh | 22 ++ AudioManagerPoC/resources/scripts/playtts.sh | 22 ++ AudioManagerPoC/resources/scripts/setvolume.sh | 22 ++ .../resources/scripts/stopCarReverse.sh | 22 ++ AudioManagerPoC/resources/scripts/stopmusic.sh | 22 ++ AudioManagerPoC/resources/scripts/stopnav.sh | 22 ++ AudioManagerPoC/resources/scripts/stoptel.sh | 22 ++ AudioManagerPoC/resources/scripts/stoptts.sh | 22 ++ AudioManagerPoC/resources/scripts/tabs.js | 36 +++ 43 files changed, 2355 insertions(+) create mode 100644 AudioManagerPoC/AudioManager_PoC.pro create mode 100644 AudioManagerPoC/AudioManager_PoC.qrc create mode 100644 AudioManagerPoC/README create mode 100644 AudioManagerPoC/business_logic/include/audioManagerInterface.h create mode 100644 AudioManagerPoC/business_logic/include/qmlbuttoneventsreceiver.h create mode 100644 AudioManagerPoC/business_logic/include/volumechart.h create mode 100644 AudioManagerPoC/business_logic/src/audioManagerInterface.cpp create mode 100644 AudioManagerPoC/business_logic/src/main.cpp create mode 100644 AudioManagerPoC/business_logic/src/qmlbuttoneventsreceiver.cpp create mode 100644 AudioManagerPoC/business_logic/src/volumechart.cpp create mode 100644 AudioManagerPoC/presentation_layer/AudioManager.qml create mode 100644 AudioManagerPoC/presentation_layer/Button.qml create mode 100644 AudioManagerPoC/presentation_layer/Clock.qml create mode 100644 AudioManagerPoC/presentation_layer/HomePage.qml create mode 100644 AudioManagerPoC/presentation_layer/Slider.qml create mode 100644 AudioManagerPoC/presentation_layer/Tab.qml create mode 100644 AudioManagerPoC/presentation_layer/main.qml create mode 100755 AudioManagerPoC/resources/audio/car_reverse.wav create mode 100755 AudioManagerPoC/resources/audio/navigation.wav create mode 100755 AudioManagerPoC/resources/audio/telephone-ring.wav create mode 100755 AudioManagerPoC/resources/audio/tts.wav create mode 100644 AudioManagerPoC/resources/pics/WindRiver_red_lrg.png create mode 100644 AudioManagerPoC/resources/pics/bg.png create mode 100644 AudioManagerPoC/resources/pics/bg_homepage.png create mode 100644 AudioManagerPoC/resources/pics/clock.png create mode 100644 AudioManagerPoC/resources/pics/clock_glass.png create mode 100644 AudioManagerPoC/resources/pics/genivi_logo.png create mode 100644 AudioManagerPoC/resources/pics/home.png create mode 100644 AudioManagerPoC/resources/pics/sound.png create mode 100755 AudioManagerPoC/resources/scripts/getconnections.sh create mode 100755 AudioManagerPoC/resources/scripts/getvolumes_val.sh create mode 100755 AudioManagerPoC/resources/scripts/playCarReverse.sh create mode 100755 AudioManagerPoC/resources/scripts/playmusic.sh create mode 100755 AudioManagerPoC/resources/scripts/playnav.sh create mode 100755 AudioManagerPoC/resources/scripts/playtel.sh create mode 100755 AudioManagerPoC/resources/scripts/playtts.sh create mode 100755 AudioManagerPoC/resources/scripts/setvolume.sh create mode 100755 AudioManagerPoC/resources/scripts/stopCarReverse.sh create mode 100755 AudioManagerPoC/resources/scripts/stopmusic.sh create mode 100755 AudioManagerPoC/resources/scripts/stopnav.sh create mode 100755 AudioManagerPoC/resources/scripts/stoptel.sh create mode 100755 AudioManagerPoC/resources/scripts/stoptts.sh create mode 100644 AudioManagerPoC/resources/scripts/tabs.js diff --git a/AudioManagerPoC/AudioManager_PoC.pro b/AudioManagerPoC/AudioManager_PoC.pro new file mode 100644 index 0000000..a8f8222 --- /dev/null +++ b/AudioManagerPoC/AudioManager_PoC.pro @@ -0,0 +1,76 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-03-04T09:20:56 +# +#------------------------------------------------- + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +QT += core +QT += gui +QT += dbus +QT += qml +QT += quick +QT += widgets + +TARGET = AudioManager_PoC +CONFIG += console +CONFIG -= app_bundle +CONFIG +=qml_debug + +TEMPLATE = app + +SOURCES += business_logic/src/main.cpp \ + business_logic/src/qmlbuttoneventsreceiver.cpp \ + business_logic/src/volumechart.cpp \ + business_logic/src/audioManagerInterface.cpp + +HEADERS += business_logic/include/qmlbuttoneventsreceiver.h \ + business_logic/include/volumechart.h \ + business_logic/include/audioManagerInterface.h + +RESOURCES += AudioManager_PoC.qrc + +scripts.files += resources/scripts/getconnections.sh \ + resources/scripts/getvolumes_val.sh \ + resources/scripts/playCarReverse.sh \ + resources/scripts/playmusic.sh \ + resources/scripts/playnav.sh \ + resources/scripts/playtel.sh \ + resources/scripts/playtts.sh \ + resources/scripts/setvolume.sh \ + resources/scripts/stopCarReverse.sh \ + resources/scripts/stopmusic.sh \ + resources/scripts/stopnav.sh \ + resources/scripts/stoptel.sh \ + resources/scripts/stoptts.sh \ + resources/scripts/start_am-poc.sh +scripts.path += /opt/audiomanager-poc/scripts + +audio.files += resources/audio/car_reverse.wav \ + resources/audio/navigation.wav \ + resources/audio/telephone-ring.wav \ + resources/audio/tts.wav +audio.path += /opt/audiomanager-poc/audio-files + +target.path = /usr/bin +INSTALLS += target \ + scripts \ + audio diff --git a/AudioManagerPoC/AudioManager_PoC.qrc b/AudioManagerPoC/AudioManager_PoC.qrc new file mode 100644 index 0000000..adec18f --- /dev/null +++ b/AudioManagerPoC/AudioManager_PoC.qrc @@ -0,0 +1,40 @@ + + + + + presentation_layer/main.qml + presentation_layer/HomePage.qml + presentation_layer/AudioManager.qml + presentation_layer/Button.qml + presentation_layer/Clock.qml + presentation_layer/Slider.qml + presentation_layer/Tab.qml + resources/scripts/tabs.js + resources/pics/bg_homepage.png + resources/pics/bg.png + resources/pics/clock_glass.png + resources/pics/clock.png + resources/pics/genivi_logo.png + resources/pics/home.png + resources/pics/sound.png + resources/pics/WindRiver_red_lrg.png + + diff --git a/AudioManagerPoC/README b/AudioManagerPoC/README new file mode 100644 index 0000000..5b2333d --- /dev/null +++ b/AudioManagerPoC/README @@ -0,0 +1,78 @@ +GENIVI_AudioManager_PoC +=============================================== +:Author: Adrian Scarlat +:doctitle: GENIVI_AudioManager_PoC + +SPDX license identifier: CC-BY-SA-4.0 + +Copyright (C) 2011-2014, Wind River Systems +Copyright (C) 2014, GENIVI Alliance + +This file is part of AudioManager PoC. + +This Documentation Form is subject to the terms of the Creative +Commons Attribution Share Alike (CC-BY-SA), v. 4.0. If a copy +of the CC-BY-SA was not distributed with this file, you can +obtain one at http://spdx.org/licenses/CC-BY-SA-4.0 + +For further information see http://www.genivi.org/. + +== Description of AudioManager_PoC +The AudioManager Proof of Concept (AM PoC) is an Qt application, based +on Qt5 and QtQuick module. It uses the GENIVI AudioManager capabilities +to demonstrate how audio sources are managed based on mixing rules +that are defined in the configuration file for AM Control Plugin: +"libPluginControlInterface.conf". + +For a detailed description please consult the "libPluginControlInterface.conf", +"libPluginRoutingInterfacePulse.conf" and AudioManager documentation. + +Also please visit the following link: +http://wiki.projects.genivi.org/index.php/Intrepid_-_Yocto_GENIVI_Demo_Platform +for a description of the GENIVI Demo Platform into which the AM PoC is +pre-integrated. + +== How to add wav files to AudioManager PoC +Currently Am PoC uses aplay to play wav files using scripts. The audio wav files +are found in AudioManagerPoC/resources/audio/ and the scripts used are found +in AudioManagerPoC/resources/scripts. + +Below is a description of which script plays what wav file: + + Script name || Wav file played +===================||===================== +playCarReverse.sh || car_reverse.wav +------------------------------------------ + playnav.sh || navigation.wav +------------------------------------------ + playtel.sh || telephone-ring.wav +------------------------------------------ + playtts.sh || tts.wav +------------------------------------------ + +To change the wav files played, the following steps must be taken: +1. Edit the script corresponding to the file you want to change by + changing the aplay file name parameter with the wav file name you + want to use; +2. Edit the AudioManager_PoC.pro file by changing the corresponding + wav file name in the files member of the audio install set; This + ensures that the new audio wav file will be installed when deploying; + +There is one script: playmusic.sh, for which the audio wav file is not provided +because of copyright issues. +To add a wav file for the playmusic.sh script do the following: +1. Edit the playmusic.sh script by changing the aplay file name parameter with + the wav file name you want to use; +2. Edit the AudioManager_PoC.pro file by adding the corresponding + wav file name in the files member of the audio install set; This + ensures that the new audio wav file will be installed when deploying; + +IMPORTANT !! +To stop playing the audio files, scripts are also used and can be found in +AudioManagerPoC/resources/scripts. Be sure that the grep parameter used to +search for the process that plays the audio file, corresponds to the wav file +name being played. + +Example: +For the stopmusic.sh script, change "grep [U]NKLE" to "grep [y]our_wav_file.wav". +Do this for all the scripts that start with 'stop'; diff --git a/AudioManagerPoC/business_logic/include/audioManagerInterface.h b/AudioManagerPoC/business_logic/include/audioManagerInterface.h new file mode 100644 index 0000000..92b53d2 --- /dev/null +++ b/AudioManagerPoC/business_logic/include/audioManagerInterface.h @@ -0,0 +1,114 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#ifndef AUDIOMANAGER_H +#define AUDIOMANAGER_H + +#include + +#include +#include +#include + +typedef struct +{ + ushort mainConnectionID; + ushort sourceID; + ushort sinkID; + short delay; + short connectionState; +} MainConnection; + + +typedef struct +{ + short available; + short reason; +} Availability; + + +typedef struct +{ + ushort sinkID; + QString name; + Availability availability; + short volume; + short muteState; + ushort sinkClassID; +} Sink; + + +typedef struct +{ + ushort sourceID; + QString name; + Availability availability; + ushort sourceClassID; + short volume; +} Source; + + +Q_DECLARE_METATYPE(ushort); +Q_DECLARE_METATYPE(MainConnection); +Q_DECLARE_METATYPE(Availability); +Q_DECLARE_METATYPE(Sink); +Q_DECLARE_METATYPE(Source); + +Q_DECLARE_METATYPE(QList); +Q_DECLARE_METATYPE(QList); +Q_DECLARE_METATYPE(QList); +Q_DECLARE_METATYPE(QList); + +QDBusArgument &operator<<(QDBusArgument &argument, const MainConnection &theStruct); + +const QDBusArgument &operator>>(const QDBusArgument &argument, MainConnection &theStruct); + +QDBusArgument &operator<<(QDBusArgument &argument, const Availability &theStruct); + +const QDBusArgument &operator>>(const QDBusArgument &argument, Availability &theStruct); + +QDBusArgument &operator<<(QDBusArgument &argument, const Sink &theStruct); + +const QDBusArgument &operator>>(const QDBusArgument &argument, Sink &theStruct); + +QDBusArgument &operator<<(QDBusArgument &argument, const Source &theStruct); + +const QDBusArgument &operator>>(const QDBusArgument &argument, Source &theStruct); + +class Q_DBUS_EXPORT audioManagerInterface : public QDBusAbstractInterface +{ +public: + audioManagerInterface(QObject *parent); + void Connect(const QString sourceName, const QString sinkName); + void Disconnect(const QString sourceName, const QString sinkName); + void SetVolume(const QString sinkName, short volume); + + QList GetListMainSources(); + QList GetListMainSinks(); + QList GetListMainConnections(); + +private: + QMap sinkName2SinkID; + QMap sourceName2SourceID; + QMap mainConnectionID2SourceName; + QMap sourceName2mainConnectionID; +}; + +#endif // AUDIOMANAGER_H diff --git a/AudioManagerPoC/business_logic/include/qmlbuttoneventsreceiver.h b/AudioManagerPoC/business_logic/include/qmlbuttoneventsreceiver.h new file mode 100644 index 0000000..e424f81 --- /dev/null +++ b/AudioManagerPoC/business_logic/include/qmlbuttoneventsreceiver.h @@ -0,0 +1,72 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#ifndef QMLBUTTONEVENTSRECEIVER_H +#define QMLBUTTONEVENTSRECEIVER_H + +#include +#include + +#include "business_logic/include/audioManagerInterface.h" +#include "business_logic/include/volumechart.h" + +#define BACKGROUND_CHANNEL 1 +#define FOREGROUND_CHANNEL 2 + +class QMLButtonEventsReceiver : public QObject +{ +Q_OBJECT + +public: + QMLButtonEventsReceiver(QQuickView *view); + + Q_INVOKABLE QString clicked(QString btnText) const; + Q_INVOKABLE void slider(QString sliderText, qreal value) const; + + +public slots: + void slotRefreshInfo(); + void slotMediaEnd(); + void slotCarEnd(); + void slotNavEnd(); + void slotTTSEnd(); + void slotTelEnd(); + + +private: + QQuickView *view; + audioManagerInterface *amgr; + int channel; + + QString playMusic; + QString stopMusic; + QString playCarReverse; + QString stopCarReverse; + QString playNav; + QString stopNav; + QString playTTS; + QString stopTTS; + QString playTel; + QString stopTel; + QString getConnections; + QString getVolumes; +}; + +#endif // QMLBUTTONEVENTSRECEIVER_H diff --git a/AudioManagerPoC/business_logic/include/volumechart.h b/AudioManagerPoC/business_logic/include/volumechart.h new file mode 100644 index 0000000..4711327 --- /dev/null +++ b/AudioManagerPoC/business_logic/include/volumechart.h @@ -0,0 +1,41 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#ifndef VOLUMECHART_H +#define VOLUMECHART_H + +#include +#include +#include +#include +#include + +class volumechart : public QQuickImageProvider +{ +public: + static QList > volumes; + + volumechart(); + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); +}; + + +#endif // VOLUMECHART_H diff --git a/AudioManagerPoC/business_logic/src/audioManagerInterface.cpp b/AudioManagerPoC/business_logic/src/audioManagerInterface.cpp new file mode 100644 index 0000000..90bbf37 --- /dev/null +++ b/AudioManagerPoC/business_logic/src/audioManagerInterface.cpp @@ -0,0 +1,230 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#include +#include +#include + +#include "business_logic/include/audioManagerInterface.h" + + + +audioManagerInterface::audioManagerInterface(QObject *parent) : + QDBusAbstractInterface( + QString("org.genivi.audiomanager"), + QString("/org/genivi/audiomanager/commandinterface"), + "org.genivi.audiomanager.commandinterface", + QDBusConnection::sessionBus(), + parent) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >(); + qDBusRegisterMetaType >(); + + GetListMainSources(); + GetListMainSinks(); + GetListMainConnections(); + +} + +void audioManagerInterface::Connect(const QString sourceName, const QString sinkName) +{ + qDebug() <<"Connect got called: " << sourceName << " " << sinkName; + QDBusMessage result = this->call( + "Connect", + QVariant::fromValue((ushort) sourceName2SourceID[sourceName]), + QVariant::fromValue((ushort) sinkName2SinkID[sinkName])); + QVariant resultCode = result.arguments().at(0); + QVariant mainConnectionID = result.arguments().at(1); + qDebug() <<"Connection ID: " << mainConnectionID.toInt(); + + if (mainConnectionID.toUInt() != 0) // connection doesn't exist + { + mainConnectionID2SourceName[mainConnectionID.toUInt()] = sourceName; + sourceName2mainConnectionID[sourceName] = mainConnectionID.toUInt(); + } +} + +void audioManagerInterface::Disconnect(const QString sourceName, const QString sinkName) +{ + qDebug() <<"Disconnect got called: " << sourceName << " " << sinkName; + qDebug() <<"Disconnect got called Cond ID: " << sourceName2mainConnectionID[sourceName]; + QDBusMessage result = this->call( + "Disconnect", + QVariant::fromValue((ushort) sourceName2mainConnectionID[sourceName])); + QVariant resultCode = result.arguments().at(0); +} + +QList audioManagerInterface::GetListMainSources() +{ + QDBusMessage result = this->call("GetListMainSources"); + if (result.errorMessage() != "") + { + return QList(); + } + QList sources = qdbus_cast >(result.arguments().at(1)); + for (int i = 0; i < sources.size(); i++) + { + + sourceName2SourceID[sources[i].name] = sources[i].sourceID; + } + return sources; +} + +QList audioManagerInterface::GetListMainSinks() +{ + QDBusMessage result = this->call("GetListMainSinks"); + if (result.errorMessage() != "") + { + return QList(); + } + QList sinks = qdbus_cast >(result.arguments().at(1)); + for (int i = 0; i < sinks.size(); i++) + { + + sinkName2SinkID[sinks[i].name] = sinks[i].sinkID; + } + return sinks; +} + +QList audioManagerInterface::GetListMainConnections() +{ + QDBusMessage result = this->call("GetListMainConnections"); + + if (result.errorMessage() != "") + { + return QList(); + } + + QList connections = qdbus_cast >(result.arguments().at(1)); + for (int i = 0; i < connections.size(); i++) + { + mainConnectionID2SourceName[connections[i].mainConnectionID] = connections[i].mainConnectionID; + } + + return connections; +} + +void audioManagerInterface::SetVolume(const QString sinkName, short volume) +{ + QDBusMessage result = this->call( + "SetVolume", + QVariant::fromValue((ushort) sinkName2SinkID[sinkName]), + QVariant::fromValue(volume)); + QVariant resultCode = result.arguments().at(0); +} + +QDBusArgument &operator<<(QDBusArgument &argument, const MainConnection &theStruct) +{ + argument.beginStructure(); + argument << theStruct.mainConnectionID + << theStruct.sourceID + << theStruct.sinkID + << theStruct.delay + << theStruct.connectionState; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, MainConnection &theStruct) +{ + argument.beginStructure(); + argument >> theStruct.mainConnectionID + >> theStruct.sourceID + >> theStruct.sinkID + >> theStruct.delay + >> theStruct.connectionState; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const Availability &theStruct) +{ + argument.beginStructure(); + argument << theStruct.available + << theStruct.reason; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, Availability &theStruct) +{ + argument.beginStructure(); + argument >> theStruct.available + >> theStruct.reason; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const Sink &theStruct) +{ + argument.beginStructure(); + argument << theStruct.sinkID + << theStruct.name + << theStruct.availability + << theStruct.volume + << theStruct.muteState + << theStruct.sinkClassID; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, Sink &theStruct) +{ + argument.beginStructure(); + argument >> theStruct.sinkID + >> theStruct.name + >> theStruct.availability + >> theStruct.volume + >> theStruct.muteState + >> theStruct.sinkClassID; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const Source &theStruct) +{ + argument.beginStructure(); + argument << theStruct.sourceID + << theStruct.name + << theStruct.availability + << theStruct.sourceClassID + << theStruct.volume; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, Source &theStruct) +{ + argument.beginStructure(); + argument >> theStruct.sourceID + >> theStruct.name + >> theStruct.availability + >> theStruct.sourceClassID + >> theStruct.volume; + argument.endStructure(); + return argument; +} diff --git a/AudioManagerPoC/business_logic/src/main.cpp b/AudioManagerPoC/business_logic/src/main.cpp new file mode 100644 index 0000000..3bdd518 --- /dev/null +++ b/AudioManagerPoC/business_logic/src/main.cpp @@ -0,0 +1,87 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + * + * 28.11.2014, Adrian Scarlat, Added code to allow only one instance of + * AM PoC to run; This was achieved by creating + * a file in /var/run and placing an advisory + * lock on it, using flock(). When another + * instance is created, it can't create the advisory + * lock on the same file since the first instance + * owns it and it will quit with an appropriate + * message. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "business_logic/include/qmlbuttoneventsreceiver.h" +#include "business_logic/include/volumechart.h" +#include "business_logic/include/audioManagerInterface.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + int pid_file = open("/var/run/AudioManager_PoC.pid", O_CREAT | O_RDWR, 0666); + if(pid_file != -1) + { + int rc = flock(pid_file, LOCK_EX | LOCK_NB); + if(rc) + { + if(EWOULDBLOCK == errno) + { + qDebug() << "Only one instance of AudioManager_PoC is allowed. Quitting!"; + return 0; + } + } + else + { + QQuickView view; + QMLButtonEventsReceiver rec(&view); + view.rootContext()->setContextProperty("QMLButtonEventsReceiver", &rec); + view.engine()->addImageProvider(QLatin1String("volumes"), new volumechart()); + view.setSource(QUrl("qrc:/presentation_layer/main.qml")); + view.showMaximized(); + + qDebug() << "Show maximized"; + + QTimer *timer = new QTimer(&rec); + QObject::connect(timer, SIGNAL(timeout()), &rec, SLOT(slotRefreshInfo())); + timer->start(500); + + QObject *sliderVolume = view.rootObject()->findChild("sliderVolume"); + sliderVolume->setProperty("value", 100.0); + + return app.exec(); + } + } + else + { + qDebug() << "Couldn't create /var/run/AudioManager_PoC.pid file."; + return 0; + } +} diff --git a/AudioManagerPoC/business_logic/src/qmlbuttoneventsreceiver.cpp b/AudioManagerPoC/business_logic/src/qmlbuttoneventsreceiver.cpp new file mode 100644 index 0000000..f6d95dc --- /dev/null +++ b/AudioManagerPoC/business_logic/src/qmlbuttoneventsreceiver.cpp @@ -0,0 +1,298 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "business_logic/include/qmlbuttoneventsreceiver.h" +#include "business_logic/include/volumechart.h" + +/** + * The value for volume is in percentage and is relative to the PulseAudio + * volume. Consult PulseAudio documentaion for a description about how + * volume is measured inside PulseAudio. + */ +static int masterVolumeFG = 100; +static int masterVolumeBG = 100; +static audioManagerInterface *static_amgr; + +QMLButtonEventsReceiver::QMLButtonEventsReceiver(QQuickView *view) +{ + playMusic = "/opt/audiomanager-poc/scripts/playmusic.sh"; + stopMusic = "/opt/audiomanager-poc/scripts/stopmusic.sh"; + playCarReverse = "/opt/audiomanager-poc/scripts/playCarReverse.sh"; + stopCarReverse = "/opt/audiomanager-poc/scripts/stopCarReverse.sh"; + playNav = "/opt/audiomanager-poc/scripts/playnav.sh"; + stopNav = "/opt/audiomanager-poc/scripts/stopnav.sh"; + playTTS = "/opt/audiomanager-poc/scripts/playtts.sh"; + stopTTS = "/opt/audiomanager-poc/scripts/stoptts.sh"; + playTel = "/opt/audiomanager-poc/scripts/playtel.sh"; + stopTel = "/opt/audiomanager-poc/scripts/stoptel.sh"; + getConnections = "/opt/audiomanager-poc/scripts/getconnections.sh"; + getVolumes = "/opt/audiomanager-poc/scripts/getvolumes_val.sh"; + + this->amgr = new audioManagerInterface(view); + static_amgr = amgr; + this->view = view; + channel = BACKGROUND_CHANNEL; +} + +QString QMLButtonEventsReceiver::clicked(QString btnText) const +{ + qDebug() << "Clicked:" << btnText; + + if (btnText == "Play Music") { + amgr->Connect("MediaPlayer", "AlsaPrimary"); + QProcess *p1 = new QProcess(); + p1->start(playMusic); + connect(p1, SIGNAL(finished(int)), SLOT(slotMediaEnd())); + return "Stop Music"; + } + + if (btnText == "Stop Music") { + amgr->Disconnect("MediaPlayer", "AlsaPrimary"); + QProcess *p1 = new QProcess(); + p1->start(stopMusic); + return "Play Music"; + } + + if (btnText == "Parking Signal") { + amgr->Connect("ReverseBeep", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(playCarReverse); + connect(p1, SIGNAL(finished(int)), SLOT(slotCarEnd())); + return "Stop Parking Signal"; + } + + if (btnText == "Stop Parking Signal") { + amgr->Disconnect("ReverseBeep", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopCarReverse); + return "Parking Signal"; + } + + if (btnText == "Navigation Message") { + amgr->Connect("NaviPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(playNav); + connect(p1, SIGNAL(finished(int)), SLOT(slotNavEnd())); + return "Stop Navigation Message"; + } + + if (btnText == "Stop Navigation Message") { + amgr->Disconnect("NaviPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopNav); + return "Navigation Message"; + } + + if (btnText == "Text To Speech") { + amgr->Connect("TTSPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(playTTS); + connect(p1, SIGNAL(finished(int)), SLOT(slotTTSEnd())); + return "Stop Text To Speech"; + } + + if (btnText == "Stop Text To Speech") { + amgr->Disconnect("TTSPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopTTS); + return "Text To Speech"; + } + + if (btnText == "Start Phone Call") { + amgr->Connect("Skype", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(playTel); + connect(p1, SIGNAL(finished(int)), SLOT(slotTelEnd())); + return "End Phone Call"; + } + + if (btnText == "End Phone Call") { + amgr->Disconnect("Skype", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopTel); + return "Start Phone Call"; + } + + return btnText; +} + + +void QMLButtonEventsReceiver::slider(QString sliderText, qreal value) const +{ + if (sliderText == "Volume") + { + if (channel == FOREGROUND_CHANNEL) + { + masterVolumeFG = (int) value; + amgr->SetVolume("AlsaSecondary", value); + } + else + { + masterVolumeBG = (int) value; + amgr->SetVolume("AlsaPrimary", value); + } + } +} + +void QMLButtonEventsReceiver::slotRefreshInfo() +{ + QObject *text = view->rootObject()->findChild("textConnections"); + QObject *textSrc = view->rootObject()->findChild("textSources"); + QObject *textVol = view->rootObject()->findChild("textVolumes"); + + QProcess *p1 = new QProcess(); + p1->start(getConnections); + p1->waitForFinished(-1); + + QString p_stdout = p1->readAllStandardOutput(); + + text->setProperty("text", QString(p_stdout)); + QStringList linesConnections = QString(p_stdout).split("\n"); + + QProcess *p2 = new QProcess(); + p2->start(getVolumes); + p2->waitForFinished(-1); + + p_stdout = p2->readAllStandardOutput(); + + QStringList lines = QString(p_stdout).split("\n"); + QString audiosources = ""; + QString audiovolumes = ""; + + int oldChannel = channel; + + channel = BACKGROUND_CHANNEL; + QObject *channelTXT = view->rootObject()->findChild("channel"); + + for (int i = 0; i < lines.size(); i++) + { + QStringList x = lines[i].split(","); + if (x.length() == 2 && x.at(0).length() != 0 && x.at(1).length() != 0 ) + { + QString src = QString(x.at(0)); + QString vol = "0"; + audiosources += src + "\n"; + int masterVolume = masterVolumeBG; + for (int j = 0; j < linesConnections.size(); j++) + { + if (linesConnections[j].contains(src) && linesConnections[j].contains("Connected")) + { + vol = QString(x.at(1)); + if (linesConnections[j].contains("AlsaSecondary")) + { + channel = FOREGROUND_CHANNEL; + masterVolume = masterVolumeFG; + } + } + } + audiovolumes += vol + "\n"; + volumechart::volumes[i].push_back(masterVolume * vol.toInt() / 100); + } + } + + if (oldChannel != channel) + { + QObject *sliderVolume = view->rootObject()->findChild("sliderVolume"); + + if (channel == BACKGROUND_CHANNEL) + { + channelTXT->setProperty("text", "Background Channel"); + sliderVolume->setProperty("value", masterVolumeBG); + } + if (channel == FOREGROUND_CHANNEL) + { + channelTXT->setProperty("text", "Foreground Channel"); + sliderVolume->setProperty("value", masterVolumeFG); + } + } + + textSrc->setProperty("text", audiosources); + textVol->setProperty("text", audiovolumes); +} + +void QMLButtonEventsReceiver::slotMediaEnd() +{ + qDebug() << "slotMediaEnd"; + amgr->Disconnect("MediaPlayer", "AlsaPrimary"); + QProcess *p1 = new QProcess(); + p1->start(stopMusic); + + QObject *connectOptions = view->rootObject()->findChild("music"); + connectOptions->setProperty("text", "Play Music"); +} + +void QMLButtonEventsReceiver::slotCarEnd() +{ + qDebug() << "slotCarEnd"; + amgr->Disconnect("ReverseBeep", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopCarReverse); + + QObject *connectOptions = view->rootObject()->findChild("parking"); + connectOptions->setProperty("text", "Parking Signal"); +} + +void QMLButtonEventsReceiver::slotNavEnd() +{ + qDebug() << "slotNavEnd"; + amgr->Disconnect("NaviPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopNav); + + QObject *connectOptions = view->rootObject()->findChild("nav"); + connectOptions->setProperty("text", "Navigation Message"); +} + + +void QMLButtonEventsReceiver::slotTTSEnd() +{ + qDebug() << "slotTTSEnd"; + amgr->Disconnect("TTSPlayer", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopTTS); + + QObject *connectOptions = view->rootObject()->findChild("tts"); + connectOptions->setProperty("text", "Text To Speech"); +} + +void QMLButtonEventsReceiver::slotTelEnd() +{ + qDebug() << "slotTelEnd"; + amgr->Disconnect("Skype", "AlsaSecondary"); + QProcess *p1 = new QProcess(); + p1->start(stopTel); + + QObject *connectOptions = view->rootObject()->findChild("phone"); + connectOptions->setProperty("text", "Start Phone Call"); +} diff --git a/AudioManagerPoC/business_logic/src/volumechart.cpp b/AudioManagerPoC/business_logic/src/volumechart.cpp new file mode 100644 index 0000000..d8ecfbc --- /dev/null +++ b/AudioManagerPoC/business_logic/src/volumechart.cpp @@ -0,0 +1,86 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "business_logic/include/volumechart.h" + +QList > volumechart::volumes; + + +volumechart::volumechart() + : QQuickImageProvider(QQuickImageProvider::Pixmap) +{ + QList l1; + volumechart::volumes.push_back(l1); + QList l2; + volumechart::volumes.push_back(l2); + QList l3; + volumechart::volumes.push_back(l3); + QList l4; + volumechart::volumes.push_back(l4); + QList l5; + volumechart::volumes.push_back(l5); +} + +QPixmap volumechart::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) +{ + int width = 400; + int height = 100; + + if (size) + *size = QSize(width, height); + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(QColor(0, 0, 0)); + + QPainter painter(&pixmap); + QColor colors[10]; + colors[0] = Qt::red; + colors[1] = Qt::green; + colors[2] = Qt::blue; + colors[3] = Qt::yellow; + colors[4] = Qt::cyan; + colors[5] = Qt::magenta; + colors[6] = Qt::darkCyan; + painter.setRenderHints(QPainter::Antialiasing); + for (int src = 0; src < volumes.size(); src++) + { + painter.setPen(colors[src]); + int limitMin = 1; + if (volumes[src].size() > 40) + { + limitMin = volumes[src].size() - 40; + } + for (int i = limitMin; i < volumes[src].size(); i++) + { + painter.drawLine((i - 1 - (limitMin -1)) * 10, src * 2 + 75 - volumes[src][i - 1] / 2, + (i - (limitMin -1)) * 10, src * 2 + 75 - volumes[src][i]/2); + } + } + return pixmap; +} diff --git a/AudioManagerPoC/presentation_layer/AudioManager.qml b/AudioManagerPoC/presentation_layer/AudioManager.qml new file mode 100644 index 0000000..e919680 --- /dev/null +++ b/AudioManagerPoC/presentation_layer/AudioManager.qml @@ -0,0 +1,183 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +import QtQuick 2.2 + +Rectangle { + + Row{ + y: 20; + x: 380 + Button { + objectName: "music" + text: "Play Music" + width: 180 + } + } + + Row { + spacing: 10 + y: 100; + x: 50 + Button { + objectName: "parking" + text: "Parking Signal" + width: 200 + } + Button { + objectName: "nav" + text: "Navigation Message" + width: 250 + } + Button { + objectName: "tts" + text: "Text To Speech" + width: 200 + } + Button { + objectName: "phone" + text: "Start Phone Call" + width: 180 + } + } + + Rectangle + { + color: "#000000"; + radius: 5 + width: 410 + height: 110 + x: 45 + y: 175 + Image { + id: volChart + source: "image://volumes/1" + width: 400 + x:5 + y:5 + height: 100 + asynchronous: true + } + } + + Timer { + property int idx: 0 + id: timerImg; + interval: 1000 + repeat: true + running: true + onTriggered: { + idx++; + volChart.source = "image://volumes/" + idx; } + } + + Row { + z: 3 + x: 50 + y: 300 + spacing: 50 + //CONNECTIONS + Column { + x: 5 + width: 450 + z: 4 + Text { + id: titleConnections + z: 5 + font { + family: "Liberation Mono" + pointSize: 12 + } + color: "#000000" + text: "CONNECTIONS:" + } + + + Text { + id: id1 + z: 5 + font { + family: "Liberation Mono" + pointSize: 9 + } + color: "#000000" + objectName: "textConnections" + text: "" + } + }//end connections + + + //SOURCES + Column { + z: 4 + width: 100 + Text { + id: titleSources + z: 5 + font { + family: "Liberation Mono" + pointSize: 12 + } + color: "#000000" + text: "SOURCES" + } + + + Text { + objectName: "textSources" + z: 5 + font { + family: "Liberation Mono" + pointSize: 9 + } + color: "#000000" + text: "" + } + }//end sources + + //VOLUMES + Column { + width: 150 + z: 4 + Text { + id: titleVolumes + z: 5 + font { + family: "Liberation Mono" + pointSize: 12 + } + color: "#000000" + text: "VOLUME" + } + + Text { + objectName: "textVolumes" + z: 5 + font { + family: "Liberation Mono" + pointSize: 9 + bold: true; + } + color: "#000000" + text: "" + } + }//end connections + } +} diff --git a/AudioManagerPoC/presentation_layer/Button.qml b/AudioManagerPoC/presentation_layer/Button.qml new file mode 100644 index 0000000..392cf5c --- /dev/null +++ b/AudioManagerPoC/presentation_layer/Button.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2011-2014, Wind River Systems +** Copyright (C) 2014, GENIVI Alliance +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 + +Rectangle { + + id: theRect + property alias text: label.text; + property alias icon: img.source; + smooth: true; + width: 150 + height:50 + border { + color: "#55000000" + width: 2 + } + gradient: Gradient { + GradientStop { position: 0.0; color: "#55444444" } + GradientStop { position: 0.05; color: "#55888888" } + GradientStop { id:gr;position: 0.8; color: "#55333333" } + GradientStop { position: 1.0; color: "#55000000" } + } + radius: 10 + //anchors: + Text { + id: label + y:20 + anchors.horizontalCenter: parent.horizontalCenter + text: "-" + //font.bold: true; + font { + family: "Verdana" + pointSize: 14 + } + style: Text.Raised; + styleColor: "#55000000" + color: "#55555555" + } + Image { + id: img + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + opacity: 0.4 + source: "" + } + transform: { + rotation: 10 + } + SequentialAnimation { + id:animation; + PropertyAnimation { + id: animation1; + target: gr; + property: "color"; + to: "#55000000"; + duration: 200 + } + PropertyAnimation { + id: animation2; + target: gr; + property: "color"; + to: "#55333333"; + duration: 200 + } + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true; + onEntered: { + border.width = 2; + } + onExited: { + border.width = 2; + } + onClicked: { + animation.start(); + label.text = QMLButtonEventsReceiver.clicked(label.text); + } + } +} diff --git a/AudioManagerPoC/presentation_layer/Clock.qml b/AudioManagerPoC/presentation_layer/Clock.qml new file mode 100644 index 0000000..91f3958 --- /dev/null +++ b/AudioManagerPoC/presentation_layer/Clock.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2011-2014, Wind River Systems +** Copyright (C) 2014, GENIVI Alliance +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 + +Item { + id: clock + width: 180; height: 180 + + property int hours + property int minutes + property int seconds + property real shift + property bool night: false + + function timeChanged() { + var date = new Date; + hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 1000; running: true; repeat: true; + onTriggered: clock.timeChanged() + } + + Image {x: clock.x; y: clock.y; smooth: true;id: background; source: "qrc:/resources/pics/clock.png"; z: clock.z+1; opacity: 0.9;} + Image {x: clock.x; y: clock.y; smooth: true;id: glass; source: "qrc:/resources/pics/clock_glass.png"; z: clock.z+10} + + Rectangle { + color: "#888888"; + height: clock.height/2 - 25 + width: 6 + z: clock.z + 2 + x: clock.x + clock.width/2 - 3 + y: clock.y + 35 + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 3; origin.y: clock.height/2 - 35; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + } + } + Rectangle { + color: "#333333"; + height: clock.height/2 - 20 + width: 4 + z: clock.z + 3 + x: clock.x + clock.width/2 - 2 + y: clock.y + 30 + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 2; origin.y: clock.height/2 - 30; + angle: clock.minutes * 6 + } + } + + Rectangle { + height: clock.height/2 - 15 + width: 2 + z: clock.z + 4 + x: clock.x + clock.width/2 - 1 + y: clock.y + 25 + color: "#555555"; + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 1; origin.y: clock.height/2 - 25; + angle: clock.seconds * 6 + } + } + Column { + x: clock.x - clock.width/2 + y: clock.y + clock.height/2 + + Text { + color: "#FF5555" + font.pointSize: 12 + font.bold: true + text: Qt.formatDateTime(new Date(), "ddd,MMM") + } + Text { + color: "#FF3333" + font.pointSize: 48 + font.bold: true + text: Qt.formatDateTime(new Date(), "dd") + } + } +} diff --git a/AudioManagerPoC/presentation_layer/HomePage.qml b/AudioManagerPoC/presentation_layer/HomePage.qml new file mode 100644 index 0000000..1df54a4 --- /dev/null +++ b/AudioManagerPoC/presentation_layer/HomePage.qml @@ -0,0 +1,53 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +import QtQuick 2.2 + +Row { + spacing: 50 + anchors.fill: parent + + Image { + id: logoGENIVI + x: 0 + y: 100 + source: "qrc:/resources/pics/genivi_logo.png" + } + + Column { + x: 0 + y: 100 + spacing: 80 + + Clock { + id: myClock + z: 10 + x: 100 + y: 100 + } + + Image { + id: logoWR + anchors.horizontalCenter: myClock.horizontalCenter + anchors.topMargin: myClock.bottom + source: "qrc:/resources/pics/WindRiver_red_lrg.png" + } + } +} diff --git a/AudioManagerPoC/presentation_layer/Slider.qml b/AudioManagerPoC/presentation_layer/Slider.qml new file mode 100644 index 0000000..1657d89 --- /dev/null +++ b/AudioManagerPoC/presentation_layer/Slider.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2011-2014, Wind River Systems +** Copyright (C) 2014, GENIVI Alliance +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 + +Item { + id: slider; + + smooth: true; + // value is read/write. + property real value + onValueChanged: { handle.x = 2 + (value - minimum) * slider.xMax / (maximum - minimum); } + property real maximum: 1 + property real minimum: 1 + property int xMax: slider.width - handle.width - 4 + + Rectangle { + smooth: true; + anchors.fill: parent + border.color: "black"; border.width: 0; radius: 16 + gradient: Gradient { + GradientStop { position: 0.0; color: "#66000000" } + GradientStop { position: 1.0; color: "#66555555" } + } + Text { + id: channel + objectName: "channel" + anchors.verticalCenter: parent.verticalCenter; + anchors.horizontalCenter: parent.horizontalCenter; + font.bold: true + font.pointSize: 16 + color: "#AAAAAA" + text: "Background Channel" + } + } + + Rectangle { + id: handle; smooth: true + x: slider.width / 2 - handle.width / 2; y: 2; width: 80; height: slider.height-4; + radius: 16 + gradient: Gradient { + GradientStop { position: 0.0; color: "#DDDDDD" } + GradientStop { position: 0.4; color: "#AAAAAA" } + GradientStop { position: 1.0; color: "#555555" } + } + + MouseArea { + anchors.fill: parent; drag.target: parent + drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 + onPositionChanged: { + value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; + for (var i = 0; i < 5; i++) + { + if (value > (i)*20) + { + volumeButton.children[i].color = "#9900AA00"; + volumeButton.children[i].border.color = "#99005500"; + } else { + volumeButton.children[i].color = "#99333333"; + volumeButton.children[i].border.color = "#99000000"; + } + } + + QMLButtonEventsReceiver.slider("Volume", value); + } + } + + Row { + id: volumeButton + spacing: 2 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: 5 + Rectangle { + width: 3; + height: 3 * (index + 1) + y: (16 - 3 * (index + 1)) + color: "#9900AA00" + border.width: 1 + border.color: "#99005500" + } + } + } + } +} diff --git a/AudioManagerPoC/presentation_layer/Tab.qml b/AudioManagerPoC/presentation_layer/Tab.qml new file mode 100644 index 0000000..8116029 --- /dev/null +++ b/AudioManagerPoC/presentation_layer/Tab.qml @@ -0,0 +1,135 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +import QtQuick 2.2 + +Rectangle { + + id: tab + + property bool isSelected: false; + property string iconURL: "" + property string basecolor: "#FFFFFF" + property variant idContainer + + Image { + id: name + source: iconURL; + smooth: true; + anchors.horizontalCenter: parent.horizontalCenter; + anchors.verticalCenter: parent.verticalCenter; + } + + Rectangle { + smooth: true; + z:1000 + x: -12 + y: -12 + radius: 14 + width: 24; + height: fullScreen.width * 0.08 + 10; + color: "#000000" + } + + + Rectangle { + id: unselected; + x: 0 + y: +1 + width: fullScreen.width * 0.08; + height: fullScreen.width * 0.08; + + gradient: Gradient { + GradientStop { + position: 0.00; + color: "#00000000"; + } + GradientStop { + position: 0.9; + color: "#55000000"; + } + GradientStop { + position: 1; + color: "#AA000000"; + } + } + color: "#000000" + } + + color: tab.basecolor + + + + gradient: Gradient { + GradientStop { + id: selected; + position: 0.00; + color: tab.basecolor;//"#77FFFFFF"; + } + GradientStop { + position: 0.2; + color: tab.basecolor; + } + } + + // color: "#FFCC33" + width: fullScreen.width * 0.08-1; + height: fullScreen.width * 0.08; + + transform: Rotation { + origin.x: fullScreen.width * 0.09 / 2; + origin.y: fullScreen.width * 0.09 / 2; + angle: -90 + } + + SequentialAnimation { + id:animationSelect; + PropertyAnimation { + id: animation1; + target: selected; + property: "color"; + to: "#77000000"; + duration: 200 + } + } + + SequentialAnimation { + id:animationUnselect; + PropertyAnimation { + id: animation2; + target: selected; + property: "color"; + to: tab.basecolor; + duration: 200 + } + } + onIsSelectedChanged: { + console.log("TAB", isSelected); + if (isSelected) { + console.log("TAB selected"); + animationSelect.start(); + unselected.visible = false; + } else { + console.log("TAB un-selected"); + unselected.visible = true; + animationUnselect.start(); + } + } +} diff --git a/AudioManagerPoC/presentation_layer/main.qml b/AudioManagerPoC/presentation_layer/main.qml new file mode 100644 index 0000000..1a85c3a --- /dev/null +++ b/AudioManagerPoC/presentation_layer/main.qml @@ -0,0 +1,163 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + */ + +import QtQuick 2.2 +import "qrc:/resources/scripts/tabs.js" as Tabs + +Rectangle { + id: fullScreen; + width: 1024; + height: 768; + color: "#000000" + + Image { + z: -1 + width: fullScreen.width;//1600// + height: fullScreen.height;//720//900// + fillMode: Image.Tile + source: "qrc:/resources/pics/bg_homepage.png" + } + gradient: Gradient { + GradientStop { + position: 0.00; + color: "#00000000"; + } + GradientStop { + position: 0.2; + color: "#FF000000"; + } + GradientStop { + position: 0.9; + color: "#FF000000"; + } + GradientStop { + position: 1; + color: "#00000000"; + } + } + + property int oldIndex: -1; + + function tabSelected(newIndex) + { + if (oldIndex != -1) + { + console.log("UNSELECT INDEX:", oldIndex); + tabs.children[oldIndex].isSelected = false; + tabs.children[oldIndex].idContainer.visible = false; + } + console.log("SELECT INDEX:", newIndex); + + tabs.children[newIndex].isSelected = true; + tabs.children[newIndex].idContainer.visible = true; + oldIndex = newIndex; + } + + Row { + x:0 + height: 100 + + Rectangle { + color: "#00000000" + width: fullScreen.width * 0.08; + height: fullScreen.width * 0.08; + } + + Slider { + y: 10; + height: 32; + width: fullScreen.width * 0.9 + id: sliderId + objectName: "sliderVolume" + minimum: 0 + maximum: 100 + onMaximumChanged: { + sliderId.value = 200 + } + } + } + + Row { + y: fullScreen.height * 0.1 + + Column { + id: tabs; + //TAB BAR + anchors.verticalCenter: parent.verticalCenter + spacing: 20 + + Tab { + id: tab1 + iconURL: "qrc:/resources/pics/home.png" + idContainer: tabContent1 + basecolor: "#FFFFFF"; + MouseArea {anchors.fill: parent; onClicked: { tabSelected(0); }} + } + + Tab { + id: tab2 + iconURL: "qrc:/resources/pics/sound.png" + idContainer: tabContent2 + basecolor: "#FFFFFF"; + MouseArea {anchors.fill: parent; onClicked: { tabSelected(1); }} + } + } + + Column { + //TAB CONTENT + anchors.verticalCenter: parent.verticalCenter + spacing: 20 + + Rectangle {//HOME + id: tabContent1; + visible: false; + color: tab1.color + width: fullScreen.width * 0.9; + height: fullScreen.height * 0.8; + radius: 10; + + HomePage { + id: homePage + anchors.rightMargin: -53 + anchors.bottomMargin: 204 + anchors.leftMargin: 124 + anchors.topMargin: -31 + } + } + + Rectangle {//SOUND SETTINGS + id: tabContent2; + visible: false; + color: tab2.color + width: fullScreen.width * 0.9; + height: fullScreen.height * 0.8 ; + radius: 10; + + AudioManager { + id: audioManager + } + } + } + + Component.onCompleted: { + tabSelected(0); + } + } +} diff --git a/AudioManagerPoC/resources/audio/car_reverse.wav b/AudioManagerPoC/resources/audio/car_reverse.wav new file mode 100755 index 0000000..ee22f68 Binary files /dev/null and b/AudioManagerPoC/resources/audio/car_reverse.wav differ diff --git a/AudioManagerPoC/resources/audio/navigation.wav b/AudioManagerPoC/resources/audio/navigation.wav new file mode 100755 index 0000000..46b147b Binary files /dev/null and b/AudioManagerPoC/resources/audio/navigation.wav differ diff --git a/AudioManagerPoC/resources/audio/telephone-ring.wav b/AudioManagerPoC/resources/audio/telephone-ring.wav new file mode 100755 index 0000000..fcc896c Binary files /dev/null and b/AudioManagerPoC/resources/audio/telephone-ring.wav differ diff --git a/AudioManagerPoC/resources/audio/tts.wav b/AudioManagerPoC/resources/audio/tts.wav new file mode 100755 index 0000000..00ca58c Binary files /dev/null and b/AudioManagerPoC/resources/audio/tts.wav differ diff --git a/AudioManagerPoC/resources/pics/WindRiver_red_lrg.png b/AudioManagerPoC/resources/pics/WindRiver_red_lrg.png new file mode 100644 index 0000000..12e64cc Binary files /dev/null and b/AudioManagerPoC/resources/pics/WindRiver_red_lrg.png differ diff --git a/AudioManagerPoC/resources/pics/bg.png b/AudioManagerPoC/resources/pics/bg.png new file mode 100644 index 0000000..8cd0ed0 Binary files /dev/null and b/AudioManagerPoC/resources/pics/bg.png differ diff --git a/AudioManagerPoC/resources/pics/bg_homepage.png b/AudioManagerPoC/resources/pics/bg_homepage.png new file mode 100644 index 0000000..2517d44 Binary files /dev/null and b/AudioManagerPoC/resources/pics/bg_homepage.png differ diff --git a/AudioManagerPoC/resources/pics/clock.png b/AudioManagerPoC/resources/pics/clock.png new file mode 100644 index 0000000..fdb660a Binary files /dev/null and b/AudioManagerPoC/resources/pics/clock.png differ diff --git a/AudioManagerPoC/resources/pics/clock_glass.png b/AudioManagerPoC/resources/pics/clock_glass.png new file mode 100644 index 0000000..d41cd44 Binary files /dev/null and b/AudioManagerPoC/resources/pics/clock_glass.png differ diff --git a/AudioManagerPoC/resources/pics/genivi_logo.png b/AudioManagerPoC/resources/pics/genivi_logo.png new file mode 100644 index 0000000..c474c06 Binary files /dev/null and b/AudioManagerPoC/resources/pics/genivi_logo.png differ diff --git a/AudioManagerPoC/resources/pics/home.png b/AudioManagerPoC/resources/pics/home.png new file mode 100644 index 0000000..0ca131f Binary files /dev/null and b/AudioManagerPoC/resources/pics/home.png differ diff --git a/AudioManagerPoC/resources/pics/sound.png b/AudioManagerPoC/resources/pics/sound.png new file mode 100644 index 0000000..4101212 Binary files /dev/null and b/AudioManagerPoC/resources/pics/sound.png differ diff --git a/AudioManagerPoC/resources/scripts/getconnections.sh b/AudioManagerPoC/resources/scripts/getconnections.sh new file mode 100755 index 0000000..6e51bc3 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/getconnections.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +dbus-send --session --print-reply --dest=org.genivi.audiomanager /org/genivi/audiomanager/commandinterface org.genivi.audiomanager.commandinterface.GetListMainConnections | awk '/struct/ {getline;getline;SOURCE=$2;getline;SINK=$2;getline;getline;STATUS=$2;print "Source"SOURCE"-->Sink"SINK"(Status"STATUS")";}' | sed 's/Source100/MediaPlayer/g' | sed 's/Source101/NaviPlayer/g' | sed 's/Source102/TTSPlayer/g' | sed 's/Source103/Skype/g' | sed 's/Source104/ReverseBeep/g' | sed 's/Sink100/AlsaPrimary/g' | sed 's/Sink101/AlsaSecondary/g' | sed 's/Status1/Connecting/g' | sed 's/Status2/Connected/g' | sed 's/Status3/Disconnecting/g' | sed 's/Status4/Disconnected/g' | sed 's/Status5/Suspended/g' diff --git a/AudioManagerPoC/resources/scripts/getvolumes_val.sh b/AudioManagerPoC/resources/scripts/getvolumes_val.sh new file mode 100755 index 0000000..f44cb74 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/getvolumes_val.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +dbus-send --session --print-reply --dest=org.genivi.audiomanager /org/genivi/audiomanager/commandinterface org.genivi.audiomanager.commandinterface.GetListMainSinks | awk '/struct/ {getline; FS="\""; getline;NAME=$2; getline; getline; getline; getline;FS=" "; getline;print NAME","$2}' diff --git a/AudioManagerPoC/resources/scripts/playCarReverse.sh b/AudioManagerPoC/resources/scripts/playCarReverse.sh new file mode 100755 index 0000000..b91acbc --- /dev/null +++ b/AudioManagerPoC/resources/scripts/playCarReverse.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +PULSE_PROP="media.role='reverse'" aplay /opt/audiomanager-poc/audio-files/car_reverse.wav diff --git a/AudioManagerPoC/resources/scripts/playmusic.sh b/AudioManagerPoC/resources/scripts/playmusic.sh new file mode 100755 index 0000000..8f15e7e --- /dev/null +++ b/AudioManagerPoC/resources/scripts/playmusic.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +PULSE_PROP="media.role='MEDIA'" aplay /opt/audiomanager-poc/audio-files/UNKLE_-_Burn_My_Shadow.wav diff --git a/AudioManagerPoC/resources/scripts/playnav.sh b/AudioManagerPoC/resources/scripts/playnav.sh new file mode 100755 index 0000000..40d7e3d --- /dev/null +++ b/AudioManagerPoC/resources/scripts/playnav.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +PULSE_PROP="media.role='NAVI'" aplay /opt/audiomanager-poc/audio-files/navigation.wav diff --git a/AudioManagerPoC/resources/scripts/playtel.sh b/AudioManagerPoC/resources/scripts/playtel.sh new file mode 100755 index 0000000..1d73bd3 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/playtel.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +PULSE_PROP="media.role='skype'" aplay /opt/audiomanager-poc/audio-files/telephone-ring.wav diff --git a/AudioManagerPoC/resources/scripts/playtts.sh b/AudioManagerPoC/resources/scripts/playtts.sh new file mode 100755 index 0000000..ec8eb8a --- /dev/null +++ b/AudioManagerPoC/resources/scripts/playtts.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +PULSE_PROP="media.role='TextToSpeach'" aplay /opt/audiomanager-poc/audio-files/tts.wav diff --git a/AudioManagerPoC/resources/scripts/setvolume.sh b/AudioManagerPoC/resources/scripts/setvolume.sh new file mode 100755 index 0000000..8c9db7b --- /dev/null +++ b/AudioManagerPoC/resources/scripts/setvolume.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +RESULT=`python -c 'import dbus; print dbus.SessionBus().call_blocking("org.genivi.audiomanager", "/org/genivi/audiomanager/commandinterface", "org.genivi.audiomanager.commandinterface", "SetVolume", "ui", (dbus.UInt32(100), dbus.UInt32('$1') ))'` diff --git a/AudioManagerPoC/resources/scripts/stopCarReverse.sh b/AudioManagerPoC/resources/scripts/stopCarReverse.sh new file mode 100755 index 0000000..d5dce81 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/stopCarReverse.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +ps aux | grep [c]ar_reverse.wav | awk '{print $2}' | xargs kill -9 diff --git a/AudioManagerPoC/resources/scripts/stopmusic.sh b/AudioManagerPoC/resources/scripts/stopmusic.sh new file mode 100755 index 0000000..a1d546e --- /dev/null +++ b/AudioManagerPoC/resources/scripts/stopmusic.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +ps aux | grep [U]NKLE | awk '{print $2}' | xargs kill -9 diff --git a/AudioManagerPoC/resources/scripts/stopnav.sh b/AudioManagerPoC/resources/scripts/stopnav.sh new file mode 100755 index 0000000..dd4894e --- /dev/null +++ b/AudioManagerPoC/resources/scripts/stopnav.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +ps aux | grep [n]avigation.wav | awk '{print $2}' | xargs kill -9 diff --git a/AudioManagerPoC/resources/scripts/stoptel.sh b/AudioManagerPoC/resources/scripts/stoptel.sh new file mode 100755 index 0000000..d6db116 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/stoptel.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +ps aux | grep [t]elephone | awk '{print $2}' | xargs kill -9 diff --git a/AudioManagerPoC/resources/scripts/stoptts.sh b/AudioManagerPoC/resources/scripts/stoptts.sh new file mode 100755 index 0000000..2bc12b7 --- /dev/null +++ b/AudioManagerPoC/resources/scripts/stoptts.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# SPDX license identifier: MPL-2.0 +# +# Copyright (C) 2011-2014, Wind River Systems +# Copyright (C) 2014, GENIVI Alliance +# +# This file is part of GENIVI AudioManager PoC. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License (MPL), v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# For further information see http://www.genivi.org/. +# +# List of changes: +# +# 21.09.2014, Adrian Scarlat, First version of the code; +# Added Copyright and License information; +# + +ps aux | grep [t]ts.wav | awk '{print $2}' | xargs kill -9 diff --git a/AudioManagerPoC/resources/scripts/tabs.js b/AudioManagerPoC/resources/scripts/tabs.js new file mode 100644 index 0000000..836744a --- /dev/null +++ b/AudioManagerPoC/resources/scripts/tabs.js @@ -0,0 +1,36 @@ +/** + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2011-2014, Wind River Systems + * Copyright (C) 2014, GENIVI Alliance + * + * This file is part of GENIVI AudioManager PoC. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License (MPL), v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * For further information see http://www.genivi.org/. + * + * List of changes: + * + * 21.09.2014, Adrian Scarlat, First version of the code; + * Added Copyright and License information; + * + */ + +var tabIDS = new Array(); + +var oldSelectedTab = null; +var oldSelectedTabContent; + +function tabSelected(newSelectedTab, newSelectedTabContent) +{ + console.log("newSelectedTab, newSelectedTabContent", newSelectedTab, newSelectedTabContent); + if (oldSelectedTab) + { + oldSelectedTab.visible = false; + } + + oldSelectedTab = newSelectedTab; +} -- cgit v1.2.1