blob: db3990f1143bf5fffc5ff233abb837dda79b533c [file] [log] [blame]
kwibergc01c6a42016-04-28 14:23:32 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
kwiberg087bd342017-02-10 08:15:44 -080011#ifndef WEBRTC_API_AUDIO_CODECS_AUDIO_FORMAT_H_
12#define WEBRTC_API_AUDIO_CODECS_AUDIO_FORMAT_H_
kwibergc01c6a42016-04-28 14:23:32 -070013
14#include <map>
15#include <ostream>
16#include <string>
17#include <utility>
18
19namespace webrtc {
20
21// SDP specification for a single audio codec.
22// NOTE: This class is still under development and may change without notice.
23struct SdpAudioFormat {
kwiberg5178ee82016-05-03 01:39:01 -070024 using Parameters = std::map<std::string, std::string>;
25
kwibergc01c6a42016-04-28 14:23:32 -070026 SdpAudioFormat(const SdpAudioFormat&);
27 SdpAudioFormat(SdpAudioFormat&&);
28 SdpAudioFormat(const char* name, int clockrate_hz, int num_channels);
kwibergd32bf752017-01-19 07:03:59 -080029 SdpAudioFormat(const std::string& name, int clockrate_hz, int num_channels);
kwiberg5178ee82016-05-03 01:39:01 -070030 SdpAudioFormat(const char* name,
31 int clockrate_hz,
32 int num_channels,
kwibergd32bf752017-01-19 07:03:59 -080033 const Parameters& param);
34 SdpAudioFormat(const std::string& name,
35 int clockrate_hz,
36 int num_channels,
37 const Parameters& param);
kwibergc01c6a42016-04-28 14:23:32 -070038 ~SdpAudioFormat();
39
40 SdpAudioFormat& operator=(const SdpAudioFormat&);
41 SdpAudioFormat& operator=(SdpAudioFormat&&);
42
kwibergc4ccd4d2016-09-21 10:55:15 -070043 friend bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b);
44 friend bool operator!=(const SdpAudioFormat& a, const SdpAudioFormat& b) {
45 return !(a == b);
46 }
47
kwibergc01c6a42016-04-28 14:23:32 -070048 std::string name;
49 int clockrate_hz;
50 int num_channels;
51 Parameters parameters;
kwibergc01c6a42016-04-28 14:23:32 -070052};
53
54void swap(SdpAudioFormat& a, SdpAudioFormat& b);
55std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf);
56
ossu9def8002017-02-09 05:14:32 -080057// To avoid API breakage, and make the code clearer, AudioCodecSpec should not
58// be directly initializable with any flags indicating optional support. If it
59// were, these initializers would break any time a new flag was added. It's also
60// more difficult to understand:
61// AudioCodecSpec spec{{"format", 8000, 1}, true, false, false, true, true};
62// than
63// AudioCodecSpec spec({"format", 8000, 1});
64// spec.allow_comfort_noise = true;
65// spec.future_flag_b = true;
66// spec.future_flag_c = true;
ossud4e9f622016-08-18 02:01:17 -070067struct AudioCodecSpec {
ossu9def8002017-02-09 05:14:32 -080068 explicit AudioCodecSpec(const SdpAudioFormat& format);
69 explicit AudioCodecSpec(SdpAudioFormat&& format);
70 ~AudioCodecSpec() = default;
71
ossud4e9f622016-08-18 02:01:17 -070072 SdpAudioFormat format;
kwiberg087bd342017-02-10 08:15:44 -080073 bool allow_comfort_noise = true; // This codec can be used with an external
74 // comfort noise generator.
ossu9def8002017-02-09 05:14:32 -080075 bool supports_network_adaption = false; // This codec can adapt to varying
76 // network conditions.
ossud4e9f622016-08-18 02:01:17 -070077};
78
kwibergc01c6a42016-04-28 14:23:32 -070079} // namespace webrtc
80
kwiberg087bd342017-02-10 08:15:44 -080081#endif // WEBRTC_API_AUDIO_CODECS_AUDIO_FORMAT_H_