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

This CL introduces VideoCodecStats and VideoCodecStatsImpl which provide baseline functionalities for storing, slicing and aggregation of encoded and/or decoded video frame statistics. To facilitate metrics logging (not implemented yet), SamplesStatsCounter is used for stream parameters. VideoCodecStats/VideoCodecStatsImpl will replace existing VideoCodecTestStats/VideoCodecTestStatsImpl. Bug: b/261160916, webrtc:14852 Change-Id: I0f96ce1ed9be3aee2a702804612524676c9882fd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291323 Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39248}
77 lines
2.3 KiB
C++
77 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2023 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.
|
|
*/
|
|
|
|
#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_
|
|
#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/test/video_codec_stats.h"
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
// Implementation of `VideoCodecStats`. This class is not thread-safe.
|
|
class VideoCodecStatsImpl : public VideoCodecStats {
|
|
public:
|
|
std::vector<Frame> Slice(
|
|
absl::optional<Filter> filter = absl::nullopt) const override;
|
|
|
|
Stream Aggregate(
|
|
const std::vector<Frame>& frames,
|
|
absl::optional<DataRate> bitrate = absl::nullopt,
|
|
absl::optional<Frequency> framerate = absl::nullopt) const override;
|
|
|
|
void LogMetrics(MetricsLogger* logger,
|
|
const Stream& stream,
|
|
std::string test_case_name) const override;
|
|
|
|
// Creates new frame, caches it and returns raw pointer to it.
|
|
Frame* AddFrame(int frame_num, uint32_t timestamp_rtp, int spatial_idx);
|
|
|
|
// Returns raw pointers to requested frame. If frame does not exist, returns
|
|
// `nullptr`.
|
|
Frame* GetFrame(uint32_t timestamp_rtp, int spatial_idx);
|
|
|
|
private:
|
|
struct FrameId {
|
|
int frame_num;
|
|
int spatial_idx;
|
|
|
|
bool operator==(const FrameId& o) const {
|
|
return frame_num == o.frame_num && spatial_idx == o.spatial_idx;
|
|
}
|
|
|
|
bool operator<(const FrameId& o) const {
|
|
if (frame_num < o.frame_num)
|
|
return true;
|
|
if (spatial_idx < o.spatial_idx)
|
|
return true;
|
|
return false;
|
|
}
|
|
};
|
|
|
|
// Merges frame stats from different spatial layers and returns vector of
|
|
// superframes.
|
|
std::vector<Frame> Merge(const std::vector<Frame>& frames) const;
|
|
|
|
// Map from RTP timestamp to frame number (`Frame::frame_num`).
|
|
std::map<uint32_t, int> frame_num_;
|
|
|
|
std::map<FrameId, Frame> frames_;
|
|
};
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_
|