Update proto for new event log format.

Bug: webrtc:8111
Change-Id: I4c62ca56fb93a741361c337ef681da39d504d7ec
Reviewed-on: https://webrtc-review.googlesource.com/c/106342
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25211}
diff --git a/logging/rtc_event_log/rtc_event_log2.proto b/logging/rtc_event_log/rtc_event_log2.proto
index 4cac455..d1e2f30 100644
--- a/logging/rtc_event_log/rtc_event_log2.proto
+++ b/logging/rtc_event_log/rtc_event_log2.proto
@@ -12,18 +12,13 @@
 // write it to a file.
 message EventStream {
   // Deprecated - Maintained for compatibility with the old event log.
-  // TODO(terelius): Maybe we can remove this and instead check the stream for
-  // presence of a version field. That requires a custom protobuf parser, but we
-  // have that already anyway.
   repeated Event stream = 1 [deprecated = true];
-  // required - The version number must be 2 for this version of the event log.
-  optional uint32 version = 2;
-  repeated IncomingRtpPackets incoming_rtp_packets = 3;
-  repeated OutgoingRtpPackets outgoing_rtp_packets = 4;
-  repeated IncomingRtcpPackets incoming_rtcp_packets = 5;
-  repeated OutgoingRtcpPackets outgoing_rtcp_packets = 6;
-  repeated AudioPlayoutEvents audio_playout_events = 7;
-  // The field tags 8-15 are reserved for the most common events
+  repeated IncomingRtpPackets incoming_rtp_packets = 2;
+  repeated OutgoingRtpPackets outgoing_rtp_packets = 3;
+  repeated IncomingRtcpPackets incoming_rtcp_packets = 4;
+  repeated OutgoingRtcpPackets outgoing_rtcp_packets = 5;
+  repeated AudioPlayoutEvents audio_playout_events = 6;
+  // The field tags 7-15 are reserved for the most common events.
   repeated BeginLogEvent begin_log_events = 16;
   repeated EndLogEvent end_log_events = 17;
   repeated LossBasedBweUpdates loss_based_bwe_updates = 18;
@@ -32,6 +27,9 @@
   repeated BweProbeCluster probe_clusters = 21;
   repeated BweProbeResultSuccess probe_success = 22;
   repeated BweProbeResultFailure probe_failure = 23;
+  repeated AlrState alr_states = 24;
+  repeated IceCandidatePairConfig ice_candidate_configs = 25;
+  repeated IceCandidatePairEvent ice_candidate_events = 26;
 
   repeated AudioRecvStreamConfig audio_recv_stream_configs = 101;
   repeated AudioSendStreamConfig audio_send_stream_configs = 102;
@@ -45,136 +43,190 @@
 }
 
 message IncomingRtpPackets {
+  // required
   optional int64 timestamp_ms = 1;
 
-  // RTP marker bit, used to label boundaries within e.g. video frames.
+  // required - RTP marker bit, used to label boundaries between video frames.
   optional bool marker = 2;
 
-  // RTP payload type.
+  // required - RTP payload type.
   optional uint32 payload_type = 3;
 
-  // RTP sequence number.
+  // required - RTP sequence number.
   optional uint32 sequence_number = 4;
 
-  // RTP monotonic clock timestamp (not actual time).
+  // required - RTP monotonic clock timestamp (not actual time).
   optional fixed32 rtp_timestamp = 5;
 
-  // Synchronization source of this packet's RTP stream.
+  // required - Synchronization source of this packet's RTP stream.
   optional fixed32 ssrc = 6;
 
   // TODO(terelius/dinor): Add CSRCs. Field number 7 reserved for this purpose.
 
-  // required - The size of the packet including both payload and header.
+  // required - The size (in bytes) of the packet including header, payload
+  // and padding.
   optional uint32 packet_size = 8;
 
-  // Optional header extensions.
-  optional int32 transmission_time_offset = 9;
-  optional uint32 absolute_send_time = 10;
-  optional uint32 transport_sequence_number = 11;
-  optional uint32 audio_level = 12;
-  // TODO(terelius): Add header extensions like video rotation, playout delay?
+  // required - The size (in bytes) of the RTP header.
+  optional uint32 header_size = 9;
 
-  // Delta encodings
+  // required - The size (in bytes) of the RTP header.
+  optional uint32 padding_size = 10;
+
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 11;
+
+  // Field numbers 12-14 reserved for future use.
+
+  // Optional header extensions.
+  optional uint32 transport_sequence_number = 15;
+  optional int32 transmission_time_offset = 16;
+  optional uint32 absolute_send_time = 17;
+  optional uint32 video_rotation = 18;
+  optional uint32 audio_level = 19;
+  // TODO(terelius): Add other header extensions like playout delay?
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes marker_deltas = 102;
   optional bytes payload_type_deltas = 103;
   optional bytes sequence_number_deltas = 104;
   optional bytes rtp_timestamp_deltas = 105;
+  // Field number 107 reserved for CSRC.
   optional bytes ssrc_deltas = 106;
-  optional bytes packet_size_deltas = 107;
-  optional bytes transmission_time_offset_deltas = 108;
-  optional bytes absolute_send_time_deltas = 109;
-  optional bytes transport_sequence_number_deltas = 110;
-  optional bytes audio_level_deltas = 111;
+  optional bytes packet_size_deltas = 108;
+  optional bytes header_size_deltas = 109;
+  optional bytes padding_size_deltas = 110;
+  // Field number 111-114 reserved for future use.
+  optional bytes transport_sequence_number_deltas = 115;
+  optional bytes transmission_time_offset_deltas = 116;
+  optional bytes absolute_send_time_deltas = 117;
+  optional bytes video_rotation_deltas = 118;
+  optional bytes audio_level_deltas = 119;
 }
 
 message OutgoingRtpPackets {
+  // required
   optional int64 timestamp_ms = 1;
 
-  // RTP marker bit, used to label boundaries within e.g. video frames.
+  // required - RTP marker bit, used to label boundaries between video frames.
   optional bool marker = 2;
 
+  // required - RTP payload type.
   optional uint32 payload_type = 3;
 
-  // RTP sequence number.
+  // required - RTP sequence number.
   optional uint32 sequence_number = 4;
 
-  // RTP monotonic clock timestamp (not actual time).
+  // required - RTP monotonic clock timestamp (not actual time).
   optional fixed32 rtp_timestamp = 5;
 
-  // Synchronization source of this packet's RTP stream.
+  // required - Synchronization source of this packet's RTP stream.
   optional fixed32 ssrc = 6;
 
   // TODO(terelius/dinor): Add CSRCs. Field number 7 reserved for this purpose.
 
-  // required - The size of the packet including both payload and header.
+  // required - The size (in bytes) of the packet including header, payload
+  // and padding.
   optional uint32 packet_size = 8;
 
-  // Optional header extensions.
-  optional int32 transmission_time_offset = 9;
-  optional uint32 absolute_send_time = 10;
-  optional uint32 transport_sequence_number = 11;
-  optional uint32 audio_level = 12;
-  // TODO(terelius): Add header extensions like video rotation, playout delay?
+  // required - The size (in bytes) of the RTP header.
+  optional uint32 header_size = 9;
 
-  // Delta encodings
+  // required - The size (in bytes) of the RTP header.
+  optional uint32 padding_size = 10;
+
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 11;
+
+  // Field numbers 12-14 reserved for future use.
+
+  // Optional header extensions.
+  optional uint32 transport_sequence_number = 15;
+  optional int32 transmission_time_offset = 16;
+  optional uint32 absolute_send_time = 17;
+  optional uint32 video_rotation = 18;
+  optional uint32 audio_level = 19;
+  // TODO(terelius): Add other header extensions like playout delay?
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes marker_deltas = 102;
   optional bytes payload_type_deltas = 103;
   optional bytes sequence_number_deltas = 104;
   optional bytes rtp_timestamp_deltas = 105;
   optional bytes ssrc_deltas = 106;
-  optional bytes packet_size_deltas = 107;
-  optional bytes probe_cluster_id_deltas = 108;
-  optional bytes transmission_time_offset_deltas = 109;
-  optional bytes absolute_send_time_deltas = 110;
-  optional bytes transport_sequence_number_deltas = 111;
+  // Field number 107 reserved for CSRC.
+  optional bytes packet_size_deltas = 108;
+  optional bytes header_size_deltas = 109;
+  optional bytes padding_size_deltas = 110;
+  // Field number 111-114 reserved for future use.
+  optional bytes transport_sequence_number_deltas = 115;
+  optional bytes transmission_time_offset_deltas = 116;
+  optional bytes absolute_send_time_deltas = 117;
+  optional bytes video_rotation_deltas = 118;
+  optional bytes audio_level_deltas = 119;
 }
 
 message IncomingRtcpPackets {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The whole packet including both payload and header.
   optional bytes raw_packet = 2;
   // TODO(terelius): Feasible to log parsed RTCP instead?
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 3;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes raw_packet_deltas = 102;
 }
 
 message OutgoingRtcpPackets {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The whole packet including both payload and header.
   optional bytes raw_packet = 2;
   // TODO(terelius): Feasible to log parsed RTCP instead?
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 3;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes raw_packet_deltas = 102;
 }
 
 message AudioPlayoutEvents {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The SSRC of the audio stream associated with the playout event.
   optional uint32 local_ssrc = 2;
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 3;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes local_ssrc_deltas = 102;
 }
 
 message BeginLogEvent {
+  // required
   optional int64 timestamp_ms = 1;
 }
 
 message EndLogEvent {
+  // required
   optional int64 timestamp_ms = 1;
 }
 
 message LossBasedBweUpdates {
+  // required
   optional int64 timestamp_ms = 1;
 
   // TODO(terelius): Update log interface to unsigned.
@@ -191,7 +243,10 @@
   // required - Total number of packets that the BWE update is based on.
   optional uint32 total_packets = 4;
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 5;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes bitrate_deltas_bps = 102;
   optional bytes fraction_loss_deltas = 103;
@@ -199,6 +254,7 @@
 }
 
 message DelayBasedBweUpdates {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - Bandwidth estimate (in bps) after the update.
@@ -211,7 +267,10 @@
   }
   optional DetectorState detector_state = 3;
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 4;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes bitrate_deltas_bps = 102;
   optional bytes detector_state_deltas = 103;
@@ -221,15 +280,17 @@
 message RtpHeaderExtensionConfig {
   // Optional IDs for the header extensions. Each ID is a 4-bit number that is
   // only set if that extension is configured.
-  // TODO(terelius): Can we skip transmission_time_offset? When is it used?
+  // TODO: Can we skip audio level?
   optional int32 transmission_time_offset_id = 1;
   optional int32 absolute_send_time_id = 2;
   optional int32 transport_sequence_number_id = 3;
-  optional int32 audio_level_id = 4;
-  // TODO(terelius): Add video_rotation and playout delay?
+  optional int32 video_rotation_id = 4;
+  optional int32 audio_level_id = 5;
+  // TODO(terelius): Add other header extensions like playout delay?
 }
 
 message VideoRecvStreamConfig {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - Synchronization source (stream identifier) to be received.
@@ -238,7 +299,7 @@
   // required - Sender SSRC used for sending RTCP (such as receiver reports).
   optional uint32 local_ssrc = 3;
 
-  // required if RTX is configured
+  // optional - required if RTX is configured. SSRC for the RTX stream.
   optional uint32 rtx_ssrc = 4;
 
   // optional - RTP source stream ID
@@ -253,16 +314,17 @@
 }
 
 message VideoSendStreamConfig {
+  // required
   optional int64 timestamp_ms = 1;
 
-  // Synchronization source (stream identifier) for outgoing stream.
-  // One stream can have several ssrcs for e.g. simulcast.
+  // required - Synchronization source (stream identifier) for outgoing stream.
+  // When using simulcast, a separate config should be logged for each stream.
   optional uint32 ssrc = 2;
 
-  // SSRC for the RTX stream
+  // optional - required if RTX is configured. SSRC for the RTX stream.
   optional uint32 rtx_ssrc = 3;
 
-  // RTP source stream ID
+  // optional - RTP source stream ID
   optional bytes rsid = 4;
 
   // IDs for the header extension we care about. Only required if there are
@@ -274,6 +336,7 @@
 }
 
 message AudioRecvStreamConfig {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - Synchronization source (stream identifier) to be received.
@@ -284,7 +347,7 @@
 
   // Field number 4 reserved for RTX SSRC.
 
-  // optional - RTP source stream ID
+  // optional - RTP source stream ID.
   optional bytes rsid = 5;
 
   // IDs for the header extension we care about. Only required if there are
@@ -296,15 +359,15 @@
 }
 
 message AudioSendStreamConfig {
+  // required
   optional int64 timestamp_ms = 1;
 
-  // Synchronization source (stream identifier) for outgoing stream.
-  // One stream can have several ssrcs for e.g. simulcast.
+  // required - Synchronization source (stream identifier) for outgoing stream.
   optional uint32 ssrc = 2;
 
   // Field number 3 reserved for RTX SSRC
 
-  // RTP source stream ID
+  // optional - RTP source stream ID
   optional bytes rsid = 4;
 
   // IDs for the header extension we care about. Only required if there are
@@ -316,6 +379,7 @@
 }
 
 message AudioNetworkAdaptations {
+  // required
   optional int64 timestamp_ms = 1;
 
   // Bit rate that the audio encoder is operating at.
@@ -339,7 +403,10 @@
   // Number of audio channels that each encoded packet consists of.
   optional uint32 num_channels = 7;
 
-  // Delta encodings
+  // optional - required if the batch contains delta encoded events.
+  optional uint32 number_of_deltas = 8;
+
+  // Delta encodings.
   optional bytes timestamp_deltas_ms = 101;
   optional bytes bitrate_deltas_bps = 102;
   optional bytes frame_length_deltas_ms = 103;
@@ -350,6 +417,7 @@
 }
 
 message BweProbeCluster {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The id of this probe cluster.
@@ -366,6 +434,7 @@
 }
 
 message BweProbeResultSuccess {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The id of this probe cluster.
@@ -376,6 +445,7 @@
 }
 
 message BweProbeResultFailure {
+  // required
   optional int64 timestamp_ms = 1;
 
   // required - The id of this probe cluster.
@@ -391,3 +461,99 @@
   // required
   optional FailureReason failure = 3;
 }
