OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 12 matching lines...) Expand all Loading... |
23 // Files generated at build-time by the protobuf compiler. | 23 // Files generated at build-time by the protobuf compiler. |
24 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 24 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
25 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 25 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
26 #else | 26 #else |
27 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 27 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
28 #endif | 28 #endif |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 namespace { | 32 namespace { |
33 MediaType GetRuntimeMediaType(rtclog::MediaType media_type) { | |
34 switch (media_type) { | |
35 case rtclog::MediaType::ANY: | |
36 return MediaType::ANY; | |
37 case rtclog::MediaType::AUDIO: | |
38 return MediaType::AUDIO; | |
39 case rtclog::MediaType::VIDEO: | |
40 return MediaType::VIDEO; | |
41 case rtclog::MediaType::DATA: | |
42 return MediaType::DATA; | |
43 } | |
44 RTC_NOTREACHED(); | |
45 return MediaType::ANY; | |
46 } | |
47 | 33 |
48 BandwidthUsage GetRuntimeDetectorState( | 34 BandwidthUsage GetRuntimeDetectorState( |
49 rtclog::DelayBasedBweUpdate::DetectorState detector_state) { | 35 rtclog::DelayBasedBweUpdate::DetectorState detector_state) { |
50 switch (detector_state) { | 36 switch (detector_state) { |
51 case rtclog::DelayBasedBweUpdate::BWE_NORMAL: | 37 case rtclog::DelayBasedBweUpdate::BWE_NORMAL: |
52 return BandwidthUsage::kBwNormal; | 38 return BandwidthUsage::kBwNormal; |
53 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING: | 39 case rtclog::DelayBasedBweUpdate::BWE_UNDERUSING: |
54 return BandwidthUsage::kBwUnderusing; | 40 return BandwidthUsage::kBwUnderusing; |
55 case rtclog::DelayBasedBweUpdate::BWE_OVERUSING: | 41 case rtclog::DelayBasedBweUpdate::BWE_OVERUSING: |
56 return BandwidthUsage::kBwOverusing; | 42 return BandwidthUsage::kBwOverusing; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 346 |
361 // Check consistency of the parser. | 347 // Check consistency of the parser. |
362 rtclog::StreamConfig parsed_config; | 348 rtclog::StreamConfig parsed_config; |
363 parsed_log.GetAudioSendConfig(index, &parsed_config); | 349 parsed_log.GetAudioSendConfig(index, &parsed_config); |
364 VerifyStreamConfigsAreEqual(config, parsed_config); | 350 VerifyStreamConfigsAreEqual(config, parsed_config); |
365 } | 351 } |
366 | 352 |
367 void RtcEventLogTestHelper::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log, | 353 void RtcEventLogTestHelper::VerifyRtpEvent(const ParsedRtcEventLog& parsed_log, |
368 size_t index, | 354 size_t index, |
369 PacketDirection direction, | 355 PacketDirection direction, |
370 MediaType media_type, | |
371 const uint8_t* header, | 356 const uint8_t* header, |
372 size_t header_size, | 357 size_t header_size, |
373 size_t total_size) { | 358 size_t total_size) { |
374 const rtclog::Event& event = parsed_log.events_[index]; | 359 const rtclog::Event& event = parsed_log.events_[index]; |
375 ASSERT_TRUE(IsValidBasicEvent(event)); | 360 ASSERT_TRUE(IsValidBasicEvent(event)); |
376 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type()); | 361 ASSERT_EQ(rtclog::Event::RTP_EVENT, event.type()); |
377 const rtclog::RtpPacket& rtp_packet = event.rtp_packet(); | 362 const rtclog::RtpPacket& rtp_packet = event.rtp_packet(); |
378 ASSERT_TRUE(rtp_packet.has_incoming()); | 363 ASSERT_TRUE(rtp_packet.has_incoming()); |
379 EXPECT_EQ(direction == kIncomingPacket, rtp_packet.incoming()); | 364 EXPECT_EQ(direction == kIncomingPacket, rtp_packet.incoming()); |
380 ASSERT_TRUE(rtp_packet.has_type()); | |
381 EXPECT_EQ(media_type, GetRuntimeMediaType(rtp_packet.type())); | |
382 ASSERT_TRUE(rtp_packet.has_packet_length()); | 365 ASSERT_TRUE(rtp_packet.has_packet_length()); |
383 EXPECT_EQ(total_size, rtp_packet.packet_length()); | 366 EXPECT_EQ(total_size, rtp_packet.packet_length()); |
384 ASSERT_TRUE(rtp_packet.has_header()); | 367 ASSERT_TRUE(rtp_packet.has_header()); |
385 ASSERT_EQ(header_size, rtp_packet.header().size()); | 368 ASSERT_EQ(header_size, rtp_packet.header().size()); |
386 for (size_t i = 0; i < header_size; i++) { | 369 for (size_t i = 0; i < header_size; i++) { |
387 EXPECT_EQ(header[i], static_cast<uint8_t>(rtp_packet.header()[i])); | 370 EXPECT_EQ(header[i], static_cast<uint8_t>(rtp_packet.header()[i])); |
388 } | 371 } |
389 | 372 |
390 // Check consistency of the parser. | 373 // Check consistency of the parser. |
391 PacketDirection parsed_direction; | 374 PacketDirection parsed_direction; |
392 MediaType parsed_media_type; | |
393 uint8_t parsed_header[1500]; | 375 uint8_t parsed_header[1500]; |
394 size_t parsed_header_size, parsed_total_size; | 376 size_t parsed_header_size, parsed_total_size; |
395 parsed_log.GetRtpHeader(index, &parsed_direction, &parsed_media_type, | 377 parsed_log.GetRtpHeader(index, &parsed_direction, parsed_header, |
396 parsed_header, &parsed_header_size, | 378 &parsed_header_size, &parsed_total_size); |
397 &parsed_total_size); | |
398 EXPECT_EQ(direction, parsed_direction); | 379 EXPECT_EQ(direction, parsed_direction); |
399 EXPECT_EQ(media_type, parsed_media_type); | |
400 ASSERT_EQ(header_size, parsed_header_size); | 380 ASSERT_EQ(header_size, parsed_header_size); |
401 EXPECT_EQ(0, std::memcmp(header, parsed_header, header_size)); | 381 EXPECT_EQ(0, std::memcmp(header, parsed_header, header_size)); |
402 EXPECT_EQ(total_size, parsed_total_size); | 382 EXPECT_EQ(total_size, parsed_total_size); |
403 } | 383 } |
404 | 384 |
405 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log, | 385 void RtcEventLogTestHelper::VerifyRtcpEvent(const ParsedRtcEventLog& parsed_log, |
406 size_t index, | 386 size_t index, |
407 PacketDirection direction, | 387 PacketDirection direction, |
408 MediaType media_type, | |
409 const uint8_t* packet, | 388 const uint8_t* packet, |
410 size_t total_size) { | 389 size_t total_size) { |
411 const rtclog::Event& event = parsed_log.events_[index]; | 390 const rtclog::Event& event = parsed_log.events_[index]; |
412 ASSERT_TRUE(IsValidBasicEvent(event)); | 391 ASSERT_TRUE(IsValidBasicEvent(event)); |
413 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type()); | 392 ASSERT_EQ(rtclog::Event::RTCP_EVENT, event.type()); |
414 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet(); | 393 const rtclog::RtcpPacket& rtcp_packet = event.rtcp_packet(); |
415 ASSERT_TRUE(rtcp_packet.has_incoming()); | 394 ASSERT_TRUE(rtcp_packet.has_incoming()); |
416 EXPECT_EQ(direction == kIncomingPacket, rtcp_packet.incoming()); | 395 EXPECT_EQ(direction == kIncomingPacket, rtcp_packet.incoming()); |
417 ASSERT_TRUE(rtcp_packet.has_type()); | |
418 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type())); | |
419 ASSERT_TRUE(rtcp_packet.has_packet_data()); | 396 ASSERT_TRUE(rtcp_packet.has_packet_data()); |
420 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); | 397 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); |
421 for (size_t i = 0; i < total_size; i++) { | 398 for (size_t i = 0; i < total_size; i++) { |
422 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i])); | 399 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i])); |
423 } | 400 } |
424 | 401 |
425 // Check consistency of the parser. | 402 // Check consistency of the parser. |
426 PacketDirection parsed_direction; | 403 PacketDirection parsed_direction; |
427 MediaType parsed_media_type; | |
428 uint8_t parsed_packet[1500]; | 404 uint8_t parsed_packet[1500]; |
429 size_t parsed_total_size; | 405 size_t parsed_total_size; |
430 parsed_log.GetRtcpPacket(index, &parsed_direction, &parsed_media_type, | 406 parsed_log.GetRtcpPacket(index, &parsed_direction, parsed_packet, |
431 parsed_packet, &parsed_total_size); | 407 &parsed_total_size); |
432 EXPECT_EQ(direction, parsed_direction); | 408 EXPECT_EQ(direction, parsed_direction); |
433 EXPECT_EQ(media_type, parsed_media_type); | |
434 ASSERT_EQ(total_size, parsed_total_size); | 409 ASSERT_EQ(total_size, parsed_total_size); |
435 EXPECT_EQ(0, std::memcmp(packet, parsed_packet, total_size)); | 410 EXPECT_EQ(0, std::memcmp(packet, parsed_packet, total_size)); |
436 } | 411 } |
437 | 412 |
438 void RtcEventLogTestHelper::VerifyPlayoutEvent( | 413 void RtcEventLogTestHelper::VerifyPlayoutEvent( |
439 const ParsedRtcEventLog& parsed_log, | 414 const ParsedRtcEventLog& parsed_log, |
440 size_t index, | 415 size_t index, |
441 uint32_t ssrc) { | 416 uint32_t ssrc) { |
442 const rtclog::Event& event = parsed_log.events_[index]; | 417 const rtclog::Event& event = parsed_log.events_[index]; |
443 ASSERT_TRUE(IsValidBasicEvent(event)); | 418 ASSERT_TRUE(IsValidBasicEvent(event)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 ASSERT_TRUE(bwe_event.has_id()); | 565 ASSERT_TRUE(bwe_event.has_id()); |
591 EXPECT_EQ(id, bwe_event.id()); | 566 EXPECT_EQ(id, bwe_event.id()); |
592 ASSERT_TRUE(bwe_event.has_result()); | 567 ASSERT_TRUE(bwe_event.has_result()); |
593 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result()); | 568 EXPECT_EQ(GetProbeResultType(failure_reason), bwe_event.result()); |
594 ASSERT_FALSE(bwe_event.has_bitrate_bps()); | 569 ASSERT_FALSE(bwe_event.has_bitrate_bps()); |
595 | 570 |
596 // TODO(philipel): Verify the parser when parsing has been implemented. | 571 // TODO(philipel): Verify the parser when parsing has been implemented. |
597 } | 572 } |
598 | 573 |
599 } // namespace webrtc | 574 } // namespace webrtc |
OLD | NEW |