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:
@ -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,7 +331,9 @@ 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]));
|
||||
scrubed_packets[i].resize(buffer_length);
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user