Event logs - separate audio_level and voice_activity
Bug: webrtc:8111 Change-Id: I44d81c5b4f5b854e8accd84521fbbd7b50228903 Reviewed-on: https://webrtc-review.googlesource.com/c/109571 Commit-Queue: Elad Alon <eladalon@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25589}
This commit is contained in:
parent
466620b326
commit
eb809f30d1
@ -239,13 +239,6 @@ rtclog2::IceCandidatePairEvent::IceCandidatePairEventType ConvertToProtoFormat(
|
||||
return rtclog2::IceCandidatePairEvent::UNKNOWN_CHECK_TYPE;
|
||||
}
|
||||
|
||||
uint8_t ConvertAudioLevelToProtoFormat(bool voice_activity,
|
||||
uint8_t audio_level) {
|
||||
RTC_DCHECK_EQ(audio_level & static_cast<uint8_t>(0x80), 0);
|
||||
constexpr uint8_t kVoiceActivityBit = 0x80;
|
||||
return audio_level | (voice_activity ? kVoiceActivityBit : 0);
|
||||
}
|
||||
|
||||
// Copies all RTCP blocks except APP, SDES and unknown from |packet| to
|
||||
// |buffer|. |buffer| must have space for |IP_PACKET_SIZE| bytes. |packet| must
|
||||
// be at most |IP_PACKET_SIZE| bytes long.
|
||||
@ -338,8 +331,10 @@ void EncodeRtcpPacket(rtc::ArrayView<const EventType*> batch,
|
||||
static_assert(sizeof(std::string::value_type) == sizeof(uint8_t), "");
|
||||
const size_t buffer_length = RemoveNonWhitelistedRtcpBlocks(
|
||||
event->packet_, reinterpret_cast<uint8_t*>(&scrubed_packets[i][0]));
|
||||
if (buffer_length < event->packet_.size()) {
|
||||
scrubed_packets[i].resize(buffer_length);
|
||||
}
|
||||
}
|
||||
proto_batch->set_raw_packet_blobs(EncodeBlobs(scrubed_packets));
|
||||
}
|
||||
|
||||
@ -405,17 +400,19 @@ void EncodeRtpPacket(const std::vector<const EventType*>& batch,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(eladalon): Separate audio level from voice activity.
|
||||
absl::optional<uint64_t> base_audio_level;
|
||||
absl::optional<uint64_t> base_voice_activity;
|
||||
{
|
||||
bool voice_activity;
|
||||
uint8_t audio_level;
|
||||
if (base_event->header_.template GetExtension<AudioLevel>(&voice_activity,
|
||||
&audio_level)) {
|
||||
proto_batch->set_audio_level(
|
||||
ConvertAudioLevelToProtoFormat(voice_activity, audio_level));
|
||||
base_audio_level =
|
||||
ConvertAudioLevelToProtoFormat(voice_activity, audio_level);
|
||||
RTC_DCHECK_LE(audio_level, 0x7Fu);
|
||||
base_audio_level = audio_level;
|
||||
proto_batch->set_audio_level(audio_level);
|
||||
|
||||
base_voice_activity = voice_activity;
|
||||
proto_batch->set_voice_activity(voice_activity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +584,8 @@ void EncodeRtpPacket(const std::vector<const EventType*>& batch,
|
||||
uint8_t audio_level;
|
||||
if (event->header_.template GetExtension<AudioLevel>(&voice_activity,
|
||||
&audio_level)) {
|
||||
values[i] = ConvertAudioLevelToProtoFormat(voice_activity, audio_level);
|
||||
RTC_DCHECK_LE(audio_level, 0x7Fu);
|
||||
values[i] = audio_level;
|
||||
} else {
|
||||
values[i].reset();
|
||||
}
|
||||
@ -596,6 +594,24 @@ void EncodeRtpPacket(const std::vector<const EventType*>& batch,
|
||||
if (!encoded_deltas.empty()) {
|
||||
proto_batch->set_audio_level_deltas(encoded_deltas);
|
||||
}
|
||||
|
||||
// voice_activity (RTP extension)
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
const EventType* event = batch[i + 1];
|
||||
bool voice_activity;
|
||||
uint8_t audio_level;
|
||||
if (event->header_.template GetExtension<AudioLevel>(&voice_activity,
|
||||
&audio_level)) {
|
||||
RTC_DCHECK_LE(audio_level, 0x7Fu);
|
||||
values[i] = voice_activity;
|
||||
} else {
|
||||
values[i].reset();
|
||||
}
|
||||
}
|
||||
encoded_deltas = EncodeDeltas(base_voice_activity, values);
|
||||
if (!encoded_deltas.empty()) {
|
||||
proto_batch->set_voice_activity_deltas(encoded_deltas);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -86,7 +86,9 @@ message IncomingRtpPackets {
|
||||
optional int32 transmission_time_offset = 16;
|
||||
optional uint32 absolute_send_time = 17;
|
||||
optional uint32 video_rotation = 18;
|
||||
// |audio_level| and |voice_activity| are always used in conjunction.
|
||||
optional uint32 audio_level = 19;
|
||||
optional bool voice_activity = 20;
|
||||
// TODO(terelius): Add other header extensions like playout delay?
|
||||
|
||||
// Delta encodings.
|
||||
@ -105,7 +107,9 @@ message IncomingRtpPackets {
|
||||
optional bytes transmission_time_offset_deltas = 116;
|
||||
optional bytes absolute_send_time_deltas = 117;
|
||||
optional bytes video_rotation_deltas = 118;
|
||||
// |audio_level| and |voice_activity| are always used in conjunction.
|
||||
optional bytes audio_level_deltas = 119;
|
||||
optional bytes voice_activity_deltas = 120;
|
||||
}
|
||||
|
||||
message OutgoingRtpPackets {
|
||||
@ -150,7 +154,9 @@ message OutgoingRtpPackets {
|
||||
optional int32 transmission_time_offset = 16;
|
||||
optional uint32 absolute_send_time = 17;
|
||||
optional uint32 video_rotation = 18;
|
||||
// |audio_level| and |voice_activity| are always used in conjunction.
|
||||
optional uint32 audio_level = 19;
|
||||
optional bool voice_activity = 20;
|
||||
// TODO(terelius): Add other header extensions like playout delay?
|
||||
|
||||
// Delta encodings.
|
||||
@ -169,7 +175,9 @@ message OutgoingRtpPackets {
|
||||
optional bytes transmission_time_offset_deltas = 116;
|
||||
optional bytes absolute_send_time_deltas = 117;
|
||||
optional bytes video_rotation_deltas = 118;
|
||||
// |audio_level| and |voice_activity| are always used in conjunction.
|
||||
optional bytes audio_level_deltas = 119;
|
||||
optional bytes voice_activity_deltas = 120;
|
||||
}
|
||||
|
||||
message IncomingRtcpPackets {
|
||||
|
||||
@ -497,11 +497,16 @@ void StoreRtpPackets(
|
||||
rtc::checked_cast<uint8_t>(proto.video_rotation()));
|
||||
}
|
||||
if (proto.has_audio_level()) {
|
||||
RTC_CHECK(proto.has_voice_activity());
|
||||
header.extension.hasAudioLevel = true;
|
||||
header.extension.voiceActivity =
|
||||
rtc::checked_cast<bool>(proto.voice_activity());
|
||||
const uint8_t audio_level =
|
||||
rtc::checked_cast<uint8_t>(proto.audio_level());
|
||||
header.extension.voiceActivity = (audio_level >> 7) != 0;
|
||||
header.extension.audioLevel = audio_level & 0x7Fu;
|
||||
RTC_CHECK_LE(audio_level, 0x7Fu);
|
||||
header.extension.audioLevel = audio_level;
|
||||
} else {
|
||||
RTC_CHECK(!proto.has_voice_activity());
|
||||
}
|
||||
(*rtp_packets_map)[header.ssrc].emplace_back(
|
||||
proto.timestamp_ms() * 1000, header, proto.header_size(),
|
||||
@ -620,6 +625,17 @@ void StoreRtpPackets(
|
||||
RTC_CHECK_EQ(audio_level_values.size(), number_of_deltas);
|
||||
}
|
||||
|
||||
// voice_activity (RTP extension)
|
||||
std::vector<absl::optional<uint64_t>> voice_activity_values;
|
||||
{
|
||||
const absl::optional<uint64_t> base_voice_activity =
|
||||
proto.has_voice_activity() ? proto.voice_activity()
|
||||
: absl::optional<uint64_t>();
|
||||
voice_activity_values = DecodeDeltas(proto.voice_activity_deltas(),
|
||||
base_voice_activity, number_of_deltas);
|
||||
RTC_CHECK_EQ(voice_activity_values.size(), number_of_deltas);
|
||||
}
|
||||
|
||||
// Delta decoding
|
||||
for (size_t i = 0; i < number_of_deltas; ++i) {
|
||||
RTC_CHECK(timestamp_ms_values[i].has_value());
|
||||
@ -670,11 +686,18 @@ void StoreRtpPackets(
|
||||
rtc::checked_cast<uint8_t>(video_rotation_values[i].value()));
|
||||
}
|
||||
if (audio_level_values.size() > i && audio_level_values[i].has_value()) {
|
||||
RTC_CHECK(voice_activity_values.size() > i &&
|
||||
voice_activity_values[i].has_value());
|
||||
header.extension.hasAudioLevel = true;
|
||||
header.extension.voiceActivity =
|
||||
rtc::checked_cast<bool>(voice_activity_values[i].value());
|
||||
const uint8_t audio_level =
|
||||
rtc::checked_cast<uint8_t>(audio_level_values[i].value());
|
||||
header.extension.voiceActivity = (audio_level >> 7) != 0;
|
||||
header.extension.audioLevel = audio_level & 0x7Fu;
|
||||
RTC_CHECK_LE(audio_level, 0x7Fu);
|
||||
header.extension.audioLevel = audio_level;
|
||||
} else {
|
||||
RTC_CHECK(voice_activity_values.size() <= i ||
|
||||
!voice_activity_values[i].has_value());
|
||||
}
|
||||
(*rtp_packets_map)[header.ssrc].emplace_back(
|
||||
timestamp_ms_values[i].value() * 1000, header, header.headerLength,
|
||||
@ -2300,6 +2323,7 @@ void ParsedRtcEventLogNew::StoreAudioNetworkAdaptationEvent(
|
||||
runtime_config.enable_dtx = proto.enable_dtx();
|
||||
}
|
||||
if (proto.has_num_channels()) {
|
||||
// TODO(eladalon): Encode 1/2 -> 0/1, to improve
|
||||
runtime_config.num_channels = proto.num_channels();
|
||||
}
|
||||
audio_network_adaptation_events_.emplace_back(1000 * proto.timestamp_ms(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user