for sdp_index, media in enumerate(proposed_remote_sdp.media):
if sdp_index == session._audio_sdp_index and session.audio_transport is not None:
if media.media != "audio":
inv.respond_to_reinvite(488)
return
if media.port == 0:
remove_audio = True
elif sdp_index == session._chat_sdp_index and session.audio_transport is not None:
if media.media != "message":
inv.respond_to_reinvite(488)
return
if media.port == 0:
remove_chat = True
elif media.media == "audio" and session.audio_transport is None and media.port != 0:
add_audio = True
elif media.media == "message" and session.chat_transport is None and media.port != 0:
add_chat = True
if any([add_audio, add_chat]):
if any([remove_audio, remove_chat]):
# We don't support adding AND removing a stream in the same proposal
inv.respond_to_reinvite(488)
return
inv.respond_to_reinvite(180)
session._change_state("PROPOSED")
self.notification_center.post_notification("SCSessionGotStreamProposal", session, TimestampedNotificationData(streams=[stream for is_added, stream in zip([add_audio, add_chat], ["audio", "chat"]) if is_added], proposer="remote"))