Reland "Remove Invoke from VideoChannel::FillBitrateInfo."
This reverts commit 48a4d33719390b7bcaf8445a1581a00825f67bfb. Reason for reland: Relanding the original change but without the modification for VideoSendStream::GetStats. Essentially there's a TODO there to fix the downstream issue, which seems to be benign. Original change's description: > Revert "Remove Invoke from VideoChannel::FillBitrateInfo." > > This reverts commit 1a1795768e1bdb65054ebe15aa238c6edc78dd14. > > Reason for revert: Speculative revert (breaks downstream project). > > Original change's description: > > Remove Invoke from VideoChannel::FillBitrateInfo. > > > > The method is relied upon by StatsCollector where it was called from the > > signaling thread in a loop. Now there's at most one invoke (not N). > > > > Uncommenting thread checks and removing TODOs in SendStatisticsProxy, > > VideoSendStream. Updating all related tests that fetched stats from > > the wrong context. > > > > Bug: webrtc:12726 > > Change-Id: Ia7db1afd7e103ec4f9816f5647203c4e2495586e > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216688 > > Commit-Queue: Tommi <tommi@webrtc.org> > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#33894} > > TBR=ilnik@webrtc.org,nisse@webrtc.org,tommi@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I2520957cdb33492d187f04320c7416788fd0f820 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:12726 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217240 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#33898} # Not skipping CQ checks because this is a reland. Bug: webrtc:12726 Change-Id: I41cce3b11a29905cde982c22e82b9b1f5a98e654 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217222 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Tommi <tommi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33902}
This commit is contained in:
parent
9c4d3163f4
commit
788d805c38
@ -654,7 +654,8 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
|
|||||||
static const int kAcceptableBitrateErrorMargin = 15; // +- 7
|
static const int kAcceptableBitrateErrorMargin = 15; // +- 7
|
||||||
class BitrateObserver : public test::EndToEndTest {
|
class BitrateObserver : public test::EndToEndTest {
|
||||||
public:
|
public:
|
||||||
explicit BitrateObserver(bool using_min_transmit_bitrate)
|
explicit BitrateObserver(bool using_min_transmit_bitrate,
|
||||||
|
TaskQueueBase* task_queue)
|
||||||
: EndToEndTest(kLongTimeoutMs),
|
: EndToEndTest(kLongTimeoutMs),
|
||||||
send_stream_(nullptr),
|
send_stream_(nullptr),
|
||||||
converged_(false),
|
converged_(false),
|
||||||
@ -667,12 +668,15 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
|
|||||||
? kMaxAcceptableTransmitBitrate
|
? kMaxAcceptableTransmitBitrate
|
||||||
: (kMaxEncodeBitrateKbps +
|
: (kMaxEncodeBitrateKbps +
|
||||||
kAcceptableBitrateErrorMargin / 2)),
|
kAcceptableBitrateErrorMargin / 2)),
|
||||||
num_bitrate_observations_in_range_(0) {}
|
num_bitrate_observations_in_range_(0),
|
||||||
|
task_queue_(task_queue) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO(holmer): Run this with a timer instead of once per packet.
|
// TODO(holmer): Run this with a timer instead of once per packet.
|
||||||
Action OnSendRtp(const uint8_t* packet, size_t length) override {
|
Action OnSendRtp(const uint8_t* packet, size_t length) override {
|
||||||
|
task_queue_->PostTask(ToQueuedTask([this]() {
|
||||||
VideoSendStream::Stats stats = send_stream_->GetStats();
|
VideoSendStream::Stats stats = send_stream_->GetStats();
|
||||||
|
|
||||||
if (!stats.substreams.empty()) {
|
if (!stats.substreams.empty()) {
|
||||||
RTC_DCHECK_EQ(1, stats.substreams.size());
|
RTC_DCHECK_EQ(1, stats.substreams.size());
|
||||||
int bitrate_kbps =
|
int bitrate_kbps =
|
||||||
@ -688,6 +692,7 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
|
|||||||
if (converged_)
|
if (converged_)
|
||||||
bitrate_kbps_list_.push_back(bitrate_kbps);
|
bitrate_kbps_list_.push_back(bitrate_kbps);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +729,8 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
|
|||||||
const int max_acceptable_bitrate_;
|
const int max_acceptable_bitrate_;
|
||||||
int num_bitrate_observations_in_range_;
|
int num_bitrate_observations_in_range_;
|
||||||
std::vector<double> bitrate_kbps_list_;
|
std::vector<double> bitrate_kbps_list_;
|
||||||
} test(pad_to_min_bitrate);
|
TaskQueueBase* task_queue_;
|
||||||
|
} test(pad_to_min_bitrate, task_queue());
|
||||||
|
|
||||||
fake_encoder_max_bitrate_ = kMaxEncodeBitrateKbps;
|
fake_encoder_max_bitrate_ = kMaxEncodeBitrateKbps;
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
@ -775,7 +781,7 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||||||
|
|
||||||
class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder {
|
class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder {
|
||||||
public:
|
public:
|
||||||
BitrateObserver()
|
explicit BitrateObserver(TaskQueueBase* task_queue)
|
||||||
: EndToEndTest(kDefaultTimeoutMs),
|
: EndToEndTest(kDefaultTimeoutMs),
|
||||||
FakeEncoder(Clock::GetRealTimeClock()),
|
FakeEncoder(Clock::GetRealTimeClock()),
|
||||||
encoder_inits_(0),
|
encoder_inits_(0),
|
||||||
@ -784,7 +790,8 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||||||
frame_generator_(nullptr),
|
frame_generator_(nullptr),
|
||||||
encoder_factory_(this),
|
encoder_factory_(this),
|
||||||
bitrate_allocator_factory_(
|
bitrate_allocator_factory_(
|
||||||
CreateBuiltinVideoBitrateAllocatorFactory()) {}
|
CreateBuiltinVideoBitrateAllocatorFactory()),
|
||||||
|
task_queue_(task_queue) {}
|
||||||
|
|
||||||
int32_t InitEncode(const VideoCodec* config,
|
int32_t InitEncode(const VideoCodec* config,
|
||||||
const VideoEncoder::Settings& settings) override {
|
const VideoEncoder::Settings& settings) override {
|
||||||
@ -854,7 +861,9 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||||||
ASSERT_TRUE(time_to_reconfigure_.Wait(kDefaultTimeoutMs))
|
ASSERT_TRUE(time_to_reconfigure_.Wait(kDefaultTimeoutMs))
|
||||||
<< "Timed out before receiving an initial high bitrate.";
|
<< "Timed out before receiving an initial high bitrate.";
|
||||||
frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2);
|
frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2);
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_, [&]() {
|
||||||
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
||||||
|
});
|
||||||
EXPECT_TRUE(Wait())
|
EXPECT_TRUE(Wait())
|
||||||
<< "Timed out while waiting for a couple of high bitrate estimates "
|
<< "Timed out while waiting for a couple of high bitrate estimates "
|
||||||
"after reconfiguring the send stream.";
|
"after reconfiguring the send stream.";
|
||||||
@ -869,7 +878,8 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
|
|||||||
test::VideoEncoderProxyFactory encoder_factory_;
|
test::VideoEncoderProxyFactory encoder_factory_;
|
||||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||||
VideoEncoderConfig encoder_config_;
|
VideoEncoderConfig encoder_config_;
|
||||||
} test;
|
TaskQueueBase* task_queue_;
|
||||||
|
} test(task_queue());
|
||||||
|
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -370,7 +370,10 @@ void RampUpTester::TriggerTestDone() {
|
|||||||
if (!send_stream_)
|
if (!send_stream_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VideoSendStream::Stats send_stats = send_stream_->GetStats();
|
VideoSendStream::Stats send_stats;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_,
|
||||||
|
[&] { send_stats = send_stream_->GetStats(); });
|
||||||
|
|
||||||
send_stream_ = nullptr; // To avoid dereferencing a bad pointer.
|
send_stream_ = nullptr; // To avoid dereferencing a bad pointer.
|
||||||
|
|
||||||
size_t total_packets_sent = 0;
|
size_t total_packets_sent = 0;
|
||||||
|
|||||||
@ -275,14 +275,14 @@ void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) {
|
|||||||
sps_ = SpsParser::ParseSps(slice + H264::kNaluTypeSize,
|
sps_ = SpsParser::ParseSps(slice + H264::kNaluTypeSize,
|
||||||
length - H264::kNaluTypeSize);
|
length - H264::kNaluTypeSize);
|
||||||
if (!sps_)
|
if (!sps_)
|
||||||
RTC_LOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream.";
|
RTC_DLOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H264::NaluType::kPps: {
|
case H264::NaluType::kPps: {
|
||||||
pps_ = PpsParser::ParsePps(slice + H264::kNaluTypeSize,
|
pps_ = PpsParser::ParsePps(slice + H264::kNaluTypeSize,
|
||||||
length - H264::kNaluTypeSize);
|
length - H264::kNaluTypeSize);
|
||||||
if (!pps_)
|
if (!pps_)
|
||||||
RTC_LOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream.";
|
RTC_DLOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H264::NaluType::kAud:
|
case H264::NaluType::kAud:
|
||||||
@ -291,7 +291,7 @@ void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) {
|
|||||||
default:
|
default:
|
||||||
Result res = ParseNonParameterSetNalu(slice, length, nalu_type);
|
Result res = ParseNonParameterSetNalu(slice, length, nalu_type);
|
||||||
if (res != kOk)
|
if (res != kOk)
|
||||||
RTC_LOG(LS_INFO) << "Failed to parse bitstream. Error: " << res;
|
RTC_DLOG(LS_INFO) << "Failed to parse bitstream. Error: " << res;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1065,9 +1065,9 @@ void VideoChannel::UpdateMediaSendRecvState_w() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VideoChannel::FillBitrateInfo(BandwidthEstimationInfo* bwe_info) {
|
void VideoChannel::FillBitrateInfo(BandwidthEstimationInfo* bwe_info) {
|
||||||
|
RTC_DCHECK_RUN_ON(worker_thread());
|
||||||
VideoMediaChannel* mc = media_channel();
|
VideoMediaChannel* mc = media_channel();
|
||||||
InvokeOnWorker<void>(RTC_FROM_HERE,
|
mc->FillBitrateInfo(bwe_info);
|
||||||
[mc, bwe_info] { mc->FillBitrateInfo(bwe_info); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
|
bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
|
||||||
|
|||||||
@ -1026,16 +1026,25 @@ void StatsCollector::ExtractBweInfo() {
|
|||||||
|
|
||||||
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
|
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
|
||||||
// TODO(holmer): Also fill this in for audio.
|
// TODO(holmer): Also fill this in for audio.
|
||||||
for (const auto& transceiver : pc_->GetTransceiversInternal()) {
|
auto transceivers = pc_->GetTransceiversInternal();
|
||||||
|
std::vector<cricket::VideoChannel*> video_channels;
|
||||||
|
for (const auto& transceiver : transceivers) {
|
||||||
if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) {
|
if (transceiver->media_type() != cricket::MEDIA_TYPE_VIDEO) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto* video_channel =
|
auto* video_channel =
|
||||||
static_cast<cricket::VideoChannel*>(transceiver->internal()->channel());
|
static_cast<cricket::VideoChannel*>(transceiver->internal()->channel());
|
||||||
if (!video_channel) {
|
if (video_channel) {
|
||||||
continue;
|
video_channels.push_back(video_channel);
|
||||||
}
|
}
|
||||||
video_channel->FillBitrateInfo(&bwe_info);
|
}
|
||||||
|
|
||||||
|
if (!video_channels.empty()) {
|
||||||
|
pc_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&] {
|
||||||
|
for (const auto& channel : video_channels) {
|
||||||
|
channel->FillBitrateInfo(&bwe_info);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
|
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
|
||||||
|
|||||||
@ -182,7 +182,11 @@ TEST(ScenarioTest,
|
|||||||
s.RunFor(TimeDelta::Seconds(10));
|
s.RunFor(TimeDelta::Seconds(10));
|
||||||
// Make sure retransmissions have happened.
|
// Make sure retransmissions have happened.
|
||||||
int retransmit_packets = 0;
|
int retransmit_packets = 0;
|
||||||
for (const auto& substream : video->send()->GetStats().substreams) {
|
|
||||||
|
VideoSendStream::Stats stats;
|
||||||
|
alice->SendTask([&]() { stats = video->send()->GetStats(); });
|
||||||
|
|
||||||
|
for (const auto& substream : stats.substreams) {
|
||||||
retransmit_packets += substream.second.rtp_stats.retransmitted.packets;
|
retransmit_packets += substream.second.rtp_stats.retransmitted.packets;
|
||||||
}
|
}
|
||||||
EXPECT_GT(retransmit_packets, 0);
|
EXPECT_GT(retransmit_packets, 0);
|
||||||
|
|||||||
@ -33,8 +33,14 @@ void CreateAnalyzedStream(Scenario* s,
|
|||||||
auto* audio = s->CreateAudioStream(route->forward(), AudioStreamConfig());
|
auto* audio = s->CreateAudioStream(route->forward(), AudioStreamConfig());
|
||||||
s->Every(TimeDelta::Seconds(1), [=] {
|
s->Every(TimeDelta::Seconds(1), [=] {
|
||||||
collectors->call.AddStats(caller->GetStats());
|
collectors->call.AddStats(caller->GetStats());
|
||||||
collectors->video_send.AddStats(video->send()->GetStats(), s->Now());
|
|
||||||
collectors->audio_receive.AddStats(audio->receive()->GetStats());
|
VideoSendStream::Stats send_stats;
|
||||||
|
caller->SendTask([&]() { send_stats = video->send()->GetStats(); });
|
||||||
|
collectors->video_send.AddStats(send_stats, s->Now());
|
||||||
|
|
||||||
|
AudioReceiveStream::Stats receive_stats;
|
||||||
|
caller->SendTask([&]() { receive_stats = audio->receive()->GetStats(); });
|
||||||
|
collectors->audio_receive.AddStats(receive_stats);
|
||||||
|
|
||||||
// Querying the video stats from within the expected runtime environment
|
// Querying the video stats from within the expected runtime environment
|
||||||
// (i.e. the TQ that belongs to the CallClient, not the Scenario TQ that
|
// (i.e. the TQ that belongs to the CallClient, not the Scenario TQ that
|
||||||
|
|||||||
@ -130,7 +130,9 @@ TEST(VideoStreamTest, SendsNacksOnLoss) {
|
|||||||
auto video = s.CreateVideoStream(route->forward(), VideoStreamConfig());
|
auto video = s.CreateVideoStream(route->forward(), VideoStreamConfig());
|
||||||
s.RunFor(TimeDelta::Seconds(1));
|
s.RunFor(TimeDelta::Seconds(1));
|
||||||
int retransmit_packets = 0;
|
int retransmit_packets = 0;
|
||||||
for (const auto& substream : video->send()->GetStats().substreams) {
|
VideoSendStream::Stats stats;
|
||||||
|
route->first()->SendTask([&]() { stats = video->send()->GetStats(); });
|
||||||
|
for (const auto& substream : stats.substreams) {
|
||||||
retransmit_packets += substream.second.rtp_stats.retransmitted.packets;
|
retransmit_packets += substream.second.rtp_stats.retransmitted.packets;
|
||||||
}
|
}
|
||||||
EXPECT_GT(retransmit_packets, 0);
|
EXPECT_GT(retransmit_packets, 0);
|
||||||
@ -152,7 +154,8 @@ TEST(VideoStreamTest, SendsFecWithUlpFec) {
|
|||||||
c->stream.use_ulpfec = true;
|
c->stream.use_ulpfec = true;
|
||||||
});
|
});
|
||||||
s.RunFor(TimeDelta::Seconds(5));
|
s.RunFor(TimeDelta::Seconds(5));
|
||||||
VideoSendStream::Stats video_stats = video->send()->GetStats();
|
VideoSendStream::Stats video_stats;
|
||||||
|
route->first()->SendTask([&]() { video_stats = video->send()->GetStats(); });
|
||||||
EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u);
|
EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u);
|
||||||
}
|
}
|
||||||
TEST(VideoStreamTest, SendsFecWithFlexFec) {
|
TEST(VideoStreamTest, SendsFecWithFlexFec) {
|
||||||
@ -169,7 +172,8 @@ TEST(VideoStreamTest, SendsFecWithFlexFec) {
|
|||||||
c->stream.use_flexfec = true;
|
c->stream.use_flexfec = true;
|
||||||
});
|
});
|
||||||
s.RunFor(TimeDelta::Seconds(5));
|
s.RunFor(TimeDelta::Seconds(5));
|
||||||
VideoSendStream::Stats video_stats = video->send()->GetStats();
|
VideoSendStream::Stats video_stats;
|
||||||
|
route->first()->SendTask([&]() { video_stats = video->send()->GetStats(); });
|
||||||
EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u);
|
EXPECT_GT(video_stats.substreams.begin()->second.rtp_stats.fec.packets, 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -132,13 +132,15 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs,
|
|||||||
public:
|
public:
|
||||||
SendsSetSsrcs(const uint32_t* ssrcs,
|
SendsSetSsrcs(const uint32_t* ssrcs,
|
||||||
size_t num_ssrcs,
|
size_t num_ssrcs,
|
||||||
bool send_single_ssrc_first)
|
bool send_single_ssrc_first,
|
||||||
|
TaskQueueBase* task_queue)
|
||||||
: EndToEndTest(kDefaultTimeoutMs),
|
: EndToEndTest(kDefaultTimeoutMs),
|
||||||
num_ssrcs_(num_ssrcs),
|
num_ssrcs_(num_ssrcs),
|
||||||
send_single_ssrc_first_(send_single_ssrc_first),
|
send_single_ssrc_first_(send_single_ssrc_first),
|
||||||
ssrcs_to_observe_(num_ssrcs),
|
ssrcs_to_observe_(num_ssrcs),
|
||||||
expect_single_ssrc_(send_single_ssrc_first),
|
expect_single_ssrc_(send_single_ssrc_first),
|
||||||
send_stream_(nullptr) {
|
send_stream_(nullptr),
|
||||||
|
task_queue_(task_queue) {
|
||||||
for (size_t i = 0; i < num_ssrcs; ++i)
|
for (size_t i = 0; i < num_ssrcs; ++i)
|
||||||
valid_ssrcs_[ssrcs[i]] = true;
|
valid_ssrcs_[ssrcs[i]] = true;
|
||||||
}
|
}
|
||||||
@ -200,8 +202,10 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs,
|
|||||||
|
|
||||||
if (send_single_ssrc_first_) {
|
if (send_single_ssrc_first_) {
|
||||||
// Set full simulcast and continue with the rest of the SSRCs.
|
// Set full simulcast and continue with the rest of the SSRCs.
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_, [&]() {
|
||||||
send_stream_->ReconfigureVideoEncoder(
|
send_stream_->ReconfigureVideoEncoder(
|
||||||
std::move(video_encoder_config_all_streams_));
|
std::move(video_encoder_config_all_streams_));
|
||||||
|
});
|
||||||
EXPECT_TRUE(Wait()) << "Timed out while waiting on additional SSRCs.";
|
EXPECT_TRUE(Wait()) << "Timed out while waiting on additional SSRCs.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,7 +222,8 @@ void SsrcEndToEndTest::TestSendsSetSsrcs(size_t num_ssrcs,
|
|||||||
|
|
||||||
VideoSendStream* send_stream_;
|
VideoSendStream* send_stream_;
|
||||||
VideoEncoderConfig video_encoder_config_all_streams_;
|
VideoEncoderConfig video_encoder_config_all_streams_;
|
||||||
} test(kVideoSendSsrcs, num_ssrcs, send_single_ssrc_first);
|
TaskQueueBase* task_queue_;
|
||||||
|
} test(kVideoSendSsrcs, num_ssrcs, send_single_ssrc_first, task_queue());
|
||||||
|
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,7 +154,10 @@ TEST_F(StatsEndToEndTest, GetStats) {
|
|||||||
|
|
||||||
bool CheckSendStats() {
|
bool CheckSendStats() {
|
||||||
RTC_DCHECK(send_stream_);
|
RTC_DCHECK(send_stream_);
|
||||||
VideoSendStream::Stats stats = send_stream_->GetStats();
|
|
||||||
|
VideoSendStream::Stats stats;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_,
|
||||||
|
[&]() { stats = send_stream_->GetStats(); });
|
||||||
|
|
||||||
size_t expected_num_streams =
|
size_t expected_num_streams =
|
||||||
kNumSimulcastStreams + expected_send_ssrcs_.size();
|
kNumSimulcastStreams + expected_send_ssrcs_.size();
|
||||||
|
|||||||
@ -670,6 +670,7 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms(
|
|||||||
void SendStatisticsProxy::OnEncoderReconfigured(
|
void SendStatisticsProxy::OnEncoderReconfigured(
|
||||||
const VideoEncoderConfig& config,
|
const VideoEncoderConfig& config,
|
||||||
const std::vector<VideoStream>& streams) {
|
const std::vector<VideoStream>& streams) {
|
||||||
|
// Called on VideoStreamEncoder's encoder_queue_.
|
||||||
MutexLock lock(&mutex_);
|
MutexLock lock(&mutex_);
|
||||||
|
|
||||||
if (content_type_ != config.content_type) {
|
if (content_type_ != config.content_type) {
|
||||||
|
|||||||
@ -169,7 +169,7 @@ void VideoSendStream::UpdateActiveSimulcastLayers(
|
|||||||
|
|
||||||
void VideoSendStream::Start() {
|
void VideoSendStream::Start() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
RTC_LOG(LS_INFO) << "VideoSendStream::Start";
|
RTC_DLOG(LS_INFO) << "VideoSendStream::Start";
|
||||||
VideoSendStreamImpl* send_stream = send_stream_.get();
|
VideoSendStreamImpl* send_stream = send_stream_.get();
|
||||||
worker_queue_->PostTask([this, send_stream] {
|
worker_queue_->PostTask([this, send_stream] {
|
||||||
send_stream->Start();
|
send_stream->Start();
|
||||||
@ -184,7 +184,7 @@ void VideoSendStream::Start() {
|
|||||||
|
|
||||||
void VideoSendStream::Stop() {
|
void VideoSendStream::Stop() {
|
||||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
RTC_LOG(LS_INFO) << "VideoSendStream::Stop";
|
RTC_DLOG(LS_INFO) << "VideoSendStream::Stop";
|
||||||
VideoSendStreamImpl* send_stream = send_stream_.get();
|
VideoSendStreamImpl* send_stream = send_stream_.get();
|
||||||
worker_queue_->PostTask([send_stream] { send_stream->Stop(); });
|
worker_queue_->PostTask([send_stream] { send_stream->Stop(); });
|
||||||
}
|
}
|
||||||
@ -209,10 +209,8 @@ void VideoSendStream::SetSource(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
|
void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
|
||||||
// TODO(perkj): Some test cases in VideoSendStreamTest call
|
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||||
// ReconfigureVideoEncoder from the network thread.
|
RTC_DCHECK_EQ(content_type_, config.content_type);
|
||||||
// RTC_DCHECK_RUN_ON(&thread_checker_);
|
|
||||||
RTC_DCHECK(content_type_ == config.content_type);
|
|
||||||
video_stream_encoder_->ConfigureEncoder(
|
video_stream_encoder_->ConfigureEncoder(
|
||||||
std::move(config),
|
std::move(config),
|
||||||
config_.rtp.max_packet_size - CalculateMaxHeaderSize(config_.rtp));
|
config_.rtp.max_packet_size - CalculateMaxHeaderSize(config_.rtp));
|
||||||
|
|||||||
@ -1474,7 +1474,9 @@ TEST_F(VideoSendStreamTest, MinTransmitBitrateRespectsRemb) {
|
|||||||
if (!rtp_packet.Parse(packet, length))
|
if (!rtp_packet.Parse(packet, length))
|
||||||
return DROP_PACKET;
|
return DROP_PACKET;
|
||||||
RTC_DCHECK(stream_);
|
RTC_DCHECK(stream_);
|
||||||
VideoSendStream::Stats stats = stream_->GetStats();
|
VideoSendStream::Stats stats;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_,
|
||||||
|
[&]() { stats = stream_->GetStats(); });
|
||||||
if (!stats.substreams.empty()) {
|
if (!stats.substreams.empty()) {
|
||||||
EXPECT_EQ(1u, stats.substreams.size());
|
EXPECT_EQ(1u, stats.substreams.size());
|
||||||
int total_bitrate_bps =
|
int total_bitrate_bps =
|
||||||
@ -2422,14 +2424,16 @@ class VideoCodecConfigObserver : public test::SendTest,
|
|||||||
public test::FakeEncoder {
|
public test::FakeEncoder {
|
||||||
public:
|
public:
|
||||||
VideoCodecConfigObserver(VideoCodecType video_codec_type,
|
VideoCodecConfigObserver(VideoCodecType video_codec_type,
|
||||||
const char* codec_name)
|
const char* codec_name,
|
||||||
|
TaskQueueBase* task_queue)
|
||||||
: SendTest(VideoSendStreamTest::kDefaultTimeoutMs),
|
: SendTest(VideoSendStreamTest::kDefaultTimeoutMs),
|
||||||
FakeEncoder(Clock::GetRealTimeClock()),
|
FakeEncoder(Clock::GetRealTimeClock()),
|
||||||
video_codec_type_(video_codec_type),
|
video_codec_type_(video_codec_type),
|
||||||
codec_name_(codec_name),
|
codec_name_(codec_name),
|
||||||
num_initializations_(0),
|
num_initializations_(0),
|
||||||
stream_(nullptr),
|
stream_(nullptr),
|
||||||
encoder_factory_(this) {
|
encoder_factory_(this),
|
||||||
|
task_queue_(task_queue) {
|
||||||
InitCodecSpecifics();
|
InitCodecSpecifics();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2477,7 +2481,9 @@ class VideoCodecConfigObserver : public test::SendTest,
|
|||||||
// Change encoder settings to actually trigger reconfiguration.
|
// Change encoder settings to actually trigger reconfiguration.
|
||||||
encoder_settings_.frameDroppingOn = !encoder_settings_.frameDroppingOn;
|
encoder_settings_.frameDroppingOn = !encoder_settings_.frameDroppingOn;
|
||||||
encoder_config_.encoder_specific_settings = GetEncoderSpecificSettings();
|
encoder_config_.encoder_specific_settings = GetEncoderSpecificSettings();
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_, [&]() {
|
||||||
stream_->ReconfigureVideoEncoder(std::move(encoder_config_));
|
stream_->ReconfigureVideoEncoder(std::move(encoder_config_));
|
||||||
|
});
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs));
|
init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs));
|
||||||
EXPECT_EQ(2u, num_initializations_)
|
EXPECT_EQ(2u, num_initializations_)
|
||||||
@ -2499,6 +2505,7 @@ class VideoCodecConfigObserver : public test::SendTest,
|
|||||||
VideoSendStream* stream_;
|
VideoSendStream* stream_;
|
||||||
test::VideoEncoderProxyFactory encoder_factory_;
|
test::VideoEncoderProxyFactory encoder_factory_;
|
||||||
VideoEncoderConfig encoder_config_;
|
VideoEncoderConfig encoder_config_;
|
||||||
|
TaskQueueBase* task_queue_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -2604,12 +2611,14 @@ VideoCodecConfigObserver<VideoCodecVP9>::GetEncoderSpecificSettings() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
|
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
|
||||||
VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8");
|
VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8",
|
||||||
|
task_queue());
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) {
|
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) {
|
||||||
VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9");
|
VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9",
|
||||||
|
task_queue());
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2621,7 +2630,8 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) {
|
|||||||
#define MAYBE_EncoderSetupPropagatesH264Config EncoderSetupPropagatesH264Config
|
#define MAYBE_EncoderSetupPropagatesH264Config EncoderSetupPropagatesH264Config
|
||||||
#endif
|
#endif
|
||||||
TEST_F(VideoSendStreamTest, MAYBE_EncoderSetupPropagatesH264Config) {
|
TEST_F(VideoSendStreamTest, MAYBE_EncoderSetupPropagatesH264Config) {
|
||||||
VideoCodecConfigObserver<VideoCodecH264> test(kVideoCodecH264, "H264");
|
VideoCodecConfigObserver<VideoCodecH264> test(kVideoCodecH264, "H264",
|
||||||
|
task_queue());
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2904,7 +2914,9 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) {
|
|||||||
// Encoder rate is capped by EncoderConfig max_bitrate_bps.
|
// Encoder rate is capped by EncoderConfig max_bitrate_bps.
|
||||||
WaitForSetRates(kMaxBitrateKbps);
|
WaitForSetRates(kMaxBitrateKbps);
|
||||||
encoder_config_.max_bitrate_bps = kLowerMaxBitrateKbps * 1000;
|
encoder_config_.max_bitrate_bps = kLowerMaxBitrateKbps * 1000;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_, [&]() {
|
||||||
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
||||||
|
});
|
||||||
ASSERT_TRUE(create_rate_allocator_event_.Wait(
|
ASSERT_TRUE(create_rate_allocator_event_.Wait(
|
||||||
VideoSendStreamTest::kDefaultTimeoutMs));
|
VideoSendStreamTest::kDefaultTimeoutMs));
|
||||||
EXPECT_EQ(2, num_rate_allocator_creations_)
|
EXPECT_EQ(2, num_rate_allocator_creations_)
|
||||||
@ -2914,7 +2926,9 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) {
|
|||||||
EXPECT_EQ(1, num_encoder_initializations_);
|
EXPECT_EQ(1, num_encoder_initializations_);
|
||||||
|
|
||||||
encoder_config_.max_bitrate_bps = kIncreasedMaxBitrateKbps * 1000;
|
encoder_config_.max_bitrate_bps = kIncreasedMaxBitrateKbps * 1000;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_, [&]() {
|
||||||
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
|
||||||
|
});
|
||||||
ASSERT_TRUE(create_rate_allocator_event_.Wait(
|
ASSERT_TRUE(create_rate_allocator_event_.Wait(
|
||||||
VideoSendStreamTest::kDefaultTimeoutMs));
|
VideoSendStreamTest::kDefaultTimeoutMs));
|
||||||
EXPECT_EQ(3, num_rate_allocator_creations_)
|
EXPECT_EQ(3, num_rate_allocator_creations_)
|
||||||
@ -2955,11 +2969,12 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) {
|
|||||||
class ScreencastTargetBitrateTest : public test::SendTest,
|
class ScreencastTargetBitrateTest : public test::SendTest,
|
||||||
public test::FakeEncoder {
|
public test::FakeEncoder {
|
||||||
public:
|
public:
|
||||||
ScreencastTargetBitrateTest()
|
explicit ScreencastTargetBitrateTest(TaskQueueBase* task_queue)
|
||||||
: SendTest(kDefaultTimeoutMs),
|
: SendTest(kDefaultTimeoutMs),
|
||||||
test::FakeEncoder(Clock::GetRealTimeClock()),
|
test::FakeEncoder(Clock::GetRealTimeClock()),
|
||||||
send_stream_(nullptr),
|
send_stream_(nullptr),
|
||||||
encoder_factory_(this) {}
|
encoder_factory_(this),
|
||||||
|
task_queue_(task_queue) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t Encode(const VideoFrame& input_image,
|
int32_t Encode(const VideoFrame& input_image,
|
||||||
@ -3007,7 +3022,9 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) {
|
|||||||
void PerformTest() override {
|
void PerformTest() override {
|
||||||
EXPECT_TRUE(Wait())
|
EXPECT_TRUE(Wait())
|
||||||
<< "Timed out while waiting for the encoder to send one frame.";
|
<< "Timed out while waiting for the encoder to send one frame.";
|
||||||
VideoSendStream::Stats stats = send_stream_->GetStats();
|
VideoSendStream::Stats stats;
|
||||||
|
SendTask(RTC_FROM_HERE, task_queue_,
|
||||||
|
[&]() { stats = send_stream_->GetStats(); });
|
||||||
|
|
||||||
for (size_t i = 0; i < kNumStreams; ++i) {
|
for (size_t i = 0; i < kNumStreams; ++i) {
|
||||||
ASSERT_TRUE(stats.substreams.find(kVideoSendSsrcs[i]) !=
|
ASSERT_TRUE(stats.substreams.find(kVideoSendSsrcs[i]) !=
|
||||||
@ -3029,7 +3046,8 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) {
|
|||||||
|
|
||||||
VideoSendStream* send_stream_;
|
VideoSendStream* send_stream_;
|
||||||
test::VideoEncoderProxyFactory encoder_factory_;
|
test::VideoEncoderProxyFactory encoder_factory_;
|
||||||
} test;
|
TaskQueueBase* const task_queue_;
|
||||||
|
} test(task_queue());
|
||||||
|
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
@ -3800,14 +3818,15 @@ class ContentSwitchTest : public test::SendTest {
|
|||||||
};
|
};
|
||||||
static const uint32_t kMinPacketsToSend = 50;
|
static const uint32_t kMinPacketsToSend = 50;
|
||||||
|
|
||||||
explicit ContentSwitchTest(T* stream_reset_fun)
|
explicit ContentSwitchTest(T* stream_reset_fun, TaskQueueBase* task_queue)
|
||||||
: SendTest(test::CallTest::kDefaultTimeoutMs),
|
: SendTest(test::CallTest::kDefaultTimeoutMs),
|
||||||
call_(nullptr),
|
call_(nullptr),
|
||||||
state_(StreamState::kBeforeSwitch),
|
state_(StreamState::kBeforeSwitch),
|
||||||
send_stream_(nullptr),
|
send_stream_(nullptr),
|
||||||
send_stream_config_(nullptr),
|
send_stream_config_(nullptr),
|
||||||
packets_sent_(0),
|
packets_sent_(0),
|
||||||
stream_resetter_(stream_reset_fun) {
|
stream_resetter_(stream_reset_fun),
|
||||||
|
task_queue_(task_queue) {
|
||||||
RTC_DCHECK(stream_resetter_);
|
RTC_DCHECK(stream_resetter_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3841,8 +3860,10 @@ class ContentSwitchTest : public test::SendTest {
|
|||||||
float pacing_factor =
|
float pacing_factor =
|
||||||
internal_send_peer.GetPacingFactorOverride().value_or(0.0f);
|
internal_send_peer.GetPacingFactorOverride().value_or(0.0f);
|
||||||
float expected_pacing_factor = 1.1; // Strict pacing factor.
|
float expected_pacing_factor = 1.1; // Strict pacing factor.
|
||||||
if (send_stream_->GetStats().content_type ==
|
VideoSendStream::Stats stats;
|
||||||
webrtc::VideoContentType::SCREENSHARE) {
|
SendTask(RTC_FROM_HERE, task_queue_,
|
||||||
|
[&stats, stream = send_stream_]() { stats = stream->GetStats(); });
|
||||||
|
if (stats.content_type == webrtc::VideoContentType::SCREENSHARE) {
|
||||||
expected_pacing_factor = 1.0f; // Currently used pacing factor in ALR.
|
expected_pacing_factor = 1.0f; // Currently used pacing factor in ALR.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3910,6 +3931,7 @@ class ContentSwitchTest : public test::SendTest {
|
|||||||
VideoEncoderConfig encoder_config_;
|
VideoEncoderConfig encoder_config_;
|
||||||
uint32_t packets_sent_ RTC_GUARDED_BY(mutex_);
|
uint32_t packets_sent_ RTC_GUARDED_BY(mutex_);
|
||||||
T* stream_resetter_;
|
T* stream_resetter_;
|
||||||
|
TaskQueueBase* task_queue_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) {
|
TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) {
|
||||||
@ -3929,7 +3951,7 @@ TEST_F(VideoSendStreamTest, SwitchesToScreenshareAndBack) {
|
|||||||
Start();
|
Start();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ContentSwitchTest<decltype(reset_fun)> test(&reset_fun);
|
ContentSwitchTest<decltype(reset_fun)> test(&reset_fun, task_queue());
|
||||||
RunBaseTest(&test);
|
RunBaseTest(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user