Bug 1241690: reduce logging output for unconnected PCs. r=bwc
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -301,16 +301,21 @@ nsresult NrIceMediaStream::GetActivePair
nsresult NrIceMediaStream::GetCandidatePairs(std::vector<NrIceCandidatePair>*
out_pairs) const {
MOZ_ASSERT(out_pairs);
if (!stream_) {
return NS_ERROR_NOT_AVAILABLE;
}
+ // If we haven't at least started checking then there is nothing to report
+ if (ctx_->connection_state() == NrIceCtx::ICE_CTX_INIT) {
+ return NS_OK;
+ }
+
// Get the check_list on the peer stream (this is where the check_list
// actually lives, not in stream_)
nr_ice_media_stream* peer_stream;
int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
if (r != 0) {
return NS_ERROR_FAILURE;
}
@@ -478,16 +483,21 @@ nsresult NrIceMediaStream::GetLocalCandi
}
nsresult NrIceMediaStream::GetRemoteCandidates(
std::vector<NrIceCandidate>* candidates) const {
if (!stream_) {
return NS_ERROR_NOT_AVAILABLE;
}
+ // If we haven't at least started checking then there is nothing to report
+ if (ctx_->connection_state() == NrIceCtx::ICE_CTX_INIT) {
+ return NS_OK;
+ }
+
nr_ice_media_stream* peer_stream;
int r = nr_ice_peer_ctx_find_pstream(ctx_->peer(), stream_, &peer_stream);
if (r != 0) {
return NS_ERROR_FAILURE;
}
return GetCandidatesFromStream(peer_stream, candidates);
}
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -2912,21 +2912,21 @@ TEST_F(IceConnectTest, TestConnectShutdo
TEST_F(IceConnectTest, TestPollCandPairsBeforeConnect) {
AddStream("first", 1);
ASSERT_TRUE(Gather());
std::vector<NrIceCandidatePair> pairs;
nsresult res = p1_->GetCandidatePairs(0, &pairs);
// There should be no candidate pairs prior to calling Connect()
- ASSERT_TRUE(NS_FAILED(res));
+ ASSERT_EQ(NS_OK, res);
ASSERT_EQ(0U, pairs.size());
res = p2_->GetCandidatePairs(0, &pairs);
- ASSERT_TRUE(NS_FAILED(res));
+ ASSERT_EQ(NS_OK, res);
ASSERT_EQ(0U, pairs.size());
}
TEST_F(IceConnectTest, TestPollCandPairsAfterConnect) {
AddStream("first", 1);
ASSERT_TRUE(Gather());
Connect();