Chromium Code Reviews| 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 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1441 return NULL; | 1441 return NULL; |
| 1442 } | 1442 } |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 return offer.release(); | 1445 return offer.release(); |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 SessionDescription* MediaSessionDescriptionFactory::CreateAnswer( | 1448 SessionDescription* MediaSessionDescriptionFactory::CreateAnswer( |
| 1449 const SessionDescription* offer, const MediaSessionOptions& options, | 1449 const SessionDescription* offer, const MediaSessionOptions& options, |
| 1450 const SessionDescription* current_description) const { | 1450 const SessionDescription* current_description) const { |
| 1451 if (!offer) { | |
| 1452 return nullptr; | |
| 1453 } | |
| 1451 // The answer contains the intersection of the codecs in the offer with the | 1454 // The answer contains the intersection of the codecs in the offer with the |
| 1452 // codecs we support. As indicated by XEP-0167, we retain the same payload ids | 1455 // codecs we support. As indicated by XEP-0167, we retain the same payload ids |
| 1453 // from the offer in the answer. | 1456 // from the offer in the answer. |
| 1454 std::unique_ptr<SessionDescription> answer(new SessionDescription()); | 1457 std::unique_ptr<SessionDescription> answer(new SessionDescription()); |
| 1455 | 1458 |
| 1456 StreamParamsVec current_streams; | 1459 StreamParamsVec current_streams; |
| 1457 GetCurrentStreamParams(current_description, ¤t_streams); | 1460 GetCurrentStreamParams(current_description, ¤t_streams); |
| 1458 | 1461 |
| 1459 if (offer) { | 1462 // If the offer supports BUNDLE, and we want to use it too, create a BUNDLE |
| 1460 ContentInfos::const_iterator it = offer->contents().begin(); | 1463 // group in the answer with the appropriate content names. |
| 1461 for (; it != offer->contents().end(); ++it) { | 1464 const ContentGroup* offer_bundle = offer->GetGroupByName(GROUP_TYPE_BUNDLE); |
| 1462 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { | 1465 ContentGroup answer_bundle(GROUP_TYPE_BUNDLE); |
| 1463 if (!AddAudioContentForAnswer(offer, options, current_description, | 1466 // Transport info shared by the bundle group. |
| 1464 ¤t_streams, answer.get())) { | 1467 std::unique_ptr<TransportInfo> bundle_transport; |
| 1465 return NULL; | 1468 |
| 1466 } | 1469 ContentInfos::const_iterator it = offer->contents().begin(); |
| 1467 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { | 1470 for (; it != offer->contents().end(); ++it) { |
| 1468 if (!AddVideoContentForAnswer(offer, options, current_description, | 1471 if (IsMediaContentOfType(&*it, MEDIA_TYPE_AUDIO)) { |
| 1469 ¤t_streams, answer.get())) { | 1472 if (!AddAudioContentForAnswer(offer, options, current_description, |
| 1470 return NULL; | 1473 bundle_transport.get(), ¤t_streams, |
| 1471 } | 1474 answer.get())) { |
| 1472 } else { | 1475 return NULL; |
| 1473 RTC_DCHECK(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)); | 1476 } |
| 1474 if (!AddDataContentForAnswer(offer, options, current_description, | 1477 } else if (IsMediaContentOfType(&*it, MEDIA_TYPE_VIDEO)) { |
| 1475 ¤t_streams, answer.get())) { | 1478 if (!AddVideoContentForAnswer(offer, options, current_description, |
| 1476 return NULL; | 1479 bundle_transport.get(), ¤t_streams, |
| 1477 } | 1480 answer.get())) { |
| 1481 return NULL; | |
| 1482 } | |
| 1483 } else { | |
| 1484 RTC_DCHECK(IsMediaContentOfType(&*it, MEDIA_TYPE_DATA)); | |
| 1485 if (!AddDataContentForAnswer(offer, options, current_description, | |
| 1486 bundle_transport.get(), ¤t_streams, | |
| 1487 answer.get())) { | |
| 1488 return NULL; | |
| 1489 } | |
| 1490 } | |
| 1491 // See if we can add the newly generated m= section to the BUNDLE group in | |
| 1492 // the answer. | |
| 1493 if (options.bundle_enabled) { | |
| 1494 ContentInfo& added = answer->contents().back(); | |
| 1495 if (!added.rejected && offer_bundle && | |
| 1496 offer_bundle->HasContentName(added.name)) { | |
| 1497 answer_bundle.AddContentName(added.name); | |
| 1498 bundle_transport.reset( | |
| 1499 new TransportInfo(*answer->GetTransportInfoByName(added.name))); | |
|
pthatcher1
2017/02/17 19:17:32
Why do you need to set the bundle_transport here?
Taylor Brandstetter
2017/02/17 21:49:15
Because it's needed inside the loop, for AddXConte
| |
| 1478 } | 1500 } |
| 1479 } | 1501 } |
|
pthatcher1
2017/02/17 19:17:32
Might be more clear with one if statement:
Conten
Taylor Brandstetter
2017/02/17 21:49:15
Done.
| |
| 1480 } | 1502 } |
|
pthatcher1
2017/02/17 19:17:32
If the offer has this:
a=bundle b a
m=
a=mid:a
m=
Taylor Brandstetter
2017/02/17 21:49:15
Yes we already do that. Yes, it's technically wron
| |
| 1481 | 1503 |
| 1482 // If the offer supports BUNDLE, and we want to use it too, create a BUNDLE | 1504 // Only put BUNDLE group in answer if nonempty. |
| 1483 // group in the answer with the appropriate content names. | 1505 if (answer_bundle.FirstContentName()) { |
| 1484 if (offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled) { | 1506 answer->AddGroup(answer_bundle); |
| 1485 const ContentGroup* offer_bundle = offer->GetGroupByName(GROUP_TYPE_BUNDLE); | 1507 |
| 1486 ContentGroup answer_bundle(GROUP_TYPE_BUNDLE); | 1508 // Share the same ICE credentials and crypto params across all contents, |
| 1487 for (ContentInfos::const_iterator content = answer->contents().begin(); | 1509 // as BUNDLE requires. |
| 1488 content != answer->contents().end(); ++content) { | 1510 if (!UpdateTransportInfoForBundle(answer_bundle, answer.get())) { |
| 1489 if (!content->rejected && offer_bundle->HasContentName(content->name)) { | 1511 LOG(LS_ERROR) << "CreateAnswer failed to UpdateTransportInfoForBundle."; |
| 1490 answer_bundle.AddContentName(content->name); | 1512 return NULL; |
| 1491 } | |
| 1492 } | 1513 } |
| 1493 if (answer_bundle.FirstContentName()) { | |
| 1494 answer->AddGroup(answer_bundle); | |
| 1495 | 1514 |
| 1496 // Share the same ICE credentials and crypto params across all contents, | 1515 if (!UpdateCryptoParamsForBundle(answer_bundle, answer.get())) { |
| 1497 // as BUNDLE requires. | 1516 LOG(LS_ERROR) << "CreateAnswer failed to UpdateCryptoParamsForBundle."; |
| 1498 if (!UpdateTransportInfoForBundle(answer_bundle, answer.get())) { | 1517 return NULL; |
| 1499 LOG(LS_ERROR) << "CreateAnswer failed to UpdateTransportInfoForBundle."; | |
| 1500 return NULL; | |
| 1501 } | |
| 1502 | |
| 1503 if (!UpdateCryptoParamsForBundle(answer_bundle, answer.get())) { | |
| 1504 LOG(LS_ERROR) << "CreateAnswer failed to UpdateCryptoParamsForBundle."; | |
| 1505 return NULL; | |
| 1506 } | |
| 1507 } | 1518 } |
| 1508 } | 1519 } |
| 1509 | 1520 |
| 1510 return answer.release(); | 1521 return answer.release(); |
| 1511 } | 1522 } |
| 1512 | 1523 |
| 1513 const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer( | 1524 const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer( |
| 1514 const RtpTransceiverDirection& direction) const { | 1525 const RtpTransceiverDirection& direction) const { |
| 1515 // If stream is inactive - generate list as if sendrecv. | 1526 // If stream is inactive - generate list as if sendrecv. |
| 1516 if (direction.send == direction.recv) { | 1527 if (direction.send == direction.recv) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 LOG(LS_ERROR) | 1656 LOG(LS_ERROR) |
| 1646 << "Failed to AddTransportOffer, content name=" << content_name; | 1657 << "Failed to AddTransportOffer, content name=" << content_name; |
| 1647 } | 1658 } |
| 1648 return ret; | 1659 return ret; |
| 1649 } | 1660 } |
| 1650 | 1661 |
| 1651 TransportDescription* MediaSessionDescriptionFactory::CreateTransportAnswer( | 1662 TransportDescription* MediaSessionDescriptionFactory::CreateTransportAnswer( |
| 1652 const std::string& content_name, | 1663 const std::string& content_name, |
| 1653 const SessionDescription* offer_desc, | 1664 const SessionDescription* offer_desc, |
| 1654 const TransportOptions& transport_options, | 1665 const TransportOptions& transport_options, |
| 1655 const SessionDescription* current_desc) const { | 1666 const SessionDescription* current_desc, |
| 1667 bool bundled) const { | |
| 1656 if (!transport_desc_factory_) | 1668 if (!transport_desc_factory_) |
| 1657 return NULL; | 1669 return NULL; |
| 1658 const TransportDescription* offer_tdesc = | 1670 const TransportDescription* offer_tdesc = |
| 1659 GetTransportDescription(content_name, offer_desc); | 1671 GetTransportDescription(content_name, offer_desc); |
| 1660 const TransportDescription* current_tdesc = | 1672 const TransportDescription* current_tdesc = |
| 1661 GetTransportDescription(content_name, current_desc); | 1673 GetTransportDescription(content_name, current_desc); |
| 1662 return | 1674 return transport_desc_factory_->CreateAnswer(offer_tdesc, transport_options, |
| 1663 transport_desc_factory_->CreateAnswer(offer_tdesc, transport_options, | 1675 current_tdesc, bundled); |
| 1664 current_tdesc); | |
| 1665 } | 1676 } |
| 1666 | 1677 |
| 1667 bool MediaSessionDescriptionFactory::AddTransportAnswer( | 1678 bool MediaSessionDescriptionFactory::AddTransportAnswer( |
| 1668 const std::string& content_name, | 1679 const std::string& content_name, |
| 1669 const TransportDescription& transport_desc, | 1680 const TransportDescription& transport_desc, |
| 1670 SessionDescription* answer_desc) const { | 1681 SessionDescription* answer_desc) const { |
| 1671 if (!answer_desc->AddTransportInfo(TransportInfo(content_name, | 1682 if (!answer_desc->AddTransportInfo(TransportInfo(content_name, |
| 1672 transport_desc))) { | 1683 transport_desc))) { |
| 1673 LOG(LS_ERROR) | 1684 LOG(LS_ERROR) |
| 1674 << "Failed to AddTransportAnswer, content name=" << content_name; | 1685 << "Failed to AddTransportAnswer, content name=" << content_name; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1849 current_description, desc)) { | 1860 current_description, desc)) { |
| 1850 return false; | 1861 return false; |
| 1851 } | 1862 } |
| 1852 return true; | 1863 return true; |
| 1853 } | 1864 } |
| 1854 | 1865 |
| 1855 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( | 1866 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( |
| 1856 const SessionDescription* offer, | 1867 const SessionDescription* offer, |
| 1857 const MediaSessionOptions& options, | 1868 const MediaSessionOptions& options, |
| 1858 const SessionDescription* current_description, | 1869 const SessionDescription* current_description, |
| 1870 const TransportInfo* bundle_transport, | |
| 1859 StreamParamsVec* current_streams, | 1871 StreamParamsVec* current_streams, |
| 1860 SessionDescription* answer) const { | 1872 SessionDescription* answer) const { |
| 1861 const ContentInfo* audio_content = GetFirstAudioContent(offer); | 1873 const ContentInfo* audio_content = GetFirstAudioContent(offer); |
| 1862 const AudioContentDescription* offer_audio = | 1874 const AudioContentDescription* offer_audio = |
| 1863 static_cast<const AudioContentDescription*>(audio_content->description); | 1875 static_cast<const AudioContentDescription*>(audio_content->description); |
| 1864 | 1876 |
| 1865 std::unique_ptr<TransportDescription> audio_transport(CreateTransportAnswer( | 1877 std::unique_ptr<TransportDescription> audio_transport( |
| 1866 audio_content->name, offer, | 1878 CreateTransportAnswer(audio_content->name, offer, |
| 1867 GetTransportOptions(options, audio_content->name), current_description)); | 1879 GetTransportOptions(options, audio_content->name), |
| 1880 current_description, bundle_transport != nullptr)); | |
| 1868 if (!audio_transport) { | 1881 if (!audio_transport) { |
| 1869 return false; | 1882 return false; |
| 1870 } | 1883 } |
| 1871 | 1884 |
| 1872 // Pick codecs based on the requested communications direction in the offer. | 1885 // Pick codecs based on the requested communications direction in the offer. |
| 1873 const bool wants_send = | 1886 const bool wants_send = |
| 1874 options.HasSendMediaStream(MEDIA_TYPE_AUDIO) || add_legacy_; | 1887 options.HasSendMediaStream(MEDIA_TYPE_AUDIO) || add_legacy_; |
| 1875 auto wants_rtd = RtpTransceiverDirection(wants_send, options.recv_audio); | 1888 auto wants_rtd = RtpTransceiverDirection(wants_send, options.recv_audio); |
| 1876 auto offer_rtd = | 1889 auto offer_rtd = |
| 1877 RtpTransceiverDirection::FromMediaContentDirection( | 1890 RtpTransceiverDirection::FromMediaContentDirection( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1896 sdes_policy, | 1909 sdes_policy, |
| 1897 GetCryptos(GetFirstAudioContentDescription(current_description)), | 1910 GetCryptos(GetFirstAudioContentDescription(current_description)), |
| 1898 audio_rtp_extensions_, | 1911 audio_rtp_extensions_, |
| 1899 current_streams, | 1912 current_streams, |
| 1900 add_legacy_, | 1913 add_legacy_, |
| 1901 bundle_enabled, | 1914 bundle_enabled, |
| 1902 audio_answer.get())) { | 1915 audio_answer.get())) { |
| 1903 return false; // Fails the session setup. | 1916 return false; // Fails the session setup. |
| 1904 } | 1917 } |
| 1905 | 1918 |
| 1919 bool secure = bundle_transport ? bundle_transport->description.secure() | |
| 1920 : audio_transport->secure(); | |
| 1906 bool rejected = !options.has_audio() || audio_content->rejected || | 1921 bool rejected = !options.has_audio() || audio_content->rejected || |
| 1907 !IsMediaProtocolSupported(MEDIA_TYPE_AUDIO, | 1922 !IsMediaProtocolSupported(MEDIA_TYPE_AUDIO, |
| 1908 audio_answer->protocol(), | 1923 audio_answer->protocol(), secure); |
| 1909 audio_transport->secure()); | |
| 1910 if (!rejected) { | 1924 if (!rejected) { |
| 1911 AddTransportAnswer(audio_content->name, *(audio_transport.get()), answer); | 1925 AddTransportAnswer(audio_content->name, *(audio_transport.get()), answer); |
| 1912 } else { | 1926 } else { |
| 1913 // RFC 3264 | 1927 // RFC 3264 |
| 1914 // The answer MUST contain the same number of m-lines as the offer. | 1928 // The answer MUST contain the same number of m-lines as the offer. |
| 1915 LOG(LS_INFO) << "Audio is not supported in the answer."; | 1929 LOG(LS_INFO) << "Audio is not supported in the answer."; |
| 1916 } | 1930 } |
| 1917 | 1931 |
| 1918 answer->AddContent(audio_content->name, audio_content->type, rejected, | 1932 answer->AddContent(audio_content->name, audio_content->type, rejected, |
| 1919 audio_answer.release()); | 1933 audio_answer.release()); |
| 1920 return true; | 1934 return true; |
| 1921 } | 1935 } |
| 1922 | 1936 |
| 1923 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( | 1937 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( |
| 1924 const SessionDescription* offer, | 1938 const SessionDescription* offer, |
| 1925 const MediaSessionOptions& options, | 1939 const MediaSessionOptions& options, |
| 1926 const SessionDescription* current_description, | 1940 const SessionDescription* current_description, |
| 1941 const TransportInfo* bundle_transport, | |
| 1927 StreamParamsVec* current_streams, | 1942 StreamParamsVec* current_streams, |
| 1928 SessionDescription* answer) const { | 1943 SessionDescription* answer) const { |
| 1929 const ContentInfo* video_content = GetFirstVideoContent(offer); | 1944 const ContentInfo* video_content = GetFirstVideoContent(offer); |
| 1930 std::unique_ptr<TransportDescription> video_transport(CreateTransportAnswer( | 1945 std::unique_ptr<TransportDescription> video_transport( |
| 1931 video_content->name, offer, | 1946 CreateTransportAnswer(video_content->name, offer, |
| 1932 GetTransportOptions(options, video_content->name), current_description)); | 1947 GetTransportOptions(options, video_content->name), |
| 1948 current_description, bundle_transport != nullptr)); | |
| 1933 if (!video_transport) { | 1949 if (!video_transport) { |
| 1934 return false; | 1950 return false; |
| 1935 } | 1951 } |
| 1936 | 1952 |
| 1937 std::unique_ptr<VideoContentDescription> video_answer( | 1953 std::unique_ptr<VideoContentDescription> video_answer( |
| 1938 new VideoContentDescription()); | 1954 new VideoContentDescription()); |
| 1939 // Do not require or create SDES cryptos if DTLS is used. | 1955 // Do not require or create SDES cryptos if DTLS is used. |
| 1940 cricket::SecurePolicy sdes_policy = | 1956 cricket::SecurePolicy sdes_policy = |
| 1941 video_transport->secure() ? cricket::SEC_DISABLED : secure(); | 1957 video_transport->secure() ? cricket::SEC_DISABLED : secure(); |
| 1942 bool bundle_enabled = | 1958 bool bundle_enabled = |
| 1943 offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled; | 1959 offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled; |
| 1944 if (!CreateMediaContentAnswer( | 1960 if (!CreateMediaContentAnswer( |
| 1945 static_cast<const VideoContentDescription*>( | 1961 static_cast<const VideoContentDescription*>( |
| 1946 video_content->description), | 1962 video_content->description), |
| 1947 options, | 1963 options, |
| 1948 video_codecs_, | 1964 video_codecs_, |
| 1949 sdes_policy, | 1965 sdes_policy, |
| 1950 GetCryptos(GetFirstVideoContentDescription(current_description)), | 1966 GetCryptos(GetFirstVideoContentDescription(current_description)), |
| 1951 video_rtp_extensions_, | 1967 video_rtp_extensions_, |
| 1952 current_streams, | 1968 current_streams, |
| 1953 add_legacy_, | 1969 add_legacy_, |
| 1954 bundle_enabled, | 1970 bundle_enabled, |
| 1955 video_answer.get())) { | 1971 video_answer.get())) { |
| 1956 return false; | 1972 return false; |
| 1957 } | 1973 } |
| 1974 bool secure = bundle_transport ? bundle_transport->description.secure() | |
| 1975 : video_transport->secure(); | |
| 1958 bool rejected = !options.has_video() || video_content->rejected || | 1976 bool rejected = !options.has_video() || video_content->rejected || |
| 1959 !IsMediaProtocolSupported(MEDIA_TYPE_VIDEO, | 1977 !IsMediaProtocolSupported(MEDIA_TYPE_VIDEO, |
| 1960 video_answer->protocol(), | 1978 video_answer->protocol(), secure); |
| 1961 video_transport->secure()); | |
| 1962 if (!rejected) { | 1979 if (!rejected) { |
| 1963 if (!AddTransportAnswer(video_content->name, *(video_transport.get()), | 1980 if (!AddTransportAnswer(video_content->name, *(video_transport.get()), |
| 1964 answer)) { | 1981 answer)) { |
| 1965 return false; | 1982 return false; |
| 1966 } | 1983 } |
| 1967 video_answer->set_bandwidth(options.video_bandwidth); | 1984 video_answer->set_bandwidth(options.video_bandwidth); |
| 1968 } else { | 1985 } else { |
| 1969 // RFC 3264 | 1986 // RFC 3264 |
| 1970 // The answer MUST contain the same number of m-lines as the offer. | 1987 // The answer MUST contain the same number of m-lines as the offer. |
| 1971 LOG(LS_INFO) << "Video is not supported in the answer."; | 1988 LOG(LS_INFO) << "Video is not supported in the answer."; |
| 1972 } | 1989 } |
| 1973 answer->AddContent(video_content->name, video_content->type, rejected, | 1990 answer->AddContent(video_content->name, video_content->type, rejected, |
| 1974 video_answer.release()); | 1991 video_answer.release()); |
| 1975 return true; | 1992 return true; |
| 1976 } | 1993 } |
| 1977 | 1994 |
| 1978 bool MediaSessionDescriptionFactory::AddDataContentForAnswer( | 1995 bool MediaSessionDescriptionFactory::AddDataContentForAnswer( |
| 1979 const SessionDescription* offer, | 1996 const SessionDescription* offer, |
| 1980 const MediaSessionOptions& options, | 1997 const MediaSessionOptions& options, |
| 1981 const SessionDescription* current_description, | 1998 const SessionDescription* current_description, |
| 1999 const TransportInfo* bundle_transport, | |
| 1982 StreamParamsVec* current_streams, | 2000 StreamParamsVec* current_streams, |
| 1983 SessionDescription* answer) const { | 2001 SessionDescription* answer) const { |
| 1984 const ContentInfo* data_content = GetFirstDataContent(offer); | 2002 const ContentInfo* data_content = GetFirstDataContent(offer); |
| 1985 std::unique_ptr<TransportDescription> data_transport(CreateTransportAnswer( | 2003 std::unique_ptr<TransportDescription> data_transport( |
| 1986 data_content->name, offer, | 2004 CreateTransportAnswer(data_content->name, offer, |
| 1987 GetTransportOptions(options, data_content->name), current_description)); | 2005 GetTransportOptions(options, data_content->name), |
| 2006 current_description, bundle_transport != nullptr)); | |
| 1988 if (!data_transport) { | 2007 if (!data_transport) { |
| 1989 return false; | 2008 return false; |
| 1990 } | 2009 } |
| 1991 bool is_sctp = (options.data_channel_type == DCT_SCTP); | 2010 bool is_sctp = (options.data_channel_type == DCT_SCTP); |
| 1992 std::vector<DataCodec> data_codecs(data_codecs_); | 2011 std::vector<DataCodec> data_codecs(data_codecs_); |
| 1993 FilterDataCodecs(&data_codecs, is_sctp); | 2012 FilterDataCodecs(&data_codecs, is_sctp); |
| 1994 | 2013 |
| 1995 std::unique_ptr<DataContentDescription> data_answer( | 2014 std::unique_ptr<DataContentDescription> data_answer( |
| 1996 new DataContentDescription()); | 2015 new DataContentDescription()); |
| 1997 // Do not require or create SDES cryptos if DTLS is used. | 2016 // Do not require or create SDES cryptos if DTLS is used. |
| 1998 cricket::SecurePolicy sdes_policy = | 2017 cricket::SecurePolicy sdes_policy = |
| 1999 data_transport->secure() ? cricket::SEC_DISABLED : secure(); | 2018 data_transport->secure() ? cricket::SEC_DISABLED : secure(); |
| 2000 bool bundle_enabled = | 2019 bool bundle_enabled = |
| 2001 offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled; | 2020 offer->HasGroup(GROUP_TYPE_BUNDLE) && options.bundle_enabled; |
| 2002 if (!CreateMediaContentAnswer( | 2021 if (!CreateMediaContentAnswer( |
| 2003 static_cast<const DataContentDescription*>( | 2022 static_cast<const DataContentDescription*>( |
| 2004 data_content->description), | 2023 data_content->description), |
| 2005 options, | 2024 options, |
| 2006 data_codecs_, | 2025 data_codecs_, |
| 2007 sdes_policy, | 2026 sdes_policy, |
| 2008 GetCryptos(GetFirstDataContentDescription(current_description)), | 2027 GetCryptos(GetFirstDataContentDescription(current_description)), |
| 2009 RtpHeaderExtensions(), | 2028 RtpHeaderExtensions(), |
| 2010 current_streams, | 2029 current_streams, |
| 2011 add_legacy_, | 2030 add_legacy_, |
| 2012 bundle_enabled, | 2031 bundle_enabled, |
| 2013 data_answer.get())) { | 2032 data_answer.get())) { |
| 2014 return false; // Fails the session setup. | 2033 return false; // Fails the session setup. |
| 2015 } | 2034 } |
| 2016 | 2035 |
| 2036 bool secure = bundle_transport ? bundle_transport->description.secure() | |
| 2037 : data_transport->secure(); | |
| 2017 bool rejected = !options.has_data() || data_content->rejected || | 2038 bool rejected = !options.has_data() || data_content->rejected || |
| 2018 !IsMediaProtocolSupported(MEDIA_TYPE_DATA, | 2039 !IsMediaProtocolSupported(MEDIA_TYPE_DATA, |
| 2019 data_answer->protocol(), | 2040 data_answer->protocol(), secure); |
| 2020 data_transport->secure()); | |
| 2021 if (!rejected) { | 2041 if (!rejected) { |
| 2022 data_answer->set_bandwidth(options.data_bandwidth); | 2042 data_answer->set_bandwidth(options.data_bandwidth); |
| 2023 if (!AddTransportAnswer(data_content->name, *(data_transport.get()), | 2043 if (!AddTransportAnswer(data_content->name, *(data_transport.get()), |
| 2024 answer)) { | 2044 answer)) { |
| 2025 return false; | 2045 return false; |
| 2026 } | 2046 } |
| 2027 } else { | 2047 } else { |
| 2028 // RFC 3264 | 2048 // RFC 3264 |
| 2029 // The answer MUST contain the same number of m-lines as the offer. | 2049 // The answer MUST contain the same number of m-lines as the offer. |
| 2030 LOG(LS_INFO) << "Data is not supported in the answer."; | 2050 LOG(LS_INFO) << "Data is not supported in the answer."; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2187 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 2207 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
| 2188 } | 2208 } |
| 2189 | 2209 |
| 2190 DataContentDescription* GetFirstDataContentDescription( | 2210 DataContentDescription* GetFirstDataContentDescription( |
| 2191 SessionDescription* sdesc) { | 2211 SessionDescription* sdesc) { |
| 2192 return static_cast<DataContentDescription*>( | 2212 return static_cast<DataContentDescription*>( |
| 2193 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 2213 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
| 2194 } | 2214 } |
| 2195 | 2215 |
| 2196 } // namespace cricket | 2216 } // namespace cricket |
| OLD | NEW |