mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00

There's been reports of dropped frames that are not counted and correctly reported by getStats(). If a HW decoder is used and the system is provoked by stressing the system, I've been able to reproduce this problem. It turns out that we've missed frames that are dropped because there is no callback to the Decoded() function. This CL restructures the code so that dropped frames are counted even in cases where there's no corresponding callback for some frames. Bug: webrtc:11229 Change-Id: I0216edba3733399c188649908d459ee86a9093d0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214783 Commit-Queue: Johannes Kron <kron@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33671}
121 lines
4.2 KiB
C++
121 lines
4.2 KiB
C++
/*
|
|
* Copyright (c) 2021 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.
|
|
*/
|
|
|
|
#include "modules/video_coding/timestamp_map.h"
|
|
|
|
#include "test/gmock.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
namespace video_coding {
|
|
namespace {
|
|
constexpr int kTimestampMapSize = 6;
|
|
constexpr int kTimestamp1 = 1;
|
|
constexpr int kTimestamp2 = 2;
|
|
constexpr int kNoExistingTimestamp3 = 3;
|
|
constexpr int kTimestamp4 = 4;
|
|
constexpr int kTimestamp5 = 5;
|
|
constexpr int kTimestamp6 = 6;
|
|
constexpr int kTimestamp7 = 7;
|
|
constexpr int64_t kRenderTime1 = 1000;
|
|
constexpr int64_t kRenderTime2 = 2000;
|
|
constexpr int64_t kRenderTime4 = 4000;
|
|
constexpr int64_t kRenderTime5 = 5000;
|
|
constexpr int64_t kRenderTime6 = 6000;
|
|
constexpr int64_t kRenderTime7 = 7000;
|
|
} // namespace
|
|
|
|
class VcmTimestampMapTest : public ::testing::Test {
|
|
protected:
|
|
VcmTimestampMapTest() : _timestampMap(kTimestampMapSize) {}
|
|
|
|
void SetUp() override {
|
|
_timestampMap.Add(kTimestamp1, VCMFrameInformation({kRenderTime1}));
|
|
_timestampMap.Add(kTimestamp2, VCMFrameInformation({kRenderTime2}));
|
|
_timestampMap.Add(kTimestamp4, VCMFrameInformation({kRenderTime4}));
|
|
}
|
|
|
|
VCMTimestampMap _timestampMap;
|
|
};
|
|
|
|
TEST_F(VcmTimestampMapTest, PopExistingFrameInfo) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
auto frameInfo = _timestampMap.Pop(kTimestamp1);
|
|
ASSERT_TRUE(frameInfo);
|
|
EXPECT_EQ(frameInfo->renderTimeMs, kRenderTime1);
|
|
frameInfo = _timestampMap.Pop(kTimestamp2);
|
|
ASSERT_TRUE(frameInfo);
|
|
EXPECT_EQ(frameInfo->renderTimeMs, kRenderTime2);
|
|
frameInfo = _timestampMap.Pop(kTimestamp4);
|
|
ASSERT_TRUE(frameInfo);
|
|
EXPECT_EQ(frameInfo->renderTimeMs, kRenderTime4);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, PopNonexistingClearsOlderFrameInfos) {
|
|
auto frameInfo = _timestampMap.Pop(kNoExistingTimestamp3);
|
|
EXPECT_FALSE(frameInfo);
|
|
EXPECT_EQ(_timestampMap.Size(), 1u);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, SizeIsIncrementedWhenAddingNewFrameInfo) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
_timestampMap.Add(kTimestamp5, VCMFrameInformation({kRenderTime5}));
|
|
EXPECT_EQ(_timestampMap.Size(), 4u);
|
|
_timestampMap.Add(kTimestamp6, VCMFrameInformation({kRenderTime6}));
|
|
EXPECT_EQ(_timestampMap.Size(), 5u);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, SizeIsDecreasedWhenPoppingFrameInfo) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp1));
|
|
EXPECT_EQ(_timestampMap.Size(), 2u);
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp2));
|
|
EXPECT_EQ(_timestampMap.Size(), 1u);
|
|
EXPECT_FALSE(_timestampMap.Pop(kNoExistingTimestamp3));
|
|
EXPECT_EQ(_timestampMap.Size(), 1u);
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp4));
|
|
EXPECT_EQ(_timestampMap.Size(), 0u);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, ClearEmptiesMap) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
_timestampMap.Clear();
|
|
EXPECT_EQ(_timestampMap.Size(), 0u);
|
|
// Clear empty map does nothing.
|
|
_timestampMap.Clear();
|
|
EXPECT_EQ(_timestampMap.Size(), 0u);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, PopLastAddedClearsMap) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp4));
|
|
EXPECT_EQ(_timestampMap.Size(), 0u);
|
|
}
|
|
|
|
TEST_F(VcmTimestampMapTest, LastAddedIsDiscardedIfMapGetsFull) {
|
|
EXPECT_EQ(_timestampMap.Size(), 3u);
|
|
_timestampMap.Add(kTimestamp5, VCMFrameInformation({kRenderTime5}));
|
|
EXPECT_EQ(_timestampMap.Size(), 4u);
|
|
_timestampMap.Add(kTimestamp6, VCMFrameInformation({kRenderTime6}));
|
|
EXPECT_EQ(_timestampMap.Size(), 5u);
|
|
_timestampMap.Add(kTimestamp7, VCMFrameInformation({kRenderTime7}));
|
|
// Size is not incremented since the oldest element is discarded.
|
|
EXPECT_EQ(_timestampMap.Size(), 5u);
|
|
EXPECT_FALSE(_timestampMap.Pop(kTimestamp1));
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp2));
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp4));
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp5));
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp6));
|
|
EXPECT_TRUE(_timestampMap.Pop(kTimestamp7));
|
|
EXPECT_EQ(_timestampMap.Size(), 0u);
|
|
}
|
|
|
|
} // namespace video_coding
|
|
} // namespace webrtc
|