webrtc: do not tear down data channel before data is flushed
authorDaniel Moberg <daniemob@axis.com>
Tue, 18 Apr 2023 09:21:05 +0000 (11:21 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 15 May 2023 07:09:36 +0000 (08:09 +0100)
commit5add11ffbc06edb573991ac76a72d8dd8f0ea336
tree85ae366e3d7fadc6d5a90c32c479ec9d88fc0bf8
parent35db71f88a02c455f3d73f270a33df87f799b0ce
webrtc: do not tear down data channel before data is flushed

Current implementation can in some cases detect
that all data is sent but in reality it is not,
leading to a push to an unlinked pad.
This is a race between the probe used to track data sent and a
call to close.

This patch sends an EOS before starting the close procedure
and then waits for the EOS event to come through to the
src pad before commencing with tear down.
This ensures that any queued data before EOS is flushed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4633>
subprojects/gst-plugins-bad/ext/webrtc/webrtcdatachannel.c