OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 using webrtc::MediaStreamInterface; | 63 using webrtc::MediaStreamInterface; |
64 using webrtc::MediaStreamTrackInterface; | 64 using webrtc::MediaStreamTrackInterface; |
65 using webrtc::PeerConnectionInterface; | 65 using webrtc::PeerConnectionInterface; |
66 using webrtc::SdpParseError; | 66 using webrtc::SdpParseError; |
67 using webrtc::SessionDescriptionInterface; | 67 using webrtc::SessionDescriptionInterface; |
68 using webrtc::StreamCollection; | 68 using webrtc::StreamCollection; |
69 using webrtc::StreamCollectionInterface; | 69 using webrtc::StreamCollectionInterface; |
70 | 70 |
71 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; | 71 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; |
72 | 72 |
| 73 static const char kAudioMid[] = "audio"; |
| 74 static const char kVideoMid[] = "video"; |
| 75 |
73 // Reference SDP with a MediaStream with label "stream1" and audio track with | 76 // Reference SDP with a MediaStream with label "stream1" and audio track with |
74 // id "audio_1" and a video track with id "video_1; | 77 // id "audio_1" and a video track with id "video_1; |
75 static const char kSdpStringWithStream1[] = | 78 static const char kSdpStringWithStream1[] = |
76 "v=0\r\n" | 79 "v=0\r\n" |
77 "o=- 0 0 IN IP4 127.0.0.1\r\n" | 80 "o=- 0 0 IN IP4 127.0.0.1\r\n" |
78 "s=-\r\n" | 81 "s=-\r\n" |
79 "t=0 0\r\n" | 82 "t=0 0\r\n" |
80 "m=audio 1 RTP/AVPF 103\r\n" | 83 "m=audio 1 RTP/AVPF 103\r\n" |
81 "a=mid:audio\r\n" | 84 "a=mid:audio\r\n" |
82 "a=rtpmap:103 ISAC/16000\r\n" | 85 "a=rtpmap:103 ISAC/16000\r\n" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Remote stream is no longer available. | 308 // Remote stream is no longer available. |
306 virtual void OnRemoveRemoteStream(MediaStreamInterface* remote_stream) { | 309 virtual void OnRemoveRemoteStream(MediaStreamInterface* remote_stream) { |
307 remote_media_streams_->RemoveStream(remote_stream); | 310 remote_media_streams_->RemoveStream(remote_stream); |
308 } | 311 } |
309 | 312 |
310 virtual void OnAddDataChannel(DataChannelInterface* data_channel) { | 313 virtual void OnAddDataChannel(DataChannelInterface* data_channel) { |
311 } | 314 } |
312 | 315 |
313 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, | 316 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, |
314 AudioTrackInterface* audio_track, | 317 AudioTrackInterface* audio_track, |
315 uint32 ssrc) { | 318 uint32 ssrc, |
316 AddTrack(&local_audio_tracks_, stream, audio_track, ssrc); | 319 const std::string& mid) { |
| 320 AddTrack(&local_audio_tracks_, stream, audio_track, ssrc, mid); |
317 } | 321 } |
318 | 322 |
319 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, | 323 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, |
320 VideoTrackInterface* video_track, | 324 VideoTrackInterface* video_track, |
321 uint32 ssrc) { | 325 uint32 ssrc, |
322 AddTrack(&local_video_tracks_, stream, video_track, ssrc); | 326 const std::string& mid) { |
| 327 AddTrack(&local_video_tracks_, stream, video_track, ssrc, mid); |
323 } | 328 } |
324 | 329 |
325 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, | 330 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, |
326 AudioTrackInterface* audio_track, | 331 AudioTrackInterface* audio_track, |
327 uint32 ssrc) { | 332 uint32 ssrc) { |
328 RemoveTrack(&local_audio_tracks_, stream, audio_track); | 333 RemoveTrack(&local_audio_tracks_, stream, audio_track); |
329 } | 334 } |
330 | 335 |
331 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, | 336 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, |
332 VideoTrackInterface* video_track) { | 337 VideoTrackInterface* video_track) { |
333 RemoveTrack(&local_video_tracks_, stream, video_track); | 338 RemoveTrack(&local_video_tracks_, stream, video_track); |
334 } | 339 } |
335 | 340 |
336 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, | 341 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, |
337 AudioTrackInterface* audio_track, | 342 AudioTrackInterface* audio_track, |
338 uint32 ssrc) { | 343 uint32 ssrc, |
339 AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc); | 344 const std::string& mid) { |
| 345 AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc, mid); |
340 } | 346 } |
341 | 347 |
342 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, | 348 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, |
343 VideoTrackInterface* video_track, | 349 VideoTrackInterface* video_track, |
344 uint32 ssrc) { | 350 uint32 ssrc, |
345 AddTrack(&remote_video_tracks_, stream, video_track, ssrc); | 351 const std::string& mid) { |
| 352 AddTrack(&remote_video_tracks_, stream, video_track, ssrc, mid); |
346 } | 353 } |
347 | 354 |
348 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, | 355 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, |
349 AudioTrackInterface* audio_track) { | 356 AudioTrackInterface* audio_track) { |
350 RemoveTrack(&remote_audio_tracks_, stream, audio_track); | 357 RemoveTrack(&remote_audio_tracks_, stream, audio_track); |
351 } | 358 } |
352 | 359 |
353 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, | 360 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, |
354 VideoTrackInterface* video_track) { | 361 VideoTrackInterface* video_track) { |
355 RemoveTrack(&remote_video_tracks_, stream, video_track); | 362 RemoveTrack(&remote_video_tracks_, stream, video_track); |
356 } | 363 } |
357 | 364 |
358 virtual void OnRemoveLocalStream(MediaStreamInterface* stream) { | 365 virtual void OnRemoveLocalStream(MediaStreamInterface* stream) { |
359 } | 366 } |
360 | 367 |
361 MediaStreamInterface* RemoteStream(const std::string& label) { | 368 MediaStreamInterface* RemoteStream(const std::string& label) { |
362 return remote_media_streams_->find(label); | 369 return remote_media_streams_->find(label); |
363 } | 370 } |
364 | 371 |
365 StreamCollectionInterface* remote_streams() const { | 372 StreamCollectionInterface* remote_streams() const { |
366 return remote_media_streams_; | 373 return remote_media_streams_; |
367 } | 374 } |
368 | 375 |
369 size_t NumberOfRemoteAudioTracks() { return remote_audio_tracks_.size(); } | 376 size_t NumberOfRemoteAudioTracks() { return remote_audio_tracks_.size(); } |
370 | 377 |
371 void VerifyRemoteAudioTrack(const std::string& stream_label, | 378 void VerifyRemoteAudioTrack(const std::string& stream_label, |
372 const std::string& track_id, | 379 const std::string& track_id, |
373 uint32 ssrc) { | 380 uint32 ssrc, |
374 VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc); | 381 const std::string& mid) { |
| 382 VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc, mid); |
375 } | 383 } |
376 | 384 |
377 size_t NumberOfRemoteVideoTracks() { return remote_video_tracks_.size(); } | 385 size_t NumberOfRemoteVideoTracks() { return remote_video_tracks_.size(); } |
378 | 386 |
379 void VerifyRemoteVideoTrack(const std::string& stream_label, | 387 void VerifyRemoteVideoTrack(const std::string& stream_label, |
380 const std::string& track_id, | 388 const std::string& track_id, |
381 uint32 ssrc) { | 389 uint32 ssrc, |
382 VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc); | 390 const std::string& mid) { |
| 391 VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc, mid); |
383 } | 392 } |
384 | 393 |
385 size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); } | 394 size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); } |
386 void VerifyLocalAudioTrack(const std::string& stream_label, | 395 void VerifyLocalAudioTrack(const std::string& stream_label, |
387 const std::string& track_id, | 396 const std::string& track_id, |
388 uint32 ssrc) { | 397 uint32 ssrc, |
389 VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc); | 398 const std::string& mid) { |
| 399 VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc, mid); |
390 } | 400 } |
391 | 401 |
392 size_t NumberOfLocalVideoTracks() { return local_video_tracks_.size(); } | 402 size_t NumberOfLocalVideoTracks() { return local_video_tracks_.size(); } |
393 | 403 |
394 void VerifyLocalVideoTrack(const std::string& stream_label, | 404 void VerifyLocalVideoTrack(const std::string& stream_label, |
395 const std::string& track_id, | 405 const std::string& track_id, |
396 uint32 ssrc) { | 406 uint32 ssrc, |
397 VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc); | 407 const std::string& mid) { |
| 408 VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc, mid); |
398 } | 409 } |
399 | 410 |
400 private: | 411 private: |
401 struct TrackInfo { | 412 struct TrackInfo { |
402 TrackInfo() {} | 413 TrackInfo() {} |
403 TrackInfo(const std::string& stream_label, const std::string track_id, | 414 TrackInfo(const std::string& stream_label, |
404 uint32 ssrc) | 415 const std::string track_id, |
| 416 uint32 ssrc, |
| 417 const std::string& mid) |
405 : stream_label(stream_label), | 418 : stream_label(stream_label), |
406 track_id(track_id), | 419 track_id(track_id), |
407 ssrc(ssrc) { | 420 ssrc(ssrc), |
408 } | 421 mid(mid) {} |
409 std::string stream_label; | 422 std::string stream_label; |
410 std::string track_id; | 423 std::string track_id; |
411 uint32 ssrc; | 424 uint32 ssrc; |
| 425 std::string mid; |
412 }; | 426 }; |
413 typedef std::vector<TrackInfo> TrackInfos; | 427 typedef std::vector<TrackInfo> TrackInfos; |
414 | 428 |
415 void AddTrack(TrackInfos* track_infos, MediaStreamInterface* stream, | 429 void AddTrack(TrackInfos* track_infos, |
| 430 MediaStreamInterface* stream, |
416 MediaStreamTrackInterface* track, | 431 MediaStreamTrackInterface* track, |
417 uint32 ssrc) { | 432 uint32 ssrc, |
418 (*track_infos).push_back(TrackInfo(stream->label(), track->id(), | 433 const std::string& mid) { |
419 ssrc)); | 434 (*track_infos) |
| 435 .push_back(TrackInfo(stream->label(), track->id(), ssrc, mid)); |
420 } | 436 } |
421 | 437 |
422 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, | 438 void RemoveTrack(TrackInfos* track_infos, MediaStreamInterface* stream, |
423 MediaStreamTrackInterface* track) { | 439 MediaStreamTrackInterface* track) { |
424 for (TrackInfos::iterator it = track_infos->begin(); | 440 for (TrackInfos::iterator it = track_infos->begin(); |
425 it != track_infos->end(); ++it) { | 441 it != track_infos->end(); ++it) { |
426 if (it->stream_label == stream->label() && it->track_id == track->id()) { | 442 if (it->stream_label == stream->label() && it->track_id == track->id()) { |
427 track_infos->erase(it); | 443 track_infos->erase(it); |
428 return; | 444 return; |
429 } | 445 } |
430 } | 446 } |
431 ADD_FAILURE(); | 447 ADD_FAILURE(); |
432 } | 448 } |
433 | 449 |
434 const TrackInfo* FindTrackInfo(const TrackInfos& infos, | 450 const TrackInfo* FindTrackInfo(const TrackInfos& infos, |
435 const std::string& stream_label, | 451 const std::string& stream_label, |
436 const std::string track_id) const { | 452 const std::string track_id) const { |
437 for (TrackInfos::const_iterator it = infos.begin(); | 453 for (TrackInfos::const_iterator it = infos.begin(); |
438 it != infos.end(); ++it) { | 454 it != infos.end(); ++it) { |
439 if (it->stream_label == stream_label && it->track_id == track_id) | 455 if (it->stream_label == stream_label && it->track_id == track_id) |
440 return &*it; | 456 return &*it; |
441 } | 457 } |
442 return NULL; | 458 return NULL; |
443 } | 459 } |
444 | 460 |
445 | |
446 void VerifyTrack(const TrackInfos& track_infos, | 461 void VerifyTrack(const TrackInfos& track_infos, |
447 const std::string& stream_label, | 462 const std::string& stream_label, |
448 const std::string& track_id, | 463 const std::string& track_id, |
449 uint32 ssrc) { | 464 uint32 ssrc, |
| 465 const std::string& mid) { |
450 const TrackInfo* track_info = FindTrackInfo(track_infos, | 466 const TrackInfo* track_info = FindTrackInfo(track_infos, |
451 stream_label, | 467 stream_label, |
452 track_id); | 468 track_id); |
453 ASSERT_TRUE(track_info != NULL); | 469 ASSERT_TRUE(track_info != NULL); |
454 EXPECT_EQ(ssrc, track_info->ssrc); | 470 EXPECT_EQ(ssrc, track_info->ssrc); |
| 471 EXPECT_EQ(mid, track_info->mid); |
455 } | 472 } |
456 | 473 |
457 TrackInfos remote_audio_tracks_; | 474 TrackInfos remote_audio_tracks_; |
458 TrackInfos remote_video_tracks_; | 475 TrackInfos remote_video_tracks_; |
459 TrackInfos local_audio_tracks_; | 476 TrackInfos local_audio_tracks_; |
460 TrackInfos local_video_tracks_; | 477 TrackInfos local_video_tracks_; |
461 | 478 |
462 rtc::scoped_refptr<StreamCollection> remote_media_streams_; | 479 rtc::scoped_refptr<StreamCollection> remote_media_streams_; |
463 }; | 480 }; |
464 | 481 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 EXPECT_TRUE(desc != NULL); | 815 EXPECT_TRUE(desc != NULL); |
799 signaling_->OnRemoteDescriptionChanged(desc.get()); | 816 signaling_->OnRemoteDescriptionChanged(desc.get()); |
800 | 817 |
801 rtc::scoped_refptr<StreamCollection> reference( | 818 rtc::scoped_refptr<StreamCollection> reference( |
802 CreateStreamCollection(1)); | 819 CreateStreamCollection(1)); |
803 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), | 820 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), |
804 reference.get())); | 821 reference.get())); |
805 EXPECT_TRUE(CompareStreamCollections(observer_->remote_streams(), | 822 EXPECT_TRUE(CompareStreamCollections(observer_->remote_streams(), |
806 reference.get())); | 823 reference.get())); |
807 EXPECT_EQ(1u, observer_->NumberOfRemoteAudioTracks()); | 824 EXPECT_EQ(1u, observer_->NumberOfRemoteAudioTracks()); |
808 observer_->VerifyRemoteAudioTrack(kStreams[0], kAudioTracks[0], 1); | 825 observer_->VerifyRemoteAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
809 EXPECT_EQ(1u, observer_->NumberOfRemoteVideoTracks()); | 826 EXPECT_EQ(1u, observer_->NumberOfRemoteVideoTracks()); |
810 observer_->VerifyRemoteVideoTrack(kStreams[0], kVideoTracks[0], 2); | 827 observer_->VerifyRemoteVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
811 ASSERT_EQ(1u, observer_->remote_streams()->count()); | 828 ASSERT_EQ(1u, observer_->remote_streams()->count()); |
812 MediaStreamInterface* remote_stream = observer_->remote_streams()->at(0); | 829 MediaStreamInterface* remote_stream = observer_->remote_streams()->at(0); |
813 EXPECT_TRUE(remote_stream->GetVideoTracks()[0]->GetSource() != NULL); | 830 EXPECT_TRUE(remote_stream->GetVideoTracks()[0]->GetSource() != NULL); |
814 | 831 |
815 // Create a session description based on another SDP with another | 832 // Create a session description based on another SDP with another |
816 // MediaStream. | 833 // MediaStream. |
817 rtc::scoped_ptr<SessionDescriptionInterface> update_desc( | 834 rtc::scoped_ptr<SessionDescriptionInterface> update_desc( |
818 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 835 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
819 kSdpStringWith2Stream, NULL)); | 836 kSdpStringWith2Stream, NULL)); |
820 EXPECT_TRUE(update_desc != NULL); | 837 EXPECT_TRUE(update_desc != NULL); |
821 signaling_->OnRemoteDescriptionChanged(update_desc.get()); | 838 signaling_->OnRemoteDescriptionChanged(update_desc.get()); |
822 | 839 |
823 rtc::scoped_refptr<StreamCollection> reference2( | 840 rtc::scoped_refptr<StreamCollection> reference2( |
824 CreateStreamCollection(2)); | 841 CreateStreamCollection(2)); |
825 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), | 842 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), |
826 reference2.get())); | 843 reference2.get())); |
827 EXPECT_TRUE(CompareStreamCollections(observer_->remote_streams(), | 844 EXPECT_TRUE(CompareStreamCollections(observer_->remote_streams(), |
828 reference2.get())); | 845 reference2.get())); |
829 | 846 |
830 EXPECT_EQ(2u, observer_->NumberOfRemoteAudioTracks()); | 847 EXPECT_EQ(2u, observer_->NumberOfRemoteAudioTracks()); |
831 observer_->VerifyRemoteAudioTrack(kStreams[0], kAudioTracks[0], 1); | 848 observer_->VerifyRemoteAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
832 observer_->VerifyRemoteAudioTrack(kStreams[1], kAudioTracks[1], 3); | 849 observer_->VerifyRemoteAudioTrack(kStreams[1], kAudioTracks[1], 3, kAudioMid); |
833 EXPECT_EQ(2u, observer_->NumberOfRemoteVideoTracks()); | 850 EXPECT_EQ(2u, observer_->NumberOfRemoteVideoTracks()); |
834 observer_->VerifyRemoteVideoTrack(kStreams[0], kVideoTracks[0], 2); | 851 observer_->VerifyRemoteVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
835 observer_->VerifyRemoteVideoTrack(kStreams[1], kVideoTracks[1], 4); | 852 observer_->VerifyRemoteVideoTrack(kStreams[1], kVideoTracks[1], 4, kVideoMid); |
836 } | 853 } |
837 | 854 |
838 // This test verifies that the remote MediaStreams corresponding to a received | 855 // This test verifies that the remote MediaStreams corresponding to a received |
839 // SDP string is created. In this test the same remote MediaStream is signaled | 856 // SDP string is created. In this test the same remote MediaStream is signaled |
840 // but MediaStream tracks are added and removed. | 857 // but MediaStream tracks are added and removed. |
841 TEST_F(MediaStreamSignalingTest, AddRemoveTrackFromExistingRemoteMediaStream) { | 858 TEST_F(MediaStreamSignalingTest, AddRemoveTrackFromExistingRemoteMediaStream) { |
842 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1; | 859 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms1; |
843 CreateSessionDescriptionAndReference(1, 1, desc_ms1.use()); | 860 CreateSessionDescriptionAndReference(1, 1, desc_ms1.use()); |
844 signaling_->OnRemoteDescriptionChanged(desc_ms1.get()); | 861 signaling_->OnRemoteDescriptionChanged(desc_ms1.get()); |
845 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), | 862 EXPECT_TRUE(CompareStreamCollections(signaling_->remote_streams(), |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 968 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
952 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 969 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
953 kSdpStringWithoutStreams, NULL)); | 970 kSdpStringWithoutStreams, NULL)); |
954 ASSERT_TRUE(desc != NULL); | 971 ASSERT_TRUE(desc != NULL); |
955 signaling_->OnRemoteDescriptionChanged(desc.get()); | 972 signaling_->OnRemoteDescriptionChanged(desc.get()); |
956 EXPECT_EQ(1u, signaling_->remote_streams()->count()); | 973 EXPECT_EQ(1u, signaling_->remote_streams()->count()); |
957 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); | 974 ASSERT_EQ(1u, remote_stream->GetAudioTracks().size()); |
958 EXPECT_EQ("defaulta0", remote_stream->GetAudioTracks()[0]->id()); | 975 EXPECT_EQ("defaulta0", remote_stream->GetAudioTracks()[0]->id()); |
959 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size()); | 976 ASSERT_EQ(1u, remote_stream->GetVideoTracks().size()); |
960 EXPECT_EQ("defaultv0", remote_stream->GetVideoTracks()[0]->id()); | 977 EXPECT_EQ("defaultv0", remote_stream->GetVideoTracks()[0]->id()); |
961 observer_->VerifyRemoteAudioTrack("default", "defaulta0", 0); | 978 observer_->VerifyRemoteAudioTrack("default", "defaulta0", 0, kAudioMid); |
962 observer_->VerifyRemoteVideoTrack("default", "defaultv0", 0); | 979 observer_->VerifyRemoteVideoTrack("default", "defaultv0", 0, kVideoMid); |
963 } | 980 } |
964 | 981 |
965 // This tests that a default MediaStream is created if a remote session | 982 // This tests that a default MediaStream is created if a remote session |
966 // description doesn't contain any streams and media direction is send only. | 983 // description doesn't contain any streams and media direction is send only. |
967 TEST_F(MediaStreamSignalingTest, RecvOnlySdpWithoutMsidCreatesDefaultStream) { | 984 TEST_F(MediaStreamSignalingTest, RecvOnlySdpWithoutMsidCreatesDefaultStream) { |
968 rtc::scoped_ptr<SessionDescriptionInterface> desc( | 985 rtc::scoped_ptr<SessionDescriptionInterface> desc( |
969 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 986 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
970 kSdpStringSendOnlyWithWithoutStreams, | 987 kSdpStringSendOnlyWithWithoutStreams, |
971 NULL)); | 988 NULL)); |
972 ASSERT_TRUE(desc != NULL); | 989 ASSERT_TRUE(desc != NULL); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // when MediaStreamSignaling::OnLocalDescriptionChanged is called with an | 1075 // when MediaStreamSignaling::OnLocalDescriptionChanged is called with an |
1059 // updated local session description. | 1076 // updated local session description. |
1060 TEST_F(MediaStreamSignalingTest, LocalDescriptionChanged) { | 1077 TEST_F(MediaStreamSignalingTest, LocalDescriptionChanged) { |
1061 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; | 1078 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; |
1062 CreateSessionDescriptionAndReference(2, 2, desc_1.use()); | 1079 CreateSessionDescriptionAndReference(2, 2, desc_1.use()); |
1063 | 1080 |
1064 signaling_->AddLocalStream(reference_collection_->at(0)); | 1081 signaling_->AddLocalStream(reference_collection_->at(0)); |
1065 signaling_->OnLocalDescriptionChanged(desc_1.get()); | 1082 signaling_->OnLocalDescriptionChanged(desc_1.get()); |
1066 EXPECT_EQ(2u, observer_->NumberOfLocalAudioTracks()); | 1083 EXPECT_EQ(2u, observer_->NumberOfLocalAudioTracks()); |
1067 EXPECT_EQ(2u, observer_->NumberOfLocalVideoTracks()); | 1084 EXPECT_EQ(2u, observer_->NumberOfLocalVideoTracks()); |
1068 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1); | 1085 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
1069 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2); | 1086 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
1070 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[1], 3); | 1087 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[1], 3, kAudioMid); |
1071 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[1], 4); | 1088 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[1], 4, kVideoMid); |
1072 | 1089 |
1073 // Remove an audio and video track. | 1090 // Remove an audio and video track. |
1074 rtc::scoped_ptr<SessionDescriptionInterface> desc_2; | 1091 rtc::scoped_ptr<SessionDescriptionInterface> desc_2; |
1075 CreateSessionDescriptionAndReference(1, 1, desc_2.use()); | 1092 CreateSessionDescriptionAndReference(1, 1, desc_2.use()); |
1076 signaling_->OnLocalDescriptionChanged(desc_2.get()); | 1093 signaling_->OnLocalDescriptionChanged(desc_2.get()); |
1077 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); | 1094 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); |
1078 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); | 1095 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); |
1079 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1); | 1096 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
1080 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2); | 1097 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
1081 } | 1098 } |
1082 | 1099 |
1083 // This test that the correct MediaStreamSignalingObserver methods are called | 1100 // This test that the correct MediaStreamSignalingObserver methods are called |
1084 // when MediaStreamSignaling::AddLocalStream is called after | 1101 // when MediaStreamSignaling::AddLocalStream is called after |
1085 // MediaStreamSignaling::OnLocalDescriptionChanged is called. | 1102 // MediaStreamSignaling::OnLocalDescriptionChanged is called. |
1086 TEST_F(MediaStreamSignalingTest, AddLocalStreamAfterLocalDescriptionChanged) { | 1103 TEST_F(MediaStreamSignalingTest, AddLocalStreamAfterLocalDescriptionChanged) { |
1087 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; | 1104 rtc::scoped_ptr<SessionDescriptionInterface> desc_1; |
1088 CreateSessionDescriptionAndReference(2, 2, desc_1.use()); | 1105 CreateSessionDescriptionAndReference(2, 2, desc_1.use()); |
1089 | 1106 |
1090 signaling_->OnLocalDescriptionChanged(desc_1.get()); | 1107 signaling_->OnLocalDescriptionChanged(desc_1.get()); |
1091 EXPECT_EQ(0u, observer_->NumberOfLocalAudioTracks()); | 1108 EXPECT_EQ(0u, observer_->NumberOfLocalAudioTracks()); |
1092 EXPECT_EQ(0u, observer_->NumberOfLocalVideoTracks()); | 1109 EXPECT_EQ(0u, observer_->NumberOfLocalVideoTracks()); |
1093 | 1110 |
1094 signaling_->AddLocalStream(reference_collection_->at(0)); | 1111 signaling_->AddLocalStream(reference_collection_->at(0)); |
1095 EXPECT_EQ(2u, observer_->NumberOfLocalAudioTracks()); | 1112 EXPECT_EQ(2u, observer_->NumberOfLocalAudioTracks()); |
1096 EXPECT_EQ(2u, observer_->NumberOfLocalVideoTracks()); | 1113 EXPECT_EQ(2u, observer_->NumberOfLocalVideoTracks()); |
1097 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1); | 1114 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
1098 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2); | 1115 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
1099 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[1], 3); | 1116 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[1], 3, kAudioMid); |
1100 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[1], 4); | 1117 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[1], 4, kVideoMid); |
1101 } | 1118 } |
1102 | 1119 |
1103 // This test that the correct MediaStreamSignalingObserver methods are called | 1120 // This test that the correct MediaStreamSignalingObserver methods are called |
1104 // if the ssrc on a local track is changed when | 1121 // if the ssrc on a local track is changed when |
1105 // MediaStreamSignaling::OnLocalDescriptionChanged is called. | 1122 // MediaStreamSignaling::OnLocalDescriptionChanged is called. |
1106 TEST_F(MediaStreamSignalingTest, ChangeSsrcOnTrackInLocalSessionDescription) { | 1123 TEST_F(MediaStreamSignalingTest, ChangeSsrcOnTrackInLocalSessionDescription) { |
1107 rtc::scoped_ptr<SessionDescriptionInterface> desc; | 1124 rtc::scoped_ptr<SessionDescriptionInterface> desc; |
1108 CreateSessionDescriptionAndReference(1, 1, desc.use()); | 1125 CreateSessionDescriptionAndReference(1, 1, desc.use()); |
1109 | 1126 |
1110 signaling_->AddLocalStream(reference_collection_->at(0)); | 1127 signaling_->AddLocalStream(reference_collection_->at(0)); |
1111 signaling_->OnLocalDescriptionChanged(desc.get()); | 1128 signaling_->OnLocalDescriptionChanged(desc.get()); |
1112 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); | 1129 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); |
1113 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); | 1130 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); |
1114 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1); | 1131 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 1, kAudioMid); |
1115 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2); | 1132 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 2, kVideoMid); |
1116 | 1133 |
1117 // Change the ssrc of the audio and video track. | 1134 // Change the ssrc of the audio and video track. |
1118 std::string sdp; | 1135 std::string sdp; |
1119 desc->ToString(&sdp); | 1136 desc->ToString(&sdp); |
1120 std::string ssrc_org = "a=ssrc:1"; | 1137 std::string ssrc_org = "a=ssrc:1"; |
1121 std::string ssrc_to = "a=ssrc:97"; | 1138 std::string ssrc_to = "a=ssrc:97"; |
1122 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), | 1139 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), |
1123 ssrc_to.c_str(), ssrc_to.length(), | 1140 ssrc_to.c_str(), ssrc_to.length(), |
1124 &sdp); | 1141 &sdp); |
1125 ssrc_org = "a=ssrc:2"; | 1142 ssrc_org = "a=ssrc:2"; |
1126 ssrc_to = "a=ssrc:98"; | 1143 ssrc_to = "a=ssrc:98"; |
1127 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), | 1144 rtc::replace_substrs(ssrc_org.c_str(), ssrc_org.length(), |
1128 ssrc_to.c_str(), ssrc_to.length(), | 1145 ssrc_to.c_str(), ssrc_to.length(), |
1129 &sdp); | 1146 &sdp); |
1130 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( | 1147 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( |
1131 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 1148 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
1132 sdp, NULL)); | 1149 sdp, NULL)); |
1133 | 1150 |
1134 signaling_->OnLocalDescriptionChanged(updated_desc.get()); | 1151 signaling_->OnLocalDescriptionChanged(updated_desc.get()); |
1135 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); | 1152 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); |
1136 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); | 1153 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); |
1137 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 97); | 1154 observer_->VerifyLocalAudioTrack(kStreams[0], kAudioTracks[0], 97, kAudioMid); |
1138 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 98); | 1155 observer_->VerifyLocalVideoTrack(kStreams[0], kVideoTracks[0], 98, kVideoMid); |
1139 } | 1156 } |
1140 | 1157 |
1141 // This test that the correct MediaStreamSignalingObserver methods are called | 1158 // This test that the correct MediaStreamSignalingObserver methods are called |
1142 // if a new session description is set with the same tracks but they are now | 1159 // if a new session description is set with the same tracks but they are now |
1143 // sent on a another MediaStream. | 1160 // sent on a another MediaStream. |
1144 TEST_F(MediaStreamSignalingTest, SignalSameTracksInSeparateMediaStream) { | 1161 TEST_F(MediaStreamSignalingTest, SignalSameTracksInSeparateMediaStream) { |
1145 rtc::scoped_ptr<SessionDescriptionInterface> desc; | 1162 rtc::scoped_ptr<SessionDescriptionInterface> desc; |
1146 CreateSessionDescriptionAndReference(1, 1, desc.use()); | 1163 CreateSessionDescriptionAndReference(1, 1, desc.use()); |
1147 | 1164 |
1148 signaling_->AddLocalStream(reference_collection_->at(0)); | 1165 signaling_->AddLocalStream(reference_collection_->at(0)); |
1149 signaling_->OnLocalDescriptionChanged(desc.get()); | 1166 signaling_->OnLocalDescriptionChanged(desc.get()); |
1150 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); | 1167 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); |
1151 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); | 1168 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); |
1152 | 1169 |
1153 std::string stream_label_0 = kStreams[0]; | 1170 std::string stream_label_0 = kStreams[0]; |
1154 observer_->VerifyLocalAudioTrack(stream_label_0, kAudioTracks[0], 1); | 1171 observer_->VerifyLocalAudioTrack(stream_label_0, kAudioTracks[0], 1, |
1155 observer_->VerifyLocalVideoTrack(stream_label_0, kVideoTracks[0], 2); | 1172 kAudioMid); |
| 1173 observer_->VerifyLocalVideoTrack(stream_label_0, kVideoTracks[0], 2, |
| 1174 kVideoMid); |
1156 | 1175 |
1157 // Add a new MediaStream but with the same tracks as in the first stream. | 1176 // Add a new MediaStream but with the same tracks as in the first stream. |
1158 std::string stream_label_1 = kStreams[1]; | 1177 std::string stream_label_1 = kStreams[1]; |
1159 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_1( | 1178 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_1( |
1160 webrtc::MediaStream::Create(kStreams[1])); | 1179 webrtc::MediaStream::Create(kStreams[1])); |
1161 stream_1->AddTrack(reference_collection_->at(0)->GetVideoTracks()[0]); | 1180 stream_1->AddTrack(reference_collection_->at(0)->GetVideoTracks()[0]); |
1162 stream_1->AddTrack(reference_collection_->at(0)->GetAudioTracks()[0]); | 1181 stream_1->AddTrack(reference_collection_->at(0)->GetAudioTracks()[0]); |
1163 signaling_->AddLocalStream(stream_1); | 1182 signaling_->AddLocalStream(stream_1); |
1164 | 1183 |
1165 // Replace msid in the original SDP. | 1184 // Replace msid in the original SDP. |
1166 std::string sdp; | 1185 std::string sdp; |
1167 desc->ToString(&sdp); | 1186 desc->ToString(&sdp); |
1168 rtc::replace_substrs( | 1187 rtc::replace_substrs( |
1169 kStreams[0], strlen(kStreams[0]), kStreams[1], strlen(kStreams[1]), &sdp); | 1188 kStreams[0], strlen(kStreams[0]), kStreams[1], strlen(kStreams[1]), &sdp); |
1170 | 1189 |
1171 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( | 1190 rtc::scoped_ptr<SessionDescriptionInterface> updated_desc( |
1172 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, | 1191 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
1173 sdp, NULL)); | 1192 sdp, NULL)); |
1174 | 1193 |
1175 signaling_->OnLocalDescriptionChanged(updated_desc.get()); | 1194 signaling_->OnLocalDescriptionChanged(updated_desc.get()); |
1176 observer_->VerifyLocalAudioTrack(kStreams[1], kAudioTracks[0], 1); | 1195 observer_->VerifyLocalAudioTrack(kStreams[1], kAudioTracks[0], 1, kAudioMid); |
1177 observer_->VerifyLocalVideoTrack(kStreams[1], kVideoTracks[0], 2); | 1196 observer_->VerifyLocalVideoTrack(kStreams[1], kVideoTracks[0], 2, kVideoMid); |
1178 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); | 1197 EXPECT_EQ(1u, observer_->NumberOfLocalAudioTracks()); |
1179 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); | 1198 EXPECT_EQ(1u, observer_->NumberOfLocalVideoTracks()); |
1180 } | 1199 } |
1181 | 1200 |
1182 // Verifies that an even SCTP id is allocated for SSL_CLIENT and an odd id for | 1201 // Verifies that an even SCTP id is allocated for SSL_CLIENT and an odd id for |
1183 // SSL_SERVER. | 1202 // SSL_SERVER. |
1184 TEST_F(MediaStreamSignalingTest, SctpIdAllocationBasedOnRole) { | 1203 TEST_F(MediaStreamSignalingTest, SctpIdAllocationBasedOnRole) { |
1185 int id; | 1204 int id; |
1186 ASSERT_TRUE(signaling_->AllocateSctpSid(rtc::SSL_SERVER, &id)); | 1205 ASSERT_TRUE(signaling_->AllocateSctpSid(rtc::SSL_SERVER, &id)); |
1187 EXPECT_EQ(1, id); | 1206 EXPECT_EQ(1, id); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 webrtc::WriteDataChannelOpenMessage("a", config, &payload); | 1356 webrtc::WriteDataChannelOpenMessage("a", config, &payload); |
1338 cricket::ReceiveDataParams params; | 1357 cricket::ReceiveDataParams params; |
1339 params.ssrc = config.id; | 1358 params.ssrc = config.id; |
1340 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); | 1359 EXPECT_TRUE(signaling_->AddDataChannelFromOpenMessage(params, payload)); |
1341 EXPECT_TRUE(signaling_->HasDataChannels()); | 1360 EXPECT_TRUE(signaling_->HasDataChannels()); |
1342 | 1361 |
1343 // Removes the DataChannel and verifies that no DataChannel is left. | 1362 // Removes the DataChannel and verifies that no DataChannel is left. |
1344 signaling_->RemoveSctpDataChannel(config.id); | 1363 signaling_->RemoveSctpDataChannel(config.id); |
1345 EXPECT_FALSE(signaling_->HasDataChannels()); | 1364 EXPECT_FALSE(signaling_->HasDataChannels()); |
1346 } | 1365 } |
OLD | NEW |