From 2b538aecb57dec32aacc27c8f23fd377b03991d4 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 19 Aug 2015 18:02:59 +0200 Subject: QXmppRtpChannel: make it possible to get / set the local SSRC --- src/base/QXmppRtpChannel.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/base/QXmppRtpChannel.cpp') diff --git a/src/base/QXmppRtpChannel.cpp b/src/base/QXmppRtpChannel.cpp index 7c093192..59f18287 100644 --- a/src/base/QXmppRtpChannel.cpp +++ b/src/base/QXmppRtpChannel.cpp @@ -121,6 +121,7 @@ QString QXmppRtpPacket::toString() const QXmppRtpChannel::QXmppRtpChannel() : m_outgoingPayloadNumbered(false) { + m_outgoingSsrc = qrand(); } /// Returns the local payload types. @@ -167,6 +168,23 @@ void QXmppRtpChannel::setRemotePayloadTypes(const QList payloadTypesChanged(); } +/// Returns the local SSRC. + +quint32 QXmppRtpChannel::localSsrc() const +{ + return m_outgoingSsrc; +} + +/// Sets the local SSRC. +/// +/// \param ssrc + +void QXmppRtpChannel::setLocalSsrc(quint32 ssrc) +{ + m_outgoingSsrc = ssrc; +} + + enum CodecId { G711u = 0, GSM = 3, @@ -260,7 +278,6 @@ public: QList outgoingTones; QXmppJinglePayloadType outgoingTonesType; - quint32 outgoingSsrc; QXmppJinglePayloadType payloadType; private: @@ -281,11 +298,9 @@ QXmppRtpAudioChannelPrivate::QXmppRtpAudioChannelPrivate(QXmppRtpAudioChannel *q outgoingSequence(1), outgoingStamp(0), outgoingTimer(0), - outgoingSsrc(0), q(qq) { qRegisterMetaType("QXmppRtpAudioChannel::Tone"); - outgoingSsrc = qrand(); } /// Returns the audio codec for the given payload type. @@ -688,7 +703,7 @@ void QXmppRtpAudioChannel::writeDatagram() packet.type = d->outgoingTonesType.id(); packet.sequence = d->outgoingSequence; packet.stamp = info.outgoingStart; - packet.ssrc = d->outgoingSsrc; + packet.ssrc = localSsrc(); QDataStream output(&packet.payload, QIODevice::WriteOnly); output << quint8(info.tone); @@ -726,7 +741,7 @@ void QXmppRtpAudioChannel::writeDatagram() packet.type = d->payloadType.id(); packet.sequence = d->outgoingSequence; packet.stamp = d->outgoingStamp; - packet.ssrc = d->outgoingSsrc; + packet.ssrc = localSsrc(); // encode audio chunk QDataStream input(chunk); @@ -856,17 +871,14 @@ public: quint8 outgoingId; quint16 outgoingSequence; quint32 outgoingStamp; - quint32 outgoingSsrc; }; QXmppRtpVideoChannelPrivate::QXmppRtpVideoChannelPrivate() : encoder(0), outgoingId(0), outgoingSequence(1), - outgoingStamp(0), - outgoingSsrc(0) + outgoingStamp(0) { - outgoingSsrc = qrand(); } /// Constructs a new RTP video channel with the given \a parent. @@ -1057,7 +1069,7 @@ void QXmppRtpVideoChannel::writeFrame(const QXmppVideoFrame &frame) packet.version = RTP_VERSION; packet.marker = false; packet.type = d->outgoingId; - packet.ssrc = d->outgoingSsrc; + packet.ssrc = localSsrc(); foreach (const QByteArray &payload, d->encoder->handleFrame(frame)) { packet.sequence = d->outgoingSequence++; packet.stamp = d->outgoingStamp; -- cgit v1.2.3