Add transaction id to candidate pair event log parser and encoder.

Covered by these tests:
RandomSeeds/RtcEventLogEncoderTest.RtcEventIceCandidatePair/*
RtcEventLogTest/RtcEventLogSession.*

Bug: webrtc:9972
Change-Id: I05473176357804e7ad0dedb51a659ab9481a4e4a
Reviewed-on: https://webrtc-review.googlesource.com/c/110103
Commit-Queue: Zach Stein <zstein@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25867}
diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
index 5aa9c83..6116d8d 100644
--- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
+++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc
@@ -1390,6 +1390,7 @@
 
     proto_batch->set_event_type(ConvertToProtoFormat(base_event->type()));
     proto_batch->set_candidate_pair_id(base_event->candidate_pair_id());
+    proto_batch->set_transaction_id(base_event->transaction_id());
   }
   // TODO(terelius): Should we delta-compress this event type?
 }
diff --git a/logging/rtc_event_log/rtc_event_log2.proto b/logging/rtc_event_log/rtc_event_log2.proto
index 5ef52a6..a8f2f9d 100644
--- a/logging/rtc_event_log/rtc_event_log2.proto
+++ b/logging/rtc_event_log/rtc_event_log2.proto
@@ -572,6 +572,9 @@
 
   // required
   optional uint32 candidate_pair_id = 3;
+
+  // required
+  optional uint32 transaction_id = 4;
 }
 
 message DtlsTransportStateEvent {
diff --git a/logging/rtc_event_log/rtc_event_log_parser_new.cc b/logging/rtc_event_log/rtc_event_log_parser_new.cc
index 19decff..d0b2038 100644
--- a/logging/rtc_event_log/rtc_event_log_parser_new.cc
+++ b/logging/rtc_event_log/rtc_event_log_parser_new.cc
@@ -2393,6 +2393,8 @@
   ice_event.type = GetRuntimeIceCandidatePairEventType(proto.event_type());
   RTC_CHECK(proto.has_candidate_pair_id());
   ice_event.candidate_pair_id = proto.candidate_pair_id();
+  RTC_CHECK(proto.has_transaction_id());
+  ice_event.transaction_id = proto.transaction_id();
 
   ice_candidate_pair_events_.push_back(ice_event);
 
diff --git a/logging/rtc_event_log/rtc_event_log_parser_new.h b/logging/rtc_event_log/rtc_event_log_parser_new.h
index 49d2ae9..98d02ad 100644
--- a/logging/rtc_event_log/rtc_event_log_parser_new.h
+++ b/logging/rtc_event_log/rtc_event_log_parser_new.h
@@ -223,10 +223,12 @@
   LoggedIceCandidatePairEvent() = default;
   LoggedIceCandidatePairEvent(int64_t timestamp_us,
                               IceCandidatePairEventType type,
-                              uint32_t candidate_pair_id)
+                              uint32_t candidate_pair_id,
+                              uint32_t transaction_id)
       : timestamp_us(timestamp_us),
         type(type),
-        candidate_pair_id(candidate_pair_id) {}
+        candidate_pair_id(candidate_pair_id),
+        transaction_id(transaction_id) {}
 
   int64_t log_time_us() const { return timestamp_us; }
   int64_t log_time_ms() const { return timestamp_us / 1000; }
@@ -234,6 +236,7 @@
   int64_t timestamp_us;
   IceCandidatePairEventType type;
   uint32_t candidate_pair_id;
+  uint32_t transaction_id;
 };
 
 struct LoggedRtpPacket {
diff --git a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
index 9ee345c..249d601 100644
--- a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
+++ b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc
@@ -653,6 +653,9 @@
 
   EXPECT_EQ(original_event.type(), logged_event.type);
   EXPECT_EQ(original_event.candidate_pair_id(), logged_event.candidate_pair_id);
+  if (encoding_type_ == RtcEventLog::EncodingType::NewFormat) {
+    EXPECT_EQ(original_event.transaction_id(), logged_event.transaction_id);
+  }
 }
 
 void VerifyLoggedRtpHeader(const RtpPacket& original_header,