| 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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 using cricket::StreamParamsVec; | 72 using cricket::StreamParamsVec; |
| 73 using cricket::TransportDescription; | 73 using cricket::TransportDescription; |
| 74 using cricket::TransportInfo; | 74 using cricket::TransportInfo; |
| 75 using cricket::VideoContentDescription; | 75 using cricket::VideoContentDescription; |
| 76 using rtc::SocketAddress; | 76 using rtc::SocketAddress; |
| 77 | 77 |
| 78 namespace cricket { | 78 namespace cricket { |
| 79 class SessionDescription; | 79 class SessionDescription; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // TODO(deadbeef): Switch to using anonymous namespace rather than declaring |
| 83 // everything "static". |
| 82 namespace webrtc { | 84 namespace webrtc { |
| 83 | 85 |
| 84 // Line type | 86 // Line type |
| 85 // RFC 4566 | 87 // RFC 4566 |
| 86 // An SDP session description consists of a number of lines of text of | 88 // An SDP session description consists of a number of lines of text of |
| 87 // the form: | 89 // the form: |
| 88 // <type>=<value> | 90 // <type>=<value> |
| 89 // where <type> MUST be exactly one case-significant character. | 91 // where <type> MUST be exactly one case-significant character. |
| 90 static const int kLinePrefixLength = 2; // Length of <type>= | 92 static const int kLinePrefixLength = 2; // Length of <type>= |
| 91 static const char kLineTypeVersion = 'v'; | 93 static const char kLineTypeVersion = 'v'; |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 if (!candidates) { | 785 if (!candidates) { |
| 784 return; | 786 return; |
| 785 } | 787 } |
| 786 const IceCandidateCollection* cc = desci.candidates(mline_index); | 788 const IceCandidateCollection* cc = desci.candidates(mline_index); |
| 787 for (size_t i = 0; i < cc->count(); ++i) { | 789 for (size_t i = 0; i < cc->count(); ++i) { |
| 788 const IceCandidateInterface* candidate = cc->at(i); | 790 const IceCandidateInterface* candidate = cc->at(i); |
| 789 candidates->push_back(candidate->candidate()); | 791 candidates->push_back(candidate->candidate()); |
| 790 } | 792 } |
| 791 } | 793 } |
| 792 | 794 |
| 795 static bool IsValidPort(int port) { |
| 796 return port >= 0 && port <= 65535; |
| 797 } |
| 798 |
| 793 std::string SdpSerialize(const JsepSessionDescription& jdesc, | 799 std::string SdpSerialize(const JsepSessionDescription& jdesc, |
| 794 bool unified_plan_sdp) { | 800 bool unified_plan_sdp) { |
| 795 const cricket::SessionDescription* desc = jdesc.description(); | 801 const cricket::SessionDescription* desc = jdesc.description(); |
| 796 if (!desc) { | 802 if (!desc) { |
| 797 return ""; | 803 return ""; |
| 798 } | 804 } |
| 799 | 805 |
| 800 std::string message; | 806 std::string message; |
| 801 | 807 |
| 802 // Session Description. | 808 // Session Description. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 const std::string& transport = fields[2]; | 1025 const std::string& transport = fields[2]; |
| 1020 uint32_t priority = 0; | 1026 uint32_t priority = 0; |
| 1021 if (!GetValueFromString(first_line, fields[3], &priority, error)) { | 1027 if (!GetValueFromString(first_line, fields[3], &priority, error)) { |
| 1022 return false; | 1028 return false; |
| 1023 } | 1029 } |
| 1024 const std::string& connection_address = fields[4]; | 1030 const std::string& connection_address = fields[4]; |
| 1025 int port = 0; | 1031 int port = 0; |
| 1026 if (!GetValueFromString(first_line, fields[5], &port, error)) { | 1032 if (!GetValueFromString(first_line, fields[5], &port, error)) { |
| 1027 return false; | 1033 return false; |
| 1028 } | 1034 } |
| 1035 if (!IsValidPort(port)) { |
| 1036 return ParseFailed(first_line, "Invalid port number.", error); |
| 1037 } |
| 1029 SocketAddress address(connection_address, port); | 1038 SocketAddress address(connection_address, port); |
| 1030 | 1039 |
| 1031 cricket::ProtocolType protocol; | 1040 cricket::ProtocolType protocol; |
| 1032 if (!StringToProto(transport.c_str(), &protocol)) { | 1041 if (!StringToProto(transport.c_str(), &protocol)) { |
| 1033 return ParseFailed(first_line, "Unsupported transport type.", error); | 1042 return ParseFailed(first_line, "Unsupported transport type.", error); |
| 1034 } | 1043 } |
| 1035 switch (protocol) { | 1044 switch (protocol) { |
| 1036 case cricket::PROTO_UDP: | 1045 case cricket::PROTO_UDP: |
| 1037 case cricket::PROTO_TCP: | 1046 case cricket::PROTO_TCP: |
| 1038 case cricket::PROTO_SSLTCP: | 1047 case cricket::PROTO_SSLTCP: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1065 related_address.SetIP(fields[++current_position]); | 1074 related_address.SetIP(fields[++current_position]); |
| 1066 ++current_position; | 1075 ++current_position; |
| 1067 } | 1076 } |
| 1068 if (fields.size() >= (current_position + 2) && | 1077 if (fields.size() >= (current_position + 2) && |
| 1069 fields[current_position] == kAttributeCandidateRport) { | 1078 fields[current_position] == kAttributeCandidateRport) { |
| 1070 int port = 0; | 1079 int port = 0; |
| 1071 if (!GetValueFromString( | 1080 if (!GetValueFromString( |
| 1072 first_line, fields[++current_position], &port, error)) { | 1081 first_line, fields[++current_position], &port, error)) { |
| 1073 return false; | 1082 return false; |
| 1074 } | 1083 } |
| 1084 if (!IsValidPort(port)) { |
| 1085 return ParseFailed(first_line, "Invalid port number.", error); |
| 1086 } |
| 1075 related_address.SetPort(port); | 1087 related_address.SetPort(port); |
| 1076 ++current_position; | 1088 ++current_position; |
| 1077 } | 1089 } |
| 1078 | 1090 |
| 1079 // If this is a TCP candidate, it has additional extension as defined in | 1091 // If this is a TCP candidate, it has additional extension as defined in |
| 1080 // RFC 6544. | 1092 // RFC 6544. |
| 1081 std::string tcptype; | 1093 std::string tcptype; |
| 1082 if (fields.size() >= (current_position + 2) && | 1094 if (fields.size() >= (current_position + 2) && |
| 1083 fields[current_position] == kTcpCandidateType) { | 1095 fields[current_position] == kTcpCandidateType) { |
| 1084 tcptype = fields[++current_position]; | 1096 tcptype = fields[++current_position]; |
| (...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3191 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3203 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
| 3192 media_desc, payload_type, feedback_param); | 3204 media_desc, payload_type, feedback_param); |
| 3193 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3205 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 3194 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3206 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
| 3195 media_desc, payload_type, feedback_param); | 3207 media_desc, payload_type, feedback_param); |
| 3196 } | 3208 } |
| 3197 return true; | 3209 return true; |
| 3198 } | 3210 } |
| 3199 | 3211 |
| 3200 } // namespace webrtc | 3212 } // namespace webrtc |
| OLD | NEW |