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
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61

media / mojo / mojom / audio_processing_mojom_traits.h [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.
#ifndef MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_
#define MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_

#include "media/base/audio_processing.h"
#include "media/base/audio_processor_controls.h"
#include "media/mojo/mojom/audio_processing.mojom-shared.h"
#include "mojo/public/cpp/bindings/struct_traits.h"

namespace mojo {

template <>
struct StructTraits<media::mojom::AudioProcessingStatsDataView,
                    media::AudioProcessingStats> {
 public:
  static bool has_echo_return_loss(const media::AudioProcessingStats& input) {
    return input.echo_return_loss.has_value();
  }
  static double echo_return_loss(const media::AudioProcessingStats& input) {
    return input.echo_return_loss.value_or(0.0);
  }

  static bool has_echo_return_loss_enhancement(
      const media::AudioProcessingStats& input) {
    return input.echo_return_loss_enhancement.has_value();
  }
  static double echo_return_loss_enhancement(
      const media::AudioProcessingStats& input) {
    return input.echo_return_loss_enhancement.value_or(0.0);
  }

  static bool Read(media::mojom::AudioProcessingStatsDataView input,
                   media::AudioProcessingStats* out_stats);
};

template <>
struct StructTraits<media::mojom::AudioProcessingSettingsDataView,
                    media::AudioProcessingSettings> {
 public:
  static bool echo_cancellation(const media::AudioProcessingSettings& s) {
    return s.echo_cancellation;
  }
  static bool noise_suppression(const media::AudioProcessingSettings& s) {
    return s.noise_suppression;
  }
  static bool automatic_gain_control(const media::AudioProcessingSettings& s) {
    return s.automatic_gain_control;
  }
  static bool multi_channel_capture_processing(
      const media::AudioProcessingSettings& s) {
    return s.multi_channel_capture_processing;
  }
  static bool Read(media::mojom::AudioProcessingSettingsDataView input,
                   media::AudioProcessingSettings* out_settings);
};

}  // namespace mojo

#endif  // MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_