xref: /aosp_15_r20/external/webrtc/media/engine/fake_webrtc_call.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #include "media/engine/fake_webrtc_call.h"
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker #include <utility>
14*d9f75844SAndroid Build Coastguard Worker 
15*d9f75844SAndroid Build Coastguard Worker #include "absl/algorithm/container.h"
16*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h"
17*d9f75844SAndroid Build Coastguard Worker #include "api/call/audio_sink.h"
18*d9f75844SAndroid Build Coastguard Worker #include "media/base/media_channel.h"
19*d9f75844SAndroid Build Coastguard Worker #include "modules/rtp_rtcp/source/rtp_util.h"
20*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h"
21*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/gunit.h"
22*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/thread.h"
23*d9f75844SAndroid Build Coastguard Worker #include "video/config/encoder_stream_factory.h"
24*d9f75844SAndroid Build Coastguard Worker 
25*d9f75844SAndroid Build Coastguard Worker namespace cricket {
26*d9f75844SAndroid Build Coastguard Worker 
27*d9f75844SAndroid Build Coastguard Worker using ::webrtc::ParseRtpSsrc;
28*d9f75844SAndroid Build Coastguard Worker 
FakeAudioSendStream(int id,const webrtc::AudioSendStream::Config & config)29*d9f75844SAndroid Build Coastguard Worker FakeAudioSendStream::FakeAudioSendStream(
30*d9f75844SAndroid Build Coastguard Worker     int id,
31*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioSendStream::Config& config)
32*d9f75844SAndroid Build Coastguard Worker     : id_(id), config_(config) {}
33*d9f75844SAndroid Build Coastguard Worker 
Reconfigure(const webrtc::AudioSendStream::Config & config,webrtc::SetParametersCallback callback)34*d9f75844SAndroid Build Coastguard Worker void FakeAudioSendStream::Reconfigure(
35*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioSendStream::Config& config,
36*d9f75844SAndroid Build Coastguard Worker     webrtc::SetParametersCallback callback) {
37*d9f75844SAndroid Build Coastguard Worker   config_ = config;
38*d9f75844SAndroid Build Coastguard Worker   webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK());
39*d9f75844SAndroid Build Coastguard Worker }
40*d9f75844SAndroid Build Coastguard Worker 
GetConfig() const41*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioSendStream::Config& FakeAudioSendStream::GetConfig() const {
42*d9f75844SAndroid Build Coastguard Worker   return config_;
43*d9f75844SAndroid Build Coastguard Worker }
44*d9f75844SAndroid Build Coastguard Worker 
SetStats(const webrtc::AudioSendStream::Stats & stats)45*d9f75844SAndroid Build Coastguard Worker void FakeAudioSendStream::SetStats(
46*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioSendStream::Stats& stats) {
47*d9f75844SAndroid Build Coastguard Worker   stats_ = stats;
48*d9f75844SAndroid Build Coastguard Worker }
49*d9f75844SAndroid Build Coastguard Worker 
50*d9f75844SAndroid Build Coastguard Worker FakeAudioSendStream::TelephoneEvent
GetLatestTelephoneEvent() const51*d9f75844SAndroid Build Coastguard Worker FakeAudioSendStream::GetLatestTelephoneEvent() const {
52*d9f75844SAndroid Build Coastguard Worker   return latest_telephone_event_;
53*d9f75844SAndroid Build Coastguard Worker }
54*d9f75844SAndroid Build Coastguard Worker 
SendTelephoneEvent(int payload_type,int payload_frequency,int event,int duration_ms)55*d9f75844SAndroid Build Coastguard Worker bool FakeAudioSendStream::SendTelephoneEvent(int payload_type,
56*d9f75844SAndroid Build Coastguard Worker                                              int payload_frequency,
57*d9f75844SAndroid Build Coastguard Worker                                              int event,
58*d9f75844SAndroid Build Coastguard Worker                                              int duration_ms) {
59*d9f75844SAndroid Build Coastguard Worker   latest_telephone_event_.payload_type = payload_type;
60*d9f75844SAndroid Build Coastguard Worker   latest_telephone_event_.payload_frequency = payload_frequency;
61*d9f75844SAndroid Build Coastguard Worker   latest_telephone_event_.event_code = event;
62*d9f75844SAndroid Build Coastguard Worker   latest_telephone_event_.duration_ms = duration_ms;
63*d9f75844SAndroid Build Coastguard Worker   return true;
64*d9f75844SAndroid Build Coastguard Worker }
65*d9f75844SAndroid Build Coastguard Worker 
SetMuted(bool muted)66*d9f75844SAndroid Build Coastguard Worker void FakeAudioSendStream::SetMuted(bool muted) {
67*d9f75844SAndroid Build Coastguard Worker   muted_ = muted;
68*d9f75844SAndroid Build Coastguard Worker }
69*d9f75844SAndroid Build Coastguard Worker 
GetStats() const70*d9f75844SAndroid Build Coastguard Worker webrtc::AudioSendStream::Stats FakeAudioSendStream::GetStats() const {
71*d9f75844SAndroid Build Coastguard Worker   return stats_;
72*d9f75844SAndroid Build Coastguard Worker }
73*d9f75844SAndroid Build Coastguard Worker 
GetStats(bool) const74*d9f75844SAndroid Build Coastguard Worker webrtc::AudioSendStream::Stats FakeAudioSendStream::GetStats(
75*d9f75844SAndroid Build Coastguard Worker     bool /*has_remote_tracks*/) const {
76*d9f75844SAndroid Build Coastguard Worker   return stats_;
77*d9f75844SAndroid Build Coastguard Worker }
78*d9f75844SAndroid Build Coastguard Worker 
FakeAudioReceiveStream(int id,const webrtc::AudioReceiveStreamInterface::Config & config)79*d9f75844SAndroid Build Coastguard Worker FakeAudioReceiveStream::FakeAudioReceiveStream(
80*d9f75844SAndroid Build Coastguard Worker     int id,
81*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioReceiveStreamInterface::Config& config)
82*d9f75844SAndroid Build Coastguard Worker     : id_(id), config_(config) {}
83*d9f75844SAndroid Build Coastguard Worker 
84*d9f75844SAndroid Build Coastguard Worker const webrtc::AudioReceiveStreamInterface::Config&
GetConfig() const85*d9f75844SAndroid Build Coastguard Worker FakeAudioReceiveStream::GetConfig() const {
86*d9f75844SAndroid Build Coastguard Worker   return config_;
87*d9f75844SAndroid Build Coastguard Worker }
88*d9f75844SAndroid Build Coastguard Worker 
SetStats(const webrtc::AudioReceiveStreamInterface::Stats & stats)89*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetStats(
90*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioReceiveStreamInterface::Stats& stats) {
91*d9f75844SAndroid Build Coastguard Worker   stats_ = stats;
92*d9f75844SAndroid Build Coastguard Worker }
93*d9f75844SAndroid Build Coastguard Worker 
VerifyLastPacket(const uint8_t * data,size_t length) const94*d9f75844SAndroid Build Coastguard Worker bool FakeAudioReceiveStream::VerifyLastPacket(const uint8_t* data,
95*d9f75844SAndroid Build Coastguard Worker                                               size_t length) const {
96*d9f75844SAndroid Build Coastguard Worker   return last_packet_ == rtc::Buffer(data, length);
97*d9f75844SAndroid Build Coastguard Worker }
98*d9f75844SAndroid Build Coastguard Worker 
DeliverRtp(const uint8_t * packet,size_t length,int64_t)99*d9f75844SAndroid Build Coastguard Worker bool FakeAudioReceiveStream::DeliverRtp(const uint8_t* packet,
100*d9f75844SAndroid Build Coastguard Worker                                         size_t length,
101*d9f75844SAndroid Build Coastguard Worker                                         int64_t /* packet_time_us */) {
102*d9f75844SAndroid Build Coastguard Worker   ++received_packets_;
103*d9f75844SAndroid Build Coastguard Worker   last_packet_.SetData(packet, length);
104*d9f75844SAndroid Build Coastguard Worker   return true;
105*d9f75844SAndroid Build Coastguard Worker }
106*d9f75844SAndroid Build Coastguard Worker 
SetDepacketizerToDecoderFrameTransformer(rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)107*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetDepacketizerToDecoderFrameTransformer(
108*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) {
109*d9f75844SAndroid Build Coastguard Worker   config_.frame_transformer = std::move(frame_transformer);
110*d9f75844SAndroid Build Coastguard Worker }
111*d9f75844SAndroid Build Coastguard Worker 
SetDecoderMap(std::map<int,webrtc::SdpAudioFormat> decoder_map)112*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetDecoderMap(
113*d9f75844SAndroid Build Coastguard Worker     std::map<int, webrtc::SdpAudioFormat> decoder_map) {
114*d9f75844SAndroid Build Coastguard Worker   config_.decoder_map = std::move(decoder_map);
115*d9f75844SAndroid Build Coastguard Worker }
116*d9f75844SAndroid Build Coastguard Worker 
SetNackHistory(int history_ms)117*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetNackHistory(int history_ms) {
118*d9f75844SAndroid Build Coastguard Worker   config_.rtp.nack.rtp_history_ms = history_ms;
119*d9f75844SAndroid Build Coastguard Worker }
120*d9f75844SAndroid Build Coastguard Worker 
SetNonSenderRttMeasurement(bool enabled)121*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetNonSenderRttMeasurement(bool enabled) {
122*d9f75844SAndroid Build Coastguard Worker   config_.enable_non_sender_rtt = enabled;
123*d9f75844SAndroid Build Coastguard Worker }
124*d9f75844SAndroid Build Coastguard Worker 
SetFrameDecryptor(rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor)125*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetFrameDecryptor(
126*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
127*d9f75844SAndroid Build Coastguard Worker   config_.frame_decryptor = std::move(frame_decryptor);
128*d9f75844SAndroid Build Coastguard Worker }
129*d9f75844SAndroid Build Coastguard Worker 
SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions)130*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetRtpExtensions(
131*d9f75844SAndroid Build Coastguard Worker     std::vector<webrtc::RtpExtension> extensions) {
132*d9f75844SAndroid Build Coastguard Worker   config_.rtp.extensions = std::move(extensions);
133*d9f75844SAndroid Build Coastguard Worker }
134*d9f75844SAndroid Build Coastguard Worker 
135*d9f75844SAndroid Build Coastguard Worker const std::vector<webrtc::RtpExtension>&
GetRtpExtensions() const136*d9f75844SAndroid Build Coastguard Worker FakeAudioReceiveStream::GetRtpExtensions() const {
137*d9f75844SAndroid Build Coastguard Worker   return config_.rtp.extensions;
138*d9f75844SAndroid Build Coastguard Worker }
139*d9f75844SAndroid Build Coastguard Worker 
GetRtpExtensionMap() const140*d9f75844SAndroid Build Coastguard Worker webrtc::RtpHeaderExtensionMap FakeAudioReceiveStream::GetRtpExtensionMap()
141*d9f75844SAndroid Build Coastguard Worker     const {
142*d9f75844SAndroid Build Coastguard Worker   return webrtc::RtpHeaderExtensionMap(config_.rtp.extensions);
143*d9f75844SAndroid Build Coastguard Worker }
144*d9f75844SAndroid Build Coastguard Worker 
GetStats(bool get_and_clear_legacy_stats) const145*d9f75844SAndroid Build Coastguard Worker webrtc::AudioReceiveStreamInterface::Stats FakeAudioReceiveStream::GetStats(
146*d9f75844SAndroid Build Coastguard Worker     bool get_and_clear_legacy_stats) const {
147*d9f75844SAndroid Build Coastguard Worker   return stats_;
148*d9f75844SAndroid Build Coastguard Worker }
149*d9f75844SAndroid Build Coastguard Worker 
SetSink(webrtc::AudioSinkInterface * sink)150*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetSink(webrtc::AudioSinkInterface* sink) {
151*d9f75844SAndroid Build Coastguard Worker   sink_ = sink;
152*d9f75844SAndroid Build Coastguard Worker }
153*d9f75844SAndroid Build Coastguard Worker 
SetGain(float gain)154*d9f75844SAndroid Build Coastguard Worker void FakeAudioReceiveStream::SetGain(float gain) {
155*d9f75844SAndroid Build Coastguard Worker   gain_ = gain;
156*d9f75844SAndroid Build Coastguard Worker }
157*d9f75844SAndroid Build Coastguard Worker 
FakeVideoSendStream(webrtc::VideoSendStream::Config config,webrtc::VideoEncoderConfig encoder_config)158*d9f75844SAndroid Build Coastguard Worker FakeVideoSendStream::FakeVideoSendStream(
159*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoSendStream::Config config,
160*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoEncoderConfig encoder_config)
161*d9f75844SAndroid Build Coastguard Worker     : sending_(false),
162*d9f75844SAndroid Build Coastguard Worker       config_(std::move(config)),
163*d9f75844SAndroid Build Coastguard Worker       codec_settings_set_(false),
164*d9f75844SAndroid Build Coastguard Worker       resolution_scaling_enabled_(false),
165*d9f75844SAndroid Build Coastguard Worker       framerate_scaling_enabled_(false),
166*d9f75844SAndroid Build Coastguard Worker       source_(nullptr),
167*d9f75844SAndroid Build Coastguard Worker       num_swapped_frames_(0) {
168*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(config.encoder_settings.encoder_factory != nullptr);
169*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(config.encoder_settings.bitrate_allocator_factory != nullptr);
170*d9f75844SAndroid Build Coastguard Worker   ReconfigureVideoEncoder(std::move(encoder_config));
171*d9f75844SAndroid Build Coastguard Worker }
172*d9f75844SAndroid Build Coastguard Worker 
~FakeVideoSendStream()173*d9f75844SAndroid Build Coastguard Worker FakeVideoSendStream::~FakeVideoSendStream() {
174*d9f75844SAndroid Build Coastguard Worker   if (source_)
175*d9f75844SAndroid Build Coastguard Worker     source_->RemoveSink(this);
176*d9f75844SAndroid Build Coastguard Worker }
177*d9f75844SAndroid Build Coastguard Worker 
GetConfig() const178*d9f75844SAndroid Build Coastguard Worker const webrtc::VideoSendStream::Config& FakeVideoSendStream::GetConfig() const {
179*d9f75844SAndroid Build Coastguard Worker   return config_;
180*d9f75844SAndroid Build Coastguard Worker }
181*d9f75844SAndroid Build Coastguard Worker 
GetEncoderConfig() const182*d9f75844SAndroid Build Coastguard Worker const webrtc::VideoEncoderConfig& FakeVideoSendStream::GetEncoderConfig()
183*d9f75844SAndroid Build Coastguard Worker     const {
184*d9f75844SAndroid Build Coastguard Worker   return encoder_config_;
185*d9f75844SAndroid Build Coastguard Worker }
186*d9f75844SAndroid Build Coastguard Worker 
GetVideoStreams() const187*d9f75844SAndroid Build Coastguard Worker const std::vector<webrtc::VideoStream>& FakeVideoSendStream::GetVideoStreams()
188*d9f75844SAndroid Build Coastguard Worker     const {
189*d9f75844SAndroid Build Coastguard Worker   return video_streams_;
190*d9f75844SAndroid Build Coastguard Worker }
191*d9f75844SAndroid Build Coastguard Worker 
IsSending() const192*d9f75844SAndroid Build Coastguard Worker bool FakeVideoSendStream::IsSending() const {
193*d9f75844SAndroid Build Coastguard Worker   return sending_;
194*d9f75844SAndroid Build Coastguard Worker }
195*d9f75844SAndroid Build Coastguard Worker 
GetVp8Settings(webrtc::VideoCodecVP8 * settings) const196*d9f75844SAndroid Build Coastguard Worker bool FakeVideoSendStream::GetVp8Settings(
197*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoCodecVP8* settings) const {
198*d9f75844SAndroid Build Coastguard Worker   if (!codec_settings_set_) {
199*d9f75844SAndroid Build Coastguard Worker     return false;
200*d9f75844SAndroid Build Coastguard Worker   }
201*d9f75844SAndroid Build Coastguard Worker 
202*d9f75844SAndroid Build Coastguard Worker   *settings = codec_specific_settings_.vp8;
203*d9f75844SAndroid Build Coastguard Worker   return true;
204*d9f75844SAndroid Build Coastguard Worker }
205*d9f75844SAndroid Build Coastguard Worker 
GetVp9Settings(webrtc::VideoCodecVP9 * settings) const206*d9f75844SAndroid Build Coastguard Worker bool FakeVideoSendStream::GetVp9Settings(
207*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoCodecVP9* settings) const {
208*d9f75844SAndroid Build Coastguard Worker   if (!codec_settings_set_) {
209*d9f75844SAndroid Build Coastguard Worker     return false;
210*d9f75844SAndroid Build Coastguard Worker   }
211*d9f75844SAndroid Build Coastguard Worker 
212*d9f75844SAndroid Build Coastguard Worker   *settings = codec_specific_settings_.vp9;
213*d9f75844SAndroid Build Coastguard Worker   return true;
214*d9f75844SAndroid Build Coastguard Worker }
215*d9f75844SAndroid Build Coastguard Worker 
GetH264Settings(webrtc::VideoCodecH264 * settings) const216*d9f75844SAndroid Build Coastguard Worker bool FakeVideoSendStream::GetH264Settings(
217*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoCodecH264* settings) const {
218*d9f75844SAndroid Build Coastguard Worker   if (!codec_settings_set_) {
219*d9f75844SAndroid Build Coastguard Worker     return false;
220*d9f75844SAndroid Build Coastguard Worker   }
221*d9f75844SAndroid Build Coastguard Worker 
222*d9f75844SAndroid Build Coastguard Worker   *settings = codec_specific_settings_.h264;
223*d9f75844SAndroid Build Coastguard Worker   return true;
224*d9f75844SAndroid Build Coastguard Worker }
225*d9f75844SAndroid Build Coastguard Worker 
GetNumberOfSwappedFrames() const226*d9f75844SAndroid Build Coastguard Worker int FakeVideoSendStream::GetNumberOfSwappedFrames() const {
227*d9f75844SAndroid Build Coastguard Worker   return num_swapped_frames_;
228*d9f75844SAndroid Build Coastguard Worker }
229*d9f75844SAndroid Build Coastguard Worker 
GetLastWidth() const230*d9f75844SAndroid Build Coastguard Worker int FakeVideoSendStream::GetLastWidth() const {
231*d9f75844SAndroid Build Coastguard Worker   return last_frame_->width();
232*d9f75844SAndroid Build Coastguard Worker }
233*d9f75844SAndroid Build Coastguard Worker 
GetLastHeight() const234*d9f75844SAndroid Build Coastguard Worker int FakeVideoSendStream::GetLastHeight() const {
235*d9f75844SAndroid Build Coastguard Worker   return last_frame_->height();
236*d9f75844SAndroid Build Coastguard Worker }
237*d9f75844SAndroid Build Coastguard Worker 
GetLastTimestamp() const238*d9f75844SAndroid Build Coastguard Worker int64_t FakeVideoSendStream::GetLastTimestamp() const {
239*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(last_frame_->ntp_time_ms() == 0);
240*d9f75844SAndroid Build Coastguard Worker   return last_frame_->render_time_ms();
241*d9f75844SAndroid Build Coastguard Worker }
242*d9f75844SAndroid Build Coastguard Worker 
OnFrame(const webrtc::VideoFrame & frame)243*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::OnFrame(const webrtc::VideoFrame& frame) {
244*d9f75844SAndroid Build Coastguard Worker   ++num_swapped_frames_;
245*d9f75844SAndroid Build Coastguard Worker   if (!last_frame_ || frame.width() != last_frame_->width() ||
246*d9f75844SAndroid Build Coastguard Worker       frame.height() != last_frame_->height() ||
247*d9f75844SAndroid Build Coastguard Worker       frame.rotation() != last_frame_->rotation()) {
248*d9f75844SAndroid Build Coastguard Worker     if (encoder_config_.video_stream_factory) {
249*d9f75844SAndroid Build Coastguard Worker       // Note: only tests set their own EncoderStreamFactory...
250*d9f75844SAndroid Build Coastguard Worker       video_streams_ =
251*d9f75844SAndroid Build Coastguard Worker           encoder_config_.video_stream_factory->CreateEncoderStreams(
252*d9f75844SAndroid Build Coastguard Worker               frame.width(), frame.height(), encoder_config_);
253*d9f75844SAndroid Build Coastguard Worker     } else {
254*d9f75844SAndroid Build Coastguard Worker       webrtc::VideoEncoder::EncoderInfo encoder_info;
255*d9f75844SAndroid Build Coastguard Worker       rtc::scoped_refptr<
256*d9f75844SAndroid Build Coastguard Worker           webrtc::VideoEncoderConfig::VideoStreamFactoryInterface>
257*d9f75844SAndroid Build Coastguard Worker           factory = rtc::make_ref_counted<cricket::EncoderStreamFactory>(
258*d9f75844SAndroid Build Coastguard Worker               encoder_config_.video_format.name, encoder_config_.max_qp,
259*d9f75844SAndroid Build Coastguard Worker               encoder_config_.content_type ==
260*d9f75844SAndroid Build Coastguard Worker                   webrtc::VideoEncoderConfig::ContentType::kScreen,
261*d9f75844SAndroid Build Coastguard Worker               encoder_config_.legacy_conference_mode, encoder_info);
262*d9f75844SAndroid Build Coastguard Worker 
263*d9f75844SAndroid Build Coastguard Worker       video_streams_ = factory->CreateEncoderStreams(
264*d9f75844SAndroid Build Coastguard Worker           frame.width(), frame.height(), encoder_config_);
265*d9f75844SAndroid Build Coastguard Worker     }
266*d9f75844SAndroid Build Coastguard Worker   }
267*d9f75844SAndroid Build Coastguard Worker   last_frame_ = frame;
268*d9f75844SAndroid Build Coastguard Worker }
269*d9f75844SAndroid Build Coastguard Worker 
SetStats(const webrtc::VideoSendStream::Stats & stats)270*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::SetStats(
271*d9f75844SAndroid Build Coastguard Worker     const webrtc::VideoSendStream::Stats& stats) {
272*d9f75844SAndroid Build Coastguard Worker   stats_ = stats;
273*d9f75844SAndroid Build Coastguard Worker }
274*d9f75844SAndroid Build Coastguard Worker 
GetStats()275*d9f75844SAndroid Build Coastguard Worker webrtc::VideoSendStream::Stats FakeVideoSendStream::GetStats() {
276*d9f75844SAndroid Build Coastguard Worker   return stats_;
277*d9f75844SAndroid Build Coastguard Worker }
278*d9f75844SAndroid Build Coastguard Worker 
ReconfigureVideoEncoder(webrtc::VideoEncoderConfig config)279*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::ReconfigureVideoEncoder(
280*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoEncoderConfig config) {
281*d9f75844SAndroid Build Coastguard Worker   ReconfigureVideoEncoder(std::move(config), nullptr);
282*d9f75844SAndroid Build Coastguard Worker }
283*d9f75844SAndroid Build Coastguard Worker 
ReconfigureVideoEncoder(webrtc::VideoEncoderConfig config,webrtc::SetParametersCallback callback)284*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::ReconfigureVideoEncoder(
285*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoEncoderConfig config,
286*d9f75844SAndroid Build Coastguard Worker     webrtc::SetParametersCallback callback) {
287*d9f75844SAndroid Build Coastguard Worker   int width, height;
288*d9f75844SAndroid Build Coastguard Worker   if (last_frame_) {
289*d9f75844SAndroid Build Coastguard Worker     width = last_frame_->width();
290*d9f75844SAndroid Build Coastguard Worker     height = last_frame_->height();
291*d9f75844SAndroid Build Coastguard Worker   } else {
292*d9f75844SAndroid Build Coastguard Worker     width = height = 0;
293*d9f75844SAndroid Build Coastguard Worker   }
294*d9f75844SAndroid Build Coastguard Worker   if (config.video_stream_factory) {
295*d9f75844SAndroid Build Coastguard Worker     // Note: only tests set their own EncoderStreamFactory...
296*d9f75844SAndroid Build Coastguard Worker     video_streams_ = config.video_stream_factory->CreateEncoderStreams(
297*d9f75844SAndroid Build Coastguard Worker         width, height, config);
298*d9f75844SAndroid Build Coastguard Worker   } else {
299*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoEncoder::EncoderInfo encoder_info;
300*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::VideoEncoderConfig::VideoStreamFactoryInterface>
301*d9f75844SAndroid Build Coastguard Worker         factory = rtc::make_ref_counted<cricket::EncoderStreamFactory>(
302*d9f75844SAndroid Build Coastguard Worker             config.video_format.name, config.max_qp,
303*d9f75844SAndroid Build Coastguard Worker             config.content_type ==
304*d9f75844SAndroid Build Coastguard Worker                 webrtc::VideoEncoderConfig::ContentType::kScreen,
305*d9f75844SAndroid Build Coastguard Worker             config.legacy_conference_mode, encoder_info);
306*d9f75844SAndroid Build Coastguard Worker 
307*d9f75844SAndroid Build Coastguard Worker     video_streams_ = factory->CreateEncoderStreams(width, height, config);
308*d9f75844SAndroid Build Coastguard Worker   }
309*d9f75844SAndroid Build Coastguard Worker 
310*d9f75844SAndroid Build Coastguard Worker   if (config.encoder_specific_settings != nullptr) {
311*d9f75844SAndroid Build Coastguard Worker     const unsigned char num_temporal_layers = static_cast<unsigned char>(
312*d9f75844SAndroid Build Coastguard Worker         video_streams_.back().num_temporal_layers.value_or(1));
313*d9f75844SAndroid Build Coastguard Worker     if (config_.rtp.payload_name == "VP8") {
314*d9f75844SAndroid Build Coastguard Worker       config.encoder_specific_settings->FillVideoCodecVp8(
315*d9f75844SAndroid Build Coastguard Worker           &codec_specific_settings_.vp8);
316*d9f75844SAndroid Build Coastguard Worker       if (!video_streams_.empty()) {
317*d9f75844SAndroid Build Coastguard Worker         codec_specific_settings_.vp8.numberOfTemporalLayers =
318*d9f75844SAndroid Build Coastguard Worker             num_temporal_layers;
319*d9f75844SAndroid Build Coastguard Worker       }
320*d9f75844SAndroid Build Coastguard Worker     } else if (config_.rtp.payload_name == "VP9") {
321*d9f75844SAndroid Build Coastguard Worker       config.encoder_specific_settings->FillVideoCodecVp9(
322*d9f75844SAndroid Build Coastguard Worker           &codec_specific_settings_.vp9);
323*d9f75844SAndroid Build Coastguard Worker       if (!video_streams_.empty()) {
324*d9f75844SAndroid Build Coastguard Worker         codec_specific_settings_.vp9.numberOfTemporalLayers =
325*d9f75844SAndroid Build Coastguard Worker             num_temporal_layers;
326*d9f75844SAndroid Build Coastguard Worker       }
327*d9f75844SAndroid Build Coastguard Worker     } else if (config_.rtp.payload_name == "H264") {
328*d9f75844SAndroid Build Coastguard Worker       codec_specific_settings_.h264.numberOfTemporalLayers =
329*d9f75844SAndroid Build Coastguard Worker           num_temporal_layers;
330*d9f75844SAndroid Build Coastguard Worker     } else {
331*d9f75844SAndroid Build Coastguard Worker       ADD_FAILURE() << "Unsupported encoder payload: "
332*d9f75844SAndroid Build Coastguard Worker                     << config_.rtp.payload_name;
333*d9f75844SAndroid Build Coastguard Worker     }
334*d9f75844SAndroid Build Coastguard Worker   }
335*d9f75844SAndroid Build Coastguard Worker   codec_settings_set_ = config.encoder_specific_settings != nullptr;
336*d9f75844SAndroid Build Coastguard Worker   encoder_config_ = std::move(config);
337*d9f75844SAndroid Build Coastguard Worker   ++num_encoder_reconfigurations_;
338*d9f75844SAndroid Build Coastguard Worker   webrtc::InvokeSetParametersCallback(callback, webrtc::RTCError::OK());
339*d9f75844SAndroid Build Coastguard Worker }
340*d9f75844SAndroid Build Coastguard Worker 
StartPerRtpStream(const std::vector<bool> active_layers)341*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::StartPerRtpStream(
342*d9f75844SAndroid Build Coastguard Worker     const std::vector<bool> active_layers) {
343*d9f75844SAndroid Build Coastguard Worker   sending_ = false;
344*d9f75844SAndroid Build Coastguard Worker   for (const bool active_layer : active_layers) {
345*d9f75844SAndroid Build Coastguard Worker     if (active_layer) {
346*d9f75844SAndroid Build Coastguard Worker       sending_ = true;
347*d9f75844SAndroid Build Coastguard Worker       break;
348*d9f75844SAndroid Build Coastguard Worker     }
349*d9f75844SAndroid Build Coastguard Worker   }
350*d9f75844SAndroid Build Coastguard Worker }
351*d9f75844SAndroid Build Coastguard Worker 
Start()352*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::Start() {
353*d9f75844SAndroid Build Coastguard Worker   sending_ = true;
354*d9f75844SAndroid Build Coastguard Worker }
355*d9f75844SAndroid Build Coastguard Worker 
Stop()356*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::Stop() {
357*d9f75844SAndroid Build Coastguard Worker   sending_ = false;
358*d9f75844SAndroid Build Coastguard Worker }
359*d9f75844SAndroid Build Coastguard Worker 
AddAdaptationResource(rtc::scoped_refptr<webrtc::Resource> resource)360*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::AddAdaptationResource(
361*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::Resource> resource) {}
362*d9f75844SAndroid Build Coastguard Worker 
363*d9f75844SAndroid Build Coastguard Worker std::vector<rtc::scoped_refptr<webrtc::Resource>>
GetAdaptationResources()364*d9f75844SAndroid Build Coastguard Worker FakeVideoSendStream::GetAdaptationResources() {
365*d9f75844SAndroid Build Coastguard Worker   return {};
366*d9f75844SAndroid Build Coastguard Worker }
367*d9f75844SAndroid Build Coastguard Worker 
SetSource(rtc::VideoSourceInterface<webrtc::VideoFrame> * source,const webrtc::DegradationPreference & degradation_preference)368*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::SetSource(
369*d9f75844SAndroid Build Coastguard Worker     rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
370*d9f75844SAndroid Build Coastguard Worker     const webrtc::DegradationPreference& degradation_preference) {
371*d9f75844SAndroid Build Coastguard Worker   if (source_)
372*d9f75844SAndroid Build Coastguard Worker     source_->RemoveSink(this);
373*d9f75844SAndroid Build Coastguard Worker   source_ = source;
374*d9f75844SAndroid Build Coastguard Worker   switch (degradation_preference) {
375*d9f75844SAndroid Build Coastguard Worker     case webrtc::DegradationPreference::MAINTAIN_FRAMERATE:
376*d9f75844SAndroid Build Coastguard Worker       resolution_scaling_enabled_ = true;
377*d9f75844SAndroid Build Coastguard Worker       framerate_scaling_enabled_ = false;
378*d9f75844SAndroid Build Coastguard Worker       break;
379*d9f75844SAndroid Build Coastguard Worker     case webrtc::DegradationPreference::MAINTAIN_RESOLUTION:
380*d9f75844SAndroid Build Coastguard Worker       resolution_scaling_enabled_ = false;
381*d9f75844SAndroid Build Coastguard Worker       framerate_scaling_enabled_ = true;
382*d9f75844SAndroid Build Coastguard Worker       break;
383*d9f75844SAndroid Build Coastguard Worker     case webrtc::DegradationPreference::BALANCED:
384*d9f75844SAndroid Build Coastguard Worker       resolution_scaling_enabled_ = true;
385*d9f75844SAndroid Build Coastguard Worker       framerate_scaling_enabled_ = true;
386*d9f75844SAndroid Build Coastguard Worker       break;
387*d9f75844SAndroid Build Coastguard Worker     case webrtc::DegradationPreference::DISABLED:
388*d9f75844SAndroid Build Coastguard Worker       resolution_scaling_enabled_ = false;
389*d9f75844SAndroid Build Coastguard Worker       framerate_scaling_enabled_ = false;
390*d9f75844SAndroid Build Coastguard Worker       break;
391*d9f75844SAndroid Build Coastguard Worker   }
392*d9f75844SAndroid Build Coastguard Worker   if (source)
393*d9f75844SAndroid Build Coastguard Worker     source->AddOrUpdateSink(this, resolution_scaling_enabled_
394*d9f75844SAndroid Build Coastguard Worker                                       ? sink_wants_
395*d9f75844SAndroid Build Coastguard Worker                                       : rtc::VideoSinkWants());
396*d9f75844SAndroid Build Coastguard Worker }
397*d9f75844SAndroid Build Coastguard Worker 
InjectVideoSinkWants(const rtc::VideoSinkWants & wants)398*d9f75844SAndroid Build Coastguard Worker void FakeVideoSendStream::InjectVideoSinkWants(
399*d9f75844SAndroid Build Coastguard Worker     const rtc::VideoSinkWants& wants) {
400*d9f75844SAndroid Build Coastguard Worker   sink_wants_ = wants;
401*d9f75844SAndroid Build Coastguard Worker   source_->AddOrUpdateSink(this, wants);
402*d9f75844SAndroid Build Coastguard Worker }
403*d9f75844SAndroid Build Coastguard Worker 
FakeVideoReceiveStream(webrtc::VideoReceiveStreamInterface::Config config)404*d9f75844SAndroid Build Coastguard Worker FakeVideoReceiveStream::FakeVideoReceiveStream(
405*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoReceiveStreamInterface::Config config)
406*d9f75844SAndroid Build Coastguard Worker     : config_(std::move(config)), receiving_(false) {}
407*d9f75844SAndroid Build Coastguard Worker 
408*d9f75844SAndroid Build Coastguard Worker const webrtc::VideoReceiveStreamInterface::Config&
GetConfig() const409*d9f75844SAndroid Build Coastguard Worker FakeVideoReceiveStream::GetConfig() const {
410*d9f75844SAndroid Build Coastguard Worker   return config_;
411*d9f75844SAndroid Build Coastguard Worker }
412*d9f75844SAndroid Build Coastguard Worker 
IsReceiving() const413*d9f75844SAndroid Build Coastguard Worker bool FakeVideoReceiveStream::IsReceiving() const {
414*d9f75844SAndroid Build Coastguard Worker   return receiving_;
415*d9f75844SAndroid Build Coastguard Worker }
416*d9f75844SAndroid Build Coastguard Worker 
InjectFrame(const webrtc::VideoFrame & frame)417*d9f75844SAndroid Build Coastguard Worker void FakeVideoReceiveStream::InjectFrame(const webrtc::VideoFrame& frame) {
418*d9f75844SAndroid Build Coastguard Worker   config_.renderer->OnFrame(frame);
419*d9f75844SAndroid Build Coastguard Worker }
420*d9f75844SAndroid Build Coastguard Worker 
GetStats() const421*d9f75844SAndroid Build Coastguard Worker webrtc::VideoReceiveStreamInterface::Stats FakeVideoReceiveStream::GetStats()
422*d9f75844SAndroid Build Coastguard Worker     const {
423*d9f75844SAndroid Build Coastguard Worker   return stats_;
424*d9f75844SAndroid Build Coastguard Worker }
425*d9f75844SAndroid Build Coastguard Worker 
SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions)426*d9f75844SAndroid Build Coastguard Worker void FakeVideoReceiveStream::SetRtpExtensions(
427*d9f75844SAndroid Build Coastguard Worker     std::vector<webrtc::RtpExtension> extensions) {
428*d9f75844SAndroid Build Coastguard Worker   config_.rtp.extensions = std::move(extensions);
429*d9f75844SAndroid Build Coastguard Worker }
430*d9f75844SAndroid Build Coastguard Worker 
GetRtpExtensionMap() const431*d9f75844SAndroid Build Coastguard Worker webrtc::RtpHeaderExtensionMap FakeVideoReceiveStream::GetRtpExtensionMap()
432*d9f75844SAndroid Build Coastguard Worker     const {
433*d9f75844SAndroid Build Coastguard Worker   return webrtc::RtpHeaderExtensionMap(config_.rtp.extensions);
434*d9f75844SAndroid Build Coastguard Worker }
435*d9f75844SAndroid Build Coastguard Worker 
Start()436*d9f75844SAndroid Build Coastguard Worker void FakeVideoReceiveStream::Start() {
437*d9f75844SAndroid Build Coastguard Worker   receiving_ = true;
438*d9f75844SAndroid Build Coastguard Worker }
439*d9f75844SAndroid Build Coastguard Worker 
Stop()440*d9f75844SAndroid Build Coastguard Worker void FakeVideoReceiveStream::Stop() {
441*d9f75844SAndroid Build Coastguard Worker   receiving_ = false;
442*d9f75844SAndroid Build Coastguard Worker }
443*d9f75844SAndroid Build Coastguard Worker 
SetStats(const webrtc::VideoReceiveStreamInterface::Stats & stats)444*d9f75844SAndroid Build Coastguard Worker void FakeVideoReceiveStream::SetStats(
445*d9f75844SAndroid Build Coastguard Worker     const webrtc::VideoReceiveStreamInterface::Stats& stats) {
446*d9f75844SAndroid Build Coastguard Worker   stats_ = stats;
447*d9f75844SAndroid Build Coastguard Worker }
448*d9f75844SAndroid Build Coastguard Worker 
FakeFlexfecReceiveStream(const webrtc::FlexfecReceiveStream::Config config)449*d9f75844SAndroid Build Coastguard Worker FakeFlexfecReceiveStream::FakeFlexfecReceiveStream(
450*d9f75844SAndroid Build Coastguard Worker     const webrtc::FlexfecReceiveStream::Config config)
451*d9f75844SAndroid Build Coastguard Worker     : config_(std::move(config)) {}
452*d9f75844SAndroid Build Coastguard Worker 
SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions)453*d9f75844SAndroid Build Coastguard Worker void FakeFlexfecReceiveStream::SetRtpExtensions(
454*d9f75844SAndroid Build Coastguard Worker     std::vector<webrtc::RtpExtension> extensions) {
455*d9f75844SAndroid Build Coastguard Worker   config_.rtp.extensions = std::move(extensions);
456*d9f75844SAndroid Build Coastguard Worker }
457*d9f75844SAndroid Build Coastguard Worker 
GetRtpExtensionMap() const458*d9f75844SAndroid Build Coastguard Worker webrtc::RtpHeaderExtensionMap FakeFlexfecReceiveStream::GetRtpExtensionMap()
459*d9f75844SAndroid Build Coastguard Worker     const {
460*d9f75844SAndroid Build Coastguard Worker   return webrtc::RtpHeaderExtensionMap(config_.rtp.extensions);
461*d9f75844SAndroid Build Coastguard Worker }
462*d9f75844SAndroid Build Coastguard Worker 
463*d9f75844SAndroid Build Coastguard Worker const webrtc::FlexfecReceiveStream::Config&
GetConfig() const464*d9f75844SAndroid Build Coastguard Worker FakeFlexfecReceiveStream::GetConfig() const {
465*d9f75844SAndroid Build Coastguard Worker   return config_;
466*d9f75844SAndroid Build Coastguard Worker }
467*d9f75844SAndroid Build Coastguard Worker 
OnRtpPacket(const webrtc::RtpPacketReceived &)468*d9f75844SAndroid Build Coastguard Worker void FakeFlexfecReceiveStream::OnRtpPacket(const webrtc::RtpPacketReceived&) {
469*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK_NOTREACHED() << "Not implemented.";
470*d9f75844SAndroid Build Coastguard Worker }
471*d9f75844SAndroid Build Coastguard Worker 
FakeCall(webrtc::test::ScopedKeyValueConfig * field_trials)472*d9f75844SAndroid Build Coastguard Worker FakeCall::FakeCall(webrtc::test::ScopedKeyValueConfig* field_trials)
473*d9f75844SAndroid Build Coastguard Worker     : FakeCall(rtc::Thread::Current(), rtc::Thread::Current(), field_trials) {}
474*d9f75844SAndroid Build Coastguard Worker 
FakeCall(webrtc::TaskQueueBase * worker_thread,webrtc::TaskQueueBase * network_thread,webrtc::test::ScopedKeyValueConfig * field_trials)475*d9f75844SAndroid Build Coastguard Worker FakeCall::FakeCall(webrtc::TaskQueueBase* worker_thread,
476*d9f75844SAndroid Build Coastguard Worker                    webrtc::TaskQueueBase* network_thread,
477*d9f75844SAndroid Build Coastguard Worker                    webrtc::test::ScopedKeyValueConfig* field_trials)
478*d9f75844SAndroid Build Coastguard Worker     : network_thread_(network_thread),
479*d9f75844SAndroid Build Coastguard Worker       worker_thread_(worker_thread),
480*d9f75844SAndroid Build Coastguard Worker       audio_network_state_(webrtc::kNetworkUp),
481*d9f75844SAndroid Build Coastguard Worker       video_network_state_(webrtc::kNetworkUp),
482*d9f75844SAndroid Build Coastguard Worker       num_created_send_streams_(0),
483*d9f75844SAndroid Build Coastguard Worker       num_created_receive_streams_(0),
484*d9f75844SAndroid Build Coastguard Worker       trials_(field_trials ? field_trials : &fallback_trials_) {}
485*d9f75844SAndroid Build Coastguard Worker 
~FakeCall()486*d9f75844SAndroid Build Coastguard Worker FakeCall::~FakeCall() {
487*d9f75844SAndroid Build Coastguard Worker   EXPECT_EQ(0u, video_send_streams_.size());
488*d9f75844SAndroid Build Coastguard Worker   EXPECT_EQ(0u, audio_send_streams_.size());
489*d9f75844SAndroid Build Coastguard Worker   EXPECT_EQ(0u, video_receive_streams_.size());
490*d9f75844SAndroid Build Coastguard Worker   EXPECT_EQ(0u, audio_receive_streams_.size());
491*d9f75844SAndroid Build Coastguard Worker }
492*d9f75844SAndroid Build Coastguard Worker 
GetVideoSendStreams()493*d9f75844SAndroid Build Coastguard Worker const std::vector<FakeVideoSendStream*>& FakeCall::GetVideoSendStreams() {
494*d9f75844SAndroid Build Coastguard Worker   return video_send_streams_;
495*d9f75844SAndroid Build Coastguard Worker }
496*d9f75844SAndroid Build Coastguard Worker 
GetVideoReceiveStreams()497*d9f75844SAndroid Build Coastguard Worker const std::vector<FakeVideoReceiveStream*>& FakeCall::GetVideoReceiveStreams() {
498*d9f75844SAndroid Build Coastguard Worker   return video_receive_streams_;
499*d9f75844SAndroid Build Coastguard Worker }
500*d9f75844SAndroid Build Coastguard Worker 
GetVideoReceiveStream(uint32_t ssrc)501*d9f75844SAndroid Build Coastguard Worker const FakeVideoReceiveStream* FakeCall::GetVideoReceiveStream(uint32_t ssrc) {
502*d9f75844SAndroid Build Coastguard Worker   for (const auto* p : GetVideoReceiveStreams()) {
503*d9f75844SAndroid Build Coastguard Worker     if (p->GetConfig().rtp.remote_ssrc == ssrc) {
504*d9f75844SAndroid Build Coastguard Worker       return p;
505*d9f75844SAndroid Build Coastguard Worker     }
506*d9f75844SAndroid Build Coastguard Worker   }
507*d9f75844SAndroid Build Coastguard Worker   return nullptr;
508*d9f75844SAndroid Build Coastguard Worker }
509*d9f75844SAndroid Build Coastguard Worker 
GetAudioSendStreams()510*d9f75844SAndroid Build Coastguard Worker const std::vector<FakeAudioSendStream*>& FakeCall::GetAudioSendStreams() {
511*d9f75844SAndroid Build Coastguard Worker   return audio_send_streams_;
512*d9f75844SAndroid Build Coastguard Worker }
513*d9f75844SAndroid Build Coastguard Worker 
GetAudioSendStream(uint32_t ssrc)514*d9f75844SAndroid Build Coastguard Worker const FakeAudioSendStream* FakeCall::GetAudioSendStream(uint32_t ssrc) {
515*d9f75844SAndroid Build Coastguard Worker   for (const auto* p : GetAudioSendStreams()) {
516*d9f75844SAndroid Build Coastguard Worker     if (p->GetConfig().rtp.ssrc == ssrc) {
517*d9f75844SAndroid Build Coastguard Worker       return p;
518*d9f75844SAndroid Build Coastguard Worker     }
519*d9f75844SAndroid Build Coastguard Worker   }
520*d9f75844SAndroid Build Coastguard Worker   return nullptr;
521*d9f75844SAndroid Build Coastguard Worker }
522*d9f75844SAndroid Build Coastguard Worker 
GetAudioReceiveStreams()523*d9f75844SAndroid Build Coastguard Worker const std::vector<FakeAudioReceiveStream*>& FakeCall::GetAudioReceiveStreams() {
524*d9f75844SAndroid Build Coastguard Worker   return audio_receive_streams_;
525*d9f75844SAndroid Build Coastguard Worker }
526*d9f75844SAndroid Build Coastguard Worker 
GetAudioReceiveStream(uint32_t ssrc)527*d9f75844SAndroid Build Coastguard Worker const FakeAudioReceiveStream* FakeCall::GetAudioReceiveStream(uint32_t ssrc) {
528*d9f75844SAndroid Build Coastguard Worker   for (const auto* p : GetAudioReceiveStreams()) {
529*d9f75844SAndroid Build Coastguard Worker     if (p->GetConfig().rtp.remote_ssrc == ssrc) {
530*d9f75844SAndroid Build Coastguard Worker       return p;
531*d9f75844SAndroid Build Coastguard Worker     }
532*d9f75844SAndroid Build Coastguard Worker   }
533*d9f75844SAndroid Build Coastguard Worker   return nullptr;
534*d9f75844SAndroid Build Coastguard Worker }
535*d9f75844SAndroid Build Coastguard Worker 
536*d9f75844SAndroid Build Coastguard Worker const std::vector<FakeFlexfecReceiveStream*>&
GetFlexfecReceiveStreams()537*d9f75844SAndroid Build Coastguard Worker FakeCall::GetFlexfecReceiveStreams() {
538*d9f75844SAndroid Build Coastguard Worker   return flexfec_receive_streams_;
539*d9f75844SAndroid Build Coastguard Worker }
540*d9f75844SAndroid Build Coastguard Worker 
GetNetworkState(webrtc::MediaType media) const541*d9f75844SAndroid Build Coastguard Worker webrtc::NetworkState FakeCall::GetNetworkState(webrtc::MediaType media) const {
542*d9f75844SAndroid Build Coastguard Worker   switch (media) {
543*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::AUDIO:
544*d9f75844SAndroid Build Coastguard Worker       return audio_network_state_;
545*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::VIDEO:
546*d9f75844SAndroid Build Coastguard Worker       return video_network_state_;
547*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::DATA:
548*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::ANY:
549*d9f75844SAndroid Build Coastguard Worker       ADD_FAILURE() << "GetNetworkState called with unknown parameter.";
550*d9f75844SAndroid Build Coastguard Worker       return webrtc::kNetworkDown;
551*d9f75844SAndroid Build Coastguard Worker   }
552*d9f75844SAndroid Build Coastguard Worker   // Even though all the values for the enum class are listed above,the compiler
553*d9f75844SAndroid Build Coastguard Worker   // will emit a warning as the method may be called with a value outside of the
554*d9f75844SAndroid Build Coastguard Worker   // valid enum range, unless this case is also handled.
555*d9f75844SAndroid Build Coastguard Worker   ADD_FAILURE() << "GetNetworkState called with unknown parameter.";
556*d9f75844SAndroid Build Coastguard Worker   return webrtc::kNetworkDown;
557*d9f75844SAndroid Build Coastguard Worker }
558*d9f75844SAndroid Build Coastguard Worker 
CreateAudioSendStream(const webrtc::AudioSendStream::Config & config)559*d9f75844SAndroid Build Coastguard Worker webrtc::AudioSendStream* FakeCall::CreateAudioSendStream(
560*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioSendStream::Config& config) {
561*d9f75844SAndroid Build Coastguard Worker   FakeAudioSendStream* fake_stream =
562*d9f75844SAndroid Build Coastguard Worker       new FakeAudioSendStream(next_stream_id_++, config);
563*d9f75844SAndroid Build Coastguard Worker   audio_send_streams_.push_back(fake_stream);
564*d9f75844SAndroid Build Coastguard Worker   ++num_created_send_streams_;
565*d9f75844SAndroid Build Coastguard Worker   return fake_stream;
566*d9f75844SAndroid Build Coastguard Worker }
567*d9f75844SAndroid Build Coastguard Worker 
DestroyAudioSendStream(webrtc::AudioSendStream * send_stream)568*d9f75844SAndroid Build Coastguard Worker void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
569*d9f75844SAndroid Build Coastguard Worker   auto it = absl::c_find(audio_send_streams_,
570*d9f75844SAndroid Build Coastguard Worker                          static_cast<FakeAudioSendStream*>(send_stream));
571*d9f75844SAndroid Build Coastguard Worker   if (it == audio_send_streams_.end()) {
572*d9f75844SAndroid Build Coastguard Worker     ADD_FAILURE() << "DestroyAudioSendStream called with unknown parameter.";
573*d9f75844SAndroid Build Coastguard Worker   } else {
574*d9f75844SAndroid Build Coastguard Worker     delete *it;
575*d9f75844SAndroid Build Coastguard Worker     audio_send_streams_.erase(it);
576*d9f75844SAndroid Build Coastguard Worker   }
577*d9f75844SAndroid Build Coastguard Worker }
578*d9f75844SAndroid Build Coastguard Worker 
CreateAudioReceiveStream(const webrtc::AudioReceiveStreamInterface::Config & config)579*d9f75844SAndroid Build Coastguard Worker webrtc::AudioReceiveStreamInterface* FakeCall::CreateAudioReceiveStream(
580*d9f75844SAndroid Build Coastguard Worker     const webrtc::AudioReceiveStreamInterface::Config& config) {
581*d9f75844SAndroid Build Coastguard Worker   audio_receive_streams_.push_back(
582*d9f75844SAndroid Build Coastguard Worker       new FakeAudioReceiveStream(next_stream_id_++, config));
583*d9f75844SAndroid Build Coastguard Worker   ++num_created_receive_streams_;
584*d9f75844SAndroid Build Coastguard Worker   return audio_receive_streams_.back();
585*d9f75844SAndroid Build Coastguard Worker }
586*d9f75844SAndroid Build Coastguard Worker 
DestroyAudioReceiveStream(webrtc::AudioReceiveStreamInterface * receive_stream)587*d9f75844SAndroid Build Coastguard Worker void FakeCall::DestroyAudioReceiveStream(
588*d9f75844SAndroid Build Coastguard Worker     webrtc::AudioReceiveStreamInterface* receive_stream) {
589*d9f75844SAndroid Build Coastguard Worker   auto it = absl::c_find(audio_receive_streams_,
590*d9f75844SAndroid Build Coastguard Worker                          static_cast<FakeAudioReceiveStream*>(receive_stream));
591*d9f75844SAndroid Build Coastguard Worker   if (it == audio_receive_streams_.end()) {
592*d9f75844SAndroid Build Coastguard Worker     ADD_FAILURE() << "DestroyAudioReceiveStream called with unknown parameter.";
593*d9f75844SAndroid Build Coastguard Worker   } else {
594*d9f75844SAndroid Build Coastguard Worker     delete *it;
595*d9f75844SAndroid Build Coastguard Worker     audio_receive_streams_.erase(it);
596*d9f75844SAndroid Build Coastguard Worker   }
597*d9f75844SAndroid Build Coastguard Worker }
598*d9f75844SAndroid Build Coastguard Worker 
CreateVideoSendStream(webrtc::VideoSendStream::Config config,webrtc::VideoEncoderConfig encoder_config)599*d9f75844SAndroid Build Coastguard Worker webrtc::VideoSendStream* FakeCall::CreateVideoSendStream(
600*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoSendStream::Config config,
601*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoEncoderConfig encoder_config) {
602*d9f75844SAndroid Build Coastguard Worker   FakeVideoSendStream* fake_stream =
603*d9f75844SAndroid Build Coastguard Worker       new FakeVideoSendStream(std::move(config), std::move(encoder_config));
604*d9f75844SAndroid Build Coastguard Worker   video_send_streams_.push_back(fake_stream);
605*d9f75844SAndroid Build Coastguard Worker   ++num_created_send_streams_;
606*d9f75844SAndroid Build Coastguard Worker   return fake_stream;
607*d9f75844SAndroid Build Coastguard Worker }
608*d9f75844SAndroid Build Coastguard Worker 
DestroyVideoSendStream(webrtc::VideoSendStream * send_stream)609*d9f75844SAndroid Build Coastguard Worker void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
610*d9f75844SAndroid Build Coastguard Worker   auto it = absl::c_find(video_send_streams_,
611*d9f75844SAndroid Build Coastguard Worker                          static_cast<FakeVideoSendStream*>(send_stream));
612*d9f75844SAndroid Build Coastguard Worker   if (it == video_send_streams_.end()) {
613*d9f75844SAndroid Build Coastguard Worker     ADD_FAILURE() << "DestroyVideoSendStream called with unknown parameter.";
614*d9f75844SAndroid Build Coastguard Worker   } else {
615*d9f75844SAndroid Build Coastguard Worker     delete *it;
616*d9f75844SAndroid Build Coastguard Worker     video_send_streams_.erase(it);
617*d9f75844SAndroid Build Coastguard Worker   }
618*d9f75844SAndroid Build Coastguard Worker }
619*d9f75844SAndroid Build Coastguard Worker 
CreateVideoReceiveStream(webrtc::VideoReceiveStreamInterface::Config config)620*d9f75844SAndroid Build Coastguard Worker webrtc::VideoReceiveStreamInterface* FakeCall::CreateVideoReceiveStream(
621*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoReceiveStreamInterface::Config config) {
622*d9f75844SAndroid Build Coastguard Worker   video_receive_streams_.push_back(
623*d9f75844SAndroid Build Coastguard Worker       new FakeVideoReceiveStream(std::move(config)));
624*d9f75844SAndroid Build Coastguard Worker   ++num_created_receive_streams_;
625*d9f75844SAndroid Build Coastguard Worker   return video_receive_streams_.back();
626*d9f75844SAndroid Build Coastguard Worker }
627*d9f75844SAndroid Build Coastguard Worker 
DestroyVideoReceiveStream(webrtc::VideoReceiveStreamInterface * receive_stream)628*d9f75844SAndroid Build Coastguard Worker void FakeCall::DestroyVideoReceiveStream(
629*d9f75844SAndroid Build Coastguard Worker     webrtc::VideoReceiveStreamInterface* receive_stream) {
630*d9f75844SAndroid Build Coastguard Worker   auto it = absl::c_find(video_receive_streams_,
631*d9f75844SAndroid Build Coastguard Worker                          static_cast<FakeVideoReceiveStream*>(receive_stream));
632*d9f75844SAndroid Build Coastguard Worker   if (it == video_receive_streams_.end()) {
633*d9f75844SAndroid Build Coastguard Worker     ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown parameter.";
634*d9f75844SAndroid Build Coastguard Worker   } else {
635*d9f75844SAndroid Build Coastguard Worker     delete *it;
636*d9f75844SAndroid Build Coastguard Worker     video_receive_streams_.erase(it);
637*d9f75844SAndroid Build Coastguard Worker   }
638*d9f75844SAndroid Build Coastguard Worker }
639*d9f75844SAndroid Build Coastguard Worker 
CreateFlexfecReceiveStream(const webrtc::FlexfecReceiveStream::Config config)640*d9f75844SAndroid Build Coastguard Worker webrtc::FlexfecReceiveStream* FakeCall::CreateFlexfecReceiveStream(
641*d9f75844SAndroid Build Coastguard Worker     const webrtc::FlexfecReceiveStream::Config config) {
642*d9f75844SAndroid Build Coastguard Worker   FakeFlexfecReceiveStream* fake_stream =
643*d9f75844SAndroid Build Coastguard Worker       new FakeFlexfecReceiveStream(std::move(config));
644*d9f75844SAndroid Build Coastguard Worker   flexfec_receive_streams_.push_back(fake_stream);
645*d9f75844SAndroid Build Coastguard Worker   ++num_created_receive_streams_;
646*d9f75844SAndroid Build Coastguard Worker   return fake_stream;
647*d9f75844SAndroid Build Coastguard Worker }
648*d9f75844SAndroid Build Coastguard Worker 
DestroyFlexfecReceiveStream(webrtc::FlexfecReceiveStream * receive_stream)649*d9f75844SAndroid Build Coastguard Worker void FakeCall::DestroyFlexfecReceiveStream(
650*d9f75844SAndroid Build Coastguard Worker     webrtc::FlexfecReceiveStream* receive_stream) {
651*d9f75844SAndroid Build Coastguard Worker   auto it =
652*d9f75844SAndroid Build Coastguard Worker       absl::c_find(flexfec_receive_streams_,
653*d9f75844SAndroid Build Coastguard Worker                    static_cast<FakeFlexfecReceiveStream*>(receive_stream));
654*d9f75844SAndroid Build Coastguard Worker   if (it == flexfec_receive_streams_.end()) {
655*d9f75844SAndroid Build Coastguard Worker     ADD_FAILURE()
656*d9f75844SAndroid Build Coastguard Worker         << "DestroyFlexfecReceiveStream called with unknown parameter.";
657*d9f75844SAndroid Build Coastguard Worker   } else {
658*d9f75844SAndroid Build Coastguard Worker     delete *it;
659*d9f75844SAndroid Build Coastguard Worker     flexfec_receive_streams_.erase(it);
660*d9f75844SAndroid Build Coastguard Worker   }
661*d9f75844SAndroid Build Coastguard Worker }
662*d9f75844SAndroid Build Coastguard Worker 
AddAdaptationResource(rtc::scoped_refptr<webrtc::Resource> resource)663*d9f75844SAndroid Build Coastguard Worker void FakeCall::AddAdaptationResource(
664*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::Resource> resource) {}
665*d9f75844SAndroid Build Coastguard Worker 
Receiver()666*d9f75844SAndroid Build Coastguard Worker webrtc::PacketReceiver* FakeCall::Receiver() {
667*d9f75844SAndroid Build Coastguard Worker   return this;
668*d9f75844SAndroid Build Coastguard Worker }
669*d9f75844SAndroid Build Coastguard Worker 
DeliverPacket(webrtc::MediaType media_type,rtc::CopyOnWriteBuffer packet,int64_t packet_time_us)670*d9f75844SAndroid Build Coastguard Worker FakeCall::DeliveryStatus FakeCall::DeliverPacket(webrtc::MediaType media_type,
671*d9f75844SAndroid Build Coastguard Worker                                                  rtc::CopyOnWriteBuffer packet,
672*d9f75844SAndroid Build Coastguard Worker                                                  int64_t packet_time_us) {
673*d9f75844SAndroid Build Coastguard Worker   EXPECT_GE(packet.size(), 12u);
674*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(media_type == webrtc::MediaType::AUDIO ||
675*d9f75844SAndroid Build Coastguard Worker              media_type == webrtc::MediaType::VIDEO);
676*d9f75844SAndroid Build Coastguard Worker 
677*d9f75844SAndroid Build Coastguard Worker   if (!webrtc::IsRtpPacket(packet)) {
678*d9f75844SAndroid Build Coastguard Worker     return DELIVERY_PACKET_ERROR;
679*d9f75844SAndroid Build Coastguard Worker   }
680*d9f75844SAndroid Build Coastguard Worker 
681*d9f75844SAndroid Build Coastguard Worker   uint32_t ssrc = ParseRtpSsrc(packet);
682*d9f75844SAndroid Build Coastguard Worker   if (media_type == webrtc::MediaType::VIDEO) {
683*d9f75844SAndroid Build Coastguard Worker     for (auto receiver : video_receive_streams_) {
684*d9f75844SAndroid Build Coastguard Worker       if (receiver->GetConfig().rtp.remote_ssrc == ssrc) {
685*d9f75844SAndroid Build Coastguard Worker         ++delivered_packets_by_ssrc_[ssrc];
686*d9f75844SAndroid Build Coastguard Worker         return DELIVERY_OK;
687*d9f75844SAndroid Build Coastguard Worker       }
688*d9f75844SAndroid Build Coastguard Worker     }
689*d9f75844SAndroid Build Coastguard Worker   }
690*d9f75844SAndroid Build Coastguard Worker   if (media_type == webrtc::MediaType::AUDIO) {
691*d9f75844SAndroid Build Coastguard Worker     for (auto receiver : audio_receive_streams_) {
692*d9f75844SAndroid Build Coastguard Worker       if (receiver->GetConfig().rtp.remote_ssrc == ssrc) {
693*d9f75844SAndroid Build Coastguard Worker         receiver->DeliverRtp(packet.cdata(), packet.size(), packet_time_us);
694*d9f75844SAndroid Build Coastguard Worker         ++delivered_packets_by_ssrc_[ssrc];
695*d9f75844SAndroid Build Coastguard Worker         return DELIVERY_OK;
696*d9f75844SAndroid Build Coastguard Worker       }
697*d9f75844SAndroid Build Coastguard Worker     }
698*d9f75844SAndroid Build Coastguard Worker   }
699*d9f75844SAndroid Build Coastguard Worker   return DELIVERY_UNKNOWN_SSRC;
700*d9f75844SAndroid Build Coastguard Worker }
701*d9f75844SAndroid Build Coastguard Worker 
SetStats(const webrtc::Call::Stats & stats)702*d9f75844SAndroid Build Coastguard Worker void FakeCall::SetStats(const webrtc::Call::Stats& stats) {
703*d9f75844SAndroid Build Coastguard Worker   stats_ = stats;
704*d9f75844SAndroid Build Coastguard Worker }
705*d9f75844SAndroid Build Coastguard Worker 
GetNumCreatedSendStreams() const706*d9f75844SAndroid Build Coastguard Worker int FakeCall::GetNumCreatedSendStreams() const {
707*d9f75844SAndroid Build Coastguard Worker   return num_created_send_streams_;
708*d9f75844SAndroid Build Coastguard Worker }
709*d9f75844SAndroid Build Coastguard Worker 
GetNumCreatedReceiveStreams() const710*d9f75844SAndroid Build Coastguard Worker int FakeCall::GetNumCreatedReceiveStreams() const {
711*d9f75844SAndroid Build Coastguard Worker   return num_created_receive_streams_;
712*d9f75844SAndroid Build Coastguard Worker }
713*d9f75844SAndroid Build Coastguard Worker 
GetStats() const714*d9f75844SAndroid Build Coastguard Worker webrtc::Call::Stats FakeCall::GetStats() const {
715*d9f75844SAndroid Build Coastguard Worker   return stats_;
716*d9f75844SAndroid Build Coastguard Worker }
717*d9f75844SAndroid Build Coastguard Worker 
network_thread() const718*d9f75844SAndroid Build Coastguard Worker webrtc::TaskQueueBase* FakeCall::network_thread() const {
719*d9f75844SAndroid Build Coastguard Worker   return network_thread_;
720*d9f75844SAndroid Build Coastguard Worker }
721*d9f75844SAndroid Build Coastguard Worker 
worker_thread() const722*d9f75844SAndroid Build Coastguard Worker webrtc::TaskQueueBase* FakeCall::worker_thread() const {
723*d9f75844SAndroid Build Coastguard Worker   return worker_thread_;
724*d9f75844SAndroid Build Coastguard Worker }
725*d9f75844SAndroid Build Coastguard Worker 
SignalChannelNetworkState(webrtc::MediaType media,webrtc::NetworkState state)726*d9f75844SAndroid Build Coastguard Worker void FakeCall::SignalChannelNetworkState(webrtc::MediaType media,
727*d9f75844SAndroid Build Coastguard Worker                                          webrtc::NetworkState state) {
728*d9f75844SAndroid Build Coastguard Worker   switch (media) {
729*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::AUDIO:
730*d9f75844SAndroid Build Coastguard Worker       audio_network_state_ = state;
731*d9f75844SAndroid Build Coastguard Worker       break;
732*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::VIDEO:
733*d9f75844SAndroid Build Coastguard Worker       video_network_state_ = state;
734*d9f75844SAndroid Build Coastguard Worker       break;
735*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::DATA:
736*d9f75844SAndroid Build Coastguard Worker     case webrtc::MediaType::ANY:
737*d9f75844SAndroid Build Coastguard Worker       ADD_FAILURE()
738*d9f75844SAndroid Build Coastguard Worker           << "SignalChannelNetworkState called with unknown parameter.";
739*d9f75844SAndroid Build Coastguard Worker   }
740*d9f75844SAndroid Build Coastguard Worker }
741*d9f75844SAndroid Build Coastguard Worker 
OnAudioTransportOverheadChanged(int transport_overhead_per_packet)742*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnAudioTransportOverheadChanged(
743*d9f75844SAndroid Build Coastguard Worker     int transport_overhead_per_packet) {}
744*d9f75844SAndroid Build Coastguard Worker 
OnLocalSsrcUpdated(webrtc::AudioReceiveStreamInterface & stream,uint32_t local_ssrc)745*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnLocalSsrcUpdated(webrtc::AudioReceiveStreamInterface& stream,
746*d9f75844SAndroid Build Coastguard Worker                                   uint32_t local_ssrc) {
747*d9f75844SAndroid Build Coastguard Worker   auto& fake_stream = static_cast<FakeAudioReceiveStream&>(stream);
748*d9f75844SAndroid Build Coastguard Worker   fake_stream.SetLocalSsrc(local_ssrc);
749*d9f75844SAndroid Build Coastguard Worker }
750*d9f75844SAndroid Build Coastguard Worker 
OnLocalSsrcUpdated(webrtc::VideoReceiveStreamInterface & stream,uint32_t local_ssrc)751*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnLocalSsrcUpdated(webrtc::VideoReceiveStreamInterface& stream,
752*d9f75844SAndroid Build Coastguard Worker                                   uint32_t local_ssrc) {
753*d9f75844SAndroid Build Coastguard Worker   auto& fake_stream = static_cast<FakeVideoReceiveStream&>(stream);
754*d9f75844SAndroid Build Coastguard Worker   fake_stream.SetLocalSsrc(local_ssrc);
755*d9f75844SAndroid Build Coastguard Worker }
756*d9f75844SAndroid Build Coastguard Worker 
OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream & stream,uint32_t local_ssrc)757*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream& stream,
758*d9f75844SAndroid Build Coastguard Worker                                   uint32_t local_ssrc) {
759*d9f75844SAndroid Build Coastguard Worker   auto& fake_stream = static_cast<FakeFlexfecReceiveStream&>(stream);
760*d9f75844SAndroid Build Coastguard Worker   fake_stream.SetLocalSsrc(local_ssrc);
761*d9f75844SAndroid Build Coastguard Worker }
762*d9f75844SAndroid Build Coastguard Worker 
OnUpdateSyncGroup(webrtc::AudioReceiveStreamInterface & stream,absl::string_view sync_group)763*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnUpdateSyncGroup(webrtc::AudioReceiveStreamInterface& stream,
764*d9f75844SAndroid Build Coastguard Worker                                  absl::string_view sync_group) {
765*d9f75844SAndroid Build Coastguard Worker   auto& fake_stream = static_cast<FakeAudioReceiveStream&>(stream);
766*d9f75844SAndroid Build Coastguard Worker   fake_stream.SetSyncGroup(sync_group);
767*d9f75844SAndroid Build Coastguard Worker }
768*d9f75844SAndroid Build Coastguard Worker 
OnSentPacket(const rtc::SentPacket & sent_packet)769*d9f75844SAndroid Build Coastguard Worker void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) {
770*d9f75844SAndroid Build Coastguard Worker   last_sent_packet_ = sent_packet;
771*d9f75844SAndroid Build Coastguard Worker   if (sent_packet.packet_id >= 0) {
772*d9f75844SAndroid Build Coastguard Worker     last_sent_nonnegative_packet_id_ = sent_packet.packet_id;
773*d9f75844SAndroid Build Coastguard Worker   }
774*d9f75844SAndroid Build Coastguard Worker }
775*d9f75844SAndroid Build Coastguard Worker 
776*d9f75844SAndroid Build Coastguard Worker }  // namespace cricket
777