OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 const int codec2_id) { | 777 const int codec2_id) { |
778 const C* codec1 = FindCodecById(codecs1, codec1_id); | 778 const C* codec1 = FindCodecById(codecs1, codec1_id); |
779 const C* codec2 = FindCodecById(codecs2, codec2_id); | 779 const C* codec2 = FindCodecById(codecs2, codec2_id); |
780 return codec1 != nullptr && codec2 != nullptr && codec1->Matches(*codec2); | 780 return codec1 != nullptr && codec2 != nullptr && codec1->Matches(*codec2); |
781 } | 781 } |
782 | 782 |
783 template <class C> | 783 template <class C> |
784 static void NegotiateCodecs(const std::vector<C>& local_codecs, | 784 static void NegotiateCodecs(const std::vector<C>& local_codecs, |
785 const std::vector<C>& offered_codecs, | 785 const std::vector<C>& offered_codecs, |
786 std::vector<C>* negotiated_codecs) { | 786 std::vector<C>* negotiated_codecs) { |
| 787 #if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
787 for (const C& ours : local_codecs) { | 788 for (const C& ours : local_codecs) { |
788 C theirs; | 789 C theirs; |
789 // Note that we intentionally only find one matching codec for each of our | 790 // Note that we intentionally only find one matching codec for each of our |
790 // local codecs, in case the remote offer contains duplicate codecs. | 791 // local codecs, in case the remote offer contains duplicate codecs. |
791 if (FindMatchingCodec(local_codecs, offered_codecs, ours, &theirs)) { | 792 if (FindMatchingCodec(local_codecs, offered_codecs, ours, &theirs)) { |
792 C negotiated = ours; | 793 C negotiated = ours; |
793 negotiated.IntersectFeedbackParams(theirs); | 794 negotiated.IntersectFeedbackParams(theirs); |
794 if (IsRtxCodec(negotiated)) { | 795 if (IsRtxCodec(negotiated)) { |
795 const auto apt_it = | 796 const auto apt_it = |
796 theirs.params.find(kCodecParamAssociatedPayloadType); | 797 theirs.params.find(kCodecParamAssociatedPayloadType); |
(...skipping 17 matching lines...) Expand all Loading... |
814 std::unordered_map<int, int> payload_type_preferences; | 815 std::unordered_map<int, int> payload_type_preferences; |
815 int preference = static_cast<int>(offered_codecs.size() + 1); | 816 int preference = static_cast<int>(offered_codecs.size() + 1); |
816 for (const C& codec : offered_codecs) { | 817 for (const C& codec : offered_codecs) { |
817 payload_type_preferences[codec.id] = preference--; | 818 payload_type_preferences[codec.id] = preference--; |
818 } | 819 } |
819 std::sort(negotiated_codecs->begin(), negotiated_codecs->end(), | 820 std::sort(negotiated_codecs->begin(), negotiated_codecs->end(), |
820 [&payload_type_preferences](const C& a, const C& b) { | 821 [&payload_type_preferences](const C& a, const C& b) { |
821 return payload_type_preferences[a.id] > | 822 return payload_type_preferences[a.id] > |
822 payload_type_preferences[b.id]; | 823 payload_type_preferences[b.id]; |
823 }); | 824 }); |
| 825 #endif |
824 } | 826 } |
825 | 827 |
826 // Finds a codec in |codecs2| that matches |codec_to_match|, which is | 828 // Finds a codec in |codecs2| that matches |codec_to_match|, which is |
827 // a member of |codecs1|. If |codec_to_match| is an RTX codec, both | 829 // a member of |codecs1|. If |codec_to_match| is an RTX codec, both |
828 // the codecs themselves and their associated codecs must match. | 830 // the codecs themselves and their associated codecs must match. |
829 template <class C> | 831 template <class C> |
830 static bool FindMatchingCodec(const std::vector<C>& codecs1, | 832 static bool FindMatchingCodec(const std::vector<C>& codecs1, |
831 const std::vector<C>& codecs2, | 833 const std::vector<C>& codecs2, |
832 const C& codec_to_match, | 834 const C& codec_to_match, |
833 C* found_codec) { | 835 C* found_codec) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 add_legacy_(true), | 1261 add_legacy_(true), |
1260 transport_desc_factory_(transport_desc_factory) { | 1262 transport_desc_factory_(transport_desc_factory) { |
1261 } | 1263 } |
1262 | 1264 |
1263 MediaSessionDescriptionFactory::MediaSessionDescriptionFactory( | 1265 MediaSessionDescriptionFactory::MediaSessionDescriptionFactory( |
1264 ChannelManager* channel_manager, | 1266 ChannelManager* channel_manager, |
1265 const TransportDescriptionFactory* transport_desc_factory) | 1267 const TransportDescriptionFactory* transport_desc_factory) |
1266 : secure_(SEC_DISABLED), | 1268 : secure_(SEC_DISABLED), |
1267 add_legacy_(true), | 1269 add_legacy_(true), |
1268 transport_desc_factory_(transport_desc_factory) { | 1270 transport_desc_factory_(transport_desc_factory) { |
| 1271 #if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
1269 channel_manager->GetSupportedAudioSendCodecs(&audio_send_codecs_); | 1272 channel_manager->GetSupportedAudioSendCodecs(&audio_send_codecs_); |
1270 channel_manager->GetSupportedAudioReceiveCodecs(&audio_recv_codecs_); | 1273 channel_manager->GetSupportedAudioReceiveCodecs(&audio_recv_codecs_); |
1271 channel_manager->GetSupportedAudioRtpHeaderExtensions(&audio_rtp_extensions_); | 1274 channel_manager->GetSupportedAudioRtpHeaderExtensions(&audio_rtp_extensions_); |
1272 channel_manager->GetSupportedVideoCodecs(&video_codecs_); | 1275 channel_manager->GetSupportedVideoCodecs(&video_codecs_); |
1273 channel_manager->GetSupportedVideoRtpHeaderExtensions(&video_rtp_extensions_); | 1276 channel_manager->GetSupportedVideoRtpHeaderExtensions(&video_rtp_extensions_); |
1274 channel_manager->GetSupportedDataCodecs(&data_codecs_); | 1277 channel_manager->GetSupportedDataCodecs(&data_codecs_); |
1275 NegotiateCodecs(audio_recv_codecs_, audio_send_codecs_, | 1278 NegotiateCodecs(audio_recv_codecs_, audio_send_codecs_, |
1276 &audio_sendrecv_codecs_); | 1279 &audio_sendrecv_codecs_); |
| 1280 #endif |
1277 } | 1281 } |
1278 | 1282 |
1279 const AudioCodecs& MediaSessionDescriptionFactory::audio_sendrecv_codecs() | 1283 const AudioCodecs& MediaSessionDescriptionFactory::audio_sendrecv_codecs() |
1280 const { | 1284 const { |
1281 return audio_sendrecv_codecs_; | 1285 return audio_sendrecv_codecs_; |
1282 } | 1286 } |
1283 | 1287 |
1284 const AudioCodecs& MediaSessionDescriptionFactory::audio_send_codecs() const { | 1288 const AudioCodecs& MediaSessionDescriptionFactory::audio_send_codecs() const { |
1285 return audio_send_codecs_; | 1289 return audio_send_codecs_; |
1286 } | 1290 } |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2187 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
2184 } | 2188 } |
2185 | 2189 |
2186 DataContentDescription* GetFirstDataContentDescription( | 2190 DataContentDescription* GetFirstDataContentDescription( |
2187 SessionDescription* sdesc) { | 2191 SessionDescription* sdesc) { |
2188 return static_cast<DataContentDescription*>( | 2192 return static_cast<DataContentDescription*>( |
2189 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2193 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
2190 } | 2194 } |
2191 | 2195 |
2192 } // namespace cricket | 2196 } // namespace cricket |
OLD | NEW |