| 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 |
| 11 #include "webrtc/media/base/codec.h" | 11 #include "webrtc/media/base/codec.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 | 15 |
| 16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/common.h" |
| 17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/base/stringencode.h" | 18 #include "webrtc/base/stringencode.h" |
| 19 #include "webrtc/base/stringutils.h" | 19 #include "webrtc/base/stringutils.h" |
| 20 #include "webrtc/common_video/h264/profile_level_id.h" | 20 #include "webrtc/common_video/h264/profile_level_id.h" |
| 21 | 21 |
| 22 namespace cricket { | 22 namespace cricket { |
| 23 | 23 |
| 24 static bool IsSameH264Profile(const CodecParameterMap& params1, | 24 static bool IsSameH264Profile(const CodecParameterMap& params1, |
| 25 const CodecParameterMap& params2) { | 25 const CodecParameterMap& params2) { |
| 26 const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id = | 26 const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 void FeedbackParams::Add(const FeedbackParam& param) { | 48 void FeedbackParams::Add(const FeedbackParam& param) { |
| 49 if (param.id().empty()) { | 49 if (param.id().empty()) { |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 if (Has(param)) { | 52 if (Has(param)) { |
| 53 // Param already in |this|. | 53 // Param already in |this|. |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 params_.push_back(param); | 56 params_.push_back(param); |
| 57 RTC_CHECK(!HasDuplicateEntries()); | 57 ASSERT(!HasDuplicateEntries()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void FeedbackParams::Intersect(const FeedbackParams& from) { | 60 void FeedbackParams::Intersect(const FeedbackParams& from) { |
| 61 std::vector<FeedbackParam>::iterator iter_to = params_.begin(); | 61 std::vector<FeedbackParam>::iterator iter_to = params_.begin(); |
| 62 while (iter_to != params_.end()) { | 62 while (iter_to != params_.end()) { |
| 63 if (!from.Has(*iter_to)) { | 63 if (!from.Has(*iter_to)) { |
| 64 iter_to = params_.erase(iter_to); | 64 iter_to = params_.erase(iter_to); |
| 65 } else { | 65 } else { |
| 66 ++iter_to; | 66 ++iter_to; |
| 67 } | 67 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { | 193 webrtc::RtpCodecParameters AudioCodec::ToCodecParameters() const { |
| 194 webrtc::RtpCodecParameters codec_params = Codec::ToCodecParameters(); | 194 webrtc::RtpCodecParameters codec_params = Codec::ToCodecParameters(); |
| 195 codec_params.channels = static_cast<int>(channels); | 195 codec_params.channels = channels; |
| 196 return codec_params; | 196 return codec_params; |
| 197 } | 197 } |
| 198 | 198 |
| 199 std::string AudioCodec::ToString() const { | 199 std::string AudioCodec::ToString() const { |
| 200 std::ostringstream os; | 200 std::ostringstream os; |
| 201 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate | 201 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate |
| 202 << ":" << channels << "]"; | 202 << ":" << channels << "]"; |
| 203 return os.str(); | 203 return os.str(); |
| 204 } | 204 } |
| 205 | 205 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (CodecNamesEq(codec.name.c_str(), kH264CodecName) && | 344 if (CodecNamesEq(codec.name.c_str(), kH264CodecName) && |
| 345 !IsSameH264Profile(codec.params, supported_codec.params)) { | 345 !IsSameH264Profile(codec.params, supported_codec.params)) { |
| 346 continue; | 346 continue; |
| 347 } | 347 } |
| 348 return &supported_codec; | 348 return &supported_codec; |
| 349 } | 349 } |
| 350 return nullptr; | 350 return nullptr; |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace cricket | 353 } // namespace cricket |
| OLD | NEW |