webrtc_m130/test/scenario/quality_stats.h
Danil Chapovalov d26a916a80 Avoid using GlobalTaskQueueFactory for TaskQueueForTest
To remove global task factory, rtc::TaskQueue need to loose it's convenient constructor
TaskQueueForTest can be used instead in tests and keep the convenient constructor.

Also cleanup the TaskQueueForTest a bit:
move the class to webrtc namespace
add default constructor
disallow copy using language construct instead of macro
cleanup build dependencies
rename build target (to match move out of the rtc namespace)

Bug: webrtc:10284
Change-Id: I17fddf3f8d4f363df7d495c28a5b0a28abda1ba7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127571
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27193}
2019-03-19 18:11:52 +00:00

109 lines
3.4 KiB
C++

/*
* Copyright 2018 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 TEST_SCENARIO_QUALITY_STATS_H_
#define TEST_SCENARIO_QUALITY_STATS_H_
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "api/units/timestamp.h"
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/clock.h"
#include "test/logging/log_writer.h"
#include "test/scenario/quality_info.h"
#include "test/scenario/scenario_config.h"
#include "test/statistics.h"
namespace webrtc {
namespace test {
class VideoQualityAnalyzer {
public:
VideoQualityAnalyzer(
std::unique_ptr<RtcEventLogOutput> writer,
std::function<void(const VideoFrameQualityInfo&)> frame_info_handler);
~VideoQualityAnalyzer();
void OnCapturedFrame(const VideoFrame& frame);
void OnDecodedFrame(const VideoFrame& frame);
void Synchronize();
bool Active() const;
Clock* clock();
private:
void PrintHeaders();
void PrintFrameInfo(const VideoFrameQualityInfo& sample);
const std::unique_ptr<RtcEventLogOutput> writer_;
std::vector<std::function<void(const VideoFrameQualityInfo&)>>
frame_info_handlers_;
std::deque<VideoFrame> captured_frames_;
TaskQueueForTest task_queue_;
};
struct VideoQualityStats {
int total = 0;
int valid = 0;
int lost = 0;
Statistics end_to_end_seconds;
Statistics frame_size;
Statistics psnr;
Statistics ssim;
void HandleFrameInfo(VideoFrameQualityInfo sample);
};
class ForwardingCapturedFrameTap
: public rtc::VideoSinkInterface<VideoFrame>,
public rtc::VideoSourceInterface<VideoFrame> {
public:
ForwardingCapturedFrameTap(Clock* clock,
VideoQualityAnalyzer* analyzer,
rtc::VideoSourceInterface<VideoFrame>* source);
ForwardingCapturedFrameTap(ForwardingCapturedFrameTap&) = delete;
ForwardingCapturedFrameTap& operator=(ForwardingCapturedFrameTap&) = delete;
~ForwardingCapturedFrameTap();
// VideoSinkInterface interface
void OnFrame(const VideoFrame& frame) override;
void OnDiscardedFrame() override;
// VideoSourceInterface interface
void AddOrUpdateSink(VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override;
void RemoveSink(VideoSinkInterface<VideoFrame>* sink) override;
VideoFrame PopFrame();
private:
Clock* const clock_;
VideoQualityAnalyzer* const analyzer_;
rtc::VideoSourceInterface<VideoFrame>* const source_;
VideoSinkInterface<VideoFrame>* sink_;
int discarded_count_ = 0;
};
class DecodedFrameTap : public rtc::VideoSinkInterface<VideoFrame> {
public:
explicit DecodedFrameTap(VideoQualityAnalyzer* analyzer);
// VideoSinkInterface interface
void OnFrame(const VideoFrame& frame) override;
private:
VideoQualityAnalyzer* const analyzer_;
};
} // namespace test
} // namespace webrtc
#endif // TEST_SCENARIO_QUALITY_STATS_H_