Merge pull request #2756 from pipecat-ai/filipi/esp32

SDP munging fixes.
This commit is contained in:
Filipi da Silva Fuchter
2025-10-01 16:05:47 -03:00
committed by GitHub
2 changed files with 8 additions and 5 deletions

View File

@@ -301,6 +301,7 @@ def _smallwebrtc_sdp_cleanup_ice_candidates(text: str, pattern: str) -> str:
Returns: Returns:
Cleaned SDP text with filtered ICE candidates. Cleaned SDP text with filtered ICE candidates.
""" """
logger.debug("Removing unsupported ICE candidates from SDP")
result = [] result = []
lines = text.splitlines() lines = text.splitlines()
for line in lines: for line in lines:
@@ -309,7 +310,7 @@ def _smallwebrtc_sdp_cleanup_ice_candidates(text: str, pattern: str) -> str:
result.append(line) result.append(line)
else: else:
result.append(line) result.append(line)
return "\r\n".join(result) return "\r\n".join(result) + "\r\n"
def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str: def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str:
@@ -321,15 +322,16 @@ def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str:
Returns: Returns:
SDP text with sha-384 and sha-512 fingerprints removed. SDP text with sha-384 and sha-512 fingerprints removed.
""" """
logger.debug("Removing unsupported fingerprints from SDP")
result = [] result = []
lines = text.splitlines() lines = text.splitlines()
for line in lines: for line in lines:
if not re.search("sha-384", line) and not re.search("sha-512", line): if not re.search("sha-384", line) and not re.search("sha-512", line):
result.append(line) result.append(line)
return "\r\n".join(result) return "\r\n".join(result) + "\r\n"
def smallwebrtc_sdp_munging(sdp: str, host: str) -> str: def smallwebrtc_sdp_munging(sdp: str, host: Optional[str]) -> str:
"""Apply SDP modifications for SmallWebRTC compatibility. """Apply SDP modifications for SmallWebRTC compatibility.
Args: Args:
@@ -340,7 +342,8 @@ def smallwebrtc_sdp_munging(sdp: str, host: str) -> str:
Modified SDP string with fingerprint and ICE candidate cleanup. Modified SDP string with fingerprint and ICE candidate cleanup.
""" """
sdp = _smallwebrtc_sdp_cleanup_fingerprints(sdp) sdp = _smallwebrtc_sdp_cleanup_fingerprints(sdp)
sdp = _smallwebrtc_sdp_cleanup_ice_candidates(sdp, host) if host:
sdp = _smallwebrtc_sdp_cleanup_ice_candidates(sdp, host)
return sdp return sdp

View File

@@ -180,7 +180,7 @@ class SmallWebRTCRequestHandler:
answer = pipecat_connection.get_answer() answer = pipecat_connection.get_answer()
if self._esp32_mode and self._host and self._host != "localhost": if self._esp32_mode:
from pipecat.runner.utils import smallwebrtc_sdp_munging from pipecat.runner.utils import smallwebrtc_sdp_munging
answer["sdp"] = smallwebrtc_sdp_munging(answer["sdp"], self._host) answer["sdp"] = smallwebrtc_sdp_munging(answer["sdp"], self._host)