+
+message AlrState {
+  // required
+  optional int64 timestamp_ms = 1;
+
+  // required - True if the send rate is application limited.
+  optional bool in_alr = 2;
+}
+
+message IceCandidatePairConfig {
+  enum IceCandidatePairConfigType {
+    ADDED = 0;
+    UPDATED = 1;
+    DESTROYED = 2;
+    SELECTED = 3;
+  }
+
+  enum IceCandidateType {
+    UNKNOWN_CANDIDATE_TYPE = 0;
+    LOCAL = 1;
+    STUN = 2;
+    PRFLX = 3;
+    RELAY = 4;
+  }
+
+  enum Protocol {
+    UNKNOWN_PROTOCOL = 0;
+    UDP = 1;
+    TCP = 2;
+    SSLTCP = 3;
+    TLS = 4;
+  }
+
+  enum AddressFamily {
+    UNKNOWN_ADDRESS_FAMILY = 0;
+    IPV4 = 1;
+    IPV6 = 2;
+  }
+
+  enum NetworkType {
+    UNKNOWN_NETWORK_TYPE = 0;
+    ETHERNET = 1;
+    WIFI = 2;
+    CELLULAR = 3;
+    VPN = 4;
+    LOOPBACK = 5;
+  }
+
+  // required
+  optional int64 timestamp_ms = 1;
+
+  // required
+  optional IceCandidatePairConfigType config_type = 2;
+
+  // required
+  optional uint32 candidate_pair_id = 3;
+
+  // required
+  optional IceCandidateType local_candidate_type = 4;
+
+  // required
+  optional Protocol local_relay_protocol = 5;
+
+  // required
+  optional NetworkType local_network_type = 6;
+
+  // required
+  optional AddressFamily local_address_family = 7;
+
+  // required
+  optional IceCandidateType remote_candidate_type = 8;
+
+  // required
+  optional AddressFamily remote_address_family = 9;
+
+  // required
+  optional Protocol candidate_pair_protocol = 10;
+}
+
+message IceCandidatePairEvent {
+  enum IceCandidatePairEventType {
+    CHECK_SENT = 0;
+    CHECK_RECEIVED = 1;
+    CHECK_RESPONSE_SENT = 2;
+    CHECK_RESPONSE_RECEIVED = 3;
+  }
+
+  // required
+  optional int64 timestamp_ms = 1;
+
+  // required
+  optional IceCandidatePairEventType event_type = 2;
+
+  // required
+  optional uint32 candidate_pair_id = 3;
+}