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

Side by Side Diff: webrtc/pc/peerconnection_integrationtest.cc

Issue 2827643003: Adding integration test for unsignaled inbound RTP stream stats. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/pc/test/mockpeerconnectionobservers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM; 99 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM;
100 100
101 // Helper function for constructing offer/answer options to initiate an ICE 101 // Helper function for constructing offer/answer options to initiate an ICE
102 // restart. 102 // restart.
103 PeerConnectionInterface::RTCOfferAnswerOptions IceRestartOfferAnswerOptions() { 103 PeerConnectionInterface::RTCOfferAnswerOptions IceRestartOfferAnswerOptions() {
104 PeerConnectionInterface::RTCOfferAnswerOptions options; 104 PeerConnectionInterface::RTCOfferAnswerOptions options;
105 options.ice_restart = true; 105 options.ice_restart = true;
106 return options; 106 return options;
107 } 107 }
108 108
109 // Remove all stream information (SSRCs, track IDs, etc.) and "msid-semantic"
110 // attribute from received SDP, simulating a legacy endpoint.
111 void RemoveSsrcsAndMsids(cricket::SessionDescription* desc) {
112 for (ContentInfo& content : desc->contents()) {
113 MediaContentDescription* media_desc =
114 static_cast<MediaContentDescription*>(content.description);
115 media_desc->mutable_streams().clear();
116 }
117 desc->set_msid_supported(false);
118 }
119
109 class SignalingMessageReceiver { 120 class SignalingMessageReceiver {
110 public: 121 public:
111 virtual void ReceiveSdpMessage(const std::string& type, 122 virtual void ReceiveSdpMessage(const std::string& type,
112 const std::string& msg) = 0; 123 const std::string& msg) = 0;
113 virtual void ReceiveIceMessage(const std::string& sdp_mid, 124 virtual void ReceiveIceMessage(const std::string& sdp_mid,
114 int sdp_mline_index, 125 int sdp_mline_index,
115 const std::string& msg) = 0; 126 const std::string& msg) = 0;
116 127
117 protected: 128 protected:
118 SignalingMessageReceiver() {} 129 SignalingMessageReceiver() {}
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 412 }
402 for (const auto& renderer : removed_fake_video_renderers_) { 413 for (const auto& renderer : removed_fake_video_renderers_) {
403 total += renderer->num_rendered_frames(); 414 total += renderer->num_rendered_frames();
404 } 415 }
405 } 416 }
406 return total; 417 return total;
407 } 418 }
408 419
409 // Returns a MockStatsObserver in a state after stats gathering finished, 420 // Returns a MockStatsObserver in a state after stats gathering finished,
410 // which can be used to access the gathered stats. 421 // which can be used to access the gathered stats.
411 rtc::scoped_refptr<MockStatsObserver> GetStatsForTrack( 422 rtc::scoped_refptr<MockStatsObserver> OldGetStatsForTrack(
412 webrtc::MediaStreamTrackInterface* track) { 423 webrtc::MediaStreamTrackInterface* track) {
413 rtc::scoped_refptr<MockStatsObserver> observer( 424 rtc::scoped_refptr<MockStatsObserver> observer(
414 new rtc::RefCountedObject<MockStatsObserver>()); 425 new rtc::RefCountedObject<MockStatsObserver>());
415 EXPECT_TRUE(peer_connection_->GetStats( 426 EXPECT_TRUE(peer_connection_->GetStats(
416 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard)); 427 observer, nullptr, PeerConnectionInterface::kStatsOutputLevelStandard));
417 EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout); 428 EXPECT_TRUE_WAIT(observer->called(), kDefaultTimeout);
418 return observer; 429 return observer;
419 } 430 }
420 431
421 // Version that doesn't take a track "filter", and gathers all stats. 432 // Version that doesn't take a track "filter", and gathers all stats.
422 rtc::scoped_refptr<MockStatsObserver> GetStats() { 433 rtc::scoped_refptr<MockStatsObserver> OldGetStats() {
423 return GetStatsForTrack(nullptr); 434 return OldGetStatsForTrack(nullptr);
435 }
436
437 // Synchronously gets stats and returns them. If it times out, fails the test
438 // and returns null.
439 rtc::scoped_refptr<const webrtc::RTCStatsReport> NewGetStats() {
440 rtc::scoped_refptr<webrtc::MockRTCStatsCollectorCallback> callback(
441 new rtc::RefCountedObject<webrtc::MockRTCStatsCollectorCallback>());
442 peer_connection_->GetStats(callback);
443 EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
444 return callback->report();
424 } 445 }
425 446
426 int rendered_width() { 447 int rendered_width() {
427 EXPECT_FALSE(fake_video_renderers_.empty()); 448 EXPECT_FALSE(fake_video_renderers_.empty());
428 return fake_video_renderers_.empty() 449 return fake_video_renderers_.empty()
429 ? 0 450 ? 0
430 : fake_video_renderers_.begin()->second->width(); 451 : fake_video_renderers_.begin()->second->width();
431 } 452 }
432 453
433 int rendered_height() { 454 int rendered_height() {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 callee_options)); 1113 callee_options));
1093 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer = 1114 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer =
1094 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); 1115 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>();
1095 caller()->pc()->RegisterUMAObserver(caller_observer); 1116 caller()->pc()->RegisterUMAObserver(caller_observer);
1096 ConnectFakeSignaling(); 1117 ConnectFakeSignaling();
1097 caller()->AddAudioVideoMediaStream(); 1118 caller()->AddAudioVideoMediaStream();
1098 callee()->AddAudioVideoMediaStream(); 1119 callee()->AddAudioVideoMediaStream();
1099 caller()->CreateAndSetAndSignalOffer(); 1120 caller()->CreateAndSetAndSignalOffer();
1100 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1121 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1101 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(expected_cipher_suite), 1122 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(expected_cipher_suite),
1102 caller()->GetStats()->SrtpCipher(), kDefaultTimeout); 1123 caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
1103 EXPECT_EQ( 1124 EXPECT_EQ(
1104 1, caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, 1125 1, caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher,
1105 expected_cipher_suite)); 1126 expected_cipher_suite));
1106 caller()->pc()->RegisterUMAObserver(nullptr); 1127 caller()->pc()->RegisterUMAObserver(nullptr);
1107 } 1128 }
1108 1129
1109 private: 1130 private:
1110 // |ss_| is used by |network_thread_| so it must be destroyed later. 1131 // |ss_| is used by |network_thread_| so it must be destroyed later.
1111 std::unique_ptr<rtc::PhysicalSocketServer> pss_; 1132 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
1112 std::unique_ptr<rtc::VirtualSocketServer> ss_; 1133 std::unique_ptr<rtc::VirtualSocketServer> ss_;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 // is needed to support legacy endpoints. 1715 // is needed to support legacy endpoints.
1695 // TODO(deadbeef): When we support the MID extension and demuxing on MID, also 1716 // TODO(deadbeef): When we support the MID extension and demuxing on MID, also
1696 // add a test for an end-to-end test without MID signaling either (basically, 1717 // add a test for an end-to-end test without MID signaling either (basically,
1697 // the minimum acceptable SDP). 1718 // the minimum acceptable SDP).
1698 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithoutSsrcOrMsidSignaling) { 1719 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithoutSsrcOrMsidSignaling) {
1699 ASSERT_TRUE(CreatePeerConnectionWrappers()); 1720 ASSERT_TRUE(CreatePeerConnectionWrappers());
1700 ConnectFakeSignaling(); 1721 ConnectFakeSignaling();
1701 // Add audio and video, testing that packets can be demuxed on payload type. 1722 // Add audio and video, testing that packets can be demuxed on payload type.
1702 caller()->AddAudioVideoMediaStream(); 1723 caller()->AddAudioVideoMediaStream();
1703 callee()->AddAudioVideoMediaStream(); 1724 callee()->AddAudioVideoMediaStream();
1704 // Remove all stream information (SSRCs, track IDs, etc.) and "msid-semantic" 1725 // Remove SSRCs and MSIDs from the received offer SDP.
1705 // attribute from received SDP, simulating a legacy endpoint. 1726 callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
1706 callee()->SetReceivedSdpMunger([](cricket::SessionDescription* desc) {
1707 for (ContentInfo& content : desc->contents()) {
1708 MediaContentDescription* media_desc =
1709 static_cast<MediaContentDescription*>(content.description);
1710 media_desc->mutable_streams().clear();
1711 }
1712 desc->set_msid_supported(false);
1713 });
1714 caller()->CreateAndSetAndSignalOffer(); 1727 caller()->CreateAndSetAndSignalOffer();
1715 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1728 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1716 ExpectNewFramesReceivedWithWait( 1729 ExpectNewFramesReceivedWithWait(
1717 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1730 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1718 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1731 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1719 kMaxWaitForFramesMs); 1732 kMaxWaitForFramesMs);
1720 } 1733 }
1721 1734
1722 // Test that if two video tracks are sent (from caller to callee, in this test), 1735 // Test that if two video tracks are sent (from caller to callee, in this test),
1723 // they're transmitted correctly end-to-end. 1736 // they're transmitted correctly end-to-end.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1793 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1781 ExpectNewFramesReceivedWithWait( 1794 ExpectNewFramesReceivedWithWait(
1782 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1795 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1783 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1796 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1784 kMaxWaitForFramesMs); 1797 kMaxWaitForFramesMs);
1785 } 1798 }
1786 1799
1787 // Test that we can receive the audio output level from a remote audio track. 1800 // Test that we can receive the audio output level from a remote audio track.
1788 // TODO(deadbeef): Use a fake audio source and verify that the output level is 1801 // TODO(deadbeef): Use a fake audio source and verify that the output level is
1789 // exactly what the source on the other side was configured with. 1802 // exactly what the source on the other side was configured with.
1790 TEST_F(PeerConnectionIntegrationTest, GetAudioOutputLevelStats) { 1803 TEST_F(PeerConnectionIntegrationTest, GetAudioOutputLevelStatsWithOldStatsApi) {
1791 ASSERT_TRUE(CreatePeerConnectionWrappers()); 1804 ASSERT_TRUE(CreatePeerConnectionWrappers());
1792 ConnectFakeSignaling(); 1805 ConnectFakeSignaling();
1793 // Just add an audio track. 1806 // Just add an audio track.
1794 caller()->AddMediaStreamFromTracks(caller()->CreateLocalAudioTrack(), 1807 caller()->AddMediaStreamFromTracks(caller()->CreateLocalAudioTrack(),
1795 nullptr); 1808 nullptr);
1796 caller()->CreateAndSetAndSignalOffer(); 1809 caller()->CreateAndSetAndSignalOffer();
1797 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1810 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1798 1811
1799 // Get the audio output level stats. Note that the level is not available 1812 // Get the audio output level stats. Note that the level is not available
1800 // until an RTCP packet has been received. 1813 // until an RTCP packet has been received.
1801 EXPECT_TRUE_WAIT(callee()->GetStats()->AudioOutputLevel() > 0, 1814 EXPECT_TRUE_WAIT(callee()->OldGetStats()->AudioOutputLevel() > 0,
1802 kMaxWaitForFramesMs); 1815 kMaxWaitForFramesMs);
1803 } 1816 }
1804 1817
1805 // Test that an audio input level is reported. 1818 // Test that an audio input level is reported.
1806 // TODO(deadbeef): Use a fake audio source and verify that the input level is 1819 // TODO(deadbeef): Use a fake audio source and verify that the input level is
1807 // exactly what the source was configured with. 1820 // exactly what the source was configured with.
1808 TEST_F(PeerConnectionIntegrationTest, GetAudioInputLevelStats) { 1821 TEST_F(PeerConnectionIntegrationTest, GetAudioInputLevelStatsWithOldStatsApi) {
1809 ASSERT_TRUE(CreatePeerConnectionWrappers()); 1822 ASSERT_TRUE(CreatePeerConnectionWrappers());
1810 ConnectFakeSignaling(); 1823 ConnectFakeSignaling();
1811 // Just add an audio track. 1824 // Just add an audio track.
1812 caller()->AddMediaStreamFromTracks(caller()->CreateLocalAudioTrack(), 1825 caller()->AddMediaStreamFromTracks(caller()->CreateLocalAudioTrack(),
1813 nullptr); 1826 nullptr);
1814 caller()->CreateAndSetAndSignalOffer(); 1827 caller()->CreateAndSetAndSignalOffer();
1815 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1828 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1816 1829
1817 // Get the audio input level stats. The level should be available very 1830 // Get the audio input level stats. The level should be available very
1818 // soon after the test starts. 1831 // soon after the test starts.
1819 EXPECT_TRUE_WAIT(caller()->GetStats()->AudioInputLevel() > 0, 1832 EXPECT_TRUE_WAIT(caller()->OldGetStats()->AudioInputLevel() > 0,
1820 kMaxWaitForStatsMs); 1833 kMaxWaitForStatsMs);
1821 } 1834 }
1822 1835
1823 // Test that we can get incoming byte counts from both audio and video tracks. 1836 // Test that we can get incoming byte counts from both audio and video tracks.
1824 TEST_F(PeerConnectionIntegrationTest, GetBytesReceivedStats) { 1837 TEST_F(PeerConnectionIntegrationTest, GetBytesReceivedStatsWithOldStatsApi) {
1825 ASSERT_TRUE(CreatePeerConnectionWrappers()); 1838 ASSERT_TRUE(CreatePeerConnectionWrappers());
1826 ConnectFakeSignaling(); 1839 ConnectFakeSignaling();
1827 caller()->AddAudioVideoMediaStream(); 1840 caller()->AddAudioVideoMediaStream();
1828 // Do offer/answer, wait for the callee to receive some frames. 1841 // Do offer/answer, wait for the callee to receive some frames.
1829 caller()->CreateAndSetAndSignalOffer(); 1842 caller()->CreateAndSetAndSignalOffer();
1830 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1843 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1831 int expected_caller_received_frames = 0; 1844 int expected_caller_received_frames = 0;
1832 ExpectNewFramesReceivedWithWait( 1845 ExpectNewFramesReceivedWithWait(
1833 expected_caller_received_frames, expected_caller_received_frames, 1846 expected_caller_received_frames, expected_caller_received_frames,
1834 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1847 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1835 kMaxWaitForFramesMs); 1848 kMaxWaitForFramesMs);
1836 1849
1837 // Get a handle to the remote tracks created, so they can be used as GetStats 1850 // Get a handle to the remote tracks created, so they can be used as GetStats
1838 // filters. 1851 // filters.
1839 StreamCollectionInterface* remote_streams = callee()->remote_streams(); 1852 StreamCollectionInterface* remote_streams = callee()->remote_streams();
1840 ASSERT_EQ(1u, remote_streams->count()); 1853 ASSERT_EQ(1u, remote_streams->count());
1841 ASSERT_EQ(1u, remote_streams->at(0)->GetAudioTracks().size()); 1854 ASSERT_EQ(1u, remote_streams->at(0)->GetAudioTracks().size());
1842 ASSERT_EQ(1u, remote_streams->at(0)->GetVideoTracks().size()); 1855 ASSERT_EQ(1u, remote_streams->at(0)->GetVideoTracks().size());
1843 MediaStreamTrackInterface* remote_audio_track = 1856 MediaStreamTrackInterface* remote_audio_track =
1844 remote_streams->at(0)->GetAudioTracks()[0]; 1857 remote_streams->at(0)->GetAudioTracks()[0];
1845 MediaStreamTrackInterface* remote_video_track = 1858 MediaStreamTrackInterface* remote_video_track =
1846 remote_streams->at(0)->GetVideoTracks()[0]; 1859 remote_streams->at(0)->GetVideoTracks()[0];
1847 1860
1848 // We received frames, so we definitely should have nonzero "received bytes" 1861 // We received frames, so we definitely should have nonzero "received bytes"
1849 // stats at this point. 1862 // stats at this point.
1850 EXPECT_GT(callee()->GetStatsForTrack(remote_audio_track)->BytesReceived(), 0); 1863 EXPECT_GT(callee()->OldGetStatsForTrack(remote_audio_track)->BytesReceived(),
1851 EXPECT_GT(callee()->GetStatsForTrack(remote_video_track)->BytesReceived(), 0); 1864 0);
1865 EXPECT_GT(callee()->OldGetStatsForTrack(remote_video_track)->BytesReceived(),
1866 0);
1852 } 1867 }
1853 1868
1854 // Test that we can get outgoing byte counts from both audio and video tracks. 1869 // Test that we can get outgoing byte counts from both audio and video tracks.
1855 TEST_F(PeerConnectionIntegrationTest, GetBytesSentStats) { 1870 TEST_F(PeerConnectionIntegrationTest, GetBytesSentStatsWithOldStatsApi) {
1856 ASSERT_TRUE(CreatePeerConnectionWrappers()); 1871 ASSERT_TRUE(CreatePeerConnectionWrappers());
1857 ConnectFakeSignaling(); 1872 ConnectFakeSignaling();
1858 auto audio_track = caller()->CreateLocalAudioTrack(); 1873 auto audio_track = caller()->CreateLocalAudioTrack();
1859 auto video_track = caller()->CreateLocalVideoTrack(); 1874 auto video_track = caller()->CreateLocalVideoTrack();
1860 caller()->AddMediaStreamFromTracks(audio_track, video_track); 1875 caller()->AddMediaStreamFromTracks(audio_track, video_track);
1861 // Do offer/answer, wait for the callee to receive some frames. 1876 // Do offer/answer, wait for the callee to receive some frames.
1862 caller()->CreateAndSetAndSignalOffer(); 1877 caller()->CreateAndSetAndSignalOffer();
1863 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1878 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1864 int expected_caller_received_frames = 0; 1879 int expected_caller_received_frames = 0;
1865 ExpectNewFramesReceivedWithWait( 1880 ExpectNewFramesReceivedWithWait(
1866 expected_caller_received_frames, expected_caller_received_frames, 1881 expected_caller_received_frames, expected_caller_received_frames,
1867 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 1882 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
1868 kMaxWaitForFramesMs); 1883 kMaxWaitForFramesMs);
1869 1884
1870 // The callee received frames, so we definitely should have nonzero "sent 1885 // The callee received frames, so we definitely should have nonzero "sent
1871 // bytes" stats at this point. 1886 // bytes" stats at this point.
1872 EXPECT_GT(caller()->GetStatsForTrack(audio_track)->BytesSent(), 0); 1887 EXPECT_GT(caller()->OldGetStatsForTrack(audio_track)->BytesSent(), 0);
1873 EXPECT_GT(caller()->GetStatsForTrack(video_track)->BytesSent(), 0); 1888 EXPECT_GT(caller()->OldGetStatsForTrack(video_track)->BytesSent(), 0);
1889 }
1890
1891 // Test that we can get stats (using the new stats implemnetation) for
1892 // unsignaled streams. Meaning when SSRCs/MSIDs aren't signaled explicitly in
1893 // SDP.
1894 TEST_F(PeerConnectionIntegrationTest,
1895 GetStatsForUnsignaledStreamWithNewStatsApi) {
1896 ASSERT_TRUE(CreatePeerConnectionWrappers());
1897 ConnectFakeSignaling();
1898 caller()->AddAudioOnlyMediaStream();
1899 // Remove SSRCs and MSIDs from the received offer SDP.
1900 callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
1901 caller()->CreateAndSetAndSignalOffer();
1902 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1903 // Wait for one audio frame to be received by the callee.
1904 ExpectNewFramesReceivedWithWait(0, 0, 1, 0, kMaxWaitForFramesMs);
1905
1906 // We received a frame, so we should have nonzero "bytes received" stats for
1907 // the unsignaled stream, if stats are working for it.
1908 rtc::scoped_refptr<const webrtc::RTCStatsReport> report =
1909 callee()->NewGetStats();
1910 ASSERT_NE(nullptr, report);
1911 auto inbound_stream_stats =
1912 report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>();
1913 ASSERT_EQ(1U, inbound_stream_stats.size());
1914 ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.is_defined());
1915 ASSERT_GT(*inbound_stream_stats[0]->bytes_received, 0U);
1916 // TODO(deadbeef): Test that track_id is defined. This is not currently
1917 // working since SSRCs are used to match RtpReceivers (and their tracks) with
1918 // received stream stats in TrackMediaInfoMap.
1874 } 1919 }
1875 1920
1876 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. 1921 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0.
1877 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { 1922 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) {
1878 PeerConnectionFactory::Options dtls_10_options; 1923 PeerConnectionFactory::Options dtls_10_options;
1879 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; 1924 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10;
1880 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, 1925 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options,
1881 dtls_10_options)); 1926 dtls_10_options));
1882 ConnectFakeSignaling(); 1927 ConnectFakeSignaling();
1883 // Do normal offer/answer and wait for some frames to be received in each 1928 // Do normal offer/answer and wait for some frames to be received in each
(...skipping 17 matching lines...) Expand all
1901 ConnectFakeSignaling(); 1946 ConnectFakeSignaling();
1902 // Register UMA observer before signaling begins. 1947 // Register UMA observer before signaling begins.
1903 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer = 1948 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer =
1904 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); 1949 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>();
1905 caller()->pc()->RegisterUMAObserver(caller_observer); 1950 caller()->pc()->RegisterUMAObserver(caller_observer);
1906 caller()->AddAudioVideoMediaStream(); 1951 caller()->AddAudioVideoMediaStream();
1907 callee()->AddAudioVideoMediaStream(); 1952 callee()->AddAudioVideoMediaStream();
1908 caller()->CreateAndSetAndSignalOffer(); 1953 caller()->CreateAndSetAndSignalOffer();
1909 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1954 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1910 EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher( 1955 EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher(
1911 caller()->GetStats()->DtlsCipher(), rtc::KT_DEFAULT), 1956 caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT),
1912 kDefaultTimeout); 1957 kDefaultTimeout);
1913 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), 1958 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite),
1914 caller()->GetStats()->SrtpCipher(), kDefaultTimeout); 1959 caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
1915 EXPECT_EQ(1, 1960 EXPECT_EQ(1,
1916 caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, 1961 caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher,
1917 kDefaultSrtpCryptoSuite)); 1962 kDefaultSrtpCryptoSuite));
1918 } 1963 }
1919 1964
1920 // Test getting cipher stats and UMA metrics when DTLS 1.2 is negotiated. 1965 // Test getting cipher stats and UMA metrics when DTLS 1.2 is negotiated.
1921 TEST_F(PeerConnectionIntegrationTest, Dtls12CipherStatsAndUmaMetrics) { 1966 TEST_F(PeerConnectionIntegrationTest, Dtls12CipherStatsAndUmaMetrics) {
1922 PeerConnectionFactory::Options dtls_12_options; 1967 PeerConnectionFactory::Options dtls_12_options;
1923 dtls_12_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; 1968 dtls_12_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
1924 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_12_options, 1969 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_12_options,
1925 dtls_12_options)); 1970 dtls_12_options));
1926 ConnectFakeSignaling(); 1971 ConnectFakeSignaling();
1927 // Register UMA observer before signaling begins. 1972 // Register UMA observer before signaling begins.
1928 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer = 1973 rtc::scoped_refptr<webrtc::FakeMetricsObserver> caller_observer =
1929 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); 1974 new rtc::RefCountedObject<webrtc::FakeMetricsObserver>();
1930 caller()->pc()->RegisterUMAObserver(caller_observer); 1975 caller()->pc()->RegisterUMAObserver(caller_observer);
1931 caller()->AddAudioVideoMediaStream(); 1976 caller()->AddAudioVideoMediaStream();
1932 callee()->AddAudioVideoMediaStream(); 1977 callee()->AddAudioVideoMediaStream();
1933 caller()->CreateAndSetAndSignalOffer(); 1978 caller()->CreateAndSetAndSignalOffer();
1934 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 1979 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1935 EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher( 1980 EXPECT_TRUE_WAIT(rtc::SSLStreamAdapter::IsAcceptableCipher(
1936 caller()->GetStats()->DtlsCipher(), rtc::KT_DEFAULT), 1981 caller()->OldGetStats()->DtlsCipher(), rtc::KT_DEFAULT),
1937 kDefaultTimeout); 1982 kDefaultTimeout);
1938 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), 1983 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite),
1939 caller()->GetStats()->SrtpCipher(), kDefaultTimeout); 1984 caller()->OldGetStats()->SrtpCipher(), kDefaultTimeout);
1940 EXPECT_EQ(1, 1985 EXPECT_EQ(1,
1941 caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, 1986 caller_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher,
1942 kDefaultSrtpCryptoSuite)); 1987 kDefaultSrtpCryptoSuite));
1943 } 1988 }
1944 1989
1945 // Test that DTLS 1.0 can be used if the caller supports DTLS 1.2 and the 1990 // Test that DTLS 1.0 can be used if the caller supports DTLS 1.2 and the
1946 // callee only supports 1.0. 1991 // callee only supports 1.0.
1947 TEST_F(PeerConnectionIntegrationTest, CallerDtls12ToCalleeDtls10) { 1992 TEST_F(PeerConnectionIntegrationTest, CallerDtls12ToCalleeDtls10) {
1948 PeerConnectionFactory::Options caller_options; 1993 PeerConnectionFactory::Options caller_options;
1949 caller_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; 1994 caller_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2758 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, 2803 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
2759 kMaxWaitForFramesMs); 2804 kMaxWaitForFramesMs);
2760 } 2805 }
2761 2806
2762 TEST_F(PeerConnectionIntegrationTest, GetSources) { 2807 TEST_F(PeerConnectionIntegrationTest, GetSources) {
2763 ASSERT_TRUE(CreatePeerConnectionWrappers()); 2808 ASSERT_TRUE(CreatePeerConnectionWrappers());
2764 ConnectFakeSignaling(); 2809 ConnectFakeSignaling();
2765 caller()->AddAudioOnlyMediaStream(); 2810 caller()->AddAudioOnlyMediaStream();
2766 caller()->CreateAndSetAndSignalOffer(); 2811 caller()->CreateAndSetAndSignalOffer();
2767 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 2812 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
2768 // Wait for one audio frame received by callee. 2813 // Wait for one audio frame to be received by the callee.
2769 ExpectNewFramesReceivedWithWait(0, 0, 1, 0, kMaxWaitForFramesMs); 2814 ExpectNewFramesReceivedWithWait(0, 0, 1, 0, kMaxWaitForFramesMs);
2770 ASSERT_GT(callee()->pc()->GetReceivers().size(), 0u); 2815 ASSERT_GT(callee()->pc()->GetReceivers().size(), 0u);
2771 auto receiver = callee()->pc()->GetReceivers()[0]; 2816 auto receiver = callee()->pc()->GetReceivers()[0];
2772 ASSERT_EQ(receiver->media_type(), cricket::MEDIA_TYPE_AUDIO); 2817 ASSERT_EQ(receiver->media_type(), cricket::MEDIA_TYPE_AUDIO);
2773 2818
2774 auto contributing_sources = receiver->GetSources(); 2819 auto contributing_sources = receiver->GetSources();
2775 ASSERT_GT(receiver->GetParameters().encodings.size(), 0u); 2820 ASSERT_GT(receiver->GetParameters().encodings.size(), 0u);
2776 EXPECT_EQ(receiver->GetParameters().encodings[0].ssrc, 2821 EXPECT_EQ(receiver->GetParameters().encodings[0].ssrc,
2777 contributing_sources[0].source_id()); 2822 contributing_sources[0].source_id());
2778 } 2823 }
(...skipping 26 matching lines...) Expand all
2805 caller()->CreateAndSetAndSignalOffer(); 2850 caller()->CreateAndSetAndSignalOffer();
2806 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 2851 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
2807 // Wait for additional audio frames to be received by the callee. 2852 // Wait for additional audio frames to be received by the callee.
2808 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, 2853 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0,
2809 kMaxWaitForFramesMs); 2854 kMaxWaitForFramesMs);
2810 } 2855 }
2811 2856
2812 } // namespace 2857 } // namespace
2813 2858
2814 #endif // if !defined(THREAD_SANITIZER) 2859 #endif // if !defined(THREAD_SANITIZER)
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/test/mockpeerconnectionobservers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698