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

Side by Side Diff: webrtc/media/base/codec.cc

Issue 1845673002: Removing `preference` field from `cricket::Codec`. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing sort order (got reversed when optimizations were made) Created 4 years, 8 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
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/base/codec_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 for (std::vector<FeedbackParam>::const_iterator found = iter + 1; 64 for (std::vector<FeedbackParam>::const_iterator found = iter + 1;
65 found != params_.end(); ++found) { 65 found != params_.end(); ++found) {
66 if (*found == *iter) { 66 if (*found == *iter) {
67 return true; 67 return true;
68 } 68 }
69 } 69 }
70 } 70 }
71 return false; 71 return false;
72 } 72 }
73 73
74 Codec::Codec(int id, const std::string& name, int clockrate, int preference) 74 Codec::Codec(int id, const std::string& name, int clockrate)
75 : id(id), name(name), clockrate(clockrate), preference(preference) { 75 : id(id), name(name), clockrate(clockrate) {}
76 }
77 76
78 Codec::Codec() : id(0), clockrate(0), preference(0) { 77 Codec::Codec() : id(0), clockrate(0) {}
79 }
80 78
81 Codec::Codec(const Codec& c) = default; 79 Codec::Codec(const Codec& c) = default;
82 80
83 Codec::~Codec() = default; 81 Codec::~Codec() = default;
84 82
85 Codec& Codec::operator=(const Codec& c) { 83 Codec& Codec::operator=(const Codec& c) {
86 this->id = c.id; // id is reserved in objective-c 84 this->id = c.id; // id is reserved in objective-c
87 name = c.name; 85 name = c.name;
88 clockrate = c.clockrate; 86 clockrate = c.clockrate;
89 preference = c.preference;
90 params = c.params; 87 params = c.params;
91 feedback_params = c.feedback_params; 88 feedback_params = c.feedback_params;
92 return *this; 89 return *this;
93 } 90 }
94 91
95 bool Codec::operator==(const Codec& c) const { 92 bool Codec::operator==(const Codec& c) const {
96 return this->id == c.id && // id is reserved in objective-c 93 return this->id == c.id && // id is reserved in objective-c
97 name == c.name && clockrate == c.clockrate && 94 name == c.name && clockrate == c.clockrate && params == c.params &&
98 preference == c.preference && params == c.params &&
99 feedback_params == c.feedback_params; 95 feedback_params == c.feedback_params;
100 } 96 }
101 97
102 bool Codec::Matches(const Codec& codec) const { 98 bool Codec::Matches(const Codec& codec) const {
103 // Match the codec id/name based on the typical static/dynamic name rules. 99 // Match the codec id/name based on the typical static/dynamic name rules.
104 // Matching is case-insensitive. 100 // Matching is case-insensitive.
105 const int kMaxStaticPayloadId = 95; 101 const int kMaxStaticPayloadId = 95;
106 return (codec.id <= kMaxStaticPayloadId) ? 102 return (codec.id <= kMaxStaticPayloadId) ?
107 (id == codec.id) : (_stricmp(name.c_str(), codec.name.c_str()) == 0); 103 (id == codec.id) : (_stricmp(name.c_str(), codec.name.c_str()) == 0);
108 } 104 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 139 }
144 140
145 void Codec::IntersectFeedbackParams(const Codec& other) { 141 void Codec::IntersectFeedbackParams(const Codec& other) {
146 feedback_params.Intersect(other.feedback_params); 142 feedback_params.Intersect(other.feedback_params);
147 } 143 }
148 144
149 AudioCodec::AudioCodec(int id, 145 AudioCodec::AudioCodec(int id,
150 const std::string& name, 146 const std::string& name,
151 int clockrate, 147 int clockrate,
152 int bitrate, 148 int bitrate,
153 size_t channels, 149 size_t channels)
154 int preference) 150 : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {}
155 : Codec(id, name, clockrate, preference),
156 bitrate(bitrate),
157 channels(channels) {
158 }
159 151
160 AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) { 152 AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) {
161 } 153 }
162 154
163 AudioCodec::AudioCodec(const AudioCodec& c) = default; 155 AudioCodec::AudioCodec(const AudioCodec& c) = default;
164 156
165 AudioCodec& AudioCodec::operator=(const AudioCodec& c) { 157 AudioCodec& AudioCodec::operator=(const AudioCodec& c) {
166 Codec::operator=(c); 158 Codec::operator=(c);
167 bitrate = c.bitrate; 159 bitrate = c.bitrate;
168 channels = c.channels; 160 channels = c.channels;
(...skipping 17 matching lines...) Expand all
186 return Codec::Matches(codec) && 178 return Codec::Matches(codec) &&
187 ((codec.clockrate == 0 /*&& clockrate == 8000*/) || 179 ((codec.clockrate == 0 /*&& clockrate == 8000*/) ||
188 clockrate == codec.clockrate) && 180 clockrate == codec.clockrate) &&
189 (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && 181 (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) &&
190 ((codec.channels < 2 && channels < 2) || channels == codec.channels); 182 ((codec.channels < 2 && channels < 2) || channels == codec.channels);
191 } 183 }
192 184
193 std::string AudioCodec::ToString() const { 185 std::string AudioCodec::ToString() const {
194 std::ostringstream os; 186 std::ostringstream os;
195 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate 187 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate
196 << ":" << channels << ":" << preference << "]"; 188 << ":" << channels << "]";
197 return os.str(); 189 return os.str();
198 } 190 }
199 191
200 std::string VideoCodec::ToString() const { 192 std::string VideoCodec::ToString() const {
201 std::ostringstream os; 193 std::ostringstream os;
202 os << "VideoCodec[" << id << ":" << name << ":" << width << ":" << height 194 os << "VideoCodec[" << id << ":" << name << ":" << width << ":" << height
203 << ":" << framerate << ":" << preference << "]"; 195 << ":" << framerate << "]";
204 return os.str(); 196 return os.str();
205 } 197 }
206 198
207 VideoCodec::VideoCodec(int id, 199 VideoCodec::VideoCodec(int id,
208 const std::string& name, 200 const std::string& name,
209 int width, 201 int width,
210 int height, 202 int height,
211 int framerate, 203 int framerate)
212 int preference) 204 : Codec(id, name, kVideoCodecClockrate),
213 : Codec(id, name, kVideoCodecClockrate, preference),
214 width(width), 205 width(width),
215 height(height), 206 height(height),
216 framerate(framerate) { 207 framerate(framerate) {}
217 }
218 208
219 VideoCodec::VideoCodec(int id, const std::string& name) 209 VideoCodec::VideoCodec(int id, const std::string& name)
220 : Codec(id, name, kVideoCodecClockrate, 0), 210 : Codec(id, name, kVideoCodecClockrate),
221 width(0), 211 width(0),
222 height(0), 212 height(0),
223 framerate(0) { 213 framerate(0) {}
224 }
225 214
226 VideoCodec::VideoCodec() : Codec(), width(0), height(0), framerate(0) { 215 VideoCodec::VideoCodec() : Codec(), width(0), height(0), framerate(0) {
227 clockrate = kVideoCodecClockrate; 216 clockrate = kVideoCodecClockrate;
228 } 217 }
229 218
230 VideoCodec::VideoCodec(const VideoCodec& c) = default; 219 VideoCodec::VideoCodec(const VideoCodec& c) = default;
231 220
232 VideoCodec& VideoCodec::operator=(const VideoCodec& c) { 221 VideoCodec& VideoCodec::operator=(const VideoCodec& c) {
233 Codec::operator=(c); 222 Codec::operator=(c);
234 width = c.width; 223 width = c.width;
235 height = c.height; 224 height = c.height;
236 framerate = c.framerate; 225 framerate = c.framerate;
237 return *this; 226 return *this;
238 } 227 }
239 228
240 bool VideoCodec::operator==(const VideoCodec& c) const { 229 bool VideoCodec::operator==(const VideoCodec& c) const {
241 return width == c.width && height == c.height && framerate == c.framerate && 230 return width == c.width && height == c.height && framerate == c.framerate &&
242 Codec::operator==(c); 231 Codec::operator==(c);
243 } 232 }
244 233
245 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, 234 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type,
246 int associated_payload_type) { 235 int associated_payload_type) {
247 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0, 0); 236 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0);
248 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); 237 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type);
249 return rtx_codec; 238 return rtx_codec;
250 } 239 }
251 240
252 VideoCodec::CodecType VideoCodec::GetCodecType() const { 241 VideoCodec::CodecType VideoCodec::GetCodecType() const {
253 const char* payload_name = name.c_str(); 242 const char* payload_name = name.c_str();
254 if (_stricmp(payload_name, kRedCodecName) == 0) { 243 if (_stricmp(payload_name, kRedCodecName) == 0) {
255 return CODEC_RED; 244 return CODEC_RED;
256 } 245 }
257 if (_stricmp(payload_name, kUlpfecCodecName) == 0) { 246 if (_stricmp(payload_name, kUlpfecCodecName) == 0) {
(...skipping 26 matching lines...) Expand all
284 if (GetParam(kCodecParamMinBitrate, &min_bitrate) && 273 if (GetParam(kCodecParamMinBitrate, &min_bitrate) &&
285 GetParam(kCodecParamMaxBitrate, &max_bitrate)) { 274 GetParam(kCodecParamMaxBitrate, &max_bitrate)) {
286 if (max_bitrate < min_bitrate) { 275 if (max_bitrate < min_bitrate) {
287 LOG(LS_ERROR) << "Codec with max < min bitrate: " << ToString(); 276 LOG(LS_ERROR) << "Codec with max < min bitrate: " << ToString();
288 return false; 277 return false;
289 } 278 }
290 } 279 }
291 return true; 280 return true;
292 } 281 }
293 282
294 DataCodec::DataCodec(int id, const std::string& name, int preference) 283 DataCodec::DataCodec(int id, const std::string& name)
295 : Codec(id, name, kDataCodecClockrate, preference) { 284 : Codec(id, name, kDataCodecClockrate) {}
296 }
297 285
298 DataCodec::DataCodec() : Codec() { 286 DataCodec::DataCodec() : Codec() {
299 clockrate = kDataCodecClockrate; 287 clockrate = kDataCodecClockrate;
300 } 288 }
301 289
302 DataCodec::DataCodec(const DataCodec& c) = default; 290 DataCodec::DataCodec(const DataCodec& c) = default;
303 291
304 DataCodec& DataCodec::operator=(const DataCodec& c) = default; 292 DataCodec& DataCodec::operator=(const DataCodec& c) = default;
305 293
306 std::string DataCodec::ToString() const { 294 std::string DataCodec::ToString() const {
(...skipping 15 matching lines...) Expand all
322 bool HasTransportCc(const Codec& codec) { 310 bool HasTransportCc(const Codec& codec) {
323 return codec.HasFeedbackParam( 311 return codec.HasFeedbackParam(
324 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); 312 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty));
325 } 313 }
326 314
327 bool CodecNamesEq(const std::string& name1, const std::string& name2) { 315 bool CodecNamesEq(const std::string& name1, const std::string& name2) {
328 return _stricmp(name1.c_str(), name2.c_str()) == 0; 316 return _stricmp(name1.c_str(), name2.c_str()) == 0;
329 } 317 }
330 318
331 } // namespace cricket 319 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/base/codec_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698