Add stream label to test video source for better debugablity and testability
Bug: b/294812400 Change-Id: I830515b797100ca2dc0e68dd3b79d5a1bb4068da Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/316221 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40581}
This commit is contained in:
parent
952e0b75f9
commit
1997837d16
@ -9,6 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "api/test/video/test_video_track_source.h"
|
#include "api/test/video/test_video_track_source.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "api/media_stream_interface.h"
|
#include "api/media_stream_interface.h"
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "api/video/video_frame.h"
|
#include "api/video/video_frame.h"
|
||||||
@ -19,8 +22,12 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
TestVideoTrackSource::TestVideoTrackSource(bool remote)
|
TestVideoTrackSource::TestVideoTrackSource(
|
||||||
: state_(kInitializing), remote_(remote) {
|
bool remote,
|
||||||
|
absl::optional<std::string> stream_label)
|
||||||
|
: stream_label_(std::move(stream_label)),
|
||||||
|
state_(kInitializing),
|
||||||
|
remote_(remote) {
|
||||||
worker_thread_checker_.Detach();
|
worker_thread_checker_.Detach();
|
||||||
signaling_thread_checker_.Detach();
|
signaling_thread_checker_.Detach();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
#ifndef API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_
|
#ifndef API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_
|
||||||
#define API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_
|
#define API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "api/media_stream_interface.h"
|
#include "api/media_stream_interface.h"
|
||||||
#include "api/notifier.h"
|
#include "api/notifier.h"
|
||||||
@ -28,7 +30,9 @@ namespace test {
|
|||||||
// Video source that can be used as input for tests.
|
// Video source that can be used as input for tests.
|
||||||
class TestVideoTrackSource : public Notifier<VideoTrackSourceInterface> {
|
class TestVideoTrackSource : public Notifier<VideoTrackSourceInterface> {
|
||||||
public:
|
public:
|
||||||
explicit TestVideoTrackSource(bool remote);
|
explicit TestVideoTrackSource(
|
||||||
|
bool remote,
|
||||||
|
absl::optional<std::string> stream_label = absl::nullopt);
|
||||||
~TestVideoTrackSource() override = default;
|
~TestVideoTrackSource() override = default;
|
||||||
|
|
||||||
void SetState(SourceState new_state);
|
void SetState(SourceState new_state);
|
||||||
@ -72,10 +76,15 @@ class TestVideoTrackSource : public Notifier<VideoTrackSourceInterface> {
|
|||||||
int height,
|
int height,
|
||||||
const absl::optional<int>& max_fps) {}
|
const absl::optional<int>& max_fps) {}
|
||||||
|
|
||||||
|
// Returns stream label for this video source if present. Implementations
|
||||||
|
// may override this method to increase debugability and testability.
|
||||||
|
virtual absl::optional<std::string> GetStreamLabel() { return stream_label_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
|
virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const absl::optional<std::string> stream_label_;
|
||||||
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_;
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_;
|
||||||
RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_;
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_;
|
||||||
SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_);
|
SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_);
|
||||||
|
|||||||
@ -130,6 +130,7 @@ if (!build_with_chromium) {
|
|||||||
"../../../api/test/video:test_video_track_source",
|
"../../../api/test/video:test_video_track_source",
|
||||||
"../../../api/video:video_frame",
|
"../../../api/video:video_frame",
|
||||||
]
|
]
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("media_helper") {
|
rtc_library("media_helper") {
|
||||||
|
|||||||
@ -59,7 +59,7 @@ MediaHelper::MaybeAddVideo(TestPeer* peer) {
|
|||||||
VideoTrackInterface::ContentHint::kDetailed;
|
VideoTrackInterface::ContentHint::kDetailed;
|
||||||
rtc::scoped_refptr<TestVideoCapturerVideoTrackSource> source =
|
rtc::scoped_refptr<TestVideoCapturerVideoTrackSource> source =
|
||||||
rtc::make_ref_counted<TestVideoCapturerVideoTrackSource>(
|
rtc::make_ref_counted<TestVideoCapturerVideoTrackSource>(
|
||||||
std::move(capturer), is_screencast);
|
std::move(capturer), is_screencast, video_config.stream_label);
|
||||||
out.push_back(source);
|
out.push_back(source);
|
||||||
RTC_LOG(LS_INFO) << "Adding video with video_config.stream_label="
|
RTC_LOG(LS_INFO) << "Adding video with video_config.stream_label="
|
||||||
<< video_config.stream_label.value();
|
<< video_config.stream_label.value();
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include "api/sequence_checker.h"
|
#include "api/sequence_checker.h"
|
||||||
#include "api/test/video/test_video_track_source.h"
|
#include "api/test/video/test_video_track_source.h"
|
||||||
#include "api/video/video_frame.h"
|
#include "api/video/video_frame.h"
|
||||||
@ -27,8 +28,9 @@ class TestVideoCapturerVideoTrackSource : public test::TestVideoTrackSource {
|
|||||||
public:
|
public:
|
||||||
TestVideoCapturerVideoTrackSource(
|
TestVideoCapturerVideoTrackSource(
|
||||||
std::unique_ptr<test::TestVideoCapturer> video_capturer,
|
std::unique_ptr<test::TestVideoCapturer> video_capturer,
|
||||||
bool is_screencast)
|
bool is_screencast,
|
||||||
: TestVideoTrackSource(/*remote=*/false),
|
absl::optional<std::string> stream_label = absl::nullopt)
|
||||||
|
: TestVideoTrackSource(/*remote=*/false, std::move(stream_label)),
|
||||||
video_capturer_(std::move(video_capturer)),
|
video_capturer_(std::move(video_capturer)),
|
||||||
is_screencast_(is_screencast) {
|
is_screencast_(is_screencast) {
|
||||||
sequence_checker_.Detach();
|
sequence_checker_.Detach();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user