Skip to content

Commit

Permalink
Make AirTunes (RAOP) server use new MythUINotificationCenter
Browse files Browse the repository at this point in the history
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 9abc5db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
33 changes: 30 additions & 3 deletions mythtv/libs/libmythtv/AirPlay/mythraopconnection.cpp
Expand Up @@ -15,6 +15,8 @@
#include "mythraopconnection.h"
#include "mythairplayserver.h"

#include "mythuinotificationcenter.h"

#define LOC QString("RAOP Conn: ")
#define MAX_PACKET_SIZE 2048

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
}
Expand Down Expand Up @@ -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;
}
10 changes: 9 additions & 1 deletion mythtv/libs/libmythtv/AirPlay/mythraopconnection.h
Expand Up @@ -13,6 +13,8 @@

#include "mythtvexp.h"

#include "mythnotification.h"

extern "C" {
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit 9abc5db

Please sign in to comment.