[M120 Migration][MM] Framerate calculation
[platform/framework/web/chromium-efl.git] / media / mojo / mojom / audio_processing_mojom_traits.h
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_
5 #define MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_
6
7 #include "media/base/audio_processing.h"
8 #include "media/base/audio_processor_controls.h"
9 #include "media/mojo/mojom/audio_processing.mojom-shared.h"
10 #include "mojo/public/cpp/bindings/struct_traits.h"
11
12 namespace mojo {
13
14 template <>
15 struct StructTraits<media::mojom::AudioProcessingStatsDataView,
16                     media::AudioProcessingStats> {
17  public:
18   static bool has_echo_return_loss(const media::AudioProcessingStats& input) {
19     return input.echo_return_loss.has_value();
20   }
21   static double echo_return_loss(const media::AudioProcessingStats& input) {
22     return input.echo_return_loss.value_or(0.0);
23   }
24
25   static bool has_echo_return_loss_enhancement(
26       const media::AudioProcessingStats& input) {
27     return input.echo_return_loss_enhancement.has_value();
28   }
29   static double echo_return_loss_enhancement(
30       const media::AudioProcessingStats& input) {
31     return input.echo_return_loss_enhancement.value_or(0.0);
32   }
33
34   static bool Read(media::mojom::AudioProcessingStatsDataView input,
35                    media::AudioProcessingStats* out_stats);
36 };
37
38 template <>
39 struct StructTraits<media::mojom::AudioProcessingSettingsDataView,
40                     media::AudioProcessingSettings> {
41  public:
42   static bool echo_cancellation(const media::AudioProcessingSettings& s) {
43     return s.echo_cancellation;
44   }
45   static bool noise_suppression(const media::AudioProcessingSettings& s) {
46     return s.noise_suppression;
47   }
48   static bool transient_noise_suppression(
49       const media::AudioProcessingSettings& s) {
50     return s.transient_noise_suppression;
51   }
52   static bool automatic_gain_control(const media::AudioProcessingSettings& s) {
53     return s.automatic_gain_control;
54   }
55   static bool high_pass_filter(const media::AudioProcessingSettings& s) {
56     return s.high_pass_filter;
57   }
58   static bool multi_channel_capture_processing(
59       const media::AudioProcessingSettings& s) {
60     return s.multi_channel_capture_processing;
61   }
62   static bool stereo_mirroring(const media::AudioProcessingSettings& s) {
63     return s.stereo_mirroring;
64   }
65   static bool force_apm_creation(const media::AudioProcessingSettings& s) {
66     return s.force_apm_creation;
67   }
68   static bool Read(media::mojom::AudioProcessingSettingsDataView input,
69                    media::AudioProcessingSettings* out_settings);
70 };
71
72 }  // namespace mojo
73
74 #endif  // MEDIA_MOJO_MOJOM_AUDIO_PROCESSING_MOJOM_TRAITS_H_