Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2372113005: Replace RTCPUtility RTCPParser with TestRtcpParser (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/end_to_end_tests.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "webrtc/base/bind.h" 14 #include "webrtc/base/bind.h"
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/criticalsection.h" 16 #include "webrtc/base/criticalsection.h"
17 #include "webrtc/base/event.h" 17 #include "webrtc/base/event.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/platform_thread.h" 19 #include "webrtc/base/platform_thread.h"
20 #include "webrtc/base/rate_limiter.h" 20 #include "webrtc/base/rate_limiter.h"
21 #include "webrtc/call.h" 21 #include "webrtc/call.h"
22 #include "webrtc/call/transport_adapter.h" 22 #include "webrtc/call/transport_adapter.h"
23 #include "webrtc/common_video/include/frame_callback.h" 23 #include "webrtc/common_video/include/frame_callback.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
29 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 28 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
30 #include "webrtc/system_wrappers/include/sleep.h" 29 #include "webrtc/system_wrappers/include/sleep.h"
31 #include "webrtc/test/call_test.h" 30 #include "webrtc/test/call_test.h"
32 #include "webrtc/test/configurable_frame_size_encoder.h" 31 #include "webrtc/test/configurable_frame_size_encoder.h"
33 #include "webrtc/test/fake_texture_frame.h" 32 #include "webrtc/test/fake_texture_frame.h"
34 #include "webrtc/test/frame_generator.h" 33 #include "webrtc/test/frame_generator.h"
35 #include "webrtc/test/frame_utils.h" 34 #include "webrtc/test/frame_utils.h"
36 #include "webrtc/test/gtest.h" 35 #include "webrtc/test/gtest.h"
37 #include "webrtc/test/null_transport.h" 36 #include "webrtc/test/null_transport.h"
37 #include "webrtc/test/rtcp_packet_parser.h"
38 #include "webrtc/test/testsupport/perf_test.h" 38 #include "webrtc/test/testsupport/perf_test.h"
39 39
40 #include "webrtc/video/send_statistics_proxy.h" 40 #include "webrtc/video/send_statistics_proxy.h"
41 #include "webrtc/video_frame.h" 41 #include "webrtc/video_frame.h"
42 #include "webrtc/video_send_stream.h" 42 #include "webrtc/video_send_stream.h"
43 43
44 namespace webrtc { 44 namespace webrtc {
45 45
46 enum VideoFormat { kGeneric, kVP8, }; 46 enum VideoFormat { kGeneric, kVP8, };
47 47
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 TEST_F(VideoSendStreamTest, SupportsCName) { 84 TEST_F(VideoSendStreamTest, SupportsCName) {
85 static std::string kCName = "PjQatC14dGfbVwGPUOA9IH7RlsFDbWl4AhXEiDsBizo="; 85 static std::string kCName = "PjQatC14dGfbVwGPUOA9IH7RlsFDbWl4AhXEiDsBizo=";
86 class CNameObserver : public test::SendTest { 86 class CNameObserver : public test::SendTest {
87 public: 87 public:
88 CNameObserver() : SendTest(kDefaultTimeoutMs) {} 88 CNameObserver() : SendTest(kDefaultTimeoutMs) {}
89 89
90 private: 90 private:
91 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 91 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
92 RTCPUtility::RTCPParserV2 parser(packet, length, true); 92 test::RtcpPacketParser parser;
93 EXPECT_TRUE(parser.IsValid()); 93 EXPECT_TRUE(parser.Parse(packet, length));
94 if (parser.sdes()->num_packets() > 0) {
95 EXPECT_EQ(1u, parser.sdes()->chunks().size());
96 EXPECT_EQ(kCName, parser.sdes()->chunks()[0].cname);
94 97
95 RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); 98 observation_complete_.Set();
96 while (packet_type != RTCPUtility::RTCPPacketTypes::kInvalid) {
97 if (packet_type == RTCPUtility::RTCPPacketTypes::kSdesChunk) {
98 EXPECT_EQ(parser.Packet().CName.CName, kCName);
99 observation_complete_.Set();
100 }
101
102 packet_type = parser.Iterate();
103 } 99 }
104 100
105 return SEND_PACKET; 101 return SEND_PACKET;
106 } 102 }
107 103
108 void ModifyVideoConfigs( 104 void ModifyVideoConfigs(
109 VideoSendStream::Config* send_config, 105 VideoSendStream::Config* send_config,
110 std::vector<VideoReceiveStream::Config>* receive_configs, 106 std::vector<VideoReceiveStream::Config>* receive_configs,
111 VideoEncoderConfig* encoder_config) override { 107 VideoEncoderConfig* encoder_config) override {
112 send_config->rtp.c_name = kCName; 108 send_config->rtp.c_name = kCName;
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 rtc::CritScope lock(&crit_); 2071 rtc::CritScope lock(&crit_);
2076 RTPHeader header; 2072 RTPHeader header;
2077 EXPECT_TRUE(parser_->Parse(packet, length, &header)); 2073 EXPECT_TRUE(parser_->Parse(packet, length, &header));
2078 ++rtp_packets_sent_; 2074 ++rtp_packets_sent_;
2079 media_bytes_sent_ += length - header.headerLength - header.paddingLength; 2075 media_bytes_sent_ += length - header.headerLength - header.paddingLength;
2080 return SEND_PACKET; 2076 return SEND_PACKET;
2081 } 2077 }
2082 2078
2083 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 2079 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
2084 rtc::CritScope lock(&crit_); 2080 rtc::CritScope lock(&crit_);
2085 RTCPUtility::RTCPParserV2 parser(packet, length, true); 2081 test::RtcpPacketParser parser;
2086 EXPECT_TRUE(parser.IsValid()); 2082 EXPECT_TRUE(parser.Parse(packet, length));
2087 2083
2088 RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); 2084 if (parser.sender_report()->num_packets() > 0) {
2089 while (packet_type != RTCPUtility::RTCPPacketTypes::kInvalid) { 2085 // Only compare sent media bytes if SenderPacketCount matches the
2090 if (packet_type == RTCPUtility::RTCPPacketTypes::kSr) { 2086 // number of sent rtp packets (a new rtp packet could be sent before
2091 // Only compare sent media bytes if SenderPacketCount matches the 2087 // the rtcp packet).
2092 // number of sent rtp packets (a new rtp packet could be sent before 2088 if (parser.sender_report()->sender_octet_count() > 0 &&
2093 // the rtcp packet). 2089 parser.sender_report()->sender_packet_count() ==
2094 if (parser.Packet().SR.SenderOctetCount > 0 && 2090 rtp_packets_sent_) {
2095 parser.Packet().SR.SenderPacketCount == rtp_packets_sent_) { 2091 EXPECT_EQ(media_bytes_sent_,
2096 EXPECT_EQ(media_bytes_sent_, parser.Packet().SR.SenderOctetCount); 2092 parser.sender_report()->sender_octet_count());
2097 observation_complete_.Set(); 2093 observation_complete_.Set();
2098 }
2099 } 2094 }
2100 packet_type = parser.Iterate();
2101 } 2095 }
2102 2096
2103 return SEND_PACKET; 2097 return SEND_PACKET;
2104 } 2098 }
2105 2099
2106 void PerformTest() override { 2100 void PerformTest() override {
2107 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP sender report."; 2101 EXPECT_TRUE(Wait()) << "Timed out while waiting for RTCP sender report.";
2108 } 2102 }
2109 2103
2110 rtc::CriticalSection crit_; 2104 rtc::CriticalSection crit_;
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 observation_complete_.Set(); 2867 observation_complete_.Set();
2874 } 2868 }
2875 } 2869 }
2876 } test; 2870 } test;
2877 2871
2878 RunBaseTest(&test); 2872 RunBaseTest(&test);
2879 } 2873 }
2880 #endif // !defined(RTC_DISABLE_VP9) 2874 #endif // !defined(RTC_DISABLE_VP9)
2881 2875
2882 } // namespace webrtc 2876 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/end_to_end_tests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698