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

Side by Side Diff: talk/app/webrtc/peerconnectioninterface_unittest.cc

Issue 1406803004: Fixing some issues with the direction attribute of m-lines in offers. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing comment. Created 5 years, 2 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 2012 Google Inc. 3 * Copyright 2012 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 using rtc::scoped_ptr; 237 using rtc::scoped_ptr;
238 using rtc::scoped_refptr; 238 using rtc::scoped_refptr;
239 using webrtc::AudioSourceInterface; 239 using webrtc::AudioSourceInterface;
240 using webrtc::AudioTrack; 240 using webrtc::AudioTrack;
241 using webrtc::AudioTrackInterface; 241 using webrtc::AudioTrackInterface;
242 using webrtc::DataBuffer; 242 using webrtc::DataBuffer;
243 using webrtc::DataChannelInterface; 243 using webrtc::DataChannelInterface;
244 using webrtc::FakeConstraints; 244 using webrtc::FakeConstraints;
245 using webrtc::FakePortAllocatorFactory; 245 using webrtc::FakePortAllocatorFactory;
246 using webrtc::IceCandidateInterface; 246 using webrtc::IceCandidateInterface;
247 using webrtc::MediaConstraintsInterface;
247 using webrtc::MediaStream; 248 using webrtc::MediaStream;
248 using webrtc::MediaStreamInterface; 249 using webrtc::MediaStreamInterface;
249 using webrtc::MediaStreamTrackInterface; 250 using webrtc::MediaStreamTrackInterface;
250 using webrtc::MockCreateSessionDescriptionObserver; 251 using webrtc::MockCreateSessionDescriptionObserver;
251 using webrtc::MockDataChannelObserver; 252 using webrtc::MockDataChannelObserver;
252 using webrtc::MockSetSessionDescriptionObserver; 253 using webrtc::MockSetSessionDescriptionObserver;
253 using webrtc::MockStatsObserver; 254 using webrtc::MockStatsObserver;
254 using webrtc::PeerConnectionInterface; 255 using webrtc::PeerConnectionInterface;
255 using webrtc::PeerConnectionObserver; 256 using webrtc::PeerConnectionObserver;
256 using webrtc::PortAllocatorFactoryInterface; 257 using webrtc::PortAllocatorFactoryInterface;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 audio_track_label, static_cast<AudioSourceInterface*>(NULL))); 636 audio_track_label, static_cast<AudioSourceInterface*>(NULL)));
636 stream->AddTrack(audio_track.get()); 637 stream->AddTrack(audio_track.get());
637 scoped_refptr<VideoTrackInterface> video_track( 638 scoped_refptr<VideoTrackInterface> video_track(
638 pc_factory_->CreateVideoTrack(video_track_label, NULL)); 639 pc_factory_->CreateVideoTrack(video_track_label, NULL));
639 stream->AddTrack(video_track.get()); 640 stream->AddTrack(video_track.get());
640 EXPECT_TRUE(pc_->AddStream(stream)); 641 EXPECT_TRUE(pc_->AddStream(stream));
641 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); 642 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
642 observer_.renegotiation_needed_ = false; 643 observer_.renegotiation_needed_ = false;
643 } 644 }
644 645
645 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc, bool offer) { 646 bool DoCreateOfferAnswer(SessionDescriptionInterface** desc,
647 bool offer,
648 MediaConstraintsInterface* constraints = nullptr) {
pthatcher1 2015/10/15 06:02:03 Usually our style is to not have optional args, bu
Taylor Brandstetter 2015/10/15 18:23:36 Done.
646 rtc::scoped_refptr<MockCreateSessionDescriptionObserver> 649 rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
647 observer(new rtc::RefCountedObject< 650 observer(new rtc::RefCountedObject<
648 MockCreateSessionDescriptionObserver>()); 651 MockCreateSessionDescriptionObserver>());
649 if (offer) { 652 if (offer) {
650 pc_->CreateOffer(observer, NULL); 653 pc_->CreateOffer(observer, constraints);
651 } else { 654 } else {
652 pc_->CreateAnswer(observer, NULL); 655 pc_->CreateAnswer(observer, constraints);
653 } 656 }
654 EXPECT_EQ_WAIT(true, observer->called(), kTimeout); 657 EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
655 *desc = observer->release_desc(); 658 *desc = observer->release_desc();
656 return observer->result(); 659 return observer->result();
657 } 660 }
658 661
659 bool DoCreateOffer(SessionDescriptionInterface** desc) { 662 bool DoCreateOffer(SessionDescriptionInterface** desc,
660 return DoCreateOfferAnswer(desc, true); 663 MediaConstraintsInterface* constraints = nullptr) {
664 return DoCreateOfferAnswer(desc, true, constraints);
661 } 665 }
662 666
663 bool DoCreateAnswer(SessionDescriptionInterface** desc) { 667 bool DoCreateAnswer(SessionDescriptionInterface** desc,
664 return DoCreateOfferAnswer(desc, false); 668 MediaConstraintsInterface* constraints = nullptr) {
669 return DoCreateOfferAnswer(desc, false, constraints);
665 } 670 }
666 671
667 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) { 672 bool DoSetSessionDescription(SessionDescriptionInterface* desc, bool local) {
668 rtc::scoped_refptr<MockSetSessionDescriptionObserver> 673 rtc::scoped_refptr<MockSetSessionDescriptionObserver>
669 observer(new rtc::RefCountedObject< 674 observer(new rtc::RefCountedObject<
670 MockSetSessionDescriptionObserver>()); 675 MockSetSessionDescriptionObserver>());
671 if (local) { 676 if (local) {
672 pc_->SetLocalDescription(observer, desc); 677 pc_->SetLocalDescription(observer, desc);
673 } else { 678 } else {
674 pc_->SetRemoteDescription(observer, desc); 679 pc_->SetRemoteDescription(observer, desc);
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 EXPECT_TRUE(DoSetSessionDescription(answer, false)); 1570 EXPECT_TRUE(DoSetSessionDescription(answer, false));
1566 1571
1567 SessionDescriptionInterface* updated_offer = 1572 SessionDescriptionInterface* updated_offer =
1568 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, 1573 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer,
1569 webrtc::kAudioSdpWithUnsupportedCodecs, 1574 webrtc::kAudioSdpWithUnsupportedCodecs,
1570 nullptr); 1575 nullptr);
1571 EXPECT_TRUE(DoSetSessionDescription(updated_offer, false)); 1576 EXPECT_TRUE(DoSetSessionDescription(updated_offer, false));
1572 CreateAnswerAsLocalDescription(); 1577 CreateAnswerAsLocalDescription();
1573 } 1578 }
1574 1579
1580 // Test that if we're receiving (but not sending) a track, subsequent offers
1581 // will have m-lines with a=recvonly.
1582 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
1583 FakeConstraints constraints;
1584 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1585 true);
1586 CreatePeerConnection(&constraints);
1587 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1588 CreateAnswerAsLocalDescription();
1589
1590 // At this point we should be receiving stream 1, but not sending anything.
1591 // A new offer should be recvonly.
1592 SessionDescriptionInterface* offer;
1593 DoCreateOffer(&offer);
1594
1595 const cricket::ContentInfo* video_content =
1596 cricket::GetFirstVideoContent(offer->description());
1597 const cricket::VideoContentDescription* video_desc =
1598 static_cast<const cricket::VideoContentDescription*>(
1599 video_content->description);
1600 ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction());
1601
1602 const cricket::ContentInfo* audio_content =
1603 cricket::GetFirstAudioContent(offer->description());
1604 const cricket::AudioContentDescription* audio_desc =
1605 static_cast<const cricket::AudioContentDescription*>(
1606 audio_content->description);
1607 ASSERT_EQ(cricket::MD_RECVONLY, audio_desc->direction());
1608 }
1609
1610 // Test that if we're receiving (but not sending) a track, and the
1611 // offerToReceiveVideo/offerToReceiveAudio constraints are explicitly set to
1612 // false, the generated m-lines will be a=inactive.
1613 TEST_F(PeerConnectionInterfaceTest, CreateSubsequentInactiveOffer) {
1614 FakeConstraints constraints;
1615 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
1616 true);
1617 CreatePeerConnection(&constraints);
1618 CreateAndSetRemoteOffer(kSdpStringWithStream1);
1619 CreateAnswerAsLocalDescription();
1620
1621 // At this point we should be receiving stream 1, but not sending anything.
1622 // A new offer should be recvonly.
1623 SessionDescriptionInterface* offer;
1624 FakeConstraints offer_constraints;
1625 offer_constraints.AddMandatory(
1626 webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false);
1627 offer_constraints.AddMandatory(
1628 webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false);
1629 DoCreateOffer(&offer, &offer_constraints);
1630
1631 const cricket::ContentInfo* video_content =
1632 cricket::GetFirstVideoContent(offer->description());
1633 const cricket::VideoContentDescription* video_desc =
1634 static_cast<const cricket::VideoContentDescription*>(
1635 video_content->description);
1636 ASSERT_EQ(cricket::MD_INACTIVE, video_desc->direction());
1637
1638 const cricket::ContentInfo* audio_content =
1639 cricket::GetFirstAudioContent(offer->description());
1640 const cricket::AudioContentDescription* audio_desc =
1641 static_cast<const cricket::AudioContentDescription*>(
1642 audio_content->description);
1643 ASSERT_EQ(cricket::MD_INACTIVE, audio_desc->direction());
1644 }
1645
1575 // Test that PeerConnection::Close changes the states to closed and all remote 1646 // Test that PeerConnection::Close changes the states to closed and all remote
1576 // tracks change state to ended. 1647 // tracks change state to ended.
1577 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { 1648 TEST_F(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) {
1578 // Initialize a PeerConnection and negotiate local and remote session 1649 // Initialize a PeerConnection and negotiate local and remote session
1579 // description. 1650 // description.
1580 InitiateCall(); 1651 InitiateCall();
1581 ASSERT_EQ(1u, pc_->local_streams()->count()); 1652 ASSERT_EQ(1u, pc_->local_streams()->count());
1582 ASSERT_EQ(1u, pc_->remote_streams()->count()); 1653 ASSERT_EQ(1u, pc_->remote_streams()->count());
1583 1654
1584 pc_->Close(); 1655 pc_->Close();
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2119 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2049 } 2120 }
2050 2121
2051 // The following tests verify that session options are created correctly. 2122 // The following tests verify that session options are created correctly.
2052 2123
2053 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { 2124 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) {
2054 RTCOfferAnswerOptions rtc_options; 2125 RTCOfferAnswerOptions rtc_options;
2055 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; 2126 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1;
2056 2127
2057 cricket::MediaSessionOptions options; 2128 cricket::MediaSessionOptions options;
2058 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2129 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2059 2130
2060 rtc_options.offer_to_receive_audio = 2131 rtc_options.offer_to_receive_audio =
2061 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2132 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2062 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2133 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2063 } 2134 }
2064 2135
2065 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { 2136 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) {
2066 RTCOfferAnswerOptions rtc_options; 2137 RTCOfferAnswerOptions rtc_options;
2067 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; 2138 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1;
2068 2139
2069 cricket::MediaSessionOptions options; 2140 cricket::MediaSessionOptions options;
2070 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2141 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2071 2142
2072 rtc_options.offer_to_receive_video = 2143 rtc_options.offer_to_receive_video =
2073 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2144 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2074 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2145 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2075 } 2146 }
2076 2147
2077 // Test that a MediaSessionOptions is created for an offer if 2148 // Test that a MediaSessionOptions is created for an offer if
2078 // OfferToReceiveAudio and OfferToReceiveVideo options are set but no 2149 // OfferToReceiveAudio and OfferToReceiveVideo options are set but no
2079 // MediaStreams are sent. 2150 // MediaStreams are sent.
2080 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { 2151 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) {
2081 RTCOfferAnswerOptions rtc_options; 2152 RTCOfferAnswerOptions rtc_options;
2082 rtc_options.offer_to_receive_audio = 1; 2153 rtc_options.offer_to_receive_audio = 1;
2083 rtc_options.offer_to_receive_video = 1; 2154 rtc_options.offer_to_receive_video = 1;
2084 2155
2085 cricket::MediaSessionOptions options; 2156 cricket::MediaSessionOptions options;
2086 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2157 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2087 EXPECT_TRUE(options.has_audio()); 2158 EXPECT_TRUE(options.has_audio());
2088 EXPECT_TRUE(options.has_video()); 2159 EXPECT_TRUE(options.has_video());
2089 EXPECT_TRUE(options.bundle_enabled); 2160 EXPECT_TRUE(options.bundle_enabled);
2090 } 2161 }
2091 2162
2092 // Test that a correct MediaSessionOptions is created for an offer if 2163 // Test that a correct MediaSessionOptions is created for an offer if
2093 // OfferToReceiveAudio is set but no MediaStreams are sent. 2164 // OfferToReceiveAudio is set but no MediaStreams are sent.
2094 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { 2165 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) {
2095 RTCOfferAnswerOptions rtc_options; 2166 RTCOfferAnswerOptions rtc_options;
2096 rtc_options.offer_to_receive_audio = 1; 2167 rtc_options.offer_to_receive_audio = 1;
2097 2168
2098 cricket::MediaSessionOptions options; 2169 cricket::MediaSessionOptions options;
2099 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2170 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2100 EXPECT_TRUE(options.has_audio()); 2171 EXPECT_TRUE(options.has_audio());
2101 EXPECT_FALSE(options.has_video()); 2172 EXPECT_FALSE(options.has_video());
2102 EXPECT_TRUE(options.bundle_enabled); 2173 EXPECT_TRUE(options.bundle_enabled);
2103 } 2174 }
2104 2175
2105 // Test that a correct MediaSessionOptions is created for an offer if 2176 // Test that a correct MediaSessionOptions is created for an offer if
2106 // the default OfferOptons is used or MediaStreams are sent. 2177 // the default OfferOptions are used and no MediaStreams are sent.
2107 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { 2178 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) {
2108 RTCOfferAnswerOptions rtc_options; 2179 RTCOfferAnswerOptions rtc_options;
2109 2180
2110 cricket::MediaSessionOptions options; 2181 cricket::MediaSessionOptions options;
2111 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2182 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2112 EXPECT_FALSE(options.has_audio()); 2183 EXPECT_FALSE(options.has_audio());
2113 EXPECT_FALSE(options.has_video()); 2184 EXPECT_FALSE(options.has_video());
2114 EXPECT_FALSE(options.bundle_enabled); 2185 EXPECT_FALSE(options.bundle_enabled);
2115 EXPECT_TRUE(options.vad_enabled); 2186 EXPECT_TRUE(options.vad_enabled);
2116 EXPECT_FALSE(options.transport_options.ice_restart); 2187 EXPECT_FALSE(options.transport_options.ice_restart);
2117 } 2188 }
2118 2189
2119 // Test that a correct MediaSessionOptions is created for an offer if 2190 // Test that a correct MediaSessionOptions is created for an offer if
2191 // the default OfferOptions are used and no MediaStreams are sent, but
2192 // MediaStreams are being received.
2193 TEST(CreateSessionOptionsTest,
2194 GetDefaultMediaSessionOptionsForAlreadyReceivingOffer) {
2195 RTCOfferAnswerOptions rtc_options;
2196
2197 cricket::MediaSessionOptions options;
2198 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, true, true));
2199 EXPECT_TRUE(options.has_audio());
2200 EXPECT_TRUE(options.has_video());
2201 EXPECT_TRUE(options.bundle_enabled);
2202 EXPECT_TRUE(options.vad_enabled);
2203 EXPECT_FALSE(options.transport_options.ice_restart);
2204 }
2205
2206 // Test that a correct MediaSessionOptions is created for an offer if
2120 // OfferToReceiveVideo is set but no MediaStreams are sent. 2207 // OfferToReceiveVideo is set but no MediaStreams are sent.
2121 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { 2208 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) {
2122 RTCOfferAnswerOptions rtc_options; 2209 RTCOfferAnswerOptions rtc_options;
2123 rtc_options.offer_to_receive_audio = 0; 2210 rtc_options.offer_to_receive_audio = 0;
2124 rtc_options.offer_to_receive_video = 1; 2211 rtc_options.offer_to_receive_video = 1;
2125 2212
2126 cricket::MediaSessionOptions options; 2213 cricket::MediaSessionOptions options;
2127 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2214 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2128 EXPECT_FALSE(options.has_audio()); 2215 EXPECT_FALSE(options.has_audio());
2129 EXPECT_TRUE(options.has_video()); 2216 EXPECT_TRUE(options.has_video());
2130 EXPECT_TRUE(options.bundle_enabled); 2217 EXPECT_TRUE(options.bundle_enabled);
2131 } 2218 }
2132 2219
2133 // Test that a correct MediaSessionOptions is created for an offer if 2220 // Test that a correct MediaSessionOptions is created for an offer if
2134 // UseRtpMux is set to false. 2221 // UseRtpMux is set to false.
2135 TEST(CreateSessionOptionsTest, 2222 TEST(CreateSessionOptionsTest,
2136 GetMediaSessionOptionsForOfferWithBundleDisabled) { 2223 GetMediaSessionOptionsForOfferWithBundleDisabled) {
2137 RTCOfferAnswerOptions rtc_options; 2224 RTCOfferAnswerOptions rtc_options;
2138 rtc_options.offer_to_receive_audio = 1; 2225 rtc_options.offer_to_receive_audio = 1;
2139 rtc_options.offer_to_receive_video = 1; 2226 rtc_options.offer_to_receive_video = 1;
2140 rtc_options.use_rtp_mux = false; 2227 rtc_options.use_rtp_mux = false;
2141 2228
2142 cricket::MediaSessionOptions options; 2229 cricket::MediaSessionOptions options;
2143 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2230 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2144 EXPECT_TRUE(options.has_audio()); 2231 EXPECT_TRUE(options.has_audio());
2145 EXPECT_TRUE(options.has_video()); 2232 EXPECT_TRUE(options.has_video());
2146 EXPECT_FALSE(options.bundle_enabled); 2233 EXPECT_FALSE(options.bundle_enabled);
2147 } 2234 }
2148 2235
2149 // Test that a correct MediaSessionOptions is created to restart ice if 2236 // Test that a correct MediaSessionOptions is created to restart ice if
2150 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't 2237 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't
2151 // have |transport_options.ice_restart| set. 2238 // have |transport_options.ice_restart| set.
2152 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) { 2239 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) {
2153 RTCOfferAnswerOptions rtc_options; 2240 RTCOfferAnswerOptions rtc_options;
2154 rtc_options.ice_restart = true; 2241 rtc_options.ice_restart = true;
2155 2242
2156 cricket::MediaSessionOptions options; 2243 cricket::MediaSessionOptions options;
2157 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2244 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2158 EXPECT_TRUE(options.transport_options.ice_restart); 2245 EXPECT_TRUE(options.transport_options.ice_restart);
2159 2246
2160 rtc_options = RTCOfferAnswerOptions(); 2247 rtc_options = RTCOfferAnswerOptions();
2161 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2248 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options, false, false));
2162 EXPECT_FALSE(options.transport_options.ice_restart); 2249 EXPECT_FALSE(options.transport_options.ice_restart);
2163 } 2250 }
2164 2251
2165 // Test that the MediaConstraints in an answer don't affect if audio and video 2252 // Test that the MediaConstraints in an answer don't affect if audio and video
2166 // is offered in an offer but that if kOfferToReceiveAudio or 2253 // is offered in an offer but that if kOfferToReceiveAudio or
2167 // kOfferToReceiveVideo constraints are true in an offer, the media type will be 2254 // kOfferToReceiveVideo constraints are true in an offer, the media type will be
2168 // included in subsequent answers. 2255 // included in subsequent answers.
2169 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { 2256 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) {
2170 FakeConstraints answer_c; 2257 FakeConstraints answer_c;
2171 answer_c.SetMandatoryReceiveAudio(true); 2258 answer_c.SetMandatoryReceiveAudio(true);
2172 answer_c.SetMandatoryReceiveVideo(true); 2259 answer_c.SetMandatoryReceiveVideo(true);
2173 2260
2174 cricket::MediaSessionOptions answer_options; 2261 cricket::MediaSessionOptions answer_options;
2175 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); 2262 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options));
2176 EXPECT_TRUE(answer_options.has_audio()); 2263 EXPECT_TRUE(answer_options.has_audio());
2177 EXPECT_TRUE(answer_options.has_video()); 2264 EXPECT_TRUE(answer_options.has_video());
2178 2265
2179 RTCOfferAnswerOptions rtc_offer_optoins; 2266 RTCOfferAnswerOptions rtc_offer_optoins;
2180 2267
2181 cricket::MediaSessionOptions offer_options; 2268 cricket::MediaSessionOptions offer_options;
2182 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_offer_optoins, &offer_options)); 2269 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_offer_optoins, &offer_options,
2270 false, false));
2183 EXPECT_FALSE(offer_options.has_audio()); 2271 EXPECT_FALSE(offer_options.has_audio());
2184 EXPECT_FALSE(offer_options.has_video()); 2272 EXPECT_FALSE(offer_options.has_video());
2185 2273
2186 RTCOfferAnswerOptions updated_rtc_offer_optoins; 2274 RTCOfferAnswerOptions updated_rtc_offer_optoins;
2187 updated_rtc_offer_optoins.offer_to_receive_audio = 1; 2275 updated_rtc_offer_optoins.offer_to_receive_audio = 1;
2188 updated_rtc_offer_optoins.offer_to_receive_video = 1; 2276 updated_rtc_offer_optoins.offer_to_receive_video = 1;
2189 2277
2190 cricket::MediaSessionOptions updated_offer_options; 2278 cricket::MediaSessionOptions updated_offer_options;
2191 EXPECT_TRUE(ConvertRtcOptionsForOffer(updated_rtc_offer_optoins, 2279 EXPECT_TRUE(ConvertRtcOptionsForOffer(updated_rtc_offer_optoins,
2192 &updated_offer_options)); 2280 &updated_offer_options, false, false));
2193 EXPECT_TRUE(updated_offer_options.has_audio()); 2281 EXPECT_TRUE(updated_offer_options.has_audio());
2194 EXPECT_TRUE(updated_offer_options.has_video()); 2282 EXPECT_TRUE(updated_offer_options.has_video());
2195 2283
2196 // Since an offer has been created with both audio and video, subsequent 2284 // Since an offer has been created with both audio and video, subsequent
2197 // offers and answers should contain both audio and video. 2285 // offers and answers should contain both audio and video.
2198 // Answers will only contain the media types that exist in the offer 2286 // Answers will only contain the media types that exist in the offer
2199 // regardless of the value of |updated_answer_options.has_audio| and 2287 // regardless of the value of |updated_answer_options.has_audio| and
2200 // |updated_answer_options.has_video|. 2288 // |updated_answer_options.has_video|.
2201 FakeConstraints updated_answer_c; 2289 FakeConstraints updated_answer_c;
2202 answer_c.SetMandatoryReceiveAudio(false); 2290 answer_c.SetMandatoryReceiveAudio(false);
2203 answer_c.SetMandatoryReceiveVideo(false); 2291 answer_c.SetMandatoryReceiveVideo(false);
2204 2292
2205 cricket::MediaSessionOptions updated_answer_options; 2293 cricket::MediaSessionOptions updated_answer_options;
2206 EXPECT_TRUE( 2294 EXPECT_TRUE(
2207 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2295 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2208 EXPECT_TRUE(updated_answer_options.has_audio()); 2296 EXPECT_TRUE(updated_answer_options.has_audio());
2209 EXPECT_TRUE(updated_answer_options.has_video()); 2297 EXPECT_TRUE(updated_answer_options.has_video());
2210 2298
2211 RTCOfferAnswerOptions default_rtc_options; 2299 RTCOfferAnswerOptions default_rtc_options;
2212 EXPECT_TRUE( 2300 EXPECT_TRUE(ConvertRtcOptionsForOffer(default_rtc_options,
2213 ConvertRtcOptionsForOffer(default_rtc_options, &updated_offer_options)); 2301 &updated_offer_options, false, false));
2214 // By default, |has_audio| or |has_video| are false if there is no media 2302 // By default, |has_audio| or |has_video| are false if there is no media
2215 // track. 2303 // track.
2216 EXPECT_FALSE(updated_offer_options.has_audio()); 2304 EXPECT_FALSE(updated_offer_options.has_audio());
2217 EXPECT_FALSE(updated_offer_options.has_video()); 2305 EXPECT_FALSE(updated_offer_options.has_video());
2218 } 2306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698