diff --git a/api/test/video/test_video_track_source.cc b/api/test/video/test_video_track_source.cc index a7ec448a7f..56d70d1774 100644 --- a/api/test/video/test_video_track_source.cc +++ b/api/test/video/test_video_track_source.cc @@ -9,6 +9,9 @@ */ #include "api/test/video/test_video_track_source.h" +#include + +#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/sequence_checker.h" #include "api/video/video_frame.h" @@ -19,8 +22,12 @@ namespace webrtc { namespace test { -TestVideoTrackSource::TestVideoTrackSource(bool remote) - : state_(kInitializing), remote_(remote) { +TestVideoTrackSource::TestVideoTrackSource( + bool remote, + absl::optional stream_label) + : stream_label_(std::move(stream_label)), + state_(kInitializing), + remote_(remote) { worker_thread_checker_.Detach(); signaling_thread_checker_.Detach(); } diff --git a/api/test/video/test_video_track_source.h b/api/test/video/test_video_track_source.h index 449228f81c..173bb64e58 100644 --- a/api/test/video/test_video_track_source.h +++ b/api/test/video/test_video_track_source.h @@ -11,6 +11,8 @@ #ifndef API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_ #define API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_ +#include + #include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/notifier.h" @@ -28,7 +30,9 @@ namespace test { // Video source that can be used as input for tests. class TestVideoTrackSource : public Notifier { public: - explicit TestVideoTrackSource(bool remote); + explicit TestVideoTrackSource( + bool remote, + absl::optional stream_label = absl::nullopt); ~TestVideoTrackSource() override = default; void SetState(SourceState new_state); @@ -72,10 +76,15 @@ class TestVideoTrackSource : public Notifier { int height, const absl::optional& max_fps) {} + // Returns stream label for this video source if present. Implementations + // may override this method to increase debugability and testability. + virtual absl::optional GetStreamLabel() { return stream_label_; } + protected: virtual rtc::VideoSourceInterface* source() = 0; private: + const absl::optional stream_label_; RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_; RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_; SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_); diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index ebe4d9b08c..75db40eef5 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -130,6 +130,7 @@ if (!build_with_chromium) { "../../../api/test/video:test_video_track_source", "../../../api/video:video_frame", ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("media_helper") { diff --git a/test/pc/e2e/media/media_helper.cc b/test/pc/e2e/media/media_helper.cc index d14dcdd908..35eae68334 100644 --- a/test/pc/e2e/media/media_helper.cc +++ b/test/pc/e2e/media/media_helper.cc @@ -59,7 +59,7 @@ MediaHelper::MaybeAddVideo(TestPeer* peer) { VideoTrackInterface::ContentHint::kDetailed; rtc::scoped_refptr source = rtc::make_ref_counted( - std::move(capturer), is_screencast); + std::move(capturer), is_screencast, video_config.stream_label); out.push_back(source); RTC_LOG(LS_INFO) << "Adding video with video_config.stream_label=" << video_config.stream_label.value(); diff --git a/test/pc/e2e/media/test_video_capturer_video_track_source.h b/test/pc/e2e/media/test_video_capturer_video_track_source.h index 846721d864..abcdc6c716 100644 --- a/test/pc/e2e/media/test_video_capturer_video_track_source.h +++ b/test/pc/e2e/media/test_video_capturer_video_track_source.h @@ -14,6 +14,7 @@ #include #include +#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "api/test/video/test_video_track_source.h" #include "api/video/video_frame.h" @@ -27,8 +28,9 @@ class TestVideoCapturerVideoTrackSource : public test::TestVideoTrackSource { public: TestVideoCapturerVideoTrackSource( std::unique_ptr video_capturer, - bool is_screencast) - : TestVideoTrackSource(/*remote=*/false), + bool is_screencast, + absl::optional stream_label = absl::nullopt) + : TestVideoTrackSource(/*remote=*/false, std::move(stream_label)), video_capturer_(std::move(video_capturer)), is_screencast_(is_screencast) { sequence_checker_.Detach();