Permalink
Browse files

Make AirTunes (RAOP) server use new MythUINotificationCenter

Will display artwork and song being played information (artist, album name, title and file format)
  • Loading branch information...
jyavenard committed Jun 27, 2013
1 parent d33d8cd commit 9abc5db3e9bd38f83c38fc9b4fe1f591ee616861
@@ -15,6 +15,8 @@
#include "mythraopconnection.h"
#include "mythairplayserver.h"
#include "mythuinotificationcenter.h"
#define LOC QString("RAOP Conn: ")
#define MAX_PACKET_SIZE 2048
@@ -82,6 +84,7 @@ MythRAOPConnection::MythRAOPConnection(QObject *parent, QTcpSocket *socket,
m_audioTimer(NULL),
m_progressStart(0), m_progressCurrent(0), m_progressEnd(0)
{
m_id = MythUINotificationCenter::GetInstance()->Register(this);
}
MythRAOPConnection::~MythRAOPConnection()
@@ -117,6 +120,11 @@ MythRAOPConnection::~MythRAOPConnection()
delete m_textStream;
m_textStream = NULL;
}
if (m_id > 0)
{
MythUINotificationCenter::GetInstance()->UnRegister(this, m_id);
}
}
void MythRAOPConnection::CleanUp(void)
@@ -1367,15 +1375,22 @@ void MythRAOPConnection::ProcessRequest(const QStringList &header,
{
// Receiving image coverart
m_artwork = content;
SendNotification();
}
else if(tags["Content-Type"] == "image/none")
{
m_artwork.clear();
SendNotification();
}
else if (tags["Content-Type"] == "application/x-dmap-tagged")
{
// Receiving DMAP metadata
QMap<QString,QString> map = decodeDMAP(content);
m_dmap = decodeDMAP(content);
LOG(VB_GENERAL, LOG_INFO,
QString("Receiving Title:%1 Artist:%2 Album:%3 Format:%4")
.arg(map["minm"]).arg(map["asar"])
.arg(map["asal"]).arg(map["asfm"]));
.arg(m_dmap["minm"]).arg(m_dmap["asar"])
.arg(m_dmap["asal"]).arg(m_dmap["asfm"]));
SendNotification();
}
}
}
@@ -1738,3 +1753,15 @@ void MythRAOPConnection::deleteEventClient(void)
QString("%1:%2 disconnected from RAOP events server.")
.arg(client->peerAddress().toString()).arg(client->peerPort()));
}
void MythRAOPConnection::SendNotification(void)
{
QImage image = m_artwork.isEmpty() ? QImage() : QImage::fromData(m_artwork);
MythImageNotification *notification =
new MythImageNotification(MythImageNotification::Update,
image, m_dmap);
notification->SetId(m_id);
notification->SetParent(this);
MythUINotificationCenter::GetInstance()->Queue(*notification);
delete notification;
}
@@ -13,6 +13,8 @@
#include "mythtvexp.h"
#include "mythnotification.h"
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
@@ -106,6 +108,9 @@ class MTV_PUBLIC MythRAOPConnection : public QObject
QString stringFromSeconds(int seconds);
uint64_t framesToMs(uint64_t frames);
// notification functions
void SendNotification(void);
QTimer *m_watchdogTimer;
// comms socket
QTcpSocket *m_socket;
@@ -177,11 +182,14 @@ class MTV_PUBLIC MythRAOPConnection : public QObject
uint32_t m_progressCurrent;
uint32_t m_progressEnd;
QByteArray m_artwork;
QByteArray m_dmap;
DMAP m_dmap;
//Authentication
QString m_nonce;
// Notification Center registration Id
int m_id;
private slots:
void ProcessAudio(void);
};

0 comments on commit 9abc5db

Please sign in to comment.