Add --disable_preview flag to video_replay.

Bug: webrtc:14508
Change-Id: I4c8c6e2807a77c5bfd8705f003d93e9ac23497b6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277821
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38286}
This commit is contained in:
philipel
2022-10-04 08:09:45 +02:00
committed by WebRTC LUCI CQ
parent ddab8d9a1d
commit f16fc05222

View File

@ -155,6 +155,8 @@ ABSL_FLAG(
ABSL_FLAG(bool, simulated_time, false, "Run in simulated time");
ABSL_FLAG(bool, disable_preview, false, "Disable decoded video preview.");
namespace {
bool ValidatePayloadType(int32_t payload_type) {
return payload_type > 0 && payload_type <= 127;
@ -178,6 +180,11 @@ namespace {
const uint32_t kReceiverLocalSsrc = 0x123456;
class NullRenderer : public rtc::VideoSinkInterface<VideoFrame> {
public:
void OnFrame(const VideoFrame& frame) override {}
};
class FileRenderPassthrough : public rtc::VideoSinkInterface<VideoFrame> {
public:
FileRenderPassthrough(const std::string& basename,
@ -314,9 +321,13 @@ std::unique_ptr<StreamState> ConfigureFromFile(const std::string& config_path,
// Create a window for this config.
std::stringstream window_title;
window_title << "Playback Video (" << config_count++ << ")";
if (absl::GetFlag(FLAGS_disable_preview)) {
stream_state->sinks.emplace_back(std::make_unique<NullRenderer>());
} else {
stream_state->sinks.emplace_back(test::VideoRenderer::Create(
window_title.str().c_str(), absl::GetFlag(FLAGS_render_width),
absl::GetFlag(FLAGS_render_height)));
}
// Create a receive stream for this config.
receive_config.renderer = stream_state->sinks.back().get();
receive_config.decoder_factory = stream_state->decoder_factory.get();
@ -335,10 +346,14 @@ std::unique_ptr<StreamState> ConfigureFromFlags(
// them from deallocating.
std::stringstream window_title;
window_title << "Playback Video (" << rtp_dump_path << ")";
std::unique_ptr<test::VideoRenderer> playback_video(
test::VideoRenderer::Create(window_title.str().c_str(),
absl::GetFlag(FLAGS_render_width),
std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>> playback_video;
if (absl::GetFlag(FLAGS_disable_preview)) {
playback_video = std::make_unique<NullRenderer>();
} else {
playback_video.reset(test::VideoRenderer::Create(
window_title.str().c_str(), absl::GetFlag(FLAGS_render_width),
absl::GetFlag(FLAGS_render_height)));
}
auto file_passthrough = std::make_unique<FileRenderPassthrough>(
absl::GetFlag(FLAGS_out_base), playback_video.get());
stream_state->sinks.push_back(std::move(playback_video));