Skip to content

Conversation

@rainey
Copy link

@rainey rainey commented Jun 24, 2025

Prevents an exception when given an SDP with only session-level connection line. Checks against session-level connection info if media-level connection info is not present. Adds an error for case when niether is present.

Intended as a fix for #876

Prevents an exception when given an SDP with only session-level
connection line.
Comment on lines +538 to +541
connection_global = None
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)
if connection_global_line is not None:
connection_global = connection_global_line.group(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest getting rid of the connection_global temp variable in the interest of compactness and understandability.

Suggested change
connection_global = None
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)
if connection_global_line is not None:
connection_global = connection_global_line.group(1)
connection_global_line = re.search(r"c=IN IP[4,6] ([^/\r\n]*)(?:/[0-9]+){0,2}", sdp_global)

Comment on lines +560 to +567
if connection_line is None:
if connection_global is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global, transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if connection_line is None:
if connection_global is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global, transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:
if connection_line is None:
if connection_global_line is None:
return False, "SDP has no session-level connection description, and no connection line in media description {}"\
.format(index)
elif connection_global_line.group(1) != transport_params["destination_ip"]:
return False, "SDP has no connection line for media description {}, and session destination IP {} does not match transport_params: {}" \
.format(index, connection_global_line.group(1), transport_params["destination_ip"])
elif connection_line.group(1) != transport_params["destination_ip"]:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants