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

Side by Side Diff: talk/session/media/mediasession.cc

Issue 1516993002: Properly handle different transports having different SSL roles. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing merge conflicts. Created 4 years, 11 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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 current_streams->push_back(stream_param); 542 current_streams->push_back(stream_param);
543 } else { 543 } else {
544 content_description->AddStream(*param); 544 content_description->AddStream(*param);
545 } 545 }
546 } 546 }
547 return true; 547 return true;
548 } 548 }
549 549
550 // Updates the transport infos of the |sdesc| according to the given 550 // Updates the transport infos of the |sdesc| according to the given
551 // |bundle_group|. The transport infos of the content names within the 551 // |bundle_group|. The transport infos of the content names within the
552 // |bundle_group| should be updated to use the ufrag and pwd of the first 552 // |bundle_group| should be updated to use the ufrag, pwd and DTLS role of the
553 // content within the |bundle_group|. 553 // first content within the |bundle_group|.
554 static bool UpdateTransportInfoForBundle(const ContentGroup& bundle_group, 554 static bool UpdateTransportInfoForBundle(const ContentGroup& bundle_group,
555 SessionDescription* sdesc) { 555 SessionDescription* sdesc) {
556 // The bundle should not be empty. 556 // The bundle should not be empty.
557 if (!sdesc || !bundle_group.FirstContentName()) { 557 if (!sdesc || !bundle_group.FirstContentName()) {
558 return false; 558 return false;
559 } 559 }
560 560
561 // We should definitely have a transport for the first content. 561 // We should definitely have a transport for the first content.
562 const std::string& selected_content_name = *bundle_group.FirstContentName(); 562 const std::string& selected_content_name = *bundle_group.FirstContentName();
563 const TransportInfo* selected_transport_info = 563 const TransportInfo* selected_transport_info =
564 sdesc->GetTransportInfoByName(selected_content_name); 564 sdesc->GetTransportInfoByName(selected_content_name);
565 if (!selected_transport_info) { 565 if (!selected_transport_info) {
566 return false; 566 return false;
567 } 567 }
568 568
569 // Set the other contents to use the same ICE credentials. 569 // Set the other contents to use the same ICE credentials.
570 const std::string& selected_ufrag = 570 const std::string& selected_ufrag =
571 selected_transport_info->description.ice_ufrag; 571 selected_transport_info->description.ice_ufrag;
572 const std::string& selected_pwd = 572 const std::string& selected_pwd =
573 selected_transport_info->description.ice_pwd; 573 selected_transport_info->description.ice_pwd;
574 ConnectionRole selected_connection_role =
575 selected_transport_info->description.connection_role;
574 for (TransportInfos::iterator it = 576 for (TransportInfos::iterator it =
575 sdesc->transport_infos().begin(); 577 sdesc->transport_infos().begin();
576 it != sdesc->transport_infos().end(); ++it) { 578 it != sdesc->transport_infos().end(); ++it) {
577 if (bundle_group.HasContentName(it->content_name) && 579 if (bundle_group.HasContentName(it->content_name) &&
578 it->content_name != selected_content_name) { 580 it->content_name != selected_content_name) {
579 it->description.ice_ufrag = selected_ufrag; 581 it->description.ice_ufrag = selected_ufrag;
580 it->description.ice_pwd = selected_pwd; 582 it->description.ice_pwd = selected_pwd;
583 it->description.connection_role = selected_connection_role;
581 } 584 }
582 } 585 }
583 return true; 586 return true;
584 } 587 }
585 588
586 // Gets the CryptoParamsVec of the given |content_name| from |sdesc|, and 589 // Gets the CryptoParamsVec of the given |content_name| from |sdesc|, and
587 // sets it to |cryptos|. 590 // sets it to |cryptos|.
588 static bool GetCryptosByName(const SessionDescription* sdesc, 591 static bool GetCryptosByName(const SessionDescription* sdesc,
589 const std::string& content_name, 592 const std::string& content_name,
590 CryptoParamsVec* cryptos) { 593 CryptoParamsVec* cryptos) {
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 } 1596 }
1594 } else { 1597 } else {
1595 if (options.recv_audio) { 1598 if (options.recv_audio) {
1596 audio->set_direction(MD_RECVONLY); 1599 audio->set_direction(MD_RECVONLY);
1597 } else { 1600 } else {
1598 audio->set_direction(MD_INACTIVE); 1601 audio->set_direction(MD_INACTIVE);
1599 } 1602 }
1600 } 1603 }
1601 1604
1602 desc->AddContent(content_name, NS_JINGLE_RTP, audio.release()); 1605 desc->AddContent(content_name, NS_JINGLE_RTP, audio.release());
1603 if (!AddTransportOffer(content_name, options.transport_options, 1606 if (!AddTransportOffer(content_name, options.audio_transport_options,
1604 current_description, desc)) { 1607 current_description, desc)) {
1605 return false; 1608 return false;
1606 } 1609 }
1607 1610
1608 return true; 1611 return true;
1609 } 1612 }
1610 1613
1611 bool MediaSessionDescriptionFactory::AddVideoContentForOffer( 1614 bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
1612 const MediaSessionOptions& options, 1615 const MediaSessionOptions& options,
1613 const SessionDescription* current_description, 1616 const SessionDescription* current_description,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 } 1656 }
1654 } else { 1657 } else {
1655 if (options.recv_video) { 1658 if (options.recv_video) {
1656 video->set_direction(MD_RECVONLY); 1659 video->set_direction(MD_RECVONLY);
1657 } else { 1660 } else {
1658 video->set_direction(MD_INACTIVE); 1661 video->set_direction(MD_INACTIVE);
1659 } 1662 }
1660 } 1663 }
1661 1664
1662 desc->AddContent(content_name, NS_JINGLE_RTP, video.release()); 1665 desc->AddContent(content_name, NS_JINGLE_RTP, video.release());
1663 if (!AddTransportOffer(content_name, options.transport_options, 1666 if (!AddTransportOffer(content_name, options.video_transport_options,
1664 current_description, desc)) { 1667 current_description, desc)) {
1665 return false; 1668 return false;
1666 } 1669 }
1667 1670
1668 return true; 1671 return true;
1669 } 1672 }
1670 1673
1671 bool MediaSessionDescriptionFactory::AddDataContentForOffer( 1674 bool MediaSessionDescriptionFactory::AddDataContentForOffer(
1672 const MediaSessionOptions& options, 1675 const MediaSessionOptions& options,
1673 const SessionDescription* current_description, 1676 const SessionDescription* current_description,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 return false; 1720 return false;
1718 } 1721 }
1719 1722
1720 if (is_sctp) { 1723 if (is_sctp) {
1721 desc->AddContent(content_name, NS_JINGLE_DRAFT_SCTP, data.release()); 1724 desc->AddContent(content_name, NS_JINGLE_DRAFT_SCTP, data.release());
1722 } else { 1725 } else {
1723 data->set_bandwidth(options.data_bandwidth); 1726 data->set_bandwidth(options.data_bandwidth);
1724 SetMediaProtocol(secure_transport, data.get()); 1727 SetMediaProtocol(secure_transport, data.get());
1725 desc->AddContent(content_name, NS_JINGLE_RTP, data.release()); 1728 desc->AddContent(content_name, NS_JINGLE_RTP, data.release());
1726 } 1729 }
1727 if (!AddTransportOffer(content_name, options.transport_options, 1730 if (!AddTransportOffer(content_name, options.data_transport_options,
1728 current_description, desc)) { 1731 current_description, desc)) {
1729 return false; 1732 return false;
1730 } 1733 }
1731 return true; 1734 return true;
1732 } 1735 }
1733 1736
1734 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( 1737 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer(
1735 const SessionDescription* offer, 1738 const SessionDescription* offer,
1736 const MediaSessionOptions& options, 1739 const MediaSessionOptions& options,
1737 const SessionDescription* current_description, 1740 const SessionDescription* current_description,
1738 StreamParamsVec* current_streams, 1741 StreamParamsVec* current_streams,
1739 SessionDescription* answer) const { 1742 SessionDescription* answer) const {
1740 const ContentInfo* audio_content = GetFirstAudioContent(offer); 1743 const ContentInfo* audio_content = GetFirstAudioContent(offer);
1741 1744
1742 scoped_ptr<TransportDescription> audio_transport( 1745 scoped_ptr<TransportDescription> audio_transport(CreateTransportAnswer(
1743 CreateTransportAnswer(audio_content->name, offer, 1746 audio_content->name, offer, options.audio_transport_options,
1744 options.transport_options, 1747 current_description));
1745 current_description));
1746 if (!audio_transport) { 1748 if (!audio_transport) {
1747 return false; 1749 return false;
1748 } 1750 }
1749 1751
1750 AudioCodecs audio_codecs = audio_codecs_; 1752 AudioCodecs audio_codecs = audio_codecs_;
1751 if (!options.vad_enabled) { 1753 if (!options.vad_enabled) {
1752 StripCNCodecs(&audio_codecs); 1754 StripCNCodecs(&audio_codecs);
1753 } 1755 }
1754 1756
1755 bool bundle_enabled = 1757 bool bundle_enabled =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 return true; 1793 return true;
1792 } 1794 }
1793 1795
1794 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( 1796 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer(
1795 const SessionDescription* offer, 1797 const SessionDescription* offer,
1796 const MediaSessionOptions& options, 1798 const MediaSessionOptions& options,
1797 const SessionDescription* current_description, 1799 const SessionDescription* current_description,
1798 StreamParamsVec* current_streams, 1800 StreamParamsVec* current_streams,
1799 SessionDescription* answer) const { 1801 SessionDescription* answer) const {
1800 const ContentInfo* video_content = GetFirstVideoContent(offer); 1802 const ContentInfo* video_content = GetFirstVideoContent(offer);
1801 scoped_ptr<TransportDescription> video_transport( 1803 scoped_ptr<TransportDescription> video_transport(CreateTransportAnswer(
1802 CreateTransportAnswer(video_content->name, offer, 1804 video_content->name, offer, options.video_transport_options,
1803 options.transport_options, 1805 current_description));
1804 current_description));
1805 if (!video_transport) { 1806 if (!video_transport) {
1806 return false; 1807 return false;
1807 } 1808 }
1808 1809
1809 scoped_ptr<VideoContentDescription> video_answer( 1810 scoped_ptr<VideoContentDescription> video_answer(
1810 new VideoContentDescription()); 1811 new VideoContentDescription());
1811 // Do not require or create SDES cryptos if DTLS is used. 1812 // Do not require or create SDES cryptos if DTLS is used.
1812 cricket::SecurePolicy sdes_policy = 1813 cricket::SecurePolicy sdes_policy =
1813 video_transport->secure() ? cricket::SEC_DISABLED : secure(); 1814 video_transport->secure() ? cricket::SEC_DISABLED : secure();
1814 bool bundle_enabled = 1815 bool bundle_enabled =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 return true; 1848 return true;
1848 } 1849 }
1849 1850
1850 bool MediaSessionDescriptionFactory::AddDataContentForAnswer( 1851 bool MediaSessionDescriptionFactory::AddDataContentForAnswer(
1851 const SessionDescription* offer, 1852 const SessionDescription* offer,
1852 const MediaSessionOptions& options, 1853 const MediaSessionOptions& options,
1853 const SessionDescription* current_description, 1854 const SessionDescription* current_description,
1854 StreamParamsVec* current_streams, 1855 StreamParamsVec* current_streams,
1855 SessionDescription* answer) const { 1856 SessionDescription* answer) const {
1856 const ContentInfo* data_content = GetFirstDataContent(offer); 1857 const ContentInfo* data_content = GetFirstDataContent(offer);
1857 scoped_ptr<TransportDescription> data_transport( 1858 scoped_ptr<TransportDescription> data_transport(CreateTransportAnswer(
1858 CreateTransportAnswer(data_content->name, offer, 1859 data_content->name, offer, options.data_transport_options,
1859 options.transport_options, 1860 current_description));
1860 current_description));
1861 if (!data_transport) { 1861 if (!data_transport) {
1862 return false; 1862 return false;
1863 } 1863 }
1864 bool is_sctp = (options.data_channel_type == DCT_SCTP); 1864 bool is_sctp = (options.data_channel_type == DCT_SCTP);
1865 std::vector<DataCodec> data_codecs(data_codecs_); 1865 std::vector<DataCodec> data_codecs(data_codecs_);
1866 FilterDataCodecs(&data_codecs, is_sctp); 1866 FilterDataCodecs(&data_codecs, is_sctp);
1867 1867
1868 scoped_ptr<DataContentDescription> data_answer( 1868 scoped_ptr<DataContentDescription> data_answer(
1869 new DataContentDescription()); 1869 new DataContentDescription());
1870 // Do not require or create SDES cryptos if DTLS is used. 1870 // Do not require or create SDES cryptos if DTLS is used.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 1987 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1988 } 1988 }
1989 1989
1990 const DataContentDescription* GetFirstDataContentDescription( 1990 const DataContentDescription* GetFirstDataContentDescription(
1991 const SessionDescription* sdesc) { 1991 const SessionDescription* sdesc) {
1992 return static_cast<const DataContentDescription*>( 1992 return static_cast<const DataContentDescription*>(
1993 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 1993 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
1994 } 1994 }
1995 1995
1996 } // namespace cricket 1996 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698