Parent: [5e96b0] (diff)

Child: [a910f6] (diff)

Download this file

avtransport_qo.h    86 lines (69 with data), 2.3 kB

 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
#include <iostream>
using namespace std;
#include <QObject>
#include <QThread>
#include <QDebug>
#include "libupnpp/control/avtransport.hxx"
class AVTMetadata {
public:
virtual std::string getDidl() const = 0;
};
class AVTransportQO : public QObject, public UPnPClient::VarEventReporter {
Q_OBJECT
public:
AVTransportQO(UPnPClient::AVTH avt, QObject *parent = 0)
: QObject(parent), m_srv(avt), m_cursecs(-1)
{
m_srv->installReporter(this);
}
virtual void changed(const char *nm, int value)
{
if (!strcmp(nm, "CurrentTrackDuration")) {
m_cursecs = value;
}
qDebug() << "AVT: Changed: " << nm << " (int): " << value;
}
virtual void changed(const char *nm, const char *value)
{
qDebug() << "AVT: Changed: " << nm << " (char*): " << value;
}
virtual void changed(const char *nm, UPnPDirObject meta)
{
string s = meta.dump();
if (!strcmp(nm, "AVTransportURIMetaData")) {
emit titleChanged(QString::fromUtf8(
meta.m_title.c_str()));
emit albumChanged(QString::fromUtf8(
meta.m_props["upnp:album"].c_str()));
emit artistChanged(QString::fromUtf8(
meta.m_props["upnp:artist"].c_str()));
//m_cursecs = meta.getDurationSeconds();
qDebug() << "AVT: duration now: " << m_cursecs << " S";
}
qDebug() << "AVT: Changed: " << nm << " (dirc): " << s.c_str();
}
public slots:
virtual void play() {m_srv->play();}
virtual void stop() {m_srv->stop();}
virtual void pause() {m_srv->pause();}
virtual void changeTrack(const string& uri, const AVTMetadata* md)
{
m_srv->setAVTransportURI(uri, md->getDidl());
}
// Seek to point. Parameter in percent.
virtual void seekPC(int pc)
{
qDebug() << "AVT: seekPC " << pc << " %";
if (m_cursecs > 0) {
m_srv->seek(UPnPClient::AVTransport::SEEK_ABS_TIME,
(float(pc)/100.0) * m_cursecs);
}
}
signals:
void titleChanged(QString);
void albumChanged(QString);
void artistChanged(QString);
private:
UPnPClient::AVTH m_srv;
int m_cursecs;
};