mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 786234 - Part 5: More detailed test-cases. r=ehugg
This commit is contained in:
parent
91c19ee225
commit
7444e95947
@ -114,7 +114,7 @@ class TransportInfo {
|
||||
dtls_ = nullptr;
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
void Shutdown() {
|
||||
if (loopback_) {
|
||||
loopback_->Disconnect();
|
||||
}
|
||||
@ -168,11 +168,6 @@ class TestAgent {
|
||||
|
||||
void StopInt() {
|
||||
audio_->GetStream()->Stop();
|
||||
audio_rtp_transport_.Stop();
|
||||
audio_rtcp_transport_.Stop();
|
||||
bundle_transport_.Stop();
|
||||
if (audio_pipeline_)
|
||||
audio_pipeline_->ShutdownTransport_s();
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
@ -184,14 +179,60 @@ class TestAgent {
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
test_utils->sts_target(),
|
||||
WrapRunnable(this, &TestAgent::StopInt));
|
||||
}
|
||||
|
||||
audio_pipeline_ = nullptr;
|
||||
void Shutdown_s() {
|
||||
audio_rtp_transport_.Shutdown();
|
||||
audio_rtcp_transport_.Shutdown();
|
||||
bundle_transport_.Shutdown();
|
||||
if (audio_pipeline_)
|
||||
audio_pipeline_->ShutdownTransport_s();
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
if (audio_pipeline_)
|
||||
audio_pipeline_->ShutdownMedia_m();
|
||||
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
test_utils->sts_target(),
|
||||
WrapRunnable(this, &TestAgent::Shutdown_s));
|
||||
}
|
||||
|
||||
uint32_t GetRemoteSSRC() {
|
||||
uint32_t res = 0;
|
||||
audio_conduit_->GetRemoteSSRC(&res);
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t GetLocalSSRC() {
|
||||
uint32_t res = 0;
|
||||
audio_conduit_->GetLocalSSRC(&res);
|
||||
return res;
|
||||
}
|
||||
|
||||
int GetAudioRtpCountSent() {
|
||||
return audio_pipeline_->rtp_packets_sent();
|
||||
}
|
||||
|
||||
int GetAudioRtpCountReceived() {
|
||||
return audio_pipeline_->rtp_packets_received();
|
||||
}
|
||||
|
||||
int GetAudioRtcpCountSent() {
|
||||
return audio_pipeline_->rtcp_packets_sent();
|
||||
}
|
||||
|
||||
int GetAudioRtcpCountReceived() {
|
||||
return audio_pipeline_->rtcp_packets_received();
|
||||
}
|
||||
|
||||
protected:
|
||||
mozilla::AudioCodecConfig audio_config_;
|
||||
mozilla::RefPtr<mozilla::MediaSessionConduit> audio_conduit_;
|
||||
nsRefPtr<DOMMediaStream> audio_;
|
||||
// TODO(bcampen@mozilla.com): Right now this does not let us test RTCP in
|
||||
// both directions; only the sender's RTCP is sent, but the receiver should
|
||||
// be sending it too.
|
||||
mozilla::RefPtr<mozilla::MediaPipeline> audio_pipeline_;
|
||||
TransportInfo audio_rtp_transport_;
|
||||
TransportInfo audio_rtcp_transport_;
|
||||
@ -238,14 +279,6 @@ class TestAgentSend : public TestAgent {
|
||||
audio_pipeline_->Init();
|
||||
}
|
||||
|
||||
int GetAudioRtpCount() {
|
||||
return audio_pipeline_->rtp_packets_sent();
|
||||
}
|
||||
|
||||
int GetAudioRtcpCount() {
|
||||
return audio_pipeline_->rtcp_packets_received();
|
||||
}
|
||||
|
||||
void SetUsingBundle(bool use_bundle) {
|
||||
use_bundle_ = use_bundle;
|
||||
}
|
||||
@ -286,6 +319,7 @@ class TestAgentReceive : public TestAgent {
|
||||
RefPtr<TransportFlow> bundle_transport;
|
||||
if (bundle_filter_) {
|
||||
bundle_transport = bundle_transport_.flow_;
|
||||
bundle_filter_->AddLocalSSRC(GetLocalSSRC());
|
||||
}
|
||||
|
||||
audio_pipeline_ = new mozilla::MediaPipelineReceiveAudio(
|
||||
@ -303,14 +337,6 @@ class TestAgentReceive : public TestAgent {
|
||||
audio_pipeline_->Init();
|
||||
}
|
||||
|
||||
int GetAudioRtpCount() {
|
||||
return audio_pipeline_->rtp_packets_received();
|
||||
}
|
||||
|
||||
int GetAudioRtcpCount() {
|
||||
return audio_pipeline_->rtcp_packets_sent();
|
||||
}
|
||||
|
||||
void SetBundleFilter(nsAutoPtr<MediaPipelineFilter> filter) {
|
||||
bundle_filter_ = filter;
|
||||
}
|
||||
@ -323,6 +349,7 @@ class TestAgentReceive : public TestAgent {
|
||||
nsAutoPtr<MediaPipelineFilter> filter) {
|
||||
audio_pipeline_->UpdateFilterFromRemoteDescription_s(filter);
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoPtr<MediaPipelineFilter> bundle_filter_;
|
||||
};
|
||||
@ -333,6 +360,8 @@ class MediaPipelineTest : public ::testing::Test {
|
||||
~MediaPipelineTest() {
|
||||
p1_.Stop();
|
||||
p2_.Stop();
|
||||
p1_.Shutdown();
|
||||
p2_.Shutdown();
|
||||
}
|
||||
|
||||
// Setup transport.
|
||||
@ -362,7 +391,9 @@ class MediaPipelineTest : public ::testing::Test {
|
||||
nsAutoPtr<MediaPipelineFilter> localFilter =
|
||||
nsAutoPtr<MediaPipelineFilter>(nullptr),
|
||||
nsAutoPtr<MediaPipelineFilter> remoteFilter =
|
||||
nsAutoPtr<MediaPipelineFilter>(nullptr)) {
|
||||
nsAutoPtr<MediaPipelineFilter>(nullptr),
|
||||
unsigned int ms_until_answer = 500,
|
||||
unsigned int ms_of_traffic_after_answer = 10000) {
|
||||
|
||||
// We do not support testing bundle without rtcp mux, since that doesn't
|
||||
// make any sense.
|
||||
@ -386,16 +417,20 @@ class MediaPipelineTest : public ::testing::Test {
|
||||
p1_.Start();
|
||||
|
||||
// Simulate pre-answer traffic
|
||||
PR_Sleep(500);
|
||||
PR_Sleep(ms_until_answer);
|
||||
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
test_utils->sts_target(),
|
||||
WrapRunnable(&p2_, &TestAgentReceive::SetUsingBundle_s, bundle));
|
||||
|
||||
if (bundle) {
|
||||
// Leaving remoteFilter not set implies we want to test sunny-day
|
||||
if (!remoteFilter) {
|
||||
remoteFilter = new MediaPipelineFilter;
|
||||
// Might not be safe, strictly speaking.
|
||||
remoteFilter->AddRemoteSSRC(p1_.GetLocalSSRC());
|
||||
}
|
||||
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
test_utils->sts_target(),
|
||||
WrapRunnable(&p2_,
|
||||
@ -405,26 +440,43 @@ class MediaPipelineTest : public ::testing::Test {
|
||||
|
||||
|
||||
// wait for some RTP/RTCP tx and rx to happen
|
||||
PR_Sleep(10000);
|
||||
|
||||
if (bundle) {
|
||||
// Filter should have eaten everything
|
||||
ASSERT_EQ(0, p2_.GetAudioRtpCount());
|
||||
} else {
|
||||
ASSERT_GE(p1_.GetAudioRtpCount(), 40);
|
||||
ASSERT_GE(p2_.GetAudioRtpCount(), 40);
|
||||
ASSERT_GE(p2_.GetAudioRtcpCount(), 1);
|
||||
}
|
||||
PR_Sleep(ms_of_traffic_after_answer);
|
||||
|
||||
p1_.Stop();
|
||||
p2_.Stop();
|
||||
|
||||
// wait for any packets in flight to arrive
|
||||
PR_Sleep(100);
|
||||
|
||||
p1_.Shutdown();
|
||||
p2_.Shutdown();
|
||||
|
||||
if (!bundle) {
|
||||
// If we are doing bundle, allow the test-case to do this checking.
|
||||
ASSERT_GE(p1_.GetAudioRtpCountSent(), 40);
|
||||
ASSERT_EQ(p1_.GetAudioRtpCountReceived(), p2_.GetAudioRtpCountSent());
|
||||
ASSERT_EQ(p1_.GetAudioRtpCountSent(), p2_.GetAudioRtpCountReceived());
|
||||
|
||||
// Calling ShutdownMedia_m on both pipelines does not stop the flow of
|
||||
// RTCP. So, we might be off by one here.
|
||||
ASSERT_LE(p2_.GetAudioRtcpCountReceived(), p1_.GetAudioRtcpCountSent());
|
||||
ASSERT_GE(p2_.GetAudioRtcpCountReceived() + 1, p1_.GetAudioRtcpCountSent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TestAudioReceiverOffersBundle(bool bundle_accepted,
|
||||
nsAutoPtr<MediaPipelineFilter> localFilter,
|
||||
nsAutoPtr<MediaPipelineFilter> remoteFilter =
|
||||
nsAutoPtr<MediaPipelineFilter>(nullptr)) {
|
||||
TestAudioSend(true, bundle_accepted, localFilter, remoteFilter);
|
||||
nsAutoPtr<MediaPipelineFilter>(nullptr),
|
||||
unsigned int ms_until_answer = 500,
|
||||
unsigned int ms_of_traffic_after_answer = 10000) {
|
||||
TestAudioSend(true,
|
||||
bundle_accepted,
|
||||
localFilter,
|
||||
remoteFilter,
|
||||
ms_until_answer,
|
||||
ms_of_traffic_after_answer);
|
||||
}
|
||||
protected:
|
||||
TestAgentSend p1_;
|
||||
@ -829,7 +881,33 @@ TEST_F(MediaPipelineTest, TestAudioSendBundleOfferedAndDeclined) {
|
||||
|
||||
TEST_F(MediaPipelineTest, TestAudioSendBundleOfferedAndAccepted) {
|
||||
nsAutoPtr<MediaPipelineFilter> filter(new MediaPipelineFilter);
|
||||
TestAudioReceiverOffersBundle(true, filter);
|
||||
// These durations have to be _extremely_ long to have any assurance that
|
||||
// some RTCP will be sent at all. This is because the first RTCP packet
|
||||
// is sometimes sent before the transports are ready, which causes it to
|
||||
// be dropped.
|
||||
TestAudioReceiverOffersBundle(true,
|
||||
filter,
|
||||
// We do not specify the filter for the remote description, so it will be
|
||||
// set to something sane after a short time.
|
||||
nsAutoPtr<MediaPipelineFilter>(),
|
||||
10000,
|
||||
10000);
|
||||
|
||||
// Some packets should have been dropped, but not all
|
||||
ASSERT_GT(p1_.GetAudioRtpCountSent(), p2_.GetAudioRtpCountReceived());
|
||||
ASSERT_GT(p2_.GetAudioRtpCountReceived(), 40);
|
||||
ASSERT_GT(p1_.GetAudioRtcpCountSent(), 1);
|
||||
ASSERT_GT(p1_.GetAudioRtcpCountSent(), p2_.GetAudioRtcpCountReceived());
|
||||
ASSERT_GT(p2_.GetAudioRtcpCountReceived(), 0);
|
||||
}
|
||||
|
||||
TEST_F(MediaPipelineTest, TestAudioSendBundleOfferedAndAcceptedEmptyFilter) {
|
||||
nsAutoPtr<MediaPipelineFilter> filter(new MediaPipelineFilter);
|
||||
nsAutoPtr<MediaPipelineFilter> bad_answer_filter(new MediaPipelineFilter);
|
||||
TestAudioReceiverOffersBundle(true, filter, bad_answer_filter);
|
||||
// Filter is empty, so should drop everything.
|
||||
ASSERT_EQ(0, p2_.GetAudioRtpCountReceived());
|
||||
ASSERT_EQ(0, p2_.GetAudioRtcpCountReceived());
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
Loading…
Reference in New Issue
Block a user