Fixed track DSCP

This commit is contained in:
Paul-Louis Ageneau
2020-11-21 12:28:52 +01:00
parent f098019c1f
commit 14918c16e8
8 changed files with 27 additions and 22 deletions

View File

@ -43,7 +43,7 @@ struct RTC_CPP_EXPORT Message : binary {
Type type; Type type;
unsigned int stream = 0; // Stream id (SCTP stream or SSRC) unsigned int stream = 0; // Stream id (SCTP stream or SSRC)
int dscp = 0; // Differentiated Services Code Point unsigned int dscp = 0; // Differentiated Services Code Point
std::shared_ptr<Reliability> reliability; std::shared_ptr<Reliability> reliability;
}; };

View File

@ -80,14 +80,10 @@ public:
void setTimestamp(uint32_t i) { _timestamp = htonl(i); } void setTimestamp(uint32_t i) { _timestamp = htonl(i); }
void log() { void log() {
PLOG_VERBOSE << "RTP V: " << (int) version() PLOG_VERBOSE << "RTP V: " << (int)version() << " P: " << (padding() ? "P" : " ")
<< " P: " << (padding() ? "P" : " ") << " X: " << (extension() ? "X" : " ") << " CC: " << (int)csrcCount()
<< " X: " << (extension() ? "X" : " ") << " M: " << (marker() ? "M" : " ") << " PT: " << (int)payloadType()
<< " CC: " << (int) csrcCount() << " SEQNO: " << seqNumber() << " TS: " << timestamp();
<< " M: " << (marker() ? "M" : " ")
<< " PT: " << (int) payloadType()
<< " SEQNO: " << seqNumber()
<< " TS: " << timestamp();
} }
}; };
@ -199,9 +195,9 @@ public:
inline void log() const { inline void log() const {
PLOG_VERBOSE << "RTCP header: " PLOG_VERBOSE << "RTCP header: "
<< "version=" << unsigned(version()) << ", padding=" << padding() << "version=" << unsigned(version()) << ", padding=" << padding()
<< ", reportCount=" << unsigned(reportCount()) << ", reportCount=" << unsigned(reportCount())
<< ", payloadType=" << unsigned(payloadType()) << ", length=" << length(); << ", payloadType=" << unsigned(payloadType()) << ", length=" << length();
} }
}; };
@ -428,7 +424,7 @@ public:
public: public:
void preparePacket(SSRC ssrc, unsigned int discreteSeqNoCount) { void preparePacket(SSRC ssrc, unsigned int discreteSeqNoCount) {
header.header.prepareHeader(205, 1, 2 + static_cast<uint16_t>(discreteSeqNoCount)); header.header.prepareHeader(205, 1, 2 + uint16_t(discreteSeqNoCount));
header.setMediaSourceSSRC(ssrc); header.setMediaSourceSSRC(ssrc);
header.setPacketSenderSSRC(ssrc); header.setPacketSenderSSRC(ssrc);
} }

View File

@ -142,8 +142,13 @@ bool DtlsSrtpTransport::sendMedia(message_ptr message) {
message->resize(size); message->resize(size);
// DSCP is set by Track according to the type if (message->dscp == 0) { // Track might override the value
return outgoing(message); // Set recommended medium-priority DSCP value
// See https://tools.ietf.org/html/draft-ietf-tsvwg-rtcweb-qos-18
message->dscp = 36; // AF42: Assured Forwarding class 4, medium drop probability
}
return Transport::outgoing(message); // bypass DTLS DSCP marking
} }
void DtlsSrtpTransport::incoming(message_ptr message) { void DtlsSrtpTransport::incoming(message_ptr message) {

View File

@ -145,7 +145,9 @@ void DtlsTransport::incoming(message_ptr message) {
} }
bool DtlsTransport::outgoing(message_ptr message) { bool DtlsTransport::outgoing(message_ptr message) {
message->dscp = mCurrentDscp; if (message->dscp == 0)
message->dscp = mCurrentDscp;
return Transport::outgoing(std::move(message)); return Transport::outgoing(std::move(message));
} }
@ -427,7 +429,9 @@ void DtlsTransport::incoming(message_ptr message) {
} }
bool DtlsTransport::outgoing(message_ptr message) { bool DtlsTransport::outgoing(message_ptr message) {
message->dscp = mCurrentDscp; if (message->dscp == 0)
message->dscp = mCurrentDscp;
return Transport::outgoing(std::move(message)); return Transport::outgoing(std::move(message));
} }

View File

@ -63,7 +63,7 @@ protected:
Queue<message_ptr> mIncomingQueue; Queue<message_ptr> mIncomingQueue;
std::thread mRecvThread; std::thread mRecvThread;
std::atomic<int> mCurrentDscp; std::atomic<unsigned int> mCurrentDscp;
#if USE_GNUTLS #if USE_GNUTLS
gnutls_session_t mSession; gnutls_session_t mSession;

View File

@ -223,7 +223,7 @@ bool IceTransport::send(message_ptr message) {
bool IceTransport::outgoing(message_ptr message) { bool IceTransport::outgoing(message_ptr message) {
// Explicit Congestion Notification takes the least-significant 2 bits of the DS field // Explicit Congestion Notification takes the least-significant 2 bits of the DS field
int ds = message->dscp << 2; int ds = int(message->dscp << 2);
return juice_send_diffserv(mAgent.get(), reinterpret_cast<const char *>(message->data()), return juice_send_diffserv(mAgent.get(), reinterpret_cast<const char *>(message->data()),
message->size(), ds) >= 0; message->size(), ds) >= 0;
} }
@ -623,7 +623,7 @@ bool IceTransport::outgoing(message_ptr message) {
if (mOutgoingDscp != message->dscp) { if (mOutgoingDscp != message->dscp) {
mOutgoingDscp = message->dscp; mOutgoingDscp = message->dscp;
// Explicit Congestion Notification takes the least-significant 2 bits of the DS field // Explicit Congestion Notification takes the least-significant 2 bits of the DS field
int ds = message->dscp << 2; int ds = int(message->dscp << 2);
nice_agent_set_stream_tos(mNiceAgent.get(), mStreamId, ds); // ToS is the legacy name for DS nice_agent_set_stream_tos(mNiceAgent.get(), mStreamId, ds); // ToS is the legacy name for DS
} }
return nice_agent_send(mNiceAgent.get(), mStreamId, 1, message->size(), return nice_agent_send(mNiceAgent.get(), mStreamId, 1, message->size(),

View File

@ -101,7 +101,7 @@ private:
std::thread mMainLoopThread; std::thread mMainLoopThread;
guint mTimeoutId = 0; guint mTimeoutId = 0;
std::mutex mOutgoingMutex; std::mutex mOutgoingMutex;
int mOutgoingDscp; unsigned int mOutgoingDscp;
static string AddressToString(const NiceAddress &addr); static string AddressToString(const NiceAddress &addr);

View File

@ -155,7 +155,7 @@ void Track::incoming(message_ptr message) {
void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) { void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) {
mRtcpHandler = std::move(handler); mRtcpHandler = std::move(handler);
if (mRtcpHandler) { if (mRtcpHandler) {
mRtcpHandler->onOutgoing([&]([[maybe_unused]] const rtc::message_ptr &message) { mRtcpHandler->onOutgoing([&]([[maybe_unused]] message_ptr message) {
#if RTC_ENABLE_MEDIA #if RTC_ENABLE_MEDIA
auto transport = mDtlsSrtpTransport.lock(); auto transport = mDtlsSrtpTransport.lock();
if (!transport) if (!transport)