MythTV
master
|
#include <libmythtv/AirPlay/mythraopconnection.h>
Public Member Functions | |
MythRAOPConnection (QObject *parent, QTcpSocket *socket, QByteArray id, int port) | |
~MythRAOPConnection () override | |
bool | Init (void) |
QTcpSocket * | GetSocket () |
int | GetDataPort () const |
bool | HasAudio () |
Static Public Member Functions | |
static QMap< QString, QString > | decodeDMAP (const QByteArray &dmap) |
decodeDMAP: More... | |
static bool | LoadKey (void) |
LoadKey. More... | |
static QString | RSALastError (void) |
Private Slots | |
void | readClient (void) |
readClient: signal handler for RAOP client connection Handle initialisation of session More... | |
void | udpDataReady (QByteArray buf, const QHostAddress &peer, quint16 port) |
Socket incoming data signal handler use for audio, control and timing socket. More... | |
void | timeout (void) |
void | audioRetry (void) |
void | newEventClient (QTcpSocket *client) |
void | deleteEventClient () |
void | ProcessAudio (void) |
Private Member Functions | |
void | ProcessSync (const QByteArray &buf) |
void | SendResendRequest (std::chrono::milliseconds timestamp, uint16_t expected, uint16_t got) |
SendResendRequest: Request RAOP client to resend missed RTP packets. More... | |
void | ExpireResendRequests (std::chrono::milliseconds timestamp) |
ExpireResendRequests: Expire resend requests that are older than timestamp. More... | |
uint32_t | decodeAudioPacket (uint8_t type, const QByteArray *buf, QList< AudioData > *dest) |
int | ExpireAudio (std::chrono::milliseconds timestamp) |
void | ResetAudio (void) |
void | ProcessRequest (const QStringList &header, const QByteArray &content) |
void | FinishAuthenticationResponse (RaopNetStream *stream, QTcpSocket *socket, QString &cseq) |
bool | CreateDecoder (void) |
void | DestroyDecoder (void) |
bool | OpenAudioDevice (void) |
void | CloseAudioDevice (void) |
void | StartAudioTimer (void) |
void | StopAudioTimer (void) |
void | CleanUp (void) |
void | SendTimeRequest (void) |
SendTimeRequest: Send a time request to the RAOP client. More... | |
void | ProcessTimeResponse (const QByteArray &buf) |
ProcessTimeResponse: Calculate the network latency, we do not use the reference time send by itunes instead we measure the time lapsed between the request and the response the latency is calculated in ms. More... | |
std::chrono::milliseconds | AudioCardLatency (void) |
AudioCardLatency: Description: Play silence and calculate audio latency between input / output. More... | |
std::chrono::milliseconds | framesToMs (uint64_t frames) const |
framesDuration Description: return the duration in ms of frames More... | |
uint64_t | MsToFrame (std::chrono::milliseconds millis) const |
void | SendNotification (bool update=false) |
Static Private Member Functions | |
static void | FinishResponse (RaopNetStream *stream, QTcpSocket *socket, QString &option, QString &cseq, QString &responseData) |
static RawHash | FindTags (const QStringList &lines) |
static std::chrono::milliseconds | NTPToLocal (uint32_t sec, uint32_t ticks) |
static void | microsecondsToNTP (std::chrono::microseconds usec, uint32_t &ntpSec, uint32_t &ntpTicks) |
static void | timevalToNTP (timeval t, uint32_t &ntpSec, uint32_t &ntpTicks) |
static bool | GetPacketType (const QByteArray &buf, uint8_t &type, uint16_t &seq, uint64_t ×tamp) |
static QStringList | splitLines (const QByteArray &lines) |
static QString | stringFromSeconds (int timeInSeconds) |
stringFromSeconds: More... | |
Private Attributes | |
QTimer * | m_watchdogTimer {nullptr} |
QTcpSocket * | m_socket {nullptr} |
RaopNetStream * | m_textStream {nullptr} |
QByteArray | m_hardwareId |
QStringList | m_incomingHeaders |
QByteArray | m_incomingContent |
bool | m_incomingPartial {false} |
int32_t | m_incomingSize {0} |
QHostAddress | m_peerAddress |
ServerPool * | m_dataSocket {nullptr} |
int | m_dataPort |
ServerPool * | m_clientControlSocket {nullptr} |
int | m_clientControlPort {0} |
ServerPool * | m_clientTimingSocket {nullptr} |
int | m_clientTimingPort {0} |
ServerPool * | m_eventServer {nullptr} |
int | m_eventPort {-1} |
QList< QTcpSocket * > | m_eventClients |
QMap< uint16_t, std::chrono::milliseconds > | m_resends |
QByteArray | m_aesIV |
std::vector< uint8_t > | m_sessionKey |
const EVP_CIPHER * | m_cipher {nullptr} |
EVP_CIPHER_CTX * | m_cctx {nullptr} |
AudioOutput * | m_audio {nullptr} |
const AVCodec * | m_codec {nullptr} |
AVCodecContext * | m_codecContext {nullptr} |
QList< int > | m_audioFormat |
int | m_channels {2} |
int | m_sampleSize {16} |
int | m_frameRate {44100} |
int | m_framesPerPacket {352} |
QTimer * | m_dequeueAudioTimer {nullptr} |
QMap< std::chrono::milliseconds, AudioPacket > | m_audioQueue |
uint32_t | m_queueLength {0} |
bool | m_streamingStarted {false} |
bool | m_allowVolumeControl {true} |
uint16_t | m_seqNum {0} |
uint16_t | m_lastSequence {0} |
std::chrono::milliseconds | m_lastTimestamp {0ms} |
std::chrono::milliseconds | m_currentTimestamp {0ms} |
uint16_t | m_nextSequence {0} |
std::chrono::milliseconds | m_nextTimestamp {0ms} |
std::chrono::milliseconds | m_bufferLength {0ms} |
std::chrono::milliseconds | m_timeLastSync {0ms} |
std::chrono::milliseconds | m_cardLatency {-1ms} |
std::chrono::milliseconds | m_adjustedLatency {-1ms} |
bool | m_audioStarted {false} |
std::chrono::milliseconds | m_networkLatency {0ms} |
std::chrono::milliseconds | m_clockSkew {0ms} |
QTimer * | m_audioTimer {nullptr} |
uint32_t | m_progressStart {0} |
uint32_t | m_progressCurrent {0} |
uint32_t | m_progressEnd {0} |
QByteArray | m_artwork |
DMAP | m_dmap |
QString | m_nonce |
int | m_id |
bool | m_firstSend {false} |
bool | m_playbackStarted {false} |
Static Private Attributes | |
static EVP_PKEY * | g_devPrivKey = nullptr |
static QString | g_rsaLastError |
Friends | |
class | MythRAOPDevice |
Definition at line 46 of file mythraopconnection.h.
MythRAOPConnection::MythRAOPConnection | ( | QObject * | parent, |
QTcpSocket * | socket, | ||
QByteArray | id, | ||
int | port | ||
) |
Definition at line 76 of file mythraopconnection.cpp.
|
override |
Definition at line 93 of file mythraopconnection.cpp.
bool MythRAOPConnection::Init | ( | void | ) |
Definition at line 203 of file mythraopconnection.cpp.
|
inline |
Definition at line 57 of file mythraopconnection.h.
Referenced by MythRAOPDevice::DeleteAllClients().
|
inline |
Definition at line 58 of file mythraopconnection.h.
|
inline |
Definition at line 59 of file mythraopconnection.h.
|
static |
decodeDMAP:
Usage: decodeDMAP(QByteArray &dmap) Description: decode the DMAP (Digital Media Access Protocol) object. The object returned is a map of the dmap tags and their associated content
Definition at line 1714 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
static |
LoadKey.
Load RSA key into static variable for re-using it later The RSA key is resident in memory for the entire duration of the application as such RSA_free is never called on it.
Definition at line 1599 of file mythraopconnection.cpp.
Referenced by MythRAOPDevice::Create(), Init(), and ProcessRequest().
|
inlinestatic |
Definition at line 62 of file mythraopconnection.h.
|
privateslot |
readClient: signal handler for RAOP client connection Handle initialisation of session
Definition at line 897 of file mythraopconnection.cpp.
Referenced by Init().
|
privateslot |
Socket incoming data signal handler use for audio, control and timing socket.
Definition at line 260 of file mythraopconnection.cpp.
Referenced by Init(), and ProcessRequest().
|
privateslot |
Definition at line 874 of file mythraopconnection.cpp.
Referenced by Init().
|
privateslot |
Definition at line 880 of file mythraopconnection.cpp.
Referenced by StartAudioTimer().
|
privateslot |
Definition at line 1878 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
privateslot |
Definition at line 1888 of file mythraopconnection.cpp.
Referenced by newEventClient().
|
private |
Definition at line 371 of file mythraopconnection.cpp.
Referenced by udpDataReady().
|
private |
SendResendRequest: Request RAOP client to resend missed RTP packets.
Definition at line 451 of file mythraopconnection.cpp.
Referenced by udpDataReady().
|
private |
ExpireResendRequests: Expire resend requests that are older than timestamp.
Those requests are expired when audio with older timestamp has already been played
Definition at line 492 of file mythraopconnection.cpp.
Referenced by ProcessSync(), and ResetAudio().
|
private |
Definition at line 650 of file mythraopconnection.cpp.
Referenced by udpDataReady().
|
private |
Definition at line 840 of file mythraopconnection.cpp.
Referenced by ProcessAudio(), ProcessSync(), and ResetAudio().
|
private |
Definition at line 863 of file mythraopconnection.cpp.
Referenced by CleanUp(), and ProcessRequest().
|
private |
Definition at line 967 of file mythraopconnection.cpp.
Referenced by readClient().
|
staticprivate |
Definition at line 1578 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
private |
Definition at line 1560 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
staticprivate |
Definition at line 1642 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
private |
Definition at line 1732 of file mythraopconnection.cpp.
Referenced by audioRetry(), and ProcessRequest().
|
private |
Definition at line 1784 of file mythraopconnection.cpp.
Referenced by CleanUp(), and CreateDecoder().
|
private |
Definition at line 1793 of file mythraopconnection.cpp.
Referenced by audioRetry(), and ProcessRequest().
|
private |
Definition at line 1829 of file mythraopconnection.cpp.
Referenced by CleanUp(), and OpenAudioDevice().
|
private |
Definition at line 1835 of file mythraopconnection.cpp.
Referenced by OpenAudioDevice().
|
private |
Definition at line 1845 of file mythraopconnection.cpp.
Referenced by audioRetry(), CleanUp(), and OpenAudioDevice().
|
private |
Definition at line 142 of file mythraopconnection.cpp.
Referenced by ~MythRAOPConnection().
|
private |
SendTimeRequest: Send a time request to the RAOP client.
Definition at line 514 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
private |
ProcessTimeResponse: Calculate the network latency, we do not use the reference time send by itunes instead we measure the time lapsed between the request and the response the latency is calculated in ms.
Definition at line 550 of file mythraopconnection.cpp.
Referenced by udpDataReady().
|
staticprivate |
Definition at line 588 of file mythraopconnection.cpp.
Referenced by ProcessTimeResponse().
|
staticprivate |
Definition at line 593 of file mythraopconnection.cpp.
Referenced by SendTimeRequest(), and timevalToNTP().
|
staticprivate |
Definition at line 599 of file mythraopconnection.cpp.
|
staticprivate |
buf | A pointer to the received data. |
type | The type of this packet. |
seq | The sequence number of this packet. This value is not always set. |
timestamp | The frame number of the first frame in this packet. NOT milliseconds. This value is not always set. |
Definition at line 615 of file mythraopconnection.cpp.
Referenced by udpDataReady().
|
private |
AudioCardLatency: Description: Play silence and calculate audio latency between input / output.
Definition at line 1859 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
staticprivate |
Definition at line 1660 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
staticprivate |
stringFromSeconds:
Usage: stringFromSeconds(timeInSeconds) Description: create a string in the format HH:mm:ss from a duration in seconds HH: will not be displayed if there's less than one hour
Definition at line 1686 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
|
private |
framesDuration Description: return the duration in ms of frames
Definition at line 1697 of file mythraopconnection.cpp.
Referenced by ProcessAudio(), ProcessRequest(), ProcessSync(), and udpDataReady().
|
private |
Definition at line 1702 of file mythraopconnection.cpp.
Referenced by ProcessRequest().
Definition at line 1902 of file mythraopconnection.cpp.
Referenced by ProcessRequest(), and ProcessSync().
|
privateslot |
Definition at line 741 of file mythraopconnection.cpp.
Referenced by Init(), and udpDataReady().
|
friend |
Definition at line 50 of file mythraopconnection.h.
|
private |
Definition at line 118 of file mythraopconnection.h.
Referenced by CleanUp(), Init(), ProcessRequest(), and udpDataReady().
|
private |
Definition at line 120 of file mythraopconnection.h.
Referenced by Init(), ProcessRequest(), readClient(), timeout(), and ~MythRAOPConnection().
|
private |
Definition at line 121 of file mythraopconnection.h.
Referenced by Init(), ProcessRequest(), and ~MythRAOPConnection().
|
private |
Definition at line 122 of file mythraopconnection.h.
Referenced by ProcessRequest().
|
private |
Definition at line 123 of file mythraopconnection.h.
Referenced by readClient().
|
private |
Definition at line 124 of file mythraopconnection.h.
Referenced by readClient().
Definition at line 125 of file mythraopconnection.h.
Referenced by readClient().
|
private |
Definition at line 126 of file mythraopconnection.h.
Referenced by readClient().
|
private |
Definition at line 127 of file mythraopconnection.h.
Referenced by ProcessRequest(), SendResendRequest(), and SendTimeRequest().
|
private |
Definition at line 128 of file mythraopconnection.h.
|
private |
Definition at line 129 of file mythraopconnection.h.
Referenced by Init(), and ProcessRequest().
|
private |
Definition at line 130 of file mythraopconnection.h.
Referenced by CleanUp(), ProcessRequest(), SendResendRequest(), and SendTimeRequest().
|
private |
Definition at line 131 of file mythraopconnection.h.
Referenced by ProcessRequest(), and SendResendRequest().
|
private |
Definition at line 132 of file mythraopconnection.h.
Referenced by CleanUp(), ProcessRequest(), and SendTimeRequest().
|
private |
Definition at line 133 of file mythraopconnection.h.
Referenced by ProcessRequest(), and SendTimeRequest().
|
private |
Definition at line 134 of file mythraopconnection.h.
Referenced by ProcessRequest(), and ~MythRAOPConnection().
|
private |
Definition at line 135 of file mythraopconnection.h.
Referenced by ProcessRequest().
|
private |
Definition at line 136 of file mythraopconnection.h.
Referenced by newEventClient(), ProcessRequest(), and ~MythRAOPConnection().
|
private |
Definition at line 139 of file mythraopconnection.h.
Referenced by ExpireResendRequests(), SendResendRequest(), and udpDataReady().
|
private |
Definition at line 141 of file mythraopconnection.h.
Referenced by decodeAudioPacket(), and ProcessRequest().
|
staticprivate |
Definition at line 142 of file mythraopconnection.h.
Referenced by LoadKey(), and ProcessRequest().
|
private |
Definition at line 143 of file mythraopconnection.h.
Referenced by decodeAudioPacket(), and ProcessRequest().
|
private |
Definition at line 145 of file mythraopconnection.h.
Referenced by decodeAudioPacket(), MythRAOPConnection(), and ~MythRAOPConnection().
|
private |
Definition at line 149 of file mythraopconnection.h.
Referenced by decodeAudioPacket(), and ~MythRAOPConnection().
|
staticprivate |
Definition at line 150 of file mythraopconnection.h.
Referenced by LoadKey().
|
private |
Definition at line 152 of file mythraopconnection.h.
Referenced by AudioCardLatency(), audioRetry(), CloseAudioDevice(), OpenAudioDevice(), ProcessAudio(), ProcessRequest(), ProcessSync(), ResetAudio(), and udpDataReady().
|
private |
Definition at line 153 of file mythraopconnection.h.
Referenced by audioRetry(), CreateDecoder(), DestroyDecoder(), and udpDataReady().
|
private |
Definition at line 154 of file mythraopconnection.h.
Referenced by audioRetry(), CreateDecoder(), decodeAudioPacket(), DestroyDecoder(), and udpDataReady().
|
private |
Definition at line 155 of file mythraopconnection.h.
Referenced by CreateDecoder(), and ProcessRequest().
|
private |
Definition at line 156 of file mythraopconnection.h.
Referenced by AudioCardLatency(), CreateDecoder(), OpenAudioDevice(), and ProcessRequest().
|
private |
Definition at line 157 of file mythraopconnection.h.
Referenced by AudioCardLatency(), and ProcessRequest().
|
private |
Definition at line 158 of file mythraopconnection.h.
Referenced by AudioCardLatency(), framesToMs(), MsToFrame(), OpenAudioDevice(), ProcessAudio(), ProcessRequest(), and SendNotification().
|
private |
Definition at line 159 of file mythraopconnection.h.
Referenced by ProcessAudio(), ProcessRequest(), and ProcessSync().
|
private |
Definition at line 160 of file mythraopconnection.h.
Referenced by CleanUp(), Init(), and ProcessAudio().
|
private |
Definition at line 162 of file mythraopconnection.h.
Referenced by ExpireAudio(), ProcessAudio(), ProcessSync(), and udpDataReady().
|
private |
Definition at line 163 of file mythraopconnection.h.
Definition at line 164 of file mythraopconnection.h.
Referenced by ExpireResendRequests(), ProcessAudio(), ProcessRequest(), and udpDataReady().
Definition at line 165 of file mythraopconnection.h.
Referenced by Init(), OpenAudioDevice(), and ProcessRequest().
|
private |
Definition at line 168 of file mythraopconnection.h.
Referenced by SendResendRequest().
|
private |
Definition at line 170 of file mythraopconnection.h.
Referenced by ProcessAudio().
|
private |
Definition at line 171 of file mythraopconnection.h.
Referenced by ProcessAudio(), and ProcessRequest().
|
private |
Definition at line 172 of file mythraopconnection.h.
Referenced by ProcessAudio(), ProcessRequest(), ProcessSync(), and udpDataReady().
|
private |
Definition at line 173 of file mythraopconnection.h.
Referenced by ProcessRequest(), and udpDataReady().
|
private |
Definition at line 174 of file mythraopconnection.h.
Referenced by ProcessRequest(), ProcessSync(), and udpDataReady().
|
private |
Definition at line 175 of file mythraopconnection.h.
Referenced by ProcessAudio(), ProcessRequest(), and ProcessSync().
|
private |
Definition at line 176 of file mythraopconnection.h.
Referenced by ProcessAudio(), and ProcessSync().
|
private |
Definition at line 177 of file mythraopconnection.h.
Referenced by ProcessRequest(), and ProcessSync().
|
private |
Definition at line 178 of file mythraopconnection.h.
Referenced by ProcessAudio(), ProcessRequest(), and ProcessSync().
Definition at line 179 of file mythraopconnection.h.
Referenced by ProcessAudio(), ProcessRequest(), ProcessSync(), and ResetAudio().
|
private |
Definition at line 182 of file mythraopconnection.h.
Referenced by ProcessRequest(), ProcessSync(), and ProcessTimeResponse().
|
private |
Definition at line 186 of file mythraopconnection.h.
Referenced by ProcessTimeResponse().
|
private |
Definition at line 189 of file mythraopconnection.h.
Referenced by StartAudioTimer(), and StopAudioTimer().
|
private |
Definition at line 192 of file mythraopconnection.h.
Referenced by ProcessRequest(), ProcessSync(), and SendNotification().
|
private |
Definition at line 193 of file mythraopconnection.h.
Referenced by ProcessRequest(), ProcessSync(), and SendNotification().
|
private |
Definition at line 194 of file mythraopconnection.h.
Referenced by ProcessRequest(), and SendNotification().
|
private |
Definition at line 195 of file mythraopconnection.h.
Referenced by ProcessRequest(), and SendNotification().
|
private |
Definition at line 196 of file mythraopconnection.h.
Referenced by ProcessRequest(), and SendNotification().
|
private |
Definition at line 199 of file mythraopconnection.h.
Referenced by FinishAuthenticationResponse(), and ProcessRequest().
|
private |
Definition at line 202 of file mythraopconnection.h.
Referenced by SendNotification(), and ~MythRAOPConnection().
Definition at line 203 of file mythraopconnection.h.
Referenced by SendNotification().
Definition at line 204 of file mythraopconnection.h.
Referenced by CleanUp(), and ProcessRequest().