Let rtp_analyze parse absolute sender time
Also change to use virtual_packet_length_bytes in order to print the actual packet size of the complete packet even when the RTP file only contains RTP headers. BUG=2692 R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/51559004 Cr-Commit-Position: refs/heads/master@{#9025}
This commit is contained in:
parent
61c2a6f241
commit
b0b54259c3
@ -38,6 +38,9 @@ static const bool red_dummy =
|
|||||||
DEFINE_int32(audio_level, 1, "Extension ID for audio level (RFC 6464)");
|
DEFINE_int32(audio_level, 1, "Extension ID for audio level (RFC 6464)");
|
||||||
static const bool audio_level_dummy =
|
static const bool audio_level_dummy =
|
||||||
google::RegisterFlagValidator(&FLAGS_audio_level, &ValidateExtensionId);
|
google::RegisterFlagValidator(&FLAGS_audio_level, &ValidateExtensionId);
|
||||||
|
DEFINE_int32(abs_send_time, 3, "Extension ID for absolute sender time");
|
||||||
|
static const bool abs_send_time_dummy =
|
||||||
|
google::RegisterFlagValidator(&FLAGS_abs_send_time, &ValidateExtensionId);
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
std::string program_name = argv[0];
|
std::string program_name = argv[0];
|
||||||
@ -63,13 +66,19 @@ int main(int argc, char* argv[]) {
|
|||||||
rtc::scoped_ptr<webrtc::test::RtpFileSource> file_source(
|
rtc::scoped_ptr<webrtc::test::RtpFileSource> file_source(
|
||||||
webrtc::test::RtpFileSource::Create(argv[1]));
|
webrtc::test::RtpFileSource::Create(argv[1]));
|
||||||
assert(file_source.get());
|
assert(file_source.get());
|
||||||
// Set RTP extension ID.
|
// Set RTP extension IDs.
|
||||||
bool print_audio_level = false;
|
bool print_audio_level = false;
|
||||||
if (!google::GetCommandLineFlagInfoOrDie("audio_level").is_default) {
|
if (!google::GetCommandLineFlagInfoOrDie("audio_level").is_default) {
|
||||||
print_audio_level = true;
|
print_audio_level = true;
|
||||||
file_source->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel,
|
file_source->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel,
|
||||||
FLAGS_audio_level);
|
FLAGS_audio_level);
|
||||||
}
|
}
|
||||||
|
bool print_abs_send_time = false;
|
||||||
|
if (!google::GetCommandLineFlagInfoOrDie("abs_send_time").is_default) {
|
||||||
|
print_abs_send_time = true;
|
||||||
|
file_source->RegisterRtpHeaderExtension(
|
||||||
|
webrtc::kRtpExtensionAbsoluteSendTime, FLAGS_abs_send_time);
|
||||||
|
}
|
||||||
|
|
||||||
FILE* out_file;
|
FILE* out_file;
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
@ -88,8 +97,13 @@ int main(int argc, char* argv[]) {
|
|||||||
if (print_audio_level) {
|
if (print_audio_level) {
|
||||||
fprintf(out_file, " AuLvl (V)");
|
fprintf(out_file, " AuLvl (V)");
|
||||||
}
|
}
|
||||||
|
if (print_abs_send_time) {
|
||||||
|
fprintf(out_file, " AbsSendTime");
|
||||||
|
}
|
||||||
fprintf(out_file, "\n");
|
fprintf(out_file, "\n");
|
||||||
|
|
||||||
|
uint32_t max_abs_send_time = 0;
|
||||||
|
int cycles = -1;
|
||||||
rtc::scoped_ptr<webrtc::test::Packet> packet;
|
rtc::scoped_ptr<webrtc::test::Packet> packet;
|
||||||
while (true) {
|
while (true) {
|
||||||
packet.reset(file_source->NextPacket());
|
packet.reset(file_source->NextPacket());
|
||||||
@ -97,13 +111,14 @@ int main(int argc, char* argv[]) {
|
|||||||
// End of file reached.
|
// End of file reached.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Write packet data to file.
|
// Write packet data to file. Use virtual_packet_length_bytes so that the
|
||||||
|
// correct packet sizes are printed also for RTP header-only dumps.
|
||||||
fprintf(out_file,
|
fprintf(out_file,
|
||||||
"%5u %10u %10u %5i %5i %2i %#08X",
|
"%5u %10u %10u %5i %5i %2i %#08X",
|
||||||
packet->header().sequenceNumber,
|
packet->header().sequenceNumber,
|
||||||
packet->header().timestamp,
|
packet->header().timestamp,
|
||||||
static_cast<unsigned int>(packet->time_ms()),
|
static_cast<unsigned int>(packet->time_ms()),
|
||||||
static_cast<int>(packet->packet_length_bytes()),
|
static_cast<int>(packet->virtual_packet_length_bytes()),
|
||||||
packet->header().payloadType,
|
packet->header().payloadType,
|
||||||
packet->header().markerBit,
|
packet->header().markerBit,
|
||||||
packet->header().ssrc);
|
packet->header().ssrc);
|
||||||
@ -114,6 +129,35 @@ int main(int argc, char* argv[]) {
|
|||||||
packet->header().extension.audioLevel & 0x7F,
|
packet->header().extension.audioLevel & 0x7F,
|
||||||
(packet->header().extension.audioLevel & 0x80) == 0 ? 0 : 1);
|
(packet->header().extension.audioLevel & 0x80) == 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
if (print_abs_send_time && packet->header().extension.hasAbsoluteSendTime) {
|
||||||
|
if (cycles == -1) {
|
||||||
|
// Initialize.
|
||||||
|
max_abs_send_time = packet->header().extension.absoluteSendTime;
|
||||||
|
cycles = 0;
|
||||||
|
}
|
||||||
|
// Abs sender time is 24 bit 6.18 fixed point. Shift by 8 to normalize to
|
||||||
|
// 32 bits (unsigned). Calculate the difference between this packet's
|
||||||
|
// send time and the maximum observed. Cast to signed 32-bit to get the
|
||||||
|
// desired wrap-around behavior.
|
||||||
|
if (static_cast<int32_t>(
|
||||||
|
(packet->header().extension.absoluteSendTime << 8) -
|
||||||
|
(max_abs_send_time << 8)) >= 0) {
|
||||||
|
// The difference is non-negative, meaning that this packet is newer
|
||||||
|
// than the previously observed maximum absolute send time.
|
||||||
|
if (packet->header().extension.absoluteSendTime < max_abs_send_time) {
|
||||||
|
// Wrap detected.
|
||||||
|
cycles++;
|
||||||
|
}
|
||||||
|
max_abs_send_time = packet->header().extension.absoluteSendTime;
|
||||||
|
}
|
||||||
|
// Abs sender time is 24 bit 6.18 fixed point. Divide by 2^18 to convert
|
||||||
|
// to floating point representation.
|
||||||
|
double send_time_seconds =
|
||||||
|
static_cast<double>(packet->header().extension.absoluteSendTime) /
|
||||||
|
262144 +
|
||||||
|
64.0 * cycles;
|
||||||
|
fprintf(out_file, " %11f", send_time_seconds);
|
||||||
|
}
|
||||||
fprintf(out_file, "\n");
|
fprintf(out_file, "\n");
|
||||||
|
|
||||||
if (packet->header().payloadType == FLAGS_red) {
|
if (packet->header().payloadType == FLAGS_red) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user