Explorar o código

Add SSRC=1 to DtlsSrtp because Chrome

Staz M %!s(int64=4) %!d(string=hai) anos
pai
achega
0fad9c0a16
Modificáronse 2 ficheiros con 19 adicións e 13 borrados
  1. 19 3
      src/dtlssrtptransport.cpp
  2. 0 10
      src/peerconnection.cpp

+ 19 - 3
src/dtlssrtptransport.cpp

@@ -177,9 +177,11 @@ void DtlsSrtpTransport::incoming(message_ptr message) {
 					PLOG_WARNING << "Incoming SRTCP packet is a replay";
 				else if (err == srtp_err_status_auth_fail)
 					PLOG_WARNING << "Incoming SRTCP packet failed authentication check";
-				else
-					PLOG_WARNING << "SRTCP unprotect error, status=" << err << " SSRC=" << ((RTCP_SR*)message->data())->senderSSRC();
-				return;
+				else {
+                    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;
@@ -268,6 +270,20 @@ void DtlsSrtpTransport::postHandshake() {
 	std::memcpy(mServerSessionKey, serverKey, SRTP_AES_128_KEY_LEN);
 	std::memcpy(mServerSessionKey + SRTP_AES_128_KEY_LEN, serverSalt, SRTP_SALT_LEN);
 
+	// Add SSRC=1 as an inbound because that is what Chrome does.
+    srtp_policy_t inbound = {};
+    srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(&inbound.rtp);
+    srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80(&inbound.rtcp);
+    inbound.ssrc.type = ssrc_specific;
+    inbound.ssrc.value = 1;
+    inbound.key = mIsClient ? mServerSessionKey : mClientSessionKey;
+    inbound.next = nullptr;
+
+    if (srtp_err_status_t err = srtp_add_stream(mSrtpIn, &inbound)) {
+        throw std::runtime_error("SRTP add inbound stream failed, status=" +
+                                 to_string(static_cast<int>(err)));
+    }
+
 	mInitDone = true;
 }
 

+ 0 - 10
src/peerconnection.cpp

@@ -549,16 +549,6 @@ void PeerConnection::forwardMedia(message_ptr message) {
 	if (!message)
 		return;
 
-//	if (message->type == Message::Type::Control) {
-//		std::shared_lock lock(mTracksMutex); // read-only
-//		for (auto it = mTracks.begin(); it != mTracks.end(); ++it)
-//			if (auto track = it->second.lock())
-//				return track->incoming(message);
-//
-//		PLOG_WARNING << "No track available to receive control, dropping";
-//		return;
-//	}
-
 	unsigned int ssrc = message->stream;
 	std::optional<string> mid;
 	if (auto it = mMidFromSssrc.find(ssrc); it != mMidFromSssrc.end()) {