Quellcode durchsuchen

Added explicit error when there is no local media to negotiate

Paul-Louis Ageneau vor 4 Jahren
Ursprung
Commit
86c0d2687c
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 8 0
      src/impl/peerconnection.cpp

+ 8 - 0
src/impl/peerconnection.cpp

@@ -867,6 +867,11 @@ void PeerConnection::processLocalDescription(Description description) {
 				description.addMedia(std::move(media));
 				description.addMedia(std::move(media));
 			}
 			}
 		}
 		}
+
+		// There might be no media at this point if the user created a Track, deleted it,
+		// then called setLocalDescription().
+		if (description.mediaCount() == 0)
+			throw std::runtime_error("No DataChannel or Track to negotiate");
 	}
 	}
 
 
 	// Set local fingerprint (wait for certificate if necessary)
 	// Set local fingerprint (wait for certificate if necessary)
@@ -874,6 +879,9 @@ void PeerConnection::processLocalDescription(Description description) {
 
 
 	PLOG_VERBOSE << "Issuing local description: " << description;
 	PLOG_VERBOSE << "Issuing local description: " << description;
 
 
+	if (description.mediaCount() == 0)
+		throw std::logic_error("Local description has no media line");
+
 	{
 	{
 		// Set as local description
 		// Set as local description
 		std::lock_guard lock(mLocalDescriptionMutex);
 		std::lock_guard lock(mLocalDescriptionMutex);