Skip to content

Instantly share code, notes, and snippets.

@robin-raymond
Last active October 25, 2017 17:48
Show Gist options
  • Save robin-raymond/cf961ce2a3f16dc28982460ed7f4b2a1 to your computer and use it in GitHub Desktop.
Save robin-raymond/cf961ce2a3f16dc28982460ed7f4b2a1 to your computer and use it in GitHub Desktop.
  1. If SSRC is present in SSRC table, forward RTP packet immediately to associated RtpReceiver
  2. Extract MID from RTP packet, search MuxID table for existing RtpReceiver; if match found add SSRC to SSRC table to point to RtpReceiver, forward immediately to RtpReceiver;
  3. In order of RtpReceiver object receive() being called, search for SSRC match inside encoding parameters as well as rtx.ssrc and fec.ssrc (if set). If match found add SSRC to SSRC table to point to RtpReceiver, forward immediately to RtpReceiver;
  4. In order of RtpReceiver object receive() being called (all checks done in same step):
  • If encodings array is specified, search each encoding:
    • If encodings[n].payloadTypee is specified, ensure a match of the incoming payload type matches (if not RTX/FEC codec).
    • If the incoming payload type codec is an RTX codec, ensure encodings[n].rtx is set.
    • If the incoming payload typecodec is an FEC codec, ensure the encodings[n].fec is set.
    • If encodings[n].payloadTypes is NOT specified, ensure the codec is a memeber of the codec list.
    • If any of the above is true, make a copy of the encodings[n] and fill in respective copy encodings[n].payloadType, and encodings[n].ssrc, or encodings[n].rtx.ssrc, or encodings[n].fec.ssrc as appropriate and prevent any latchings to this same encoding where a direct payload/SSRC match to the filled in copied information is not present. Add SSRC to SSRC table pointing to RtpReceiver. This can allow independent latching of media codecs, RTX codecs and FEC codes to the same encoding.
  • If encodings array is empty, latch all inconing payload types types where the payload is a member of the receiver's codec list. Add SSRC to SSRC table pointing to RtpReceiver.

Additional note: When expiring SSRCs from SSRC table, the RtpReceiver's where copied information was filled via a latch in would become purged. For example, if the codec payload type and SSRC were filled into the copied information, both would expire and revert to the value contained in the original encoding. Media codecs, RTX and FEC SSRCS/codec values are independently expired from SSRC tables if they do not sure the same SSRC value.

NOTE

Assumption is all RtpReceivers can only have unique MuxIDs and SSRCs although no error is dispatched if the RtpReceivers overlap values.

@robin-raymond
Copy link
Author

Updated to address ^

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