Browse Source

Add processing for SDES packets in PeerConnection::forwardMedia

Filip Klembara 4 years ago
parent
commit
01085e4492
2 changed files with 18 additions and 2 deletions
  1. 11 0
      include/rtc/rtp.hpp
  2. 7 2
      src/peerconnection.cpp

+ 11 - 0
include/rtc/rtp.hpp

@@ -374,6 +374,17 @@ public:
         header.prepareHeader(202, chunkCount, length);
     }
 
+
+    inline unsigned int chunksCount() {
+        uint16_t chunksSize = 4 * (header.length() + 1) - sizeof(header);
+        unsigned int size = 0;
+        unsigned int i = 0;
+        while (size < chunksSize) {
+            size += getChunk(i++)->getSize();
+        }
+        return i;
+    }
+
     inline RTCP_SDES_CHUNK *getChunk(int num) {
         auto base = &_chunks;
         while (num-- > 0) {

+ 7 - 2
src/peerconnection.cpp

@@ -692,10 +692,15 @@ void PeerConnection::forwardMedia(message_ptr message) {
 				ssrcs.insert(rtcpsr->senderSSRC());
 				for (int i = 0; i < rtcpsr->header.reportCount(); ++i)
 					ssrcs.insert(rtcpsr->getReportBlock(i)->getSSRC());
+            } else if (header->payloadType() == 202) {
+                auto sdes = reinterpret_cast<RTCP_SDES *>(header);
+                for (unsigned int i = 0; i < sdes->chunksCount(); i++) {
+                    auto chunk = sdes->getChunk(i);
+                    ssrcs.insert(chunk->ssrc());
+                }
 			} else {
-				// PT=202 == SDES
 				// PT=207 == Extended Report
-				if (header->payloadType() != 202 && header->payloadType() != 207) {
+				if (header->payloadType() != 207) {
 					PLOG_WARNING << "Unknown packet type: " << (int)header->version() << " "
 					             << header->payloadType() << "";
 				}