Test for Mediaplayer of HMI Framework at dab version
[apps/mediaplayer.git] / app / qlibsoundmanager.h
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef QLIBSOUNDMANAGER_H
17 #define QLIBSOUNDMANAGER_H
18
19  #include <QObject>
20  #include <QVariant>
21  #include <QtCore/QJsonObject>
22  #include <libsoundmanager.hpp>
23  #include <QString>
24  #include <string>
25
26
27 class QLibSoundmanager : public QObject
28 {
29     Q_OBJECT
30 public: // method
31     explicit QLibSoundmanager(QObject *parent = nullptr);
32     ~QLibSoundmanager();
33     int init(int port, const QString& token);
34
35     using sm_event_handler = std::function<void(int sourceid, int handle)>;
36
37     void subscribe(const QString &event_name);
38     void unsubscribe(const QString &event_name);
39
40     void emit_event(const QString &event, const QJsonObject &msg);
41     void emit_reply(const QJsonObject &msg);
42
43 public:
44
45     Q_INVOKABLE int call(const QString &verb, const QJsonObject &arg);
46     Q_INVOKABLE int connect(int sourceID, const QString& sinkName);
47     Q_INVOKABLE int disconnect(int connectionID);
48     Q_INVOKABLE int ackSetSourceState(int handle, int errorcode);
49     Q_INVOKABLE int registerSource(const QString& name);
50
51 signals:
52     void reply(const QVariant &msg);
53     void event(const QVariant &event, const QVariant &msg);
54
55 private:
56     LibSoundmanager* libsm;
57 };
58
59
60 #endif /*QLIBSOUNDMANAGER_H*/