Add AbsoluteCaptureTimeReceiver to audio ChannelReceive.

Bug: webrtc:10739
Change-Id: Ib4aeead29c8f6e605e5df5c2d14730824b10484e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167921
Reviewed-by: Chen Xing <chxg@google.com>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30516}
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc
index d0c17fb..21af710 100644
--- a/audio/channel_receive.cc
+++ b/audio/channel_receive.cc
@@ -32,6 +32,7 @@
 #include "modules/rtp_rtcp/include/receive_statistics.h"
 #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp.h"
+#include "modules/rtp_rtcp/source/absolute_capture_time_receiver.h"
 #include "modules/rtp_rtcp/source/rtp_header_extensions.h"
 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
 #include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
@@ -259,6 +260,8 @@
   // E2EE Audio Frame Decryption
   rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor_;
   webrtc::CryptoOptions crypto_options_;
+
+  webrtc::AbsoluteCaptureTimeReceiver absolute_capture_time_receiver_;
 };
 
 void ChannelReceive::OnReceivedPayloadData(
@@ -440,7 +443,8 @@
       _outputGain(1.0f),
       associated_send_channel_(nullptr),
       frame_decryptor_(frame_decryptor),
-      crypto_options_(crypto_options) {
+      crypto_options_(crypto_options),
+      absolute_capture_time_receiver_(clock) {
   // TODO(nisse): Use _moduleProcessThreadPtr instead?
   module_process_thread_checker_.Detach();
 
@@ -543,6 +547,15 @@
   RTPHeader header;
   packet_copy.GetHeader(&header);
 
+  // Interpolates absolute capture timestamp RTP header extension.
+  header.extension.absolute_capture_time =
+      absolute_capture_time_receiver_.OnReceivePacket(
+          AbsoluteCaptureTimeReceiver::GetSource(header.ssrc,
+                                                 header.arrOfCSRCs),
+          header.timestamp,
+          rtc::saturated_cast<uint32_t>(packet_copy.payload_type_frequency()),
+          header.extension.absolute_capture_time);
+
   ReceivePacket(packet_copy.data(), packet_copy.size(), header);
 }