| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <algorithm> // max | 10 #include <algorithm> // max |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 | 1515 |
| 1516 TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) { | 1516 TEST_F(VideoSendStreamTest, RtcpSenderReportContainsMediaBytesSent) { |
| 1517 class RtcpSenderReportTest : public test::SendTest { | 1517 class RtcpSenderReportTest : public test::SendTest { |
| 1518 public: | 1518 public: |
| 1519 RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs), | 1519 RtcpSenderReportTest() : SendTest(kDefaultTimeoutMs), |
| 1520 rtp_packets_sent_(0), | 1520 rtp_packets_sent_(0), |
| 1521 media_bytes_sent_(0) {} | 1521 media_bytes_sent_(0) {} |
| 1522 | 1522 |
| 1523 private: | 1523 private: |
| 1524 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 1524 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 1525 rtc::CritScope lock(&crit_); |
| 1525 RTPHeader header; | 1526 RTPHeader header; |
| 1526 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | 1527 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 1527 ++rtp_packets_sent_; | 1528 ++rtp_packets_sent_; |
| 1528 media_bytes_sent_ += length - header.headerLength - header.paddingLength; | 1529 media_bytes_sent_ += length - header.headerLength - header.paddingLength; |
| 1529 return SEND_PACKET; | 1530 return SEND_PACKET; |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 Action OnSendRtcp(const uint8_t* packet, size_t length) override { | 1533 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
| 1534 rtc::CritScope lock(&crit_); |
| 1533 RTCPUtility::RTCPParserV2 parser(packet, length, true); | 1535 RTCPUtility::RTCPParserV2 parser(packet, length, true); |
| 1534 EXPECT_TRUE(parser.IsValid()); | 1536 EXPECT_TRUE(parser.IsValid()); |
| 1535 | 1537 |
| 1536 RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); | 1538 RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); |
| 1537 while (packet_type != RTCPUtility::RTCPPacketTypes::kInvalid) { | 1539 while (packet_type != RTCPUtility::RTCPPacketTypes::kInvalid) { |
| 1538 if (packet_type == RTCPUtility::RTCPPacketTypes::kSr) { | 1540 if (packet_type == RTCPUtility::RTCPPacketTypes::kSr) { |
| 1539 // Only compare sent media bytes if SenderPacketCount matches the | 1541 // Only compare sent media bytes if SenderPacketCount matches the |
| 1540 // number of sent rtp packets (a new rtp packet could be sent before | 1542 // number of sent rtp packets (a new rtp packet could be sent before |
| 1541 // the rtcp packet). | 1543 // the rtcp packet). |
| 1542 if (parser.Packet().SR.SenderOctetCount > 0 && | 1544 if (parser.Packet().SR.SenderOctetCount > 0 && |
| 1543 parser.Packet().SR.SenderPacketCount == rtp_packets_sent_) { | 1545 parser.Packet().SR.SenderPacketCount == rtp_packets_sent_) { |
| 1544 EXPECT_EQ(media_bytes_sent_, parser.Packet().SR.SenderOctetCount); | 1546 EXPECT_EQ(media_bytes_sent_, parser.Packet().SR.SenderOctetCount); |
| 1545 observation_complete_->Set(); | 1547 observation_complete_->Set(); |
| 1546 } | 1548 } |
| 1547 } | 1549 } |
| 1548 packet_type = parser.Iterate(); | 1550 packet_type = parser.Iterate(); |
| 1549 } | 1551 } |
| 1550 | 1552 |
| 1551 return SEND_PACKET; | 1553 return SEND_PACKET; |
| 1552 } | 1554 } |
| 1553 | 1555 |
| 1554 void PerformTest() override { | 1556 void PerformTest() override { |
| 1555 EXPECT_EQ(kEventSignaled, Wait()) | 1557 EXPECT_EQ(kEventSignaled, Wait()) |
| 1556 << "Timed out while waiting for RTCP sender report."; | 1558 << "Timed out while waiting for RTCP sender report."; |
| 1557 } | 1559 } |
| 1558 | 1560 |
| 1559 size_t rtp_packets_sent_; | 1561 rtc::CriticalSection crit_; |
| 1560 size_t media_bytes_sent_; | 1562 size_t rtp_packets_sent_ GUARDED_BY(&crit_); |
| 1563 size_t media_bytes_sent_ GUARDED_BY(&crit_); |
| 1561 } test; | 1564 } test; |
| 1562 | 1565 |
| 1563 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1566 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 1564 } | 1567 } |
| 1565 | 1568 |
| 1566 TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { | 1569 TEST_F(VideoSendStreamTest, TranslatesTwoLayerScreencastToTargetBitrate) { |
| 1567 static const int kScreencastTargetBitrateKbps = 200; | 1570 static const int kScreencastTargetBitrateKbps = 200; |
| 1568 class ScreencastTargetBitrateTest : public test::SendTest, | 1571 class ScreencastTargetBitrateTest : public test::SendTest, |
| 1569 public test::FakeEncoder { | 1572 public test::FakeEncoder { |
| 1570 public: | 1573 public: |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 observation_complete_->Set(); | 1937 observation_complete_->Set(); |
| 1935 } | 1938 } |
| 1936 } | 1939 } |
| 1937 | 1940 |
| 1938 } test; | 1941 } test; |
| 1939 | 1942 |
| 1940 RunBaseTest(&test, FakeNetworkPipe::Config()); | 1943 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 1941 } | 1944 } |
| 1942 | 1945 |
| 1943 } // namespace webrtc | 1946 } // namespace webrtc |
| OLD | NEW |