OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 19 matching lines...) Expand all Loading... |
30 return false; | 30 return false; |
31 const AudioPayload& audio_payload = payload.typeSpecific.Audio; | 31 const AudioPayload& audio_payload = payload.typeSpecific.Audio; |
32 const uint32_t rate = std::max(0, audio_codec.rate); | 32 const uint32_t rate = std::max(0, audio_codec.rate); |
33 return audio_payload.frequency == static_cast<uint32_t>(audio_codec.plfreq) && | 33 return audio_payload.frequency == static_cast<uint32_t>(audio_codec.plfreq) && |
34 audio_payload.channels == audio_codec.channels && | 34 audio_payload.channels == audio_codec.channels && |
35 (audio_payload.rate == rate || audio_payload.rate == 0 || rate == 0); | 35 (audio_payload.rate == rate || audio_payload.rate == 0 || rate == 0); |
36 } | 36 } |
37 | 37 |
38 bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 38 bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
39 const VideoCodec& video_codec) { | 39 const VideoCodec& video_codec) { |
40 if (payload.audio || _stricmp(payload.name, video_codec.plName) != 0) | 40 return !payload.audio && _stricmp(payload.name, video_codec.plName) == 0; |
41 return false; | |
42 // For H264, profiles must match as well. | |
43 if (video_codec.codecType == kVideoCodecH264) { | |
44 return video_codec.H264().profile == | |
45 payload.typeSpecific.Video.h264_profile; | |
46 } | |
47 return true; | |
48 } | 41 } |
49 | 42 |
50 RtpUtility::Payload CreatePayloadType(const CodecInst& audio_codec) { | 43 RtpUtility::Payload CreatePayloadType(const CodecInst& audio_codec) { |
51 RtpUtility::Payload payload; | 44 RtpUtility::Payload payload; |
52 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; | 45 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; |
53 strncpy(payload.name, audio_codec.plname, RTP_PAYLOAD_NAME_SIZE - 1); | 46 strncpy(payload.name, audio_codec.plname, RTP_PAYLOAD_NAME_SIZE - 1); |
54 RTC_DCHECK_GE(audio_codec.plfreq, 1000); | 47 RTC_DCHECK_GE(audio_codec.plfreq, 1000); |
55 payload.typeSpecific.Audio.frequency = audio_codec.plfreq; | 48 payload.typeSpecific.Audio.frequency = audio_codec.plfreq; |
56 payload.typeSpecific.Audio.channels = audio_codec.channels; | 49 payload.typeSpecific.Audio.channels = audio_codec.channels; |
57 payload.typeSpecific.Audio.rate = std::max(0, audio_codec.rate); | 50 payload.typeSpecific.Audio.rate = std::max(0, audio_codec.rate); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 const char* payload_name) const { | 379 const char* payload_name) const { |
387 rtc::CritScope cs(&crit_sect_); | 380 rtc::CritScope cs(&crit_sect_); |
388 for (const auto& it : payload_type_map_) { | 381 for (const auto& it : payload_type_map_) { |
389 if (_stricmp(it.second.name, payload_name) == 0) | 382 if (_stricmp(it.second.name, payload_name) == 0) |
390 return it.first; | 383 return it.first; |
391 } | 384 } |
392 return -1; | 385 return -1; |
393 } | 386 } |
394 | 387 |
395 } // namespace webrtc | 388 } // namespace webrtc |
OLD | NEW |