summaryrefslogtreecommitdiff
path: root/musicagent.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-26 20:02:47 +0100
committerJavier <dev.git@javispedro.com>2015-12-26 20:02:47 +0100
commitceafe544919a35f674684c2e71593b9fb35747a5 (patch)
treed0912a51b60b91cf4f6177a0c18aab0629d501b8 /musicagent.cc
parent693f100e919132bd1cf703c5987c5d503bc2289c (diff)
downloadsapd-ceafe544919a35f674684c2e71593b9fb35747a5.tar.gz
sapd-ceafe544919a35f674684c2e71593b9fb35747a5.zip
prepare new agent for music controller
Diffstat (limited to 'musicagent.cc')
-rw-r--r--musicagent.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/musicagent.cc b/musicagent.cc
new file mode 100644
index 0000000..5d7836a
--- /dev/null
+++ b/musicagent.cc
@@ -0,0 +1,55 @@
+#include "sapsocket.h"
+#include "sapconnectionrequest.h"
+#include "sapserviceinfo.h"
+#include "sapchannelinfo.h"
+#include "musicconn.h"
+#include "musicagent.h"
+
+static MusicAgent *agent = 0;
+static const QLatin1String music_profile("/system/music");
+
+MusicAgent::MusicAgent(QObject *parent)
+ : QObject(parent), _peer(0), _socket(0)
+{
+}
+
+MusicAgent* MusicAgent::instance()
+{
+ if (!agent) {
+ agent = new MusicAgent;
+ }
+ return agent;
+}
+
+void MusicAgent::peerFound(SAPPeer *peer)
+{
+}
+
+void MusicAgent::requestConnection(SAPConnectionRequest *request)
+{
+ qDebug() << "MusicAgent request connection from" << request->peer()->peerName();
+ SAPConnection *conn = request->connection();
+ new MusicConn(conn, this);
+ request->accept();
+}
+
+void MusicAgent::registerServices(SAPManager *manager)
+{
+ SAPServiceInfo service;
+ SAPChannelInfo channel;
+
+ service.setProfile(music_profile);
+ service.setFriendlyName("Media controller");
+ service.setRole(SAPServiceInfo::RoleConsumer);
+ service.setVersion(1, 0);
+ service.setConnectionTimeout(0);
+
+ channel.setChannelId(100);
+ channel.setPayloadType(SAPChannelInfo::PayloadJson);
+ channel.setQoSType(SAPChannelInfo::QoSReliabilityDisable);
+ channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow);
+ channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow);
+ service.addChannel(channel);
+
+ manager->registerServiceAgent(service, instance());
+}