1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39

media / mojo / mojom / audio_processing_mojom_traits.cc [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/mojo/mojom/audio_processing_mojom_traits.h"

namespace mojo {
namespace {
// Deserializes has_field and field into a std::optional.
#define DESERIALIZE_INTO_OPT(field) \
  if (input.has_##field())          \
  out_stats->field = input.field()
}  // namespace

// static
bool StructTraits<media::mojom::AudioProcessingStatsDataView,
                  media::AudioProcessingStats>::
    Read(media::mojom::AudioProcessingStatsDataView input,
         media::AudioProcessingStats* out_stats) {
  DESERIALIZE_INTO_OPT(echo_return_loss);
  DESERIALIZE_INTO_OPT(echo_return_loss_enhancement);
  return true;
}

// static
bool StructTraits<media::mojom::AudioProcessingSettingsDataView,
                  media::AudioProcessingSettings>::
    Read(media::mojom::AudioProcessingSettingsDataView input,
         media::AudioProcessingSettings* out_settings) {
  *out_settings = media::AudioProcessingSettings();
  out_settings->echo_cancellation = input.echo_cancellation();
  out_settings->noise_suppression = input.noise_suppression();
  out_settings->automatic_gain_control = input.automatic_gain_control();
  out_settings->multi_channel_capture_processing =
      input.multi_channel_capture_processing();
  return true;
}

}  // namespace mojo