--- a/upqo/avtransport_qo.h
+++ b/upqo/avtransport_qo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 J.F.Dockes
+/* Copyright (C) 2014-2018 J.F.Dockes
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -39,11 +39,7 @@
public:
AVTransportQO(UPnPClient::AVTH avt, QObject *parent = 0)
- : QObject(parent), m_srv(avt), m_timer(0), m_errcnt(0),
- m_cursecs(-1),
- m_sent_end_of_track_sig(false),
- m_in_ending(false),
- m_tpstate(AVTransport::Unknown) {
+ : QObject(parent), m_srv(avt) {
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(update()));
@@ -68,22 +64,14 @@
const char *tpstatetostr(int tps) {
switch (tps) {
default:
- case UPnPClient::AVTransport::Unknown:
- return "Unknown";
- case UPnPClient::AVTransport::Stopped:
- return "Stopped";
- case UPnPClient::AVTransport::Playing:
- return "Playing";
- case UPnPClient::AVTransport::Transitioning:
- return "Transitionning";
- case UPnPClient::AVTransport::PausedPlayback:
- return "PausedPlay";
- case UPnPClient::AVTransport::PausedRecording:
- return "PausedRecord";
- case UPnPClient::AVTransport::Recording:
- return "Recording";
- case UPnPClient::AVTransport::NoMediaPresent:
- return "No Media";
+ case UPnPClient::AVTransport::Unknown: return "Unknown";
+ case UPnPClient::AVTransport::Stopped: return "Stopped";
+ case UPnPClient::AVTransport::Playing: return "Playing";
+ case UPnPClient::AVTransport::Transitioning: return "Transitionning";
+ case UPnPClient::AVTransport::PausedPlayback: return "PausedPlay";
+ case UPnPClient::AVTransport::PausedRecording: return "PausedRecord";
+ case UPnPClient::AVTransport::Recording: return "Recording";
+ case UPnPClient::AVTransport::NoMediaPresent: return "No Media";
}
}
@@ -95,18 +83,18 @@
//qDebug() << "AVT: Changed: " << nm << " (int): " << value;
m_cursecs = value;
} else if (!strcmp(nm, "TransportState")) {
- //qDebug() << "AVT: Changed: " << nm << " " << tpstatetostr(value);
+ qDebug() << "AVT: Changed: " << nm << " " << tpstatetostr(value);
m_tpstate = AVTransport::TransportState(value);
emit tpStateChanged(value);
if (m_in_ending &&
(value == UPnPClient::AVTransport::Stopped ||
value == UPnPClient::AVTransport::NoMediaPresent)) {
m_in_ending = false;
- qDebug() << "AVT EVT: emitting stoppedAtEOT";
+ qDebug() << "AVT: changed: emitting stoppedAtEOT";
emit stoppedAtEOT();
}
} else if (!strcmp(nm, "CurrentTransportActions")) {
- //qDebug() << "AVT: Changed: " << nm << " (int): " << value;
+ //qDebug() << "AVT: changed: " << nm << " (int): " << value;
emit tpActionsChanged(value);
}
}
@@ -131,8 +119,8 @@
(m_tpstate == UPnPClient::AVTransport::Playing ||
m_tpstate == UPnPClient::AVTransport::Transitioning ||
m_tpstate == UPnPClient::AVTransport::PausedPlayback)) {
- //qDebug() << "AVT: ext track change: cur [" << m_cururi.c_str()
- // << "] new [" << value << "]";
+ qDebug() << "AVT: ext track change: cur [" << m_cururi.c_str()
+ << "] new [" << value << "]";
setcururi(value);
emit newTrackPlaying(QString::fromUtf8(value));
}
@@ -141,8 +129,8 @@
virtual void changed(const char *nm, UPnPClient::UPnPDirObject meta) {
if (!strcmp(nm, "AVTransportURIMetaData")) {
- qDebug() << "AVT: Changed: " << nm << " (dirc): " <<
- meta.dump().c_str();
+ //qDebug() << "AVT: Changed: " << nm << " (dirc): " <<
+ // meta.dump().c_str();
// Don't use this if no resources are set. XBMC/Kodi does
// this for some reason. Else we'd end-up with
// resource-less unplayable entries in the
@@ -162,19 +150,22 @@
public slots:
virtual void play() {
+ qDebug() << "AVT: play";
m_srv->play();
}
virtual void stop() {
+ qDebug() << "AVT: stop";
setcururi("");
m_in_ending = false;
m_srv->stop();
}
virtual void pause() {
+ qDebug() << "AVT: pause";
m_srv->pause();
}
virtual void changeTrack(const std::string& uri, const AVTMetadata* md) {
- qDebug() << "AVT:changeTrack: " << uri.c_str();
+ qDebug() << "AVT: changeTrack: " << uri.c_str();
m_srv->setAVTransportURI(uri, md->getDidl());
// Don't do this: wait for the renderer data, else we risk
// flickering if an event reports the old track.
@@ -183,7 +174,7 @@
virtual void prepareNextTrack(const std::string& uri,
const AVTMetadata* md) {
- qDebug() << "AVT:prepareNextTrack: " << uri.c_str();
+ qDebug() << "AVT: prepareNextTrack: " << uri.c_str();
m_srv->setNextAVTransportURI(uri, md->getDidl());
}
@@ -193,8 +184,9 @@
m_srv->seek(UPnPClient::AVTransport::SEEK_REL_TIME, secs);
}
- // Retrieve the current track length in seconds. This is useful
- // if the available metadata does not have a duration (esp. happens with video)
+ // Retrieve the current track length in seconds. This is useful if
+ // the available metadata does not have a duration (esp. happens
+ // with video)
virtual int trackSecs() {
return m_cursecs;
}
@@ -207,7 +199,7 @@
UPnPClient::AVTransport::PositionInfo info;
int error;
if ((error = m_srv->getPositionInfo(info)) != 0) {
- qDebug() << "getPositionInfo failed with error " << error;
+ qDebug() << "AVT: getPositionInfo failed with error " << error;
if (m_errcnt++ > 4) {
emit connectionLost();
}
@@ -218,7 +210,7 @@
UPnPClient::AVTransport::TransportInfo tinfo;
if ((error = m_srv->getTransportInfo(tinfo)) != 0) {
- qDebug() << "getTransportInfo failed with error " << error;
+ qDebug() << "AVT: getTransportInfo failed with error " << error;
return;
}
@@ -231,11 +223,6 @@
emit secsInSongChanged(info.reltime);
if (m_cursecs > 0) {
if (info.reltime > m_cursecs - 10) {
- if (!m_sent_end_of_track_sig) {
- qDebug() << "AVT: Emitting endOfTrackIsNear()";
- emit endOfTrackIsNear();
- m_sent_end_of_track_sig = true;
- }
m_in_ending = true;
} else if (info.reltime > 0 && info.reltime < 5) {
// This is for the case where we are playing 2
@@ -287,7 +274,6 @@
signals:
void secsInSongChanged(quint32);
- void endOfTrackIsNear();
void newTrackPlaying(QString);
void tpStateChanged(int);
void tpActionsChanged(int);
@@ -297,18 +283,16 @@
private:
UPnPClient::AVTH m_srv;
- QTimer *m_timer;
- int m_errcnt;
- int m_cursecs;
- bool m_sent_end_of_track_sig;
- bool m_in_ending;
+ QTimer *m_timer{nullptr};
+ int m_errcnt{0};
+ int m_cursecs{-1};
+ bool m_in_ending{false};
std::string m_cururi;
- AVTransport::TransportState m_tpstate;
+ AVTransport::TransportState m_tpstate{AVTransport::Unknown};
void setcururi(const std::string& uri) {
- qDebug() << "setcururi: " << uri.c_str();
+ qDebug() << "AVT: setcururi: " << uri.c_str();
m_cururi = uri;
- m_sent_end_of_track_sig = false;
if (uri != "") {
// Don't reset m_in_ending if uri is null: we often get an
// uri change to "" before we get the transport state