Source code
Revision control
Copy as Markdown
Other Tools
From: Dan Baker <dbaker@mozilla.com>
Date: Thu, 10 Sep 2026 15:49:00 -0600
AudioReceiveStreamInterface::Config.Copy() with move-only on_first_packet
Config::Copy() relied on a defaulted copy constructor, which upstream's
addition of the move-only on_first_packet AnyInvocable member (in
44d3a8877e) implicitly deletes. Rewrite Copy() to construct a fresh
Config and copy each field explicitly, skipping on_first_packet, the
same approach already used by VideoReceiveStreamInterface::Config::Copy()
for the same member.
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/52a4da6f2223f0283ef67f2d6e5835b136c4db33
---
call/audio_receive_stream.cc | 22 +++++++++++++++++++++-
call/audio_receive_stream.h | 9 +++------
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/call/audio_receive_stream.cc b/call/audio_receive_stream.cc
index c8e818a1d0..fb0533d976 100644
--- a/call/audio_receive_stream.cc
+++ b/call/audio_receive_stream.cc
@@ -16,12 +16,32 @@ AudioReceiveStreamInterface::Stats::Stats() = default;
AudioReceiveStreamInterface::Stats::~Stats() = default;
AudioReceiveStreamInterface::Config::Config() = default;
-AudioReceiveStreamInterface::Config::Config(const Config&) = default;
AudioReceiveStreamInterface::Config::Config(Config&&) = default;
AudioReceiveStreamInterface::Config&
AudioReceiveStreamInterface::Config::operator=(Config&&) = default;
AudioReceiveStreamInterface::Config::~Config() = default;
+AudioReceiveStreamInterface::Config AudioReceiveStreamInterface::Config::Copy()
+ const {
+ AudioReceiveStreamInterface::Config config_copy;
+ config_copy.rtp = rtp;
+ config_copy.enable_non_sender_rtt = enable_non_sender_rtt;
+ config_copy.rtcp_send_transport = rtcp_send_transport;
+ config_copy.jitter_buffer_max_packets = jitter_buffer_max_packets;
+ config_copy.jitter_buffer_fast_accelerate = jitter_buffer_fast_accelerate;
+ config_copy.jitter_buffer_min_delay_ms = jitter_buffer_min_delay_ms;
+ config_copy.sync_group = sync_group;
+ config_copy.decoder_map = decoder_map;
+ config_copy.decoder_factory = decoder_factory;
+ config_copy.codec_pair_id = codec_pair_id;
+ config_copy.crypto_options = crypto_options;
+ config_copy.frame_decryptor = frame_decryptor;
+ config_copy.frame_transformer = frame_transformer;
+ // Note: `on_first_packet` is a one-shot move-only callback.
+ // It is moved out during construction and should not be copied.
+ return config_copy;
+}
+
AudioReceiveStreamInterface::Config::Rtp::Rtp() = default;
AudioReceiveStreamInterface::Config::Rtp::~Rtp() = default;
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index 757ea3be88..812b1444ef 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -121,20 +121,17 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
int round_trip_time_measurements = 0;
};
struct Config {
- private:
- // Access to the copy constructor is private to force use of the Copy()
- // method for those exceptional cases where we do use it.
- Config(const Config&);
-
public:
Config();
+ Config(const Config&) = delete;
Config& operator=(const Config&) = delete;
Config(Config&&);
Config& operator=(Config&&);
~Config();
// Mostly used by tests. Avoid creating copies if you can.
- Config Copy() const { return Config(*this); }
+ // Note that this method will not copy move-only fields.
+ Config Copy() const;
std::string ToString() const;