webrtc/pc/peer_connection_internal.h
Tomas Gunnarsson bfd9ba8802 Fix unsafe variable access in RTCStatsCollector
With this change, all production callers of BaseChannel::transport_name()
will be making the call from the right thread and we can safely delegate
the call to the transport itself. Some tests still need to be updated.
This facilitates the main goal of not needing synchronization inside
of the channel classes, being able to apply thread checks and eventually
remove thread hops from the channel classes.

A downside of this particular change is that a blocking call to the
network thread from the signaling thread inside of RTCStatsCollector
needs to be done. This is done once though and fixes a race.

Bug: webrtc:12601, webrtc:11687, webrtc:12644
Change-Id: I85f34f3341a06da9a9efd936b1d36722b10ec487
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213080
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33775}
2021-04-19 16:22:23 +00:00

87 lines
3.1 KiB
C++

/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef PC_PEER_CONNECTION_INTERNAL_H_
#define PC_PEER_CONNECTION_INTERNAL_H_
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "api/peer_connection_interface.h"
#include "call/call.h"
#include "pc/rtp_transceiver.h"
#include "pc/sctp_data_channel.h"
namespace webrtc {
// Internal interface for extra PeerConnection methods.
class PeerConnectionInternal : public PeerConnectionInterface {
public:
virtual rtc::Thread* network_thread() const = 0;
virtual rtc::Thread* worker_thread() const = 0;
// The SDP session ID as defined by RFC 3264.
virtual std::string session_id() const = 0;
// Returns true if we were the initial offerer.
virtual bool initial_offerer() const = 0;
virtual std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const = 0;
virtual sigslot::signal1<SctpDataChannel*>&
SignalSctpDataChannelCreated() = 0;
// Call on the network thread to fetch stats for all the data channels.
// TODO(tommi): Make pure virtual after downstream updates.
virtual std::vector<DataChannelStats> GetDataChannelStats() const {
return {};
}
virtual absl::optional<std::string> sctp_transport_name() const = 0;
virtual absl::optional<std::string> sctp_mid() const = 0;
virtual cricket::CandidateStatsList GetPooledCandidateStats() const = 0;
// Returns a map from transport name to transport stats for all given
// transport names.
// Must be called on the network thread.
virtual std::map<std::string, cricket::TransportStats>
GetTransportStatsByNames(const std::set<std::string>& transport_names) = 0;
virtual Call::Stats GetCallStats() = 0;
virtual bool GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) = 0;
virtual std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
const std::string& transport_name) = 0;
// Returns true if there was an ICE restart initiated by the remote offer.
virtual bool IceRestartPending(const std::string& content_name) const = 0;
// Returns true if the ICE restart flag above was set, and no ICE restart has
// occurred yet for this transport (by applying a local description with
// changed ufrag/password). If the transport has been deleted as a result of
// bundling, returns false.
virtual bool NeedsIceRestart(const std::string& content_name) const = 0;
// Get SSL role for an arbitrary m= section (handles bundling correctly).
virtual bool GetSslRole(const std::string& content_name,
rtc::SSLRole* role) = 0;
};
} // namespace webrtc
#endif // PC_PEER_CONNECTION_INTERNAL_H_