mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
video_replay tool fix/update
Change-Id: I188ed4c7cebc5cafb31e01a38e0460cde65fefa1 Bug: none Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/341800 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41926}
This commit is contained in:
parent
8ae894d924
commit
5f86437dbc
3 changed files with 58 additions and 33 deletions
|
@ -290,6 +290,7 @@ if (!is_component_build) {
|
||||||
"../test/time_controller:time_controller",
|
"../test/time_controller:time_controller",
|
||||||
"//third_party/abseil-cpp/absl/flags:flag",
|
"//third_party/abseil-cpp/absl/flags:flag",
|
||||||
"//third_party/abseil-cpp/absl/flags:parse",
|
"//third_party/abseil-cpp/absl/flags:parse",
|
||||||
|
"//third_party/abseil-cpp/absl/strings:strings",
|
||||||
]
|
]
|
||||||
if (build_with_chromium) {
|
if (build_with_chromium) {
|
||||||
# When building from Chromium, WebRTC's metrics and field trial
|
# When building from Chromium, WebRTC's metrics and field trial
|
||||||
|
|
|
@ -32,6 +32,7 @@ specific_include_rules = {
|
||||||
],
|
],
|
||||||
".*video_replay\.cc": [
|
".*video_replay\.cc": [
|
||||||
"+modules/video_coding/utility/ivf_file_writer.h",
|
"+modules/video_coding/utility/ivf_file_writer.h",
|
||||||
|
"+absl/strings/str_split.h",
|
||||||
],
|
],
|
||||||
".*video_encoder\.cc": [
|
".*video_encoder\.cc": [
|
||||||
"+modules/video_coding/codecs/av1/av1_svc_config.h",
|
"+modules/video_coding/codecs/av1/av1_svc_config.h",
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#include "absl/flags/parse.h"
|
#include "absl/flags/parse.h"
|
||||||
|
#include "absl/strings/str_split.h"
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/field_trials.h"
|
#include "api/field_trials.h"
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||||
#include "media/engine/internal_decoder_factory.h"
|
#include "media/engine/internal_decoder_factory.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
|
||||||
|
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet.h"
|
#include "modules/rtp_rtcp/source/rtp_packet.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_util.h"
|
#include "modules/rtp_rtcp/source/rtp_util.h"
|
||||||
|
@ -102,14 +104,22 @@ ABSL_FLAG(uint32_t,
|
||||||
webrtc::test::VideoTestConstants::kFlexfecSendSsrc,
|
webrtc::test::VideoTestConstants::kFlexfecSendSsrc,
|
||||||
"Incoming FLEXFEC SSRC");
|
"Incoming FLEXFEC SSRC");
|
||||||
|
|
||||||
// Flag for abs-send-time id.
|
ABSL_FLAG(std::vector<std::string>,
|
||||||
ABSL_FLAG(int, abs_send_time_id, -1, "RTP extension ID for abs-send-time");
|
ext_map,
|
||||||
|
{},
|
||||||
// Flag for transmission-offset id.
|
"RTP extension to ID map in the format of EXT1:ID,EXT2:ID,EXT3:ID"
|
||||||
ABSL_FLAG(int,
|
" Known extensions are:\n"
|
||||||
transmission_offset_id,
|
"TOFF - kTimestampOffsetUri\n"
|
||||||
-1,
|
"ABSSEND - kAbsSendTimeUri\n"
|
||||||
"RTP extension ID for transmission-offset");
|
"ABSCAPT - kAbsoluteCaptureTimeUri\n"
|
||||||
|
"ROT - kVideoRotationUri\n"
|
||||||
|
"CONT - kVideoContentTypeUri\n"
|
||||||
|
"DD - kDependencyDescriptorUri\n"
|
||||||
|
"LALOC - kVideoLayersAllocationUri\n"
|
||||||
|
"TWCC - kTransportSequenceNumberUri\n"
|
||||||
|
"TWCC2 - kTransportSequenceNumberV2Uri\n"
|
||||||
|
"DELAY - kPlayoutDelayUri\n"
|
||||||
|
"COLOR - kColorSpaceUri\n");
|
||||||
|
|
||||||
// Flag for rtpdump input file.
|
// Flag for rtpdump input file.
|
||||||
ABSL_FLAG(std::string, input_file, "", "input file");
|
ABSL_FLAG(std::string, input_file, "", "input file");
|
||||||
|
@ -179,10 +189,6 @@ bool ValidateOptionalPayloadType(int32_t payload_type) {
|
||||||
return payload_type == -1 || ValidatePayloadType(payload_type);
|
return payload_type == -1 || ValidatePayloadType(payload_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateRtpHeaderExtensionId(int32_t extension_id) {
|
|
||||||
return extension_id >= -1 && extension_id < 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ValidateInputFilenameNotEmpty(const std::string& string) {
|
bool ValidateInputFilenameNotEmpty(const std::string& string) {
|
||||||
return !string.empty();
|
return !string.empty();
|
||||||
}
|
}
|
||||||
|
@ -542,6 +548,35 @@ class RtpReplayer final {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
RtpHeaderExtensionMap GetExtensionMapFromFlags() {
|
||||||
|
const std::map<std::string_view, absl::string_view> kKnownExtensions = {
|
||||||
|
{"TOFF", RtpExtension::kTimestampOffsetUri},
|
||||||
|
{"ABSSEND", RtpExtension::kAbsSendTimeUri},
|
||||||
|
{"ABSCAPT", RtpExtension::kAbsoluteCaptureTimeUri},
|
||||||
|
{"ROT", RtpExtension::kVideoRotationUri},
|
||||||
|
{"CONT", RtpExtension::kVideoContentTypeUri},
|
||||||
|
{"DD", RtpExtension::kDependencyDescriptorUri},
|
||||||
|
{"LALOC", RtpExtension::kVideoLayersAllocationUri},
|
||||||
|
{"TWCC", RtpExtension::kTransportSequenceNumberUri},
|
||||||
|
{"TWCC2", RtpExtension::kTransportSequenceNumberV2Uri},
|
||||||
|
{"DELAY", RtpExtension::kPlayoutDelayUri},
|
||||||
|
{"COLOR", RtpExtension::kColorSpaceUri},
|
||||||
|
};
|
||||||
|
|
||||||
|
RtpHeaderExtensionMap res;
|
||||||
|
for (const std::string& extension : absl::GetFlag(FLAGS_ext_map)) {
|
||||||
|
std::pair<std::string, std::string> ext = absl::StrSplit(extension, ':');
|
||||||
|
if (auto it = kKnownExtensions.find(ext.first);
|
||||||
|
it != kKnownExtensions.end()) {
|
||||||
|
res.RegisterByUri(std::stoi(ext.second), it->second);
|
||||||
|
} else {
|
||||||
|
RTC_DCHECK_NOTREACHED() << "Unknown extension \"" << ext.first << "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void ReplayPackets() {
|
void ReplayPackets() {
|
||||||
enum class Result { kOk, kUnknownSsrc, kParsingFailed };
|
enum class Result { kOk, kUnknownSsrc, kParsingFailed };
|
||||||
int64_t replay_start_ms = -1;
|
int64_t replay_start_ms = -1;
|
||||||
|
@ -551,15 +586,7 @@ class RtpReplayer final {
|
||||||
uint32_t start_timestamp = absl::GetFlag(FLAGS_start_timestamp);
|
uint32_t start_timestamp = absl::GetFlag(FLAGS_start_timestamp);
|
||||||
uint32_t stop_timestamp = absl::GetFlag(FLAGS_stop_timestamp);
|
uint32_t stop_timestamp = absl::GetFlag(FLAGS_stop_timestamp);
|
||||||
|
|
||||||
RtpHeaderExtensionMap extensions;
|
RtpHeaderExtensionMap extensions = GetExtensionMapFromFlags();
|
||||||
if (absl::GetFlag(FLAGS_transmission_offset_id) != -1) {
|
|
||||||
extensions.RegisterByUri(absl::GetFlag(FLAGS_transmission_offset_id),
|
|
||||||
RtpExtension::kTimestampOffsetUri);
|
|
||||||
}
|
|
||||||
if (absl::GetFlag(FLAGS_abs_send_time_id) != -1) {
|
|
||||||
extensions.RegisterByUri(absl::GetFlag(FLAGS_abs_send_time_id),
|
|
||||||
RtpExtension::kAbsSendTimeUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int64_t now_ms = CurrentTimeMs();
|
int64_t now_ms = CurrentTimeMs();
|
||||||
|
@ -603,15 +630,15 @@ class RtpReplayer final {
|
||||||
Timestamp::Millis(CurrentTimeMs()));
|
Timestamp::Millis(CurrentTimeMs()));
|
||||||
if (!received_packet.Parse(std::move(packet_buffer))) {
|
if (!received_packet.Parse(std::move(packet_buffer))) {
|
||||||
result = Result::kParsingFailed;
|
result = Result::kParsingFailed;
|
||||||
return;
|
} else {
|
||||||
|
call_->Receiver()->DeliverRtpPacket(
|
||||||
|
MediaType::VIDEO, received_packet,
|
||||||
|
[&result](const RtpPacketReceived& parsed_packet) -> bool {
|
||||||
|
result = Result::kUnknownSsrc;
|
||||||
|
// No point in trying to demux again.
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
call_->Receiver()->DeliverRtpPacket(
|
|
||||||
MediaType::VIDEO, received_packet,
|
|
||||||
[&result](const RtpPacketReceived& parsed_packet) -> bool {
|
|
||||||
result = Result::kUnknownSsrc;
|
|
||||||
// No point in trying to demux again.
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
event.Set();
|
event.Set();
|
||||||
});
|
});
|
||||||
event.Wait(/*give_up_after=*/TimeDelta::Seconds(10));
|
event.Wait(/*give_up_after=*/TimeDelta::Seconds(10));
|
||||||
|
@ -693,10 +720,6 @@ int main(int argc, char* argv[]) {
|
||||||
ValidateOptionalPayloadType(absl::GetFlag(FLAGS_ulpfec_payload_type)));
|
ValidateOptionalPayloadType(absl::GetFlag(FLAGS_ulpfec_payload_type)));
|
||||||
RTC_CHECK(
|
RTC_CHECK(
|
||||||
ValidateOptionalPayloadType(absl::GetFlag(FLAGS_flexfec_payload_type)));
|
ValidateOptionalPayloadType(absl::GetFlag(FLAGS_flexfec_payload_type)));
|
||||||
RTC_CHECK(
|
|
||||||
ValidateRtpHeaderExtensionId(absl::GetFlag(FLAGS_abs_send_time_id)));
|
|
||||||
RTC_CHECK(ValidateRtpHeaderExtensionId(
|
|
||||||
absl::GetFlag(FLAGS_transmission_offset_id)));
|
|
||||||
RTC_CHECK(ValidateInputFilenameNotEmpty(absl::GetFlag(FLAGS_input_file)));
|
RTC_CHECK(ValidateInputFilenameNotEmpty(absl::GetFlag(FLAGS_input_file)));
|
||||||
RTC_CHECK_GE(absl::GetFlag(FLAGS_extend_run_time_duration), 0);
|
RTC_CHECK_GE(absl::GetFlag(FLAGS_extend_run_time_duration), 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue