Fixed broken switching when using different payload types in Streaming plugin #2692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes a broken behaviour I discovered in the Streaming plugin when using the switching functionality. The plugin allows you to dynamically "switch" to a different mountpoint you subscribed to initially, assuming the same codecs are used: this can be used to easily "change channel" when using the Streaming plugin, without using a new PeerConnection or renegotiating the existing one (as far as the browser is concerned, it's the same stream, as the plugin will fix RTP headers to make the transition seamless).
This usually works nicely in both Streaming plugin and VideoRoom, but in the Streaming plugin this breaks if the mountpoint you're leaving and the one you're moving to don't use the same payload types. In that case, if e.g. you're expecting payload type X for VP8 because that's what subscribing to the first mountpoint offered you in the SDP, if the mountpoint you switch to uses payload type Y for VP8, then you'll start receiving RTP packets with payload type Y, and the browser will obviously ignore them and video will stop working, even though it's still VP8. This patch fixes this behaviour, by basically keeping track of which payload types were assigned to a subscriber PeerConnection, and overwrite payload types accordingly when sending that subscriber RTP packets no matter the source (old or new mountpoint).
Notice that this is only an issue in the Streaming plugin. The VideoRoom implements the feature differently (payload types are always overwritten, and are always the same for the same codec), and so is not affected.