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

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

Issue 1348113003: Update to the RtcEventLog protobuf to remove the DebugEvent message. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio_playout_timing
Patch Set: Rebase. Created 5 years, 2 months 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
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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return ::testing::AssertionFailure() << "Event has no event type"; 77 return ::testing::AssertionFailure() << "Event has no event type";
78 rtclog::Event_EventType type = event.type(); 78 rtclog::Event_EventType type = event.type();
79 if ((type == rtclog::Event::RTP_EVENT) != event.has_rtp_packet()) 79 if ((type == rtclog::Event::RTP_EVENT) != event.has_rtp_packet())
80 return ::testing::AssertionFailure() 80 return ::testing::AssertionFailure()
81 << "Event of type " << type << " has " 81 << "Event of type " << type << " has "
82 << (event.has_rtp_packet() ? "" : "no ") << "RTP packet"; 82 << (event.has_rtp_packet() ? "" : "no ") << "RTP packet";
83 if ((type == rtclog::Event::RTCP_EVENT) != event.has_rtcp_packet()) 83 if ((type == rtclog::Event::RTCP_EVENT) != event.has_rtcp_packet())
84 return ::testing::AssertionFailure() 84 return ::testing::AssertionFailure()
85 << "Event of type " << type << " has " 85 << "Event of type " << type << " has "
86 << (event.has_rtcp_packet() ? "" : "no ") << "RTCP packet"; 86 << (event.has_rtcp_packet() ? "" : "no ") << "RTCP packet";
87 if ((type == rtclog::Event::DEBUG_EVENT) != event.has_debug_event()) 87 if ((type == rtclog::Event::AUDIO_PLAYOUT_EVENT) !=
88 event.has_audio_playout_event())
88 return ::testing::AssertionFailure() 89 return ::testing::AssertionFailure()
89 << "Event of type " << type << " has " 90 << "Event of type " << type << " has "
90 << (event.has_debug_event() ? "" : "no ") << "debug event"; 91 << (event.has_audio_playout_event() ? "" : "no ")
92 << "audio_playout event";
91 if ((type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT) != 93 if ((type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT) !=
92 event.has_video_receiver_config()) 94 event.has_video_receiver_config())
93 return ::testing::AssertionFailure() 95 return ::testing::AssertionFailure()
94 << "Event of type " << type << " has " 96 << "Event of type " << type << " has "
95 << (event.has_video_receiver_config() ? "" : "no ") 97 << (event.has_video_receiver_config() ? "" : "no ")
96 << "receiver config"; 98 << "receiver config";
97 if ((type == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT) != 99 if ((type == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT) !=
98 event.has_video_sender_config()) 100 event.has_video_sender_config())
99 return ::testing::AssertionFailure() 101 return ::testing::AssertionFailure()
100 << "Event of type " << type << " has " 102 << "Event of type " << type << " has "
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type())); 262 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type()));
261 ASSERT_TRUE(rtcp_packet.has_packet_data()); 263 ASSERT_TRUE(rtcp_packet.has_packet_data());
262 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); 264 ASSERT_EQ(total_size, rtcp_packet.packet_data().size());
263 for (size_t i = 0; i < total_size; i++) { 265 for (size_t i = 0; i < total_size; i++) {
264 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i])); 266 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i]));
265 } 267 }
266 } 268 }
267 269
268 void VerifyPlayoutEvent(const rtclog::Event& event, uint32_t ssrc) { 270 void VerifyPlayoutEvent(const rtclog::Event& event, uint32_t ssrc) {
269 ASSERT_TRUE(IsValidBasicEvent(event)); 271 ASSERT_TRUE(IsValidBasicEvent(event));
270 ASSERT_EQ(rtclog::Event::DEBUG_EVENT, event.type()); 272 ASSERT_EQ(rtclog::Event::AUDIO_PLAYOUT_EVENT, event.type());
271 const rtclog::DebugEvent& debug_event = event.debug_event(); 273 const rtclog::AudioPlayoutEvent& playout_event = event.audio_playout_event();
272 ASSERT_TRUE(debug_event.has_type()); 274 ASSERT_TRUE(playout_event.has_local_ssrc());
273 EXPECT_EQ(rtclog::DebugEvent::AUDIO_PLAYOUT, debug_event.type()); 275 EXPECT_EQ(ssrc, playout_event.local_ssrc());
274 ASSERT_TRUE(debug_event.has_local_ssrc());
275 EXPECT_EQ(ssrc, debug_event.local_ssrc());
276 } 276 }
277 277
278 void VerifyLogStartEvent(const rtclog::Event& event) { 278 void VerifyLogStartEvent(const rtclog::Event& event) {
279 ASSERT_TRUE(IsValidBasicEvent(event)); 279 ASSERT_TRUE(IsValidBasicEvent(event));
280 ASSERT_EQ(rtclog::Event::DEBUG_EVENT, event.type()); 280 EXPECT_EQ(rtclog::Event::LOG_START, event.type());
281 const rtclog::DebugEvent& debug_event = event.debug_event();
282 ASSERT_TRUE(debug_event.has_type());
283 EXPECT_EQ(rtclog::DebugEvent::LOG_START, debug_event.type());
284 } 281 }
285 282
286 /* 283 /*
287 * Bit number i of extension_bitvector is set to indicate the 284 * Bit number i of extension_bitvector is set to indicate the
288 * presence of extension number i from kExtensionTypes / kExtensionNames. 285 * presence of extension number i from kExtensionTypes / kExtensionNames.
289 * The least significant bit extension_bitvector has number 0. 286 * The least significant bit extension_bitvector has number 0.
290 */ 287 */
291 size_t GenerateRtpPacket(uint32_t extensions_bitvector, 288 size_t GenerateRtpPacket(uint32_t extensions_bitvector,
292 uint32_t csrcs_count, 289 uint32_t csrcs_count,
293 uint8_t* packet, 290 uint8_t* packet,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 config->rtp.extensions.push_back( 389 config->rtp.extensions.push_back(
393 RtpExtension(kExtensionNames[i], rand())); 390 RtpExtension(kExtensionNames[i], rand()));
394 } 391 }
395 } 392 }
396 } 393 }
397 394
398 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads 395 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads
399 // them back to see if they match. 396 // them back to see if they match.
400 void LogSessionAndReadBack(size_t rtp_count, 397 void LogSessionAndReadBack(size_t rtp_count,
401 size_t rtcp_count, 398 size_t rtcp_count,
402 size_t debug_count, 399 size_t playout_count,
403 uint32_t extensions_bitvector, 400 uint32_t extensions_bitvector,
404 uint32_t csrcs_count, 401 uint32_t csrcs_count,
405 unsigned random_seed) { 402 unsigned random_seed) {
406 ASSERT_LE(rtcp_count, rtp_count); 403 ASSERT_LE(rtcp_count, rtp_count);
407 ASSERT_LE(debug_count, rtp_count); 404 ASSERT_LE(playout_count, rtp_count);
408 std::vector<rtc::Buffer> rtp_packets; 405 std::vector<rtc::Buffer> rtp_packets;
409 std::vector<rtc::Buffer> rtcp_packets; 406 std::vector<rtc::Buffer> rtcp_packets;
410 std::vector<size_t> rtp_header_sizes; 407 std::vector<size_t> rtp_header_sizes;
411 std::vector<uint32_t> playout_ssrcs; 408 std::vector<uint32_t> playout_ssrcs;
412 409
413 VideoReceiveStream::Config receiver_config(nullptr); 410 VideoReceiveStream::Config receiver_config(nullptr);
414 VideoSendStream::Config sender_config(nullptr); 411 VideoSendStream::Config sender_config(nullptr);
415 412
416 srand(random_seed); 413 srand(random_seed);
417 414
418 // Create rtp_count RTP packets containing random data. 415 // Create rtp_count RTP packets containing random data.
419 for (size_t i = 0; i < rtp_count; i++) { 416 for (size_t i = 0; i < rtp_count; i++) {
420 size_t packet_size = 1000 + rand() % 64; 417 size_t packet_size = 1000 + rand() % 64;
421 rtp_packets.push_back(rtc::Buffer(packet_size)); 418 rtp_packets.push_back(rtc::Buffer(packet_size));
422 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count, 419 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count,
423 rtp_packets[i].data(), packet_size); 420 rtp_packets[i].data(), packet_size);
424 rtp_header_sizes.push_back(header_size); 421 rtp_header_sizes.push_back(header_size);
425 } 422 }
426 // Create rtcp_count RTCP packets containing random data. 423 // Create rtcp_count RTCP packets containing random data.
427 for (size_t i = 0; i < rtcp_count; i++) { 424 for (size_t i = 0; i < rtcp_count; i++) {
428 size_t packet_size = 1000 + rand() % 64; 425 size_t packet_size = 1000 + rand() % 64;
429 rtcp_packets.push_back(rtc::Buffer(packet_size)); 426 rtcp_packets.push_back(rtc::Buffer(packet_size));
430 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size); 427 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size);
431 } 428 }
432 // Create debug_count random SSRCs to use when logging AudioPlayout events. 429 // Create playout_count random SSRCs to use when logging AudioPlayout events.
433 for (size_t i = 0; i < debug_count; i++) { 430 for (size_t i = 0; i < playout_count; i++) {
434 playout_ssrcs.push_back(static_cast<uint32_t>(rand())); 431 playout_ssrcs.push_back(static_cast<uint32_t>(rand()));
435 } 432 }
436 // Create configurations for the video streams. 433 // Create configurations for the video streams.
437 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config); 434 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config);
438 GenerateVideoSendConfig(extensions_bitvector, &sender_config); 435 GenerateVideoSendConfig(extensions_bitvector, &sender_config);
439 const int config_count = 2; 436 const int config_count = 2;
440 437
441 // Find the name of the current test, in order to use it as a temporary 438 // Find the name of the current test, in order to use it as a temporary
442 // filename. 439 // filename.
443 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 440 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
444 const std::string temp_filename = 441 const std::string temp_filename =
445 test::OutputPath() + test_info->test_case_name() + test_info->name(); 442 test::OutputPath() + test_info->test_case_name() + test_info->name();
446 443
447 // When log_dumper goes out of scope, it causes the log file to be flushed 444 // When log_dumper goes out of scope, it causes the log file to be flushed
448 // to disk. 445 // to disk.
449 { 446 {
450 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 447 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
451 log_dumper->LogVideoReceiveStreamConfig(receiver_config); 448 log_dumper->LogVideoReceiveStreamConfig(receiver_config);
452 log_dumper->LogVideoSendStreamConfig(sender_config); 449 log_dumper->LogVideoSendStreamConfig(sender_config);
453 size_t rtcp_index = 1, debug_index = 1; 450 size_t rtcp_index = 1, playout_index = 1;
454 for (size_t i = 1; i <= rtp_count; i++) { 451 for (size_t i = 1; i <= rtp_count; i++) {
455 log_dumper->LogRtpHeader( 452 log_dumper->LogRtpHeader(
456 (i % 2 == 0), // Every second packet is incoming. 453 (i % 2 == 0), // Every second packet is incoming.
457 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, 454 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
458 rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); 455 rtp_packets[i - 1].data(), rtp_packets[i - 1].size());
459 if (i * rtcp_count >= rtcp_index * rtp_count) { 456 if (i * rtcp_count >= rtcp_index * rtp_count) {
460 log_dumper->LogRtcpPacket( 457 log_dumper->LogRtcpPacket(
461 rtcp_index % 2 == 0, // Every second packet is incoming 458 rtcp_index % 2 == 0, // Every second packet is incoming
462 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, 459 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO,
463 rtcp_packets[rtcp_index - 1].data(), 460 rtcp_packets[rtcp_index - 1].data(),
464 rtcp_packets[rtcp_index - 1].size()); 461 rtcp_packets[rtcp_index - 1].size());
465 rtcp_index++; 462 rtcp_index++;
466 } 463 }
467 if (i * debug_count >= debug_index * rtp_count) { 464 if (i * playout_count >= playout_index * rtp_count) {
468 log_dumper->LogAudioPlayout(playout_ssrcs[debug_index - 1]); 465 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]);
469 debug_index++; 466 playout_index++;
470 } 467 }
471 if (i == rtp_count / 2) { 468 if (i == rtp_count / 2) {
472 log_dumper->StartLogging(temp_filename, 10000000); 469 log_dumper->StartLogging(temp_filename, 10000000);
473 } 470 }
474 } 471 }
475 } 472 }
476 473
477 // Read the generated file from disk. 474 // Read the generated file from disk.
478 rtclog::EventStream parsed_stream; 475 rtclog::EventStream parsed_stream;
479 476
480 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream)); 477 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream));
481 478
482 // Verify the result. 479 // Verify the result.
483 const int event_count = 480 const int event_count =
484 config_count + debug_count + rtcp_count + rtp_count + 1; 481 config_count + playout_count + rtcp_count + rtp_count + 1;
485 EXPECT_EQ(event_count, parsed_stream.stream_size()); 482 EXPECT_EQ(event_count, parsed_stream.stream_size());
486 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config); 483 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config);
487 VerifySendStreamConfig(parsed_stream.stream(1), sender_config); 484 VerifySendStreamConfig(parsed_stream.stream(1), sender_config);
488 size_t event_index = config_count, rtcp_index = 1, debug_index = 1; 485 size_t event_index = config_count, rtcp_index = 1, playout_index = 1;
489 for (size_t i = 1; i <= rtp_count; i++) { 486 for (size_t i = 1; i <= rtp_count; i++) {
490 VerifyRtpEvent(parsed_stream.stream(event_index), 487 VerifyRtpEvent(parsed_stream.stream(event_index),
491 (i % 2 == 0), // Every second packet is incoming. 488 (i % 2 == 0), // Every second packet is incoming.
492 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, 489 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
493 rtp_packets[i - 1].data(), rtp_header_sizes[i - 1], 490 rtp_packets[i - 1].data(), rtp_header_sizes[i - 1],
494 rtp_packets[i - 1].size()); 491 rtp_packets[i - 1].size());
495 event_index++; 492 event_index++;
496 if (i * rtcp_count >= rtcp_index * rtp_count) { 493 if (i * rtcp_count >= rtcp_index * rtp_count) {
497 VerifyRtcpEvent(parsed_stream.stream(event_index), 494 VerifyRtcpEvent(parsed_stream.stream(event_index),
498 rtcp_index % 2 == 0, // Every second packet is incoming. 495 rtcp_index % 2 == 0, // Every second packet is incoming.
499 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, 496 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO,
500 rtcp_packets[rtcp_index - 1].data(), 497 rtcp_packets[rtcp_index - 1].data(),
501 rtcp_packets[rtcp_index - 1].size()); 498 rtcp_packets[rtcp_index - 1].size());
502 event_index++; 499 event_index++;
503 rtcp_index++; 500 rtcp_index++;
504 } 501 }
505 if (i * debug_count >= debug_index * rtp_count) { 502 if (i * playout_count >= playout_index * rtp_count) {
506 VerifyPlayoutEvent(parsed_stream.stream(event_index), 503 VerifyPlayoutEvent(parsed_stream.stream(event_index),
507 playout_ssrcs[debug_index - 1]); 504 playout_ssrcs[playout_index - 1]);
508 event_index++; 505 event_index++;
509 debug_index++; 506 playout_index++;
510 } 507 }
511 if (i == rtp_count / 2) { 508 if (i == rtp_count / 2) {
512 VerifyLogStartEvent(parsed_stream.stream(event_index)); 509 VerifyLogStartEvent(parsed_stream.stream(event_index));
513 event_index++; 510 event_index++;
514 } 511 }
515 } 512 }
516 513
517 // Clean up temporary file - can be pretty slow. 514 // Clean up temporary file - can be pretty slow.
518 remove(temp_filename.c_str()); 515 remove(temp_filename.c_str());
519 } 516 }
(...skipping 25 matching lines...) Expand all
545 extensions, // Bit vector choosing extensions 542 extensions, // Bit vector choosing extensions
546 csrcs_count, // Number of contributing sources 543 csrcs_count, // Number of contributing sources
547 rand()); 544 rand());
548 } 545 }
549 } 546 }
550 } 547 }
551 548
552 } // namespace webrtc 549 } // namespace webrtc
553 550
554 #endif // ENABLE_RTC_EVENT_LOG 551 #endif // ENABLE_RTC_EVENT_LOG
OLDNEW
« no previous file with comments | « webrtc/call/rtc_event_log.proto ('k') | webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698