Skip to content

Commit

Permalink
Prepare for usrsctp being updated.
Browse files Browse the repository at this point in the history
The signature of send_cb was changed, adding ulp_info. This change makes
it easier to retrieve the SctpTransport pointer from the callback.

Bug: webrtc:11899
Change-Id: I12a4ccd2d0deb329f6be17a4c7208449833dc188
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/182984
Reviewed-by: Harald Alvestrand <[email protected]>
Commit-Queue: Taylor <[email protected]>
Cr-Commit-Position: refs/heads/master@{#32067}
  • Loading branch information
Taylor Brandstetter authored and Commit Bot committed Sep 9, 2020
1 parent 76a627b commit 822283d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions media/sctp/sctp_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ class SctpTransport::UsrSctpWrapper {
struct sctp_rcvinfo rcv,
int flags,
void* ulp_info) {
// Sanity check that both methods of getting the SctpTransport pointer
// yield the same result.
RTC_CHECK_EQ(static_cast<SctpTransport*>(ulp_info),
GetTransportFromSocket(sock));
SctpTransport* transport = static_cast<SctpTransport*>(ulp_info);
int result =
transport->OnDataOrNotificationFromSctp(data, length, rcv, flags);
Expand Down Expand Up @@ -426,6 +430,8 @@ class SctpTransport::UsrSctpWrapper {
return transport;
}

// TODO(crbug.com/webrtc/11899): This is a legacy callback signature, remove
// when usrsctp is updated.
static int SendThresholdCallback(struct socket* sock, uint32_t sb_free) {
// Fired on our I/O thread. SctpTransport::OnPacketReceived() gets
// a packet containing acknowledgments, which goes into usrsctp_conninput,
Expand All @@ -440,6 +446,21 @@ class SctpTransport::UsrSctpWrapper {
transport->OnSendThresholdCallback();
return 0;
}

static int SendThresholdCallback(struct socket* sock,
uint32_t sb_free,
void* ulp_info) {
// Sanity check that both methods of getting the SctpTransport pointer
// yield the same result.
RTC_CHECK_EQ(static_cast<SctpTransport*>(ulp_info),
GetTransportFromSocket(sock));
// Fired on our I/O thread. SctpTransport::OnPacketReceived() gets
// a packet containing acknowledgments, which goes into usrsctp_conninput,
// and then back here.
SctpTransport* transport = static_cast<SctpTransport*>(ulp_info);
transport->OnSendThresholdCallback();
return 0;
}
};

SctpTransport::SctpTransport(rtc::Thread* network_thread,
Expand Down

0 comments on commit 822283d

Please sign in to comment.