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

Side by Side Diff: webrtc/call/rtc_event_log_unittest.cc

Issue 1419523004: Skip logging RTCP messages of type SDES and APP. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 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/call/rtc_event_log.proto ('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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 10
11 #ifdef ENABLE_RTC_EVENT_LOG 11 #ifdef ENABLE_RTC_EVENT_LOG
12 12
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <string.h>
14 #include <string> 15 #include <string>
15 #include <vector> 16 #include <vector>
16 17
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/buffer.h" 19 #include "webrtc/base/buffer.h"
19 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
20 #include "webrtc/base/scoped_ptr.h" 21 #include "webrtc/base/scoped_ptr.h"
21 #include "webrtc/base/thread.h" 22 #include "webrtc/base/thread.h"
22 #include "webrtc/call.h" 23 #include "webrtc/call.h"
23 #include "webrtc/call/rtc_event_log.h" 24 #include "webrtc/call/rtc_event_log.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
25 #include "webrtc/system_wrappers/interface/clock.h" 27 #include "webrtc/system_wrappers/interface/clock.h"
26 #include "webrtc/test/test_suite.h" 28 #include "webrtc/test/test_suite.h"
27 #include "webrtc/test/testsupport/fileutils.h" 29 #include "webrtc/test/testsupport/fileutils.h"
28 #include "webrtc/test/testsupport/gtest_disable.h" 30 #include "webrtc/test/testsupport/gtest_disable.h"
29 31
30 // Files generated at build-time by the protobuf compiler. 32 // Files generated at build-time by the protobuf compiler.
31 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 33 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
32 #include "external/webrtc/webrtc/call/rtc_event_log.pb.h" 34 #include "external/webrtc/webrtc/call/rtc_event_log.pb.h"
33 #else 35 #else
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ASSERT_TRUE(receiver_config.has_local_ssrc()); 133 ASSERT_TRUE(receiver_config.has_local_ssrc());
132 EXPECT_EQ(config.rtp.local_ssrc, receiver_config.local_ssrc()); 134 EXPECT_EQ(config.rtp.local_ssrc, receiver_config.local_ssrc());
133 // Check RTCP settings. 135 // Check RTCP settings.
134 ASSERT_TRUE(receiver_config.has_rtcp_mode()); 136 ASSERT_TRUE(receiver_config.has_rtcp_mode());
135 if (config.rtp.rtcp_mode == RtcpMode::kCompound) 137 if (config.rtp.rtcp_mode == RtcpMode::kCompound)
136 EXPECT_EQ(rtclog::VideoReceiveConfig::RTCP_COMPOUND, 138 EXPECT_EQ(rtclog::VideoReceiveConfig::RTCP_COMPOUND,
137 receiver_config.rtcp_mode()); 139 receiver_config.rtcp_mode());
138 else 140 else
139 EXPECT_EQ(rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE, 141 EXPECT_EQ(rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE,
140 receiver_config.rtcp_mode()); 142 receiver_config.rtcp_mode());
141 ASSERT_TRUE(receiver_config.has_receiver_reference_time_report());
142 EXPECT_EQ(config.rtp.rtcp_xr.receiver_reference_time_report,
143 receiver_config.receiver_reference_time_report());
144 ASSERT_TRUE(receiver_config.has_remb()); 143 ASSERT_TRUE(receiver_config.has_remb());
145 EXPECT_EQ(config.rtp.remb, receiver_config.remb()); 144 EXPECT_EQ(config.rtp.remb, receiver_config.remb());
146 // Check RTX map. 145 // Check RTX map.
147 ASSERT_EQ(static_cast<int>(config.rtp.rtx.size()), 146 ASSERT_EQ(static_cast<int>(config.rtp.rtx.size()),
148 receiver_config.rtx_map_size()); 147 receiver_config.rtx_map_size());
149 for (const rtclog::RtxMap& rtx_map : receiver_config.rtx_map()) { 148 for (const rtclog::RtxMap& rtx_map : receiver_config.rtx_map()) {
150 ASSERT_TRUE(rtx_map.has_payload_type()); 149 ASSERT_TRUE(rtx_map.has_payload_type());
151 ASSERT_TRUE(rtx_map.has_config()); 150 ASSERT_TRUE(rtx_map.has_config());
152 EXPECT_EQ(1u, config.rtp.rtx.count(rtx_map.payload_type())); 151 EXPECT_EQ(1u, config.rtp.rtx.count(rtx_map.payload_type()));
153 const rtclog::RtxConfig& rtx_config = rtx_map.config(); 152 const rtclog::RtxConfig& rtx_config = rtx_map.config();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Check RTX settings. 206 // Check RTX settings.
208 ASSERT_EQ(static_cast<int>(config.rtp.rtx.ssrcs.size()), 207 ASSERT_EQ(static_cast<int>(config.rtp.rtx.ssrcs.size()),
209 sender_config.rtx_ssrcs_size()); 208 sender_config.rtx_ssrcs_size());
210 for (int i = 0; i < sender_config.rtx_ssrcs_size(); i++) { 209 for (int i = 0; i < sender_config.rtx_ssrcs_size(); i++) {
211 EXPECT_EQ(config.rtp.rtx.ssrcs[i], sender_config.rtx_ssrcs(i)); 210 EXPECT_EQ(config.rtp.rtx.ssrcs[i], sender_config.rtx_ssrcs(i));
212 } 211 }
213 if (sender_config.rtx_ssrcs_size() > 0) { 212 if (sender_config.rtx_ssrcs_size() > 0) {
214 ASSERT_TRUE(sender_config.has_rtx_payload_type()); 213 ASSERT_TRUE(sender_config.has_rtx_payload_type());
215 EXPECT_EQ(config.rtp.rtx.payload_type, sender_config.rtx_payload_type()); 214 EXPECT_EQ(config.rtp.rtx.payload_type, sender_config.rtx_payload_type());
216 } 215 }
217 // Check CNAME.
218 ASSERT_TRUE(sender_config.has_c_name());
219 EXPECT_EQ(config.rtp.c_name, sender_config.c_name());
220 // Check encoder. 216 // Check encoder.
221 ASSERT_TRUE(sender_config.has_encoder()); 217 ASSERT_TRUE(sender_config.has_encoder());
222 ASSERT_TRUE(sender_config.encoder().has_name()); 218 ASSERT_TRUE(sender_config.encoder().has_name());
223 ASSERT_TRUE(sender_config.encoder().has_payload_type()); 219 ASSERT_TRUE(sender_config.encoder().has_payload_type());
224 EXPECT_EQ(config.encoder_settings.payload_name, 220 EXPECT_EQ(config.encoder_settings.payload_name,
225 sender_config.encoder().name()); 221 sender_config.encoder().name());
226 EXPECT_EQ(config.encoder_settings.payload_type, 222 EXPECT_EQ(config.encoder_settings.payload_type,
227 sender_config.encoder().payload_type()); 223 sender_config.encoder().payload_type());
228 } 224 }
229 225
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 packet, payload_type, marker_bit, capture_timestamp, capture_time_ms, 326 packet, payload_type, marker_bit, capture_timestamp, capture_time_ms,
331 timestamp_provided, inc_sequence_number); 327 timestamp_provided, inc_sequence_number);
332 328
333 for (size_t i = header_size; i < packet_size; i++) { 329 for (size_t i = header_size; i < packet_size; i++) {
334 packet[i] = rand(); 330 packet[i] = rand();
335 } 331 }
336 332
337 return header_size; 333 return header_size;
338 } 334 }
339 335
340 void GenerateRtcpPacket(uint8_t* packet, size_t packet_size) { 336 void GenerateRtcpPacket(rtc::Buffer* packet) {
åsapersson 2015/10/28 14:16:43 To generate rtcp packets, the RtcpPacket class cou
terelius 2015/10/30 11:17:18 Thanks for the suggestion; the new code is much cl
341 for (size_t i = 0; i < packet_size; i++) { 337 class OnePacketTransport : public Transport, public NullRtpData {
342 packet[i] = rand(); 338 public:
339 OnePacketTransport(rtc::Buffer* packet) { packet_ = packet; }
340
341 bool SendRtp(const uint8_t* /*data*/,
342 size_t /*len*/,
343 const PacketOptions& /*options*/) override {
344 return false;
345 }
346 bool SendRtcp(const uint8_t* data, size_t len) override {
347 packet_->AppendData(data, len);
348 return true;
349 }
350 int OnReceivedPayloadData(const uint8_t* /*payload_data*/,
351 const size_t /*payload_size*/,
352 const WebRtcRTPHeader* /*rtp_header*/) override {
353 return 0;
354 }
355 rtc::Buffer* packet_;
356 };
357
358 packet->EnsureCapacity(IP_PACKET_SIZE);
359 packet->SetSize(0);
360 OnePacketTransport transport(packet);
361 SimulatedClock clock(1335900000);
362 rtc::scoped_ptr<ReceiveStatistics> receive_statistics(
363 ReceiveStatistics::Create(&clock));
364 RTCPSender::FeedbackState feedback_state;
365 RTCPSender rtcp_sender(false, // audio
366 &clock, // clock
367 receive_statistics.get(), // Used to generate RR
368 nullptr, // packet_type_counter_observer
369 &transport);
370 rtcp_sender.SetSSRC(rand()); // kSenderSsrc
371 rtcp_sender.SetRemoteSSRC(rand()); // kRemoteSsrc
372
373 // Insert packets in receive statistics
374 for (int i = 0; i < 5; i++) {
375 RTPHeader header;
376 header.ssrc = rand();
377 header.sequenceNumber = rand();
378 header.timestamp = rand();
379 header.headerLength = 12;
380 size_t kPacketLength = 100 + rand() % 100;
381 receive_statistics->IncomingPacket(header, kPacketLength, false);
343 } 382 }
383
384 rtcp_sender.SetRTCPStatus(RtcpMode::kCompound);
385 rtcp_sender.SendRTCP(feedback_state, kRtcpRr);
386
387 // assert(transport.packet.size() <= packet_size);
388 // packet_size = transport.packet.size();
389 // memcpy(packet, transport.packet.data(), packet_size);
390 // return packet_size;
stefan-webrtc 2015/10/28 13:37:12 Should this code be removed?
terelius 2015/10/30 11:17:18 Yes. Done.
344 } 391 }
345 392
346 void GenerateVideoReceiveConfig(uint32_t extensions_bitvector, 393 void GenerateVideoReceiveConfig(uint32_t extensions_bitvector,
347 VideoReceiveStream::Config* config) { 394 VideoReceiveStream::Config* config) {
348 // Create a map from a payload type to an encoder name. 395 // Create a map from a payload type to an encoder name.
349 VideoReceiveStream::Decoder decoder; 396 VideoReceiveStream::Decoder decoder;
350 decoder.payload_type = rand(); 397 decoder.payload_type = rand();
351 decoder.payload_name = (rand() % 2 ? "VP8" : "H264"); 398 decoder.payload_name = (rand() % 2 ? "VP8" : "H264");
352 config->decoders.push_back(decoder); 399 config->decoders.push_back(decoder);
353 // Add SSRCs for the stream. 400 // Add SSRCs for the stream.
354 config->rtp.remote_ssrc = rand(); 401 config->rtp.remote_ssrc = rand();
355 config->rtp.local_ssrc = rand(); 402 config->rtp.local_ssrc = rand();
356 // Add extensions and settings for RTCP. 403 // Add extensions and settings for RTCP.
357 config->rtp.rtcp_mode = 404 config->rtp.rtcp_mode =
358 rand() % 2 ? RtcpMode::kCompound : RtcpMode::kReducedSize; 405 rand() % 2 ? RtcpMode::kCompound : RtcpMode::kReducedSize;
359 config->rtp.rtcp_xr.receiver_reference_time_report = (rand() % 2 == 1);
360 config->rtp.remb = (rand() % 2 == 1); 406 config->rtp.remb = (rand() % 2 == 1);
361 // Add a map from a payload type to a new ssrc and a new payload type for RTX. 407 // Add a map from a payload type to a new ssrc and a new payload type for RTX.
362 VideoReceiveStream::Config::Rtp::Rtx rtx_pair; 408 VideoReceiveStream::Config::Rtp::Rtx rtx_pair;
363 rtx_pair.ssrc = rand(); 409 rtx_pair.ssrc = rand();
364 rtx_pair.payload_type = rand(); 410 rtx_pair.payload_type = rand();
365 config->rtp.rtx.insert(std::make_pair(rand(), rtx_pair)); 411 config->rtp.rtx.insert(std::make_pair(rand(), rtx_pair));
366 // Add header extensions. 412 // Add header extensions.
367 for (unsigned i = 0; i < kNumExtensions; i++) { 413 for (unsigned i = 0; i < kNumExtensions; i++) {
368 if (extensions_bitvector & (1u << i)) { 414 if (extensions_bitvector & (1u << i)) {
369 config->rtp.extensions.push_back( 415 config->rtp.extensions.push_back(
370 RtpExtension(kExtensionNames[i], rand())); 416 RtpExtension(kExtensionNames[i], rand()));
371 } 417 }
372 } 418 }
373 } 419 }
374 420
375 void GenerateVideoSendConfig(uint32_t extensions_bitvector, 421 void GenerateVideoSendConfig(uint32_t extensions_bitvector,
376 VideoSendStream::Config* config) { 422 VideoSendStream::Config* config) {
377 // Create a map from a payload type to an encoder name. 423 // Create a map from a payload type to an encoder name.
378 config->encoder_settings.payload_type = rand(); 424 config->encoder_settings.payload_type = rand();
379 config->encoder_settings.payload_name = (rand() % 2 ? "VP8" : "H264"); 425 config->encoder_settings.payload_name = (rand() % 2 ? "VP8" : "H264");
380 // Add SSRCs for the stream. 426 // Add SSRCs for the stream.
381 config->rtp.ssrcs.push_back(rand()); 427 config->rtp.ssrcs.push_back(rand());
382 // Add a map from a payload type to new ssrcs and a new payload type for RTX. 428 // Add a map from a payload type to new ssrcs and a new payload type for RTX.
383 config->rtp.rtx.ssrcs.push_back(rand()); 429 config->rtp.rtx.ssrcs.push_back(rand());
384 config->rtp.rtx.payload_type = rand(); 430 config->rtp.rtx.payload_type = rand();
385 // Add a CNAME.
386 config->rtp.c_name = "some.user@some.host";
387 // Add header extensions. 431 // Add header extensions.
388 for (unsigned i = 0; i < kNumExtensions; i++) { 432 for (unsigned i = 0; i < kNumExtensions; i++) {
389 if (extensions_bitvector & (1u << i)) { 433 if (extensions_bitvector & (1u << i)) {
390 config->rtp.extensions.push_back( 434 config->rtp.extensions.push_back(
391 RtpExtension(kExtensionNames[i], rand())); 435 RtpExtension(kExtensionNames[i], rand()));
392 } 436 }
393 } 437 }
394 } 438 }
395 439
396 // Test for the RtcEventLog class. Dumps some RTP packets and other events 440 // Test for the RtcEventLog class. Dumps some RTP packets and other events
(...skipping 19 matching lines...) Expand all
416 // Create rtp_count RTP packets containing random data. 460 // Create rtp_count RTP packets containing random data.
417 for (size_t i = 0; i < rtp_count; i++) { 461 for (size_t i = 0; i < rtp_count; i++) {
418 size_t packet_size = 1000 + rand() % 64; 462 size_t packet_size = 1000 + rand() % 64;
419 rtp_packets.push_back(rtc::Buffer(packet_size)); 463 rtp_packets.push_back(rtc::Buffer(packet_size));
420 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count, 464 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count,
421 rtp_packets[i].data(), packet_size); 465 rtp_packets[i].data(), packet_size);
422 rtp_header_sizes.push_back(header_size); 466 rtp_header_sizes.push_back(header_size);
423 } 467 }
424 // Create rtcp_count RTCP packets containing random data. 468 // Create rtcp_count RTCP packets containing random data.
425 for (size_t i = 0; i < rtcp_count; i++) { 469 for (size_t i = 0; i < rtcp_count; i++) {
426 size_t packet_size = 1000 + rand() % 64; 470 rtcp_packets.push_back(rtc::Buffer());
427 rtcp_packets.push_back(rtc::Buffer(packet_size)); 471 GenerateRtcpPacket(&(rtcp_packets[i]));
428 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size);
429 } 472 }
430 // Create playout_count random SSRCs to use when logging AudioPlayout events. 473 // Create playout_count random SSRCs to use when logging AudioPlayout events.
431 for (size_t i = 0; i < playout_count; i++) { 474 for (size_t i = 0; i < playout_count; i++) {
432 playout_ssrcs.push_back(static_cast<uint32_t>(rand())); 475 playout_ssrcs.push_back(static_cast<uint32_t>(rand()));
433 } 476 }
434 // Create configurations for the video streams. 477 // Create configurations for the video streams.
435 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config); 478 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config);
436 GenerateVideoSendConfig(extensions_bitvector, &sender_config); 479 GenerateVideoSendConfig(extensions_bitvector, &sender_config);
437 const int config_count = 2; 480 const int config_count = 2;
438 481
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 size_t packet_size = 1000 + rand() % 64; 611 size_t packet_size = 1000 + rand() % 64;
569 old_rtp_packet.SetSize(packet_size); 612 old_rtp_packet.SetSize(packet_size);
570 GenerateRtpPacket(extensions_bitvector, csrcs_count, old_rtp_packet.data(), 613 GenerateRtpPacket(extensions_bitvector, csrcs_count, old_rtp_packet.data(),
571 packet_size); 614 packet_size);
572 packet_size = 1000 + rand() % 64; 615 packet_size = 1000 + rand() % 64;
573 recent_rtp_packet.SetSize(packet_size); 616 recent_rtp_packet.SetSize(packet_size);
574 size_t recent_header_size = GenerateRtpPacket( 617 size_t recent_header_size = GenerateRtpPacket(
575 extensions_bitvector, csrcs_count, recent_rtp_packet.data(), packet_size); 618 extensions_bitvector, csrcs_count, recent_rtp_packet.data(), packet_size);
576 619
577 // Create two RTCP packets containing random data. 620 // Create two RTCP packets containing random data.
578 packet_size = 1000 + rand() % 64; 621 GenerateRtcpPacket(&old_rtcp_packet);
579 old_rtcp_packet.SetSize(packet_size); 622 GenerateRtcpPacket(&recent_rtcp_packet);
580 GenerateRtcpPacket(old_rtcp_packet.data(), packet_size);
581 packet_size = 1000 + rand() % 64;
582 recent_rtcp_packet.SetSize(packet_size);
583 GenerateRtcpPacket(recent_rtcp_packet.data(), packet_size);
584 623
585 // Create configurations for the video streams. 624 // Create configurations for the video streams.
586 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config); 625 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config);
587 GenerateVideoSendConfig(extensions_bitvector, &sender_config); 626 GenerateVideoSendConfig(extensions_bitvector, &sender_config);
588 627
589 // Find the name of the current test, in order to use it as a temporary 628 // Find the name of the current test, in order to use it as a temporary
590 // filename. 629 // filename.
591 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 630 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
592 const std::string temp_filename = 631 const std::string temp_filename =
593 test::OutputPath() + test_info->test_case_name() + test_info->name(); 632 test::OutputPath() + test_info->test_case_name() + test_info->name();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // Enable all header extensions 677 // Enable all header extensions
639 uint32_t extensions = (1u << kNumExtensions) - 1; 678 uint32_t extensions = (1u << kNumExtensions) - 1;
640 uint32_t csrcs_count = 2; 679 uint32_t csrcs_count = 2;
641 DropOldEvents(extensions, csrcs_count, 141421356); 680 DropOldEvents(extensions, csrcs_count, 141421356);
642 DropOldEvents(extensions, csrcs_count, 173205080); 681 DropOldEvents(extensions, csrcs_count, 173205080);
643 } 682 }
644 683
645 } // namespace webrtc 684 } // namespace webrtc
646 685
647 #endif // ENABLE_RTC_EVENT_LOG 686 #endif // ENABLE_RTC_EVENT_LOG
OLDNEW
« no previous file with comments | « webrtc/call/rtc_event_log.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698