| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #define ASSERT_CRYPTO(cd, s, cs) \ | 28 #define ASSERT_CRYPTO(cd, s, cs) \ |
| 29 ASSERT_EQ(s, cd->cryptos().size()); \ | 29 ASSERT_EQ(s, cd->cryptos().size()); \ |
| 30 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) | 30 ASSERT_EQ(std::string(cs), cd->cryptos()[0].cipher_suite) |
| 31 | 31 |
| 32 typedef std::vector<cricket::Candidate> Candidates; | 32 typedef std::vector<cricket::Candidate> Candidates; |
| 33 | 33 |
| 34 using cricket::MediaContentDescription; | 34 using cricket::MediaContentDescription; |
| 35 using cricket::MediaSessionDescriptionFactory; | 35 using cricket::MediaSessionDescriptionFactory; |
| 36 using cricket::MediaContentDirection; | 36 using cricket::MediaContentDirection; |
| 37 using cricket::MediaDescriptionOptions; |
| 37 using cricket::MediaSessionOptions; | 38 using cricket::MediaSessionOptions; |
| 38 using cricket::MediaType; | 39 using cricket::MediaType; |
| 39 using cricket::SessionDescription; | 40 using cricket::SessionDescription; |
| 40 using cricket::SsrcGroup; | 41 using cricket::SsrcGroup; |
| 41 using cricket::StreamParams; | 42 using cricket::StreamParams; |
| 42 using cricket::StreamParamsVec; | 43 using cricket::StreamParamsVec; |
| 43 using cricket::TransportDescription; | 44 using cricket::TransportDescription; |
| 44 using cricket::TransportDescriptionFactory; | 45 using cricket::TransportDescriptionFactory; |
| 45 using cricket::TransportInfo; | 46 using cricket::TransportInfo; |
| 46 using cricket::ContentInfo; | 47 using cricket::ContentInfo; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 using cricket::AudioCodec; | 59 using cricket::AudioCodec; |
| 59 using cricket::VideoCodec; | 60 using cricket::VideoCodec; |
| 60 using cricket::DataCodec; | 61 using cricket::DataCodec; |
| 61 using cricket::NS_JINGLE_RTP; | 62 using cricket::NS_JINGLE_RTP; |
| 62 using cricket::MEDIA_TYPE_AUDIO; | 63 using cricket::MEDIA_TYPE_AUDIO; |
| 63 using cricket::MEDIA_TYPE_VIDEO; | 64 using cricket::MEDIA_TYPE_VIDEO; |
| 64 using cricket::MEDIA_TYPE_DATA; | 65 using cricket::MEDIA_TYPE_DATA; |
| 65 using cricket::SEC_DISABLED; | 66 using cricket::SEC_DISABLED; |
| 66 using cricket::SEC_ENABLED; | 67 using cricket::SEC_ENABLED; |
| 67 using cricket::SEC_REQUIRED; | 68 using cricket::SEC_REQUIRED; |
| 69 using cricket::RtpTransceiverDirection; |
| 68 using rtc::CS_AES_CM_128_HMAC_SHA1_32; | 70 using rtc::CS_AES_CM_128_HMAC_SHA1_32; |
| 69 using rtc::CS_AES_CM_128_HMAC_SHA1_80; | 71 using rtc::CS_AES_CM_128_HMAC_SHA1_80; |
| 70 using rtc::CS_AEAD_AES_128_GCM; | 72 using rtc::CS_AEAD_AES_128_GCM; |
| 71 using rtc::CS_AEAD_AES_256_GCM; | 73 using rtc::CS_AEAD_AES_256_GCM; |
| 72 using webrtc::RtpExtension; | 74 using webrtc::RtpExtension; |
| 73 | 75 |
| 74 static const AudioCodec kAudioCodecs1[] = { | 76 static const AudioCodec kAudioCodecs1[] = { |
| 75 AudioCodec(103, "ISAC", 16000, -1, 1), | 77 AudioCodec(103, "ISAC", 16000, -1, 1), |
| 76 AudioCodec(102, "iLBC", 8000, 13300, 1), | 78 AudioCodec(102, "iLBC", 8000, 13300, 1), |
| 77 AudioCodec(0, "PCMU", 8000, 64000, 1), | 79 AudioCodec(0, "PCMU", 8000, 64000, 1), |
| 78 AudioCodec(8, "PCMA", 8000, 64000, 1), | 80 AudioCodec(8, "PCMA", 8000, 64000, 1), |
| 79 AudioCodec(117, "red", 8000, 0, 1), | 81 AudioCodec(117, "red", 8000, 0, 1), |
| 80 AudioCodec(107, "CN", 48000, 0, 1)}; | 82 AudioCodec(107, "CN", 48000, 0, 1)}; |
| 81 | 83 |
| 82 static const AudioCodec kAudioCodecs2[] = { | 84 static const AudioCodec kAudioCodecs2[] = { |
| 83 AudioCodec(126, "speex", 16000, 22000, 1), | 85 AudioCodec(126, "speex", 16000, 22000, 1), |
| 84 AudioCodec(0, "PCMU", 8000, 64000, 1), | 86 AudioCodec(0, "PCMU", 8000, 64000, 1), |
| 85 AudioCodec(127, "iLBC", 8000, 13300, 1), | 87 AudioCodec(127, "iLBC", 8000, 13300, 1), |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 static const AudioCodec kAudioCodecsAnswer[] = { | 90 static const AudioCodec kAudioCodecsAnswer[] = { |
| 89 AudioCodec(102, "iLBC", 8000, 13300, 1), | 91 AudioCodec(102, "iLBC", 8000, 13300, 1), |
| 90 AudioCodec(0, "PCMU", 8000, 64000, 1), | 92 AudioCodec(0, "PCMU", 8000, 64000, 1), |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 static const VideoCodec kVideoCodecs1[] = {VideoCodec(96, "H264-SVC"), | 95 static const VideoCodec kVideoCodecs1[] = {VideoCodec(96, "H264-SVC"), |
| 94 VideoCodec(97, "H264")}; | 96 VideoCodec(97, "H264")}; |
| 95 | 97 |
| 98 static const VideoCodec kVideoCodecs1Reverse[] = {VideoCodec(97, "H264"), |
| 99 VideoCodec(96, "H264-SVC")}; |
| 100 |
| 96 static const VideoCodec kVideoCodecs2[] = {VideoCodec(126, "H264"), | 101 static const VideoCodec kVideoCodecs2[] = {VideoCodec(126, "H264"), |
| 97 VideoCodec(127, "H263")}; | 102 VideoCodec(127, "H263")}; |
| 98 | 103 |
| 99 static const VideoCodec kVideoCodecsAnswer[] = {VideoCodec(97, "H264")}; | 104 static const VideoCodec kVideoCodecsAnswer[] = {VideoCodec(97, "H264")}; |
| 100 | 105 |
| 101 static const DataCodec kDataCodecs1[] = {DataCodec(98, "binary-data"), | 106 static const DataCodec kDataCodecs1[] = {DataCodec(98, "binary-data"), |
| 102 DataCodec(99, "utf8-text")}; | 107 DataCodec(99, "utf8-text")}; |
| 103 | 108 |
| 104 static const DataCodec kDataCodecs2[] = {DataCodec(126, "binary-data"), | 109 static const DataCodec kDataCodecs2[] = {DataCodec(126, "binary-data"), |
| 105 DataCodec(127, "utf8-text")}; | 110 DataCodec(127, "utf8-text")}; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 static const char kDataTrack1[] = "data_1"; | 206 static const char kDataTrack1[] = "data_1"; |
| 202 static const char kDataTrack2[] = "data_2"; | 207 static const char kDataTrack2[] = "data_2"; |
| 203 static const char kDataTrack3[] = "data_3"; | 208 static const char kDataTrack3[] = "data_3"; |
| 204 | 209 |
| 205 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", | 210 static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF", |
| 206 "RTP/SAVPF"}; | 211 "RTP/SAVPF"}; |
| 207 static const char* kMediaProtocolsDtls[] = { | 212 static const char* kMediaProtocolsDtls[] = { |
| 208 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", | 213 "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF", |
| 209 "UDP/TLS/RTP/SAVP"}; | 214 "UDP/TLS/RTP/SAVP"}; |
| 210 | 215 |
| 216 // These constants are used to make the code using "AddMediaSection" more |
| 217 // readable. |
| 218 static constexpr bool kStopped = true; |
| 219 static constexpr bool kActive = false; |
| 220 |
| 211 static bool IsMediaContentOfType(const ContentInfo* content, | 221 static bool IsMediaContentOfType(const ContentInfo* content, |
| 212 MediaType media_type) { | 222 MediaType media_type) { |
| 213 const MediaContentDescription* mdesc = | 223 const MediaContentDescription* mdesc = |
| 214 static_cast<const MediaContentDescription*>(content->description); | 224 static_cast<const MediaContentDescription*>(content->description); |
| 215 return mdesc && mdesc->type() == media_type; | 225 return mdesc && mdesc->type() == media_type; |
| 216 } | 226 } |
| 217 | 227 |
| 218 static cricket::MediaContentDirection | 228 static cricket::MediaContentDirection |
| 219 GetMediaDirection(const ContentInfo* content) { | 229 GetMediaDirection(const ContentInfo* content) { |
| 220 cricket::MediaContentDescription* desc = | 230 cricket::MediaContentDescription* desc = |
| 221 reinterpret_cast<cricket::MediaContentDescription*>(content->description); | 231 reinterpret_cast<cricket::MediaContentDescription*>(content->description); |
| 222 return desc->direction(); | 232 return desc->direction(); |
| 223 } | 233 } |
| 224 | 234 |
| 225 static void AddRtxCodec(const VideoCodec& rtx_codec, | 235 static void AddRtxCodec(const VideoCodec& rtx_codec, |
| 226 std::vector<VideoCodec>* codecs) { | 236 std::vector<VideoCodec>* codecs) { |
| 227 ASSERT_FALSE(cricket::FindCodecById(*codecs, rtx_codec.id)); | 237 ASSERT_FALSE(cricket::FindCodecById(*codecs, rtx_codec.id)); |
| 228 codecs->push_back(rtx_codec); | 238 codecs->push_back(rtx_codec); |
| 229 } | 239 } |
| 230 | 240 |
| 231 template <class T> | 241 template <class T> |
| 232 static std::vector<std::string> GetCodecNames(const std::vector<T>& codecs) { | 242 static std::vector<std::string> GetCodecNames(const std::vector<T>& codecs) { |
| 233 std::vector<std::string> codec_names; | 243 std::vector<std::string> codec_names; |
| 234 for (const auto& codec : codecs) { | 244 for (const auto& codec : codecs) { |
| 235 codec_names.push_back(codec.name); | 245 codec_names.push_back(codec.name); |
| 236 } | 246 } |
| 237 return codec_names; | 247 return codec_names; |
| 238 } | 248 } |
| 239 | 249 |
| 250 // This is used for test only. MIDs are not the identification of the |
| 251 // MediaDescriptionOptions since some end points may not support MID and the SDP |
| 252 // may not contain 'mid'. |
| 253 std::vector<MediaDescriptionOptions>::iterator FindFirstMediaDescriptionByMid( |
| 254 const std::string& mid, |
| 255 MediaSessionOptions* opts) { |
| 256 return std::find_if( |
| 257 opts->media_description_options.begin(), |
| 258 opts->media_description_options.end(), |
| 259 [mid](const MediaDescriptionOptions& t) { return t.mid == mid; }); |
| 260 } |
| 261 |
| 262 // Add a media section to the |session_options|. |
| 263 static void AddMediaSection(MediaType type, |
| 264 const std::string& mid, |
| 265 MediaContentDirection direction, |
| 266 bool stopped, |
| 267 MediaSessionOptions* opts) { |
| 268 opts->media_description_options.push_back(MediaDescriptionOptions( |
| 269 type, mid, |
| 270 cricket::RtpTransceiverDirection::FromMediaContentDirection(direction), |
| 271 stopped)); |
| 272 } |
| 273 |
| 274 static void AddAudioVideoSections(MediaContentDirection direction, |
| 275 MediaSessionOptions* opts) { |
| 276 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, kActive, opts); |
| 277 AddMediaSection(MEDIA_TYPE_VIDEO, "video", direction, kActive, opts); |
| 278 } |
| 279 |
| 280 static void AddDataSection(cricket::DataChannelType dct, |
| 281 MediaContentDirection direction, |
| 282 MediaSessionOptions* opts) { |
| 283 opts->data_channel_type = dct; |
| 284 AddMediaSection(MEDIA_TYPE_DATA, "data", direction, kActive, opts); |
| 285 } |
| 286 |
| 287 static void AttachSenderToMediaSection(const std::string& mid, |
| 288 MediaType type, |
| 289 const std::string& track_id, |
| 290 const std::string& stream_id, |
| 291 int num_sim_layer, |
| 292 MediaSessionOptions* session_options) { |
| 293 auto it = FindFirstMediaDescriptionByMid(mid, session_options); |
| 294 switch (type) { |
| 295 case MEDIA_TYPE_AUDIO: |
| 296 it->AddAudioSender(track_id, stream_id); |
| 297 break; |
| 298 case MEDIA_TYPE_VIDEO: |
| 299 it->AddVideoSender(track_id, stream_id, num_sim_layer); |
| 300 break; |
| 301 case MEDIA_TYPE_DATA: |
| 302 it->AddRtpDataChannel(track_id, stream_id); |
| 303 break; |
| 304 default: |
| 305 RTC_NOTREACHED(); |
| 306 } |
| 307 } |
| 308 |
| 309 static void DetachSenderFromMediaSection(const std::string& mid, |
| 310 const std::string& track_id, |
| 311 MediaSessionOptions* session_options) { |
| 312 auto it = FindFirstMediaDescriptionByMid(mid, session_options); |
| 313 auto sender_it = it->sender_options.begin(); |
| 314 for (; sender_it != it->sender_options.end(); ++sender_it) { |
| 315 if (sender_it->track_id == track_id) { |
| 316 it->sender_options.erase(sender_it); |
| 317 return; |
| 318 } |
| 319 } |
| 320 RTC_NOTREACHED(); |
| 321 } |
| 322 |
| 323 // Helper function used to create a default MediaSessionOptions for Plan B SDP. |
| 324 // (https://tools.ietf.org/html/draft-uberti-rtcweb-plan-00). |
| 325 static MediaSessionOptions CreatePlanBMediaSessionOptions() { |
| 326 MediaSessionOptions session_options; |
| 327 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 328 &session_options); |
| 329 return session_options; |
| 330 } |
| 331 |
| 332 // TODO(zhihuang): Most of these tests were written while MediaSessionOptions |
| 333 // was designed for Plan B SDP, where only one audio "m=" section and one video |
| 334 // "m=" section could be generated, and ordering couldn't be controlled. Many of |
| 335 // these tests may be obsolete as a result, and should be refactored or removed. |
| 240 class MediaSessionDescriptionFactoryTest : public testing::Test { | 336 class MediaSessionDescriptionFactoryTest : public testing::Test { |
| 241 public: | 337 public: |
| 242 MediaSessionDescriptionFactoryTest() | 338 MediaSessionDescriptionFactoryTest() : f1_(&tdf1_), f2_(&tdf2_) { |
| 243 : f1_(&tdf1_), | |
| 244 f2_(&tdf2_) { | |
| 245 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), | 339 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), |
| 246 MAKE_VECTOR(kAudioCodecs1)); | 340 MAKE_VECTOR(kAudioCodecs1)); |
| 247 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | 341 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); |
| 248 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | 342 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); |
| 249 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), | 343 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), |
| 250 MAKE_VECTOR(kAudioCodecs2)); | 344 MAKE_VECTOR(kAudioCodecs2)); |
| 251 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | 345 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); |
| 252 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); | 346 f2_.set_data_codecs(MAKE_VECTOR(kDataCodecs2)); |
| 253 tdf1_.set_certificate(rtc::RTCCertificate::Create( | 347 tdf1_.set_certificate(rtc::RTCCertificate::Create( |
| 254 std::unique_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); | 348 std::unique_ptr<rtc::SSLIdentity>(new rtc::FakeSSLIdentity("id1")))); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // Returns true if the transport info contains "renomination" as an | 392 // Returns true if the transport info contains "renomination" as an |
| 299 // ICE option. | 393 // ICE option. |
| 300 bool GetIceRenomination(const TransportInfo* transport_info) { | 394 bool GetIceRenomination(const TransportInfo* transport_info) { |
| 301 const std::vector<std::string>& ice_options = | 395 const std::vector<std::string>& ice_options = |
| 302 transport_info->description.transport_options; | 396 transport_info->description.transport_options; |
| 303 auto iter = | 397 auto iter = |
| 304 std::find(ice_options.begin(), ice_options.end(), "renomination"); | 398 std::find(ice_options.begin(), ice_options.end(), "renomination"); |
| 305 return iter != ice_options.end(); | 399 return iter != ice_options.end(); |
| 306 } | 400 } |
| 307 | 401 |
| 308 void TestTransportInfo(bool offer, const MediaSessionOptions& options, | 402 void TestTransportInfo(bool offer, |
| 403 MediaSessionOptions& options, |
| 309 bool has_current_desc) { | 404 bool has_current_desc) { |
| 310 const std::string current_audio_ufrag = "current_audio_ufrag"; | 405 const std::string current_audio_ufrag = "current_audio_ufrag"; |
| 311 const std::string current_audio_pwd = "current_audio_pwd"; | 406 const std::string current_audio_pwd = "current_audio_pwd"; |
| 312 const std::string current_video_ufrag = "current_video_ufrag"; | 407 const std::string current_video_ufrag = "current_video_ufrag"; |
| 313 const std::string current_video_pwd = "current_video_pwd"; | 408 const std::string current_video_pwd = "current_video_pwd"; |
| 314 const std::string current_data_ufrag = "current_data_ufrag"; | 409 const std::string current_data_ufrag = "current_data_ufrag"; |
| 315 const std::string current_data_pwd = "current_data_pwd"; | 410 const std::string current_data_pwd = "current_data_pwd"; |
| 316 std::unique_ptr<SessionDescription> current_desc; | 411 std::unique_ptr<SessionDescription> current_desc; |
| 317 std::unique_ptr<SessionDescription> desc; | 412 std::unique_ptr<SessionDescription> desc; |
| 318 if (has_current_desc) { | 413 if (has_current_desc) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 343 EXPECT_TRUE(ti_audio != NULL); | 438 EXPECT_TRUE(ti_audio != NULL); |
| 344 if (has_current_desc) { | 439 if (has_current_desc) { |
| 345 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); | 440 EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag); |
| 346 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); | 441 EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd); |
| 347 } else { | 442 } else { |
| 348 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 443 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
| 349 ti_audio->description.ice_ufrag.size()); | 444 ti_audio->description.ice_ufrag.size()); |
| 350 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 445 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
| 351 ti_audio->description.ice_pwd.size()); | 446 ti_audio->description.ice_pwd.size()); |
| 352 } | 447 } |
| 353 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_audio)); | 448 auto media_desc_options_it = |
| 449 FindFirstMediaDescriptionByMid("audio", &options); |
| 450 EXPECT_EQ( |
| 451 media_desc_options_it->transport_options.enable_ice_renomination, |
| 452 GetIceRenomination(ti_audio)); |
| 354 | 453 |
| 355 } else { | 454 } else { |
| 356 EXPECT_TRUE(ti_audio == NULL); | 455 EXPECT_TRUE(ti_audio == NULL); |
| 357 } | 456 } |
| 358 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); | 457 const TransportInfo* ti_video = desc->GetTransportInfoByName("video"); |
| 359 if (options.has_video()) { | 458 if (options.has_video()) { |
| 360 EXPECT_TRUE(ti_video != NULL); | 459 EXPECT_TRUE(ti_video != NULL); |
| 361 if (options.bundle_enabled) { | 460 if (options.bundle_enabled) { |
| 362 EXPECT_EQ(ti_audio->description.ice_ufrag, | 461 EXPECT_EQ(ti_audio->description.ice_ufrag, |
| 363 ti_video->description.ice_ufrag); | 462 ti_video->description.ice_ufrag); |
| 364 EXPECT_EQ(ti_audio->description.ice_pwd, | 463 EXPECT_EQ(ti_audio->description.ice_pwd, |
| 365 ti_video->description.ice_pwd); | 464 ti_video->description.ice_pwd); |
| 366 } else { | 465 } else { |
| 367 if (has_current_desc) { | 466 if (has_current_desc) { |
| 368 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); | 467 EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag); |
| 369 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); | 468 EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd); |
| 370 } else { | 469 } else { |
| 371 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 470 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
| 372 ti_video->description.ice_ufrag.size()); | 471 ti_video->description.ice_ufrag.size()); |
| 373 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 472 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
| 374 ti_video->description.ice_pwd.size()); | 473 ti_video->description.ice_pwd.size()); |
| 375 } | 474 } |
| 376 } | 475 } |
| 377 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_video)); | 476 auto media_desc_options_it = |
| 477 FindFirstMediaDescriptionByMid("video", &options); |
| 478 EXPECT_EQ( |
| 479 media_desc_options_it->transport_options.enable_ice_renomination, |
| 480 GetIceRenomination(ti_video)); |
| 378 } else { | 481 } else { |
| 379 EXPECT_TRUE(ti_video == NULL); | 482 EXPECT_TRUE(ti_video == NULL); |
| 380 } | 483 } |
| 381 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); | 484 const TransportInfo* ti_data = desc->GetTransportInfoByName("data"); |
| 382 if (options.has_data()) { | 485 if (options.has_data()) { |
| 383 EXPECT_TRUE(ti_data != NULL); | 486 EXPECT_TRUE(ti_data != NULL); |
| 384 if (options.bundle_enabled) { | 487 if (options.bundle_enabled) { |
| 385 EXPECT_EQ(ti_audio->description.ice_ufrag, | 488 EXPECT_EQ(ti_audio->description.ice_ufrag, |
| 386 ti_data->description.ice_ufrag); | 489 ti_data->description.ice_ufrag); |
| 387 EXPECT_EQ(ti_audio->description.ice_pwd, | 490 EXPECT_EQ(ti_audio->description.ice_pwd, |
| 388 ti_data->description.ice_pwd); | 491 ti_data->description.ice_pwd); |
| 389 } else { | 492 } else { |
| 390 if (has_current_desc) { | 493 if (has_current_desc) { |
| 391 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); | 494 EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag); |
| 392 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); | 495 EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd); |
| 393 } else { | 496 } else { |
| 394 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), | 497 EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
| 395 ti_data->description.ice_ufrag.size()); | 498 ti_data->description.ice_ufrag.size()); |
| 396 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), | 499 EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH), |
| 397 ti_data->description.ice_pwd.size()); | 500 ti_data->description.ice_pwd.size()); |
| 398 } | 501 } |
| 399 } | 502 } |
| 400 EXPECT_EQ(options.enable_ice_renomination, GetIceRenomination(ti_data)); | 503 auto media_desc_options_it = |
| 504 FindFirstMediaDescriptionByMid("data", &options); |
| 505 EXPECT_EQ( |
| 506 media_desc_options_it->transport_options.enable_ice_renomination, |
| 507 GetIceRenomination(ti_data)); |
| 401 | 508 |
| 402 } else { | 509 } else { |
| 403 EXPECT_TRUE(ti_video == NULL); | 510 EXPECT_TRUE(ti_video == NULL); |
| 404 } | 511 } |
| 405 } | 512 } |
| 406 | 513 |
| 407 void TestCryptoWithBundle(bool offer) { | 514 void TestCryptoWithBundle(bool offer) { |
| 408 f1_.set_secure(SEC_ENABLED); | 515 f1_.set_secure(SEC_ENABLED); |
| 409 MediaSessionOptions options; | 516 MediaSessionOptions options; |
| 410 options.recv_audio = true; | 517 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 411 options.recv_video = true; | 518 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 412 options.data_channel_type = cricket::DCT_RTP; | |
| 413 std::unique_ptr<SessionDescription> ref_desc; | 519 std::unique_ptr<SessionDescription> ref_desc; |
| 414 std::unique_ptr<SessionDescription> desc; | 520 std::unique_ptr<SessionDescription> desc; |
| 415 if (offer) { | 521 if (offer) { |
| 416 options.bundle_enabled = false; | 522 options.bundle_enabled = false; |
| 417 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 523 ref_desc.reset(f1_.CreateOffer(options, NULL)); |
| 418 options.bundle_enabled = true; | 524 options.bundle_enabled = true; |
| 419 desc.reset(f1_.CreateOffer(options, ref_desc.get())); | 525 desc.reset(f1_.CreateOffer(options, ref_desc.get())); |
| 420 } else { | 526 } else { |
| 421 options.bundle_enabled = true; | 527 options.bundle_enabled = true; |
| 422 ref_desc.reset(f1_.CreateOffer(options, NULL)); | 528 ref_desc.reset(f1_.CreateOffer(options, NULL)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 448 audio_media_desc->cryptos()[0])) { | 554 audio_media_desc->cryptos()[0])) { |
| 449 found = true; | 555 found = true; |
| 450 break; | 556 break; |
| 451 } | 557 } |
| 452 } | 558 } |
| 453 EXPECT_TRUE(found); | 559 EXPECT_TRUE(found); |
| 454 } | 560 } |
| 455 | 561 |
| 456 // This test that the audio and video media direction is set to | 562 // This test that the audio and video media direction is set to |
| 457 // |expected_direction_in_answer| in an answer if the offer direction is set | 563 // |expected_direction_in_answer| in an answer if the offer direction is set |
| 458 // to |direction_in_offer|. | 564 // to |direction_in_offer| and the answer is willing to both send and receive. |
| 459 void TestMediaDirectionInAnswer( | 565 void TestMediaDirectionInAnswer( |
| 460 cricket::MediaContentDirection direction_in_offer, | 566 cricket::MediaContentDirection direction_in_offer, |
| 461 cricket::MediaContentDirection expected_direction_in_answer) { | 567 cricket::MediaContentDirection expected_direction_in_answer) { |
| 462 MediaSessionOptions opts; | 568 MediaSessionOptions offer_opts; |
| 463 opts.recv_video = true; | 569 AddAudioVideoSections(direction_in_offer, &offer_opts); |
| 464 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 570 |
| 571 std::unique_ptr<SessionDescription> offer( |
| 572 f1_.CreateOffer(offer_opts, NULL)); |
| 465 ASSERT_TRUE(offer.get() != NULL); | 573 ASSERT_TRUE(offer.get() != NULL); |
| 466 ContentInfo* ac_offer = offer->GetContentByName("audio"); | 574 ContentInfo* ac_offer = offer->GetContentByName("audio"); |
| 467 ASSERT_TRUE(ac_offer != NULL); | 575 ASSERT_TRUE(ac_offer != NULL); |
| 468 AudioContentDescription* acd_offer = | |
| 469 static_cast<AudioContentDescription*>(ac_offer->description); | |
| 470 acd_offer->set_direction(direction_in_offer); | |
| 471 ContentInfo* vc_offer = offer->GetContentByName("video"); | 576 ContentInfo* vc_offer = offer->GetContentByName("video"); |
| 472 ASSERT_TRUE(vc_offer != NULL); | 577 ASSERT_TRUE(vc_offer != NULL); |
| 473 VideoContentDescription* vcd_offer = | |
| 474 static_cast<VideoContentDescription*>(vc_offer->description); | |
| 475 vcd_offer->set_direction(direction_in_offer); | |
| 476 | 578 |
| 579 MediaSessionOptions answer_opts; |
| 580 AddAudioVideoSections(cricket::MD_SENDRECV, &answer_opts); |
| 477 std::unique_ptr<SessionDescription> answer( | 581 std::unique_ptr<SessionDescription> answer( |
| 478 f2_.CreateAnswer(offer.get(), opts, NULL)); | 582 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 479 const AudioContentDescription* acd_answer = | 583 const AudioContentDescription* acd_answer = |
| 480 GetFirstAudioContentDescription(answer.get()); | 584 GetFirstAudioContentDescription(answer.get()); |
| 481 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); | 585 EXPECT_EQ(expected_direction_in_answer, acd_answer->direction()); |
| 482 const VideoContentDescription* vcd_answer = | 586 const VideoContentDescription* vcd_answer = |
| 483 GetFirstVideoContentDescription(answer.get()); | 587 GetFirstVideoContentDescription(answer.get()); |
| 484 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); | 588 EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction()); |
| 485 } | 589 } |
| 486 | 590 |
| 487 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { | 591 bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { |
| 488 const cricket::ContentDescription* description = content->description; | 592 const cricket::ContentDescription* description = content->description; |
| 489 RTC_CHECK(description != NULL); | 593 RTC_CHECK(description != NULL); |
| 490 const cricket::AudioContentDescription* audio_content_desc = | 594 const cricket::AudioContentDescription* audio_content_desc = |
| 491 static_cast<const cricket::AudioContentDescription*>(description); | 595 static_cast<const cricket::AudioContentDescription*>(description); |
| 492 RTC_CHECK(audio_content_desc != NULL); | 596 RTC_CHECK(audio_content_desc != NULL); |
| 493 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { | 597 for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
| 494 if (audio_content_desc->codecs()[i].name == "CN") | 598 if (audio_content_desc->codecs()[i].name == "CN") |
| 495 return false; | 599 return false; |
| 496 } | 600 } |
| 497 return true; | 601 return true; |
| 498 } | 602 } |
| 499 | 603 |
| 500 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { | 604 void TestVideoGcmCipher(bool gcm_offer, bool gcm_answer) { |
| 501 MediaSessionOptions offer_opts; | 605 MediaSessionOptions offer_opts; |
| 502 offer_opts.recv_video = true; | 606 AddAudioVideoSections(cricket::MD_RECVONLY, &offer_opts); |
| 503 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; | 607 offer_opts.crypto_options.enable_gcm_crypto_suites = gcm_offer; |
| 608 |
| 504 MediaSessionOptions answer_opts; | 609 MediaSessionOptions answer_opts; |
| 505 answer_opts.recv_video = true; | 610 AddAudioVideoSections(cricket::MD_RECVONLY, &answer_opts); |
| 506 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; | 611 answer_opts.crypto_options.enable_gcm_crypto_suites = gcm_answer; |
| 612 |
| 507 f1_.set_secure(SEC_ENABLED); | 613 f1_.set_secure(SEC_ENABLED); |
| 508 f2_.set_secure(SEC_ENABLED); | 614 f2_.set_secure(SEC_ENABLED); |
| 509 std::unique_ptr<SessionDescription> offer( | 615 std::unique_ptr<SessionDescription> offer( |
| 510 f1_.CreateOffer(offer_opts, NULL)); | 616 f1_.CreateOffer(offer_opts, NULL)); |
| 511 ASSERT_TRUE(offer.get() != NULL); | 617 ASSERT_TRUE(offer.get() != NULL); |
| 512 std::unique_ptr<SessionDescription> answer( | 618 std::unique_ptr<SessionDescription> answer( |
| 513 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 619 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 514 const ContentInfo* ac = answer->GetContentByName("audio"); | 620 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 515 const ContentInfo* vc = answer->GetContentByName("video"); | 621 const ContentInfo* vc = answer->GetContentByName("video"); |
| 516 ASSERT_TRUE(ac != NULL); | 622 ASSERT_TRUE(ac != NULL); |
| 517 ASSERT_TRUE(vc != NULL); | 623 ASSERT_TRUE(vc != NULL); |
| 518 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 624 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 519 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 625 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
| 520 const AudioContentDescription* acd = | 626 const AudioContentDescription* acd = |
| 521 static_cast<const AudioContentDescription*>(ac->description); | 627 static_cast<const AudioContentDescription*>(ac->description); |
| 522 const VideoContentDescription* vcd = | 628 const VideoContentDescription* vcd = |
| 523 static_cast<const VideoContentDescription*>(vc->description); | 629 static_cast<const VideoContentDescription*>(vc->description); |
| 524 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 630 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 525 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 631 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 526 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 632 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 527 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 633 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 528 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 634 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 529 if (gcm_offer && gcm_answer) { | 635 if (gcm_offer && gcm_answer) { |
| 530 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 636 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
| 531 } else { | 637 } else { |
| 532 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 638 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
| 533 } | 639 } |
| 534 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 640 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
| 535 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); | 641 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); |
| 536 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 642 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
| 537 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 643 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
| 538 if (gcm_offer && gcm_answer) { | 644 if (gcm_offer && gcm_answer) { |
| 539 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); | 645 ASSERT_CRYPTO(vcd, 1U, CS_AEAD_AES_256_GCM); |
| 540 } else { | 646 } else { |
| 541 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 647 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 542 } | 648 } |
| 543 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 649 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
| 544 } | 650 } |
| 545 | 651 |
| 546 protected: | 652 protected: |
| 547 MediaSessionDescriptionFactory f1_; | 653 MediaSessionDescriptionFactory f1_; |
| 548 MediaSessionDescriptionFactory f2_; | 654 MediaSessionDescriptionFactory f2_; |
| 549 TransportDescriptionFactory tdf1_; | 655 TransportDescriptionFactory tdf1_; |
| 550 TransportDescriptionFactory tdf2_; | 656 TransportDescriptionFactory tdf2_; |
| 551 }; | 657 }; |
| 552 | 658 |
| 553 // Create a typical audio offer, and ensure it matches what we expect. | 659 // Create a typical audio offer, and ensure it matches what we expect. |
| 554 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { | 660 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) { |
| 555 f1_.set_secure(SEC_ENABLED); | 661 f1_.set_secure(SEC_ENABLED); |
| 556 std::unique_ptr<SessionDescription> offer( | 662 std::unique_ptr<SessionDescription> offer( |
| 557 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 663 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
| 558 ASSERT_TRUE(offer.get() != NULL); | 664 ASSERT_TRUE(offer.get() != NULL); |
| 559 const ContentInfo* ac = offer->GetContentByName("audio"); | 665 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 560 const ContentInfo* vc = offer->GetContentByName("video"); | 666 const ContentInfo* vc = offer->GetContentByName("video"); |
| 561 ASSERT_TRUE(ac != NULL); | 667 ASSERT_TRUE(ac != NULL); |
| 562 ASSERT_TRUE(vc == NULL); | 668 ASSERT_TRUE(vc == NULL); |
| 563 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 669 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 564 const AudioContentDescription* acd = | 670 const AudioContentDescription* acd = |
| 565 static_cast<const AudioContentDescription*>(ac->description); | 671 static_cast<const AudioContentDescription*>(ac->description); |
| 566 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 672 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 567 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 673 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
| 568 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 674 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached. |
| 569 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 675 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
| 570 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 676 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
| 571 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 677 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
| 572 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 678 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 573 } | 679 } |
| 574 | 680 |
| 575 // Create a typical video offer, and ensure it matches what we expect. | 681 // Create a typical video offer, and ensure it matches what we expect. |
| 576 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { | 682 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) { |
| 577 MediaSessionOptions opts; | 683 MediaSessionOptions opts; |
| 578 opts.recv_video = true; | 684 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 579 f1_.set_secure(SEC_ENABLED); | 685 f1_.set_secure(SEC_ENABLED); |
| 580 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 686 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 581 ASSERT_TRUE(offer.get() != NULL); | 687 ASSERT_TRUE(offer.get() != NULL); |
| 582 const ContentInfo* ac = offer->GetContentByName("audio"); | 688 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 583 const ContentInfo* vc = offer->GetContentByName("video"); | 689 const ContentInfo* vc = offer->GetContentByName("video"); |
| 584 ASSERT_TRUE(ac != NULL); | 690 ASSERT_TRUE(ac != NULL); |
| 585 ASSERT_TRUE(vc != NULL); | 691 ASSERT_TRUE(vc != NULL); |
| 586 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 692 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 587 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 693 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
| 588 const AudioContentDescription* acd = | 694 const AudioContentDescription* acd = |
| 589 static_cast<const AudioContentDescription*>(ac->description); | 695 static_cast<const AudioContentDescription*>(ac->description); |
| 590 const VideoContentDescription* vcd = | 696 const VideoContentDescription* vcd = |
| 591 static_cast<const VideoContentDescription*>(vc->description); | 697 static_cast<const VideoContentDescription*>(vc->description); |
| 592 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 698 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 593 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 699 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
| 594 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 700 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 595 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 701 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
| 596 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 702 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
| 597 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 703 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
| 598 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 704 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 599 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 705 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
| 600 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); | 706 EXPECT_EQ(f1_.video_codecs(), vcd->codecs()); |
| 601 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 707 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
| 602 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) | 708 EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto) |
| 603 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on | 709 EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on |
| 604 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 710 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 605 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 711 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
| 606 } | 712 } |
| 607 | 713 |
| 608 // Test creating an offer with bundle where the Codecs have the same dynamic | 714 // Test creating an offer with bundle where the Codecs have the same dynamic |
| 609 // RTP playlod type. The test verifies that the offer don't contain the | 715 // RTP playlod type. The test verifies that the offer don't contain the |
| 610 // duplicate RTP payload types. | 716 // duplicate RTP payload types. |
| 611 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { | 717 TEST_F(MediaSessionDescriptionFactoryTest, TestBundleOfferWithSameCodecPlType) { |
| 612 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; | 718 const VideoCodec& offered_video_codec = f2_.video_codecs()[0]; |
| 613 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; | 719 const AudioCodec& offered_audio_codec = f2_.audio_sendrecv_codecs()[0]; |
| 614 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; | 720 const DataCodec& offered_data_codec = f2_.data_codecs()[0]; |
| 615 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); | 721 ASSERT_EQ(offered_video_codec.id, offered_audio_codec.id); |
| 616 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); | 722 ASSERT_EQ(offered_video_codec.id, offered_data_codec.id); |
| 617 | 723 |
| 618 MediaSessionOptions opts; | 724 MediaSessionOptions opts; |
| 619 opts.recv_audio = true; | 725 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 620 opts.recv_video = true; | 726 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 621 opts.data_channel_type = cricket::DCT_RTP; | |
| 622 opts.bundle_enabled = true; | 727 opts.bundle_enabled = true; |
| 623 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); | 728 std::unique_ptr<SessionDescription> offer(f2_.CreateOffer(opts, NULL)); |
| 624 const VideoContentDescription* vcd = | 729 const VideoContentDescription* vcd = |
| 625 GetFirstVideoContentDescription(offer.get()); | 730 GetFirstVideoContentDescription(offer.get()); |
| 626 const AudioContentDescription* acd = | 731 const AudioContentDescription* acd = |
| 627 GetFirstAudioContentDescription(offer.get()); | 732 GetFirstAudioContentDescription(offer.get()); |
| 628 const DataContentDescription* dcd = | 733 const DataContentDescription* dcd = |
| 629 GetFirstDataContentDescription(offer.get()); | 734 GetFirstDataContentDescription(offer.get()); |
| 630 ASSERT_TRUE(NULL != vcd); | 735 ASSERT_TRUE(NULL != vcd); |
| 631 ASSERT_TRUE(NULL != acd); | 736 ASSERT_TRUE(NULL != acd); |
| 632 ASSERT_TRUE(NULL != dcd); | 737 ASSERT_TRUE(NULL != dcd); |
| 633 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); | 738 EXPECT_NE(vcd->codecs()[0].id, acd->codecs()[0].id); |
| 634 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); | 739 EXPECT_NE(vcd->codecs()[0].id, dcd->codecs()[0].id); |
| 635 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); | 740 EXPECT_NE(acd->codecs()[0].id, dcd->codecs()[0].id); |
| 636 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); | 741 EXPECT_EQ(vcd->codecs()[0].name, offered_video_codec.name); |
| 637 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); | 742 EXPECT_EQ(acd->codecs()[0].name, offered_audio_codec.name); |
| 638 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); | 743 EXPECT_EQ(dcd->codecs()[0].name, offered_data_codec.name); |
| 639 } | 744 } |
| 640 | 745 |
| 641 // Test creating an updated offer with with bundle, audio, video and data | 746 // Test creating an updated offer with bundle, audio, video and data |
| 642 // after an audio only session has been negotiated. | 747 // after an audio only session has been negotiated. |
| 643 TEST_F(MediaSessionDescriptionFactoryTest, | 748 TEST_F(MediaSessionDescriptionFactoryTest, |
| 644 TestCreateUpdatedVideoOfferWithBundle) { | 749 TestCreateUpdatedVideoOfferWithBundle) { |
| 645 f1_.set_secure(SEC_ENABLED); | 750 f1_.set_secure(SEC_ENABLED); |
| 646 f2_.set_secure(SEC_ENABLED); | 751 f2_.set_secure(SEC_ENABLED); |
| 647 MediaSessionOptions opts; | 752 MediaSessionOptions opts; |
| 648 opts.recv_audio = true; | 753 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 649 opts.recv_video = false; | 754 &opts); |
| 755 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_INACTIVE, kStopped, |
| 756 &opts); |
| 650 opts.data_channel_type = cricket::DCT_NONE; | 757 opts.data_channel_type = cricket::DCT_NONE; |
| 651 opts.bundle_enabled = true; | 758 opts.bundle_enabled = true; |
| 652 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 759 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 653 std::unique_ptr<SessionDescription> answer( | 760 std::unique_ptr<SessionDescription> answer( |
| 654 f2_.CreateAnswer(offer.get(), opts, NULL)); | 761 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 655 | 762 |
| 656 MediaSessionOptions updated_opts; | 763 MediaSessionOptions updated_opts; |
| 657 updated_opts.recv_audio = true; | 764 AddAudioVideoSections(cricket::MD_RECVONLY, &updated_opts); |
| 658 updated_opts.recv_video = true; | 765 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &updated_opts); |
| 659 updated_opts.data_channel_type = cricket::DCT_RTP; | |
| 660 updated_opts.bundle_enabled = true; | 766 updated_opts.bundle_enabled = true; |
| 661 std::unique_ptr<SessionDescription> updated_offer( | 767 std::unique_ptr<SessionDescription> updated_offer( |
| 662 f1_.CreateOffer(updated_opts, answer.get())); | 768 f1_.CreateOffer(updated_opts, answer.get())); |
| 663 | 769 |
| 664 const AudioContentDescription* acd = | 770 const AudioContentDescription* acd = |
| 665 GetFirstAudioContentDescription(updated_offer.get()); | 771 GetFirstAudioContentDescription(updated_offer.get()); |
| 666 const VideoContentDescription* vcd = | 772 const VideoContentDescription* vcd = |
| 667 GetFirstVideoContentDescription(updated_offer.get()); | 773 GetFirstVideoContentDescription(updated_offer.get()); |
| 668 const DataContentDescription* dcd = | 774 const DataContentDescription* dcd = |
| 669 GetFirstDataContentDescription(updated_offer.get()); | 775 GetFirstDataContentDescription(updated_offer.get()); |
| 670 EXPECT_TRUE(NULL != vcd); | 776 EXPECT_TRUE(NULL != vcd); |
| 671 EXPECT_TRUE(NULL != acd); | 777 EXPECT_TRUE(NULL != acd); |
| 672 EXPECT_TRUE(NULL != dcd); | 778 EXPECT_TRUE(NULL != dcd); |
| 673 | 779 |
| 674 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 780 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 675 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 781 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 676 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 782 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 677 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 783 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
| 678 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 784 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 679 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 785 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
| 680 } | 786 } |
| 681 | 787 |
| 682 // Create a RTP data offer, and ensure it matches what we expect. | 788 // Create a RTP data offer, and ensure it matches what we expect. |
| 683 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { | 789 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateRtpDataOffer) { |
| 684 MediaSessionOptions opts; | 790 MediaSessionOptions opts; |
| 685 opts.data_channel_type = cricket::DCT_RTP; | 791 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 792 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 686 f1_.set_secure(SEC_ENABLED); | 793 f1_.set_secure(SEC_ENABLED); |
| 687 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 794 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 688 ASSERT_TRUE(offer.get() != NULL); | 795 ASSERT_TRUE(offer.get() != NULL); |
| 689 const ContentInfo* ac = offer->GetContentByName("audio"); | 796 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 690 const ContentInfo* dc = offer->GetContentByName("data"); | 797 const ContentInfo* dc = offer->GetContentByName("data"); |
| 691 ASSERT_TRUE(ac != NULL); | 798 ASSERT_TRUE(ac != NULL); |
| 692 ASSERT_TRUE(dc != NULL); | 799 ASSERT_TRUE(dc != NULL); |
| 693 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 800 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 694 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 801 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
| 695 const AudioContentDescription* acd = | 802 const AudioContentDescription* acd = |
| 696 static_cast<const AudioContentDescription*>(ac->description); | 803 static_cast<const AudioContentDescription*>(ac->description); |
| 697 const DataContentDescription* dcd = | 804 const DataContentDescription* dcd = |
| 698 static_cast<const DataContentDescription*>(dc->description); | 805 static_cast<const DataContentDescription*>(dc->description); |
| 699 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 806 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 700 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); | 807 EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs()); |
| 701 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 808 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attched. |
| 702 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) | 809 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto) |
| 703 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on | 810 EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on |
| 704 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); | 811 ASSERT_CRYPTO(acd, 2U, CS_AES_CM_128_HMAC_SHA1_32); |
| 705 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 812 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 706 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 813 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
| 707 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); | 814 EXPECT_EQ(f1_.data_codecs(), dcd->codecs()); |
| 708 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 815 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached. |
| 709 EXPECT_EQ(cricket::kDataMaxBandwidth, | 816 EXPECT_EQ(cricket::kDataMaxBandwidth, |
| 710 dcd->bandwidth()); // default bandwidth (auto) | 817 dcd->bandwidth()); // default bandwidth (auto) |
| 711 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 818 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
| 712 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 819 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 713 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 820 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
| 714 } | 821 } |
| 715 | 822 |
| 716 // Create an SCTP data offer with bundle without error. | 823 // Create an SCTP data offer with bundle without error. |
| 717 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { | 824 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) { |
| 718 MediaSessionOptions opts; | 825 MediaSessionOptions opts; |
| 719 opts.recv_audio = false; | |
| 720 opts.bundle_enabled = true; | 826 opts.bundle_enabled = true; |
| 721 opts.data_channel_type = cricket::DCT_SCTP; | 827 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 722 f1_.set_secure(SEC_ENABLED); | 828 f1_.set_secure(SEC_ENABLED); |
| 723 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 829 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 724 EXPECT_TRUE(offer.get() != NULL); | 830 EXPECT_TRUE(offer.get() != NULL); |
| 725 EXPECT_TRUE(offer->GetContentByName("data") != NULL); | 831 EXPECT_TRUE(offer->GetContentByName("data") != NULL); |
| 726 } | 832 } |
| 727 | 833 |
| 728 // Test creating an sctp data channel from an already generated offer. | 834 // Test creating an sctp data channel from an already generated offer. |
| 729 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { | 835 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) { |
| 730 MediaSessionOptions opts; | 836 MediaSessionOptions opts; |
| 731 opts.recv_audio = false; | |
| 732 opts.bundle_enabled = true; | 837 opts.bundle_enabled = true; |
| 733 opts.data_channel_type = cricket::DCT_SCTP; | 838 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 734 f1_.set_secure(SEC_ENABLED); | 839 f1_.set_secure(SEC_ENABLED); |
| 735 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 840 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
| 736 ASSERT_TRUE(offer1.get() != NULL); | 841 ASSERT_TRUE(offer1.get() != NULL); |
| 737 const ContentInfo* data = offer1->GetContentByName("data"); | 842 const ContentInfo* data = offer1->GetContentByName("data"); |
| 738 ASSERT_TRUE(data != NULL); | 843 ASSERT_TRUE(data != NULL); |
| 739 const MediaContentDescription* mdesc = | 844 const MediaContentDescription* mdesc = |
| 740 static_cast<const MediaContentDescription*>(data->description); | 845 static_cast<const MediaContentDescription*>(data->description); |
| 741 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 846 ASSERT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
| 742 | 847 |
| 743 // Now set data_channel_type to 'none' (default) and make sure that the | 848 // Now set data_channel_type to 'none' (default) and make sure that the |
| 744 // datachannel type that gets generated from the previous offer, is of the | 849 // datachannel type that gets generated from the previous offer, is of the |
| 745 // same type. | 850 // same type. |
| 746 opts.data_channel_type = cricket::DCT_NONE; | 851 opts.data_channel_type = cricket::DCT_NONE; |
| 747 std::unique_ptr<SessionDescription> offer2( | 852 std::unique_ptr<SessionDescription> offer2( |
| 748 f1_.CreateOffer(opts, offer1.get())); | 853 f1_.CreateOffer(opts, offer1.get())); |
| 749 data = offer2->GetContentByName("data"); | 854 data = offer2->GetContentByName("data"); |
| 750 ASSERT_TRUE(data != NULL); | 855 ASSERT_TRUE(data != NULL); |
| 751 mdesc = static_cast<const MediaContentDescription*>(data->description); | 856 mdesc = static_cast<const MediaContentDescription*>(data->description); |
| 752 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); | 857 EXPECT_EQ(cricket::kMediaProtocolSctp, mdesc->protocol()); |
| 753 } | 858 } |
| 754 | 859 |
| 755 // Create an audio, video offer without legacy StreamParams. | 860 // Create an audio, video offer without legacy StreamParams. |
| 756 TEST_F(MediaSessionDescriptionFactoryTest, | 861 TEST_F(MediaSessionDescriptionFactoryTest, |
| 757 TestCreateOfferWithoutLegacyStreams) { | 862 TestCreateOfferWithoutLegacyStreams) { |
| 758 MediaSessionOptions opts; | 863 MediaSessionOptions opts; |
| 759 opts.recv_video = true; | 864 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 760 f1_.set_add_legacy_streams(false); | |
| 761 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 865 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 762 ASSERT_TRUE(offer.get() != NULL); | 866 ASSERT_TRUE(offer.get() != NULL); |
| 763 const ContentInfo* ac = offer->GetContentByName("audio"); | 867 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 764 const ContentInfo* vc = offer->GetContentByName("video"); | 868 const ContentInfo* vc = offer->GetContentByName("video"); |
| 765 ASSERT_TRUE(ac != NULL); | 869 ASSERT_TRUE(ac != NULL); |
| 766 ASSERT_TRUE(vc != NULL); | 870 ASSERT_TRUE(vc != NULL); |
| 767 const AudioContentDescription* acd = | 871 const AudioContentDescription* acd = |
| 768 static_cast<const AudioContentDescription*>(ac->description); | 872 static_cast<const AudioContentDescription*>(ac->description); |
| 769 const VideoContentDescription* vcd = | 873 const VideoContentDescription* vcd = |
| 770 static_cast<const VideoContentDescription*>(vc->description); | 874 static_cast<const VideoContentDescription*>(vc->description); |
| 771 | 875 |
| 772 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 876 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
| 773 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 877 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
| 774 } | 878 } |
| 775 | 879 |
| 776 // Creates an audio+video sendonly offer. | 880 // Creates an audio+video sendonly offer. |
| 777 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { | 881 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSendOnlyOffer) { |
| 778 MediaSessionOptions options; | 882 MediaSessionOptions opts; |
| 779 options.recv_audio = false; | 883 AddAudioVideoSections(cricket::MD_SENDONLY, &opts); |
| 780 options.recv_video = false; | 884 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 781 options.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 885 kMediaStream1, 1, &opts); |
| 782 options.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 886 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 887 kMediaStream1, 1, &opts); |
| 783 | 888 |
| 784 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 889 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 785 ASSERT_TRUE(offer.get() != NULL); | 890 ASSERT_TRUE(offer.get() != NULL); |
| 786 EXPECT_EQ(2u, offer->contents().size()); | 891 EXPECT_EQ(2u, offer->contents().size()); |
| 787 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); | 892 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[0], MEDIA_TYPE_AUDIO)); |
| 788 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); | 893 EXPECT_TRUE(IsMediaContentOfType(&offer->contents()[1], MEDIA_TYPE_VIDEO)); |
| 789 | 894 |
| 790 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); | 895 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[0])); |
| 791 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); | 896 EXPECT_EQ(cricket::MD_SENDONLY, GetMediaDirection(&offer->contents()[1])); |
| 792 } | 897 } |
| 793 | 898 |
| 794 // Verifies that the order of the media contents in the current | 899 // Verifies that the order of the media contents in the current |
| 795 // SessionDescription is preserved in the new SessionDescription. | 900 // SessionDescription is preserved in the new SessionDescription. |
| 796 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { | 901 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateOfferContentOrder) { |
| 797 MediaSessionOptions opts; | 902 MediaSessionOptions opts; |
| 798 opts.recv_audio = false; | 903 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 799 opts.recv_video = false; | |
| 800 opts.data_channel_type = cricket::DCT_SCTP; | |
| 801 | 904 |
| 802 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 905 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
| 803 ASSERT_TRUE(offer1.get() != NULL); | 906 ASSERT_TRUE(offer1.get() != NULL); |
| 804 EXPECT_EQ(1u, offer1->contents().size()); | 907 EXPECT_EQ(1u, offer1->contents().size()); |
| 805 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); | 908 EXPECT_TRUE(IsMediaContentOfType(&offer1->contents()[0], MEDIA_TYPE_DATA)); |
| 806 | 909 |
| 807 opts.recv_video = true; | 910 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 911 &opts); |
| 808 std::unique_ptr<SessionDescription> offer2( | 912 std::unique_ptr<SessionDescription> offer2( |
| 809 f1_.CreateOffer(opts, offer1.get())); | 913 f1_.CreateOffer(opts, offer1.get())); |
| 810 ASSERT_TRUE(offer2.get() != NULL); | 914 ASSERT_TRUE(offer2.get() != NULL); |
| 811 EXPECT_EQ(2u, offer2->contents().size()); | 915 EXPECT_EQ(2u, offer2->contents().size()); |
| 812 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); | 916 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[0], MEDIA_TYPE_DATA)); |
| 813 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); | 917 EXPECT_TRUE(IsMediaContentOfType(&offer2->contents()[1], MEDIA_TYPE_VIDEO)); |
| 814 | 918 |
| 815 opts.recv_audio = true; | 919 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 920 &opts); |
| 816 std::unique_ptr<SessionDescription> offer3( | 921 std::unique_ptr<SessionDescription> offer3( |
| 817 f1_.CreateOffer(opts, offer2.get())); | 922 f1_.CreateOffer(opts, offer2.get())); |
| 818 ASSERT_TRUE(offer3.get() != NULL); | 923 ASSERT_TRUE(offer3.get() != NULL); |
| 819 EXPECT_EQ(3u, offer3->contents().size()); | 924 EXPECT_EQ(3u, offer3->contents().size()); |
| 820 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); | 925 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[0], MEDIA_TYPE_DATA)); |
| 821 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); | 926 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[1], MEDIA_TYPE_VIDEO)); |
| 822 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); | 927 EXPECT_TRUE(IsMediaContentOfType(&offer3->contents()[2], MEDIA_TYPE_AUDIO)); |
| 823 | |
| 824 // Verifies the default order is audio-video-data, so that the previous checks | |
| 825 // didn't pass by accident. | |
| 826 std::unique_ptr<SessionDescription> offer4(f1_.CreateOffer(opts, NULL)); | |
| 827 ASSERT_TRUE(offer4.get() != NULL); | |
| 828 EXPECT_EQ(3u, offer4->contents().size()); | |
| 829 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[0], MEDIA_TYPE_AUDIO)); | |
| 830 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[1], MEDIA_TYPE_VIDEO)); | |
| 831 EXPECT_TRUE(IsMediaContentOfType(&offer4->contents()[2], MEDIA_TYPE_DATA)); | |
| 832 } | 928 } |
| 833 | 929 |
| 834 // Create a typical audio answer, and ensure it matches what we expect. | 930 // Create a typical audio answer, and ensure it matches what we expect. |
| 835 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { | 931 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) { |
| 836 f1_.set_secure(SEC_ENABLED); | 932 f1_.set_secure(SEC_ENABLED); |
| 837 f2_.set_secure(SEC_ENABLED); | 933 f2_.set_secure(SEC_ENABLED); |
| 838 std::unique_ptr<SessionDescription> offer( | 934 std::unique_ptr<SessionDescription> offer( |
| 839 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 935 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
| 840 ASSERT_TRUE(offer.get() != NULL); | 936 ASSERT_TRUE(offer.get() != NULL); |
| 841 std::unique_ptr<SessionDescription> answer( | 937 std::unique_ptr<SessionDescription> answer( |
| 842 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 938 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
| 843 const ContentInfo* ac = answer->GetContentByName("audio"); | 939 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 844 const ContentInfo* vc = answer->GetContentByName("video"); | 940 const ContentInfo* vc = answer->GetContentByName("video"); |
| 845 ASSERT_TRUE(ac != NULL); | 941 ASSERT_TRUE(ac != NULL); |
| 846 ASSERT_TRUE(vc == NULL); | 942 ASSERT_TRUE(vc == NULL); |
| 847 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 943 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 848 const AudioContentDescription* acd = | 944 const AudioContentDescription* acd = |
| 849 static_cast<const AudioContentDescription*>(ac->description); | 945 static_cast<const AudioContentDescription*>(ac->description); |
| 850 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 946 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 851 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 947 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 852 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 948 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 853 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 949 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 854 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 950 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 855 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 951 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
| 856 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 952 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 857 } | 953 } |
| 858 | 954 |
| 859 // Create a typical audio answer with GCM ciphers enabled, and ensure it | 955 // Create a typical audio answer with GCM ciphers enabled, and ensure it |
| 860 // matches what we expect. | 956 // matches what we expect. |
| 861 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { | 957 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) { |
| 862 f1_.set_secure(SEC_ENABLED); | 958 f1_.set_secure(SEC_ENABLED); |
| 863 f2_.set_secure(SEC_ENABLED); | 959 f2_.set_secure(SEC_ENABLED); |
| 864 MediaSessionOptions options; | 960 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
| 865 options.crypto_options.enable_gcm_crypto_suites = true; | 961 opts.crypto_options.enable_gcm_crypto_suites = true; |
| 866 std::unique_ptr<SessionDescription> offer( | 962 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 867 f1_.CreateOffer(options, NULL)); | |
| 868 ASSERT_TRUE(offer.get() != NULL); | 963 ASSERT_TRUE(offer.get() != NULL); |
| 869 std::unique_ptr<SessionDescription> answer( | 964 std::unique_ptr<SessionDescription> answer( |
| 870 f2_.CreateAnswer(offer.get(), options, NULL)); | 965 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 871 const ContentInfo* ac = answer->GetContentByName("audio"); | 966 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 872 const ContentInfo* vc = answer->GetContentByName("video"); | 967 const ContentInfo* vc = answer->GetContentByName("video"); |
| 873 ASSERT_TRUE(ac != NULL); | 968 ASSERT_TRUE(ac != NULL); |
| 874 ASSERT_TRUE(vc == NULL); | 969 ASSERT_TRUE(vc == NULL); |
| 875 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 970 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 876 const AudioContentDescription* acd = | 971 const AudioContentDescription* acd = |
| 877 static_cast<const AudioContentDescription*>(ac->description); | 972 static_cast<const AudioContentDescription*>(ac->description); |
| 878 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 973 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 879 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 974 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 880 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 975 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 881 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 976 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 882 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 977 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 883 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 978 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
| 884 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); | 979 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), acd->protocol()); |
| 885 } | 980 } |
| 886 | 981 |
| 887 // Create a typical video answer, and ensure it matches what we expect. | 982 // Create a typical video answer, and ensure it matches what we expect. |
| 888 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { | 983 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) { |
| 889 MediaSessionOptions opts; | 984 MediaSessionOptions opts; |
| 890 opts.recv_video = true; | 985 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 891 f1_.set_secure(SEC_ENABLED); | 986 f1_.set_secure(SEC_ENABLED); |
| 892 f2_.set_secure(SEC_ENABLED); | 987 f2_.set_secure(SEC_ENABLED); |
| 893 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 988 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 894 ASSERT_TRUE(offer.get() != NULL); | 989 ASSERT_TRUE(offer.get() != NULL); |
| 895 std::unique_ptr<SessionDescription> answer( | 990 std::unique_ptr<SessionDescription> answer( |
| 896 f2_.CreateAnswer(offer.get(), opts, NULL)); | 991 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 897 const ContentInfo* ac = answer->GetContentByName("audio"); | 992 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 898 const ContentInfo* vc = answer->GetContentByName("video"); | 993 const ContentInfo* vc = answer->GetContentByName("video"); |
| 899 ASSERT_TRUE(ac != NULL); | 994 ASSERT_TRUE(ac != NULL); |
| 900 ASSERT_TRUE(vc != NULL); | 995 ASSERT_TRUE(vc != NULL); |
| 901 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 996 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 902 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); | 997 EXPECT_EQ(std::string(NS_JINGLE_RTP), vc->type); |
| 903 const AudioContentDescription* acd = | 998 const AudioContentDescription* acd = |
| 904 static_cast<const AudioContentDescription*>(ac->description); | 999 static_cast<const AudioContentDescription*>(ac->description); |
| 905 const VideoContentDescription* vcd = | 1000 const VideoContentDescription* vcd = |
| 906 static_cast<const VideoContentDescription*>(vc->description); | 1001 static_cast<const VideoContentDescription*>(vc->description); |
| 907 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1002 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 908 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1003 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 909 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 1004 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 910 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 1005 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 911 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1006 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 912 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1007 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
| 913 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); | 1008 EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type()); |
| 914 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); | 1009 EXPECT_EQ(MAKE_VECTOR(kVideoCodecsAnswer), vcd->codecs()); |
| 915 EXPECT_NE(0U, vcd->first_ssrc()); // a random nonzero ssrc | 1010 EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached |
| 916 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux | 1011 EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux |
| 917 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1012 ASSERT_CRYPTO(vcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 918 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); | 1013 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), vcd->protocol()); |
| 919 } | 1014 } |
| 920 | 1015 |
| 921 // Create a typical video answer with GCM ciphers enabled, and ensure it | 1016 // Create a typical video answer with GCM ciphers enabled, and ensure it |
| 922 // matches what we expect. | 1017 // matches what we expect. |
| 923 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcm) { | 1018 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcm) { |
| 924 TestVideoGcmCipher(true, true); | 1019 TestVideoGcmCipher(true, true); |
| 925 } | 1020 } |
| 926 | 1021 |
| 927 // Create a typical video answer with GCM ciphers enabled for the offer only, | 1022 // Create a typical video answer with GCM ciphers enabled for the offer only, |
| 928 // and ensure it matches what we expect. | 1023 // and ensure it matches what we expect. |
| 929 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmOffer) { | 1024 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmOffer) { |
| 930 TestVideoGcmCipher(true, false); | 1025 TestVideoGcmCipher(true, false); |
| 931 } | 1026 } |
| 932 | 1027 |
| 933 // Create a typical video answer with GCM ciphers enabled for the answer only, | 1028 // Create a typical video answer with GCM ciphers enabled for the answer only, |
| 934 // and ensure it matches what we expect. | 1029 // and ensure it matches what we expect. |
| 935 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { | 1030 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerGcmAnswer) { |
| 936 TestVideoGcmCipher(false, true); | 1031 TestVideoGcmCipher(false, true); |
| 937 } | 1032 } |
| 938 | 1033 |
| 939 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { | 1034 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswer) { |
| 940 MediaSessionOptions opts; | 1035 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
| 941 opts.data_channel_type = cricket::DCT_RTP; | 1036 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 942 f1_.set_secure(SEC_ENABLED); | 1037 f1_.set_secure(SEC_ENABLED); |
| 943 f2_.set_secure(SEC_ENABLED); | 1038 f2_.set_secure(SEC_ENABLED); |
| 944 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1039 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 945 ASSERT_TRUE(offer.get() != NULL); | 1040 ASSERT_TRUE(offer.get() != NULL); |
| 946 std::unique_ptr<SessionDescription> answer( | 1041 std::unique_ptr<SessionDescription> answer( |
| 947 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1042 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 948 const ContentInfo* ac = answer->GetContentByName("audio"); | 1043 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 949 const ContentInfo* dc = answer->GetContentByName("data"); | 1044 const ContentInfo* dc = answer->GetContentByName("data"); |
| 950 ASSERT_TRUE(ac != NULL); | 1045 ASSERT_TRUE(ac != NULL); |
| 951 ASSERT_TRUE(dc != NULL); | 1046 ASSERT_TRUE(dc != NULL); |
| 952 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 1047 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 953 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 1048 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
| 954 const AudioContentDescription* acd = | 1049 const AudioContentDescription* acd = |
| 955 static_cast<const AudioContentDescription*>(ac->description); | 1050 static_cast<const AudioContentDescription*>(ac->description); |
| 956 const DataContentDescription* dcd = | 1051 const DataContentDescription* dcd = |
| 957 static_cast<const DataContentDescription*>(dc->description); | 1052 static_cast<const DataContentDescription*>(dc->description); |
| 958 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1053 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 959 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1054 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 960 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 1055 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 961 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 1056 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 962 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1057 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 963 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); | 1058 ASSERT_CRYPTO(acd, 1U, CS_AES_CM_128_HMAC_SHA1_32); |
| 964 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 1059 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
| 965 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); | 1060 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
| 966 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 1061 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached |
| 967 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux | 1062 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
| 968 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1063 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 969 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 1064 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
| 970 } | 1065 } |
| 971 | 1066 |
| 972 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { | 1067 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) { |
| 973 MediaSessionOptions opts; | 1068 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
| 974 opts.data_channel_type = cricket::DCT_RTP; | 1069 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 975 opts.crypto_options.enable_gcm_crypto_suites = true; | 1070 opts.crypto_options.enable_gcm_crypto_suites = true; |
| 976 f1_.set_secure(SEC_ENABLED); | 1071 f1_.set_secure(SEC_ENABLED); |
| 977 f2_.set_secure(SEC_ENABLED); | 1072 f2_.set_secure(SEC_ENABLED); |
| 978 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1073 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 979 ASSERT_TRUE(offer.get() != NULL); | 1074 ASSERT_TRUE(offer.get() != NULL); |
| 980 std::unique_ptr<SessionDescription> answer( | 1075 std::unique_ptr<SessionDescription> answer( |
| 981 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1076 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 982 const ContentInfo* ac = answer->GetContentByName("audio"); | 1077 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 983 const ContentInfo* dc = answer->GetContentByName("data"); | 1078 const ContentInfo* dc = answer->GetContentByName("data"); |
| 984 ASSERT_TRUE(ac != NULL); | 1079 ASSERT_TRUE(ac != NULL); |
| 985 ASSERT_TRUE(dc != NULL); | 1080 ASSERT_TRUE(dc != NULL); |
| 986 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); | 1081 EXPECT_EQ(std::string(NS_JINGLE_RTP), ac->type); |
| 987 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); | 1082 EXPECT_EQ(std::string(NS_JINGLE_RTP), dc->type); |
| 988 const AudioContentDescription* acd = | 1083 const AudioContentDescription* acd = |
| 989 static_cast<const AudioContentDescription*>(ac->description); | 1084 static_cast<const AudioContentDescription*>(ac->description); |
| 990 const DataContentDescription* dcd = | 1085 const DataContentDescription* dcd = |
| 991 static_cast<const DataContentDescription*>(dc->description); | 1086 static_cast<const DataContentDescription*>(dc->description); |
| 992 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 1087 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 993 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1088 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 994 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw | 1089 EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw |
| 995 EXPECT_NE(0U, acd->first_ssrc()); // a random nonzero ssrc | 1090 EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached |
| 996 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux | 1091 EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux |
| 997 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); | 1092 ASSERT_CRYPTO(acd, 1U, CS_AEAD_AES_256_GCM); |
| 998 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); | 1093 EXPECT_EQ(MEDIA_TYPE_DATA, dcd->type()); |
| 999 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); | 1094 EXPECT_EQ(MAKE_VECTOR(kDataCodecsAnswer), dcd->codecs()); |
| 1000 EXPECT_NE(0U, dcd->first_ssrc()); // a random nonzero ssrc | 1095 EXPECT_EQ(0U, dcd->first_ssrc()); // no sender is attached |
| 1001 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux | 1096 EXPECT_TRUE(dcd->rtcp_mux()); // negotiated rtcp-mux |
| 1002 ASSERT_CRYPTO(dcd, 1U, CS_AEAD_AES_256_GCM); | 1097 ASSERT_CRYPTO(dcd, 1U, CS_AEAD_AES_256_GCM); |
| 1003 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); | 1098 EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf), dcd->protocol()); |
| 1004 } | 1099 } |
| 1005 | 1100 |
| 1006 // The use_sctpmap flag should be set in a DataContentDescription by default. | 1101 // The use_sctpmap flag should be set in a DataContentDescription by default. |
| 1007 // The answer's use_sctpmap flag should match the offer's. | 1102 // The answer's use_sctpmap flag should match the offer's. |
| 1008 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { | 1103 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) { |
| 1009 MediaSessionOptions opts; | 1104 MediaSessionOptions opts; |
| 1010 opts.data_channel_type = cricket::DCT_SCTP; | 1105 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 1011 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1106 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1012 ASSERT_TRUE(offer.get() != NULL); | 1107 ASSERT_TRUE(offer.get() != NULL); |
| 1013 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1108 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 1014 ASSERT_TRUE(dc_offer != NULL); | 1109 ASSERT_TRUE(dc_offer != NULL); |
| 1015 DataContentDescription* dcd_offer = | 1110 DataContentDescription* dcd_offer = |
| 1016 static_cast<DataContentDescription*>(dc_offer->description); | 1111 static_cast<DataContentDescription*>(dc_offer->description); |
| 1017 EXPECT_TRUE(dcd_offer->use_sctpmap()); | 1112 EXPECT_TRUE(dcd_offer->use_sctpmap()); |
| 1018 | 1113 |
| 1019 std::unique_ptr<SessionDescription> answer( | 1114 std::unique_ptr<SessionDescription> answer( |
| 1020 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1115 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1021 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1116 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 1022 ASSERT_TRUE(dc_answer != NULL); | 1117 ASSERT_TRUE(dc_answer != NULL); |
| 1023 const DataContentDescription* dcd_answer = | 1118 const DataContentDescription* dcd_answer = |
| 1024 static_cast<const DataContentDescription*>(dc_answer->description); | 1119 static_cast<const DataContentDescription*>(dc_answer->description); |
| 1025 EXPECT_TRUE(dcd_answer->use_sctpmap()); | 1120 EXPECT_TRUE(dcd_answer->use_sctpmap()); |
| 1026 } | 1121 } |
| 1027 | 1122 |
| 1028 // The answer's use_sctpmap flag should match the offer's. | 1123 // The answer's use_sctpmap flag should match the offer's. |
| 1029 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { | 1124 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerWithoutSctpmap) { |
| 1030 MediaSessionOptions opts; | 1125 MediaSessionOptions opts; |
| 1031 opts.data_channel_type = cricket::DCT_SCTP; | 1126 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 1032 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1127 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1033 ASSERT_TRUE(offer.get() != NULL); | 1128 ASSERT_TRUE(offer.get() != NULL); |
| 1034 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1129 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 1035 ASSERT_TRUE(dc_offer != NULL); | 1130 ASSERT_TRUE(dc_offer != NULL); |
| 1036 DataContentDescription* dcd_offer = | 1131 DataContentDescription* dcd_offer = |
| 1037 static_cast<DataContentDescription*>(dc_offer->description); | 1132 static_cast<DataContentDescription*>(dc_offer->description); |
| 1038 dcd_offer->set_use_sctpmap(false); | 1133 dcd_offer->set_use_sctpmap(false); |
| 1039 | 1134 |
| 1040 std::unique_ptr<SessionDescription> answer( | 1135 std::unique_ptr<SessionDescription> answer( |
| 1041 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1136 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1042 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1137 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 1043 ASSERT_TRUE(dc_answer != NULL); | 1138 ASSERT_TRUE(dc_answer != NULL); |
| 1044 const DataContentDescription* dcd_answer = | 1139 const DataContentDescription* dcd_answer = |
| 1045 static_cast<const DataContentDescription*>(dc_answer->description); | 1140 static_cast<const DataContentDescription*>(dc_answer->description); |
| 1046 EXPECT_FALSE(dcd_answer->use_sctpmap()); | 1141 EXPECT_FALSE(dcd_answer->use_sctpmap()); |
| 1047 } | 1142 } |
| 1048 | 1143 |
| 1049 // Test that a valid answer will be created for "DTLS/SCTP", "UDP/DTLS/SCTP" | 1144 // Test that a valid answer will be created for "DTLS/SCTP", "UDP/DTLS/SCTP" |
| 1050 // and "TCP/DTLS/SCTP" offers. | 1145 // and "TCP/DTLS/SCTP" offers. |
| 1051 TEST_F(MediaSessionDescriptionFactoryTest, | 1146 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1052 TestCreateDataAnswerToDifferentOfferedProtos) { | 1147 TestCreateDataAnswerToDifferentOfferedProtos) { |
| 1053 // Need to enable DTLS offer/answer generation (disabled by default in this | 1148 // Need to enable DTLS offer/answer generation (disabled by default in this |
| 1054 // test). | 1149 // test). |
| 1055 f1_.set_secure(SEC_ENABLED); | 1150 f1_.set_secure(SEC_ENABLED); |
| 1056 f2_.set_secure(SEC_ENABLED); | 1151 f2_.set_secure(SEC_ENABLED); |
| 1057 tdf1_.set_secure(SEC_ENABLED); | 1152 tdf1_.set_secure(SEC_ENABLED); |
| 1058 tdf2_.set_secure(SEC_ENABLED); | 1153 tdf2_.set_secure(SEC_ENABLED); |
| 1059 | 1154 |
| 1060 MediaSessionOptions opts; | 1155 MediaSessionOptions opts; |
| 1061 opts.data_channel_type = cricket::DCT_SCTP; | 1156 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 1062 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 1157 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 1063 ASSERT_TRUE(offer.get() != nullptr); | 1158 ASSERT_TRUE(offer.get() != nullptr); |
| 1064 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1159 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 1065 ASSERT_TRUE(dc_offer != nullptr); | 1160 ASSERT_TRUE(dc_offer != nullptr); |
| 1066 DataContentDescription* dcd_offer = | 1161 DataContentDescription* dcd_offer = |
| 1067 static_cast<DataContentDescription*>(dc_offer->description); | 1162 static_cast<DataContentDescription*>(dc_offer->description); |
| 1068 | 1163 |
| 1069 std::vector<std::string> protos = {"DTLS/SCTP", "UDP/DTLS/SCTP", | 1164 std::vector<std::string> protos = {"DTLS/SCTP", "UDP/DTLS/SCTP", |
| 1070 "TCP/DTLS/SCTP"}; | 1165 "TCP/DTLS/SCTP"}; |
| 1071 for (const std::string& proto : protos) { | 1166 for (const std::string& proto : protos) { |
| 1072 dcd_offer->set_protocol(proto); | 1167 dcd_offer->set_protocol(proto); |
| 1073 std::unique_ptr<SessionDescription> answer( | 1168 std::unique_ptr<SessionDescription> answer( |
| 1074 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 1169 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 1075 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1170 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 1076 ASSERT_TRUE(dc_answer != nullptr); | 1171 ASSERT_TRUE(dc_answer != nullptr); |
| 1077 const DataContentDescription* dcd_answer = | 1172 const DataContentDescription* dcd_answer = |
| 1078 static_cast<const DataContentDescription*>(dc_answer->description); | 1173 static_cast<const DataContentDescription*>(dc_answer->description); |
| 1079 EXPECT_FALSE(dc_answer->rejected); | 1174 EXPECT_FALSE(dc_answer->rejected); |
| 1080 EXPECT_EQ(proto, dcd_answer->protocol()); | 1175 EXPECT_EQ(proto, dcd_answer->protocol()); |
| 1081 } | 1176 } |
| 1082 } | 1177 } |
| 1083 | 1178 |
| 1084 // Verifies that the order of the media contents in the offer is preserved in | 1179 // Verifies that the order of the media contents in the offer is preserved in |
| 1085 // the answer. | 1180 // the answer. |
| 1086 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { | 1181 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAnswerContentOrder) { |
| 1087 MediaSessionOptions opts; | 1182 MediaSessionOptions opts; |
| 1088 | 1183 |
| 1089 // Creates a data only offer. | 1184 // Creates a data only offer. |
| 1090 opts.recv_audio = false; | 1185 AddDataSection(cricket::DCT_SCTP, cricket::MD_SENDRECV, &opts); |
| 1091 opts.data_channel_type = cricket::DCT_SCTP; | |
| 1092 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); | 1186 std::unique_ptr<SessionDescription> offer1(f1_.CreateOffer(opts, NULL)); |
| 1093 ASSERT_TRUE(offer1.get() != NULL); | 1187 ASSERT_TRUE(offer1.get() != NULL); |
| 1094 | 1188 |
| 1095 // Appends audio to the offer. | 1189 // Appends audio to the offer. |
| 1096 opts.recv_audio = true; | 1190 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 1191 &opts); |
| 1097 std::unique_ptr<SessionDescription> offer2( | 1192 std::unique_ptr<SessionDescription> offer2( |
| 1098 f1_.CreateOffer(opts, offer1.get())); | 1193 f1_.CreateOffer(opts, offer1.get())); |
| 1099 ASSERT_TRUE(offer2.get() != NULL); | 1194 ASSERT_TRUE(offer2.get() != NULL); |
| 1100 | 1195 |
| 1101 // Appends video to the offer. | 1196 // Appends video to the offer. |
| 1102 opts.recv_video = true; | 1197 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 1198 &opts); |
| 1103 std::unique_ptr<SessionDescription> offer3( | 1199 std::unique_ptr<SessionDescription> offer3( |
| 1104 f1_.CreateOffer(opts, offer2.get())); | 1200 f1_.CreateOffer(opts, offer2.get())); |
| 1105 ASSERT_TRUE(offer3.get() != NULL); | 1201 ASSERT_TRUE(offer3.get() != NULL); |
| 1106 | 1202 |
| 1107 std::unique_ptr<SessionDescription> answer( | 1203 std::unique_ptr<SessionDescription> answer( |
| 1108 f2_.CreateAnswer(offer3.get(), opts, NULL)); | 1204 f2_.CreateAnswer(offer3.get(), opts, NULL)); |
| 1109 ASSERT_TRUE(answer.get() != NULL); | 1205 ASSERT_TRUE(answer.get() != NULL); |
| 1110 EXPECT_EQ(3u, answer->contents().size()); | 1206 EXPECT_EQ(3u, answer->contents().size()); |
| 1111 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); | 1207 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[0], MEDIA_TYPE_DATA)); |
| 1112 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); | 1208 EXPECT_TRUE(IsMediaContentOfType(&answer->contents()[1], MEDIA_TYPE_AUDIO)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1137 // This test that the media direction is set to inactive in an answer if | 1233 // This test that the media direction is set to inactive in an answer if |
| 1138 // the offer is inactive. | 1234 // the offer is inactive. |
| 1139 TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerToInactiveOffer) { | 1235 TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerToInactiveOffer) { |
| 1140 TestMediaDirectionInAnswer(cricket::MD_INACTIVE, cricket::MD_INACTIVE); | 1236 TestMediaDirectionInAnswer(cricket::MD_INACTIVE, cricket::MD_INACTIVE); |
| 1141 } | 1237 } |
| 1142 | 1238 |
| 1143 // Test that a data content with an unknown protocol is rejected in an answer. | 1239 // Test that a data content with an unknown protocol is rejected in an answer. |
| 1144 TEST_F(MediaSessionDescriptionFactoryTest, | 1240 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1145 CreateDataAnswerToOfferWithUnknownProtocol) { | 1241 CreateDataAnswerToOfferWithUnknownProtocol) { |
| 1146 MediaSessionOptions opts; | 1242 MediaSessionOptions opts; |
| 1147 opts.data_channel_type = cricket::DCT_RTP; | 1243 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 1148 opts.recv_audio = false; | |
| 1149 f1_.set_secure(SEC_ENABLED); | 1244 f1_.set_secure(SEC_ENABLED); |
| 1150 f2_.set_secure(SEC_ENABLED); | 1245 f2_.set_secure(SEC_ENABLED); |
| 1151 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1246 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1152 ContentInfo* dc_offer = offer->GetContentByName("data"); | 1247 ContentInfo* dc_offer = offer->GetContentByName("data"); |
| 1153 ASSERT_TRUE(dc_offer != NULL); | 1248 ASSERT_TRUE(dc_offer != NULL); |
| 1154 DataContentDescription* dcd_offer = | 1249 DataContentDescription* dcd_offer = |
| 1155 static_cast<DataContentDescription*>(dc_offer->description); | 1250 static_cast<DataContentDescription*>(dc_offer->description); |
| 1156 ASSERT_TRUE(dcd_offer != NULL); | 1251 ASSERT_TRUE(dcd_offer != NULL); |
| 1157 std::string protocol = "a weird unknown protocol"; | 1252 std::string protocol = "a weird unknown protocol"; |
| 1158 dcd_offer->set_protocol(protocol); | 1253 dcd_offer->set_protocol(protocol); |
| 1159 | 1254 |
| 1160 std::unique_ptr<SessionDescription> answer( | 1255 std::unique_ptr<SessionDescription> answer( |
| 1161 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1256 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1162 | 1257 |
| 1163 const ContentInfo* dc_answer = answer->GetContentByName("data"); | 1258 const ContentInfo* dc_answer = answer->GetContentByName("data"); |
| 1164 ASSERT_TRUE(dc_answer != NULL); | 1259 ASSERT_TRUE(dc_answer != NULL); |
| 1165 EXPECT_TRUE(dc_answer->rejected); | 1260 EXPECT_TRUE(dc_answer->rejected); |
| 1166 const DataContentDescription* dcd_answer = | 1261 const DataContentDescription* dcd_answer = |
| 1167 static_cast<const DataContentDescription*>(dc_answer->description); | 1262 static_cast<const DataContentDescription*>(dc_answer->description); |
| 1168 ASSERT_TRUE(dcd_answer != NULL); | 1263 ASSERT_TRUE(dcd_answer != NULL); |
| 1169 EXPECT_EQ(protocol, dcd_answer->protocol()); | 1264 EXPECT_EQ(protocol, dcd_answer->protocol()); |
| 1170 } | 1265 } |
| 1171 | 1266 |
| 1172 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. | 1267 // Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled. |
| 1173 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { | 1268 TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) { |
| 1174 MediaSessionOptions opts; | 1269 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
| 1175 f1_.set_secure(SEC_DISABLED); | 1270 f1_.set_secure(SEC_DISABLED); |
| 1176 f2_.set_secure(SEC_DISABLED); | 1271 f2_.set_secure(SEC_DISABLED); |
| 1177 tdf1_.set_secure(SEC_DISABLED); | 1272 tdf1_.set_secure(SEC_DISABLED); |
| 1178 tdf2_.set_secure(SEC_DISABLED); | 1273 tdf2_.set_secure(SEC_DISABLED); |
| 1179 | 1274 |
| 1180 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1275 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1181 const AudioContentDescription* offer_acd = | 1276 const AudioContentDescription* offer_acd = |
| 1182 GetFirstAudioContentDescription(offer.get()); | 1277 GetFirstAudioContentDescription(offer.get()); |
| 1183 ASSERT_TRUE(offer_acd != NULL); | 1278 ASSERT_TRUE(offer_acd != NULL); |
| 1184 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); | 1279 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), offer_acd->protocol()); |
| 1185 | 1280 |
| 1186 std::unique_ptr<SessionDescription> answer( | 1281 std::unique_ptr<SessionDescription> answer( |
| 1187 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1282 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1188 | 1283 |
| 1189 const ContentInfo* ac_answer = answer->GetContentByName("audio"); | 1284 const ContentInfo* ac_answer = answer->GetContentByName("audio"); |
| 1190 ASSERT_TRUE(ac_answer != NULL); | 1285 ASSERT_TRUE(ac_answer != NULL); |
| 1191 EXPECT_FALSE(ac_answer->rejected); | 1286 EXPECT_FALSE(ac_answer->rejected); |
| 1192 | 1287 |
| 1193 const AudioContentDescription* answer_acd = | 1288 const AudioContentDescription* answer_acd = |
| 1194 GetFirstAudioContentDescription(answer.get()); | 1289 GetFirstAudioContentDescription(answer.get()); |
| 1195 ASSERT_TRUE(answer_acd != NULL); | 1290 ASSERT_TRUE(answer_acd != NULL); |
| 1196 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); | 1291 EXPECT_EQ(std::string(cricket::kMediaProtocolAvpf), answer_acd->protocol()); |
| 1197 } | 1292 } |
| 1198 | 1293 |
| 1199 // Create a video offer and answer and ensure the RTP header extensions | 1294 // Create a video offer and answer and ensure the RTP header extensions |
| 1200 // matches what we expect. | 1295 // matches what we expect. |
| 1201 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { | 1296 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferAnswerWithRtpExtensions) { |
| 1202 MediaSessionOptions opts; | 1297 MediaSessionOptions opts; |
| 1203 opts.recv_video = true; | 1298 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1204 | |
| 1205 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 1299 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
| 1206 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 1300 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
| 1207 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 1301 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
| 1208 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 1302 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
| 1209 | 1303 |
| 1210 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1304 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1211 ASSERT_TRUE(offer.get() != NULL); | 1305 ASSERT_TRUE(offer.get() != NULL); |
| 1212 std::unique_ptr<SessionDescription> answer( | 1306 std::unique_ptr<SessionDescription> answer( |
| 1213 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1307 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1214 | 1308 |
| 1215 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), | 1309 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtension1), |
| 1216 GetFirstAudioContentDescription( | 1310 GetFirstAudioContentDescription( |
| 1217 offer.get())->rtp_header_extensions()); | 1311 offer.get())->rtp_header_extensions()); |
| 1218 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), | 1312 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtension1), |
| 1219 GetFirstVideoContentDescription( | 1313 GetFirstVideoContentDescription( |
| 1220 offer.get())->rtp_header_extensions()); | 1314 offer.get())->rtp_header_extensions()); |
| 1221 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), | 1315 EXPECT_EQ(MAKE_VECTOR(kAudioRtpExtensionAnswer), |
| 1222 GetFirstAudioContentDescription( | 1316 GetFirstAudioContentDescription( |
| 1223 answer.get())->rtp_header_extensions()); | 1317 answer.get())->rtp_header_extensions()); |
| 1224 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1318 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
| 1225 GetFirstVideoContentDescription( | 1319 GetFirstVideoContentDescription( |
| 1226 answer.get())->rtp_header_extensions()); | 1320 answer.get())->rtp_header_extensions()); |
| 1227 } | 1321 } |
| 1228 | 1322 |
| 1229 TEST_F(MediaSessionDescriptionFactoryTest, | 1323 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1230 TestOfferAnswerWithEncryptedRtpExtensionsBoth) { | 1324 TestOfferAnswerWithEncryptedRtpExtensionsBoth) { |
| 1231 MediaSessionOptions opts; | 1325 MediaSessionOptions opts; |
| 1232 opts.recv_video = true; | 1326 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1233 | 1327 |
| 1234 f1_.set_enable_encrypted_rtp_header_extensions(true); | 1328 f1_.set_enable_encrypted_rtp_header_extensions(true); |
| 1235 f2_.set_enable_encrypted_rtp_header_extensions(true); | 1329 f2_.set_enable_encrypted_rtp_header_extensions(true); |
| 1236 | 1330 |
| 1237 f1_.set_audio_rtp_header_extensions( | 1331 f1_.set_audio_rtp_header_extensions( |
| 1238 MAKE_VECTOR(kAudioRtpExtension1)); | 1332 MAKE_VECTOR(kAudioRtpExtension1)); |
| 1239 f1_.set_video_rtp_header_extensions( | 1333 f1_.set_video_rtp_header_extensions( |
| 1240 MAKE_VECTOR(kVideoRtpExtension1)); | 1334 MAKE_VECTOR(kVideoRtpExtension1)); |
| 1241 f2_.set_audio_rtp_header_extensions( | 1335 f2_.set_audio_rtp_header_extensions( |
| 1242 MAKE_VECTOR(kAudioRtpExtension2)); | 1336 MAKE_VECTOR(kAudioRtpExtension2)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1258 GetFirstAudioContentDescription( | 1352 GetFirstAudioContentDescription( |
| 1259 answer.get())->rtp_header_extensions()); | 1353 answer.get())->rtp_header_extensions()); |
| 1260 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), | 1354 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionEncryptedAnswer), |
| 1261 GetFirstVideoContentDescription( | 1355 GetFirstVideoContentDescription( |
| 1262 answer.get())->rtp_header_extensions()); | 1356 answer.get())->rtp_header_extensions()); |
| 1263 } | 1357 } |
| 1264 | 1358 |
| 1265 TEST_F(MediaSessionDescriptionFactoryTest, | 1359 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1266 TestOfferAnswerWithEncryptedRtpExtensionsOffer) { | 1360 TestOfferAnswerWithEncryptedRtpExtensionsOffer) { |
| 1267 MediaSessionOptions opts; | 1361 MediaSessionOptions opts; |
| 1268 opts.recv_video = true; | 1362 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1269 | 1363 |
| 1270 f1_.set_enable_encrypted_rtp_header_extensions(true); | 1364 f1_.set_enable_encrypted_rtp_header_extensions(true); |
| 1271 | 1365 |
| 1272 f1_.set_audio_rtp_header_extensions( | 1366 f1_.set_audio_rtp_header_extensions( |
| 1273 MAKE_VECTOR(kAudioRtpExtension1)); | 1367 MAKE_VECTOR(kAudioRtpExtension1)); |
| 1274 f1_.set_video_rtp_header_extensions( | 1368 f1_.set_video_rtp_header_extensions( |
| 1275 MAKE_VECTOR(kVideoRtpExtension1)); | 1369 MAKE_VECTOR(kVideoRtpExtension1)); |
| 1276 f2_.set_audio_rtp_header_extensions( | 1370 f2_.set_audio_rtp_header_extensions( |
| 1277 MAKE_VECTOR(kAudioRtpExtension2)); | 1371 MAKE_VECTOR(kAudioRtpExtension2)); |
| 1278 f2_.set_video_rtp_header_extensions( | 1372 f2_.set_video_rtp_header_extensions( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1293 GetFirstAudioContentDescription( | 1387 GetFirstAudioContentDescription( |
| 1294 answer.get())->rtp_header_extensions()); | 1388 answer.get())->rtp_header_extensions()); |
| 1295 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1389 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
| 1296 GetFirstVideoContentDescription( | 1390 GetFirstVideoContentDescription( |
| 1297 answer.get())->rtp_header_extensions()); | 1391 answer.get())->rtp_header_extensions()); |
| 1298 } | 1392 } |
| 1299 | 1393 |
| 1300 TEST_F(MediaSessionDescriptionFactoryTest, | 1394 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1301 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { | 1395 TestOfferAnswerWithEncryptedRtpExtensionsAnswer) { |
| 1302 MediaSessionOptions opts; | 1396 MediaSessionOptions opts; |
| 1303 opts.recv_video = true; | 1397 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1304 | 1398 |
| 1305 f2_.set_enable_encrypted_rtp_header_extensions(true); | 1399 f2_.set_enable_encrypted_rtp_header_extensions(true); |
| 1306 | 1400 |
| 1307 f1_.set_audio_rtp_header_extensions( | 1401 f1_.set_audio_rtp_header_extensions( |
| 1308 MAKE_VECTOR(kAudioRtpExtension1)); | 1402 MAKE_VECTOR(kAudioRtpExtension1)); |
| 1309 f1_.set_video_rtp_header_extensions( | 1403 f1_.set_video_rtp_header_extensions( |
| 1310 MAKE_VECTOR(kVideoRtpExtension1)); | 1404 MAKE_VECTOR(kVideoRtpExtension1)); |
| 1311 f2_.set_audio_rtp_header_extensions( | 1405 f2_.set_audio_rtp_header_extensions( |
| 1312 MAKE_VECTOR(kAudioRtpExtension2)); | 1406 MAKE_VECTOR(kAudioRtpExtension2)); |
| 1313 f2_.set_video_rtp_header_extensions( | 1407 f2_.set_video_rtp_header_extensions( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1329 answer.get())->rtp_header_extensions()); | 1423 answer.get())->rtp_header_extensions()); |
| 1330 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), | 1424 EXPECT_EQ(MAKE_VECTOR(kVideoRtpExtensionAnswer), |
| 1331 GetFirstVideoContentDescription( | 1425 GetFirstVideoContentDescription( |
| 1332 answer.get())->rtp_header_extensions()); | 1426 answer.get())->rtp_header_extensions()); |
| 1333 } | 1427 } |
| 1334 | 1428 |
| 1335 // Create an audio, video, data answer without legacy StreamParams. | 1429 // Create an audio, video, data answer without legacy StreamParams. |
| 1336 TEST_F(MediaSessionDescriptionFactoryTest, | 1430 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1337 TestCreateAnswerWithoutLegacyStreams) { | 1431 TestCreateAnswerWithoutLegacyStreams) { |
| 1338 MediaSessionOptions opts; | 1432 MediaSessionOptions opts; |
| 1339 opts.recv_video = true; | 1433 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1340 opts.data_channel_type = cricket::DCT_RTP; | 1434 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 1341 f1_.set_add_legacy_streams(false); | |
| 1342 f2_.set_add_legacy_streams(false); | |
| 1343 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1435 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1344 ASSERT_TRUE(offer.get() != NULL); | 1436 ASSERT_TRUE(offer.get() != NULL); |
| 1345 std::unique_ptr<SessionDescription> answer( | 1437 std::unique_ptr<SessionDescription> answer( |
| 1346 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1438 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1347 const ContentInfo* ac = answer->GetContentByName("audio"); | 1439 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 1348 const ContentInfo* vc = answer->GetContentByName("video"); | 1440 const ContentInfo* vc = answer->GetContentByName("video"); |
| 1349 const ContentInfo* dc = answer->GetContentByName("data"); | 1441 const ContentInfo* dc = answer->GetContentByName("data"); |
| 1350 ASSERT_TRUE(ac != NULL); | 1442 ASSERT_TRUE(ac != NULL); |
| 1351 ASSERT_TRUE(vc != NULL); | 1443 ASSERT_TRUE(vc != NULL); |
| 1352 const AudioContentDescription* acd = | 1444 const AudioContentDescription* acd = |
| 1353 static_cast<const AudioContentDescription*>(ac->description); | 1445 static_cast<const AudioContentDescription*>(ac->description); |
| 1354 const VideoContentDescription* vcd = | 1446 const VideoContentDescription* vcd = |
| 1355 static_cast<const VideoContentDescription*>(vc->description); | 1447 static_cast<const VideoContentDescription*>(vc->description); |
| 1356 const DataContentDescription* dcd = | 1448 const DataContentDescription* dcd = |
| 1357 static_cast<const DataContentDescription*>(dc->description); | 1449 static_cast<const DataContentDescription*>(dc->description); |
| 1358 | 1450 |
| 1359 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. | 1451 EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams. |
| 1360 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. | 1452 EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams. |
| 1361 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. | 1453 EXPECT_FALSE(dcd->has_ssrcs()); // No StreamParams. |
| 1362 } | 1454 } |
| 1363 | 1455 |
| 1364 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { | 1456 TEST_F(MediaSessionDescriptionFactoryTest, TestPartial) { |
| 1365 MediaSessionOptions opts; | 1457 MediaSessionOptions opts; |
| 1366 opts.recv_video = true; | 1458 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1367 opts.data_channel_type = cricket::DCT_RTP; | 1459 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 1368 f1_.set_secure(SEC_ENABLED); | 1460 f1_.set_secure(SEC_ENABLED); |
| 1369 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1461 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1370 ASSERT_TRUE(offer.get() != NULL); | 1462 ASSERT_TRUE(offer.get() != NULL); |
| 1371 const ContentInfo* ac = offer->GetContentByName("audio"); | 1463 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 1372 const ContentInfo* vc = offer->GetContentByName("video"); | 1464 const ContentInfo* vc = offer->GetContentByName("video"); |
| 1373 const ContentInfo* dc = offer->GetContentByName("data"); | 1465 const ContentInfo* dc = offer->GetContentByName("data"); |
| 1374 AudioContentDescription* acd = const_cast<AudioContentDescription*>( | 1466 AudioContentDescription* acd = const_cast<AudioContentDescription*>( |
| 1375 static_cast<const AudioContentDescription*>(ac->description)); | 1467 static_cast<const AudioContentDescription*>(ac->description)); |
| 1376 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( | 1468 VideoContentDescription* vcd = const_cast<VideoContentDescription*>( |
| 1377 static_cast<const VideoContentDescription*>(vc->description)); | 1469 static_cast<const VideoContentDescription*>(vc->description)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1393 EXPECT_FALSE(dcd->partial()); // default is false. | 1485 EXPECT_FALSE(dcd->partial()); // default is false. |
| 1394 dcd->set_partial(true); | 1486 dcd->set_partial(true); |
| 1395 EXPECT_TRUE(dcd->partial()); | 1487 EXPECT_TRUE(dcd->partial()); |
| 1396 dcd->set_partial(false); | 1488 dcd->set_partial(false); |
| 1397 EXPECT_FALSE(dcd->partial()); | 1489 EXPECT_FALSE(dcd->partial()); |
| 1398 } | 1490 } |
| 1399 | 1491 |
| 1400 // Create a typical video answer, and ensure it matches what we expect. | 1492 // Create a typical video answer, and ensure it matches what we expect. |
| 1401 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { | 1493 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswerRtcpMux) { |
| 1402 MediaSessionOptions offer_opts; | 1494 MediaSessionOptions offer_opts; |
| 1495 AddAudioVideoSections(cricket::MD_SENDRECV, &offer_opts); |
| 1496 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &offer_opts); |
| 1497 |
| 1403 MediaSessionOptions answer_opts; | 1498 MediaSessionOptions answer_opts; |
| 1404 answer_opts.recv_video = true; | 1499 AddAudioVideoSections(cricket::MD_SENDRECV, &answer_opts); |
| 1405 offer_opts.recv_video = true; | 1500 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &answer_opts); |
| 1406 answer_opts.data_channel_type = cricket::DCT_RTP; | |
| 1407 offer_opts.data_channel_type = cricket::DCT_RTP; | |
| 1408 | 1501 |
| 1409 std::unique_ptr<SessionDescription> offer; | 1502 std::unique_ptr<SessionDescription> offer; |
| 1410 std::unique_ptr<SessionDescription> answer; | 1503 std::unique_ptr<SessionDescription> answer; |
| 1411 | 1504 |
| 1412 offer_opts.rtcp_mux_enabled = true; | 1505 offer_opts.rtcp_mux_enabled = true; |
| 1413 answer_opts.rtcp_mux_enabled = true; | 1506 answer_opts.rtcp_mux_enabled = true; |
| 1414 | |
| 1415 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1507 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
| 1416 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1508 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 1417 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1509 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
| 1418 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1510 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
| 1419 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1511 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
| 1420 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1512 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
| 1421 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1513 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
| 1422 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1514 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
| 1423 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1515 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
| 1424 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1516 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
| 1425 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1517 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
| 1426 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1518 EXPECT_TRUE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
| 1427 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1519 EXPECT_TRUE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
| 1428 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1520 EXPECT_TRUE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
| 1429 | 1521 |
| 1430 offer_opts.rtcp_mux_enabled = true; | 1522 offer_opts.rtcp_mux_enabled = true; |
| 1431 answer_opts.rtcp_mux_enabled = false; | 1523 answer_opts.rtcp_mux_enabled = false; |
| 1432 | |
| 1433 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1524 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
| 1434 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1525 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 1435 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1526 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
| 1436 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1527 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
| 1437 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1528 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
| 1438 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1529 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
| 1439 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1530 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
| 1440 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1531 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
| 1441 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1532 EXPECT_TRUE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
| 1442 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1533 EXPECT_TRUE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
| 1443 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1534 EXPECT_TRUE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
| 1444 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1535 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
| 1445 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1536 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
| 1446 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1537 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
| 1447 | 1538 |
| 1448 offer_opts.rtcp_mux_enabled = false; | 1539 offer_opts.rtcp_mux_enabled = false; |
| 1449 answer_opts.rtcp_mux_enabled = true; | 1540 answer_opts.rtcp_mux_enabled = true; |
| 1450 | |
| 1451 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1541 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
| 1452 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1542 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 1453 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1543 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
| 1454 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1544 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
| 1455 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1545 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
| 1456 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1546 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
| 1457 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1547 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
| 1458 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1548 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
| 1459 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1549 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
| 1460 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1550 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
| 1461 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1551 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
| 1462 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1552 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
| 1463 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1553 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
| 1464 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1554 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
| 1465 | 1555 |
| 1466 offer_opts.rtcp_mux_enabled = false; | 1556 offer_opts.rtcp_mux_enabled = false; |
| 1467 answer_opts.rtcp_mux_enabled = false; | 1557 answer_opts.rtcp_mux_enabled = false; |
| 1468 | |
| 1469 offer.reset(f1_.CreateOffer(offer_opts, NULL)); | 1558 offer.reset(f1_.CreateOffer(offer_opts, NULL)); |
| 1470 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); | 1559 answer.reset(f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 1471 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); | 1560 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(offer.get())); |
| 1472 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); | 1561 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(offer.get())); |
| 1473 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); | 1562 ASSERT_TRUE(NULL != GetFirstDataContentDescription(offer.get())); |
| 1474 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); | 1563 ASSERT_TRUE(NULL != GetFirstAudioContentDescription(answer.get())); |
| 1475 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); | 1564 ASSERT_TRUE(NULL != GetFirstVideoContentDescription(answer.get())); |
| 1476 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); | 1565 ASSERT_TRUE(NULL != GetFirstDataContentDescription(answer.get())); |
| 1477 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); | 1566 EXPECT_FALSE(GetFirstAudioContentDescription(offer.get())->rtcp_mux()); |
| 1478 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); | 1567 EXPECT_FALSE(GetFirstVideoContentDescription(offer.get())->rtcp_mux()); |
| 1479 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); | 1568 EXPECT_FALSE(GetFirstDataContentDescription(offer.get())->rtcp_mux()); |
| 1480 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); | 1569 EXPECT_FALSE(GetFirstAudioContentDescription(answer.get())->rtcp_mux()); |
| 1481 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); | 1570 EXPECT_FALSE(GetFirstVideoContentDescription(answer.get())->rtcp_mux()); |
| 1482 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); | 1571 EXPECT_FALSE(GetFirstDataContentDescription(answer.get())->rtcp_mux()); |
| 1483 } | 1572 } |
| 1484 | 1573 |
| 1485 // Create an audio-only answer to a video offer. | 1574 // Create an audio-only answer to a video offer. |
| 1486 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { | 1575 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerToVideo) { |
| 1487 MediaSessionOptions opts; | 1576 MediaSessionOptions opts; |
| 1488 opts.recv_video = true; | 1577 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 1578 &opts); |
| 1579 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 1580 &opts); |
| 1489 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1581 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1490 ASSERT_TRUE(offer.get() != NULL); | 1582 ASSERT_TRUE(offer.get() != NULL); |
| 1583 |
| 1584 opts.media_description_options[1].stopped = true; |
| 1491 std::unique_ptr<SessionDescription> answer( | 1585 std::unique_ptr<SessionDescription> answer( |
| 1492 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1586 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1493 const ContentInfo* ac = answer->GetContentByName("audio"); | 1587 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 1494 const ContentInfo* vc = answer->GetContentByName("video"); | 1588 const ContentInfo* vc = answer->GetContentByName("video"); |
| 1495 ASSERT_TRUE(ac != NULL); | 1589 ASSERT_TRUE(ac != NULL); |
| 1496 ASSERT_TRUE(vc != NULL); | 1590 ASSERT_TRUE(vc != NULL); |
| 1497 ASSERT_TRUE(vc->description != NULL); | 1591 ASSERT_TRUE(vc->description != NULL); |
| 1498 EXPECT_TRUE(vc->rejected); | 1592 EXPECT_TRUE(vc->rejected); |
| 1499 } | 1593 } |
| 1500 | 1594 |
| 1501 // Create an audio-only answer to an offer with data. | 1595 // Create an audio-only answer to an offer with data. |
| 1502 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { | 1596 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateNoDataAnswerToDataOffer) { |
| 1503 MediaSessionOptions opts; | 1597 MediaSessionOptions opts = CreatePlanBMediaSessionOptions(); |
| 1504 opts.data_channel_type = cricket::DCT_RTP; | 1598 opts.data_channel_type = cricket::DCT_RTP; |
| 1599 AddMediaSection(MEDIA_TYPE_DATA, "data", cricket::MD_RECVONLY, kActive, |
| 1600 &opts); |
| 1505 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1601 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1506 ASSERT_TRUE(offer.get() != NULL); | 1602 ASSERT_TRUE(offer.get() != NULL); |
| 1603 |
| 1604 opts.media_description_options[1].stopped = true; |
| 1507 std::unique_ptr<SessionDescription> answer( | 1605 std::unique_ptr<SessionDescription> answer( |
| 1508 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 1606 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1509 const ContentInfo* ac = answer->GetContentByName("audio"); | 1607 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 1510 const ContentInfo* dc = answer->GetContentByName("data"); | 1608 const ContentInfo* dc = answer->GetContentByName("data"); |
| 1511 ASSERT_TRUE(ac != NULL); | 1609 ASSERT_TRUE(ac != NULL); |
| 1512 ASSERT_TRUE(dc != NULL); | 1610 ASSERT_TRUE(dc != NULL); |
| 1513 ASSERT_TRUE(dc->description != NULL); | 1611 ASSERT_TRUE(dc->description != NULL); |
| 1514 EXPECT_TRUE(dc->rejected); | 1612 EXPECT_TRUE(dc->rejected); |
| 1515 } | 1613 } |
| 1516 | 1614 |
| 1517 // Create an answer that rejects the contents which are rejected in the offer. | 1615 // Create an answer that rejects the contents which are rejected in the offer. |
| 1518 TEST_F(MediaSessionDescriptionFactoryTest, | 1616 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1519 CreateAnswerToOfferWithRejectedMedia) { | 1617 CreateAnswerToOfferWithRejectedMedia) { |
| 1520 MediaSessionOptions opts; | 1618 MediaSessionOptions opts; |
| 1521 opts.recv_video = true; | 1619 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1522 opts.data_channel_type = cricket::DCT_RTP; | 1620 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &opts); |
| 1523 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1621 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1524 ASSERT_TRUE(offer.get() != NULL); | 1622 ASSERT_TRUE(offer.get() != NULL); |
| 1525 ContentInfo* ac = offer->GetContentByName("audio"); | 1623 ContentInfo* ac = offer->GetContentByName("audio"); |
| 1526 ContentInfo* vc = offer->GetContentByName("video"); | 1624 ContentInfo* vc = offer->GetContentByName("video"); |
| 1527 ContentInfo* dc = offer->GetContentByName("data"); | 1625 ContentInfo* dc = offer->GetContentByName("data"); |
| 1528 ASSERT_TRUE(ac != NULL); | 1626 ASSERT_TRUE(ac != NULL); |
| 1529 ASSERT_TRUE(vc != NULL); | 1627 ASSERT_TRUE(vc != NULL); |
| 1530 ASSERT_TRUE(dc != NULL); | 1628 ASSERT_TRUE(dc != NULL); |
| 1531 ac->rejected = true; | 1629 ac->rejected = true; |
| 1532 vc->rejected = true; | 1630 vc->rejected = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1545 } | 1643 } |
| 1546 | 1644 |
| 1547 // Create an audio and video offer with: | 1645 // Create an audio and video offer with: |
| 1548 // - one video track | 1646 // - one video track |
| 1549 // - two audio tracks | 1647 // - two audio tracks |
| 1550 // - two data tracks | 1648 // - two data tracks |
| 1551 // and ensure it matches what we expect. Also updates the initial offer by | 1649 // and ensure it matches what we expect. Also updates the initial offer by |
| 1552 // adding a new video track and replaces one of the audio tracks. | 1650 // adding a new video track and replaces one of the audio tracks. |
| 1553 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { | 1651 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) { |
| 1554 MediaSessionOptions opts; | 1652 MediaSessionOptions opts; |
| 1555 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1653 AddAudioVideoSections(cricket::MD_SENDRECV, &opts); |
| 1556 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1654 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 1557 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1655 kMediaStream1, 1, &opts); |
| 1558 opts.data_channel_type = cricket::DCT_RTP; | 1656 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 1559 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1657 kMediaStream1, 1, &opts); |
| 1560 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1658 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack2, |
| 1659 kMediaStream1, 1, &opts); |
| 1660 |
| 1661 AddDataSection(cricket::DCT_RTP, cricket::MD_SENDRECV, &opts); |
| 1662 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack1, |
| 1663 kMediaStream1, 1, &opts); |
| 1664 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack2, |
| 1665 kMediaStream1, 1, &opts); |
| 1561 | 1666 |
| 1562 f1_.set_secure(SEC_ENABLED); | 1667 f1_.set_secure(SEC_ENABLED); |
| 1563 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1668 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1564 | 1669 |
| 1565 ASSERT_TRUE(offer.get() != NULL); | 1670 ASSERT_TRUE(offer.get() != NULL); |
| 1566 const ContentInfo* ac = offer->GetContentByName("audio"); | 1671 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 1567 const ContentInfo* vc = offer->GetContentByName("video"); | 1672 const ContentInfo* vc = offer->GetContentByName("video"); |
| 1568 const ContentInfo* dc = offer->GetContentByName("data"); | 1673 const ContentInfo* dc = offer->GetContentByName("data"); |
| 1569 ASSERT_TRUE(ac != NULL); | 1674 ASSERT_TRUE(ac != NULL); |
| 1570 ASSERT_TRUE(vc != NULL); | 1675 ASSERT_TRUE(vc != NULL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 EXPECT_NE(0U, data_streams[0].ssrcs[0]); | 1720 EXPECT_NE(0U, data_streams[0].ssrcs[0]); |
| 1616 EXPECT_EQ(kDataTrack2, data_streams[1].id); | 1721 EXPECT_EQ(kDataTrack2, data_streams[1].id); |
| 1617 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); | 1722 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); |
| 1618 EXPECT_NE(0U, data_streams[1].ssrcs[0]); | 1723 EXPECT_NE(0U, data_streams[1].ssrcs[0]); |
| 1619 | 1724 |
| 1620 EXPECT_EQ(cricket::kDataMaxBandwidth, | 1725 EXPECT_EQ(cricket::kDataMaxBandwidth, |
| 1621 dcd->bandwidth()); // default bandwidth (auto) | 1726 dcd->bandwidth()); // default bandwidth (auto) |
| 1622 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 1727 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
| 1623 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); | 1728 ASSERT_CRYPTO(dcd, 1U, CS_AES_CM_128_HMAC_SHA1_80); |
| 1624 | 1729 |
| 1625 | |
| 1626 // Update the offer. Add a new video track that is not synched to the | 1730 // Update the offer. Add a new video track that is not synched to the |
| 1627 // other tracks and replace audio track 2 with audio track 3. | 1731 // other tracks and replace audio track 2 with audio track 3. |
| 1628 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1732 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack2, |
| 1629 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1733 kMediaStream2, 1, &opts); |
| 1630 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack3, kMediaStream1); | 1734 DetachSenderFromMediaSection("audio", kAudioTrack2, &opts); |
| 1631 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1735 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack3, |
| 1632 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack3, kMediaStream1); | 1736 kMediaStream1, 1, &opts); |
| 1737 DetachSenderFromMediaSection("data", kDataTrack2, &opts); |
| 1738 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack3, |
| 1739 kMediaStream1, 1, &opts); |
| 1633 std::unique_ptr<SessionDescription> updated_offer( | 1740 std::unique_ptr<SessionDescription> updated_offer( |
| 1634 f1_.CreateOffer(opts, offer.get())); | 1741 f1_.CreateOffer(opts, offer.get())); |
| 1635 | 1742 |
| 1636 ASSERT_TRUE(updated_offer.get() != NULL); | 1743 ASSERT_TRUE(updated_offer.get() != NULL); |
| 1637 ac = updated_offer->GetContentByName("audio"); | 1744 ac = updated_offer->GetContentByName("audio"); |
| 1638 vc = updated_offer->GetContentByName("video"); | 1745 vc = updated_offer->GetContentByName("video"); |
| 1639 dc = updated_offer->GetContentByName("data"); | 1746 dc = updated_offer->GetContentByName("data"); |
| 1640 ASSERT_TRUE(ac != NULL); | 1747 ASSERT_TRUE(ac != NULL); |
| 1641 ASSERT_TRUE(vc != NULL); | 1748 ASSERT_TRUE(vc != NULL); |
| 1642 ASSERT_TRUE(dc != NULL); | 1749 ASSERT_TRUE(dc != NULL); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname); | 1791 EXPECT_EQ(updated_data_streams[0].cname, updated_data_streams[1].cname); |
| 1685 // The stream correctly got the CNAME from the MediaSessionOptions. | 1792 // The stream correctly got the CNAME from the MediaSessionOptions. |
| 1686 // The Expected RTCP CNAME is the default one as we are using the default | 1793 // The Expected RTCP CNAME is the default one as we are using the default |
| 1687 // MediaSessionOptions. | 1794 // MediaSessionOptions. |
| 1688 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); | 1795 EXPECT_EQ(updated_data_streams[0].cname, cricket::kDefaultRtcpCname); |
| 1689 } | 1796 } |
| 1690 | 1797 |
| 1691 // Create an offer with simulcast video stream. | 1798 // Create an offer with simulcast video stream. |
| 1692 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { | 1799 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) { |
| 1693 MediaSessionOptions opts; | 1800 MediaSessionOptions opts; |
| 1801 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 1802 &opts); |
| 1803 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 1804 &opts); |
| 1694 const int num_sim_layers = 3; | 1805 const int num_sim_layers = 3; |
| 1695 opts.AddSendVideoStream(kVideoTrack1, kMediaStream1, num_sim_layers); | 1806 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 1807 kMediaStream1, num_sim_layers, &opts); |
| 1696 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1808 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1697 | 1809 |
| 1698 ASSERT_TRUE(offer.get() != NULL); | 1810 ASSERT_TRUE(offer.get() != NULL); |
| 1699 const ContentInfo* vc = offer->GetContentByName("video"); | 1811 const ContentInfo* vc = offer->GetContentByName("video"); |
| 1700 ASSERT_TRUE(vc != NULL); | 1812 ASSERT_TRUE(vc != NULL); |
| 1701 const VideoContentDescription* vcd = | 1813 const VideoContentDescription* vcd = |
| 1702 static_cast<const VideoContentDescription*>(vc->description); | 1814 static_cast<const VideoContentDescription*>(vc->description); |
| 1703 | 1815 |
| 1704 const StreamParamsVec& video_streams = vcd->streams(); | 1816 const StreamParamsVec& video_streams = vcd->streams(); |
| 1705 ASSERT_EQ(1U, video_streams.size()); | 1817 ASSERT_EQ(1U, video_streams.size()); |
| 1706 EXPECT_EQ(kVideoTrack1, video_streams[0].id); | 1818 EXPECT_EQ(kVideoTrack1, video_streams[0].id); |
| 1707 const SsrcGroup* sim_ssrc_group = | 1819 const SsrcGroup* sim_ssrc_group = |
| 1708 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); | 1820 video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics); |
| 1709 ASSERT_TRUE(sim_ssrc_group != NULL); | 1821 ASSERT_TRUE(sim_ssrc_group != NULL); |
| 1710 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); | 1822 EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size()); |
| 1711 } | 1823 } |
| 1712 | 1824 |
| 1713 // Create an audio and video answer to a standard video offer with: | 1825 // Create an audio and video answer to a standard video offer with: |
| 1714 // - one video track | 1826 // - one video track |
| 1715 // - two audio tracks | 1827 // - two audio tracks |
| 1716 // - two data tracks | 1828 // - two data tracks |
| 1717 // and ensure it matches what we expect. Also updates the initial answer by | 1829 // and ensure it matches what we expect. Also updates the initial answer by |
| 1718 // adding a new video track and removes one of the audio tracks. | 1830 // adding a new video track and removes one of the audio tracks. |
| 1719 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { | 1831 TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) { |
| 1720 MediaSessionOptions offer_opts; | 1832 MediaSessionOptions offer_opts; |
| 1721 offer_opts.recv_video = true; | 1833 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 1834 &offer_opts); |
| 1835 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 1836 &offer_opts); |
| 1722 offer_opts.data_channel_type = cricket::DCT_RTP; | 1837 offer_opts.data_channel_type = cricket::DCT_RTP; |
| 1838 AddMediaSection(MEDIA_TYPE_DATA, "data", cricket::MD_RECVONLY, kActive, |
| 1839 &offer_opts); |
| 1723 f1_.set_secure(SEC_ENABLED); | 1840 f1_.set_secure(SEC_ENABLED); |
| 1724 f2_.set_secure(SEC_ENABLED); | 1841 f2_.set_secure(SEC_ENABLED); |
| 1725 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); | 1842 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(offer_opts, NULL)); |
| 1726 | 1843 |
| 1727 MediaSessionOptions opts; | 1844 MediaSessionOptions answer_opts; |
| 1728 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack1, kMediaStream1); | 1845 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_SENDRECV, kActive, |
| 1729 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 1846 &answer_opts); |
| 1730 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2, kMediaStream1); | 1847 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 1731 opts.data_channel_type = cricket::DCT_RTP; | 1848 &answer_opts); |
| 1732 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack1, kMediaStream1); | 1849 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 1733 opts.AddSendStream(MEDIA_TYPE_DATA, kDataTrack2, kMediaStream1); | 1850 kMediaStream1, 1, &answer_opts); |
| 1851 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 1852 kMediaStream1, 1, &answer_opts); |
| 1853 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack2, |
| 1854 kMediaStream1, 1, &answer_opts); |
| 1855 |
| 1856 AddMediaSection(MEDIA_TYPE_DATA, "data", cricket::MD_SENDRECV, kActive, |
| 1857 &answer_opts); |
| 1858 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack1, |
| 1859 kMediaStream1, 1, &answer_opts); |
| 1860 AttachSenderToMediaSection("data", MEDIA_TYPE_DATA, kDataTrack2, |
| 1861 kMediaStream1, 1, &answer_opts); |
| 1862 answer_opts.data_channel_type = cricket::DCT_RTP; |
| 1734 | 1863 |
| 1735 std::unique_ptr<SessionDescription> answer( | 1864 std::unique_ptr<SessionDescription> answer( |
| 1736 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1865 f2_.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 1737 | 1866 |
| 1738 ASSERT_TRUE(answer.get() != NULL); | 1867 ASSERT_TRUE(answer.get() != NULL); |
| 1739 const ContentInfo* ac = answer->GetContentByName("audio"); | 1868 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 1740 const ContentInfo* vc = answer->GetContentByName("video"); | 1869 const ContentInfo* vc = answer->GetContentByName("video"); |
| 1741 const ContentInfo* dc = answer->GetContentByName("data"); | 1870 const ContentInfo* dc = answer->GetContentByName("data"); |
| 1742 ASSERT_TRUE(ac != NULL); | 1871 ASSERT_TRUE(ac != NULL); |
| 1743 ASSERT_TRUE(vc != NULL); | 1872 ASSERT_TRUE(vc != NULL); |
| 1744 ASSERT_TRUE(dc != NULL); | 1873 ASSERT_TRUE(dc != NULL); |
| 1745 const AudioContentDescription* acd = | 1874 const AudioContentDescription* acd = |
| 1746 static_cast<const AudioContentDescription*>(ac->description); | 1875 static_cast<const AudioContentDescription*>(ac->description); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 EXPECT_EQ(kDataTrack2, data_streams[1].id); | 1919 EXPECT_EQ(kDataTrack2, data_streams[1].id); |
| 1791 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); | 1920 ASSERT_EQ(1U, data_streams[1].ssrcs.size()); |
| 1792 EXPECT_NE(0U, data_streams[1].ssrcs[0]); | 1921 EXPECT_NE(0U, data_streams[1].ssrcs[0]); |
| 1793 | 1922 |
| 1794 EXPECT_EQ(cricket::kDataMaxBandwidth, | 1923 EXPECT_EQ(cricket::kDataMaxBandwidth, |
| 1795 dcd->bandwidth()); // default bandwidth (auto) | 1924 dcd->bandwidth()); // default bandwidth (auto) |
| 1796 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on | 1925 EXPECT_TRUE(dcd->rtcp_mux()); // rtcp-mux defaults on |
| 1797 | 1926 |
| 1798 // Update the answer. Add a new video track that is not synched to the | 1927 // Update the answer. Add a new video track that is not synched to the |
| 1799 // other tracks and remove 1 audio track. | 1928 // other tracks and remove 1 audio track. |
| 1800 opts.AddSendStream(MEDIA_TYPE_VIDEO, kVideoTrack2, kMediaStream2); | 1929 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, kVideoTrack2, |
| 1801 opts.RemoveSendStream(MEDIA_TYPE_AUDIO, kAudioTrack2); | 1930 kMediaStream2, 1, &answer_opts); |
| 1802 opts.RemoveSendStream(MEDIA_TYPE_DATA, kDataTrack2); | 1931 DetachSenderFromMediaSection("audio", kAudioTrack2, &answer_opts); |
| 1932 DetachSenderFromMediaSection("data", kDataTrack2, &answer_opts); |
| 1803 std::unique_ptr<SessionDescription> updated_answer( | 1933 std::unique_ptr<SessionDescription> updated_answer( |
| 1804 f2_.CreateAnswer(offer.get(), opts, answer.get())); | 1934 f2_.CreateAnswer(offer.get(), answer_opts, answer.get())); |
| 1805 | 1935 |
| 1806 ASSERT_TRUE(updated_answer.get() != NULL); | 1936 ASSERT_TRUE(updated_answer.get() != NULL); |
| 1807 ac = updated_answer->GetContentByName("audio"); | 1937 ac = updated_answer->GetContentByName("audio"); |
| 1808 vc = updated_answer->GetContentByName("video"); | 1938 vc = updated_answer->GetContentByName("video"); |
| 1809 dc = updated_answer->GetContentByName("data"); | 1939 dc = updated_answer->GetContentByName("data"); |
| 1810 ASSERT_TRUE(ac != NULL); | 1940 ASSERT_TRUE(ac != NULL); |
| 1811 ASSERT_TRUE(vc != NULL); | 1941 ASSERT_TRUE(vc != NULL); |
| 1812 ASSERT_TRUE(dc != NULL); | 1942 ASSERT_TRUE(dc != NULL); |
| 1813 const AudioContentDescription* updated_acd = | 1943 const AudioContentDescription* updated_acd = |
| 1814 static_cast<const AudioContentDescription*>(ac->description); | 1944 static_cast<const AudioContentDescription*>(ac->description); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 ASSERT_EQ(1U, updated_data_streams.size()); | 1976 ASSERT_EQ(1U, updated_data_streams.size()); |
| 1847 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); | 1977 EXPECT_TRUE(data_streams[0] == updated_data_streams[0]); |
| 1848 } | 1978 } |
| 1849 | 1979 |
| 1850 // Create an updated offer after creating an answer to the original offer and | 1980 // Create an updated offer after creating an answer to the original offer and |
| 1851 // verify that the codecs that were part of the original answer are not changed | 1981 // verify that the codecs that were part of the original answer are not changed |
| 1852 // in the updated offer. | 1982 // in the updated offer. |
| 1853 TEST_F(MediaSessionDescriptionFactoryTest, | 1983 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1854 RespondentCreatesOfferAfterCreatingAnswer) { | 1984 RespondentCreatesOfferAfterCreatingAnswer) { |
| 1855 MediaSessionOptions opts; | 1985 MediaSessionOptions opts; |
| 1856 opts.recv_audio = true; | 1986 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1857 opts.recv_video = true; | |
| 1858 | 1987 |
| 1859 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 1988 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1860 std::unique_ptr<SessionDescription> answer( | 1989 std::unique_ptr<SessionDescription> answer( |
| 1861 f2_.CreateAnswer(offer.get(), opts, NULL)); | 1990 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1862 | 1991 |
| 1863 const AudioContentDescription* acd = | 1992 const AudioContentDescription* acd = |
| 1864 GetFirstAudioContentDescription(answer.get()); | 1993 GetFirstAudioContentDescription(answer.get()); |
| 1865 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 1994 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 1866 | 1995 |
| 1867 const VideoContentDescription* vcd = | 1996 const VideoContentDescription* vcd = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1898 GetFirstVideoContentDescription(updated_offer.get()); | 2027 GetFirstVideoContentDescription(updated_offer.get()); |
| 1899 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoCodecOffer), updated_vcd->codecs()); | 2028 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoCodecOffer), updated_vcd->codecs()); |
| 1900 } | 2029 } |
| 1901 | 2030 |
| 1902 // Create an updated offer after creating an answer to the original offer and | 2031 // Create an updated offer after creating an answer to the original offer and |
| 1903 // verify that the codecs that were part of the original answer are not changed | 2032 // verify that the codecs that were part of the original answer are not changed |
| 1904 // in the updated offer. In this test Rtx is enabled. | 2033 // in the updated offer. In this test Rtx is enabled. |
| 1905 TEST_F(MediaSessionDescriptionFactoryTest, | 2034 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1906 RespondentCreatesOfferAfterCreatingAnswerWithRtx) { | 2035 RespondentCreatesOfferAfterCreatingAnswerWithRtx) { |
| 1907 MediaSessionOptions opts; | 2036 MediaSessionOptions opts; |
| 1908 opts.recv_video = true; | 2037 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 1909 opts.recv_audio = false; | 2038 &opts); |
| 1910 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2039 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1911 // This creates rtx for H264 with the payload type |f1_| uses. | 2040 // This creates rtx for H264 with the payload type |f1_| uses. |
| 1912 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2041 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 1913 f1_.set_video_codecs(f1_codecs); | 2042 f1_.set_video_codecs(f1_codecs); |
| 1914 | 2043 |
| 1915 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2044 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 1916 // This creates rtx for H264 with the payload type |f2_| uses. | 2045 // This creates rtx for H264 with the payload type |f2_| uses. |
| 1917 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2046 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
| 1918 f2_.set_video_codecs(f2_codecs); | 2047 f2_.set_video_codecs(f2_codecs); |
| 1919 | 2048 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 // codec have the same default payload type as an audio codec that is already in | 2080 // codec have the same default payload type as an audio codec that is already in |
| 1952 // use, the added codecs payload types are changed. | 2081 // use, the added codecs payload types are changed. |
| 1953 TEST_F(MediaSessionDescriptionFactoryTest, | 2082 TEST_F(MediaSessionDescriptionFactoryTest, |
| 1954 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { | 2083 RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) { |
| 1955 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2084 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 1956 // This creates rtx for H264 with the payload type |f1_| uses. | 2085 // This creates rtx for H264 with the payload type |f1_| uses. |
| 1957 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2086 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 1958 f1_.set_video_codecs(f1_codecs); | 2087 f1_.set_video_codecs(f1_codecs); |
| 1959 | 2088 |
| 1960 MediaSessionOptions opts; | 2089 MediaSessionOptions opts; |
| 1961 opts.recv_audio = true; | 2090 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 1962 opts.recv_video = false; | 2091 &opts); |
| 1963 | 2092 |
| 1964 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2093 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 1965 std::unique_ptr<SessionDescription> answer( | 2094 std::unique_ptr<SessionDescription> answer( |
| 1966 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2095 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 1967 | 2096 |
| 1968 const AudioContentDescription* acd = | 2097 const AudioContentDescription* acd = |
| 1969 GetFirstAudioContentDescription(answer.get()); | 2098 GetFirstAudioContentDescription(answer.get()); |
| 1970 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); | 2099 EXPECT_EQ(MAKE_VECTOR(kAudioCodecsAnswer), acd->codecs()); |
| 1971 | 2100 |
| 1972 // Now - let |f2_| add video with RTX and let the payload type the RTX codec | 2101 // Now - let |f2_| add video with RTX and let the payload type the RTX codec |
| 1973 // reference be the same as an audio codec that was negotiated in the | 2102 // reference be the same as an audio codec that was negotiated in the |
| 1974 // first offer/answer exchange. | 2103 // first offer/answer exchange. |
| 1975 opts.recv_audio = true; | 2104 opts.media_description_options.clear(); |
| 1976 opts.recv_video = true; | 2105 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 1977 | 2106 |
| 1978 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2107 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 1979 int used_pl_type = acd->codecs()[0].id; | 2108 int used_pl_type = acd->codecs()[0].id; |
| 1980 f2_codecs[0].id = used_pl_type; // Set the payload type for H264. | 2109 f2_codecs[0].id = used_pl_type; // Set the payload type for H264. |
| 1981 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs); | 2110 AddRtxCodec(VideoCodec::CreateRtxCodec(125, used_pl_type), &f2_codecs); |
| 1982 f2_.set_video_codecs(f2_codecs); | 2111 f2_.set_video_codecs(f2_codecs); |
| 1983 | 2112 |
| 1984 std::unique_ptr<SessionDescription> updated_offer( | 2113 std::unique_ptr<SessionDescription> updated_offer( |
| 1985 f2_.CreateOffer(opts, answer.get())); | 2114 f2_.CreateOffer(opts, answer.get())); |
| 1986 ASSERT_TRUE(updated_offer); | 2115 ASSERT_TRUE(updated_offer); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2003 rtx.params[cricket::kCodecParamAssociatedPayloadType]); | 2132 rtx.params[cricket::kCodecParamAssociatedPayloadType]); |
| 2004 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); | 2133 EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx); |
| 2005 } | 2134 } |
| 2006 | 2135 |
| 2007 // Create an updated offer with RTX after creating an answer to an offer | 2136 // Create an updated offer with RTX after creating an answer to an offer |
| 2008 // without RTX, and with different default payload types. | 2137 // without RTX, and with different default payload types. |
| 2009 // Verify that the added RTX codec references the correct payload type. | 2138 // Verify that the added RTX codec references the correct payload type. |
| 2010 TEST_F(MediaSessionDescriptionFactoryTest, | 2139 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2011 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { | 2140 RespondentCreatesOfferWithRtxAfterCreatingAnswerWithoutRtx) { |
| 2012 MediaSessionOptions opts; | 2141 MediaSessionOptions opts; |
| 2013 opts.recv_video = true; | 2142 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 2014 opts.recv_audio = true; | |
| 2015 | 2143 |
| 2016 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2144 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 2017 // This creates rtx for H264 with the payload type |f2_| uses. | 2145 // This creates rtx for H264 with the payload type |f2_| uses. |
| 2018 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2146 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
| 2019 f2_.set_video_codecs(f2_codecs); | 2147 f2_.set_video_codecs(f2_codecs); |
| 2020 | 2148 |
| 2021 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2149 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2022 ASSERT_TRUE(offer.get() != nullptr); | 2150 ASSERT_TRUE(offer.get() != nullptr); |
| 2023 std::unique_ptr<SessionDescription> answer( | 2151 std::unique_ptr<SessionDescription> answer( |
| 2024 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 2152 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2042 // New offer should attempt to add H263, and RTX for H264. | 2170 // New offer should attempt to add H263, and RTX for H264. |
| 2043 expected_codecs.push_back(kVideoCodecs2[1]); | 2171 expected_codecs.push_back(kVideoCodecs2[1]); |
| 2044 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), | 2172 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[1].id), |
| 2045 &expected_codecs); | 2173 &expected_codecs); |
| 2046 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); | 2174 EXPECT_EQ(expected_codecs, updated_vcd->codecs()); |
| 2047 } | 2175 } |
| 2048 | 2176 |
| 2049 // Test that RTX is ignored when there is no associated payload type parameter. | 2177 // Test that RTX is ignored when there is no associated payload type parameter. |
| 2050 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { | 2178 TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { |
| 2051 MediaSessionOptions opts; | 2179 MediaSessionOptions opts; |
| 2052 opts.recv_video = true; | 2180 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 2053 opts.recv_audio = false; | 2181 &opts); |
| 2054 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2182 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 2055 // This creates RTX without associated payload type parameter. | 2183 // This creates RTX without associated payload type parameter. |
| 2056 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); | 2184 AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs); |
| 2057 f1_.set_video_codecs(f1_codecs); | 2185 f1_.set_video_codecs(f1_codecs); |
| 2058 | 2186 |
| 2059 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2187 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 2060 // This creates RTX for H264 with the payload type |f2_| uses. | 2188 // This creates RTX for H264 with the payload type |f2_| uses. |
| 2061 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); | 2189 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs); |
| 2062 f2_.set_video_codecs(f2_codecs); | 2190 f2_.set_video_codecs(f2_codecs); |
| 2063 | 2191 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2086 std::vector<std::string> codec_names = | 2214 std::vector<std::string> codec_names = |
| 2087 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 2215 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
| 2088 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 2216 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
| 2089 cricket::kRtxCodecName)); | 2217 cricket::kRtxCodecName)); |
| 2090 } | 2218 } |
| 2091 | 2219 |
| 2092 // Test that RTX will be filtered out in the answer if its associated payload | 2220 // Test that RTX will be filtered out in the answer if its associated payload |
| 2093 // type doesn't match the local value. | 2221 // type doesn't match the local value. |
| 2094 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { | 2222 TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) { |
| 2095 MediaSessionOptions opts; | 2223 MediaSessionOptions opts; |
| 2096 opts.recv_video = true; | 2224 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 2097 opts.recv_audio = false; | 2225 &opts); |
| 2098 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2226 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 2099 // This creates RTX for H264 in sender. | 2227 // This creates RTX for H264 in sender. |
| 2100 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2228 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 2101 f1_.set_video_codecs(f1_codecs); | 2229 f1_.set_video_codecs(f1_codecs); |
| 2102 | 2230 |
| 2103 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2231 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| 2104 // This creates RTX for H263 in receiver. | 2232 // This creates RTX for H263 in receiver. |
| 2105 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); | 2233 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs); |
| 2106 f2_.set_video_codecs(f2_codecs); | 2234 f2_.set_video_codecs(f2_codecs); |
| 2107 | 2235 |
| 2108 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2236 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 2109 ASSERT_TRUE(offer.get() != NULL); | 2237 ASSERT_TRUE(offer.get() != NULL); |
| 2110 // Associated payload type doesn't match, therefore, RTX codec is removed in | 2238 // Associated payload type doesn't match, therefore, RTX codec is removed in |
| 2111 // the answer. | 2239 // the answer. |
| 2112 std::unique_ptr<SessionDescription> answer( | 2240 std::unique_ptr<SessionDescription> answer( |
| 2113 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2241 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 2114 | 2242 |
| 2115 std::vector<std::string> codec_names = | 2243 std::vector<std::string> codec_names = |
| 2116 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); | 2244 GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()); |
| 2117 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), | 2245 EXPECT_EQ(codec_names.end(), std::find(codec_names.begin(), codec_names.end(), |
| 2118 cricket::kRtxCodecName)); | 2246 cricket::kRtxCodecName)); |
| 2119 } | 2247 } |
| 2120 | 2248 |
| 2121 // Test that when multiple RTX codecs are offered, only the matched RTX codec | 2249 // Test that when multiple RTX codecs are offered, only the matched RTX codec |
| 2122 // is added in the answer, and the unsupported RTX codec is filtered out. | 2250 // is added in the answer, and the unsupported RTX codec is filtered out. |
| 2123 TEST_F(MediaSessionDescriptionFactoryTest, | 2251 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2124 FilterOutUnsupportedRtxWhenCreatingAnswer) { | 2252 FilterOutUnsupportedRtxWhenCreatingAnswer) { |
| 2125 MediaSessionOptions opts; | 2253 MediaSessionOptions opts; |
| 2126 opts.recv_video = true; | 2254 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 2127 opts.recv_audio = false; | 2255 &opts); |
| 2128 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2256 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 2129 // This creates RTX for H264-SVC in sender. | 2257 // This creates RTX for H264-SVC in sender. |
| 2130 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); | 2258 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs); |
| 2131 f1_.set_video_codecs(f1_codecs); | 2259 f1_.set_video_codecs(f1_codecs); |
| 2132 | 2260 |
| 2133 // This creates RTX for H264 in sender. | 2261 // This creates RTX for H264 in sender. |
| 2134 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2262 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 2135 f1_.set_video_codecs(f1_codecs); | 2263 f1_.set_video_codecs(f1_codecs); |
| 2136 | 2264 |
| 2137 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); | 2265 std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2151 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), | 2279 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), |
| 2152 &expected_codecs); | 2280 &expected_codecs); |
| 2153 | 2281 |
| 2154 EXPECT_EQ(expected_codecs, vcd->codecs()); | 2282 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 2155 } | 2283 } |
| 2156 | 2284 |
| 2157 // Test that after one RTX codec has been negotiated, a new offer can attempt | 2285 // Test that after one RTX codec has been negotiated, a new offer can attempt |
| 2158 // to add another. | 2286 // to add another. |
| 2159 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { | 2287 TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) { |
| 2160 MediaSessionOptions opts; | 2288 MediaSessionOptions opts; |
| 2161 opts.recv_video = true; | 2289 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_RECVONLY, kActive, |
| 2162 opts.recv_audio = false; | 2290 &opts); |
| 2163 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); | 2291 std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 2164 // This creates RTX for H264 for the offerer. | 2292 // This creates RTX for H264 for the offerer. |
| 2165 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); | 2293 AddRtxCodec(VideoCodec::CreateRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs); |
| 2166 f1_.set_video_codecs(f1_codecs); | 2294 f1_.set_video_codecs(f1_codecs); |
| 2167 | 2295 |
| 2168 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2296 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2169 ASSERT_TRUE(offer); | 2297 ASSERT_TRUE(offer); |
| 2170 const VideoContentDescription* vcd = | 2298 const VideoContentDescription* vcd = |
| 2171 GetFirstVideoContentDescription(offer.get()); | 2299 GetFirstVideoContentDescription(offer.get()); |
| 2172 | 2300 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2186 | 2314 |
| 2187 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), | 2315 AddRtxCodec(VideoCodec::CreateRtxCodec(125, kVideoCodecs1[0].id), |
| 2188 &expected_codecs); | 2316 &expected_codecs); |
| 2189 EXPECT_EQ(expected_codecs, vcd->codecs()); | 2317 EXPECT_EQ(expected_codecs, vcd->codecs()); |
| 2190 } | 2318 } |
| 2191 | 2319 |
| 2192 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is | 2320 // Test that when RTX is used in conjunction with simulcast, an RTX ssrc is |
| 2193 // generated for each simulcast ssrc and correctly grouped. | 2321 // generated for each simulcast ssrc and correctly grouped. |
| 2194 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { | 2322 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { |
| 2195 MediaSessionOptions opts; | 2323 MediaSessionOptions opts; |
| 2196 opts.recv_video = true; | 2324 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 2197 opts.recv_audio = false; | 2325 &opts); |
| 2198 | |
| 2199 // Add simulcast streams. | 2326 // Add simulcast streams. |
| 2200 opts.AddSendVideoStream("stream1", "stream1label", 3); | 2327 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
| 2328 "stream1label", 3, &opts); |
| 2201 | 2329 |
| 2202 // Use a single real codec, and then add RTX for it. | 2330 // Use a single real codec, and then add RTX for it. |
| 2203 std::vector<VideoCodec> f1_codecs; | 2331 std::vector<VideoCodec> f1_codecs; |
| 2204 f1_codecs.push_back(VideoCodec(97, "H264")); | 2332 f1_codecs.push_back(VideoCodec(97, "H264")); |
| 2205 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); | 2333 AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs); |
| 2206 f1_.set_video_codecs(f1_codecs); | 2334 f1_.set_video_codecs(f1_codecs); |
| 2207 | 2335 |
| 2208 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there | 2336 // Ensure that the offer has an RTX ssrc for each regular ssrc, and that there |
| 2209 // is a FID ssrc + grouping for each. | 2337 // is a FID ssrc + grouping for each. |
| 2210 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2338 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2227 EXPECT_EQ(3u, primary_ssrcs.size()); | 2355 EXPECT_EQ(3u, primary_ssrcs.size()); |
| 2228 std::vector<uint32_t> fid_ssrcs; | 2356 std::vector<uint32_t> fid_ssrcs; |
| 2229 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); | 2357 streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); |
| 2230 EXPECT_EQ(3u, fid_ssrcs.size()); | 2358 EXPECT_EQ(3u, fid_ssrcs.size()); |
| 2231 } | 2359 } |
| 2232 | 2360 |
| 2233 // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created | 2361 // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created |
| 2234 // together with a FEC-FR grouping. | 2362 // together with a FEC-FR grouping. |
| 2235 TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { | 2363 TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { |
| 2236 MediaSessionOptions opts; | 2364 MediaSessionOptions opts; |
| 2237 opts.recv_video = true; | 2365 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 2238 opts.recv_audio = false; | 2366 &opts); |
| 2239 | |
| 2240 // Add single stream. | 2367 // Add single stream. |
| 2241 opts.AddSendVideoStream("stream1", "stream1label", 1); | 2368 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
| 2369 "stream1label", 1, &opts); |
| 2242 | 2370 |
| 2243 // Use a single real codec, and then add FlexFEC for it. | 2371 // Use a single real codec, and then add FlexFEC for it. |
| 2244 std::vector<VideoCodec> f1_codecs; | 2372 std::vector<VideoCodec> f1_codecs; |
| 2245 f1_codecs.push_back(VideoCodec(97, "H264")); | 2373 f1_codecs.push_back(VideoCodec(97, "H264")); |
| 2246 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); | 2374 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
| 2247 f1_.set_video_codecs(f1_codecs); | 2375 f1_.set_video_codecs(f1_codecs); |
| 2248 | 2376 |
| 2249 // Ensure that the offer has a single FlexFEC ssrc and that | 2377 // Ensure that the offer has a single FlexFEC ssrc and that |
| 2250 // there is no FEC-FR ssrc + grouping for each. | 2378 // there is no FEC-FR ssrc + grouping for each. |
| 2251 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2379 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2267 uint32_t flexfec_ssrc; | 2395 uint32_t flexfec_ssrc; |
| 2268 EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc)); | 2396 EXPECT_TRUE(streams[0].GetFecFrSsrc(primary_ssrcs[0], &flexfec_ssrc)); |
| 2269 EXPECT_NE(flexfec_ssrc, 0u); | 2397 EXPECT_NE(flexfec_ssrc, 0u); |
| 2270 } | 2398 } |
| 2271 | 2399 |
| 2272 // Test that FlexFEC is disabled for simulcast. | 2400 // Test that FlexFEC is disabled for simulcast. |
| 2273 // TODO(brandtr): Remove this test when we support simulcast, either through | 2401 // TODO(brandtr): Remove this test when we support simulcast, either through |
| 2274 // multiple FlexfecSenders, or through multistream protection. | 2402 // multiple FlexfecSenders, or through multistream protection. |
| 2275 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { | 2403 TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { |
| 2276 MediaSessionOptions opts; | 2404 MediaSessionOptions opts; |
| 2277 opts.recv_video = true; | 2405 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 2278 opts.recv_audio = false; | 2406 &opts); |
| 2279 | |
| 2280 // Add simulcast streams. | 2407 // Add simulcast streams. |
| 2281 opts.AddSendVideoStream("stream1", "stream1label", 3); | 2408 AttachSenderToMediaSection("video", MEDIA_TYPE_VIDEO, "stream1", |
| 2409 "stream1label", 3, &opts); |
| 2282 | 2410 |
| 2283 // Use a single real codec, and then add FlexFEC for it. | 2411 // Use a single real codec, and then add FlexFEC for it. |
| 2284 std::vector<VideoCodec> f1_codecs; | 2412 std::vector<VideoCodec> f1_codecs; |
| 2285 f1_codecs.push_back(VideoCodec(97, "H264")); | 2413 f1_codecs.push_back(VideoCodec(97, "H264")); |
| 2286 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); | 2414 f1_codecs.push_back(VideoCodec(118, "flexfec-03")); |
| 2287 f1_.set_video_codecs(f1_codecs); | 2415 f1_.set_video_codecs(f1_codecs); |
| 2288 | 2416 |
| 2289 // Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that | 2417 // Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that |
| 2290 // there is no FEC-FR ssrc + grouping for each. | 2418 // there is no FEC-FR ssrc + grouping for each. |
| 2291 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2419 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2311 EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)); | 2439 EXPECT_FALSE(streams[0].GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)); |
| 2312 } | 2440 } |
| 2313 } | 2441 } |
| 2314 | 2442 |
| 2315 // Create an updated offer after creating an answer to the original offer and | 2443 // Create an updated offer after creating an answer to the original offer and |
| 2316 // verify that the RTP header extensions that were part of the original answer | 2444 // verify that the RTP header extensions that were part of the original answer |
| 2317 // are not changed in the updated offer. | 2445 // are not changed in the updated offer. |
| 2318 TEST_F(MediaSessionDescriptionFactoryTest, | 2446 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2319 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { | 2447 RespondentCreatesOfferAfterCreatingAnswerWithRtpExtensions) { |
| 2320 MediaSessionOptions opts; | 2448 MediaSessionOptions opts; |
| 2321 opts.recv_audio = true; | 2449 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 2322 opts.recv_video = true; | |
| 2323 | 2450 |
| 2324 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); | 2451 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension1)); |
| 2325 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); | 2452 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension1)); |
| 2326 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); | 2453 f2_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension2)); |
| 2327 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); | 2454 f2_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension2)); |
| 2328 | 2455 |
| 2329 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2456 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 2330 std::unique_ptr<SessionDescription> answer( | 2457 std::unique_ptr<SessionDescription> answer( |
| 2331 f2_.CreateAnswer(offer.get(), opts, NULL)); | 2458 f2_.CreateAnswer(offer.get(), opts, NULL)); |
| 2332 | 2459 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 GetFirstVideoContentDescription(updated_offer.get()); | 2493 GetFirstVideoContentDescription(updated_offer.get()); |
| 2367 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoRtpExtensions), | 2494 EXPECT_EQ(MAKE_VECTOR(kUpdatedVideoRtpExtensions), |
| 2368 updated_vcd->rtp_header_extensions()); | 2495 updated_vcd->rtp_header_extensions()); |
| 2369 } | 2496 } |
| 2370 | 2497 |
| 2371 // Verify that if the same RTP extension URI is used for audio and video, the | 2498 // Verify that if the same RTP extension URI is used for audio and video, the |
| 2372 // same ID is used. Also verify that the ID isn't changed when creating an | 2499 // same ID is used. Also verify that the ID isn't changed when creating an |
| 2373 // updated offer (this was previously a bug). | 2500 // updated offer (this was previously a bug). |
| 2374 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { | 2501 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReused) { |
| 2375 MediaSessionOptions opts; | 2502 MediaSessionOptions opts; |
| 2376 opts.recv_audio = true; | 2503 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 2377 opts.recv_video = true; | |
| 2378 | 2504 |
| 2379 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); | 2505 f1_.set_audio_rtp_header_extensions(MAKE_VECTOR(kAudioRtpExtension3)); |
| 2380 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); | 2506 f1_.set_video_rtp_header_extensions(MAKE_VECTOR(kVideoRtpExtension3)); |
| 2381 | 2507 |
| 2382 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2508 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| 2383 | 2509 |
| 2384 // Since the audio extensions used ID 3 for "both_audio_and_video", so should | 2510 // Since the audio extensions used ID 3 for "both_audio_and_video", so should |
| 2385 // the video extensions. | 2511 // the video extensions. |
| 2386 const RtpExtension kExpectedVideoRtpExtension[] = { | 2512 const RtpExtension kExpectedVideoRtpExtension[] = { |
| 2387 kVideoRtpExtension3[0], kAudioRtpExtension3[1], | 2513 kVideoRtpExtension3[0], kAudioRtpExtension3[1], |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2402 GetFirstAudioContentDescription( | 2528 GetFirstAudioContentDescription( |
| 2403 updated_offer.get())->rtp_header_extensions()); | 2529 updated_offer.get())->rtp_header_extensions()); |
| 2404 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), | 2530 EXPECT_EQ(MAKE_VECTOR(kExpectedVideoRtpExtension), |
| 2405 GetFirstVideoContentDescription( | 2531 GetFirstVideoContentDescription( |
| 2406 updated_offer.get())->rtp_header_extensions()); | 2532 updated_offer.get())->rtp_header_extensions()); |
| 2407 } | 2533 } |
| 2408 | 2534 |
| 2409 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions. | 2535 // Same as "RtpExtensionIdReused" above for encrypted RTP extensions. |
| 2410 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) { | 2536 TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) { |
| 2411 MediaSessionOptions opts; | 2537 MediaSessionOptions opts; |
| 2412 opts.recv_audio = true; | 2538 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 2413 opts.recv_video = true; | |
| 2414 | 2539 |
| 2415 f1_.set_enable_encrypted_rtp_header_extensions(true); | 2540 f1_.set_enable_encrypted_rtp_header_extensions(true); |
| 2416 f2_.set_enable_encrypted_rtp_header_extensions(true); | 2541 f2_.set_enable_encrypted_rtp_header_extensions(true); |
| 2417 | 2542 |
| 2418 f1_.set_audio_rtp_header_extensions( | 2543 f1_.set_audio_rtp_header_extensions( |
| 2419 MAKE_VECTOR(kAudioRtpExtension3ForEncryption)); | 2544 MAKE_VECTOR(kAudioRtpExtension3ForEncryption)); |
| 2420 f1_.set_video_rtp_header_extensions( | 2545 f1_.set_video_rtp_header_extensions( |
| 2421 MAKE_VECTOR(kVideoRtpExtension3ForEncryption)); | 2546 MAKE_VECTOR(kVideoRtpExtension3ForEncryption)); |
| 2422 | 2547 |
| 2423 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); | 2548 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, NULL)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 const VideoContentDescription* vcd_copy = | 2604 const VideoContentDescription* vcd_copy = |
| 2480 static_cast<const VideoContentDescription*>(vc->description); | 2605 static_cast<const VideoContentDescription*>(vc->description); |
| 2481 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); | 2606 EXPECT_EQ(vcd->codecs(), vcd_copy->codecs()); |
| 2482 EXPECT_EQ(2u, vcd->first_ssrc()); | 2607 EXPECT_EQ(2u, vcd->first_ssrc()); |
| 2483 } | 2608 } |
| 2484 | 2609 |
| 2485 // The below TestTransportInfoXXX tests create different offers/answers, and | 2610 // The below TestTransportInfoXXX tests create different offers/answers, and |
| 2486 // ensure the TransportInfo in the SessionDescription matches what we expect. | 2611 // ensure the TransportInfo in the SessionDescription matches what we expect. |
| 2487 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { | 2612 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudio) { |
| 2488 MediaSessionOptions options; | 2613 MediaSessionOptions options; |
| 2489 options.recv_audio = true; | 2614 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2615 &options); |
| 2490 TestTransportInfo(true, options, false); | 2616 TestTransportInfo(true, options, false); |
| 2491 } | 2617 } |
| 2492 | 2618 |
| 2493 TEST_F(MediaSessionDescriptionFactoryTest, | 2619 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2494 TestTransportInfoOfferIceRenomination) { | 2620 TestTransportInfoOfferIceRenomination) { |
| 2495 MediaSessionOptions options; | 2621 MediaSessionOptions options; |
| 2496 options.enable_ice_renomination = true; | 2622 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2623 &options); |
| 2624 options.media_description_options[0] |
| 2625 .transport_options.enable_ice_renomination = true; |
| 2497 TestTransportInfo(true, options, false); | 2626 TestTransportInfo(true, options, false); |
| 2498 } | 2627 } |
| 2499 | 2628 |
| 2500 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { | 2629 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferAudioCurrent) { |
| 2501 MediaSessionOptions options; | 2630 MediaSessionOptions options; |
| 2502 options.recv_audio = true; | 2631 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2632 &options); |
| 2503 TestTransportInfo(true, options, true); | 2633 TestTransportInfo(true, options, true); |
| 2504 } | 2634 } |
| 2505 | 2635 |
| 2506 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { | 2636 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferMultimedia) { |
| 2507 MediaSessionOptions options; | 2637 MediaSessionOptions options; |
| 2508 options.recv_audio = true; | 2638 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2509 options.recv_video = true; | 2639 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2510 options.data_channel_type = cricket::DCT_RTP; | |
| 2511 TestTransportInfo(true, options, false); | 2640 TestTransportInfo(true, options, false); |
| 2512 } | 2641 } |
| 2513 | 2642 |
| 2514 TEST_F(MediaSessionDescriptionFactoryTest, | 2643 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2515 TestTransportInfoOfferMultimediaCurrent) { | 2644 TestTransportInfoOfferMultimediaCurrent) { |
| 2516 MediaSessionOptions options; | 2645 MediaSessionOptions options; |
| 2517 options.recv_audio = true; | 2646 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2518 options.recv_video = true; | 2647 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2519 options.data_channel_type = cricket::DCT_RTP; | |
| 2520 TestTransportInfo(true, options, true); | 2648 TestTransportInfo(true, options, true); |
| 2521 } | 2649 } |
| 2522 | 2650 |
| 2523 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferBundle) { | 2651 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoOfferBundle) { |
| 2524 MediaSessionOptions options; | 2652 MediaSessionOptions options; |
| 2525 options.recv_audio = true; | 2653 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2526 options.recv_video = true; | 2654 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2527 options.data_channel_type = cricket::DCT_RTP; | |
| 2528 options.bundle_enabled = true; | 2655 options.bundle_enabled = true; |
| 2529 TestTransportInfo(true, options, false); | 2656 TestTransportInfo(true, options, false); |
| 2530 } | 2657 } |
| 2531 | 2658 |
| 2532 TEST_F(MediaSessionDescriptionFactoryTest, | 2659 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2533 TestTransportInfoOfferBundleCurrent) { | 2660 TestTransportInfoOfferBundleCurrent) { |
| 2534 MediaSessionOptions options; | 2661 MediaSessionOptions options; |
| 2535 options.recv_audio = true; | 2662 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2536 options.recv_video = true; | 2663 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2537 options.data_channel_type = cricket::DCT_RTP; | |
| 2538 options.bundle_enabled = true; | 2664 options.bundle_enabled = true; |
| 2539 TestTransportInfo(true, options, true); | 2665 TestTransportInfo(true, options, true); |
| 2540 } | 2666 } |
| 2541 | 2667 |
| 2542 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { | 2668 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerAudio) { |
| 2543 MediaSessionOptions options; | 2669 MediaSessionOptions options; |
| 2544 options.recv_audio = true; | 2670 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2671 &options); |
| 2545 TestTransportInfo(false, options, false); | 2672 TestTransportInfo(false, options, false); |
| 2546 } | 2673 } |
| 2547 | 2674 |
| 2548 TEST_F(MediaSessionDescriptionFactoryTest, | 2675 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2549 TestTransportInfoAnswerIceRenomination) { | 2676 TestTransportInfoAnswerIceRenomination) { |
| 2550 MediaSessionOptions options; | 2677 MediaSessionOptions options; |
| 2551 options.enable_ice_renomination = true; | 2678 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2679 &options); |
| 2680 options.media_description_options[0] |
| 2681 .transport_options.enable_ice_renomination = true; |
| 2552 TestTransportInfo(false, options, false); | 2682 TestTransportInfo(false, options, false); |
| 2553 } | 2683 } |
| 2554 | 2684 |
| 2555 TEST_F(MediaSessionDescriptionFactoryTest, | 2685 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2556 TestTransportInfoAnswerAudioCurrent) { | 2686 TestTransportInfoAnswerAudioCurrent) { |
| 2557 MediaSessionOptions options; | 2687 MediaSessionOptions options; |
| 2558 options.recv_audio = true; | 2688 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_RECVONLY, kActive, |
| 2689 &options); |
| 2559 TestTransportInfo(false, options, true); | 2690 TestTransportInfo(false, options, true); |
| 2560 } | 2691 } |
| 2561 | 2692 |
| 2562 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { | 2693 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerMultimedia) { |
| 2563 MediaSessionOptions options; | 2694 MediaSessionOptions options; |
| 2564 options.recv_audio = true; | 2695 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2565 options.recv_video = true; | 2696 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2566 options.data_channel_type = cricket::DCT_RTP; | |
| 2567 TestTransportInfo(false, options, false); | 2697 TestTransportInfo(false, options, false); |
| 2568 } | 2698 } |
| 2569 | 2699 |
| 2570 TEST_F(MediaSessionDescriptionFactoryTest, | 2700 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2571 TestTransportInfoAnswerMultimediaCurrent) { | 2701 TestTransportInfoAnswerMultimediaCurrent) { |
| 2572 MediaSessionOptions options; | 2702 MediaSessionOptions options; |
| 2573 options.recv_audio = true; | 2703 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2574 options.recv_video = true; | 2704 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2575 options.data_channel_type = cricket::DCT_RTP; | |
| 2576 TestTransportInfo(false, options, true); | 2705 TestTransportInfo(false, options, true); |
| 2577 } | 2706 } |
| 2578 | 2707 |
| 2579 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerBundle) { | 2708 TEST_F(MediaSessionDescriptionFactoryTest, TestTransportInfoAnswerBundle) { |
| 2580 MediaSessionOptions options; | 2709 MediaSessionOptions options; |
| 2581 options.recv_audio = true; | 2710 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2582 options.recv_video = true; | 2711 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2583 options.data_channel_type = cricket::DCT_RTP; | |
| 2584 options.bundle_enabled = true; | 2712 options.bundle_enabled = true; |
| 2585 TestTransportInfo(false, options, false); | 2713 TestTransportInfo(false, options, false); |
| 2586 } | 2714 } |
| 2587 | 2715 |
| 2588 TEST_F(MediaSessionDescriptionFactoryTest, | 2716 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2589 TestTransportInfoAnswerBundleCurrent) { | 2717 TestTransportInfoAnswerBundleCurrent) { |
| 2590 MediaSessionOptions options; | 2718 MediaSessionOptions options; |
| 2591 options.recv_audio = true; | 2719 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2592 options.recv_video = true; | 2720 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2593 options.data_channel_type = cricket::DCT_RTP; | |
| 2594 options.bundle_enabled = true; | 2721 options.bundle_enabled = true; |
| 2595 TestTransportInfo(false, options, true); | 2722 TestTransportInfo(false, options, true); |
| 2596 } | 2723 } |
| 2597 | 2724 |
| 2598 // Create an offer with bundle enabled and verify the crypto parameters are | 2725 // Create an offer with bundle enabled and verify the crypto parameters are |
| 2599 // the common set of the available cryptos. | 2726 // the common set of the available cryptos. |
| 2600 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithOfferBundle) { | 2727 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithOfferBundle) { |
| 2601 TestCryptoWithBundle(true); | 2728 TestCryptoWithBundle(true); |
| 2602 } | 2729 } |
| 2603 | 2730 |
| 2604 // Create an answer with bundle enabled and verify the crypto parameters are | 2731 // Create an answer with bundle enabled and verify the crypto parameters are |
| 2605 // the common set of the available cryptos. | 2732 // the common set of the available cryptos. |
| 2606 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithAnswerBundle) { | 2733 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoWithAnswerBundle) { |
| 2607 TestCryptoWithBundle(false); | 2734 TestCryptoWithBundle(false); |
| 2608 } | 2735 } |
| 2609 | 2736 |
| 2610 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but | 2737 // Verifies that creating answer fails if the offer has UDP/TLS/RTP/SAVPF but |
| 2611 // DTLS is not enabled locally. | 2738 // DTLS is not enabled locally. |
| 2612 TEST_F(MediaSessionDescriptionFactoryTest, | 2739 TEST_F(MediaSessionDescriptionFactoryTest, |
| 2613 TestOfferDtlsSavpfWithoutDtlsFailed) { | 2740 TestOfferDtlsSavpfWithoutDtlsFailed) { |
| 2614 f1_.set_secure(SEC_ENABLED); | 2741 f1_.set_secure(SEC_ENABLED); |
| 2615 f2_.set_secure(SEC_ENABLED); | 2742 f2_.set_secure(SEC_ENABLED); |
| 2616 tdf1_.set_secure(SEC_DISABLED); | 2743 tdf1_.set_secure(SEC_DISABLED); |
| 2617 tdf2_.set_secure(SEC_DISABLED); | 2744 tdf2_.set_secure(SEC_DISABLED); |
| 2618 | 2745 |
| 2619 std::unique_ptr<SessionDescription> offer( | 2746 std::unique_ptr<SessionDescription> offer( |
| 2620 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2747 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
| 2621 ASSERT_TRUE(offer.get() != NULL); | 2748 ASSERT_TRUE(offer.get() != NULL); |
| 2622 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2749 ContentInfo* offer_content = offer->GetContentByName("audio"); |
| 2623 ASSERT_TRUE(offer_content != NULL); | 2750 ASSERT_TRUE(offer_content != NULL); |
| 2624 AudioContentDescription* offer_audio_desc = | 2751 AudioContentDescription* offer_audio_desc = |
| 2625 static_cast<AudioContentDescription*>(offer_content->description); | 2752 static_cast<AudioContentDescription*>(offer_content->description); |
| 2626 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2753 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
| 2627 | 2754 |
| 2628 std::unique_ptr<SessionDescription> answer( | 2755 std::unique_ptr<SessionDescription> answer( |
| 2629 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2756 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
| 2630 ASSERT_TRUE(answer != NULL); | 2757 ASSERT_TRUE(answer != NULL); |
| 2631 ContentInfo* answer_content = answer->GetContentByName("audio"); | 2758 ContentInfo* answer_content = answer->GetContentByName("audio"); |
| 2632 ASSERT_TRUE(answer_content != NULL); | 2759 ASSERT_TRUE(answer_content != NULL); |
| 2633 | 2760 |
| 2634 ASSERT_TRUE(answer_content->rejected); | 2761 ASSERT_TRUE(answer_content->rejected); |
| 2635 } | 2762 } |
| 2636 | 2763 |
| 2637 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains | 2764 // Offers UDP/TLS/RTP/SAVPF and verifies the answer can be created and contains |
| 2638 // UDP/TLS/RTP/SAVPF. | 2765 // UDP/TLS/RTP/SAVPF. |
| 2639 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { | 2766 TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) { |
| 2640 f1_.set_secure(SEC_ENABLED); | 2767 f1_.set_secure(SEC_ENABLED); |
| 2641 f2_.set_secure(SEC_ENABLED); | 2768 f2_.set_secure(SEC_ENABLED); |
| 2642 tdf1_.set_secure(SEC_ENABLED); | 2769 tdf1_.set_secure(SEC_ENABLED); |
| 2643 tdf2_.set_secure(SEC_ENABLED); | 2770 tdf2_.set_secure(SEC_ENABLED); |
| 2644 | 2771 |
| 2645 std::unique_ptr<SessionDescription> offer( | 2772 std::unique_ptr<SessionDescription> offer( |
| 2646 f1_.CreateOffer(MediaSessionOptions(), NULL)); | 2773 f1_.CreateOffer(CreatePlanBMediaSessionOptions(), NULL)); |
| 2647 ASSERT_TRUE(offer.get() != NULL); | 2774 ASSERT_TRUE(offer.get() != NULL); |
| 2648 ContentInfo* offer_content = offer->GetContentByName("audio"); | 2775 ContentInfo* offer_content = offer->GetContentByName("audio"); |
| 2649 ASSERT_TRUE(offer_content != NULL); | 2776 ASSERT_TRUE(offer_content != NULL); |
| 2650 AudioContentDescription* offer_audio_desc = | 2777 AudioContentDescription* offer_audio_desc = |
| 2651 static_cast<AudioContentDescription*>(offer_content->description); | 2778 static_cast<AudioContentDescription*>(offer_content->description); |
| 2652 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); | 2779 offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf); |
| 2653 | 2780 |
| 2654 std::unique_ptr<SessionDescription> answer( | 2781 std::unique_ptr<SessionDescription> answer( |
| 2655 f2_.CreateAnswer(offer.get(), MediaSessionOptions(), NULL)); | 2782 f2_.CreateAnswer(offer.get(), CreatePlanBMediaSessionOptions(), NULL)); |
| 2656 ASSERT_TRUE(answer != NULL); | 2783 ASSERT_TRUE(answer != NULL); |
| 2657 | 2784 |
| 2658 const ContentInfo* answer_content = answer->GetContentByName("audio"); | 2785 const ContentInfo* answer_content = answer->GetContentByName("audio"); |
| 2659 ASSERT_TRUE(answer_content != NULL); | 2786 ASSERT_TRUE(answer_content != NULL); |
| 2660 ASSERT_FALSE(answer_content->rejected); | 2787 ASSERT_FALSE(answer_content->rejected); |
| 2661 | 2788 |
| 2662 const AudioContentDescription* answer_audio_desc = | 2789 const AudioContentDescription* answer_audio_desc = |
| 2663 static_cast<const AudioContentDescription*>(answer_content->description); | 2790 static_cast<const AudioContentDescription*>(answer_content->description); |
| 2664 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), | 2791 EXPECT_EQ(std::string(cricket::kMediaProtocolDtlsSavpf), |
| 2665 answer_audio_desc->protocol()); | 2792 answer_audio_desc->protocol()); |
| 2666 } | 2793 } |
| 2667 | 2794 |
| 2668 // Test that we include both SDES and DTLS in the offer, but only include SDES | 2795 // Test that we include both SDES and DTLS in the offer, but only include SDES |
| 2669 // in the answer if DTLS isn't negotiated. | 2796 // in the answer if DTLS isn't negotiated. |
| 2670 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { | 2797 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) { |
| 2671 f1_.set_secure(SEC_ENABLED); | 2798 f1_.set_secure(SEC_ENABLED); |
| 2672 f2_.set_secure(SEC_ENABLED); | 2799 f2_.set_secure(SEC_ENABLED); |
| 2673 tdf1_.set_secure(SEC_ENABLED); | 2800 tdf1_.set_secure(SEC_ENABLED); |
| 2674 tdf2_.set_secure(SEC_DISABLED); | 2801 tdf2_.set_secure(SEC_DISABLED); |
| 2675 MediaSessionOptions options; | 2802 MediaSessionOptions options; |
| 2676 options.recv_audio = true; | 2803 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2677 options.recv_video = true; | |
| 2678 std::unique_ptr<SessionDescription> offer, answer; | 2804 std::unique_ptr<SessionDescription> offer, answer; |
| 2679 const cricket::MediaContentDescription* audio_media_desc; | 2805 const cricket::MediaContentDescription* audio_media_desc; |
| 2680 const cricket::MediaContentDescription* video_media_desc; | 2806 const cricket::MediaContentDescription* video_media_desc; |
| 2681 const cricket::TransportDescription* audio_trans_desc; | 2807 const cricket::TransportDescription* audio_trans_desc; |
| 2682 const cricket::TransportDescription* video_trans_desc; | 2808 const cricket::TransportDescription* video_trans_desc; |
| 2683 | 2809 |
| 2684 // Generate an offer with SDES and DTLS support. | 2810 // Generate an offer with SDES and DTLS support. |
| 2685 offer.reset(f1_.CreateOffer(options, NULL)); | 2811 offer.reset(f1_.CreateOffer(options, NULL)); |
| 2686 ASSERT_TRUE(offer.get() != NULL); | 2812 ASSERT_TRUE(offer.get() != NULL); |
| 2687 | 2813 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 ASSERT_TRUE(audio_trans_desc != NULL); | 2889 ASSERT_TRUE(audio_trans_desc != NULL); |
| 2764 video_trans_desc = offer->GetTransportDescriptionByName("video"); | 2890 video_trans_desc = offer->GetTransportDescriptionByName("video"); |
| 2765 ASSERT_TRUE(video_trans_desc != NULL); | 2891 ASSERT_TRUE(video_trans_desc != NULL); |
| 2766 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); | 2892 ASSERT_TRUE(audio_trans_desc->identity_fingerprint.get() != NULL); |
| 2767 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); | 2893 ASSERT_TRUE(video_trans_desc->identity_fingerprint.get() != NULL); |
| 2768 } | 2894 } |
| 2769 | 2895 |
| 2770 // Test that an answer can't be created if cryptos are required but the offer is | 2896 // Test that an answer can't be created if cryptos are required but the offer is |
| 2771 // unsecure. | 2897 // unsecure. |
| 2772 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { | 2898 TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) { |
| 2773 MediaSessionOptions options; | 2899 MediaSessionOptions options = CreatePlanBMediaSessionOptions(); |
| 2774 f1_.set_secure(SEC_DISABLED); | 2900 f1_.set_secure(SEC_DISABLED); |
| 2775 tdf1_.set_secure(SEC_DISABLED); | 2901 tdf1_.set_secure(SEC_DISABLED); |
| 2776 f2_.set_secure(SEC_REQUIRED); | 2902 f2_.set_secure(SEC_REQUIRED); |
| 2777 tdf1_.set_secure(SEC_ENABLED); | 2903 tdf1_.set_secure(SEC_ENABLED); |
| 2778 | 2904 |
| 2779 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2905 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); |
| 2780 ASSERT_TRUE(offer.get() != NULL); | 2906 ASSERT_TRUE(offer.get() != NULL); |
| 2781 std::unique_ptr<SessionDescription> answer( | 2907 std::unique_ptr<SessionDescription> answer( |
| 2782 f2_.CreateAnswer(offer.get(), options, NULL)); | 2908 f2_.CreateAnswer(offer.get(), options, NULL)); |
| 2783 EXPECT_TRUE(answer.get() == NULL); | 2909 EXPECT_TRUE(answer.get() == NULL); |
| 2784 } | 2910 } |
| 2785 | 2911 |
| 2786 // Test that we accept a DTLS offer without SDES and create an appropriate | 2912 // Test that we accept a DTLS offer without SDES and create an appropriate |
| 2787 // answer. | 2913 // answer. |
| 2788 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { | 2914 TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) { |
| 2789 f1_.set_secure(SEC_DISABLED); | 2915 f1_.set_secure(SEC_DISABLED); |
| 2790 f2_.set_secure(SEC_ENABLED); | 2916 f2_.set_secure(SEC_ENABLED); |
| 2791 tdf1_.set_secure(SEC_ENABLED); | 2917 tdf1_.set_secure(SEC_ENABLED); |
| 2792 tdf2_.set_secure(SEC_ENABLED); | 2918 tdf2_.set_secure(SEC_ENABLED); |
| 2793 MediaSessionOptions options; | 2919 MediaSessionOptions options; |
| 2794 options.recv_audio = true; | 2920 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2795 options.recv_video = true; | 2921 AddDataSection(cricket::DCT_RTP, cricket::MD_RECVONLY, &options); |
| 2796 options.data_channel_type = cricket::DCT_RTP; | |
| 2797 | 2922 |
| 2798 std::unique_ptr<SessionDescription> offer, answer; | 2923 std::unique_ptr<SessionDescription> offer, answer; |
| 2799 | 2924 |
| 2800 // Generate an offer with DTLS but without SDES. | 2925 // Generate an offer with DTLS but without SDES. |
| 2801 offer.reset(f1_.CreateOffer(options, NULL)); | 2926 offer.reset(f1_.CreateOffer(options, NULL)); |
| 2802 ASSERT_TRUE(offer.get() != NULL); | 2927 ASSERT_TRUE(offer.get() != NULL); |
| 2803 | 2928 |
| 2804 const AudioContentDescription* audio_offer = | 2929 const AudioContentDescription* audio_offer = |
| 2805 GetFirstAudioContentDescription(offer.get()); | 2930 GetFirstAudioContentDescription(offer.get()); |
| 2806 ASSERT_TRUE(audio_offer->cryptos().empty()); | 2931 ASSERT_TRUE(audio_offer->cryptos().empty()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2833 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != NULL); | 2958 EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get() != NULL); |
| 2834 const cricket::TransportDescription* data_answer_trans_desc = | 2959 const cricket::TransportDescription* data_answer_trans_desc = |
| 2835 answer->GetTransportDescriptionByName("data"); | 2960 answer->GetTransportDescriptionByName("data"); |
| 2836 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); | 2961 EXPECT_TRUE(data_answer_trans_desc->identity_fingerprint.get() != NULL); |
| 2837 } | 2962 } |
| 2838 | 2963 |
| 2839 // Verifies if vad_enabled option is set to false, CN codecs are not present in | 2964 // Verifies if vad_enabled option is set to false, CN codecs are not present in |
| 2840 // offer or answer. | 2965 // offer or answer. |
| 2841 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { | 2966 TEST_F(MediaSessionDescriptionFactoryTest, TestVADEnableOption) { |
| 2842 MediaSessionOptions options; | 2967 MediaSessionOptions options; |
| 2843 options.recv_audio = true; | 2968 AddAudioVideoSections(cricket::MD_RECVONLY, &options); |
| 2844 options.recv_video = true; | |
| 2845 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); | 2969 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(options, NULL)); |
| 2846 ASSERT_TRUE(offer.get() != NULL); | 2970 ASSERT_TRUE(offer.get() != NULL); |
| 2847 const ContentInfo* audio_content = offer->GetContentByName("audio"); | 2971 const ContentInfo* audio_content = offer->GetContentByName("audio"); |
| 2848 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); | 2972 EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); |
| 2849 | 2973 |
| 2850 options.vad_enabled = false; | 2974 options.vad_enabled = false; |
| 2851 offer.reset(f1_.CreateOffer(options, NULL)); | 2975 offer.reset(f1_.CreateOffer(options, NULL)); |
| 2852 ASSERT_TRUE(offer.get() != NULL); | 2976 ASSERT_TRUE(offer.get() != NULL); |
| 2853 audio_content = offer->GetContentByName("audio"); | 2977 audio_content = offer->GetContentByName("audio"); |
| 2854 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2978 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
| 2855 std::unique_ptr<SessionDescription> answer( | 2979 std::unique_ptr<SessionDescription> answer( |
| 2856 f1_.CreateAnswer(offer.get(), options, NULL)); | 2980 f1_.CreateAnswer(offer.get(), options, NULL)); |
| 2857 ASSERT_TRUE(answer.get() != NULL); | 2981 ASSERT_TRUE(answer.get() != NULL); |
| 2858 audio_content = answer->GetContentByName("audio"); | 2982 audio_content = answer->GetContentByName("audio"); |
| 2859 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); | 2983 EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
| 2860 } | 2984 } |
| 2861 | 2985 |
| 2862 // Test that the content name ("mid" in SDP) is unchanged when creating a | 2986 // Test that the generated MIDs match the existing offer. |
| 2863 // new offer. | 2987 TEST_F(MediaSessionDescriptionFactoryTest, TestMIDsMatchesExistingOffer) { |
| 2864 TEST_F(MediaSessionDescriptionFactoryTest, | |
| 2865 TestContentNameNotChangedInSubsequentOffers) { | |
| 2866 MediaSessionOptions opts; | 2988 MediaSessionOptions opts; |
| 2867 opts.recv_audio = true; | 2989 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_modified", cricket::MD_RECVONLY, |
| 2868 opts.recv_video = true; | 2990 kActive, &opts); |
| 2991 AddMediaSection(MEDIA_TYPE_VIDEO, "video_modified", cricket::MD_RECVONLY, |
| 2992 kActive, &opts); |
| 2869 opts.data_channel_type = cricket::DCT_SCTP; | 2993 opts.data_channel_type = cricket::DCT_SCTP; |
| 2870 // Create offer and modify the default content names. | 2994 AddMediaSection(MEDIA_TYPE_DATA, "data_modified", cricket::MD_SENDRECV, |
| 2995 kActive, &opts); |
| 2996 // Create offer. |
| 2871 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 2997 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2872 for (ContentInfo& content : offer->contents()) { | |
| 2873 content.name.append("_modified"); | |
| 2874 } | |
| 2875 | |
| 2876 std::unique_ptr<SessionDescription> updated_offer( | 2998 std::unique_ptr<SessionDescription> updated_offer( |
| 2877 f1_.CreateOffer(opts, offer.get())); | 2999 f1_.CreateOffer(opts, offer.get())); |
| 3000 |
| 2878 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); | 3001 const ContentInfo* audio_content = GetFirstAudioContent(updated_offer.get()); |
| 2879 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); | 3002 const ContentInfo* video_content = GetFirstVideoContent(updated_offer.get()); |
| 2880 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); | 3003 const ContentInfo* data_content = GetFirstDataContent(updated_offer.get()); |
| 2881 ASSERT_TRUE(audio_content != nullptr); | 3004 ASSERT_TRUE(audio_content != nullptr); |
| 2882 ASSERT_TRUE(video_content != nullptr); | 3005 ASSERT_TRUE(video_content != nullptr); |
| 2883 ASSERT_TRUE(data_content != nullptr); | 3006 ASSERT_TRUE(data_content != nullptr); |
| 2884 EXPECT_EQ("audio_modified", audio_content->name); | 3007 EXPECT_EQ("audio_modified", audio_content->name); |
| 2885 EXPECT_EQ("video_modified", video_content->name); | 3008 EXPECT_EQ("video_modified", video_content->name); |
| 2886 EXPECT_EQ("data_modified", data_content->name); | 3009 EXPECT_EQ("data_modified", data_content->name); |
| 2887 } | 3010 } |
| 2888 | 3011 |
| 3012 // The following tests verify that the unified plan SDP is supported. |
| 3013 // Test that we can create an offer with multiple media sections of same media |
| 3014 // type. |
| 3015 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3016 CreateOfferWithMultipleAVMediaSections) { |
| 3017 MediaSessionOptions opts; |
| 3018 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_1", cricket::MD_SENDRECV, kActive, |
| 3019 &opts); |
| 3020 AttachSenderToMediaSection("audio_1", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 3021 kMediaStream1, 1, &opts); |
| 3022 |
| 3023 AddMediaSection(MEDIA_TYPE_VIDEO, "video_1", cricket::MD_SENDRECV, kActive, |
| 3024 &opts); |
| 3025 AttachSenderToMediaSection("video_1", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 3026 kMediaStream1, 1, &opts); |
| 3027 |
| 3028 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_2", cricket::MD_SENDRECV, kActive, |
| 3029 &opts); |
| 3030 AttachSenderToMediaSection("audio_2", MEDIA_TYPE_AUDIO, kAudioTrack2, |
| 3031 kMediaStream2, 1, &opts); |
| 3032 |
| 3033 AddMediaSection(MEDIA_TYPE_VIDEO, "video_2", cricket::MD_SENDRECV, kActive, |
| 3034 &opts); |
| 3035 AttachSenderToMediaSection("video_2", MEDIA_TYPE_VIDEO, kVideoTrack2, |
| 3036 kMediaStream2, 1, &opts); |
| 3037 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3038 ASSERT_TRUE(offer); |
| 3039 |
| 3040 ASSERT_EQ(4u, offer->contents().size()); |
| 3041 EXPECT_FALSE(offer->contents()[0].rejected); |
| 3042 const AudioContentDescription* acd = |
| 3043 static_cast<const AudioContentDescription*>( |
| 3044 offer->contents()[0].description); |
| 3045 ASSERT_EQ(1u, acd->streams().size()); |
| 3046 EXPECT_EQ(kAudioTrack1, acd->streams()[0].id); |
| 3047 EXPECT_EQ(cricket::MD_SENDRECV, acd->direction()); |
| 3048 |
| 3049 EXPECT_FALSE(offer->contents()[1].rejected); |
| 3050 const VideoContentDescription* vcd = |
| 3051 static_cast<const VideoContentDescription*>( |
| 3052 offer->contents()[1].description); |
| 3053 ASSERT_EQ(1u, vcd->streams().size()); |
| 3054 EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id); |
| 3055 EXPECT_EQ(cricket::MD_SENDRECV, vcd->direction()); |
| 3056 |
| 3057 EXPECT_FALSE(offer->contents()[2].rejected); |
| 3058 acd = static_cast<const AudioContentDescription*>( |
| 3059 offer->contents()[2].description); |
| 3060 ASSERT_EQ(1u, acd->streams().size()); |
| 3061 EXPECT_EQ(kAudioTrack2, acd->streams()[0].id); |
| 3062 EXPECT_EQ(cricket::MD_SENDRECV, acd->direction()); |
| 3063 |
| 3064 EXPECT_FALSE(offer->contents()[3].rejected); |
| 3065 vcd = static_cast<const VideoContentDescription*>( |
| 3066 offer->contents()[3].description); |
| 3067 ASSERT_EQ(1u, vcd->streams().size()); |
| 3068 EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id); |
| 3069 EXPECT_EQ(cricket::MD_SENDRECV, vcd->direction()); |
| 3070 } |
| 3071 |
| 3072 // Test that we can create an answer with multiple media sections of same media |
| 3073 // type. |
| 3074 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3075 CreateAnswerWithMultipleAVMediaSections) { |
| 3076 MediaSessionOptions opts; |
| 3077 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_1", cricket::MD_SENDRECV, kActive, |
| 3078 &opts); |
| 3079 AttachSenderToMediaSection("audio_1", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 3080 kMediaStream1, 1, &opts); |
| 3081 |
| 3082 AddMediaSection(MEDIA_TYPE_VIDEO, "video_1", cricket::MD_SENDRECV, kActive, |
| 3083 &opts); |
| 3084 AttachSenderToMediaSection("video_1", MEDIA_TYPE_VIDEO, kVideoTrack1, |
| 3085 kMediaStream1, 1, &opts); |
| 3086 |
| 3087 AddMediaSection(MEDIA_TYPE_AUDIO, "audio_2", cricket::MD_SENDRECV, kActive, |
| 3088 &opts); |
| 3089 AttachSenderToMediaSection("audio_2", MEDIA_TYPE_AUDIO, kAudioTrack2, |
| 3090 kMediaStream2, 1, &opts); |
| 3091 |
| 3092 AddMediaSection(MEDIA_TYPE_VIDEO, "video_2", cricket::MD_SENDRECV, kActive, |
| 3093 &opts); |
| 3094 AttachSenderToMediaSection("video_2", MEDIA_TYPE_VIDEO, kVideoTrack2, |
| 3095 kMediaStream2, 1, &opts); |
| 3096 |
| 3097 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3098 ASSERT_TRUE(offer); |
| 3099 std::unique_ptr<SessionDescription> answer( |
| 3100 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 3101 |
| 3102 ASSERT_EQ(4u, answer->contents().size()); |
| 3103 EXPECT_FALSE(answer->contents()[0].rejected); |
| 3104 const AudioContentDescription* acd = |
| 3105 static_cast<const AudioContentDescription*>( |
| 3106 answer->contents()[0].description); |
| 3107 ASSERT_EQ(1u, acd->streams().size()); |
| 3108 EXPECT_EQ(kAudioTrack1, acd->streams()[0].id); |
| 3109 EXPECT_EQ(cricket::MD_SENDRECV, acd->direction()); |
| 3110 |
| 3111 EXPECT_FALSE(answer->contents()[1].rejected); |
| 3112 const VideoContentDescription* vcd = |
| 3113 static_cast<const VideoContentDescription*>( |
| 3114 answer->contents()[1].description); |
| 3115 ASSERT_EQ(1u, vcd->streams().size()); |
| 3116 EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id); |
| 3117 EXPECT_EQ(cricket::MD_SENDRECV, vcd->direction()); |
| 3118 |
| 3119 EXPECT_FALSE(answer->contents()[2].rejected); |
| 3120 acd = static_cast<const AudioContentDescription*>( |
| 3121 answer->contents()[2].description); |
| 3122 ASSERT_EQ(1u, acd->streams().size()); |
| 3123 EXPECT_EQ(kAudioTrack2, acd->streams()[0].id); |
| 3124 EXPECT_EQ(cricket::MD_SENDRECV, acd->direction()); |
| 3125 |
| 3126 EXPECT_FALSE(answer->contents()[3].rejected); |
| 3127 vcd = static_cast<const VideoContentDescription*>( |
| 3128 answer->contents()[3].description); |
| 3129 ASSERT_EQ(1u, vcd->streams().size()); |
| 3130 EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id); |
| 3131 EXPECT_EQ(cricket::MD_SENDRECV, vcd->direction()); |
| 3132 } |
| 3133 |
| 3134 // Test that the media section will be rejected in offer if the corresponding |
| 3135 // MediaDescriptionOptions is stopped by the offerer. |
| 3136 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3137 CreateOfferWithMediaSectionStoppedByOfferer) { |
| 3138 // Create an offer with two audio sections and one of them is stopped. |
| 3139 MediaSessionOptions offer_opts; |
| 3140 AddMediaSection(MEDIA_TYPE_AUDIO, "audio1", cricket::MD_SENDRECV, kActive, |
| 3141 &offer_opts); |
| 3142 AddMediaSection(MEDIA_TYPE_AUDIO, "audio2", cricket::MD_INACTIVE, kStopped, |
| 3143 &offer_opts); |
| 3144 std::unique_ptr<SessionDescription> offer( |
| 3145 f1_.CreateOffer(offer_opts, nullptr)); |
| 3146 ASSERT_TRUE(offer); |
| 3147 ASSERT_EQ(2u, offer->contents().size()); |
| 3148 EXPECT_FALSE(offer->contents()[0].rejected); |
| 3149 EXPECT_TRUE(offer->contents()[1].rejected); |
| 3150 } |
| 3151 |
| 3152 // Test that the media section will be rejected in answer if the corresponding |
| 3153 // MediaDescriptionOptions is stopped by the offerer. |
| 3154 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3155 CreateAnswerWithMediaSectionStoppedByOfferer) { |
| 3156 // Create an offer with two audio sections and one of them is stopped. |
| 3157 MediaSessionOptions offer_opts; |
| 3158 AddMediaSection(MEDIA_TYPE_AUDIO, "audio1", cricket::MD_SENDRECV, kActive, |
| 3159 &offer_opts); |
| 3160 AddMediaSection(MEDIA_TYPE_AUDIO, "audio2", cricket::MD_INACTIVE, kStopped, |
| 3161 &offer_opts); |
| 3162 std::unique_ptr<SessionDescription> offer( |
| 3163 f1_.CreateOffer(offer_opts, nullptr)); |
| 3164 ASSERT_TRUE(offer); |
| 3165 ASSERT_EQ(2u, offer->contents().size()); |
| 3166 EXPECT_FALSE(offer->contents()[0].rejected); |
| 3167 EXPECT_TRUE(offer->contents()[1].rejected); |
| 3168 |
| 3169 // Create an answer based on the offer. |
| 3170 MediaSessionOptions answer_opts; |
| 3171 AddMediaSection(MEDIA_TYPE_AUDIO, "audio1", cricket::MD_SENDRECV, kActive, |
| 3172 &answer_opts); |
| 3173 AddMediaSection(MEDIA_TYPE_AUDIO, "audio2", cricket::MD_SENDRECV, kActive, |
| 3174 &answer_opts); |
| 3175 std::unique_ptr<SessionDescription> answer( |
| 3176 f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
| 3177 ASSERT_EQ(2u, answer->contents().size()); |
| 3178 EXPECT_FALSE(answer->contents()[0].rejected); |
| 3179 EXPECT_TRUE(answer->contents()[1].rejected); |
| 3180 } |
| 3181 |
| 3182 // Test that the media section will be rejected in answer if the corresponding |
| 3183 // MediaDescriptionOptions is stopped by the answerer. |
| 3184 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3185 CreateAnswerWithMediaSectionRejectedByAnswerer) { |
| 3186 // Create an offer with two audio sections. |
| 3187 MediaSessionOptions offer_opts; |
| 3188 AddMediaSection(MEDIA_TYPE_AUDIO, "audio1", cricket::MD_SENDRECV, kActive, |
| 3189 &offer_opts); |
| 3190 AddMediaSection(MEDIA_TYPE_AUDIO, "audio2", cricket::MD_SENDRECV, kActive, |
| 3191 &offer_opts); |
| 3192 std::unique_ptr<SessionDescription> offer( |
| 3193 f1_.CreateOffer(offer_opts, nullptr)); |
| 3194 ASSERT_TRUE(offer); |
| 3195 ASSERT_EQ(2u, offer->contents().size()); |
| 3196 ASSERT_FALSE(offer->contents()[0].rejected); |
| 3197 ASSERT_FALSE(offer->contents()[1].rejected); |
| 3198 |
| 3199 // The answerer rejects one of the audio sections. |
| 3200 MediaSessionOptions answer_opts; |
| 3201 AddMediaSection(MEDIA_TYPE_AUDIO, "audio1", cricket::MD_SENDRECV, kActive, |
| 3202 &answer_opts); |
| 3203 AddMediaSection(MEDIA_TYPE_AUDIO, "audio2", cricket::MD_INACTIVE, kStopped, |
| 3204 &answer_opts); |
| 3205 std::unique_ptr<SessionDescription> answer( |
| 3206 f2_.CreateAnswer(offer.get(), answer_opts, nullptr)); |
| 3207 ASSERT_EQ(2u, answer->contents().size()); |
| 3208 EXPECT_FALSE(answer->contents()[0].rejected); |
| 3209 EXPECT_TRUE(answer->contents()[1].rejected); |
| 3210 } |
| 3211 |
| 3212 // Test the generated media sections has the same order of the |
| 3213 // corresponding MediaDescriptionOptions. |
| 3214 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3215 CreateOfferRespectsMediaDescriptionOptionsOrder) { |
| 3216 MediaSessionOptions opts; |
| 3217 // This tests put video section first because normally audio comes first by |
| 3218 // default. |
| 3219 AddMediaSection(MEDIA_TYPE_VIDEO, "video", cricket::MD_SENDRECV, kActive, |
| 3220 &opts); |
| 3221 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", cricket::MD_SENDRECV, kActive, |
| 3222 &opts); |
| 3223 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3224 |
| 3225 ASSERT_TRUE(offer); |
| 3226 ASSERT_EQ(2u, offer->contents().size()); |
| 3227 EXPECT_EQ("video", offer->contents()[0].name); |
| 3228 EXPECT_EQ("audio", offer->contents()[1].name); |
| 3229 } |
| 3230 |
| 3231 // Test that different media sections using the same codec have same payload |
| 3232 // type. |
| 3233 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3234 PayloadTypesSharedByMediaSectionsOfSameType) { |
| 3235 MediaSessionOptions opts; |
| 3236 AddMediaSection(MEDIA_TYPE_VIDEO, "video1", cricket::MD_SENDRECV, kActive, |
| 3237 &opts); |
| 3238 AddMediaSection(MEDIA_TYPE_VIDEO, "video2", cricket::MD_SENDRECV, kActive, |
| 3239 &opts); |
| 3240 // Create an offer with two video sections using same codecs. |
| 3241 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3242 ASSERT_TRUE(offer); |
| 3243 ASSERT_EQ(2u, offer->contents().size()); |
| 3244 const VideoContentDescription* vcd1 = |
| 3245 static_cast<const VideoContentDescription*>( |
| 3246 offer->contents()[0].description); |
| 3247 const VideoContentDescription* vcd2 = |
| 3248 static_cast<const VideoContentDescription*>( |
| 3249 offer->contents()[1].description); |
| 3250 EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size()); |
| 3251 ASSERT_EQ(2u, vcd1->codecs().size()); |
| 3252 EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name); |
| 3253 EXPECT_EQ(vcd1->codecs()[0].id, vcd2->codecs()[0].id); |
| 3254 EXPECT_EQ(vcd1->codecs()[1].name, vcd2->codecs()[1].name); |
| 3255 EXPECT_EQ(vcd1->codecs()[1].id, vcd2->codecs()[1].id); |
| 3256 |
| 3257 // Create answer and negotiate the codecs. |
| 3258 std::unique_ptr<SessionDescription> answer( |
| 3259 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 3260 ASSERT_TRUE(answer); |
| 3261 ASSERT_EQ(2u, answer->contents().size()); |
| 3262 vcd1 = static_cast<const VideoContentDescription*>( |
| 3263 answer->contents()[0].description); |
| 3264 vcd2 = static_cast<const VideoContentDescription*>( |
| 3265 answer->contents()[1].description); |
| 3266 EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size()); |
| 3267 ASSERT_EQ(1u, vcd1->codecs().size()); |
| 3268 EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name); |
| 3269 EXPECT_EQ(vcd1->codecs()[0].id, vcd2->codecs()[0].id); |
| 3270 } |
| 3271 |
| 3272 // Test that the codec preference order per media section is respected in |
| 3273 // subsequent offer. |
| 3274 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3275 CreateOfferRespectsCodecPreferenceOrder) { |
| 3276 MediaSessionOptions opts; |
| 3277 AddMediaSection(MEDIA_TYPE_VIDEO, "video1", cricket::MD_SENDRECV, kActive, |
| 3278 &opts); |
| 3279 AddMediaSection(MEDIA_TYPE_VIDEO, "video2", cricket::MD_SENDRECV, kActive, |
| 3280 &opts); |
| 3281 // Create an offer with two video sections using same codecs. |
| 3282 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3283 ASSERT_TRUE(offer); |
| 3284 ASSERT_EQ(2u, offer->contents().size()); |
| 3285 VideoContentDescription* vcd1 = |
| 3286 static_cast<VideoContentDescription*>(offer->contents()[0].description); |
| 3287 const VideoContentDescription* vcd2 = |
| 3288 static_cast<const VideoContentDescription*>( |
| 3289 offer->contents()[1].description); |
| 3290 auto video_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 3291 EXPECT_EQ(video_codecs, vcd1->codecs()); |
| 3292 EXPECT_EQ(video_codecs, vcd2->codecs()); |
| 3293 |
| 3294 // Change the codec preference of the first video section and create a |
| 3295 // follow-up offer. |
| 3296 auto video_codecs_reverse = MAKE_VECTOR(kVideoCodecs1Reverse); |
| 3297 vcd1->set_codecs(video_codecs_reverse); |
| 3298 std::unique_ptr<SessionDescription> updated_offer( |
| 3299 f1_.CreateOffer(opts, offer.get())); |
| 3300 vcd1 = static_cast<VideoContentDescription*>( |
| 3301 updated_offer->contents()[0].description); |
| 3302 vcd2 = static_cast<const VideoContentDescription*>( |
| 3303 updated_offer->contents()[1].description); |
| 3304 // The video codec preference order should be respected. |
| 3305 EXPECT_EQ(video_codecs_reverse, vcd1->codecs()); |
| 3306 EXPECT_EQ(video_codecs, vcd2->codecs()); |
| 3307 } |
| 3308 |
| 3309 // Test that the codec preference order per media section is respected in |
| 3310 // the answer. |
| 3311 TEST_F(MediaSessionDescriptionFactoryTest, |
| 3312 CreateAnswerRespectsCodecPreferenceOrder) { |
| 3313 MediaSessionOptions opts; |
| 3314 AddMediaSection(MEDIA_TYPE_VIDEO, "video1", cricket::MD_SENDRECV, kActive, |
| 3315 &opts); |
| 3316 AddMediaSection(MEDIA_TYPE_VIDEO, "video2", cricket::MD_SENDRECV, kActive, |
| 3317 &opts); |
| 3318 // Create an offer with two video sections using same codecs. |
| 3319 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 3320 ASSERT_TRUE(offer); |
| 3321 ASSERT_EQ(2u, offer->contents().size()); |
| 3322 VideoContentDescription* vcd1 = |
| 3323 static_cast<VideoContentDescription*>(offer->contents()[0].description); |
| 3324 const VideoContentDescription* vcd2 = |
| 3325 static_cast<const VideoContentDescription*>( |
| 3326 offer->contents()[1].description); |
| 3327 auto video_codecs = MAKE_VECTOR(kVideoCodecs1); |
| 3328 EXPECT_EQ(video_codecs, vcd1->codecs()); |
| 3329 EXPECT_EQ(video_codecs, vcd2->codecs()); |
| 3330 |
| 3331 // Change the codec preference of the first video section and create an |
| 3332 // answer. |
| 3333 auto video_codecs_reverse = MAKE_VECTOR(kVideoCodecs1Reverse); |
| 3334 vcd1->set_codecs(video_codecs_reverse); |
| 3335 std::unique_ptr<SessionDescription> answer( |
| 3336 f1_.CreateAnswer(offer.get(), opts, nullptr)); |
| 3337 vcd1 = |
| 3338 static_cast<VideoContentDescription*>(answer->contents()[0].description); |
| 3339 vcd2 = static_cast<const VideoContentDescription*>( |
| 3340 answer->contents()[1].description); |
| 3341 // The video codec preference order should be respected. |
| 3342 EXPECT_EQ(video_codecs_reverse, vcd1->codecs()); |
| 3343 EXPECT_EQ(video_codecs, vcd2->codecs()); |
| 3344 } |
| 3345 |
| 2889 class MediaProtocolTest : public ::testing::TestWithParam<const char*> { | 3346 class MediaProtocolTest : public ::testing::TestWithParam<const char*> { |
| 2890 public: | 3347 public: |
| 2891 MediaProtocolTest() : f1_(&tdf1_), f2_(&tdf2_) { | 3348 MediaProtocolTest() : f1_(&tdf1_), f2_(&tdf2_) { |
| 2892 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), | 3349 f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), |
| 2893 MAKE_VECTOR(kAudioCodecs1)); | 3350 MAKE_VECTOR(kAudioCodecs1)); |
| 2894 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); | 3351 f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1)); |
| 2895 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); | 3352 f1_.set_data_codecs(MAKE_VECTOR(kDataCodecs1)); |
| 2896 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), | 3353 f2_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs2), |
| 2897 MAKE_VECTOR(kAudioCodecs2)); | 3354 MAKE_VECTOR(kAudioCodecs2)); |
| 2898 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); | 3355 f2_.set_video_codecs(MAKE_VECTOR(kVideoCodecs2)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2909 | 3366 |
| 2910 protected: | 3367 protected: |
| 2911 MediaSessionDescriptionFactory f1_; | 3368 MediaSessionDescriptionFactory f1_; |
| 2912 MediaSessionDescriptionFactory f2_; | 3369 MediaSessionDescriptionFactory f2_; |
| 2913 TransportDescriptionFactory tdf1_; | 3370 TransportDescriptionFactory tdf1_; |
| 2914 TransportDescriptionFactory tdf2_; | 3371 TransportDescriptionFactory tdf2_; |
| 2915 }; | 3372 }; |
| 2916 | 3373 |
| 2917 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { | 3374 TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) { |
| 2918 MediaSessionOptions opts; | 3375 MediaSessionOptions opts; |
| 2919 opts.recv_video = true; | 3376 AddAudioVideoSections(cricket::MD_RECVONLY, &opts); |
| 2920 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); | 3377 std::unique_ptr<SessionDescription> offer(f1_.CreateOffer(opts, nullptr)); |
| 2921 ASSERT_TRUE(offer.get() != nullptr); | 3378 ASSERT_TRUE(offer.get() != nullptr); |
| 2922 // Set the protocol for all the contents. | 3379 // Set the protocol for all the contents. |
| 2923 for (auto content : offer.get()->contents()) { | 3380 for (auto content : offer.get()->contents()) { |
| 2924 static_cast<MediaContentDescription*>(content.description) | 3381 static_cast<MediaContentDescription*>(content.description) |
| 2925 ->set_protocol(GetParam()); | 3382 ->set_protocol(GetParam()); |
| 2926 } | 3383 } |
| 2927 std::unique_ptr<SessionDescription> answer( | 3384 std::unique_ptr<SessionDescription> answer( |
| 2928 f2_.CreateAnswer(offer.get(), opts, nullptr)); | 3385 f2_.CreateAnswer(offer.get(), opts, nullptr)); |
| 2929 const ContentInfo* ac = answer->GetContentByName("audio"); | 3386 const ContentInfo* ac = answer->GetContentByName("audio"); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 // Alter iLBC send codec to have zero channels, to test that that is handled | 3426 // Alter iLBC send codec to have zero channels, to test that that is handled |
| 2970 // properly. | 3427 // properly. |
| 2971 send_codecs[1].channels = 0; | 3428 send_codecs[1].channels = 0; |
| 2972 | 3429 |
| 2973 // Alther iLBC receive codec to be lowercase, to test that case conversions | 3430 // Alther iLBC receive codec to be lowercase, to test that case conversions |
| 2974 // are handled properly. | 3431 // are handled properly. |
| 2975 recv_codecs[2].name = "ilbc"; | 3432 recv_codecs[2].name = "ilbc"; |
| 2976 | 3433 |
| 2977 // Test proper merge | 3434 // Test proper merge |
| 2978 sf.set_audio_codecs(send_codecs, recv_codecs); | 3435 sf.set_audio_codecs(send_codecs, recv_codecs); |
| 2979 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 3436 EXPECT_EQ(send_codecs, sf.audio_send_codecs()); |
| 2980 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 3437 EXPECT_EQ(recv_codecs, sf.audio_recv_codecs()); |
| 2981 EXPECT_TRUE(sf.audio_sendrecv_codecs() == sendrecv_codecs); | 3438 EXPECT_EQ(sendrecv_codecs, sf.audio_sendrecv_codecs()); |
| 2982 | 3439 |
| 2983 // Test empty send codecs list | 3440 // Test empty send codecs list |
| 2984 sf.set_audio_codecs(no_codecs, recv_codecs); | 3441 sf.set_audio_codecs(no_codecs, recv_codecs); |
| 2985 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 3442 EXPECT_EQ(no_codecs, sf.audio_send_codecs()); |
| 2986 EXPECT_TRUE(sf.audio_recv_codecs() == recv_codecs); | 3443 EXPECT_EQ(recv_codecs, sf.audio_recv_codecs()); |
| 2987 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3444 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
| 2988 | 3445 |
| 2989 // Test empty recv codecs list | 3446 // Test empty recv codecs list |
| 2990 sf.set_audio_codecs(send_codecs, no_codecs); | 3447 sf.set_audio_codecs(send_codecs, no_codecs); |
| 2991 EXPECT_TRUE(sf.audio_send_codecs() == send_codecs); | 3448 EXPECT_EQ(send_codecs, sf.audio_send_codecs()); |
| 2992 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 3449 EXPECT_EQ(no_codecs, sf.audio_recv_codecs()); |
| 2993 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3450 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
| 2994 | 3451 |
| 2995 // Test all empty codec lists | 3452 // Test all empty codec lists |
| 2996 sf.set_audio_codecs(no_codecs, no_codecs); | 3453 sf.set_audio_codecs(no_codecs, no_codecs); |
| 2997 EXPECT_TRUE(sf.audio_send_codecs() == no_codecs); | 3454 EXPECT_EQ(no_codecs, sf.audio_send_codecs()); |
| 2998 EXPECT_TRUE(sf.audio_recv_codecs() == no_codecs); | 3455 EXPECT_EQ(no_codecs, sf.audio_recv_codecs()); |
| 2999 EXPECT_TRUE(sf.audio_sendrecv_codecs() == no_codecs); | 3456 EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs()); |
| 3000 } | 3457 } |
| 3001 | 3458 |
| 3002 namespace { | 3459 namespace { |
| 3003 void TestAudioCodecsOffer(MediaContentDirection direction, | 3460 // Compare the two vectors of codecs ignoring the payload type. |
| 3004 bool add_legacy_stream) { | 3461 template <class Codec> |
| 3462 bool CodecsMatch(const std::vector<Codec>& codecs1, |
| 3463 const std::vector<Codec>& codecs2) { |
| 3464 if (codecs1.size() != codecs2.size()) { |
| 3465 return false; |
| 3466 } |
| 3467 |
| 3468 for (size_t i = 0; i < codecs1.size(); ++i) { |
| 3469 if (!codecs1[i].Matches(codecs2[i])) { |
| 3470 return false; |
| 3471 } |
| 3472 } |
| 3473 return true; |
| 3474 } |
| 3475 |
| 3476 void TestAudioCodecsOffer(MediaContentDirection direction) { |
| 3005 TransportDescriptionFactory tdf; | 3477 TransportDescriptionFactory tdf; |
| 3006 MediaSessionDescriptionFactory sf(&tdf); | 3478 MediaSessionDescriptionFactory sf(&tdf); |
| 3007 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); | 3479 const std::vector<AudioCodec> send_codecs = MAKE_VECTOR(kAudioCodecs1); |
| 3008 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); | 3480 const std::vector<AudioCodec> recv_codecs = MAKE_VECTOR(kAudioCodecs2); |
| 3009 const std::vector<AudioCodec> sendrecv_codecs = | 3481 const std::vector<AudioCodec> sendrecv_codecs = |
| 3010 MAKE_VECTOR(kAudioCodecsAnswer); | 3482 MAKE_VECTOR(kAudioCodecsAnswer); |
| 3011 sf.set_audio_codecs(send_codecs, recv_codecs); | 3483 sf.set_audio_codecs(send_codecs, recv_codecs); |
| 3012 sf.set_add_legacy_streams(add_legacy_stream); | |
| 3013 | 3484 |
| 3014 MediaSessionOptions opts; | 3485 MediaSessionOptions opts; |
| 3015 opts.recv_audio = (direction == cricket::MD_RECVONLY || | 3486 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, kActive, &opts); |
| 3016 direction == cricket::MD_SENDRECV); | 3487 |
| 3017 opts.recv_video = false; | 3488 if (RtpTransceiverDirection::FromMediaContentDirection(direction).send) { |
| 3018 if (direction == cricket::MD_SENDONLY || direction == cricket::MD_SENDRECV) | 3489 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 3019 opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3490 kMediaStream1, 1, &opts); |
| 3491 } |
| 3020 | 3492 |
| 3021 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, NULL)); | 3493 std::unique_ptr<SessionDescription> offer(sf.CreateOffer(opts, NULL)); |
| 3022 ASSERT_TRUE(offer.get() != NULL); | 3494 ASSERT_TRUE(offer.get() != NULL); |
| 3023 const ContentInfo* ac = offer->GetContentByName("audio"); | 3495 const ContentInfo* ac = offer->GetContentByName("audio"); |
| 3024 | 3496 |
| 3025 // If the factory didn't add any audio content to the offer, we cannot check | 3497 // If the factory didn't add any audio content to the offer, we cannot check |
| 3026 // that the codecs put in are right. This happens when we neither want to send | 3498 // that the codecs put in are right. This happens when we neither want to |
| 3027 // nor receive audio. The checks are still in place if at some point we'd | 3499 // send nor receive audio. The checks are still in place if at some point |
| 3028 // instead create an inactive stream. | 3500 // we'd instead create an inactive stream. |
| 3029 if (ac) { | 3501 if (ac) { |
| 3030 AudioContentDescription* acd = | 3502 AudioContentDescription* acd = |
| 3031 static_cast<AudioContentDescription*>(ac->description); | 3503 static_cast<AudioContentDescription*>(ac->description); |
| 3032 // sendrecv and inactive should both present lists as if the channel was to | 3504 // sendrecv and inactive should both present lists as if the channel was |
| 3033 // be used for sending and receiving. Inactive essentially means it might | 3505 // to be used for sending and receiving. Inactive essentially means it |
| 3034 // eventually be used anything, but we don't know more at this moment. | 3506 // might eventually be used anything, but we don't know more at this |
| 3507 // moment. |
| 3035 if (acd->direction() == cricket::MD_SENDONLY) { | 3508 if (acd->direction() == cricket::MD_SENDONLY) { |
| 3036 EXPECT_TRUE(acd->codecs() == send_codecs); | 3509 EXPECT_TRUE(CodecsMatch<AudioCodec>(send_codecs, acd->codecs())); |
| 3037 } else if (acd->direction() == cricket::MD_RECVONLY) { | 3510 } else if (acd->direction() == cricket::MD_RECVONLY) { |
| 3038 EXPECT_TRUE(acd->codecs() == recv_codecs); | 3511 EXPECT_TRUE(CodecsMatch<AudioCodec>(recv_codecs, acd->codecs())); |
| 3039 } else { | 3512 } else { |
| 3040 EXPECT_TRUE(acd->codecs() == sendrecv_codecs); | 3513 EXPECT_TRUE(CodecsMatch<AudioCodec>(sendrecv_codecs, acd->codecs())); |
| 3041 } | 3514 } |
| 3042 } | 3515 } |
| 3043 } | 3516 } |
| 3044 | 3517 |
| 3045 static const AudioCodec kOfferAnswerCodecs[] = { | 3518 static const AudioCodec kOfferAnswerCodecs[] = { |
| 3046 AudioCodec(0, "codec0", 16000, -1, 1), | 3519 AudioCodec(0, "codec0", 16000, -1, 1), |
| 3047 AudioCodec(1, "codec1", 8000, 13300, 1), | 3520 AudioCodec(1, "codec1", 8000, 13300, 1), |
| 3048 AudioCodec(2, "codec2", 8000, 64000, 1), | 3521 AudioCodec(2, "codec2", 8000, 64000, 1), |
| 3049 AudioCodec(3, "codec3", 8000, 64000, 1), | 3522 AudioCodec(3, "codec3", 8000, 64000, 1), |
| 3050 AudioCodec(4, "codec4", 8000, 0, 2), | 3523 AudioCodec(4, "codec4", 8000, 0, 2), |
| 3051 AudioCodec(5, "codec5", 32000, 0, 1), | 3524 AudioCodec(5, "codec5", 32000, 0, 1), |
| 3052 AudioCodec(6, "codec6", 48000, 0, 1) | 3525 AudioCodec(6, "codec6", 48000, 0, 1)}; |
| 3053 }; | |
| 3054 | 3526 |
| 3055 | 3527 /* The codecs groups below are chosen as per the matrix below. The objective |
| 3056 /* The codecs groups below are chosen as per the matrix below. The objective is | 3528 * is to have different sets of codecs in the inputs, to get unique sets of |
| 3057 * to have different sets of codecs in the inputs, to get unique sets of codecs | 3529 * codecs after negotiation, depending on offer and answer communication |
| 3058 * after negotiation, depending on offer and answer communication directions. | 3530 * directions. One-way directions in the offer should either result in the |
| 3059 * One-way directions in the offer should either result in the opposite | 3531 * opposite direction in the answer, or an inactive answer. Regardless, the |
| 3060 * direction in the answer, or an inactive answer. Regardless, the choice of | 3532 * choice of codecs should be as if the answer contained the opposite |
| 3061 * codecs should be as if the answer contained the opposite direction. | 3533 * direction. Inactive offers should be treated as sendrecv/sendrecv. |
| 3062 * Inactive offers should be treated as sendrecv/sendrecv. | |
| 3063 * | 3534 * |
| 3064 * | Offer | Answer | Result | 3535 * | Offer | Answer | Result |
| 3065 * codec|send recv sr | send recv sr | s/r r/s sr/s sr/r sr/sr | 3536 * codec|send recv sr | send recv sr | s/r r/s sr/s sr/r sr/sr |
| 3066 * 0 | x - - | - x - | x - - - - | 3537 * 0 | x - - | - x - | x - - - - |
| 3067 * 1 | x x x | - x - | x - - x - | 3538 * 1 | x x x | - x - | x - - x - |
| 3068 * 2 | - x - | x - - | - x - - - | 3539 * 2 | - x - | x - - | - x - - - |
| 3069 * 3 | x x x | x - - | - x x - - | 3540 * 3 | x x x | x - - | - x x - - |
| 3070 * 4 | - x - | x x x | - x - - - | 3541 * 4 | - x - | x x x | - x - - - |
| 3071 * 5 | x - - | x x x | x - - - - | 3542 * 5 | x - - | x x x | x - - - - |
| 3072 * 6 | x x x | x x x | x x x x x | 3543 * 6 | x x x | x x x | x x x x x |
| 3073 */ | 3544 */ |
| 3074 // Codecs used by offerer in the AudioCodecsAnswerTest | 3545 // Codecs used by offerer in the AudioCodecsAnswerTest |
| 3075 static const int kOfferSendCodecs[] = { 0, 1, 3, 5, 6 }; | 3546 static const int kOfferSendCodecs[] = {0, 1, 3, 5, 6}; |
| 3076 static const int kOfferRecvCodecs[] = { 1, 2, 3, 4, 6 }; | 3547 static const int kOfferRecvCodecs[] = {1, 2, 3, 4, 6}; |
| 3077 // Codecs used in the answerer in the AudioCodecsAnswerTest. The order is | 3548 // Codecs used in the answerer in the AudioCodecsAnswerTest. The order is |
| 3078 // jumbled to catch the answer not following the order in the offer. | 3549 // jumbled to catch the answer not following the order in the offer. |
| 3079 static const int kAnswerSendCodecs[] = { 6, 5, 2, 3, 4 }; | 3550 static const int kAnswerSendCodecs[] = {6, 5, 2, 3, 4}; |
| 3080 static const int kAnswerRecvCodecs[] = { 6, 5, 4, 1, 0 }; | 3551 static const int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0}; |
| 3081 // The resulting sets of codecs in the answer in the AudioCodecsAnswerTest | 3552 // The resulting sets of codecs in the answer in the AudioCodecsAnswerTest |
| 3082 static const int kResultSend_RecvCodecs[] = { 0, 1, 5, 6 }; | 3553 static const int kResultSend_RecvCodecs[] = {0, 1, 5, 6}; |
| 3083 static const int kResultRecv_SendCodecs[] = { 2, 3, 4, 6 }; | 3554 static const int kResultRecv_SendCodecs[] = {2, 3, 4, 6}; |
| 3084 static const int kResultSendrecv_SendCodecs[] = { 3, 6 }; | 3555 static const int kResultSendrecv_SendCodecs[] = {3, 6}; |
| 3085 static const int kResultSendrecv_RecvCodecs[] = { 1, 6 }; | 3556 static const int kResultSendrecv_RecvCodecs[] = {1, 6}; |
| 3086 static const int kResultSendrecv_SendrecvCodecs[] = { 6 }; | 3557 static const int kResultSendrecv_SendrecvCodecs[] = {6}; |
| 3087 | 3558 |
| 3088 template <typename T, int IDXS> | 3559 template <typename T, int IDXS> |
| 3089 std::vector<T> VectorFromIndices(const T* array, const int (&indices)[IDXS]) { | 3560 std::vector<T> VectorFromIndices(const T* array, const int (&indices)[IDXS]) { |
| 3090 std::vector<T> out; | 3561 std::vector<T> out; |
| 3091 out.reserve(IDXS); | 3562 out.reserve(IDXS); |
| 3092 for (int idx : indices) | 3563 for (int idx : indices) |
| 3093 out.push_back(array[idx]); | 3564 out.push_back(array[idx]); |
| 3094 | 3565 |
| 3095 return out; | 3566 return out; |
| 3096 } | 3567 } |
| 3097 | 3568 |
| 3098 void TestAudioCodecsAnswer(MediaContentDirection offer_direction, | 3569 void TestAudioCodecsAnswer(MediaContentDirection offer_direction, |
| 3099 MediaContentDirection answer_direction, | 3570 MediaContentDirection answer_direction, |
| 3100 bool add_legacy_stream) { | 3571 bool add_legacy_stream) { |
| 3101 TransportDescriptionFactory offer_tdf; | 3572 TransportDescriptionFactory offer_tdf; |
| 3102 TransportDescriptionFactory answer_tdf; | 3573 TransportDescriptionFactory answer_tdf; |
| 3103 MediaSessionDescriptionFactory offer_factory(&offer_tdf); | 3574 MediaSessionDescriptionFactory offer_factory(&offer_tdf); |
| 3104 MediaSessionDescriptionFactory answer_factory(&answer_tdf); | 3575 MediaSessionDescriptionFactory answer_factory(&answer_tdf); |
| 3105 offer_factory.set_audio_codecs( | 3576 offer_factory.set_audio_codecs( |
| 3106 VectorFromIndices(kOfferAnswerCodecs, kOfferSendCodecs), | 3577 VectorFromIndices(kOfferAnswerCodecs, kOfferSendCodecs), |
| 3107 VectorFromIndices(kOfferAnswerCodecs, kOfferRecvCodecs)); | 3578 VectorFromIndices(kOfferAnswerCodecs, kOfferRecvCodecs)); |
| 3108 answer_factory.set_audio_codecs( | 3579 answer_factory.set_audio_codecs( |
| 3109 VectorFromIndices(kOfferAnswerCodecs, kAnswerSendCodecs), | 3580 VectorFromIndices(kOfferAnswerCodecs, kAnswerSendCodecs), |
| 3110 VectorFromIndices(kOfferAnswerCodecs, kAnswerRecvCodecs)); | 3581 VectorFromIndices(kOfferAnswerCodecs, kAnswerRecvCodecs)); |
| 3111 | 3582 |
| 3112 // Never add a legacy stream to offer - we want to control the offer | |
| 3113 // parameters exactly. | |
| 3114 offer_factory.set_add_legacy_streams(false); | |
| 3115 answer_factory.set_add_legacy_streams(add_legacy_stream); | |
| 3116 MediaSessionOptions offer_opts; | 3583 MediaSessionOptions offer_opts; |
| 3117 offer_opts.recv_audio = (offer_direction == cricket::MD_RECVONLY || | 3584 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", offer_direction, kActive, |
| 3118 offer_direction == cricket::MD_SENDRECV); | 3585 &offer_opts); |
| 3119 offer_opts.recv_video = false; | 3586 |
| 3120 if (offer_direction == cricket::MD_SENDONLY || | 3587 if (RtpTransceiverDirection::FromMediaContentDirection(offer_direction) |
| 3121 offer_direction == cricket::MD_SENDRECV) { | 3588 .send) { |
| 3122 offer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3589 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 3590 kMediaStream1, 1, &offer_opts); |
| 3123 } | 3591 } |
| 3124 | 3592 |
| 3125 std::unique_ptr<SessionDescription> offer( | 3593 std::unique_ptr<SessionDescription> offer( |
| 3126 offer_factory.CreateOffer(offer_opts, NULL)); | 3594 offer_factory.CreateOffer(offer_opts, NULL)); |
| 3127 ASSERT_TRUE(offer.get() != NULL); | 3595 ASSERT_TRUE(offer.get() != NULL); |
| 3128 | 3596 |
| 3129 MediaSessionOptions answer_opts; | 3597 MediaSessionOptions answer_opts; |
| 3130 answer_opts.recv_audio = (answer_direction == cricket::MD_RECVONLY || | 3598 AddMediaSection(MEDIA_TYPE_AUDIO, "audio", answer_direction, kActive, |
| 3131 answer_direction == cricket::MD_SENDRECV); | 3599 &answer_opts); |
| 3132 answer_opts.recv_video = false; | 3600 |
| 3133 if (answer_direction == cricket::MD_SENDONLY || | 3601 if (RtpTransceiverDirection::FromMediaContentDirection(answer_direction) |
| 3134 answer_direction == cricket::MD_SENDRECV) { | 3602 .send) { |
| 3135 answer_opts.AddSendStream(MEDIA_TYPE_AUDIO, kAudioTrack1, kMediaStream1); | 3603 AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1, |
| 3604 kMediaStream1, 1, &answer_opts); |
| 3136 } | 3605 } |
| 3137 std::unique_ptr<SessionDescription> answer( | 3606 std::unique_ptr<SessionDescription> answer( |
| 3138 answer_factory.CreateAnswer(offer.get(), answer_opts, NULL)); | 3607 answer_factory.CreateAnswer(offer.get(), answer_opts, NULL)); |
| 3139 const ContentInfo* ac = answer->GetContentByName("audio"); | 3608 const ContentInfo* ac = answer->GetContentByName("audio"); |
| 3140 | 3609 |
| 3141 // If the factory didn't add any audio content to the answer, we cannot check | 3610 // If the factory didn't add any audio content to the answer, we cannot |
| 3142 // that the codecs put in are right. This happens when we neither want to send | 3611 // check that the codecs put in are right. This happens when we neither want |
| 3143 // nor receive audio. The checks are still in place if at some point we'd | 3612 // to send nor receive audio. The checks are still in place if at some point |
| 3144 // instead create an inactive stream. | 3613 // we'd instead create an inactive stream. |
| 3145 if (ac) { | 3614 if (ac) { |
| 3146 const AudioContentDescription* acd = | 3615 const AudioContentDescription* acd = |
| 3147 static_cast<const AudioContentDescription*>(ac->description); | 3616 static_cast<const AudioContentDescription*>(ac->description); |
| 3148 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); | 3617 EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type()); |
| 3149 | 3618 |
| 3150 | |
| 3151 std::vector<AudioCodec> target_codecs; | 3619 std::vector<AudioCodec> target_codecs; |
| 3152 // For offers with sendrecv or inactive, we should never reply with more | 3620 // For offers with sendrecv or inactive, we should never reply with more |
| 3153 // codecs than offered, with these codec sets. | 3621 // codecs than offered, with these codec sets. |
| 3154 switch (offer_direction) { | 3622 switch (offer_direction) { |
| 3155 case cricket::MD_INACTIVE: | 3623 case cricket::MD_INACTIVE: |
| 3156 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3624 target_codecs = VectorFromIndices(kOfferAnswerCodecs, |
| 3157 kResultSendrecv_SendrecvCodecs); | 3625 kResultSendrecv_SendrecvCodecs); |
| 3158 break; | 3626 break; |
| 3159 case cricket::MD_SENDONLY: | 3627 case cricket::MD_SENDONLY: |
| 3160 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3628 target_codecs = |
| 3161 kResultSend_RecvCodecs); | 3629 VectorFromIndices(kOfferAnswerCodecs, kResultSend_RecvCodecs); |
| 3162 break; | 3630 break; |
| 3163 case cricket::MD_RECVONLY: | 3631 case cricket::MD_RECVONLY: |
| 3164 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3632 target_codecs = |
| 3165 kResultRecv_SendCodecs); | 3633 VectorFromIndices(kOfferAnswerCodecs, kResultRecv_SendCodecs); |
| 3166 break; | 3634 break; |
| 3167 case cricket::MD_SENDRECV: | 3635 case cricket::MD_SENDRECV: |
| 3168 if (acd->direction() == cricket::MD_SENDONLY) { | 3636 if (acd->direction() == cricket::MD_SENDONLY) { |
| 3169 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3637 target_codecs = |
| 3170 kResultSendrecv_SendCodecs); | 3638 VectorFromIndices(kOfferAnswerCodecs, kResultSendrecv_SendCodecs); |
| 3171 } else if (acd->direction() == cricket::MD_RECVONLY) { | 3639 } else if (acd->direction() == cricket::MD_RECVONLY) { |
| 3172 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3640 target_codecs = |
| 3173 kResultSendrecv_RecvCodecs); | 3641 VectorFromIndices(kOfferAnswerCodecs, kResultSendrecv_RecvCodecs); |
| 3174 } else { | 3642 } else { |
| 3175 target_codecs = VectorFromIndices(kOfferAnswerCodecs, | 3643 target_codecs = VectorFromIndices(kOfferAnswerCodecs, |
| 3176 kResultSendrecv_SendrecvCodecs); | 3644 kResultSendrecv_SendrecvCodecs); |
| 3177 } | 3645 } |
| 3178 break; | 3646 break; |
| 3179 } | 3647 } |
| 3180 | 3648 |
| 3181 auto format_codecs = [] (const std::vector<AudioCodec>& codecs) { | 3649 auto format_codecs = [](const std::vector<AudioCodec>& codecs) { |
| 3182 std::stringstream os; | 3650 std::stringstream os; |
| 3183 bool first = true; | 3651 bool first = true; |
| 3184 os << "{"; | 3652 os << "{"; |
| 3185 for (const auto& c : codecs) { | 3653 for (const auto& c : codecs) { |
| 3186 os << (first ? " " : ", ") << c.id; | 3654 os << (first ? " " : ", ") << c.id; |
| 3187 first = false; | 3655 first = false; |
| 3188 } | 3656 } |
| 3189 os << " }"; | 3657 os << " }"; |
| 3190 return os.str(); | 3658 return os.str(); |
| 3191 }; | 3659 }; |
| 3192 | 3660 |
| 3193 EXPECT_TRUE(acd->codecs() == target_codecs) | 3661 EXPECT_TRUE(acd->codecs() == target_codecs) |
| 3194 << "Expected: " << format_codecs(target_codecs) | 3662 << "Expected: " << format_codecs(target_codecs) |
| 3195 << ", got: " << format_codecs(acd->codecs()) | 3663 << ", got: " << format_codecs(acd->codecs()) |
| 3196 << "; Offered: " << MediaContentDirectionToString(offer_direction) | 3664 << "; Offered: " << MediaContentDirectionToString(offer_direction) |
| 3197 << ", answerer wants: " | 3665 << ", answerer wants: " |
| 3198 << MediaContentDirectionToString(answer_direction) | 3666 << MediaContentDirectionToString(answer_direction) |
| 3199 << "; got: " << MediaContentDirectionToString(acd->direction()); | 3667 << "; got: " << MediaContentDirectionToString(acd->direction()); |
| 3200 } else { | 3668 } else { |
| 3201 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) | 3669 EXPECT_EQ(offer_direction, cricket::MD_INACTIVE) |
| 3202 << "Only inactive offers are allowed to not generate any audio content"; | 3670 << "Only inactive offers are allowed to not generate any audio " |
| 3671 "content"; |
| 3203 } | 3672 } |
| 3204 } | 3673 } |
| 3205 | 3674 |
| 3206 } // namespace | 3675 } // namespace |
| 3207 | 3676 |
| 3208 class AudioCodecsOfferTest | 3677 class AudioCodecsOfferTest |
| 3209 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, | 3678 : public ::testing::TestWithParam<MediaContentDirection> {}; |
| 3210 bool>> { | |
| 3211 }; | |
| 3212 | 3679 |
| 3213 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { | 3680 TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) { |
| 3214 TestAudioCodecsOffer(::testing::get<0>(GetParam()), | 3681 TestAudioCodecsOffer(GetParam()); |
| 3215 ::testing::get<1>(GetParam())); | |
| 3216 } | 3682 } |
| 3217 | 3683 |
| 3218 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, | 3684 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, |
| 3219 AudioCodecsOfferTest, | 3685 AudioCodecsOfferTest, |
| 3220 ::testing::Combine( | 3686 ::testing::Values(cricket::MD_SENDONLY, |
| 3221 ::testing::Values(cricket::MD_SENDONLY, | 3687 cricket::MD_RECVONLY, |
| 3222 cricket::MD_RECVONLY, | 3688 cricket::MD_SENDRECV, |
| 3223 cricket::MD_SENDRECV, | 3689 cricket::MD_INACTIVE)); |
| 3224 cricket::MD_INACTIVE), | |
| 3225 ::testing::Bool())); | |
| 3226 | 3690 |
| 3227 class AudioCodecsAnswerTest | 3691 class AudioCodecsAnswerTest |
| 3228 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, | 3692 : public ::testing::TestWithParam<::testing::tuple<MediaContentDirection, |
| 3229 MediaContentDirection, | 3693 MediaContentDirection, |
| 3230 bool>> { | 3694 bool>> {}; |
| 3231 }; | |
| 3232 | 3695 |
| 3233 TEST_P(AudioCodecsAnswerTest, TestCodecsInAnswer) { | 3696 TEST_P(AudioCodecsAnswerTest, TestCodecsInAnswer) { |
| 3234 TestAudioCodecsAnswer(::testing::get<0>(GetParam()), | 3697 TestAudioCodecsAnswer(::testing::get<0>(GetParam()), |
| 3235 ::testing::get<1>(GetParam()), | 3698 ::testing::get<1>(GetParam()), |
| 3236 ::testing::get<2>(GetParam())); | 3699 ::testing::get<2>(GetParam())); |
| 3237 } | 3700 } |
| 3238 | 3701 |
| 3239 INSTANTIATE_TEST_CASE_P(MediaSessionDescriptionFactoryTest, | 3702 INSTANTIATE_TEST_CASE_P( |
| 3240 AudioCodecsAnswerTest, | 3703 MediaSessionDescriptionFactoryTest, |
| 3241 ::testing::Combine( | 3704 AudioCodecsAnswerTest, |
| 3242 ::testing::Values(cricket::MD_SENDONLY, | 3705 ::testing::Combine(::testing::Values(cricket::MD_SENDONLY, |
| 3243 cricket::MD_RECVONLY, | 3706 cricket::MD_RECVONLY, |
| 3244 cricket::MD_SENDRECV, | 3707 cricket::MD_SENDRECV, |
| 3245 cricket::MD_INACTIVE), | 3708 cricket::MD_INACTIVE), |
| 3246 ::testing::Values(cricket::MD_SENDONLY, | 3709 ::testing::Values(cricket::MD_SENDONLY, |
| 3247 cricket::MD_RECVONLY, | 3710 cricket::MD_RECVONLY, |
| 3248 cricket::MD_SENDRECV, | 3711 cricket::MD_SENDRECV, |
| 3249 cricket::MD_INACTIVE), | 3712 cricket::MD_INACTIVE), |
| 3250 ::testing::Bool())); | 3713 ::testing::Bool())); |
| OLD | NEW |