| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 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 |
| 11 #include "webrtc/api/webrtcsdp.h" | 11 #include "webrtc/api/webrtcsdp.h" |
| 12 | 12 |
| 13 #include <ctype.h> | 13 #include <ctype.h> |
| 14 #include <limits.h> | 14 #include <limits.h> |
| 15 #include <stdio.h> | 15 #include <stdio.h> |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <memory> | 18 #include <memory> |
| 19 #include <string> | 19 #include <string> |
| 20 #include <unordered_map> | 20 #include <unordered_map> |
| 21 #include <vector> | 21 #include <vector> |
| 22 | 22 |
| 23 #include "webrtc/api/jsepicecandidate.h" | 23 #include "webrtc/api/jsepicecandidate.h" |
| 24 #include "webrtc/api/jsepsessiondescription.h" | 24 #include "webrtc/api/jsepsessiondescription.h" |
| 25 #include "webrtc/base/arraysize.h" | 25 #include "webrtc/base/arraysize.h" |
| 26 #include "webrtc/base/checks.h" |
| 26 #include "webrtc/base/common.h" | 27 #include "webrtc/base/common.h" |
| 27 #include "webrtc/base/logging.h" | 28 #include "webrtc/base/logging.h" |
| 28 #include "webrtc/base/messagedigest.h" | 29 #include "webrtc/base/messagedigest.h" |
| 29 #include "webrtc/base/stringutils.h" | 30 #include "webrtc/base/stringutils.h" |
| 30 // for RtpExtension | 31 // for RtpExtension |
| 31 #include "webrtc/config.h" | 32 #include "webrtc/config.h" |
| 32 #include "webrtc/media/base/codec.h" | 33 #include "webrtc/media/base/codec.h" |
| 33 #include "webrtc/media/base/cryptoparams.h" | 34 #include "webrtc/media/base/cryptoparams.h" |
| 34 #include "webrtc/media/base/mediaconstants.h" | 35 #include "webrtc/media/base/mediaconstants.h" |
| 35 #include "webrtc/media/base/rtputils.h" | 36 #include "webrtc/media/base/rtputils.h" |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 658 |
| 658 static int GetCandidatePreferenceFromType(const std::string& type) { | 659 static int GetCandidatePreferenceFromType(const std::string& type) { |
| 659 int preference = kPreferenceUnknown; | 660 int preference = kPreferenceUnknown; |
| 660 if (type == cricket::LOCAL_PORT_TYPE) { | 661 if (type == cricket::LOCAL_PORT_TYPE) { |
| 661 preference = kPreferenceHost; | 662 preference = kPreferenceHost; |
| 662 } else if (type == cricket::STUN_PORT_TYPE) { | 663 } else if (type == cricket::STUN_PORT_TYPE) { |
| 663 preference = kPreferenceReflexive; | 664 preference = kPreferenceReflexive; |
| 664 } else if (type == cricket::RELAY_PORT_TYPE) { | 665 } else if (type == cricket::RELAY_PORT_TYPE) { |
| 665 preference = kPreferenceRelayed; | 666 preference = kPreferenceRelayed; |
| 666 } else { | 667 } else { |
| 667 ASSERT(false); | 668 RTC_NOTREACHED(); |
| 668 } | 669 } |
| 669 return preference; | 670 return preference; |
| 670 } | 671 } |
| 671 | 672 |
| 672 // Get ip and port of the default destination from the |candidates| with the | 673 // Get ip and port of the default destination from the |candidates| with the |
| 673 // given value of |component_id|. The default candidate should be the one most | 674 // given value of |component_id|. The default candidate should be the one most |
| 674 // likely to work, typically IPv4 relay. | 675 // likely to work, typically IPv4 relay. |
| 675 // RFC 5245 | 676 // RFC 5245 |
| 676 // The value of |component_id| currently supported are 1 (RTP) and 2 (RTCP). | 677 // The value of |component_id| currently supported are 1 (RTP) and 2 (RTCP). |
| 677 // TODO: Decide the default destination in webrtcsession and | 678 // TODO: Decide the default destination in webrtcsession and |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 // m=<media> <port> <proto> <fmt> | 1235 // m=<media> <port> <proto> <fmt> |
| 1235 // fmt is a list of payload type numbers that MAY be used in the session. | 1236 // fmt is a list of payload type numbers that MAY be used in the session. |
| 1236 const char* type = NULL; | 1237 const char* type = NULL; |
| 1237 if (media_type == cricket::MEDIA_TYPE_AUDIO) | 1238 if (media_type == cricket::MEDIA_TYPE_AUDIO) |
| 1238 type = kMediaTypeAudio; | 1239 type = kMediaTypeAudio; |
| 1239 else if (media_type == cricket::MEDIA_TYPE_VIDEO) | 1240 else if (media_type == cricket::MEDIA_TYPE_VIDEO) |
| 1240 type = kMediaTypeVideo; | 1241 type = kMediaTypeVideo; |
| 1241 else if (media_type == cricket::MEDIA_TYPE_DATA) | 1242 else if (media_type == cricket::MEDIA_TYPE_DATA) |
| 1242 type = kMediaTypeData; | 1243 type = kMediaTypeData; |
| 1243 else | 1244 else |
| 1244 ASSERT(false); | 1245 RTC_NOTREACHED(); |
| 1245 | 1246 |
| 1246 std::string fmt; | 1247 std::string fmt; |
| 1247 if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 1248 if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 1248 const VideoContentDescription* video_desc = | 1249 const VideoContentDescription* video_desc = |
| 1249 static_cast<const VideoContentDescription*>(media_desc); | 1250 static_cast<const VideoContentDescription*>(media_desc); |
| 1250 for (std::vector<cricket::VideoCodec>::const_iterator it = | 1251 for (std::vector<cricket::VideoCodec>::const_iterator it = |
| 1251 video_desc->codecs().begin(); | 1252 video_desc->codecs().begin(); |
| 1252 it != video_desc->codecs().end(); ++it) { | 1253 it != video_desc->codecs().end(); ++it) { |
| 1253 fmt.append(" "); | 1254 fmt.append(" "); |
| 1254 fmt.append(rtc::ToString<int>(it->id)); | 1255 fmt.append(rtc::ToString<int>(it->id)); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 if (it->type() == cricket::LOCAL_PORT_TYPE) { | 1824 if (it->type() == cricket::LOCAL_PORT_TYPE) { |
| 1824 type = kCandidateHost; | 1825 type = kCandidateHost; |
| 1825 } else if (it->type() == cricket::STUN_PORT_TYPE) { | 1826 } else if (it->type() == cricket::STUN_PORT_TYPE) { |
| 1826 type = kCandidateSrflx; | 1827 type = kCandidateSrflx; |
| 1827 } else if (it->type() == cricket::RELAY_PORT_TYPE) { | 1828 } else if (it->type() == cricket::RELAY_PORT_TYPE) { |
| 1828 type = kCandidateRelay; | 1829 type = kCandidateRelay; |
| 1829 } else if (it->type() == cricket::PRFLX_PORT_TYPE) { | 1830 } else if (it->type() == cricket::PRFLX_PORT_TYPE) { |
| 1830 type = kCandidatePrflx; | 1831 type = kCandidatePrflx; |
| 1831 // Peer reflexive candidate may be signaled for being removed. | 1832 // Peer reflexive candidate may be signaled for being removed. |
| 1832 } else { | 1833 } else { |
| 1833 ASSERT(false); | 1834 RTC_NOTREACHED(); |
| 1834 // Never write out candidates if we don't know the type. | 1835 // Never write out candidates if we don't know the type. |
| 1835 continue; | 1836 continue; |
| 1836 } | 1837 } |
| 1837 | 1838 |
| 1838 InitAttrLine(kAttributeCandidate, &os); | 1839 InitAttrLine(kAttributeCandidate, &os); |
| 1839 os << kSdpDelimiterColon | 1840 os << kSdpDelimiterColon |
| 1840 << it->foundation() << " " | 1841 << it->foundation() << " " |
| 1841 << it->component() << " " | 1842 << it->component() << " " |
| 1842 << it->protocol() << " " | 1843 << it->protocol() << " " |
| 1843 << it->priority() << " " | 1844 << it->priority() << " " |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 case cricket::MEDIA_TYPE_AUDIO: | 2243 case cricket::MEDIA_TYPE_AUDIO: |
| 2243 *content_name = cricket::CN_AUDIO; | 2244 *content_name = cricket::CN_AUDIO; |
| 2244 break; | 2245 break; |
| 2245 case cricket::MEDIA_TYPE_VIDEO: | 2246 case cricket::MEDIA_TYPE_VIDEO: |
| 2246 *content_name = cricket::CN_VIDEO; | 2247 *content_name = cricket::CN_VIDEO; |
| 2247 break; | 2248 break; |
| 2248 case cricket::MEDIA_TYPE_DATA: | 2249 case cricket::MEDIA_TYPE_DATA: |
| 2249 *content_name = cricket::CN_DATA; | 2250 *content_name = cricket::CN_DATA; |
| 2250 break; | 2251 break; |
| 2251 default: | 2252 default: |
| 2252 ASSERT(false); | 2253 RTC_NOTREACHED(); |
| 2253 break; | 2254 break; |
| 2254 } | 2255 } |
| 2255 if (!ParseContent(message, media_type, mline_index, protocol, payload_types, | 2256 if (!ParseContent(message, media_type, mline_index, protocol, payload_types, |
| 2256 pos, content_name, bundle_only, media_desc, transport, | 2257 pos, content_name, bundle_only, media_desc, transport, |
| 2257 candidates, error)) { | 2258 candidates, error)) { |
| 2258 delete media_desc; | 2259 delete media_desc; |
| 2259 return NULL; | 2260 return NULL; |
| 2260 } | 2261 } |
| 2261 // Sort the codecs according to the m-line fmt list. | 2262 // Sort the codecs according to the m-line fmt list. |
| 2262 std::unordered_map<int, int> payload_type_preferences; | 2263 std::unordered_map<int, int> payload_type_preferences; |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3224 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3225 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
| 3225 media_desc, payload_type, feedback_param); | 3226 media_desc, payload_type, feedback_param); |
| 3226 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3227 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 3227 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3228 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
| 3228 media_desc, payload_type, feedback_param); | 3229 media_desc, payload_type, feedback_param); |
| 3229 } | 3230 } |
| 3230 return true; | 3231 return true; |
| 3231 } | 3232 } |
| 3232 | 3233 |
| 3233 } // namespace webrtc | 3234 } // namespace webrtc |
| OLD | NEW |