Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: webrtc/pc/webrtcsdp.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 cricket::IsValidRtpPayloadType(*payload_type); 570 cricket::IsValidRtpPayloadType(*payload_type);
571 } 571 }
572 572
573 // |msid_stream_id| and |msid_track_id| represent the stream/track ID from the 573 // |msid_stream_id| and |msid_track_id| represent the stream/track ID from the
574 // "a=msid" attribute, if it exists. They are empty if the attribute does not 574 // "a=msid" attribute, if it exists. They are empty if the attribute does not
575 // exist. 575 // exist.
576 void CreateTracksFromSsrcInfos(const SsrcInfoVec& ssrc_infos, 576 void CreateTracksFromSsrcInfos(const SsrcInfoVec& ssrc_infos,
577 const std::string& msid_stream_id, 577 const std::string& msid_stream_id,
578 const std::string& msid_track_id, 578 const std::string& msid_track_id,
579 StreamParamsVec* tracks) { 579 StreamParamsVec* tracks) {
580 RTC_DCHECK(tracks != NULL); 580 RTC_DCHECK(tracks != nullptr);
581 RTC_DCHECK(msid_stream_id.empty() == msid_track_id.empty()); 581 RTC_DCHECK(msid_stream_id.empty() == msid_track_id.empty());
582 for (SsrcInfoVec::const_iterator ssrc_info = ssrc_infos.begin(); 582 for (SsrcInfoVec::const_iterator ssrc_info = ssrc_infos.begin();
583 ssrc_info != ssrc_infos.end(); ++ssrc_info) { 583 ssrc_info != ssrc_infos.end(); ++ssrc_info) {
584 if (ssrc_info->cname.empty()) { 584 if (ssrc_info->cname.empty()) {
585 continue; 585 continue;
586 } 586 }
587 587
588 std::string stream_id; 588 std::string stream_id;
589 std::string track_id; 589 std::string track_id;
590 if (ssrc_info->stream_id.empty() && !ssrc_info->mslabel.empty()) { 590 if (ssrc_info->stream_id.empty() && !ssrc_info->mslabel.empty()) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 AddLine(kSessionName, &message); 824 AddLine(kSessionName, &message);
825 825
826 // Time Description. 826 // Time Description.
827 AddLine(kTimeDescription, &message); 827 AddLine(kTimeDescription, &message);
828 828
829 // Group 829 // Group
830 if (desc->HasGroup(cricket::GROUP_TYPE_BUNDLE)) { 830 if (desc->HasGroup(cricket::GROUP_TYPE_BUNDLE)) {
831 std::string group_line = kAttrGroup; 831 std::string group_line = kAttrGroup;
832 const cricket::ContentGroup* group = 832 const cricket::ContentGroup* group =
833 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); 833 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
834 RTC_DCHECK(group != NULL); 834 RTC_DCHECK(group != nullptr);
835 const cricket::ContentNames& content_names = group->content_names(); 835 const cricket::ContentNames& content_names = group->content_names();
836 for (cricket::ContentNames::const_iterator it = content_names.begin(); 836 for (cricket::ContentNames::const_iterator it = content_names.begin();
837 it != content_names.end(); ++it) { 837 it != content_names.end(); ++it) {
838 group_line.append(" "); 838 group_line.append(" ");
839 group_line.append(*it); 839 group_line.append(*it);
840 } 840 }
841 AddLine(group_line, &message); 841 AddLine(group_line, &message);
842 } 842 }
843 843
844 // MediaStream semantics 844 // MediaStream semantics
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 it = candidates.begin(); it != candidates.end(); ++it) { 931 it = candidates.begin(); it != candidates.end(); ++it) {
932 jdesc->AddCandidate(*it); 932 jdesc->AddCandidate(*it);
933 delete *it; 933 delete *it;
934 } 934 }
935 return true; 935 return true;
936 } 936 }
937 937
938 bool SdpDeserializeCandidate(const std::string& message, 938 bool SdpDeserializeCandidate(const std::string& message,
939 JsepIceCandidate* jcandidate, 939 JsepIceCandidate* jcandidate,
940 SdpParseError* error) { 940 SdpParseError* error) {
941 RTC_DCHECK(jcandidate != NULL); 941 RTC_DCHECK(jcandidate != nullptr);
942 Candidate candidate; 942 Candidate candidate;
943 if (!ParseCandidate(message, &candidate, error, true)) { 943 if (!ParseCandidate(message, &candidate, error, true)) {
944 return false; 944 return false;
945 } 945 }
946 jcandidate->SetCandidate(candidate); 946 jcandidate->SetCandidate(candidate);
947 return true; 947 return true;
948 } 948 }
949 949
950 bool SdpDeserializeCandidate(const std::string& transport_name, 950 bool SdpDeserializeCandidate(const std::string& transport_name,
951 const std::string& message, 951 const std::string& message,
952 cricket::Candidate* candidate, 952 cricket::Candidate* candidate,
953 SdpParseError* error) { 953 SdpParseError* error) {
954 RTC_DCHECK(candidate != nullptr); 954 RTC_DCHECK(candidate != nullptr);
955 if (!ParseCandidate(message, candidate, error, true)) { 955 if (!ParseCandidate(message, candidate, error, true)) {
956 return false; 956 return false;
957 } 957 }
958 candidate->set_transport_name(transport_name); 958 candidate->set_transport_name(transport_name);
959 return true; 959 return true;
960 } 960 }
961 961
962 bool ParseCandidate(const std::string& message, Candidate* candidate, 962 bool ParseCandidate(const std::string& message, Candidate* candidate,
963 SdpParseError* error, bool is_raw) { 963 SdpParseError* error, bool is_raw) {
964 RTC_DCHECK(candidate != NULL); 964 RTC_DCHECK(candidate != nullptr);
965 965
966 // Get the first line from |message|. 966 // Get the first line from |message|.
967 std::string first_line = message; 967 std::string first_line = message;
968 size_t pos = 0; 968 size_t pos = 0;
969 GetLine(message, &pos, &first_line); 969 GetLine(message, &pos, &first_line);
970 970
971 // Makes sure |message| contains only one line. 971 // Makes sure |message| contains only one line.
972 if (message.size() > first_line.size()) { 972 if (message.size() > first_line.size()) {
973 std::string left, right; 973 std::string left, right;
974 if (rtc::tokenize_first(message, kNewLine, &left, &right) && 974 if (rtc::tokenize_first(message, kNewLine, &left, &right) &&
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 *extmap = RtpExtension(uri, value); 1214 *extmap = RtpExtension(uri, value);
1215 return true; 1215 return true;
1216 } 1216 }
1217 1217
1218 void BuildMediaDescription(const ContentInfo* content_info, 1218 void BuildMediaDescription(const ContentInfo* content_info,
1219 const TransportInfo* transport_info, 1219 const TransportInfo* transport_info,
1220 const MediaType media_type, 1220 const MediaType media_type,
1221 const std::vector<Candidate>& candidates, 1221 const std::vector<Candidate>& candidates,
1222 bool unified_plan_sdp, 1222 bool unified_plan_sdp,
1223 std::string* message) { 1223 std::string* message) {
1224 RTC_DCHECK(message != NULL); 1224 RTC_DCHECK(message != nullptr);
1225 if (content_info == NULL || message == NULL) { 1225 if (content_info == nullptr || message == nullptr) {
1226 return; 1226 return;
1227 } 1227 }
1228 // TODO: Rethink if we should use sprintfn instead of stringstream. 1228 // TODO: Rethink if we should use sprintfn instead of stringstream.
1229 // According to the style guide, streams should only be used for logging. 1229 // According to the style guide, streams should only be used for logging.
1230 // http://google-styleguide.googlecode.com/svn/ 1230 // http://google-styleguide.googlecode.com/svn/
1231 // trunk/cppguide.xml?showone=Streams#Streams 1231 // trunk/cppguide.xml?showone=Streams#Streams
1232 std::ostringstream os; 1232 std::ostringstream os;
1233 const MediaContentDescription* media_desc = 1233 const MediaContentDescription* media_desc =
1234 static_cast<const MediaContentDescription*>( 1234 static_cast<const MediaContentDescription*>(
1235 content_info->description); 1235 content_info->description);
1236 RTC_DCHECK(media_desc != NULL); 1236 RTC_DCHECK(media_desc != nullptr);
1237 1237
1238 int sctp_port = cricket::kSctpDefaultPort; 1238 int sctp_port = cricket::kSctpDefaultPort;
1239 1239
1240 // RFC 4566 1240 // RFC 4566
1241 // m=<media> <port> <proto> <fmt> 1241 // m=<media> <port> <proto> <fmt>
1242 // fmt is a list of payload type numbers that MAY be used in the session. 1242 // fmt is a list of payload type numbers that MAY be used in the session.
1243 const char* type = NULL; 1243 const char* type = nullptr;
1244 if (media_type == cricket::MEDIA_TYPE_AUDIO) 1244 if (media_type == cricket::MEDIA_TYPE_AUDIO)
1245 type = kMediaTypeAudio; 1245 type = kMediaTypeAudio;
1246 else if (media_type == cricket::MEDIA_TYPE_VIDEO) 1246 else if (media_type == cricket::MEDIA_TYPE_VIDEO)
1247 type = kMediaTypeVideo; 1247 type = kMediaTypeVideo;
1248 else if (media_type == cricket::MEDIA_TYPE_DATA) 1248 else if (media_type == cricket::MEDIA_TYPE_DATA)
1249 type = kMediaTypeData; 1249 type = kMediaTypeData;
1250 else 1250 else
1251 RTC_NOTREACHED(); 1251 RTC_NOTREACHED();
1252 1252
1253 std::string fmt; 1253 std::string fmt;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // RFC 3264 1307 // RFC 3264
1308 // To reject an offered stream, the port number in the corresponding stream in 1308 // To reject an offered stream, the port number in the corresponding stream in
1309 // the answer MUST be set to zero. 1309 // the answer MUST be set to zero.
1310 // 1310 //
1311 // However, the BUNDLE draft adds a new meaning to port zero, when used along 1311 // However, the BUNDLE draft adds a new meaning to port zero, when used along
1312 // with a=bundle-only. 1312 // with a=bundle-only.
1313 const std::string& port = 1313 const std::string& port =
1314 (content_info->rejected || content_info->bundle_only) ? kMediaPortRejected 1314 (content_info->rejected || content_info->bundle_only) ? kMediaPortRejected
1315 : kDummyPort; 1315 : kDummyPort;
1316 1316
1317 rtc::SSLFingerprint* fp = (transport_info) ? 1317 rtc::SSLFingerprint* fp =
1318 transport_info->description.identity_fingerprint.get() : NULL; 1318 (transport_info) ? transport_info->description.identity_fingerprint.get()
1319 : nullptr;
1319 1320
1320 // Add the m and c lines. 1321 // Add the m and c lines.
1321 InitLine(kLineTypeMedia, type, &os); 1322 InitLine(kLineTypeMedia, type, &os);
1322 os << " " << port << " " << media_desc->protocol() << fmt; 1323 os << " " << port << " " << media_desc->protocol() << fmt;
1323 std::string mline = os.str(); 1324 std::string mline = os.str();
1324 UpdateMediaDefaultDestination(candidates, mline, message); 1325 UpdateMediaDefaultDestination(candidates, mline, message);
1325 1326
1326 // RFC 4566 1327 // RFC 4566
1327 // b=AS:<bandwidth> 1328 // b=AS:<bandwidth>
1328 if (media_desc->bandwidth() >= 1000) { 1329 if (media_desc->bandwidth() >= 1000) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 os << " " << iter->param(); 1658 os << " " << iter->param();
1658 } 1659 }
1659 AddLine(os.str(), message); 1660 AddLine(os.str(), message);
1660 } 1661 }
1661 } 1662 }
1662 1663
1663 bool AddSctpDataCodec(DataContentDescription* media_desc, 1664 bool AddSctpDataCodec(DataContentDescription* media_desc,
1664 int sctp_port) { 1665 int sctp_port) {
1665 for (const auto& codec : media_desc->codecs()) { 1666 for (const auto& codec : media_desc->codecs()) {
1666 if (cricket::CodecNamesEq(codec.name, cricket::kGoogleSctpDataCodecName)) { 1667 if (cricket::CodecNamesEq(codec.name, cricket::kGoogleSctpDataCodecName)) {
1667 return ParseFailed("", 1668 return ParseFailed("", "Can't have multiple sctp port attributes.",
1668 "Can't have multiple sctp port attributes.", 1669 nullptr);
1669 NULL);
1670 } 1670 }
1671 } 1671 }
1672 // Add the SCTP Port number as a pseudo-codec "port" parameter 1672 // Add the SCTP Port number as a pseudo-codec "port" parameter
1673 cricket::DataCodec codec_port(cricket::kGoogleSctpDataCodecPlType, 1673 cricket::DataCodec codec_port(cricket::kGoogleSctpDataCodecPlType,
1674 cricket::kGoogleSctpDataCodecName); 1674 cricket::kGoogleSctpDataCodecName);
1675 codec_port.SetParam(cricket::kCodecParamPort, sctp_port); 1675 codec_port.SetParam(cricket::kCodecParamPort, sctp_port);
1676 LOG(INFO) << "AddSctpDataCodec: Got SCTP Port Number " 1676 LOG(INFO) << "AddSctpDataCodec: Got SCTP Port Number "
1677 << sctp_port; 1677 << sctp_port;
1678 media_desc->AddCodec(codec_port); 1678 media_desc->AddCodec(codec_port);
1679 return true; 1679 return true;
(...skipping 18 matching lines...) Expand all
1698 } 1698 }
1699 if (!rtc::FromString(found->second, value)) { 1699 if (!rtc::FromString(found->second, value)) {
1700 return false; 1700 return false;
1701 } 1701 }
1702 return true; 1702 return true;
1703 } 1703 }
1704 1704
1705 void BuildRtpMap(const MediaContentDescription* media_desc, 1705 void BuildRtpMap(const MediaContentDescription* media_desc,
1706 const MediaType media_type, 1706 const MediaType media_type,
1707 std::string* message) { 1707 std::string* message) {
1708 RTC_DCHECK(message != NULL); 1708 RTC_DCHECK(message != nullptr);
1709 RTC_DCHECK(media_desc != NULL); 1709 RTC_DCHECK(media_desc != nullptr);
1710 std::ostringstream os; 1710 std::ostringstream os;
1711 if (media_type == cricket::MEDIA_TYPE_VIDEO) { 1711 if (media_type == cricket::MEDIA_TYPE_VIDEO) {
1712 const VideoContentDescription* video_desc = 1712 const VideoContentDescription* video_desc =
1713 static_cast<const VideoContentDescription*>(media_desc); 1713 static_cast<const VideoContentDescription*>(media_desc);
1714 for (std::vector<cricket::VideoCodec>::const_iterator it = 1714 for (std::vector<cricket::VideoCodec>::const_iterator it =
1715 video_desc->codecs().begin(); 1715 video_desc->codecs().begin();
1716 it != video_desc->codecs().end(); ++it) { 1716 it != video_desc->codecs().end(); ++it) {
1717 // RFC 4566 1717 // RFC 4566
1718 // a=rtpmap:<payload type> <encoding name>/<clock rate> 1718 // a=rtpmap:<payload type> <encoding name>/<clock rate>
1719 // [/<encodingparameters>] 1719 // [/<encodingparameters>]
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 if (!ParseIceOptions(line, &(session_td->transport_options), error)) { 2005 if (!ParseIceOptions(line, &(session_td->transport_options), error)) {
2006 return false; 2006 return false;
2007 } 2007 }
2008 } else if (HasAttribute(line, kAttributeFingerprint)) { 2008 } else if (HasAttribute(line, kAttributeFingerprint)) {
2009 if (session_td->identity_fingerprint.get()) { 2009 if (session_td->identity_fingerprint.get()) {
2010 return ParseFailed( 2010 return ParseFailed(
2011 line, 2011 line,
2012 "Can't have multiple fingerprint attributes at the same level.", 2012 "Can't have multiple fingerprint attributes at the same level.",
2013 error); 2013 error);
2014 } 2014 }
2015 rtc::SSLFingerprint* fingerprint = NULL; 2015 rtc::SSLFingerprint* fingerprint = nullptr;
2016 if (!ParseFingerprintAttribute(line, &fingerprint, error)) { 2016 if (!ParseFingerprintAttribute(line, &fingerprint, error)) {
2017 return false; 2017 return false;
2018 } 2018 }
2019 session_td->identity_fingerprint.reset(fingerprint); 2019 session_td->identity_fingerprint.reset(fingerprint);
2020 } else if (HasAttribute(line, kAttributeSetup)) { 2020 } else if (HasAttribute(line, kAttributeSetup)) {
2021 if (!ParseDtlsSetup(line, &(session_td->connection_role), error)) { 2021 if (!ParseDtlsSetup(line, &(session_td->connection_role), error)) {
2022 return false; 2022 return false;
2023 } 2023 }
2024 } else if (HasAttribute(line, kAttributeMsidSemantics)) { 2024 } else if (HasAttribute(line, kAttributeMsidSemantics)) {
2025 std::string semantics; 2025 std::string semantics;
(...skipping 10 matching lines...) Expand all
2036 session_extmaps->push_back(extmap); 2036 session_extmaps->push_back(extmap);
2037 } 2037 }
2038 } 2038 }
2039 2039
2040 return true; 2040 return true;
2041 } 2041 }
2042 2042
2043 bool ParseGroupAttribute(const std::string& line, 2043 bool ParseGroupAttribute(const std::string& line,
2044 cricket::SessionDescription* desc, 2044 cricket::SessionDescription* desc,
2045 SdpParseError* error) { 2045 SdpParseError* error) {
2046 RTC_DCHECK(desc != NULL); 2046 RTC_DCHECK(desc != nullptr);
2047 2047
2048 // RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00 2048 // RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00
2049 // a=group:BUNDLE video voice 2049 // a=group:BUNDLE video voice
2050 std::vector<std::string> fields; 2050 std::vector<std::string> fields;
2051 rtc::split(line.substr(kLinePrefixLength), 2051 rtc::split(line.substr(kLinePrefixLength),
2052 kSdpDelimiterSpace, &fields); 2052 kSdpDelimiterSpace, &fields);
2053 std::string semantics; 2053 std::string semantics;
2054 if (!GetValue(fields[0], kAttributeGroup, &semantics, error)) { 2054 if (!GetValue(fields[0], kAttributeGroup, &semantics, error)) {
2055 return false; 2055 return false;
2056 } 2056 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 *content_name = cricket::CN_DATA; 2243 *content_name = cricket::CN_DATA;
2244 break; 2244 break;
2245 default: 2245 default:
2246 RTC_NOTREACHED(); 2246 RTC_NOTREACHED();
2247 break; 2247 break;
2248 } 2248 }
2249 if (!ParseContent(message, media_type, mline_index, protocol, payload_types, 2249 if (!ParseContent(message, media_type, mline_index, protocol, payload_types,
2250 pos, content_name, bundle_only, media_desc, transport, 2250 pos, content_name, bundle_only, media_desc, transport,
2251 candidates, error)) { 2251 candidates, error)) {
2252 delete media_desc; 2252 delete media_desc;
2253 return NULL; 2253 return nullptr;
2254 } 2254 }
2255 // Sort the codecs according to the m-line fmt list. 2255 // Sort the codecs according to the m-line fmt list.
2256 std::unordered_map<int, int> payload_type_preferences; 2256 std::unordered_map<int, int> payload_type_preferences;
2257 // "size + 1" so that the lowest preference payload type has a preference of 2257 // "size + 1" so that the lowest preference payload type has a preference of
2258 // 1, which is greater than the default (0) for payload types not in the fmt 2258 // 1, which is greater than the default (0) for payload types not in the fmt
2259 // list. 2259 // list.
2260 int preference = static_cast<int>(payload_types.size() + 1); 2260 int preference = static_cast<int>(payload_types.size() + 1);
2261 for (int pt : payload_types) { 2261 for (int pt : payload_types) {
2262 payload_type_preferences[pt] = preference--; 2262 payload_type_preferences[pt] = preference--;
2263 } 2263 }
2264 std::vector<typename C::CodecType> codecs = media_desc->codecs(); 2264 std::vector<typename C::CodecType> codecs = media_desc->codecs();
2265 std::sort(codecs.begin(), codecs.end(), [&payload_type_preferences]( 2265 std::sort(codecs.begin(), codecs.end(), [&payload_type_preferences](
2266 const typename C::CodecType& a, 2266 const typename C::CodecType& a,
2267 const typename C::CodecType& b) { 2267 const typename C::CodecType& b) {
2268 return payload_type_preferences[a.id] > payload_type_preferences[b.id]; 2268 return payload_type_preferences[a.id] > payload_type_preferences[b.id];
2269 }); 2269 });
2270 media_desc->set_codecs(codecs); 2270 media_desc->set_codecs(codecs);
2271 return media_desc; 2271 return media_desc;
2272 } 2272 }
2273 2273
2274 bool ParseMediaDescription(const std::string& message, 2274 bool ParseMediaDescription(const std::string& message,
2275 const TransportDescription& session_td, 2275 const TransportDescription& session_td,
2276 const RtpHeaderExtensions& session_extmaps, 2276 const RtpHeaderExtensions& session_extmaps,
2277 size_t* pos, 2277 size_t* pos,
2278 cricket::SessionDescription* desc, 2278 cricket::SessionDescription* desc,
2279 std::vector<JsepIceCandidate*>* candidates, 2279 std::vector<JsepIceCandidate*>* candidates,
2280 SdpParseError* error) { 2280 SdpParseError* error) {
2281 RTC_DCHECK(desc != NULL); 2281 RTC_DCHECK(desc != nullptr);
2282 std::string line; 2282 std::string line;
2283 int mline_index = -1; 2283 int mline_index = -1;
2284 2284
2285 // Zero or more media descriptions 2285 // Zero or more media descriptions
2286 // RFC 4566 2286 // RFC 4566
2287 // m=<media> <port> <proto> <fmt> 2287 // m=<media> <port> <proto> <fmt>
2288 while (GetLineWithType(message, pos, &line, kLineTypeMedia)) { 2288 while (GetLineWithType(message, pos, &line, kLineTypeMedia)) {
2289 ++mline_index; 2289 ++mline_index;
2290 2290
2291 std::vector<std::string> fields; 2291 std::vector<std::string> fields;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 int p; 2354 int p;
2355 if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) { 2355 if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) {
2356 if (!AddSctpDataCodec(data_desc, p)) 2356 if (!AddSctpDataCodec(data_desc, p))
2357 return false; 2357 return false;
2358 } 2358 }
2359 } else { 2359 } else {
2360 LOG(LS_WARNING) << "Unsupported media type: " << line; 2360 LOG(LS_WARNING) << "Unsupported media type: " << line;
2361 continue; 2361 continue;
2362 } 2362 }
2363 if (!content.get()) { 2363 if (!content.get()) {
2364 // ParseContentDescription returns NULL if failed. 2364 // ParseContentDescription returns null if failed.
2365 return false; 2365 return false;
2366 } 2366 }
2367 2367
2368 bool content_rejected = false; 2368 bool content_rejected = false;
2369 // A port of 0 is not interpreted as a rejected m= section when it's 2369 // A port of 0 is not interpreted as a rejected m= section when it's
2370 // used along with a=bundle-only. 2370 // used along with a=bundle-only.
2371 if (bundle_only) { 2371 if (bundle_only) {
2372 if (!port_rejected) { 2372 if (!port_rejected) {
2373 // Usage of bundle-only with a nonzero port is unspecified. So just 2373 // Usage of bundle-only with a nonzero port is unspecified. So just
2374 // ignore bundle-only if we see this. 2374 // ignore bundle-only if we see this.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 int mline_index, 2575 int mline_index,
2576 const std::string& protocol, 2576 const std::string& protocol,
2577 const std::vector<int>& payload_types, 2577 const std::vector<int>& payload_types,
2578 size_t* pos, 2578 size_t* pos,
2579 std::string* content_name, 2579 std::string* content_name,
2580 bool* bundle_only, 2580 bool* bundle_only,
2581 MediaContentDescription* media_desc, 2581 MediaContentDescription* media_desc,
2582 TransportDescription* transport, 2582 TransportDescription* transport,
2583 std::vector<JsepIceCandidate*>* candidates, 2583 std::vector<JsepIceCandidate*>* candidates,
2584 SdpParseError* error) { 2584 SdpParseError* error) {
2585 RTC_DCHECK(media_desc != NULL); 2585 RTC_DCHECK(media_desc != nullptr);
2586 RTC_DCHECK(content_name != NULL); 2586 RTC_DCHECK(content_name != nullptr);
2587 RTC_DCHECK(transport != NULL); 2587 RTC_DCHECK(transport != nullptr);
2588 2588
2589 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 2589 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
2590 MaybeCreateStaticPayloadAudioCodecs( 2590 MaybeCreateStaticPayloadAudioCodecs(
2591 payload_types, static_cast<AudioContentDescription*>(media_desc)); 2591 payload_types, static_cast<AudioContentDescription*>(media_desc));
2592 } 2592 }
2593 2593
2594 // The media level "ice-ufrag" and "ice-pwd". 2594 // The media level "ice-ufrag" and "ice-pwd".
2595 // The candidates before update the media level "ice-pwd" and "ice-ufrag". 2595 // The candidates before update the media level "ice-pwd" and "ice-ufrag".
2596 Candidates candidates_orig; 2596 Candidates candidates_orig;
2597 std::string line; 2597 std::string line;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 } 2686 }
2687 } else if (HasAttribute(line, kAttributeIceOption)) { 2687 } else if (HasAttribute(line, kAttributeIceOption)) {
2688 if (!ParseIceOptions(line, &transport->transport_options, error)) { 2688 if (!ParseIceOptions(line, &transport->transport_options, error)) {
2689 return false; 2689 return false;
2690 } 2690 }
2691 } else if (HasAttribute(line, kAttributeFmtp)) { 2691 } else if (HasAttribute(line, kAttributeFmtp)) {
2692 if (!ParseFmtpAttributes(line, media_type, media_desc, error)) { 2692 if (!ParseFmtpAttributes(line, media_type, media_desc, error)) {
2693 return false; 2693 return false;
2694 } 2694 }
2695 } else if (HasAttribute(line, kAttributeFingerprint)) { 2695 } else if (HasAttribute(line, kAttributeFingerprint)) {
2696 rtc::SSLFingerprint* fingerprint = NULL; 2696 rtc::SSLFingerprint* fingerprint = nullptr;
2697 2697
2698 if (!ParseFingerprintAttribute(line, &fingerprint, error)) { 2698 if (!ParseFingerprintAttribute(line, &fingerprint, error)) {
2699 return false; 2699 return false;
2700 } 2700 }
2701 transport->identity_fingerprint.reset(fingerprint); 2701 transport->identity_fingerprint.reset(fingerprint);
2702 } else if (HasAttribute(line, kAttributeSetup)) { 2702 } else if (HasAttribute(line, kAttributeSetup)) {
2703 if (!ParseDtlsSetup(line, &(transport->connection_role), error)) { 2703 if (!ParseDtlsSetup(line, &(transport->connection_role), error)) {
2704 return false; 2704 return false;
2705 } 2705 }
2706 } else if (IsDtlsSctp(protocol) && HasAttribute(line, kAttributeSctpPort)) { 2706 } else if (IsDtlsSctp(protocol) && HasAttribute(line, kAttributeSctpPort)) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 RTC_DCHECK((*it).password().empty()); 2851 RTC_DCHECK((*it).password().empty());
2852 (*it).set_password(transport->ice_pwd); 2852 (*it).set_password(transport->ice_pwd);
2853 candidates->push_back( 2853 candidates->push_back(
2854 new JsepIceCandidate(mline_id, mline_index, *it)); 2854 new JsepIceCandidate(mline_id, mline_index, *it));
2855 } 2855 }
2856 return true; 2856 return true;
2857 } 2857 }
2858 2858
2859 bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos, 2859 bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos,
2860 SdpParseError* error) { 2860 SdpParseError* error) {
2861 RTC_DCHECK(ssrc_infos != NULL); 2861 RTC_DCHECK(ssrc_infos != nullptr);
2862 // RFC 5576 2862 // RFC 5576
2863 // a=ssrc:<ssrc-id> <attribute> 2863 // a=ssrc:<ssrc-id> <attribute>
2864 // a=ssrc:<ssrc-id> <attribute>:<value> 2864 // a=ssrc:<ssrc-id> <attribute>:<value>
2865 std::string field1, field2; 2865 std::string field1, field2;
2866 if (!rtc::tokenize_first(line.substr(kLinePrefixLength), kSdpDelimiterSpace, 2866 if (!rtc::tokenize_first(line.substr(kLinePrefixLength), kSdpDelimiterSpace,
2867 &field1, &field2)) { 2867 &field1, &field2)) {
2868 const size_t expected_fields = 2; 2868 const size_t expected_fields = 2;
2869 return ParseFailedExpectFieldNum(line, expected_fields, error); 2869 return ParseFailedExpectFieldNum(line, expected_fields, error);
2870 } 2870 }
2871 2871
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 // The label isn't defined. 2930 // The label isn't defined.
2931 // label:<value> 2931 // label:<value>
2932 ssrc_info->label = value; 2932 ssrc_info->label = value;
2933 } 2933 }
2934 return true; 2934 return true;
2935 } 2935 }
2936 2936
2937 bool ParseSsrcGroupAttribute(const std::string& line, 2937 bool ParseSsrcGroupAttribute(const std::string& line,
2938 SsrcGroupVec* ssrc_groups, 2938 SsrcGroupVec* ssrc_groups,
2939 SdpParseError* error) { 2939 SdpParseError* error) {
2940 RTC_DCHECK(ssrc_groups != NULL); 2940 RTC_DCHECK(ssrc_groups != nullptr);
2941 // RFC 5576 2941 // RFC 5576
2942 // a=ssrc-group:<semantics> <ssrc-id> ... 2942 // a=ssrc-group:<semantics> <ssrc-id> ...
2943 std::vector<std::string> fields; 2943 std::vector<std::string> fields;
2944 rtc::split(line.substr(kLinePrefixLength), 2944 rtc::split(line.substr(kLinePrefixLength),
2945 kSdpDelimiterSpace, &fields); 2945 kSdpDelimiterSpace, &fields);
2946 const size_t expected_min_fields = 2; 2946 const size_t expected_min_fields = 2;
2947 if (fields.size() < expected_min_fields) { 2947 if (fields.size() < expected_min_fields) {
2948 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); 2948 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
2949 } 2949 }
2950 std::string semantics; 2950 std::string semantics;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( 3212 UpdateCodec<AudioContentDescription, cricket::AudioCodec>(
3213 media_desc, payload_type, feedback_param); 3213 media_desc, payload_type, feedback_param);
3214 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 3214 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
3215 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( 3215 UpdateCodec<VideoContentDescription, cricket::VideoCodec>(
3216 media_desc, payload_type, feedback_param); 3216 media_desc, payload_type, feedback_param);
3217 } 3217 }
3218 return true; 3218 return true;
3219 } 3219 }
3220 3220
3221 } // namespace webrtc 3221 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698