Fix race in VideoSendStreamTest.RtcpSenderReportContainsMediaBytesSent.

BUG=webrtc:5194

Review URL: https://codereview.webrtc.org/1434963002

Cr-Commit-Position: refs/heads/master@{#10602}
This commit is contained in:
stefan
2015-11-11 06:39:57 -08:00
committed by Commit bot
parent 00ac85e2e3
commit 4b56904b70

View File

@ -1522,6 +1522,7 @@ TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
private: private:
Action OnSendRtp(const uint8_t* packet, size_t length) override { Action OnSendRtp(const uint8_t* packet, size_t length) override {
rtc::CritScope lock(&crit_);
RTPHeader header; RTPHeader header;
EXPECT_TRUE(parser_->Parse(packet, length, &header)); EXPECT_TRUE(parser_->Parse(packet, length, &header));
++rtp_packets_sent_; ++rtp_packets_sent_;
@ -1530,6 +1531,7 @@ TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
} }
Action OnSendRtcp(const uint8_t* packet, size_t length) override { Action OnSendRtcp(const uint8_t* packet, size_t length) override {
rtc::CritScope lock(&crit_);
RTCPUtility::RTCPParserV2 parser(packet, length, true); RTCPUtility::RTCPParserV2 parser(packet, length, true);
EXPECT_TRUE(parser.IsValid()); EXPECT_TRUE(parser.IsValid());
@ -1556,8 +1558,9 @@ TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) {
<< "Timed out while waiting for RTCP sender report."; << "Timed out while waiting for RTCP sender report.";
} }
size_t rtp_packets_sent_; rtc::CriticalSection crit_;
size_t media_bytes_sent_; size_t rtp_packets_sent_ GUARDED_BY(&crit_);
size_t media_bytes_sent_ GUARDED_BY(&crit_);
} test; } test;
RunBaseTest(&test, FakeNetworkPipe::Config()); RunBaseTest(&test, FakeNetworkPipe::Config());