#include "third_party/blink/renderer/modules/peerconnection/mock_peer_connection_impl.h"
#include <stddef.h>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "third_party/blink/renderer/modules/peerconnection/mock_data_channel_impl.h"
#include "third_party/blink/renderer/modules/peerconnection/mock_peer_connection_dependency_factory.h"
#include "third_party/blink/renderer/modules/peerconnection/mock_rtc_peer_connection_handler_platform.h"
#include "third_party/blink/renderer/platform/allow_discouraged_type.h"
#include "third_party/webrtc/api/rtp_receiver_interface.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"
_;
AudioTrackInterface;
CreateSessionDescriptionObserver;
DtmfSenderInterface;
DtmfSenderObserverInterface;
IceCandidateInterface;
MediaStreamInterface;
PeerConnectionInterface;
SessionDescriptionInterface;
SetSessionDescriptionObserver;
namespace blink {
class MockStreamCollection : public webrtc::StreamCollectionInterface { … };
class MockDtmfSender : public DtmfSenderInterface { … };
FakeRtpSender::FakeRtpSender(
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track,
std::vector<std::string> stream_ids)
: … { … }
FakeRtpSender::~FakeRtpSender() { … }
bool FakeRtpSender::SetTrack(webrtc::MediaStreamTrackInterface* track) { … }
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> FakeRtpSender::track()
const { … }
rtc::scoped_refptr<webrtc::DtlsTransportInterface>
FakeRtpSender::dtls_transport() const { … }
uint32_t FakeRtpSender::ssrc() const { … }
cricket::MediaType FakeRtpSender::media_type() const { … }
std::string FakeRtpSender::id() const { … }
std::vector<std::string> FakeRtpSender::stream_ids() const { … }
void FakeRtpSender::SetStreams(const std::vector<std::string>& stream_ids) { … }
std::vector<webrtc::RtpEncodingParameters> FakeRtpSender::init_send_encodings()
const { … }
webrtc::RtpParameters FakeRtpSender::GetParameters() const { … }
webrtc::RTCError FakeRtpSender::SetParameters(
const webrtc::RtpParameters& parameters) { … }
rtc::scoped_refptr<webrtc::DtmfSenderInterface> FakeRtpSender::GetDtmfSender()
const { … }
FakeRtpReceiver::FakeRtpReceiver(
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track,
std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>> streams)
: … { … }
FakeRtpReceiver::~FakeRtpReceiver() { … }
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> FakeRtpReceiver::track()
const { … }
rtc::scoped_refptr<webrtc::DtlsTransportInterface>
FakeRtpReceiver::dtls_transport() const { … }
std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>
FakeRtpReceiver::streams() const { … }
std::vector<std::string> FakeRtpReceiver::stream_ids() const { … }
cricket::MediaType FakeRtpReceiver::media_type() const { … }
std::string FakeRtpReceiver::id() const { … }
webrtc::RtpParameters FakeRtpReceiver::GetParameters() const { … }
bool FakeRtpReceiver::SetParameters(const webrtc::RtpParameters& parameters) { … }
void FakeRtpReceiver::SetObserver(
webrtc::RtpReceiverObserverInterface* observer) { … }
void FakeRtpReceiver::SetJitterBufferMinimumDelay(
std::optional<double> delay_seconds) { … }
std::vector<webrtc::RtpSource> FakeRtpReceiver::GetSources() const { … }
FakeRtpTransceiver::FakeRtpTransceiver(
cricket::MediaType media_type,
rtc::scoped_refptr<FakeRtpSender> sender,
rtc::scoped_refptr<FakeRtpReceiver> receiver,
std::optional<std::string> mid,
bool stopped,
webrtc::RtpTransceiverDirection direction,
std::optional<webrtc::RtpTransceiverDirection> current_direction)
: … { … }
FakeRtpTransceiver::~FakeRtpTransceiver() = default;
void FakeRtpTransceiver::ReplaceWith(const FakeRtpTransceiver& other) { … }
cricket::MediaType FakeRtpTransceiver::media_type() const { … }
std::optional<std::string> FakeRtpTransceiver::mid() const { … }
rtc::scoped_refptr<webrtc::RtpSenderInterface> FakeRtpTransceiver::sender()
const { … }
rtc::scoped_refptr<webrtc::RtpReceiverInterface> FakeRtpTransceiver::receiver()
const { … }
bool FakeRtpTransceiver::stopped() const { … }
bool FakeRtpTransceiver::stopping() const { … }
webrtc::RtpTransceiverDirection FakeRtpTransceiver::direction() const { … }
std::optional<webrtc::RtpTransceiverDirection>
FakeRtpTransceiver::current_direction() const { … }
void FakeRtpTransceiver::SetTransport(
rtc::scoped_refptr<webrtc::DtlsTransportInterface> transport) { … }
FakeDtlsTransport::FakeDtlsTransport() { … }
rtc::scoped_refptr<webrtc::IceTransportInterface>
FakeDtlsTransport::ice_transport() { … }
webrtc::DtlsTransportInformation FakeDtlsTransport::Information() { … }
const char MockPeerConnectionImpl::kDummyOffer[] = …;
const char MockPeerConnectionImpl::kDummyAnswer[] = …;
MockPeerConnectionImpl::MockPeerConnectionImpl(
MockPeerConnectionDependencyFactory* factory,
webrtc::PeerConnectionObserver* observer)
: … { … }
MockPeerConnectionImpl::~MockPeerConnectionImpl() { … }
webrtc::RTCErrorOr<rtc::scoped_refptr<webrtc::RtpSenderInterface>>
MockPeerConnectionImpl::AddTrack(
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids) { … }
webrtc::RTCError MockPeerConnectionImpl::RemoveTrackOrError(
rtc::scoped_refptr<webrtc::RtpSenderInterface> s) { … }
std::vector<rtc::scoped_refptr<webrtc::RtpSenderInterface>>
MockPeerConnectionImpl::GetSenders() const { … }
std::vector<rtc::scoped_refptr<webrtc::RtpReceiverInterface>>
MockPeerConnectionImpl::GetReceivers() const { … }
std::vector<rtc::scoped_refptr<webrtc::RtpTransceiverInterface>>
MockPeerConnectionImpl::GetTransceivers() const { … }
webrtc::RTCErrorOr<rtc::scoped_refptr<webrtc::DataChannelInterface>>
MockPeerConnectionImpl::CreateDataChannelOrError(
const std::string& label,
const webrtc::DataChannelInit* config) { … }
bool MockPeerConnectionImpl::GetStats(webrtc::StatsObserver* observer,
webrtc::MediaStreamTrackInterface* track,
StatsOutputLevel level) { … }
void MockPeerConnectionImpl::GetStats(
webrtc::RTCStatsCollectorCallback* callback) { … }
void MockPeerConnectionImpl::GetStats(
rtc::scoped_refptr<webrtc::RtpSenderInterface> selector,
rtc::scoped_refptr<webrtc::RTCStatsCollectorCallback> callback) { … }
void MockPeerConnectionImpl::GetStats(
rtc::scoped_refptr<webrtc::RtpReceiverInterface> selector,
rtc::scoped_refptr<webrtc::RTCStatsCollectorCallback> callback) { … }
void MockPeerConnectionImpl::SetGetStatsReport(webrtc::RTCStatsReport* report) { … }
const webrtc::SessionDescriptionInterface*
MockPeerConnectionImpl::local_description() const { … }
const webrtc::SessionDescriptionInterface*
MockPeerConnectionImpl::remote_description() const { … }
void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { … }
void MockPeerConnectionImpl::CreateOffer(
CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) { … }
void MockPeerConnectionImpl::CreateAnswer(
CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) { … }
void MockPeerConnectionImpl::SetLocalDescriptionWorker(
SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) { … }
void MockPeerConnectionImpl::SetRemoteDescriptionWorker(
SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) { … }
webrtc::RTCError MockPeerConnectionImpl::SetConfiguration(
const RTCConfiguration& configuration) { … }
bool MockPeerConnectionImpl::AddIceCandidate(
const IceCandidateInterface* candidate) { … }
void MockPeerConnectionImpl::AddIceCandidate(
std::unique_ptr<webrtc::IceCandidateInterface> candidate,
std::function<void(webrtc::RTCError)> callback) { … }
}