2011-10-06 06:44:54 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2011-12-08 07:42:18 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/codecs/test/stats.h"
|
2011-12-08 07:42:18 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/gtest.h"
|
2011-10-06 06:44:54 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
2018-01-19 14:57:10 +01:00
|
|
|
namespace {
|
|
|
|
|
const size_t kTimestamp = 12345;
|
|
|
|
|
} // namespace
|
2011-10-06 06:44:54 +00:00
|
|
|
|
2018-01-19 14:57:10 +01:00
|
|
|
TEST(StatsTest, AddFrame) {
|
2017-06-04 23:43:41 -07:00
|
|
|
Stats stats;
|
2018-02-20 09:48:26 +01:00
|
|
|
FrameStatistics* frame_stat = stats.AddFrame(kTimestamp, 0);
|
2018-01-17 15:11:44 +01:00
|
|
|
EXPECT_EQ(0ull, frame_stat->frame_number);
|
2018-01-19 14:57:10 +01:00
|
|
|
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp);
|
2018-02-20 09:48:26 +01:00
|
|
|
EXPECT_EQ(1u, stats.Size(0));
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-19 14:57:10 +01:00
|
|
|
TEST(StatsTest, GetFrame) {
|
|
|
|
|
Stats stats;
|
2018-02-20 09:48:26 +01:00
|
|
|
stats.AddFrame(kTimestamp, 0);
|
|
|
|
|
FrameStatistics* frame_stat = stats.GetFrame(0u, 0);
|
2018-01-19 14:57:10 +01:00
|
|
|
EXPECT_EQ(0u, frame_stat->frame_number);
|
|
|
|
|
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(StatsTest, AddFrames) {
|
2017-06-04 23:43:41 -07:00
|
|
|
Stats stats;
|
2018-01-17 15:11:44 +01:00
|
|
|
const size_t kNumFrames = 1000;
|
|
|
|
|
for (size_t i = 0; i < kNumFrames; ++i) {
|
2018-02-20 09:48:26 +01:00
|
|
|
FrameStatistics* frame_stat = stats.AddFrame(kTimestamp + i, 0);
|
2017-09-06 01:53:22 -07:00
|
|
|
EXPECT_EQ(i, frame_stat->frame_number);
|
2018-01-19 14:57:10 +01:00
|
|
|
EXPECT_EQ(kTimestamp + i, frame_stat->rtp_timestamp);
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
2018-02-20 09:48:26 +01:00
|
|
|
EXPECT_EQ(kNumFrames, stats.Size(0));
|
2018-01-19 14:57:10 +01:00
|
|
|
// Get frame.
|
|
|
|
|
size_t i = 22;
|
2018-02-20 09:48:26 +01:00
|
|
|
FrameStatistics* frame_stat = stats.GetFrameWithTimestamp(kTimestamp + i, 0);
|
2018-01-19 14:57:10 +01:00
|
|
|
EXPECT_EQ(i, frame_stat->frame_number);
|
|
|
|
|
EXPECT_EQ(kTimestamp + i, frame_stat->rtp_timestamp);
|
2011-10-06 06:44:54 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-20 09:48:26 +01:00
|
|
|
TEST(StatsTest, AddFrameLayering) {
|
|
|
|
|
Stats stats;
|
|
|
|
|
for (size_t i = 0; i < 3; ++i) {
|
|
|
|
|
stats.AddFrame(kTimestamp + i, i);
|
|
|
|
|
FrameStatistics* frame_stat = stats.GetFrame(0u, i);
|
|
|
|
|
EXPECT_EQ(0u, frame_stat->frame_number);
|
|
|
|
|
EXPECT_EQ(kTimestamp, frame_stat->rtp_timestamp - i);
|
|
|
|
|
EXPECT_EQ(1u, stats.Size(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-06 06:44:54 +00:00
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|