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

Side by Side Diff: webrtc/video/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: Addressed terelius@ comments. 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 config->rtp.extensions.push_back( 390 config->rtp.extensions.push_back(
394 RtpExtension(kExtensionNames[i], rand())); 391 RtpExtension(kExtensionNames[i], rand()));
395 } 392 }
396 } 393 }
397 } 394 }
398 395
399 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads 396 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads
400 // them back to see if they match. 397 // them back to see if they match.
401 void LogSessionAndReadBack(size_t rtp_count, 398 void LogSessionAndReadBack(size_t rtp_count,
402 size_t rtcp_count, 399 size_t rtcp_count,
403 size_t debug_count, 400 size_t playout_count,
404 uint32_t extensions_bitvector, 401 uint32_t extensions_bitvector,
405 uint32_t csrcs_count, 402 uint32_t csrcs_count,
406 unsigned random_seed) { 403 unsigned random_seed) {
407 ASSERT_LE(rtcp_count, rtp_count); 404 ASSERT_LE(rtcp_count, rtp_count);
408 ASSERT_LE(debug_count, rtp_count); 405 ASSERT_LE(playout_count, rtp_count);
409 std::vector<rtc::Buffer> rtp_packets; 406 std::vector<rtc::Buffer> rtp_packets;
410 std::vector<rtc::Buffer> rtcp_packets; 407 std::vector<rtc::Buffer> rtcp_packets;
411 std::vector<size_t> rtp_header_sizes; 408 std::vector<size_t> rtp_header_sizes;
412 std::vector<uint32_t> playout_ssrcs; 409 std::vector<uint32_t> playout_ssrcs;
413 410
414 VideoReceiveStream::Config receiver_config(nullptr); 411 VideoReceiveStream::Config receiver_config(nullptr);
415 VideoSendStream::Config sender_config(nullptr); 412 VideoSendStream::Config sender_config(nullptr);
416 413
417 srand(random_seed); 414 srand(random_seed);
418 415
419 // Create rtp_count RTP packets containing random data. 416 // Create rtp_count RTP packets containing random data.
420 for (size_t i = 0; i < rtp_count; i++) { 417 for (size_t i = 0; i < rtp_count; i++) {
421 size_t packet_size = 1000 + rand() % 64; 418 size_t packet_size = 1000 + rand() % 64;
422 rtp_packets.push_back(rtc::Buffer(packet_size)); 419 rtp_packets.push_back(rtc::Buffer(packet_size));
423 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count, 420 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count,
424 rtp_packets[i].data(), packet_size); 421 rtp_packets[i].data(), packet_size);
425 rtp_header_sizes.push_back(header_size); 422 rtp_header_sizes.push_back(header_size);
426 } 423 }
427 // Create rtcp_count RTCP packets containing random data. 424 // Create rtcp_count RTCP packets containing random data.
428 for (size_t i = 0; i < rtcp_count; i++) { 425 for (size_t i = 0; i < rtcp_count; i++) {
429 size_t packet_size = 1000 + rand() % 64; 426 size_t packet_size = 1000 + rand() % 64;
430 rtcp_packets.push_back(rtc::Buffer(packet_size)); 427 rtcp_packets.push_back(rtc::Buffer(packet_size));
431 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size); 428 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size);
432 } 429 }
433 // Create debug_count random SSRCs to use when logging AudioPlayout events. 430 // Create playout_count random SSRCs to use when logging AudioPlayout events.
434 for (size_t i = 0; i < debug_count; i++) { 431 for (size_t i = 0; i < playout_count; i++) {
435 playout_ssrcs.push_back(static_cast<uint32_t>(rand())); 432 playout_ssrcs.push_back(static_cast<uint32_t>(rand()));
436 } 433 }
437 // Create configurations for the video streams. 434 // Create configurations for the video streams.
438 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config); 435 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config);
439 GenerateVideoSendConfig(extensions_bitvector, &sender_config); 436 GenerateVideoSendConfig(extensions_bitvector, &sender_config);
440 const int config_count = 2; 437 const int config_count = 2;
441 438
442 // Find the name of the current test, in order to use it as a temporary 439 // Find the name of the current test, in order to use it as a temporary
443 // filename. 440 // filename.
444 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 441 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
445 const std::string temp_filename = 442 const std::string temp_filename =
446 test::OutputPath() + test_info->test_case_name() + test_info->name(); 443 test::OutputPath() + test_info->test_case_name() + test_info->name();
447 444
448 // When log_dumper goes out of scope, it causes the log file to be flushed 445 // When log_dumper goes out of scope, it causes the log file to be flushed
449 // to disk. 446 // to disk.
450 { 447 {
451 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 448 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
452 log_dumper->LogVideoReceiveStreamConfig(receiver_config); 449 log_dumper->LogVideoReceiveStreamConfig(receiver_config);
453 log_dumper->LogVideoSendStreamConfig(sender_config); 450 log_dumper->LogVideoSendStreamConfig(sender_config);
454 size_t rtcp_index = 1, debug_index = 1; 451 size_t rtcp_index = 1, playout_index = 1;
455 for (size_t i = 1; i <= rtp_count; i++) { 452 for (size_t i = 1; i <= rtp_count; i++) {
456 log_dumper->LogRtpHeader( 453 log_dumper->LogRtpHeader(
457 (i % 2 == 0), // Every second packet is incoming. 454 (i % 2 == 0), // Every second packet is incoming.
458 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, 455 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
459 rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); 456 rtp_packets[i - 1].data(), rtp_packets[i - 1].size());
460 if (i * rtcp_count >= rtcp_index * rtp_count) { 457 if (i * rtcp_count >= rtcp_index * rtp_count) {
461 log_dumper->LogRtcpPacket( 458 log_dumper->LogRtcpPacket(
462 rtcp_index % 2 == 0, // Every second packet is incoming 459 rtcp_index % 2 == 0, // Every second packet is incoming
463 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, 460 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO,
464 rtcp_packets[rtcp_index - 1].data(), 461 rtcp_packets[rtcp_index - 1].data(),
465 rtcp_packets[rtcp_index - 1].size()); 462 rtcp_packets[rtcp_index - 1].size());
466 rtcp_index++; 463 rtcp_index++;
467 } 464 }
468 if (i * debug_count >= debug_index * rtp_count) { 465 if (i * playout_count >= playout_index * rtp_count) {
469 log_dumper->LogAudioPlayout(playout_ssrcs[debug_index - 1]); 466 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]);
470 debug_index++; 467 playout_index++;
471 } 468 }
472 if (i == rtp_count / 2) { 469 if (i == rtp_count / 2) {
473 log_dumper->StartLogging(temp_filename, 10000000); 470 log_dumper->StartLogging(temp_filename, 10000000);
474 } 471 }
475 } 472 }
476 } 473 }
477 474
478 // Read the generated file from disk. 475 // Read the generated file from disk.
479 rtclog::EventStream parsed_stream; 476 rtclog::EventStream parsed_stream;
480 477
481 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream)); 478 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream));
482 479
483 // Verify the result. 480 // Verify the result.
484 const int event_count = 481 const int event_count =
485 config_count + debug_count + rtcp_count + rtp_count + 1; 482 config_count + playout_count + rtcp_count + rtp_count + 1;
486 EXPECT_EQ(event_count, parsed_stream.stream_size()); 483 EXPECT_EQ(event_count, parsed_stream.stream_size());
487 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config); 484 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config);
488 VerifySendStreamConfig(parsed_stream.stream(1), sender_config); 485 VerifySendStreamConfig(parsed_stream.stream(1), sender_config);
489 size_t event_index = config_count, rtcp_index = 1, debug_index = 1; 486 size_t event_index = config_count, rtcp_index = 1, playout_index = 1;
490 for (size_t i = 1; i <= rtp_count; i++) { 487 for (size_t i = 1; i <= rtp_count; i++) {
491 VerifyRtpEvent(parsed_stream.stream(event_index), 488 VerifyRtpEvent(parsed_stream.stream(event_index),
492 (i % 2 == 0), // Every second packet is incoming. 489 (i % 2 == 0), // Every second packet is incoming.
493 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, 490 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
494 rtp_packets[i - 1].data(), rtp_header_sizes[i - 1], 491 rtp_packets[i - 1].data(), rtp_header_sizes[i - 1],
495 rtp_packets[i - 1].size()); 492 rtp_packets[i - 1].size());
496 event_index++; 493 event_index++;
497 if (i * rtcp_count >= rtcp_index * rtp_count) { 494 if (i * rtcp_count >= rtcp_index * rtp_count) {
498 VerifyRtcpEvent(parsed_stream.stream(event_index), 495 VerifyRtcpEvent(parsed_stream.stream(event_index),
499 rtcp_index % 2 == 0, // Every second packet is incoming. 496 rtcp_index % 2 == 0, // Every second packet is incoming.
500 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, 497 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO,
501 rtcp_packets[rtcp_index - 1].data(), 498 rtcp_packets[rtcp_index - 1].data(),
502 rtcp_packets[rtcp_index - 1].size()); 499 rtcp_packets[rtcp_index - 1].size());
503 event_index++; 500 event_index++;
504 rtcp_index++; 501 rtcp_index++;
505 } 502 }
506 if (i * debug_count >= debug_index * rtp_count) { 503 if (i * playout_count >= playout_index * rtp_count) {
507 VerifyPlayoutEvent(parsed_stream.stream(event_index), 504 VerifyPlayoutEvent(parsed_stream.stream(event_index),
508 playout_ssrcs[debug_index - 1]); 505 playout_ssrcs[playout_index - 1]);
509 event_index++; 506 event_index++;
510 debug_index++; 507 playout_index++;
511 } 508 }
512 if (i == rtp_count / 2) { 509 if (i == rtp_count / 2) {
513 VerifyLogStartEvent(parsed_stream.stream(event_index)); 510 VerifyLogStartEvent(parsed_stream.stream(event_index));
514 event_index++; 511 event_index++;
515 } 512 }
516 } 513 }
517 514
518 // Clean up temporary file - can be pretty slow. 515 // Clean up temporary file - can be pretty slow.
519 remove(temp_filename.c_str()); 516 remove(temp_filename.c_str());
520 } 517 }
(...skipping 25 matching lines...) Expand all
546 extensions, // Bit vector choosing extensions 543 extensions, // Bit vector choosing extensions
547 csrcs_count, // Number of contributing sources 544 csrcs_count, // Number of contributing sources
548 rand()); 545 rand());
549 } 546 }
550 } 547 }
551 } 548 }
552 549
553 } // namespace webrtc 550 } // namespace webrtc
554 551
555 #endif // ENABLE_RTC_EVENT_LOG 552 #endif // ENABLE_RTC_EVENT_LOG
OLDNEW
« webrtc/video/rtc_event_log.proto ('K') | « webrtc/video/rtc_event_log.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698