Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_buffered_amount() to WebRTCDataChannel #50658

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Jul 20, 2021

This methods gives access to RTCDataChannel.bufferedAmount - see:

https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/bufferedAmount

This can be useful for checking if SCTP is buffering data (possibly due to its flow control kicking in) and then waiting to send more data until the buffer clears.

This comment on DataChannelInterface::Send() is a really good explanation of the motivation for this:

  // Sends |data| to the remote peer. If the data can't be sent at the SCTP
  // level (due to congestion control), it's buffered at the data channel level,
  // up to a maximum of 16MB. If Send is called while this buffer is full, the
  // data channel will be closed abruptly.
  //
  // So, it's important to use buffered_amount() and OnBufferedAmountChange to
  // ensure the data channel is used efficiently but without filling this
  // buffer.
  virtual bool Send(const DataBuffer& buffer) = 0;

https://github.com/maitrungduc1410/webrtc/blob/master/api/data_channel_interface.h#L191

This won't cleanly cherry-pick to 3.x and requires some minor changes, so I'll make a separate PR.

I'll also make a PR to the GDNative plugin, but I'm not sure how the GDNative part will work with backward compatibility? This changes the godot_net_webrtc_data_channel struct which will cause old version of the GDNative plugin to not work until updated, and also updated versions of the GDNative plugin won't work with older versions of Godot.

Copy link
Collaborator

@Faless Faless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, great job! 🏆

@Faless Faless merged commit ff85bbc into godotengine:master Jul 21, 2021
@Faless
Copy link
Collaborator

Faless commented Jul 21, 2021

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants