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

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

Issue 1671173002: Track pending ICE restarts independently for different media sections. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Extend ICE restart test to check that a second answer has new credentials. Created 4 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 * 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 731 }
732 } 732 }
733 return false; 733 return false;
734 } 734 }
735 735
736 template <class C> 736 template <class C>
737 static bool IsRtxCodec(const C& codec) { 737 static bool IsRtxCodec(const C& codec) {
738 return stricmp(codec.name.c_str(), kRtxCodecName) == 0; 738 return stricmp(codec.name.c_str(), kRtxCodecName) == 0;
739 } 739 }
740 740
741 static TransportOptions GetTransportOptions(const MediaSessionOptions& options,
742 const std::string& content_name) {
743 auto it = options.transport_options.find(content_name);
honghaiz3 2016/02/12 18:21:04 Perhaps this can be replaced with return options.t
Taylor Brandstetter 2016/02/12 20:43:02 I can't use the [] operator because the MediaSessi
744 if (it == options.transport_options.end()) {
745 return TransportOptions();
746 }
747 return it->second;
748 }
749
741 // Create a media content to be offered in a session-initiate, 750 // Create a media content to be offered in a session-initiate,
742 // according to the given options.rtcp_mux, options.is_muc, 751 // according to the given options.rtcp_mux, options.is_muc,
743 // options.streams, codecs, secure_transport, crypto, and streams. If we don't 752 // options.streams, codecs, secure_transport, crypto, and streams. If we don't
744 // currently have crypto (in current_cryptos) and it is enabled (in 753 // currently have crypto (in current_cryptos) and it is enabled (in
745 // secure_policy), crypto is created (according to crypto_suites). If 754 // secure_policy), crypto is created (according to crypto_suites). If
746 // add_legacy_stream is true, and current_streams is empty, a legacy 755 // add_legacy_stream is true, and current_streams is empty, a legacy
747 // stream is created. The created content is added to the offer. 756 // stream is created. The created content is added to the offer.
748 template <class C> 757 template <class C>
749 static bool CreateMediaContentOffer( 758 static bool CreateMediaContentOffer(
750 const MediaSessionOptions& options, 759 const MediaSessionOptions& options,
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 } 1605 }
1597 } else { 1606 } else {
1598 if (options.recv_audio) { 1607 if (options.recv_audio) {
1599 audio->set_direction(MD_RECVONLY); 1608 audio->set_direction(MD_RECVONLY);
1600 } else { 1609 } else {
1601 audio->set_direction(MD_INACTIVE); 1610 audio->set_direction(MD_INACTIVE);
1602 } 1611 }
1603 } 1612 }
1604 1613
1605 desc->AddContent(content_name, NS_JINGLE_RTP, audio.release()); 1614 desc->AddContent(content_name, NS_JINGLE_RTP, audio.release());
1606 if (!AddTransportOffer(content_name, options.audio_transport_options, 1615 if (!AddTransportOffer(content_name,
1616 GetTransportOptions(options, content_name),
1607 current_description, desc)) { 1617 current_description, desc)) {
1608 return false; 1618 return false;
1609 } 1619 }
1610 1620
1611 return true; 1621 return true;
1612 } 1622 }
1613 1623
1614 bool MediaSessionDescriptionFactory::AddVideoContentForOffer( 1624 bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
1615 const MediaSessionOptions& options, 1625 const MediaSessionOptions& options,
1616 const SessionDescription* current_description, 1626 const SessionDescription* current_description,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 } 1666 }
1657 } else { 1667 } else {
1658 if (options.recv_video) { 1668 if (options.recv_video) {
1659 video->set_direction(MD_RECVONLY); 1669 video->set_direction(MD_RECVONLY);
1660 } else { 1670 } else {
1661 video->set_direction(MD_INACTIVE); 1671 video->set_direction(MD_INACTIVE);
1662 } 1672 }
1663 } 1673 }
1664 1674
1665 desc->AddContent(content_name, NS_JINGLE_RTP, video.release()); 1675 desc->AddContent(content_name, NS_JINGLE_RTP, video.release());
1666 if (!AddTransportOffer(content_name, options.video_transport_options, 1676 if (!AddTransportOffer(content_name,
1677 GetTransportOptions(options, content_name),
1667 current_description, desc)) { 1678 current_description, desc)) {
1668 return false; 1679 return false;
1669 } 1680 }
1670 1681
1671 return true; 1682 return true;
1672 } 1683 }
1673 1684
1674 bool MediaSessionDescriptionFactory::AddDataContentForOffer( 1685 bool MediaSessionDescriptionFactory::AddDataContentForOffer(
1675 const MediaSessionOptions& options, 1686 const MediaSessionOptions& options,
1676 const SessionDescription* current_description, 1687 const SessionDescription* current_description,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 return false; 1731 return false;
1721 } 1732 }
1722 1733
1723 if (is_sctp) { 1734 if (is_sctp) {
1724 desc->AddContent(content_name, NS_JINGLE_DRAFT_SCTP, data.release()); 1735 desc->AddContent(content_name, NS_JINGLE_DRAFT_SCTP, data.release());
1725 } else { 1736 } else {
1726 data->set_bandwidth(options.data_bandwidth); 1737 data->set_bandwidth(options.data_bandwidth);
1727 SetMediaProtocol(secure_transport, data.get()); 1738 SetMediaProtocol(secure_transport, data.get());
1728 desc->AddContent(content_name, NS_JINGLE_RTP, data.release()); 1739 desc->AddContent(content_name, NS_JINGLE_RTP, data.release());
1729 } 1740 }
1730 if (!AddTransportOffer(content_name, options.data_transport_options, 1741 if (!AddTransportOffer(content_name,
1742 GetTransportOptions(options, content_name),
1731 current_description, desc)) { 1743 current_description, desc)) {
1732 return false; 1744 return false;
1733 } 1745 }
1734 return true; 1746 return true;
1735 } 1747 }
1736 1748
1737 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( 1749 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer(
1738 const SessionDescription* offer, 1750 const SessionDescription* offer,
1739 const MediaSessionOptions& options, 1751 const MediaSessionOptions& options,
1740 const SessionDescription* current_description, 1752 const SessionDescription* current_description,
1741 StreamParamsVec* current_streams, 1753 StreamParamsVec* current_streams,
1742 SessionDescription* answer) const { 1754 SessionDescription* answer) const {
1743 const ContentInfo* audio_content = GetFirstAudioContent(offer); 1755 const ContentInfo* audio_content = GetFirstAudioContent(offer);
1744 1756
1745 scoped_ptr<TransportDescription> audio_transport(CreateTransportAnswer( 1757 scoped_ptr<TransportDescription> audio_transport(CreateTransportAnswer(
1746 audio_content->name, offer, options.audio_transport_options, 1758 audio_content->name, offer,
1747 current_description)); 1759 GetTransportOptions(options, audio_content->name), current_description));
1748 if (!audio_transport) { 1760 if (!audio_transport) {
1749 return false; 1761 return false;
1750 } 1762 }
1751 1763
1752 AudioCodecs audio_codecs = audio_codecs_; 1764 AudioCodecs audio_codecs = audio_codecs_;
1753 if (!options.vad_enabled) { 1765 if (!options.vad_enabled) {
1754 StripCNCodecs(&audio_codecs); 1766 StripCNCodecs(&audio_codecs);
1755 } 1767 }
1756 1768
1757 bool bundle_enabled = 1769 bool bundle_enabled =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 } 1806 }
1795 1807
1796 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( 1808 bool MediaSessionDescriptionFactory::AddVideoContentForAnswer(
1797 const SessionDescription* offer, 1809 const SessionDescription* offer,
1798 const MediaSessionOptions& options, 1810 const MediaSessionOptions& options,
1799 const SessionDescription* current_description, 1811 const SessionDescription* current_description,
1800 StreamParamsVec* current_streams, 1812 StreamParamsVec* current_streams,
1801 SessionDescription* answer) const { 1813 SessionDescription* answer) const {
1802 const ContentInfo* video_content = GetFirstVideoContent(offer); 1814 const ContentInfo* video_content = GetFirstVideoContent(offer);
1803 scoped_ptr<TransportDescription> video_transport(CreateTransportAnswer( 1815 scoped_ptr<TransportDescription> video_transport(CreateTransportAnswer(
1804 video_content->name, offer, options.video_transport_options, 1816 video_content->name, offer,
1805 current_description)); 1817 GetTransportOptions(options, video_content->name), current_description));
1806 if (!video_transport) { 1818 if (!video_transport) {
1807 return false; 1819 return false;
1808 } 1820 }
1809 1821
1810 scoped_ptr<VideoContentDescription> video_answer( 1822 scoped_ptr<VideoContentDescription> video_answer(
1811 new VideoContentDescription()); 1823 new VideoContentDescription());
1812 // Do not require or create SDES cryptos if DTLS is used. 1824 // Do not require or create SDES cryptos if DTLS is used.
1813 cricket::SecurePolicy sdes_policy = 1825 cricket::SecurePolicy sdes_policy =
1814 video_transport->secure() ? cricket::SEC_DISABLED : secure(); 1826 video_transport->secure() ? cricket::SEC_DISABLED : secure();
1815 bool bundle_enabled = 1827 bool bundle_enabled =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 } 1861 }
1850 1862
1851 bool MediaSessionDescriptionFactory::AddDataContentForAnswer( 1863 bool MediaSessionDescriptionFactory::AddDataContentForAnswer(
1852 const SessionDescription* offer, 1864 const SessionDescription* offer,
1853 const MediaSessionOptions& options, 1865 const MediaSessionOptions& options,
1854 const SessionDescription* current_description, 1866 const SessionDescription* current_description,
1855 StreamParamsVec* current_streams, 1867 StreamParamsVec* current_streams,
1856 SessionDescription* answer) const { 1868 SessionDescription* answer) const {
1857 const ContentInfo* data_content = GetFirstDataContent(offer); 1869 const ContentInfo* data_content = GetFirstDataContent(offer);
1858 scoped_ptr<TransportDescription> data_transport(CreateTransportAnswer( 1870 scoped_ptr<TransportDescription> data_transport(CreateTransportAnswer(
1859 data_content->name, offer, options.data_transport_options, 1871 data_content->name, offer,
1860 current_description)); 1872 GetTransportOptions(options, data_content->name), current_description));
1861 if (!data_transport) { 1873 if (!data_transport) {
1862 return false; 1874 return false;
1863 } 1875 }
1864 bool is_sctp = (options.data_channel_type == DCT_SCTP); 1876 bool is_sctp = (options.data_channel_type == DCT_SCTP);
1865 std::vector<DataCodec> data_codecs(data_codecs_); 1877 std::vector<DataCodec> data_codecs(data_codecs_);
1866 FilterDataCodecs(&data_codecs, is_sctp); 1878 FilterDataCodecs(&data_codecs, is_sctp);
1867 1879
1868 scoped_ptr<DataContentDescription> data_answer( 1880 scoped_ptr<DataContentDescription> data_answer(
1869 new DataContentDescription()); 1881 new DataContentDescription());
1870 // Do not require or create SDES cryptos if DTLS is used. 1882 // Do not require or create SDES cryptos if DTLS is used.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 } 1930 }
1919 1931
1920 bool IsVideoContent(const ContentInfo* content) { 1932 bool IsVideoContent(const ContentInfo* content) {
1921 return IsMediaContentOfType(content, MEDIA_TYPE_VIDEO); 1933 return IsMediaContentOfType(content, MEDIA_TYPE_VIDEO);
1922 } 1934 }
1923 1935
1924 bool IsDataContent(const ContentInfo* content) { 1936 bool IsDataContent(const ContentInfo* content) {
1925 return IsMediaContentOfType(content, MEDIA_TYPE_DATA); 1937 return IsMediaContentOfType(content, MEDIA_TYPE_DATA);
1926 } 1938 }
1927 1939
1928 static const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, 1940 const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
1929 MediaType media_type) { 1941 MediaType media_type) {
1930 for (ContentInfos::const_iterator content = contents.begin(); 1942 for (ContentInfos::const_iterator content = contents.begin();
1931 content != contents.end(); content++) { 1943 content != contents.end(); content++) {
1932 if (IsMediaContentOfType(&*content, media_type)) { 1944 if (IsMediaContentOfType(&*content, media_type)) {
1933 return &*content; 1945 return &*content;
1934 } 1946 }
1935 } 1947 }
1936 return NULL; 1948 return nullptr;
1937 } 1949 }
1938 1950
1939 const ContentInfo* GetFirstAudioContent(const ContentInfos& contents) { 1951 const ContentInfo* GetFirstAudioContent(const ContentInfos& contents) {
1940 return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO); 1952 return GetFirstMediaContent(contents, MEDIA_TYPE_AUDIO);
1941 } 1953 }
1942 1954
1943 const ContentInfo* GetFirstVideoContent(const ContentInfos& contents) { 1955 const ContentInfo* GetFirstVideoContent(const ContentInfos& contents) {
1944 return GetFirstMediaContent(contents, MEDIA_TYPE_VIDEO); 1956 return GetFirstMediaContent(contents, MEDIA_TYPE_VIDEO);
1945 } 1957 }
1946 1958
1947 const ContentInfo* GetFirstDataContent(const ContentInfos& contents) { 1959 const ContentInfo* GetFirstDataContent(const ContentInfos& contents) {
1948 return GetFirstMediaContent(contents, MEDIA_TYPE_DATA); 1960 return GetFirstMediaContent(contents, MEDIA_TYPE_DATA);
1949 } 1961 }
1950 1962
1951 static const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, 1963 static const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc,
1952 MediaType media_type) { 1964 MediaType media_type) {
1953 if (sdesc == NULL) 1965 if (sdesc == nullptr) {
1954 return NULL; 1966 return nullptr;
1967 }
1955 1968
1956 return GetFirstMediaContent(sdesc->contents(), media_type); 1969 return GetFirstMediaContent(sdesc->contents(), media_type);
1957 } 1970 }
1958 1971
1959 const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc) { 1972 const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc) {
1960 return GetFirstMediaContent(sdesc, MEDIA_TYPE_AUDIO); 1973 return GetFirstMediaContent(sdesc, MEDIA_TYPE_AUDIO);
1961 } 1974 }
1962 1975
1963 const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc) { 1976 const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc) {
1964 return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO); 1977 return GetFirstMediaContent(sdesc, MEDIA_TYPE_VIDEO);
(...skipping 22 matching lines...) Expand all
1987 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); 2000 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO));
1988 } 2001 }
1989 2002
1990 const DataContentDescription* GetFirstDataContentDescription( 2003 const DataContentDescription* GetFirstDataContentDescription(
1991 const SessionDescription* sdesc) { 2004 const SessionDescription* sdesc) {
1992 return static_cast<const DataContentDescription*>( 2005 return static_cast<const DataContentDescription*>(
1993 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); 2006 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA));
1994 } 2007 }
1995 2008
1996 } // namespace cricket 2009 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698