Line data Source code
1 : /*
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 :
11 : #include "webrtc/modules/audio_coding/codecs/audio_format.h"
12 :
13 : #include "webrtc/common_types.h"
14 :
15 : namespace webrtc {
16 :
17 : SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
18 : SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
19 :
20 0 : SdpAudioFormat::SdpAudioFormat(const char* name,
21 : int clockrate_hz,
22 0 : int num_channels)
23 0 : : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
24 :
25 0 : SdpAudioFormat::SdpAudioFormat(const char* name,
26 : int clockrate_hz,
27 : int num_channels,
28 0 : Parameters&& param)
29 : : name(name),
30 : clockrate_hz(clockrate_hz),
31 : num_channels(num_channels),
32 0 : parameters(std::move(param)) {}
33 :
34 : SdpAudioFormat::~SdpAudioFormat() = default;
35 : SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
36 : SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
37 :
38 0 : bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) {
39 0 : return STR_CASE_CMP(a.name.c_str(), b.name.c_str()) == 0 &&
40 0 : a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels &&
41 0 : a.parameters == b.parameters;
42 : }
43 :
44 0 : void swap(SdpAudioFormat& a, SdpAudioFormat& b) {
45 : using std::swap;
46 0 : swap(a.name, b.name);
47 0 : swap(a.clockrate_hz, b.clockrate_hz);
48 0 : swap(a.num_channels, b.num_channels);
49 0 : swap(a.parameters, b.parameters);
50 0 : }
51 :
52 0 : std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) {
53 0 : os << "{name: " << saf.name;
54 0 : os << ", clockrate_hz: " << saf.clockrate_hz;
55 0 : os << ", num_channels: " << saf.num_channels;
56 0 : os << ", parameters: {";
57 0 : const char* sep = "";
58 0 : for (const auto& kv : saf.parameters) {
59 0 : os << sep << kv.first << ": " << kv.second;
60 0 : sep = ", ";
61 : }
62 0 : os << "}}";
63 0 : return os;
64 : }
65 :
66 : } // namespace webrtc
|