| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 367 } |
| 368 | 368 |
| 369 | 369 |
| 370 private: | 370 private: |
| 371 static const int kDynamicPayloadTypeMin = 96; | 371 static const int kDynamicPayloadTypeMin = 96; |
| 372 static const int kDynamicPayloadTypeMax = 127; | 372 static const int kDynamicPayloadTypeMax = 127; |
| 373 }; | 373 }; |
| 374 | 374 |
| 375 // Helper class used for finding duplicate RTP Header extension ids among | 375 // Helper class used for finding duplicate RTP Header extension ids among |
| 376 // audio and video extensions. | 376 // audio and video extensions. |
| 377 class UsedRtpHeaderExtensionIds : public UsedIds<RtpHeaderExtension> { | 377 class UsedRtpHeaderExtensionIds : public UsedIds<webrtc::RtpExtension> { |
| 378 public: | 378 public: |
| 379 UsedRtpHeaderExtensionIds() | 379 UsedRtpHeaderExtensionIds() |
| 380 : UsedIds<RtpHeaderExtension>(kLocalIdMin, kLocalIdMax) { | 380 : UsedIds<webrtc::RtpExtension>(kLocalIdMin, kLocalIdMax) {} |
| 381 } | |
| 382 | 381 |
| 383 private: | 382 private: |
| 384 // Min and Max local identifier for one-byte header extensions, per RFC5285. | 383 // Min and Max local identifier for one-byte header extensions, per RFC5285. |
| 385 static const int kLocalIdMin = 1; | 384 static const int kLocalIdMin = 1; |
| 386 static const int kLocalIdMax = 14; | 385 static const int kLocalIdMax = 14; |
| 387 }; | 386 }; |
| 388 | 387 |
| 389 static bool IsSctp(const MediaContentDescription* desc) { | 388 static bool IsSctp(const MediaContentDescription* desc) { |
| 390 return ((desc->protocol() == kMediaProtocolSctp) || | 389 return ((desc->protocol() == kMediaProtocolSctp) || |
| 391 (desc->protocol() == kMediaProtocolDtlsSctp)); | 390 (desc->protocol() == kMediaProtocolDtlsSctp)); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 } | 882 } |
| 884 | 883 |
| 885 rtx_codec.params[kCodecParamAssociatedPayloadType] = | 884 rtx_codec.params[kCodecParamAssociatedPayloadType] = |
| 886 rtc::ToString(matching_codec.id); | 885 rtc::ToString(matching_codec.id); |
| 887 used_pltypes->FindAndSetIdUsed(&rtx_codec); | 886 used_pltypes->FindAndSetIdUsed(&rtx_codec); |
| 888 offered_codecs->push_back(rtx_codec); | 887 offered_codecs->push_back(rtx_codec); |
| 889 } | 888 } |
| 890 } | 889 } |
| 891 } | 890 } |
| 892 | 891 |
| 893 | |
| 894 static bool FindByUri(const RtpHeaderExtensions& extensions, | 892 static bool FindByUri(const RtpHeaderExtensions& extensions, |
| 895 const RtpHeaderExtension& ext_to_match, | 893 const webrtc::RtpExtension& ext_to_match, |
| 896 RtpHeaderExtension* found_extension) { | 894 webrtc::RtpExtension* found_extension) { |
| 897 for (RtpHeaderExtensions::const_iterator it = extensions.begin(); | 895 for (RtpHeaderExtensions::const_iterator it = extensions.begin(); |
| 898 it != extensions.end(); ++it) { | 896 it != extensions.end(); ++it) { |
| 899 // We assume that all URIs are given in a canonical format. | 897 // We assume that all URIs are given in a canonical format. |
| 900 if (it->uri == ext_to_match.uri) { | 898 if (it->uri == ext_to_match.uri) { |
| 901 if (found_extension != NULL) { | 899 if (found_extension != NULL) { |
| 902 *found_extension = *it; | 900 *found_extension = *it; |
| 903 } | 901 } |
| 904 return true; | 902 return true; |
| 905 } | 903 } |
| 906 } | 904 } |
| 907 return false; | 905 return false; |
| 908 } | 906 } |
| 909 | 907 |
| 910 // Iterates through |offered_extensions|, adding each one to |all_extensions| | 908 // Iterates through |offered_extensions|, adding each one to |all_extensions| |
| 911 // and |used_ids|, and resolving ID conflicts. If an offered extension has the | 909 // and |used_ids|, and resolving ID conflicts. If an offered extension has the |
| 912 // same URI as one in |all_extensions|, it will re-use the same ID and won't be | 910 // same URI as one in |all_extensions|, it will re-use the same ID and won't be |
| 913 // treated as a conflict. | 911 // treated as a conflict. |
| 914 static void FindAndSetRtpHdrExtUsed(RtpHeaderExtensions* offered_extensions, | 912 static void FindAndSetRtpHdrExtUsed(RtpHeaderExtensions* offered_extensions, |
| 915 RtpHeaderExtensions* all_extensions, | 913 RtpHeaderExtensions* all_extensions, |
| 916 UsedRtpHeaderExtensionIds* used_ids) { | 914 UsedRtpHeaderExtensionIds* used_ids) { |
| 917 for (auto& extension : *offered_extensions) { | 915 for (auto& extension : *offered_extensions) { |
| 918 RtpHeaderExtension existing; | 916 webrtc::RtpExtension existing; |
| 919 if (FindByUri(*all_extensions, extension, &existing)) { | 917 if (FindByUri(*all_extensions, extension, &existing)) { |
| 920 extension.id = existing.id; | 918 extension.id = existing.id; |
| 921 } else { | 919 } else { |
| 922 used_ids->FindAndSetIdUsed(&extension); | 920 used_ids->FindAndSetIdUsed(&extension); |
| 923 all_extensions->push_back(extension); | 921 all_extensions->push_back(extension); |
| 924 } | 922 } |
| 925 } | 923 } |
| 926 } | 924 } |
| 927 | 925 |
| 928 // Adds |reference_extensions| to |offered_extensions|, while updating | 926 // Adds |reference_extensions| to |offered_extensions|, while updating |
| 929 // |all_extensions| and |used_ids|. | 927 // |all_extensions| and |used_ids|. |
| 930 static void FindRtpHdrExtsToOffer( | 928 static void FindRtpHdrExtsToOffer( |
| 931 const RtpHeaderExtensions& reference_extensions, | 929 const RtpHeaderExtensions& reference_extensions, |
| 932 RtpHeaderExtensions* offered_extensions, | 930 RtpHeaderExtensions* offered_extensions, |
| 933 RtpHeaderExtensions* all_extensions, | 931 RtpHeaderExtensions* all_extensions, |
| 934 UsedRtpHeaderExtensionIds* used_ids) { | 932 UsedRtpHeaderExtensionIds* used_ids) { |
| 935 for (auto reference_extension : reference_extensions) { | 933 for (auto reference_extension : reference_extensions) { |
| 936 if (!FindByUri(*offered_extensions, reference_extension, NULL)) { | 934 if (!FindByUri(*offered_extensions, reference_extension, NULL)) { |
| 937 RtpHeaderExtension existing; | 935 webrtc::RtpExtension existing; |
| 938 if (FindByUri(*all_extensions, reference_extension, &existing)) { | 936 if (FindByUri(*all_extensions, reference_extension, &existing)) { |
| 939 offered_extensions->push_back(existing); | 937 offered_extensions->push_back(existing); |
| 940 } else { | 938 } else { |
| 941 used_ids->FindAndSetIdUsed(&reference_extension); | 939 used_ids->FindAndSetIdUsed(&reference_extension); |
| 942 all_extensions->push_back(reference_extension); | 940 all_extensions->push_back(reference_extension); |
| 943 offered_extensions->push_back(reference_extension); | 941 offered_extensions->push_back(reference_extension); |
| 944 } | 942 } |
| 945 } | 943 } |
| 946 } | 944 } |
| 947 } | 945 } |
| 948 | 946 |
| 949 static void NegotiateRtpHeaderExtensions( | 947 static void NegotiateRtpHeaderExtensions( |
| 950 const RtpHeaderExtensions& local_extensions, | 948 const RtpHeaderExtensions& local_extensions, |
| 951 const RtpHeaderExtensions& offered_extensions, | 949 const RtpHeaderExtensions& offered_extensions, |
| 952 RtpHeaderExtensions* negotiated_extenstions) { | 950 RtpHeaderExtensions* negotiated_extenstions) { |
| 953 RtpHeaderExtensions::const_iterator ours; | 951 RtpHeaderExtensions::const_iterator ours; |
| 954 for (ours = local_extensions.begin(); | 952 for (ours = local_extensions.begin(); |
| 955 ours != local_extensions.end(); ++ours) { | 953 ours != local_extensions.end(); ++ours) { |
| 956 RtpHeaderExtension theirs; | 954 webrtc::RtpExtension theirs; |
| 957 if (FindByUri(offered_extensions, *ours, &theirs)) { | 955 if (FindByUri(offered_extensions, *ours, &theirs)) { |
| 958 // We respond with their RTP header extension id. | 956 // We respond with their RTP header extension id. |
| 959 negotiated_extenstions->push_back(theirs); | 957 negotiated_extenstions->push_back(theirs); |
| 960 } | 958 } |
| 961 } | 959 } |
| 962 } | 960 } |
| 963 | 961 |
| 964 static void StripCNCodecs(AudioCodecs* audio_codecs) { | 962 static void StripCNCodecs(AudioCodecs* audio_codecs) { |
| 965 AudioCodecs::iterator iter = audio_codecs->begin(); | 963 AudioCodecs::iterator iter = audio_codecs->begin(); |
| 966 while (iter != audio_codecs->end()) { | 964 while (iter != audio_codecs->end()) { |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2050 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2053 } | 2051 } |
| 2054 | 2052 |
| 2055 DataContentDescription* GetFirstDataContentDescription( | 2053 DataContentDescription* GetFirstDataContentDescription( |
| 2056 SessionDescription* sdesc) { | 2054 SessionDescription* sdesc) { |
| 2057 return static_cast<DataContentDescription*>( | 2055 return static_cast<DataContentDescription*>( |
| 2058 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2056 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2059 } | 2057 } |
| 2060 | 2058 |
| 2061 } // namespace cricket | 2059 } // namespace cricket |
| OLD | NEW |