Add end-to-end test for ColorSpace information
Bug: webrtc:8651
Change-Id: Ib7f6162c8dd41868b7d7acca8a6292b2d911c520
Reviewed-on: https://webrtc-review.googlesource.com/c/113941
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25992}
diff --git a/test/call_test.cc b/test/call_test.cc
index 6e25b85..5d2bbca 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -31,10 +31,6 @@
namespace webrtc {
namespace test {
-namespace {
-const int kVideoRotationRtpExtensionId = 4;
-}
-
CallTest::CallTest()
: clock_(Clock::GetRealTimeClock()),
send_event_log_(RtcEventLog::CreateNull()),
@@ -240,6 +236,7 @@
bitrate_allocator_factory_.get();
video_config->rtp.payload_name = "FAKE";
video_config->rtp.payload_type = kFakeVideoSendPayloadType;
+ video_config->rtp.extmap_allow_mixed = true;
video_config->rtp.extensions.push_back(
RtpExtension(RtpExtension::kTransportSequenceNumberUri,
kTransportSequenceNumberExtensionId));
@@ -255,8 +252,10 @@
for (size_t i = 0; i < num_video_streams; ++i)
video_config->rtp.ssrcs.push_back(kVideoSendSsrcs[num_used_ssrcs + i]);
- video_config->rtp.extensions.push_back(RtpExtension(
- RtpExtension::kVideoRotationUri, kVideoRotationRtpExtensionId));
+ video_config->rtp.extensions.push_back(
+ RtpExtension(RtpExtension::kVideoRotationUri, kVideoRotationExtensionId));
+ video_config->rtp.extensions.push_back(
+ RtpExtension(RtpExtension::kColorSpaceUri, kColorSpaceExtensionId));
}
void CallTest::CreateAudioAndFecSendConfigs(size_t num_audio_streams,
diff --git a/test/constants.cc b/test/constants.cc
index 12ae8e8..4f33d25 100644
--- a/test/constants.cc
+++ b/test/constants.cc
@@ -21,6 +21,7 @@
const int kVideoContentTypeExtensionId = 10;
const int kVideoTimingExtensionId = 11;
const int kGenericDescriptorExtensionId = 12;
+const int kColorSpaceExtensionId = 13;
} // namespace test
} // namespace webrtc
diff --git a/test/constants.h b/test/constants.h
index 3cee828..b1b87d6 100644
--- a/test/constants.h
+++ b/test/constants.h
@@ -19,5 +19,6 @@
extern const int kVideoContentTypeExtensionId;
extern const int kVideoTimingExtensionId;
extern const int kGenericDescriptorExtensionId;
+extern const int kColorSpaceExtensionId;
} // namespace test
} // namespace webrtc
diff --git a/test/frame_generator.h b/test/frame_generator.h
index a92c3b4..45cc9f0 100644
--- a/test/frame_generator.h
+++ b/test/frame_generator.h
@@ -50,6 +50,9 @@
virtual ~FrameGenerator() = default;
// Returns video frame that remains valid until next call.
+ // TODO(kron): Return rtc::scoped_refptr<VideoFrameBuffer> instead of
+ // VideoFrame* and populate the VideoFrame struct in FrameGeneratorCapturer
+ // using VideoFrame::Builder.
virtual VideoFrame* NextFrame() = 0;
// Change the capture resolution.
diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc
index 8729187..6ca1ddb 100644
--- a/test/frame_generator_capturer.cc
+++ b/test/frame_generator_capturer.cc
@@ -147,6 +147,12 @@
fake_rotation_ = rotation;
}
+void FrameGeneratorCapturer::SetFakeColorSpace(
+ absl::optional<ColorSpace> color_space) {
+ rtc::CritScope cs(&lock_);
+ fake_color_space_ = color_space;
+}
+
bool FrameGeneratorCapturer::Init() {
// This check is added because frame_generator_ might be file based and should
// not crash because a file moved.
@@ -173,6 +179,9 @@
frame->set_timestamp_us(clock_->TimeInMicroseconds());
frame->set_ntp_time_ms(clock_->CurrentNtpInMilliseconds());
frame->set_rotation(fake_rotation_);
+ if (fake_color_space_) {
+ frame->set_color_space(&fake_color_space_.value());
+ }
if (first_frame_capture_time_ == -1) {
first_frame_capture_time_ = frame->ntp_time_ms();
}
diff --git a/test/frame_generator_capturer.h b/test/frame_generator_capturer.h
index 6b2ed69..a5e60a5 100644
--- a/test/frame_generator_capturer.h
+++ b/test/frame_generator_capturer.h
@@ -74,6 +74,7 @@
void ForceFrame();
void SetFakeRotation(VideoRotation rotation);
+ void SetFakeColorSpace(absl::optional<ColorSpace> color_space);
int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
@@ -101,6 +102,7 @@
int target_capture_fps_ RTC_GUARDED_BY(&lock_);
absl::optional<int> wanted_fps_ RTC_GUARDED_BY(&lock_);
VideoRotation fake_rotation_ = kVideoRotation_0;
+ absl::optional<ColorSpace> fake_color_space_ RTC_GUARDED_BY(&lock_);
int64_t first_frame_capture_time_;
// Must be the last field, so it will be deconstructed first as tasks