summaryrefslogtreecommitdiff
path: root/AudioManagerPoC/business_logic/include/audioManagerInterface.h
blob: 92b53d26a4092bbc40139e403e8f91e23047fe80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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 <stdint.h>

#include <QDBusArgument>
#include <QDBusAbstractInterface>
#include <QDBusVariant>

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<MainConnection>);
Q_DECLARE_METATYPE(QList<Availability>);
Q_DECLARE_METATYPE(QList<Sink>);
Q_DECLARE_METATYPE(QList<Source>);

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<Source>         GetListMainSources();
    QList<Sink>           GetListMainSinks();
    QList<MainConnection> GetListMainConnections();

private:
    QMap<QString, ushort> sinkName2SinkID;
    QMap<QString, ushort> sourceName2SourceID;
    QMap<uint, QString>   mainConnectionID2SourceName;
    QMap<QString, uint>   sourceName2mainConnectionID;
};

#endif // AUDIOMANAGER_H