Browse Source

Added explicit error when there is no local media to negotiate

Paul-Louis Ageneau 3 years ago
parent
commit
86c0d2687c
1 changed files with 8 additions and 0 deletions
  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));
 			}
 		}
+
+		// 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)
@@ -874,6 +879,9 @@ void PeerConnection::processLocalDescription(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
 		std::lock_guard lock(mLocalDescriptionMutex);