Chromium Code Reviews| Index: webrtc/media/engine/webrtcvideoengine_unittest.cc |
| diff --git a/webrtc/media/engine/webrtcvideoengine_unittest.cc b/webrtc/media/engine/webrtcvideoengine_unittest.cc |
| index c6adfd3976fa6b89d95223ec0c1eac001364c0b6..aa3aff879503e894f0fe2fc3623a8e01ae2573c7 100644 |
| --- a/webrtc/media/engine/webrtcvideoengine_unittest.cc |
| +++ b/webrtc/media/engine/webrtcvideoengine_unittest.cc |
| @@ -83,6 +83,32 @@ bool HasRtxCodec(const std::vector<cricket::VideoCodec>& codecs, |
| return false; |
| } |
| +// TODO(nisse): Duplicated in call.cc. |
| +const int* FindKeyByValue(const std::map<int, int>& m, int v) { |
| + for (const auto& kv : m) { |
| + if (kv.second == v) |
| + return &kv.first; |
| + } |
| + return nullptr; |
| +} |
| + |
| +bool VerifyRtxReceiveAssociation( |
|
danilchap
2017/08/29 13:33:06
may be Has instead of Verify
nisse-webrtc
2017/08/29 13:51:36
Done.
|
| + const webrtc::VideoReceiveStream::Config& config, |
| + int payload_type) { |
| + return FindKeyByValue(config.rtp.rtx_associated_payload_types, |
| + payload_type) != nullptr; |
| +} |
| + |
| +// Check that there's an Rtx payload type for each decoder. |
| +bool VerifyRtxReceiveAssociations( |
| + const webrtc::VideoReceiveStream::Config& config) { |
| + for (auto& decoder : config.decoders) { |
|
danilchap
2017/08/29 13:33:06
may be const auto& to stress it is not modified
nisse-webrtc
2017/08/29 13:51:36
Done.
|
| + if (!VerifyRtxReceiveAssociation(config, decoder.payload_type)) |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( |
| int width, |
| int height) { |
| @@ -112,15 +138,6 @@ cricket::MediaConfig GetMediaConfig() { |
| return media_config; |
| } |
| -// TODO(nisse): Duplicated in call.cc. |
| -const int* FindKeyByValue(const std::map<int, int>& m, int v) { |
| - for (const auto& kv : m) { |
| - if (kv.second == v) |
| - return &kv.first; |
| - } |
| - return nullptr; |
| -} |
| - |
| } // namespace |
| namespace cricket { |
| @@ -1316,9 +1333,12 @@ TEST_F(WebRtcVideoChannelTest, RecvStreamWithSimAndRtx) { |
| cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
| EXPECT_FALSE( |
| recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); |
| - EXPECT_EQ(recv_stream->GetConfig().decoders.size(), |
| - recv_stream->GetConfig().rtp.rtx_associated_payload_types.size()) |
| + EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) |
| << "RTX should be mapped for all decoders/payload types."; |
| + EXPECT_TRUE(VerifyRtxReceiveAssociation(recv_stream->GetConfig(), |
| + GetEngineCodec("red").id)) |
| + << "RTX should be mapped also for the RED payload type"; |
|
danilchap
2017/08/29 13:33:06
may be remove 'also' (this expectation might fail
nisse-webrtc
2017/08/29 13:51:36
Done, here and below.
|
| + |
| EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
| } |
| @@ -1329,6 +1349,12 @@ TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) { |
| params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); |
| FakeVideoReceiveStream* recv_stream = AddRecvStream(params); |
| EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
| + |
| + EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) |
| + << "RTX should be mapped for all decoders/payload types."; |
| + EXPECT_TRUE(VerifyRtxReceiveAssociation(recv_stream->GetConfig(), |
| + GetEngineCodec("red").id)) |
| + << "RTX should be mapped also for the RED payload type"; |
| } |
| TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) { |
| @@ -3796,9 +3822,11 @@ TEST_F(WebRtcVideoChannelTest, DefaultReceiveStreamReconfiguresToUseRtx) { |
| recv_stream = fake_call_->GetVideoReceiveStreams()[0]; |
| EXPECT_FALSE( |
| recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); |
| - EXPECT_EQ(recv_stream->GetConfig().decoders.size(), |
| - recv_stream->GetConfig().rtp.rtx_associated_payload_types.size()) |
| + EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) |
| << "RTX should be mapped for all decoders/payload types."; |
| + EXPECT_TRUE(VerifyRtxReceiveAssociation(recv_stream->GetConfig(), |
| + GetEngineCodec("red").id)) |
| + << "RTX should be mapped also for the RED payload type"; |
| EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); |
| } |