Browse Source

Disabled RTX because Firefox; Fixed a typo causing things to identify as SSRC=0

Staz M 4 years ago
parent
commit
8dbcd155e5
4 changed files with 26 additions and 12 deletions
  1. 4 3
      include/rtc/rtp.hpp
  2. 11 4
      src/description.cpp
  3. 3 3
      src/dtlssrtptransport.cpp
  4. 8 2
      src/peerconnection.cpp

+ 4 - 3
include/rtc/rtp.hpp

@@ -215,7 +215,7 @@ struct RTCP_FB_HEADER {
 
 struct RTCP_SR {
     RTCP_HEADER header;
-    SSRC senderSSRC;
+    SSRC _senderSSRC;
 
 private:
     uint64_t _ntpTimestamp;
@@ -230,7 +230,7 @@ public:
         unsigned int length =
                 ((sizeof(header) + 24 + reportCount * sizeof(RTCP_ReportBlock)) / 4) - 1;
         header.prepareHeader(200, reportCount, uint16_t(length));
-        this->senderSSRC = htonl(senderSSRC);
+        this->_senderSSRC = htonl(senderSSRC);
     }
 
     inline RTCP_ReportBlock *getReportBlock(int num) { return &_reportBlocks + num; }
@@ -245,6 +245,7 @@ public:
     inline uint32_t rtpTimestamp() const { return ntohl(_rtpTimestamp); }
     inline uint32_t packetCount() const { return ntohl(_packetCount); }
     inline uint32_t octetCount() const { return ntohl(_octetCount); }
+    inline uint32_t senderSSRC() const {return ntohl(_senderSSRC);}
 
     inline void setNtpTimestamp(uint32_t ts) { _ntpTimestamp = htonll(ts); }
     inline void setRtpTimestamp(uint32_t ts) { _rtpTimestamp = htonl(ts); }
@@ -252,7 +253,7 @@ public:
     inline void log() const {
         header.log();
         PLOG_VERBOSE << "RTCP SR: "
-                   << " SSRC=" << ntohl(senderSSRC) << ", NTP_TS=" << ntpTimestamp()
+                   << " SSRC=" << senderSSRC() << ", NTP_TS=" << ntpTimestamp()
                    << ", RTP_TS=" << rtpTimestamp() << ", packetCount=" << packetCount()
                    << ", octetCount=" << octetCount();
 

+ 11 - 4
src/description.cpp

@@ -611,10 +611,17 @@ void Description::Video::addVideoCodec(int payloadType, const string &codec) {
 	addRTPMap(map);
 
 //	// RTX Packets
-    RTPMap rtx(std::to_string(payloadType+1) + " RTX/90000");
-    // TODO rtx-time is how long can a request be stashed for before needing to resend it. Needs to be parameterized
-    rtx.addAttribute("apt=" + std::to_string(payloadType) + ";rtx-time=3000");
-    addRTPMap(rtx);
+/* TODO
+ *  TIL that Firefox does not properly support the negotiation of RTX! It works, but doesn't negotiate the SSRC so
+ *  we have no idea what SSRC is RTX going to be. Three solutions:
+ *  One) we don't negotitate it and (maybe) break RTX support with Edge.
+ *  Two) we do negotiate it and rebuild the original packet before we send it distribute it to each track.
+ *  Three) we complain to mozilla. This one probably won't do much.
+*/
+//    RTPMap rtx(std::to_string(payloadType+1) + " rtx/90000");
+//    // TODO rtx-time is how long can a request be stashed for before needing to resend it. Needs to be parameterized
+//    rtx.addAttribute("apt=" + std::to_string(payloadType) + ";rtx-time=3000");
+//    addRTPMap(rtx);
 }
 
 void Description::Audio::addAudioCodec(int payloadType, const string &codec) {

+ 3 - 3
src/dtlssrtptransport.cpp

@@ -178,13 +178,13 @@ void DtlsSrtpTransport::incoming(message_ptr message) {
 				else if (err == srtp_err_status_auth_fail)
 					PLOG_WARNING << "Incoming SRTCP packet failed authentication check";
 				else
-					PLOG_WARNING << "SRTCP unprotect error, status=" << err;
+					PLOG_WARNING << "SRTCP unprotect error, status=" << err << " SSRC=" << ((RTCP_SR*)message->data())->senderSSRC();
 				return;
 			}
 			PLOG_VERBOSE << "Unprotected SRTCP packet, size=" << size;
 			message->type = Message::Type::Control;
             auto rtp = (RTCP_SR*) message->data();
-			message->stream = ntohl(rtp->senderSSRC);
+			message->stream = rtp->senderSSRC();
 		} else {
 			PLOG_VERBOSE << "Incoming SRTP packet, size=" << size;
 			if (srtp_err_status_t err = srtp_unprotect(mSrtpIn, message->data(), &size)) {
@@ -193,7 +193,7 @@ void DtlsSrtpTransport::incoming(message_ptr message) {
 				else if (err == srtp_err_status_auth_fail)
 					PLOG_WARNING << "Incoming SRTP packet failed authentication check";
 				else
-					PLOG_WARNING << "SRTP unprotect error, status=" << err;
+					PLOG_WARNING << "SRTP unprotect error, status=" << err << " SSRC=" << ((RTP*)message->data())->ssrc();
 				return;
 			}
 			PLOG_VERBOSE << "Unprotected SRTP packet, size=" << size;

+ 8 - 2
src/peerconnection.cpp

@@ -695,6 +695,7 @@ void PeerConnection::openTracks() {
 		auto srtpTransport = std::reinterpret_pointer_cast<DtlsSrtpTransport>(transport);
 		std::shared_lock lock(mTracksMutex); // read-only
 //		for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
+        if (mTrackLines.size() == remoteDescription()->mediaCount()) {
         for (unsigned int i = 0; i < mTrackLines.size(); i++) {
             if (auto track = mTrackLines[i].lock()) {
                 if (!track->isOpen()) {
@@ -702,14 +703,19 @@ void PeerConnection::openTracks() {
 //                        srtpTransport->addInboundSSRC(0);
 //                    if (track->description().direction() == rtc::Description::Direction::SendOnly || track->description().direction() == rtc::Description::Direction::SendRecv)
 
-                    for (auto ssrc : track->description().getSSRCs())
+                    for (auto ssrc : track->description().getSSRCs()) {
+                        PLOG_DEBUG << "Adding " << ssrc << " to list";
                         srtpTransport->addSSRC(ssrc);
-                    for (auto ssrc : std::get<rtc::Description::Media *>(remoteDescription()->media(i))->getSSRCs())
+                    }
+                    for (auto ssrc : std::get<rtc::Description::Media *>(remoteDescription()->media(i))->getSSRCs()) {
+                        PLOG_DEBUG << "Adding " << ssrc << " to list";
                         srtpTransport->addSSRC(ssrc);
+                    }
 
                     track->open(srtpTransport);
                 }
             }
+            }
         }
 	}
 #endif