Skip to content

Commit 8b18304

Browse files
titov-artemWebRTC LUCI CQ
authored andcommitted
Extract internal DVQA shared objects for future split
Bug: b/196229820 Change-Id: I6bb4be2656d1686a5f30721378605b39d5c391ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228522 Reviewed-by: Mirko Bonadei <[email protected]> Commit-Queue: Artem Titov <[email protected]> Cr-Commit-Position: refs/heads/master@{#34737}
1 parent a17ec76 commit 8b18304

7 files changed

+210
-122
lines changed

test/pc/e2e/BUILD.gn

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ if (!build_with_chromium) {
444444
deps = [
445445
":default_audio_quality_analyzer",
446446
":default_video_quality_analyzer",
447+
":default_video_quality_analyzer_shared",
447448
":network_quality_metrics_reporter",
448449
":stats_based_network_quality_metrics_reporter",
449450
"../../../api:callfactory_api",
@@ -502,6 +503,7 @@ if (!build_with_chromium) {
502503
sources = [ "analyzer/video/default_video_quality_analyzer_test.cc" ]
503504
deps = [
504505
":default_video_quality_analyzer",
506+
":default_video_quality_analyzer_shared",
505507
"../..:test_support",
506508
"../../../api:create_frame_generator",
507509
"../../../api:rtp_packet_info",
@@ -617,11 +619,11 @@ if (!build_with_chromium) {
617619
sources = [
618620
"analyzer/video/default_video_quality_analyzer.cc",
619621
"analyzer/video/default_video_quality_analyzer.h",
620-
"analyzer/video/default_video_quality_analyzer_shared_objects.cc",
621-
"analyzer/video/default_video_quality_analyzer_shared_objects.h",
622622
]
623623

624624
deps = [
625+
":default_video_quality_analyzer_internal",
626+
":default_video_quality_analyzer_shared",
625627
":multi_head_queue",
626628
"../..:perf_test",
627629
"../../../api:array_view",
@@ -645,6 +647,46 @@ if (!build_with_chromium) {
645647
"../../../rtc_tools:video_quality_analysis",
646648
"../../../system_wrappers",
647649
]
650+
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
651+
}
652+
653+
# This target contains implementation details of DefaultVideoQualityAnalyzer,
654+
# so headers exported by it shouldn't be used in other places.
655+
rtc_library("default_video_quality_analyzer_internal") {
656+
visibility = [ ":default_video_quality_analyzer" ]
657+
658+
testonly = true
659+
sources = [
660+
"analyzer/video/default_video_quality_analyzer_internal_shared_objects.cc",
661+
"analyzer/video/default_video_quality_analyzer_internal_shared_objects.h",
662+
]
663+
664+
deps = [
665+
":default_video_quality_analyzer_shared",
666+
"../../../api/numerics:numerics",
667+
"../../../api/units:timestamp",
668+
"../../../api/video:video_frame",
669+
"../../../rtc_base:stringutils",
670+
]
671+
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
672+
}
673+
674+
rtc_library("default_video_quality_analyzer_shared") {
675+
visibility = [ "*" ]
676+
677+
testonly = true
678+
sources = [
679+
"analyzer/video/default_video_quality_analyzer_shared_objects.cc",
680+
"analyzer/video/default_video_quality_analyzer_shared_objects.h",
681+
]
682+
683+
deps = [
684+
"../../../api/numerics:numerics",
685+
"../../../api/units:timestamp",
686+
"../../../rtc_base:checks",
687+
"../../../rtc_base:stringutils",
688+
]
689+
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
648690
}
649691

650692
rtc_library("network_quality_metrics_reporter") {

test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "rtc_base/strings/string_builder.h"
2626
#include "rtc_base/time_utils.h"
2727
#include "rtc_tools/frame_analyzer/video_geometry_aligner.h"
28+
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_internal_shared_objects.h"
2829
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h"
2930

3031
namespace webrtc {
@@ -1027,20 +1028,6 @@ double DefaultVideoQualityAnalyzer::GetCpuUsagePercent() {
10271028
return static_cast<double>(cpu_time_) / wallclock_time_ * 100.0;
10281029
}
10291030

1030-
DefaultVideoQualityAnalyzer::FrameComparison::FrameComparison(
1031-
InternalStatsKey stats_key,
1032-
absl::optional<VideoFrame> captured,
1033-
absl::optional<VideoFrame> rendered,
1034-
bool dropped,
1035-
FrameStats frame_stats,
1036-
OverloadReason overload_reason)
1037-
: stats_key(std::move(stats_key)),
1038-
captured(std::move(captured)),
1039-
rendered(std::move(rendered)),
1040-
dropped(dropped),
1041-
frame_stats(std::move(frame_stats)),
1042-
overload_reason(overload_reason) {}
1043-
10441031
uint16_t DefaultVideoQualityAnalyzer::StreamState::PopFront(size_t peer) {
10451032
absl::optional<uint16_t> frame_id = frame_ids_.PopFront(peer);
10461033
RTC_DCHECK(frame_id.has_value());
@@ -1217,8 +1204,8 @@ bool DefaultVideoQualityAnalyzer::FrameInFlight::HasRenderedTime(
12171204
return it->second.rendered_time.IsFinite();
12181205
}
12191206

1220-
DefaultVideoQualityAnalyzer::FrameStats
1221-
DefaultVideoQualityAnalyzer::FrameInFlight::GetStatsForPeer(size_t peer) const {
1207+
FrameStats DefaultVideoQualityAnalyzer::FrameInFlight::GetStatsForPeer(
1208+
size_t peer) const {
12221209
FrameStats stats(captured_time_);
12231210
stats.pre_encode_time = pre_encode_time_;
12241211
stats.encoded_time = encoded_time_;

test/pc/e2e/analyzer/video/default_video_quality_analyzer.h

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "rtc_base/platform_thread.h"
3030
#include "rtc_base/synchronization/mutex.h"
3131
#include "system_wrappers/include/clock.h"
32+
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_internal_shared_objects.h"
3233
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h"
3334
#include "test/pc/e2e/analyzer/video/multi_head_queue.h"
3435
#include "test/testsupport/perf_test.h"
@@ -113,73 +114,6 @@ class DefaultVideoQualityAnalyzer : public VideoQualityAnalyzerInterface {
113114
double GetCpuUsagePercent();
114115

115116
private:
116-
// Final stats computed for frame after it went through the whole video
117-
// pipeline from capturing to rendering or dropping.
118-
struct FrameStats {
119-
FrameStats(Timestamp captured_time) : captured_time(captured_time) {}
120-
121-
// Frame events timestamp.
122-
Timestamp captured_time;
123-
Timestamp pre_encode_time = Timestamp::MinusInfinity();
124-
Timestamp encoded_time = Timestamp::MinusInfinity();
125-
// Time when last packet of a frame was received.
126-
Timestamp received_time = Timestamp::MinusInfinity();
127-
Timestamp decode_start_time = Timestamp::MinusInfinity();
128-
Timestamp decode_end_time = Timestamp::MinusInfinity();
129-
Timestamp rendered_time = Timestamp::MinusInfinity();
130-
Timestamp prev_frame_rendered_time = Timestamp::MinusInfinity();
131-
132-
int64_t encoded_image_size = 0;
133-
uint32_t target_encode_bitrate = 0;
134-
135-
absl::optional<int> rendered_frame_width = absl::nullopt;
136-
absl::optional<int> rendered_frame_height = absl::nullopt;
137-
138-
// Can be not set if frame was dropped by encoder.
139-
absl::optional<StreamCodecInfo> used_encoder = absl::nullopt;
140-
// Can be not set if frame was dropped in the network.
141-
absl::optional<StreamCodecInfo> used_decoder = absl::nullopt;
142-
};
143-
144-
// Describes why comparison was done in overloaded mode (without calculating
145-
// PSNR and SSIM).
146-
enum class OverloadReason {
147-
kNone,
148-
// Not enough CPU to process all incoming comparisons.
149-
kCpu,
150-
// Not enough memory to store captured frames for all comparisons.
151-
kMemory
152-
};
153-
154-
// Represents comparison between two VideoFrames. Contains video frames itself
155-
// and stats. Can be one of two types:
156-
// 1. Normal - in this case `captured` is presented and either `rendered` is
157-
// presented and `dropped` is false, either `rendered` is omitted and
158-
// `dropped` is true.
159-
// 2. Overloaded - in this case both `captured` and `rendered` are omitted
160-
// because there were too many comparisons in the queue. `dropped` can be
161-
// true or false showing was frame dropped or not.
162-
struct FrameComparison {
163-
FrameComparison(InternalStatsKey stats_key,
164-
absl::optional<VideoFrame> captured,
165-
absl::optional<VideoFrame> rendered,
166-
bool dropped,
167-
FrameStats frame_stats,
168-
OverloadReason overload_reason);
169-
170-
InternalStatsKey stats_key;
171-
// Frames can be omitted if there too many computations waiting in the
172-
// queue.
173-
absl::optional<VideoFrame> captured;
174-
absl::optional<VideoFrame> rendered;
175-
// If true frame was dropped somewhere from capturing to rendering and
176-
// wasn't rendered on remote peer side. If `dropped` is true, `rendered`
177-
// will be `absl::nullopt`.
178-
bool dropped;
179-
FrameStats frame_stats;
180-
OverloadReason overload_reason;
181-
};
182-
183117
// Represents a current state of video stream.
184118
class StreamState {
185119
public:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3+
*
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
6+
* tree. An additional intellectual property rights grant can be found
7+
* in the file PATENTS. All contributing project authors may
8+
* be found in the AUTHORS file in the root of the source tree.
9+
*/
10+
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_internal_shared_objects.h"
11+
12+
#include "api/video/video_frame.h"
13+
#include "rtc_base/strings/string_builder.h"
14+
15+
namespace webrtc {
16+
17+
std::string InternalStatsKey::ToString() const {
18+
rtc::StringBuilder out;
19+
out << "stream=" << stream << "_sender=" << sender
20+
<< "_receiver=" << receiver;
21+
return out.str();
22+
}
23+
24+
bool operator<(const InternalStatsKey& a, const InternalStatsKey& b) {
25+
if (a.stream != b.stream) {
26+
return a.stream < b.stream;
27+
}
28+
if (a.sender != b.sender) {
29+
return a.sender < b.sender;
30+
}
31+
return a.receiver < b.receiver;
32+
}
33+
34+
bool operator==(const InternalStatsKey& a, const InternalStatsKey& b) {
35+
return a.stream == b.stream && a.sender == b.sender &&
36+
a.receiver == b.receiver;
37+
}
38+
39+
FrameComparison::FrameComparison(InternalStatsKey stats_key,
40+
absl::optional<VideoFrame> captured,
41+
absl::optional<VideoFrame> rendered,
42+
bool dropped,
43+
FrameStats frame_stats,
44+
OverloadReason overload_reason)
45+
: stats_key(std::move(stats_key)),
46+
captured(std::move(captured)),
47+
rendered(std::move(rendered)),
48+
dropped(dropped),
49+
frame_stats(std::move(frame_stats)),
50+
overload_reason(overload_reason) {}
51+
52+
} // namespace webrtc
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3+
*
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
6+
* tree. An additional intellectual property rights grant can be found
7+
* in the file PATENTS. All contributing project authors may
8+
* be found in the AUTHORS file in the root of the source tree.
9+
*/
10+
11+
#ifndef TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_VIDEO_QUALITY_ANALYZER_INTERNAL_SHARED_OBJECTS_H_
12+
#define TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_VIDEO_QUALITY_ANALYZER_INTERNAL_SHARED_OBJECTS_H_
13+
14+
#include <memory>
15+
#include <string>
16+
#include <utility>
17+
18+
#include "absl/types/optional.h"
19+
#include "api/units/timestamp.h"
20+
#include "api/video/video_frame.h"
21+
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h"
22+
23+
namespace webrtc {
24+
25+
struct InternalStatsKey {
26+
InternalStatsKey(size_t stream, size_t sender, size_t receiver)
27+
: stream(stream), sender(sender), receiver(receiver) {}
28+
29+
std::string ToString() const;
30+
31+
size_t stream;
32+
size_t sender;
33+
size_t receiver;
34+
};
35+
36+
// Required to use InternalStatsKey as std::map key.
37+
bool operator<(const InternalStatsKey& a, const InternalStatsKey& b);
38+
bool operator==(const InternalStatsKey& a, const InternalStatsKey& b);
39+
40+
// Final stats computed for frame after it went through the whole video
41+
// pipeline from capturing to rendering or dropping.
42+
struct FrameStats {
43+
explicit FrameStats(Timestamp captured_time) : captured_time(captured_time) {}
44+
45+
// Frame events timestamp.
46+
Timestamp captured_time;
47+
Timestamp pre_encode_time = Timestamp::MinusInfinity();
48+
Timestamp encoded_time = Timestamp::MinusInfinity();
49+
// Time when last packet of a frame was received.
50+
Timestamp received_time = Timestamp::MinusInfinity();
51+
Timestamp decode_start_time = Timestamp::MinusInfinity();
52+
Timestamp decode_end_time = Timestamp::MinusInfinity();
53+
Timestamp rendered_time = Timestamp::MinusInfinity();
54+
Timestamp prev_frame_rendered_time = Timestamp::MinusInfinity();
55+
56+
int64_t encoded_image_size = 0;
57+
uint32_t target_encode_bitrate = 0;
58+
59+
absl::optional<int> rendered_frame_width = absl::nullopt;
60+
absl::optional<int> rendered_frame_height = absl::nullopt;
61+
62+
// Can be not set if frame was dropped by encoder.
63+
absl::optional<webrtc_pc_e2e::StreamCodecInfo> used_encoder = absl::nullopt;
64+
// Can be not set if frame was dropped in the network.
65+
absl::optional<webrtc_pc_e2e::StreamCodecInfo> used_decoder = absl::nullopt;
66+
};
67+
68+
// Describes why comparison was done in overloaded mode (without calculating
69+
// PSNR and SSIM).
70+
enum class OverloadReason {
71+
kNone,
72+
// Not enough CPU to process all incoming comparisons.
73+
kCpu,
74+
// Not enough memory to store captured frames for all comparisons.
75+
kMemory
76+
};
77+
78+
// Represents comparison between two VideoFrames. Contains video frames itself
79+
// and stats. Can be one of two types:
80+
// 1. Normal - in this case `captured` is presented and either `rendered` is
81+
// presented and `dropped` is false, either `rendered` is omitted and
82+
// `dropped` is true.
83+
// 2. Overloaded - in this case both `captured` and `rendered` are omitted
84+
// because there were too many comparisons in the queue. `dropped` can be
85+
// true or false showing was frame dropped or not.
86+
struct FrameComparison {
87+
FrameComparison(InternalStatsKey stats_key,
88+
absl::optional<VideoFrame> captured,
89+
absl::optional<VideoFrame> rendered,
90+
bool dropped,
91+
FrameStats frame_stats,
92+
OverloadReason overload_reason);
93+
94+
InternalStatsKey stats_key;
95+
// Frames can be omitted if there too many computations waiting in the
96+
// queue.
97+
absl::optional<VideoFrame> captured;
98+
absl::optional<VideoFrame> rendered;
99+
// If true frame was dropped somewhere from capturing to rendering and
100+
// wasn't rendered on remote peer side. If `dropped` is true, `rendered`
101+
// will be `absl::nullopt`.
102+
bool dropped;
103+
FrameStats frame_stats;
104+
OverloadReason overload_reason;
105+
};
106+
107+
} // namespace webrtc
108+
109+
#endif // TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_VIDEO_QUALITY_ANALYZER_INTERNAL_SHARED_OBJECTS_H_

test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.cc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,5 @@ bool operator==(const StatsKey& a, const StatsKey& b) {
5959
a.receiver == b.receiver;
6060
}
6161

62-
std::string InternalStatsKey::ToString() const {
63-
rtc::StringBuilder out;
64-
out << "stream=" << stream << "_sender=" << sender
65-
<< "_receiver=" << receiver;
66-
return out.str();
67-
}
68-
69-
bool operator<(const InternalStatsKey& a, const InternalStatsKey& b) {
70-
if (a.stream != b.stream) {
71-
return a.stream < b.stream;
72-
}
73-
if (a.sender != b.sender) {
74-
return a.sender < b.sender;
75-
}
76-
return a.receiver < b.receiver;
77-
}
78-
79-
bool operator==(const InternalStatsKey& a, const InternalStatsKey& b) {
80-
return a.stream == b.stream && a.sender == b.sender &&
81-
a.receiver == b.receiver;
82-
}
83-
8462
} // namespace webrtc_pc_e2e
8563
} // namespace webrtc

0 commit comments

Comments
 (0)