| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 AddMediaCryptos(cryptos, media); | 159 AddMediaCryptos(cryptos, media); |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 const CryptoParamsVec* GetCryptos(const MediaContentDescription* media) { | 164 const CryptoParamsVec* GetCryptos(const MediaContentDescription* media) { |
| 165 if (!media) { | 165 if (!media) { |
| 166 return NULL; | 166 return nullptr; |
| 167 } | 167 } |
| 168 return &media->cryptos(); | 168 return &media->cryptos(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool FindMatchingCrypto(const CryptoParamsVec& cryptos, | 171 bool FindMatchingCrypto(const CryptoParamsVec& cryptos, |
| 172 const CryptoParams& crypto, | 172 const CryptoParams& crypto, |
| 173 CryptoParams* out) { | 173 CryptoParams* out) { |
| 174 for (CryptoParamsVec::const_iterator it = cryptos.begin(); | 174 for (CryptoParamsVec::const_iterator it = cryptos.begin(); |
| 175 it != cryptos.end(); ++it) { | 175 it != cryptos.end(); ++it) { |
| 176 if (crypto.Matches(*it)) { | 176 if (crypto.Matches(*it)) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 const MediaContentDescription* media_desc = | 571 const MediaContentDescription* media_desc = |
| 572 static_cast<const MediaContentDescription*>(content->description); | 572 static_cast<const MediaContentDescription*>(content->description); |
| 573 *cryptos = media_desc->cryptos(); | 573 *cryptos = media_desc->cryptos(); |
| 574 return true; | 574 return true; |
| 575 } | 575 } |
| 576 | 576 |
| 577 // Predicate function used by the remove_if. | 577 // Predicate function used by the remove_if. |
| 578 // Returns true if the |crypto|'s cipher_suite is not found in |filter|. | 578 // Returns true if the |crypto|'s cipher_suite is not found in |filter|. |
| 579 static bool CryptoNotFound(const CryptoParams crypto, | 579 static bool CryptoNotFound(const CryptoParams crypto, |
| 580 const CryptoParamsVec* filter) { | 580 const CryptoParamsVec* filter) { |
| 581 if (filter == NULL) { | 581 if (filter == nullptr) { |
| 582 return true; | 582 return true; |
| 583 } | 583 } |
| 584 for (CryptoParamsVec::const_iterator it = filter->begin(); | 584 for (CryptoParamsVec::const_iterator it = filter->begin(); |
| 585 it != filter->end(); ++it) { | 585 it != filter->end(); ++it) { |
| 586 if (it->cipher_suite == crypto.cipher_suite) { | 586 if (it->cipher_suite == crypto.cipher_suite) { |
| 587 return false; | 587 return false; |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 return true; | 590 return true; |
| 591 } | 591 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 } | 940 } |
| 941 } | 941 } |
| 942 | 942 |
| 943 static bool FindByUri(const RtpHeaderExtensions& extensions, | 943 static bool FindByUri(const RtpHeaderExtensions& extensions, |
| 944 const webrtc::RtpExtension& ext_to_match, | 944 const webrtc::RtpExtension& ext_to_match, |
| 945 webrtc::RtpExtension* found_extension) { | 945 webrtc::RtpExtension* found_extension) { |
| 946 for (RtpHeaderExtensions::const_iterator it = extensions.begin(); | 946 for (RtpHeaderExtensions::const_iterator it = extensions.begin(); |
| 947 it != extensions.end(); ++it) { | 947 it != extensions.end(); ++it) { |
| 948 // We assume that all URIs are given in a canonical format. | 948 // We assume that all URIs are given in a canonical format. |
| 949 if (it->uri == ext_to_match.uri) { | 949 if (it->uri == ext_to_match.uri) { |
| 950 if (found_extension != NULL) { | 950 if (found_extension != nullptr) { |
| 951 *found_extension = *it; | 951 *found_extension = *it; |
| 952 } | 952 } |
| 953 return true; | 953 return true; |
| 954 } | 954 } |
| 955 } | 955 } |
| 956 return false; | 956 return false; |
| 957 } | 957 } |
| 958 | 958 |
| 959 // Iterates through |offered_extensions|, adding each one to |all_extensions| | 959 // Iterates through |offered_extensions|, adding each one to |all_extensions| |
| 960 // and |used_ids|, and resolving ID conflicts. If an offered extension has the | 960 // and |used_ids|, and resolving ID conflicts. If an offered extension has the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 975 } | 975 } |
| 976 | 976 |
| 977 // Adds |reference_extensions| to |offered_extensions|, while updating | 977 // Adds |reference_extensions| to |offered_extensions|, while updating |
| 978 // |all_extensions| and |used_ids|. | 978 // |all_extensions| and |used_ids|. |
| 979 static void FindRtpHdrExtsToOffer( | 979 static void FindRtpHdrExtsToOffer( |
| 980 const RtpHeaderExtensions& reference_extensions, | 980 const RtpHeaderExtensions& reference_extensions, |
| 981 RtpHeaderExtensions* offered_extensions, | 981 RtpHeaderExtensions* offered_extensions, |
| 982 RtpHeaderExtensions* all_extensions, | 982 RtpHeaderExtensions* all_extensions, |
| 983 UsedRtpHeaderExtensionIds* used_ids) { | 983 UsedRtpHeaderExtensionIds* used_ids) { |
| 984 for (auto reference_extension : reference_extensions) { | 984 for (auto reference_extension : reference_extensions) { |
| 985 if (!FindByUri(*offered_extensions, reference_extension, NULL)) { | 985 if (!FindByUri(*offered_extensions, reference_extension, nullptr)) { |
| 986 webrtc::RtpExtension existing; | 986 webrtc::RtpExtension existing; |
| 987 if (FindByUri(*all_extensions, reference_extension, &existing)) { | 987 if (FindByUri(*all_extensions, reference_extension, &existing)) { |
| 988 offered_extensions->push_back(existing); | 988 offered_extensions->push_back(existing); |
| 989 } else { | 989 } else { |
| 990 used_ids->FindAndSetIdUsed(&reference_extension); | 990 used_ids->FindAndSetIdUsed(&reference_extension); |
| 991 all_extensions->push_back(reference_extension); | 991 all_extensions->push_back(reference_extension); |
| 992 offered_extensions->push_back(reference_extension); | 992 offered_extensions->push_back(reference_extension); |
| 993 } | 993 } |
| 994 } | 994 } |
| 995 } | 995 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 desc->set_protocol(kMediaProtocolDtlsSavpf); | 1156 desc->set_protocol(kMediaProtocolDtlsSavpf); |
| 1157 else | 1157 else |
| 1158 desc->set_protocol(kMediaProtocolAvpf); | 1158 desc->set_protocol(kMediaProtocolAvpf); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 // Gets the TransportInfo of the given |content_name| from the | 1161 // Gets the TransportInfo of the given |content_name| from the |
| 1162 // |current_description|. If doesn't exist, returns a new one. | 1162 // |current_description|. If doesn't exist, returns a new one. |
| 1163 static const TransportDescription* GetTransportDescription( | 1163 static const TransportDescription* GetTransportDescription( |
| 1164 const std::string& content_name, | 1164 const std::string& content_name, |
| 1165 const SessionDescription* current_description) { | 1165 const SessionDescription* current_description) { |
| 1166 const TransportDescription* desc = NULL; | 1166 const TransportDescription* desc = nullptr; |
| 1167 if (current_description) { | 1167 if (current_description) { |
| 1168 const TransportInfo* info = | 1168 const TransportInfo* info = |
| 1169 current_description->GetTransportInfoByName(content_name); | 1169 current_description->GetTransportInfoByName(content_name); |
| 1170 if (info) { | 1170 if (info) { |
| 1171 desc = &info->description; | 1171 desc = &info->description; |
| 1172 } | 1172 } |
| 1173 } | 1173 } |
| 1174 return desc; | 1174 return desc; |
| 1175 } | 1175 } |
| 1176 | 1176 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 | 1351 |
| 1352 // Iterate through the contents of |current_description| to maintain the order | 1352 // Iterate through the contents of |current_description| to maintain the order |
| 1353 // of the m-lines in the new offer. | 1353 // of the m-lines in the new offer. |
| 1354 if (current_description) { | 1354 if (current_description) { |
| 1355 ContentInfos::const_iterator it = current_description->contents().begin(); | 1355 ContentInfos::const_iterator it = current_description->contents().begin(); |
| 1356 for (; it != current_description->contents().end(); ++it) { | 1356 for (; it != current_description->contents().end(); ++it) { |
| 1357 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { | 1357 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { |
| 1358 if (!AddAudioContentForOffer(options, current_description, | 1358 if (!AddAudioContentForOffer(options, current_description, |
| 1359 audio_rtp_extensions, audio_codecs, | 1359 audio_rtp_extensions, audio_codecs, |
| 1360 ¤t_streams, offer.get())) { | 1360 ¤t_streams, offer.get())) { |
| 1361 return NULL; | 1361 return nullptr; |
| 1362 } | 1362 } |
| 1363 audio_added = true; | 1363 audio_added = true; |
| 1364 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { | 1364 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { |
| 1365 if (!AddVideoContentForOffer(options, current_description, | 1365 if (!AddVideoContentForOffer(options, current_description, |
| 1366 video_rtp_extensions, video_codecs, | 1366 video_rtp_extensions, video_codecs, |
| 1367 ¤t_streams, offer.get())) { | 1367 ¤t_streams, offer.get())) { |
| 1368 return NULL; | 1368 return nullptr; |
| 1369 } | 1369 } |
| 1370 video_added = true; | 1370 video_added = true; |
| 1371 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)) { | 1371 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)) { |
| 1372 MediaSessionOptions options_copy(options); | 1372 MediaSessionOptions options_copy(options); |
| 1373 if (IsSctp(static_cast<const MediaContentDescription*>( | 1373 if (IsSctp(static_cast<const MediaContentDescription*>( |
| 1374 it->description))) { | 1374 it->description))) { |
| 1375 options_copy.data_channel_type = DCT_SCTP; | 1375 options_copy.data_channel_type = DCT_SCTP; |
| 1376 } | 1376 } |
| 1377 if (!AddDataContentForOffer(options_copy, current_description, | 1377 if (!AddDataContentForOffer(options_copy, current_description, |
| 1378 &data_codecs, ¤t_streams, | 1378 &data_codecs, ¤t_streams, |
| 1379 offer.get())) { | 1379 offer.get())) { |
| 1380 return NULL; | 1380 return nullptr; |
| 1381 } | 1381 } |
| 1382 data_added = true; | 1382 data_added = true; |
| 1383 } else { | 1383 } else { |
| 1384 RTC_NOTREACHED(); | 1384 RTC_NOTREACHED(); |
| 1385 } | 1385 } |
| 1386 } | 1386 } |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 // Append contents that are not in |current_description|. | 1389 // Append contents that are not in |current_description|. |
| 1390 if (!audio_added && options.has_audio() && | 1390 if (!audio_added && options.has_audio() && |
| 1391 !AddAudioContentForOffer(options, current_description, | 1391 !AddAudioContentForOffer(options, current_description, |
| 1392 audio_rtp_extensions, audio_codecs, | 1392 audio_rtp_extensions, audio_codecs, |
| 1393 ¤t_streams, offer.get())) { | 1393 ¤t_streams, offer.get())) { |
| 1394 return NULL; | 1394 return nullptr; |
| 1395 } | 1395 } |
| 1396 if (!video_added && options.has_video() && | 1396 if (!video_added && options.has_video() && |
| 1397 !AddVideoContentForOffer(options, current_description, | 1397 !AddVideoContentForOffer(options, current_description, |
| 1398 video_rtp_extensions, video_codecs, | 1398 video_rtp_extensions, video_codecs, |
| 1399 ¤t_streams, offer.get())) { | 1399 ¤t_streams, offer.get())) { |
| 1400 return NULL; | 1400 return nullptr; |
| 1401 } | 1401 } |
| 1402 if (!data_added && options.has_data() && | 1402 if (!data_added && options.has_data() && |
| 1403 !AddDataContentForOffer(options, current_description, &data_codecs, | 1403 !AddDataContentForOffer(options, current_description, &data_codecs, |
| 1404 ¤t_streams, offer.get())) { | 1404 ¤t_streams, offer.get())) { |
| 1405 return NULL; | 1405 return nullptr; |
| 1406 } | 1406 } |
| 1407 | 1407 |
| 1408 // Bundle the contents together, if we've been asked to do so, and update any | 1408 // Bundle the contents together, if we've been asked to do so, and update any |
| 1409 // parameters that need to be tweaked for BUNDLE. | 1409 // parameters that need to be tweaked for BUNDLE. |
| 1410 if (options.bundle_enabled) { | 1410 if (options.bundle_enabled) { |
| 1411 ContentGroup offer_bundle(GROUP_TYPE_BUNDLE); | 1411 ContentGroup offer_bundle(GROUP_TYPE_BUNDLE); |
| 1412 for (ContentInfos::const_iterator content = offer->contents().begin(); | 1412 for (ContentInfos::const_iterator content = offer->contents().begin(); |
| 1413 content != offer->contents().end(); ++content) { | 1413 content != offer->contents().end(); ++content) { |
| 1414 offer_bundle.AddContentName(content->name); | 1414 offer_bundle.AddContentName(content->name); |
| 1415 } | 1415 } |
| 1416 offer->AddGroup(offer_bundle); | 1416 offer->AddGroup(offer_bundle); |
| 1417 if (!UpdateTransportInfoForBundle(offer_bundle, offer.get())) { | 1417 if (!UpdateTransportInfoForBundle(offer_bundle, offer.get())) { |
| 1418 LOG(LS_ERROR) << "CreateOffer failed to UpdateTransportInfoForBundle."; | 1418 LOG(LS_ERROR) << "CreateOffer failed to UpdateTransportInfoForBundle."; |
| 1419 return NULL; | 1419 return nullptr; |
| 1420 } | 1420 } |
| 1421 if (!UpdateCryptoParamsForBundle(offer_bundle, offer.get())) { | 1421 if (!UpdateCryptoParamsForBundle(offer_bundle, offer.get())) { |
| 1422 LOG(LS_ERROR) << "CreateOffer failed to UpdateCryptoParamsForBundle."; | 1422 LOG(LS_ERROR) << "CreateOffer failed to UpdateCryptoParamsForBundle."; |
| 1423 return NULL; | 1423 return nullptr; |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 return offer.release(); | 1427 return offer.release(); |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 SessionDescription* MediaSessionDescriptionFactory::CreateAnswer( | 1430 SessionDescription* MediaSessionDescriptionFactory::CreateAnswer( |
| 1431 const SessionDescription* offer, const MediaSessionOptions& options, | 1431 const SessionDescription* offer, const MediaSessionOptions& options, |
| 1432 const SessionDescription* current_description) const { | 1432 const SessionDescription* current_description) const { |
| 1433 // The answer contains the intersection of the codecs in the offer with the | 1433 // The answer contains the intersection of the codecs in the offer with the |
| 1434 // codecs we support. As indicated by XEP-0167, we retain the same payload ids | 1434 // codecs we support. As indicated by XEP-0167, we retain the same payload ids |
| 1435 // from the offer in the answer. | 1435 // from the offer in the answer. |
| 1436 std::unique_ptr<SessionDescription> answer(new SessionDescription()); | 1436 std::unique_ptr<SessionDescription> answer(new SessionDescription()); |
| 1437 | 1437 |
| 1438 StreamParamsVec current_streams; | 1438 StreamParamsVec current_streams; |
| 1439 GetCurrentStreamParams(current_description, ¤t_streams); | 1439 GetCurrentStreamParams(current_description, ¤t_streams); |
| 1440 | 1440 |
| 1441 if (offer) { | 1441 if (offer) { |
| 1442 ContentInfos::const_iterator it = offer->contents().begin(); | 1442 ContentInfos::const_iterator it = offer->contents().begin(); |
| 1443 for (; it != offer->contents().end(); ++it) { | 1443 for (; it != offer->contents().end(); ++it) { |
| 1444 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { | 1444 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { |
| 1445 if (!AddAudioContentForAnswer(offer, options, current_description, | 1445 if (!AddAudioContentForAnswer(offer, options, current_description, |
| 1446 ¤t_streams, answer.get())) { | 1446 ¤t_streams, answer.get())) { |
| 1447 return NULL; | 1447 return nullptr; |
| 1448 } | 1448 } |
| 1449 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { | 1449 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { |
| 1450 if (!AddVideoContentForAnswer(offer, options, current_description, | 1450 if (!AddVideoContentForAnswer(offer, options, current_description, |
| 1451 ¤t_streams, answer.get())) { | 1451 ¤t_streams, answer.get())) { |
| 1452 return NULL; | 1452 return nullptr; |
| 1453 } | 1453 } |
| 1454 } else { | 1454 } else { |
| 1455 RTC_DCHECK(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)); | 1455 RTC_DCHECK(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)); |
| 1456 if (!AddDataContentForAnswer(offer, options, current_description, | 1456 if (!AddDataContentForAnswer(offer, options, current_description, |
| 1457 ¤t_streams, answer.get())) { | 1457 ¤t_streams, answer.get())) { |
| 1458 return NULL; | 1458 return nullptr; |
| 1459 } | 1459 } |
| 1460 } | 1460 } |
| 1461 } | 1461 } |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 // If the offer supports BUNDLE, and we want to use it too, create a BUNDLE | 1464 // If the offer supports BUNDLE, and we want to use it too, create a BUNDLE |
| 1465 // group in the answer with the appropriate content names. | 1465 // group in the answer with the appropriate content names. |
| 1466 if (offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled) { | 1466 if (offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled) { |
| 1467 const ContentGroup* offer_bundle = offer->GetGroupByName(GROUP_TYPE_BUNDLE); | 1467 const ContentGroup* offer_bundle = offer->GetGroupByName(GROUP_TYPE_BUNDLE); |
| 1468 ContentGroup answer_bundle(GROUP_TYPE_BUNDLE); | 1468 ContentGroup answer_bundle(GROUP_TYPE_BUNDLE); |
| 1469 for (ContentInfos::const_iterator content = answer->contents().begin(); | 1469 for (ContentInfos::const_iterator content = answer->contents().begin(); |
| 1470 content != answer->contents().end(); ++content) { | 1470 content != answer->contents().end(); ++content) { |
| 1471 if (!content->rejected && offer_bundle->HasContentName(content->name)) { | 1471 if (!content->rejected && offer_bundle->HasContentName(content->name)) { |
| 1472 answer_bundle.AddContentName(content->name); | 1472 answer_bundle.AddContentName(content->name); |
| 1473 } | 1473 } |
| 1474 } | 1474 } |
| 1475 if (answer_bundle.FirstContentName()) { | 1475 if (answer_bundle.FirstContentName()) { |
| 1476 answer->AddGroup(answer_bundle); | 1476 answer->AddGroup(answer_bundle); |
| 1477 | 1477 |
| 1478 // Share the same ICE credentials and crypto params across all contents, | 1478 // Share the same ICE credentials and crypto params across all contents, |
| 1479 // as BUNDLE requires. | 1479 // as BUNDLE requires. |
| 1480 if (!UpdateTransportInfoForBundle(answer_bundle, answer.get())) { | 1480 if (!UpdateTransportInfoForBundle(answer_bundle, answer.get())) { |
| 1481 LOG(LS_ERROR) << "CreateAnswer failed to UpdateTransportInfoForBundle."; | 1481 LOG(LS_ERROR) << "CreateAnswer failed to UpdateTransportInfoForBundle."; |
| 1482 return NULL; | 1482 return nullptr; |
| 1483 } | 1483 } |
| 1484 | 1484 |
| 1485 if (!UpdateCryptoParamsForBundle(answer_bundle, answer.get())) { | 1485 if (!UpdateCryptoParamsForBundle(answer_bundle, answer.get())) { |
| 1486 LOG(LS_ERROR) << "CreateAnswer failed to UpdateCryptoParamsForBundle."; | 1486 LOG(LS_ERROR) << "CreateAnswer failed to UpdateCryptoParamsForBundle."; |
| 1487 return NULL; | 1487 return nullptr; |
| 1488 } | 1488 } |
| 1489 } | 1489 } |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 return answer.release(); | 1492 return answer.release(); |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer( | 1495 const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer( |
| 1496 const RtpTransceiverDirection& direction) const { | 1496 const RtpTransceiverDirection& direction) const { |
| 1497 // If stream is inactive - generate list as if sendrecv. | 1497 // If stream is inactive - generate list as if sendrecv. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 const std::string& content_name, | 1614 const std::string& content_name, |
| 1615 const TransportOptions& transport_options, | 1615 const TransportOptions& transport_options, |
| 1616 const SessionDescription* current_desc, | 1616 const SessionDescription* current_desc, |
| 1617 SessionDescription* offer_desc) const { | 1617 SessionDescription* offer_desc) const { |
| 1618 if (!transport_desc_factory_) | 1618 if (!transport_desc_factory_) |
| 1619 return false; | 1619 return false; |
| 1620 const TransportDescription* current_tdesc = | 1620 const TransportDescription* current_tdesc = |
| 1621 GetTransportDescription(content_name, current_desc); | 1621 GetTransportDescription(content_name, current_desc); |
| 1622 std::unique_ptr<TransportDescription> new_tdesc( | 1622 std::unique_ptr<TransportDescription> new_tdesc( |
| 1623 transport_desc_factory_->CreateOffer(transport_options, current_tdesc)); | 1623 transport_desc_factory_->CreateOffer(transport_options, current_tdesc)); |
| 1624 bool ret = (new_tdesc.get() != NULL && | 1624 bool ret = |
| 1625 offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc))); | 1625 (new_tdesc.get() != nullptr && |
| 1626 offer_desc->AddTransportInfo(TransportInfo(content_name, *new_tdesc))); |
| 1626 if (!ret) { | 1627 if (!ret) { |
| 1627 LOG(LS_ERROR) | 1628 LOG(LS_ERROR) |
| 1628 << "Failed to AddTransportOffer, content name=" << content_name; | 1629 << "Failed to AddTransportOffer, content name=" << content_name; |
| 1629 } | 1630 } |
| 1630 return ret; | 1631 return ret; |
| 1631 } | 1632 } |
| 1632 | 1633 |
| 1633 TransportDescription* MediaSessionDescriptionFactory::CreateTransportAnswer( | 1634 TransportDescription* MediaSessionDescriptionFactory::CreateTransportAnswer( |
| 1634 const std::string& content_name, | 1635 const std::string& content_name, |
| 1635 const SessionDescription* offer_desc, | 1636 const SessionDescription* offer_desc, |
| 1636 const TransportOptions& transport_options, | 1637 const TransportOptions& transport_options, |
| 1637 const SessionDescription* current_desc) const { | 1638 const SessionDescription* current_desc) const { |
| 1638 if (!transport_desc_factory_) | 1639 if (!transport_desc_factory_) |
| 1639 return NULL; | 1640 return nullptr; |
| 1640 const TransportDescription* offer_tdesc = | 1641 const TransportDescription* offer_tdesc = |
| 1641 GetTransportDescription(content_name, offer_desc); | 1642 GetTransportDescription(content_name, offer_desc); |
| 1642 const TransportDescription* current_tdesc = | 1643 const TransportDescription* current_tdesc = |
| 1643 GetTransportDescription(content_name, current_desc); | 1644 GetTransportDescription(content_name, current_desc); |
| 1644 return | 1645 return |
| 1645 transport_desc_factory_->CreateAnswer(offer_tdesc, transport_options, | 1646 transport_desc_factory_->CreateAnswer(offer_tdesc, transport_options, |
| 1646 current_tdesc); | 1647 current_tdesc); |
| 1647 } | 1648 } |
| 1648 | 1649 |
| 1649 bool MediaSessionDescriptionFactory::AddTransportAnswer( | 1650 bool MediaSessionDescriptionFactory::AddTransportAnswer( |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO); | 2074 return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO); |
| 2074 } | 2075 } |
| 2075 | 2076 |
| 2076 const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc) { | 2077 const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc) { |
| 2077 return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA); | 2078 return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA); |
| 2078 } | 2079 } |
| 2079 | 2080 |
| 2080 const MediaContentDescription* GetFirstMediaContentDescription( | 2081 const MediaContentDescription* GetFirstMediaContentDescription( |
| 2081 const SessionDescription* sdesc, MediaType media_type) { | 2082 const SessionDescription* sdesc, MediaType media_type) { |
| 2082 const ContentInfo* content = GetFirstMediaContent(sdesc, media_type); | 2083 const ContentInfo* content = GetFirstMediaContent(sdesc, media_type); |
| 2083 const ContentDescription* description = content ? content->description : NULL; | 2084 const ContentDescription* description = |
| 2085 content ? content->description : nullptr; |
| 2084 return static_cast<const MediaContentDescription*>(description); | 2086 return static_cast<const MediaContentDescription*>(description); |
| 2085 } | 2087 } |
| 2086 | 2088 |
| 2087 const AudioContentDescription* GetFirstAudioContentDescription( | 2089 const AudioContentDescription* GetFirstAudioContentDescription( |
| 2088 const SessionDescription* sdesc) { | 2090 const SessionDescription* sdesc) { |
| 2089 return static_cast<const AudioContentDescription*>( | 2091 return static_cast<const AudioContentDescription*>( |
| 2090 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO)); | 2092 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO)); |
| 2091 } | 2093 } |
| 2092 | 2094 |
| 2093 const VideoContentDescription* GetFirstVideoContentDescription( | 2095 const VideoContentDescription* GetFirstVideoContentDescription( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 } | 2148 } |
| 2147 | 2149 |
| 2148 ContentInfo* GetFirstDataContent(SessionDescription* sdesc) { | 2150 ContentInfo* GetFirstDataContent(SessionDescription* sdesc) { |
| 2149 return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA); | 2151 return GetFirstMediaContent(sdesc, MEDIA_TYPE_DATA); |
| 2150 } | 2152 } |
| 2151 | 2153 |
| 2152 MediaContentDescription* GetFirstMediaContentDescription( | 2154 MediaContentDescription* GetFirstMediaContentDescription( |
| 2153 SessionDescription* sdesc, | 2155 SessionDescription* sdesc, |
| 2154 MediaType media_type) { | 2156 MediaType media_type) { |
| 2155 ContentInfo* content = GetFirstMediaContent(sdesc, media_type); | 2157 ContentInfo* content = GetFirstMediaContent(sdesc, media_type); |
| 2156 ContentDescription* description = content ? content->description : NULL; | 2158 ContentDescription* description = content ? content->description : nullptr; |
| 2157 return static_cast<MediaContentDescription*>(description); | 2159 return static_cast<MediaContentDescription*>(description); |
| 2158 } | 2160 } |
| 2159 | 2161 |
| 2160 AudioContentDescription* GetFirstAudioContentDescription( | 2162 AudioContentDescription* GetFirstAudioContentDescription( |
| 2161 SessionDescription* sdesc) { | 2163 SessionDescription* sdesc) { |
| 2162 return static_cast<AudioContentDescription*>( | 2164 return static_cast<AudioContentDescription*>( |
| 2163 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO)); | 2165 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_AUDIO)); |
| 2164 } | 2166 } |
| 2165 | 2167 |
| 2166 VideoContentDescription* GetFirstVideoContentDescription( | 2168 VideoContentDescription* GetFirstVideoContentDescription( |
| 2167 SessionDescription* sdesc) { | 2169 SessionDescription* sdesc) { |
| 2168 return static_cast<VideoContentDescription*>( | 2170 return static_cast<VideoContentDescription*>( |
| 2169 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2171 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2170 } | 2172 } |
| 2171 | 2173 |
| 2172 DataContentDescription* GetFirstDataContentDescription( | 2174 DataContentDescription* GetFirstDataContentDescription( |
| 2173 SessionDescription* sdesc) { | 2175 SessionDescription* sdesc) { |
| 2174 return static_cast<DataContentDescription*>( | 2176 return static_cast<DataContentDescription*>( |
| 2175 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2177 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2176 } | 2178 } |
| 2177 | 2179 |
| 2178 } // namespace cricket | 2180 } // namespace cricket |
| OLD | NEW |