webrtc
webrtc copied to clipboard
Consolidate setting up streams for RTPReceiver
Summary
There are two (or three) different paths to initialise streams of RTPReceiver. This request is for consolidation/simplification.
Motivation
Simplification/Consolidation.
Describe alternatives you've considered
There are three cases to consider while initialising streams of RTPReceiver.
- Undeclared SSRC: SDP does not have SSRC or MID/RID and there is only one media description.
- Declared SSRC: SDP has SSRC. May or may not have MID/RID.
- Declared MID/RID: SDP has MID/RID. May or may not have SSRC.
Precedence
- If MID/RID is in SDP (even if there are SSRCs), that path is used to initialise streams.
- SSRC in SDP.
- Undeclared SSRC: This is a special case.
For case #2 above, streams are initialised first whereas in the other two cases, streams are initialised in handleIncomingSSRC when first packet(s) of an RTP stream is(are) received.
To simplify, even case #2 can be done in handleIncomingSSRC. startRTP can just be used to set up undeclaredMediaProcessor (although the naming might have to change) and start SCTP. All the RTP streams can be initialised in undeclaredMediaProcessor and handleIncomingSSRC. This will provide a unified flow for setting up streams for all cases.
Additional context
Original bug that triggered work on splitting configuring receive and starting receive - https://github.com/pion/webrtc/issues/2054 Comment in the PR that addressed the bug where this was originally proposed - https://github.com/pion/webrtc/pull/2087#issuecomment-1013722593