OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 #include <string> | 11 #include <string> |
12 | 12 |
13 #include <list> | 13 #include <list> |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "webrtc/modules/video_coding/frame_buffer.h" | 18 #include "webrtc/modules/video_coding/frame_buffer.h" |
19 #include "webrtc/modules/video_coding/jitter_buffer.h" | 19 #include "webrtc/modules/video_coding/jitter_buffer.h" |
20 #include "webrtc/modules/video_coding/media_opt_util.h" | 20 #include "webrtc/modules/video_coding/media_opt_util.h" |
21 #include "webrtc/modules/video_coding/packet.h" | 21 #include "webrtc/modules/video_coding/packet.h" |
22 #include "webrtc/modules/video_coding/test/stream_generator.h" | 22 #include "webrtc/modules/video_coding/test/stream_generator.h" |
23 #include "webrtc/modules/video_coding/test/test_util.h" | 23 #include "webrtc/modules/video_coding/test/test_util.h" |
24 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
25 #include "webrtc/system_wrappers/include/field_trial.h" | 25 #include "webrtc/system_wrappers/include/field_trial.h" |
26 #include "webrtc/system_wrappers/include/metrics.h" | 26 #include "webrtc/system_wrappers/include/metrics.h" |
| 27 #include "webrtc/system_wrappers/include/metrics_default.h" |
27 #include "webrtc/test/field_trial.h" | 28 #include "webrtc/test/field_trial.h" |
28 #include "webrtc/test/histogram.h" | |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 namespace { | 32 namespace { |
33 const uint32_t kProcessIntervalSec = 60; | 33 const uint32_t kProcessIntervalSec = 60; |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 class Vp9SsMapTest : public ::testing::Test { | 36 class Vp9SsMapTest : public ::testing::Test { |
37 protected: | 37 protected: |
38 Vp9SsMapTest() : packet_(data_, 1400, 1234, 1, true) {} | 38 Vp9SsMapTest() : packet_(data_, 1400, 1234, 1, true) {} |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 bool retransmitted = false; | 491 bool retransmitted = false; |
492 EXPECT_EQ(kCompleteSession, | 492 EXPECT_EQ(kCompleteSession, |
493 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 493 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
494 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 494 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
495 CheckOutFrame(frame_out, size_, false); | 495 CheckOutFrame(frame_out, size_, false); |
496 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 496 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
497 jitter_buffer_->ReleaseFrame(frame_out); | 497 jitter_buffer_->ReleaseFrame(frame_out); |
498 } | 498 } |
499 | 499 |
500 TEST_P(TestBasicJitterBuffer, VerifyHistogramStats) { | 500 TEST_P(TestBasicJitterBuffer, VerifyHistogramStats) { |
501 test::ClearHistograms(); | 501 metrics::Reset(); |
502 // Always start with a complete key frame when not allowing errors. | 502 // Always start with a complete key frame when not allowing errors. |
503 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 503 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
504 packet_->frameType = kVideoFrameKey; | 504 packet_->frameType = kVideoFrameKey; |
505 packet_->isFirstPacket = true; | 505 packet_->isFirstPacket = true; |
506 packet_->markerBit = true; | 506 packet_->markerBit = true; |
507 packet_->timestamp += 123 * 90; | 507 packet_->timestamp += 123 * 90; |
508 | 508 |
509 // Insert single packet frame to the jitter buffer and get a frame. | 509 // Insert single packet frame to the jitter buffer and get a frame. |
510 bool retransmitted = false; | 510 bool retransmitted = false; |
511 EXPECT_EQ(kCompleteSession, | 511 EXPECT_EQ(kCompleteSession, |
512 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 512 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
513 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 513 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
514 CheckOutFrame(frame_out, size_, false); | 514 CheckOutFrame(frame_out, size_, false); |
515 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 515 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
516 jitter_buffer_->ReleaseFrame(frame_out); | 516 jitter_buffer_->ReleaseFrame(frame_out); |
517 | 517 |
518 // Verify that histograms are updated when the jitter buffer is stopped. | 518 // Verify that histograms are updated when the jitter buffer is stopped. |
519 clock_->AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); | 519 clock_->AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); |
520 jitter_buffer_->Stop(); | 520 jitter_buffer_->Stop(); |
| 521 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.DiscardedPacketsInPercent", 0)); |
| 522 EXPECT_EQ(1, |
| 523 metrics::NumEvents("WebRTC.Video.DuplicatedPacketsInPercent", 0)); |
521 EXPECT_EQ( | 524 EXPECT_EQ( |
522 0, test::LastHistogramSample("WebRTC.Video.DiscardedPacketsInPercent")); | 525 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond")); |
523 EXPECT_EQ( | 526 EXPECT_EQ( |
524 0, test::LastHistogramSample("WebRTC.Video.DuplicatedPacketsInPercent")); | 527 1, metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 1000)); |
525 EXPECT_NE(-1, test::LastHistogramSample( | |
526 "WebRTC.Video.CompleteFramesReceivedPerSecond")); | |
527 EXPECT_EQ(1000, test::LastHistogramSample( | |
528 "WebRTC.Video.KeyFramesReceivedInPermille")); | |
529 | 528 |
530 // Verify that histograms are not updated if stop is called again. | 529 // Verify that histograms are not updated if stop is called again. |
531 jitter_buffer_->Stop(); | 530 jitter_buffer_->Stop(); |
| 531 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DiscardedPacketsInPercent")); |
| 532 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DuplicatedPacketsInPercent")); |
532 EXPECT_EQ( | 533 EXPECT_EQ( |
533 1, test::NumHistogramSamples("WebRTC.Video.DiscardedPacketsInPercent")); | 534 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond")); |
534 EXPECT_EQ( | 535 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
535 1, test::NumHistogramSamples("WebRTC.Video.DuplicatedPacketsInPercent")); | |
536 EXPECT_EQ(1, test::NumHistogramSamples( | |
537 "WebRTC.Video.CompleteFramesReceivedPerSecond")); | |
538 EXPECT_EQ( | |
539 1, test::NumHistogramSamples("WebRTC.Video.KeyFramesReceivedInPermille")); | |
540 } | 536 } |
541 | 537 |
542 TEST_P(TestBasicJitterBuffer, DualPacketFrame) { | 538 TEST_P(TestBasicJitterBuffer, DualPacketFrame) { |
543 packet_->frameType = kVideoFrameKey; | 539 packet_->frameType = kVideoFrameKey; |
544 packet_->isFirstPacket = true; | 540 packet_->isFirstPacket = true; |
545 packet_->markerBit = false; | 541 packet_->markerBit = false; |
546 | 542 |
547 bool retransmitted = false; | 543 bool retransmitted = false; |
548 EXPECT_EQ(kIncomplete, | 544 EXPECT_EQ(kIncomplete, |
549 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 545 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 | 2659 |
2664 // Stream should be decodable from this point. | 2660 // Stream should be decodable from this point. |
2665 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2661 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2666 InsertFrame(kVideoFrameDelta); | 2662 InsertFrame(kVideoFrameDelta); |
2667 EXPECT_TRUE(DecodeCompleteFrame()); | 2663 EXPECT_TRUE(DecodeCompleteFrame()); |
2668 nack_list = jitter_buffer_->GetNackList(&extended); | 2664 nack_list = jitter_buffer_->GetNackList(&extended); |
2669 EXPECT_EQ(0u, nack_list.size()); | 2665 EXPECT_EQ(0u, nack_list.size()); |
2670 } | 2666 } |
2671 | 2667 |
2672 } // namespace webrtc | 2668 } // namespace webrtc |
OLD | NEW |