In the constructor of WebRTC VideoSendStreamParameters, why is the config argument not passed by a reference?

  c++, webrtc

In the constructor of WebRTC VideoSendStreamParameters, config argument is passed by a value(thus introducing a copy overhead), but options argument is passed by a reference.
Also the config member is initialized by std::move(config).
I want to know why they designed like this.

The followings are scrapped from Chromium source.

namespace webrtc {
...
class VideoSendStream {
  ...
  struct Config {
    ...
    Config() = delete;
    Config(Config&&);
    ... // It's followed by many data members.
  };
  ...
};
...
}



namespace cricket {
...
class WebRtcVideoChannel ... {
  ...
  class WebRtcVideoSendStream {
    ...
    struct VideoSendStreamParameters {
      VideoSendStreamParameters(
          webrtc::VideoSendStream::Config config,
          const VideoOptions& options, ...)
      ...
      webrtc::VideoSendStream::Config config;
      ...
    };
    VideoSendStreamParameters parameters_ ... ;
    ...
  };
  ...
};

WebRtcVideoChannel::WebRtcVideoSendStream::VideoSendStreamParameters::
    VideoSendStreamParameters(
        webrtc::VideoSendStream::Config config,
        const VideoOptions& options, ...)
    : config(std::move(config)),
      options(options), ... {}

WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream(
    ...
    webrtc::VideoSendStream::Config config,
    const VideoOptions& options, ...)
    : ...,
      parameters_(std::move(config), options, ...), ...
{
  ...  
}
...
}

Source: Windows Questions C++

LEAVE A COMMENT