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 return !payload.audio && _stricmp(payload.name, video_codec.plName) == 0; | 40 if (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; |
41 } | 48 } |
42 | 49 |
43 RtpUtility::Payload CreatePayloadType(const CodecInst& audio_codec) { | 50 RtpUtility::Payload CreatePayloadType(const CodecInst& audio_codec) { |
44 RtpUtility::Payload payload; | 51 RtpUtility::Payload payload; |
45 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; | 52 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; |
46 strncpy(payload.name, audio_codec.plname, RTP_PAYLOAD_NAME_SIZE - 1); | 53 strncpy(payload.name, audio_codec.plname, RTP_PAYLOAD_NAME_SIZE - 1); |
47 RTC_DCHECK_GE(audio_codec.plfreq, 1000); | 54 RTC_DCHECK_GE(audio_codec.plfreq, 1000); |
48 payload.typeSpecific.Audio.frequency = audio_codec.plfreq; | 55 payload.typeSpecific.Audio.frequency = audio_codec.plfreq; |
49 payload.typeSpecific.Audio.channels = audio_codec.channels; | 56 payload.typeSpecific.Audio.channels = audio_codec.channels; |
50 payload.typeSpecific.Audio.rate = std::max(0, audio_codec.rate); | 57 payload.typeSpecific.Audio.rate = std::max(0, audio_codec.rate); |
(...skipping 16 matching lines...) Expand all Loading... |
67 return kRtpVideoGeneric; | 74 return kRtpVideoGeneric; |
68 } | 75 } |
69 } | 76 } |
70 | 77 |
71 RtpUtility::Payload CreatePayloadType(const VideoCodec& video_codec) { | 78 RtpUtility::Payload CreatePayloadType(const VideoCodec& video_codec) { |
72 RtpUtility::Payload payload; | 79 RtpUtility::Payload payload; |
73 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; | 80 payload.name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; |
74 strncpy(payload.name, video_codec.plName, RTP_PAYLOAD_NAME_SIZE - 1); | 81 strncpy(payload.name, video_codec.plName, RTP_PAYLOAD_NAME_SIZE - 1); |
75 payload.typeSpecific.Video.videoCodecType = | 82 payload.typeSpecific.Video.videoCodecType = |
76 ConvertToRtpVideoCodecType(video_codec.codecType); | 83 ConvertToRtpVideoCodecType(video_codec.codecType); |
| 84 if (video_codec.codecType == kVideoCodecH264) |
| 85 payload.typeSpecific.Video.h264_profile = video_codec.H264().profile; |
77 payload.audio = false; | 86 payload.audio = false; |
78 return payload; | 87 return payload; |
79 } | 88 } |
80 | 89 |
81 bool IsPayloadTypeValid(int8_t payload_type) { | 90 bool IsPayloadTypeValid(int8_t payload_type) { |
82 assert(payload_type >= 0); | 91 assert(payload_type >= 0); |
83 | 92 |
84 // Sanity check. | 93 // Sanity check. |
85 switch (payload_type) { | 94 switch (payload_type) { |
86 // Reserved payload types to avoid RTCP conflicts when marker bit is set. | 95 // Reserved payload types to avoid RTCP conflicts when marker bit is set. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 const char* payload_name) const { | 388 const char* payload_name) const { |
380 rtc::CritScope cs(&crit_sect_); | 389 rtc::CritScope cs(&crit_sect_); |
381 for (const auto& it : payload_type_map_) { | 390 for (const auto& it : payload_type_map_) { |
382 if (_stricmp(it.second.name, payload_name) == 0) | 391 if (_stricmp(it.second.name, payload_name) == 0) |
383 return it.first; | 392 return it.first; |
384 } | 393 } |
385 return -1; | 394 return -1; |
386 } | 395 } |
387 | 396 |
388 } // namespace webrtc | 397 } // namespace webrtc |
OLD | NEW |