OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 return feedback_params.Has(param); | 142 return feedback_params.Has(param); |
143 } | 143 } |
144 | 144 |
145 void Codec::IntersectFeedbackParams(const Codec& other) { | 145 void Codec::IntersectFeedbackParams(const Codec& other) { |
146 feedback_params.Intersect(other.feedback_params); | 146 feedback_params.Intersect(other.feedback_params); |
147 } | 147 } |
148 | 148 |
149 webrtc::RtpCodecParameters Codec::ToCodecParameters() const { | 149 webrtc::RtpCodecParameters Codec::ToCodecParameters() const { |
150 webrtc::RtpCodecParameters codec_params; | 150 webrtc::RtpCodecParameters codec_params; |
151 codec_params.payload_type = id; | 151 codec_params.payload_type = id; |
152 codec_params.mime_type = name; | 152 codec_params.name = name; |
153 codec_params.clock_rate = clockrate; | 153 codec_params.clock_rate = rtc::Optional<int>(clockrate); |
154 return codec_params; | 154 return codec_params; |
155 } | 155 } |
156 | 156 |
157 AudioCodec::AudioCodec(int id, | 157 AudioCodec::AudioCodec(int id, |
158 const std::string& name, | 158 const std::string& name, |
159 int clockrate, | 159 int clockrate, |
160 int bitrate, | 160 int bitrate, |
161 size_t channels) | 161 size_t channels) |
162 : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {} | 162 : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {} |
163 | 163 |
(...skipping 19 matching lines...) Expand all Loading... |
183 // omitted if the number of channels is one." | 183 // omitted if the number of channels is one." |
184 // Preference is ignored. | 184 // Preference is ignored. |
185 // TODO(juberti): Treat a zero clockrate as 8000Hz, the RTP default clockrate. | 185 // TODO(juberti): Treat a zero clockrate as 8000Hz, the RTP default clockrate. |
186 return Codec::Matches(codec) && | 186 return Codec::Matches(codec) && |
187 ((codec.clockrate == 0 /*&& clockrate == 8000*/) || | 187 ((codec.clockrate == 0 /*&& clockrate == 8000*/) || |
188 clockrate == codec.clockrate) && | 188 clockrate == codec.clockrate) && |
189 (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && | 189 (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && |
190 ((codec.channels < 2 && channels < 2) || channels == codec.channels); | 190 ((codec.channels < 2 && channels < 2) || channels == codec.channels); |
191 } | 191 } |
192 | 192 |
193 webrtc::RtpCodecParameters AudioCodec::ToCodecParameters() const { | |
194 webrtc::RtpCodecParameters codec_params = Codec::ToCodecParameters(); | |
195 codec_params.channels = static_cast<int>(channels); | |
196 return codec_params; | |
197 } | |
198 | |
199 std::string AudioCodec::ToString() const { | 193 std::string AudioCodec::ToString() const { |
200 std::ostringstream os; | 194 std::ostringstream os; |
201 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate | 195 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate |
202 << ":" << channels << "]"; | 196 << ":" << channels << "]"; |
203 return os.str(); | 197 return os.str(); |
204 } | 198 } |
205 | 199 |
| 200 webrtc::RtpCodecParameters AudioCodec::ToCodecParameters() const { |
| 201 webrtc::RtpCodecParameters codec_params = Codec::ToCodecParameters(); |
| 202 codec_params.num_channels = rtc::Optional<int>(static_cast<int>(channels)); |
| 203 codec_params.kind = MEDIA_TYPE_AUDIO; |
| 204 return codec_params; |
| 205 } |
| 206 |
206 std::string VideoCodec::ToString() const { | 207 std::string VideoCodec::ToString() const { |
207 std::ostringstream os; | 208 std::ostringstream os; |
208 os << "VideoCodec[" << id << ":" << name << "]"; | 209 os << "VideoCodec[" << id << ":" << name << "]"; |
209 return os.str(); | 210 return os.str(); |
210 } | 211 } |
211 | 212 |
| 213 webrtc::RtpCodecParameters VideoCodec::ToCodecParameters() const { |
| 214 webrtc::RtpCodecParameters codec_params = Codec::ToCodecParameters(); |
| 215 codec_params.kind = MEDIA_TYPE_VIDEO; |
| 216 return codec_params; |
| 217 } |
| 218 |
212 VideoCodec::VideoCodec(int id, const std::string& name) | 219 VideoCodec::VideoCodec(int id, const std::string& name) |
213 : Codec(id, name, kVideoCodecClockrate) { | 220 : Codec(id, name, kVideoCodecClockrate) { |
214 SetDefaultParameters(); | 221 SetDefaultParameters(); |
215 } | 222 } |
216 | 223 |
217 VideoCodec::VideoCodec(const std::string& name) : VideoCodec(0 /* id */, name) { | 224 VideoCodec::VideoCodec(const std::string& name) : VideoCodec(0 /* id */, name) { |
218 SetDefaultParameters(); | 225 SetDefaultParameters(); |
219 } | 226 } |
220 | 227 |
221 VideoCodec::VideoCodec() : Codec() { | 228 VideoCodec::VideoCodec() : Codec() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (CodecNamesEq(codec.name.c_str(), kH264CodecName) && | 353 if (CodecNamesEq(codec.name.c_str(), kH264CodecName) && |
347 !IsSameH264Profile(codec.params, supported_codec.params)) { | 354 !IsSameH264Profile(codec.params, supported_codec.params)) { |
348 continue; | 355 continue; |
349 } | 356 } |
350 return &supported_codec; | 357 return &supported_codec; |
351 } | 358 } |
352 return nullptr; | 359 return nullptr; |
353 } | 360 } |
354 | 361 |
355 } // namespace cricket | 362 } // namespace cricket |
OLD | NEW |