Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_format.cc

Issue 2072753002: WebRtcVoiceEngine: Use AudioDecoderFactory to generate recv codecs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() = default; 17 SdpAudioFormat::SdpAudioFormat() = default;
16 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default; 18 SdpAudioFormat::SdpAudioFormat(const SdpAudioFormat&) = default;
17 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default; 19 SdpAudioFormat::SdpAudioFormat(SdpAudioFormat&&) = default;
18 20
19 SdpAudioFormat::SdpAudioFormat(const char* name, 21 SdpAudioFormat::SdpAudioFormat(const char* name,
20 int clockrate_hz, 22 int clockrate_hz,
21 int num_channels) 23 int num_channels)
22 : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {} 24 : name(name), clockrate_hz(clockrate_hz), num_channels(num_channels) {}
23 25
24 SdpAudioFormat::SdpAudioFormat(const char* name, 26 SdpAudioFormat::SdpAudioFormat(const char* name,
25 int clockrate_hz, 27 int clockrate_hz,
26 int num_channels, 28 int num_channels,
27 Parameters&& param) 29 Parameters&& param)
28 : name(name), 30 : name(name),
29 clockrate_hz(clockrate_hz), 31 clockrate_hz(clockrate_hz),
30 num_channels(num_channels), 32 num_channels(num_channels),
31 parameters(std::move(param)) {} 33 parameters(std::move(param)) {}
32 34
33 SdpAudioFormat::~SdpAudioFormat() = default; 35 SdpAudioFormat::~SdpAudioFormat() = default;
34 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default; 36 SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default;
35 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default; 37 SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default;
36 38
39 bool SdpAudioFormat::operator<(const SdpAudioFormat& b) const {
40 if (clockrate_hz == b.clockrate_hz) {
41 if (num_channels == b.num_channels) {
42 int name_cmp = STR_CASE_CMP(name.c_str(), b.name.c_str());
43 if (name_cmp == 0)
44 return parameters < b.parameters;
45 return name_cmp < 0;
46 }
47 return num_channels < b.num_channels;
48 }
49 return clockrate_hz < b.clockrate_hz;
50 }
51
37 void swap(SdpAudioFormat& a, SdpAudioFormat& b) { 52 void swap(SdpAudioFormat& a, SdpAudioFormat& b) {
38 using std::swap; 53 using std::swap;
39 swap(a.name, b.name); 54 swap(a.name, b.name);
40 swap(a.clockrate_hz, b.clockrate_hz); 55 swap(a.clockrate_hz, b.clockrate_hz);
41 swap(a.num_channels, b.num_channels); 56 swap(a.num_channels, b.num_channels);
42 swap(a.parameters, b.parameters); 57 swap(a.parameters, b.parameters);
43 } 58 }
44 59
45 std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) { 60 std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) {
46 os << "{name: " << saf.name; 61 os << "{name: " << saf.name;
47 os << ", clockrate_hz: " << saf.clockrate_hz; 62 os << ", clockrate_hz: " << saf.clockrate_hz;
48 os << ", num_channels: " << saf.num_channels; 63 os << ", num_channels: " << saf.num_channels;
49 os << ", parameters: {"; 64 os << ", parameters: {";
50 const char* sep = ""; 65 const char* sep = "";
51 for (const auto& kv : saf.parameters) { 66 for (const auto& kv : saf.parameters) {
52 os << sep << kv.first << ": " << kv.second; 67 os << sep << kv.first << ": " << kv.second;
53 sep = ", "; 68 sep = ", ";
54 } 69 }
55 os << "}}"; 70 os << "}}";
56 return os; 71 return os;
57 } 72 }
58 73
59 } // namespace webrtc 74 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698