OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
900 if (it->uri == ext_to_match.uri) { | 900 if (it->uri == ext_to_match.uri) { |
901 if (found_extension != NULL) { | 901 if (found_extension != NULL) { |
902 *found_extension = *it; | 902 *found_extension = *it; |
903 } | 903 } |
904 return true; | 904 return true; |
905 } | 905 } |
906 } | 906 } |
907 return false; | 907 return false; |
908 } | 908 } |
909 | 909 |
910 static void FindAndSetRtpHdrExtUsed( | 910 // Iterates through |offered_extensions|, adding each one to |all_extensions| |
911 const RtpHeaderExtensions& reference_extensions, | 911 // and |used_ids|, and resolving ID conflicts. If an offered extension has the |
912 RtpHeaderExtensions* offered_extensions, | 912 // same URI as one in |all_extensions|, it will re-use the same ID and won't be |
913 const RtpHeaderExtensions& other_extensions, | 913 // treated as a conflict. |
914 UsedRtpHeaderExtensionIds* used_extensions) { | 914 static void FindAndSetRtpHdrExtUsed(RtpHeaderExtensions* offered_extensions, |
915 for (RtpHeaderExtensions::const_iterator it = reference_extensions.begin(); | 915 RtpHeaderExtensions* all_extensions, |
916 it != reference_extensions.end(); ++it) { | 916 UsedRtpHeaderExtensionIds* used_ids) { |
917 if (!FindByUri(*offered_extensions, *it, NULL)) { | 917 for (auto& extension : *offered_extensions) { |
918 RtpHeaderExtension ext; | 918 RtpHeaderExtension existing; |
919 if (!FindByUri(other_extensions, *it, &ext)) { | 919 if (FindByUri(*all_extensions, extension, &existing)) { |
920 ext = *it; | 920 extension.id = existing.id; |
921 used_extensions->FindAndSetIdUsed(&ext); | 921 } else { |
922 } | 922 used_ids->FindAndSetIdUsed(&extension); |
923 offered_extensions->push_back(ext); | 923 all_extensions->push_back(extension); |
924 } | 924 } |
925 } | 925 } |
926 } | 926 } |
927 | |
928 // Adds |reference_extensions| to |offered_extensions|, while updating | |
929 // |all_extensions| and |used_ids|. | |
930 static void FindRtpHdrExtsToOffer( | |
931 const RtpHeaderExtensions& reference_extensions, | |
932 RtpHeaderExtensions* offered_extensions, | |
933 RtpHeaderExtensions* all_extensions, | |
934 UsedRtpHeaderExtensionIds* used_ids) { | |
935 for (auto reference_extension : reference_extensions) { | |
pthatcher1
2015/08/18 20:33:12
Can't it be "const auto&" instead of auto?
Taylor Brandstetter
2015/08/18 20:55:06
No, because FindAndSetIdUsed modifies the id, and
| |
936 if (!FindByUri(*offered_extensions, reference_extension, NULL)) { | |
937 RtpHeaderExtension existing; | |
938 if (FindByUri(*all_extensions, reference_extension, &existing)) { | |
939 offered_extensions->push_back(existing); | |
940 } else { | |
941 used_ids->FindAndSetIdUsed(&reference_extension); | |
942 all_extensions->push_back(reference_extension); | |
943 offered_extensions->push_back(reference_extension); | |
944 } | |
945 } | |
946 } | |
947 } | |
927 | 948 |
928 static void NegotiateRtpHeaderExtensions( | 949 static void NegotiateRtpHeaderExtensions( |
929 const RtpHeaderExtensions& local_extensions, | 950 const RtpHeaderExtensions& local_extensions, |
930 const RtpHeaderExtensions& offered_extensions, | 951 const RtpHeaderExtensions& offered_extensions, |
931 RtpHeaderExtensions* negotiated_extenstions) { | 952 RtpHeaderExtensions* negotiated_extenstions) { |
932 RtpHeaderExtensions::const_iterator ours; | 953 RtpHeaderExtensions::const_iterator ours; |
933 for (ours = local_extensions.begin(); | 954 for (ours = local_extensions.begin(); |
934 ours != local_extensions.end(); ++ours) { | 955 ours != local_extensions.end(); ++ours) { |
935 RtpHeaderExtension theirs; | 956 RtpHeaderExtension theirs; |
936 if (FindByUri(offered_extensions, *ours, &theirs)) { | 957 if (FindByUri(offered_extensions, *ours, &theirs)) { |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 FindCodecsToOffer<DataCodec>(data_codecs_, data_codecs, &used_pltypes); | 1412 FindCodecsToOffer<DataCodec>(data_codecs_, data_codecs, &used_pltypes); |
1392 } | 1413 } |
1393 | 1414 |
1394 void MediaSessionDescriptionFactory::GetRtpHdrExtsToOffer( | 1415 void MediaSessionDescriptionFactory::GetRtpHdrExtsToOffer( |
1395 const SessionDescription* current_description, | 1416 const SessionDescription* current_description, |
1396 RtpHeaderExtensions* audio_extensions, | 1417 RtpHeaderExtensions* audio_extensions, |
1397 RtpHeaderExtensions* video_extensions) const { | 1418 RtpHeaderExtensions* video_extensions) const { |
1398 // All header extensions allocated from the same range to avoid potential | 1419 // All header extensions allocated from the same range to avoid potential |
1399 // issues when using BUNDLE. | 1420 // issues when using BUNDLE. |
1400 UsedRtpHeaderExtensionIds used_ids; | 1421 UsedRtpHeaderExtensionIds used_ids; |
1422 RtpHeaderExtensions all_extensions; | |
1401 audio_extensions->clear(); | 1423 audio_extensions->clear(); |
1402 video_extensions->clear(); | 1424 video_extensions->clear(); |
1403 | 1425 |
1404 // First - get all extensions from the current description if the media type | 1426 // First - get all extensions from the current description if the media type |
1405 // is used. | 1427 // is used. |
1406 // Add them to |used_ids| so the local ids are not reused if a new media | 1428 // Add them to |used_ids| so the local ids are not reused if a new media |
1407 // type is added. | 1429 // type is added. |
1408 if (current_description) { | 1430 if (current_description) { |
1409 const AudioContentDescription* audio = | 1431 const AudioContentDescription* audio = |
1410 GetFirstAudioContentDescription(current_description); | 1432 GetFirstAudioContentDescription(current_description); |
1411 if (audio) { | 1433 if (audio) { |
1412 *audio_extensions = audio->rtp_header_extensions(); | 1434 *audio_extensions = audio->rtp_header_extensions(); |
1413 used_ids.FindAndSetIdUsed(audio_extensions); | 1435 FindAndSetRtpHdrExtUsed(audio_extensions, &all_extensions, &used_ids); |
1414 } | 1436 } |
1415 const VideoContentDescription* video = | 1437 const VideoContentDescription* video = |
1416 GetFirstVideoContentDescription(current_description); | 1438 GetFirstVideoContentDescription(current_description); |
1417 if (video) { | 1439 if (video) { |
1418 *video_extensions = video->rtp_header_extensions(); | 1440 *video_extensions = video->rtp_header_extensions(); |
1419 used_ids.FindAndSetIdUsed(video_extensions); | 1441 FindAndSetRtpHdrExtUsed(video_extensions, &all_extensions, &used_ids); |
1420 } | 1442 } |
1421 } | 1443 } |
1422 | 1444 |
1423 // Add our default RTP header extensions that are not in | 1445 // Add our default RTP header extensions that are not in |
1424 // |current_description|. | 1446 // |current_description|. |
1425 FindAndSetRtpHdrExtUsed(audio_rtp_header_extensions(), audio_extensions, | 1447 FindRtpHdrExtsToOffer(audio_rtp_header_extensions(), audio_extensions, |
1426 *video_extensions, &used_ids); | 1448 &all_extensions, &used_ids); |
1427 FindAndSetRtpHdrExtUsed(video_rtp_header_extensions(), video_extensions, | 1449 FindRtpHdrExtsToOffer(video_rtp_header_extensions(), video_extensions, |
1428 *audio_extensions, &used_ids); | 1450 &all_extensions, &used_ids); |
1429 } | 1451 } |
1430 | 1452 |
1431 bool MediaSessionDescriptionFactory::AddTransportOffer( | 1453 bool MediaSessionDescriptionFactory::AddTransportOffer( |
1432 const std::string& content_name, | 1454 const std::string& content_name, |
1433 const TransportOptions& transport_options, | 1455 const TransportOptions& transport_options, |
1434 const SessionDescription* current_desc, | 1456 const SessionDescription* current_desc, |
1435 SessionDescription* offer_desc) const { | 1457 SessionDescription* offer_desc) const { |
1436 if (!transport_desc_factory_) | 1458 if (!transport_desc_factory_) |
1437 return false; | 1459 return false; |
1438 const TransportDescription* current_tdesc = | 1460 const TransportDescription* current_tdesc = |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1947 } else if (channel_name == GICE_CHANNEL_NAME_DATA_RTP || | 1969 } else if (channel_name == GICE_CHANNEL_NAME_DATA_RTP || |
1948 channel_name == GICE_CHANNEL_NAME_DATA_RTCP) { | 1970 channel_name == GICE_CHANNEL_NAME_DATA_RTCP) { |
1949 *media_type = MEDIA_TYPE_DATA; | 1971 *media_type = MEDIA_TYPE_DATA; |
1950 return true; | 1972 return true; |
1951 } | 1973 } |
1952 | 1974 |
1953 return false; | 1975 return false; |
1954 } | 1976 } |
1955 | 1977 |
1956 } // namespace cricket | 1978 } // namespace cricket |
OLD | NEW |