OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/audio_coding/codecs/audio_format.h" | 11 #include "webrtc/modules/audio_coding/codecs/audio_format.h" |
12 | 12 |
| 13 #include "webrtc/common_types.h" |
| 14 |
13 namespace webrtc { | 15 namespace webrtc { |
14 | 16 |
15 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default; | 17 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default; |
16 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default; | 18 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default; |
17 | 19 |
18 SdpAudioFormat::SdpAudioFormat(const char* name, | 20 SdpAudioFormat::SdpAudioFormat(const char* name, |
19 int clockrate_hz, | 21 int clockrate_hz, |
20 int num_channels) | 22 int num_channels) |
21 : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {} | 23 : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {} |
22 | 24 |
23 SdpAudioFormat::SdpAudioFormat(const char* name, | 25 SdpAudioFormat::SdpAudioFormat(const char* name, |
24 int clockrate_hz, | 26 int clockrate_hz, |
25 int num_channels, | 27 int num_channels, |
26 Parameters&& param) | 28 Parameters&& param) |
27 : name(name), | 29 : name(name), |
28 clockrate_hz(clockrate_hz), | 30 clockrate_hz(clockrate_hz), |
29 num_channels(num_channels), | 31 num_channels(num_channels), |
30 parameters(std::move(param)) {} | 32 parameters(std::move(param)) {} |
31 | 33 |
32 SdpAudioFormat::~SdpAudioFormat() = default; | 34 SdpAudioFormat::~SdpAudioFormat() = default; |
33 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default; | 35 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default; |
34 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default; | 36 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default; |
35 | 37 |
| 38 bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) { |
| 39 return STR_CASE_CMP(a.name.c_str(), b.name.c_str()) == 0 && |
| 40 a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels && |
| 41 a.parameters == b.parameters; |
| 42 } |
| 43 |
36 void swap(SdpAudioFormat& a, SdpAudioFormat& b) { | 44 void swap(SdpAudioFormat& a, SdpAudioFormat& b) { |
37 using std::swap; | 45 using std::swap; |
38 swap(a.name, b.name); | 46 swap(a.name, b.name); |
39 swap(a.clockrate_hz, b.clockrate_hz); | 47 swap(a.clockrate_hz, b.clockrate_hz); |
40 swap(a.num_channels, b.num_channels); | 48 swap(a.num_channels, b.num_channels); |
41 swap(a.parameters, b.parameters); | 49 swap(a.parameters, b.parameters); |
42 } | 50 } |
43 | 51 |
44 std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) { | 52 std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) { |
45 os << "{name: " << saf.name; | 53 os << "{name: " << saf.name; |
46 os << ", clockrate_hz: " << saf.clockrate_hz; | 54 os << ", clockrate_hz: " << saf.clockrate_hz; |
47 os << ", num_channels: " << saf.num_channels; | 55 os << ", num_channels: " << saf.num_channels; |
48 os << ", parameters: {"; | 56 os << ", parameters: {"; |
49 const char* sep = ""; | 57 const char* sep = ""; |
50 for (const auto& kv : saf.parameters) { | 58 for (const auto& kv : saf.parameters) { |
51 os << sep << kv.first << ": " << kv.second; | 59 os << sep << kv.first << ": " << kv.second; |
52 sep = ", "; | 60 sep = ", "; |
53 } | 61 } |
54 os << "}}"; | 62 os << "}}"; |
55 return os; | 63 return os; |
56 } | 64 } |
57 | 65 |
58 } // namespace webrtc | 66 } // namespace webrtc |
OLD | NEW |