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
62
63
64
65
66
67
media / mojo / mojom / audio_encoder_config_mojom_traits.h [blame]
// Copyright 2021 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_ENCODER_CONFIG_MOJOM_TRAITS_H_
#define MEDIA_MOJO_MOJOM_AUDIO_ENCODER_CONFIG_MOJOM_TRAITS_H_
#include "media/base/audio_encoder.h"
#include "media/base/ipc/media_param_traits.h"
#include "media/mojo/mojom/audio_encoder.mojom-shared.h"
#include "media/mojo/mojom/media_types.mojom.h"
namespace mojo {
template <>
struct EnumTraits<media::mojom::AacOutputFormat,
media::AudioEncoder::AacOutputFormat> {
static media::mojom::AacOutputFormat ToMojom(
media::AudioEncoder::AacOutputFormat input);
static bool FromMojom(media::mojom::AacOutputFormat,
media::AudioEncoder::AacOutputFormat* output);
};
template <>
struct StructTraits<media::mojom::AacAudioEncoderConfigDataView,
media::AudioEncoder::AacOptions> {
static media::AudioEncoder::AacOutputFormat format(
media::AudioEncoder::AacOptions& input) {
return input.format;
}
static bool Read(media::mojom::AacAudioEncoderConfigDataView input,
media::AudioEncoder::AacOptions* output);
};
template <>
struct StructTraits<media::mojom::AudioEncoderConfigDataView,
media::AudioEncoderConfig> {
static media::AudioCodec codec(const media::AudioEncoderConfig& input) {
return input.codec;
}
static uint8_t channel_count(const media::AudioEncoderConfig& input) {
return input.channels;
}
static uint32_t sample_rate(const media::AudioEncoderConfig& input) {
return input.sample_rate;
}
static uint32_t bitrate(const media::AudioEncoderConfig& input) {
return input.bitrate.value_or(0);
}
static media::AudioEncoder::AacOptions aac(
const media::AudioEncoderConfig& input) {
return input.aac.value_or(media::AudioEncoder::AacOptions());
}
static bool Read(media::mojom::AudioEncoderConfigDataView input,
media::AudioEncoderConfig* output);
};
} // namespace mojo
#endif // MEDIA_MOJO_MOJOM_AUDIO_ENCODER_CONFIG_MOJOM_TRAITS_H_