Skip to content

webrtc: Return error for datachannel send requests when channel is closed

When a datachannel is closed the appsrc element handling the sending of data is unlinked from the sctpenc that encodes the data as SCTP. Thus, any attempt at sending data after the channel is closed results in a pipeline "not linked" failure.

At the application side it can be hard to guarantee that nothing is sent after the datachannel is closed since the on-close signal is emitted in the webrtc thread and the application might send from another thread. Furthermore the sending is made by pushing to an internal queue in appsrc and the actual flow of data down the pipeline happens in yet another thread (the basesrc thread).

The solution here is to follow the W3C spec and simply don't allow anything to be sent unless the channel is not in "open" state. For this to work we have to return an error when data could not be sent. This requires a signature change of "send-data" and "send-string", which means a breaking change so instead we deprecate them and introduce "send-string-full" and "send-data-full".

Edited by Johan Sternerup

Merge request reports