Skip to content

Commit

Permalink
Bug 1806510 - Vendor libwebrtc from 18408391ad
Browse files Browse the repository at this point in the history
Upstream commit: https://webrtc.googlesource.com/src/+/18408391ad4c947ad1a3eeae424663f15e6346ef
    Keep state internally of connections added to P2PTransportChannel (#4/n)

    P2PTransportChannel currently relies on the ICE controller to keep track of this, even though P2PTransportChannel is actually supposed to hold the mutable connections.

    Reading connections from the ICE controller also leaks some internal state from the ICE controller through the ordering of connections, which isn't strictly part of the interface. This change is a step towards fixing this.

    This change is functionally no-op for now. The internal state will be used behind a field-trial in a future CL. That is also when some tests will be updated to work with the new internal state.

    Bug: webrtc:14367, webrtc:1413
    Change-Id: I6f8c5d805c780411fe940926f192fd2d6ce86d29
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/275081
    Commit-Queue: Sameer Vijaykar <samvi@google.com>
    Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#38080}
  • Loading branch information
Drekabi committed Jan 9, 2023
1 parent 90469cd commit 010540c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions third_party/libwebrtc/README.moz-ff-commit
Original file line number Diff line number Diff line change
Expand Up @@ -17799,3 +17799,6 @@ c898c82884
# MOZ_LIBWEBRTC_SRC=/Users/danielbaker/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
80ed9b8eb9
# MOZ_LIBWEBRTC_SRC=/Users/danielbaker/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
18408391ad
2 changes: 2 additions & 0 deletions third_party/libwebrtc/README.mozilla
Original file line number Diff line number Diff line change
Expand Up @@ -11888,3 +11888,5 @@ libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 202
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T22:54:37.395531.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T22:59:53.109826.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T23:01:12.545588.
17 changes: 13 additions & 4 deletions third_party/libwebrtc/p2p/base/p2p_transport_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ P2PTransportChannel::~P2PTransportChannel() {
std::vector<Connection*> copy(connections().begin(), connections().end());
for (Connection* connection : copy) {
connection->SignalDestroyed.disconnect(this);
ice_controller_->OnConnectionDestroyed(connection);
RemoveConnection(connection);
connection->Destroy();
}
resolvers_.clear();
Expand Down Expand Up @@ -281,6 +281,7 @@ void P2PTransportChannel::AddConnection(Connection* connection) {
LogCandidatePairConfig(connection,
webrtc::IceCandidatePairConfigType::kAdded);

connections_.push_back(connection);
ice_controller_->AddConnection(connection);
}

Expand Down Expand Up @@ -1693,7 +1694,7 @@ void P2PTransportChannel::RemoveConnectionForTest(Connection* connection) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(FindConnection(connection));
connection->SignalDestroyed.disconnect(this);
ice_controller_->OnConnectionDestroyed(connection);
RemoveConnection(connection);
RTC_DCHECK(!FindConnection(connection));
if (selected_connection_ == connection)
selected_connection_ = nullptr;
Expand Down Expand Up @@ -2045,7 +2046,7 @@ void P2PTransportChannel::HandleAllTimedOut() {
update_selected_connection = true;
}
connection->SignalDestroyed.disconnect(this);
ice_controller_->OnConnectionDestroyed(connection);
RemoveConnection(connection);
connection->Destroy();
}

Expand Down Expand Up @@ -2172,7 +2173,7 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
// use it.

// Remove this connection from the list.
ice_controller_->OnConnectionDestroyed(connection);
RemoveConnection(connection);

RTC_LOG(LS_INFO) << ToString() << ": Removed connection " << connection
<< " (" << connections().size() << " remaining)";
Expand All @@ -2193,6 +2194,14 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
}
}

void P2PTransportChannel::RemoveConnection(const Connection* connection) {
RTC_DCHECK_RUN_ON(network_thread_);
auto it = absl::c_find(connections_, connection);
RTC_DCHECK(it != connections_.end());
connections_.erase(it);
ice_controller_->OnConnectionDestroyed(connection);
}

// When a port is destroyed, remove it from our list of ports to use for
// connection attempts.
void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
Expand Down
3 changes: 3 additions & 0 deletions third_party/libwebrtc/p2p/base/p2p_transport_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
int check_receiving_interval() const;
absl::optional<rtc::NetworkRoute> network_route() const override;

void RemoveConnection(const Connection* connection);

// Helper method used only in unittest.
rtc::DiffServCodePoint DefaultDscpValue() const;

Expand Down Expand Up @@ -427,6 +429,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
std::vector<PortInterface*> pruned_ports_ RTC_GUARDED_BY(network_thread_);

Connection* selected_connection_ RTC_GUARDED_BY(network_thread_) = nullptr;
std::vector<Connection*> connections_ RTC_GUARDED_BY(network_thread_);

std::vector<RemoteCandidate> remote_candidates_
RTC_GUARDED_BY(network_thread_);
Expand Down

0 comments on commit 010540c

Please sign in to comment.