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

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

Issue 2883943003: Add media related stats (audio level etc.) to unsignaled streams. (Closed)
Patch Set: Fix the bug related to the unsignaled video track. Modified the test. Created 3 years, 7 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/trackmediainfomap.cc » ('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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // attribute from received SDP, simulating a legacy endpoint. 109 // attribute from received SDP, simulating a legacy endpoint.
110 void RemoveSsrcsAndMsids(cricket::SessionDescription* desc) { 110 void RemoveSsrcsAndMsids(cricket::SessionDescription* desc) {
111 for (ContentInfo& content : desc->contents()) { 111 for (ContentInfo& content : desc->contents()) {
112 MediaContentDescription* media_desc = 112 MediaContentDescription* media_desc =
113 static_cast<MediaContentDescription*>(content.description); 113 static_cast<MediaContentDescription*>(content.description);
114 media_desc->mutable_streams().clear(); 114 media_desc->mutable_streams().clear();
115 } 115 }
116 desc->set_msid_supported(false); 116 desc->set_msid_supported(false);
117 } 117 }
118 118
119 int FindFirstMediaStatsIndexByKind(
120 const std::string& kind,
121 const std::vector<const webrtc::RTCMediaStreamTrackStats*>&
122 media_stats_vec) {
123 for (size_t i = 0; i < media_stats_vec.size(); i++) {
124 if (media_stats_vec[i]->kind.ValueToString() == kind) {
125 return i;
126 }
127 }
128 return -1;
129 }
130
119 class SignalingMessageReceiver { 131 class SignalingMessageReceiver {
120 public: 132 public:
121 virtual void ReceiveSdpMessage(const std::string& type, 133 virtual void ReceiveSdpMessage(const std::string& type,
122 const std::string& msg) = 0; 134 const std::string& msg) = 0;
123 virtual void ReceiveIceMessage(const std::string& sdp_mid, 135 virtual void ReceiveIceMessage(const std::string& sdp_mid,
124 int sdp_mline_index, 136 int sdp_mline_index,
125 const std::string& msg) = 0; 137 const std::string& msg) = 0;
126 138
127 protected: 139 protected:
128 SignalingMessageReceiver() {} 140 SignalingMessageReceiver() {}
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 // We received a frame, so we should have nonzero "bytes received" stats for 1931 // We received a frame, so we should have nonzero "bytes received" stats for
1920 // the unsignaled stream, if stats are working for it. 1932 // the unsignaled stream, if stats are working for it.
1921 rtc::scoped_refptr<const webrtc::RTCStatsReport> report = 1933 rtc::scoped_refptr<const webrtc::RTCStatsReport> report =
1922 callee()->NewGetStats(); 1934 callee()->NewGetStats();
1923 ASSERT_NE(nullptr, report); 1935 ASSERT_NE(nullptr, report);
1924 auto inbound_stream_stats = 1936 auto inbound_stream_stats =
1925 report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>(); 1937 report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>();
1926 ASSERT_EQ(1U, inbound_stream_stats.size()); 1938 ASSERT_EQ(1U, inbound_stream_stats.size());
1927 ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.is_defined()); 1939 ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.is_defined());
1928 ASSERT_GT(*inbound_stream_stats[0]->bytes_received, 0U); 1940 ASSERT_GT(*inbound_stream_stats[0]->bytes_received, 0U);
1929 // TODO(deadbeef): Test that track_id is defined. This is not currently 1941 ASSERT_TRUE(inbound_stream_stats[0]->track_id.is_defined());
1930 // working since SSRCs are used to match RtpReceivers (and their tracks) with 1942 }
1931 // received stream stats in TrackMediaInfoMap. 1943
1944 // Test that we can successfully get the media related stats (audio level
1945 // etc.) for the unsignaled stream.
1946 TEST_F(PeerConnectionIntegrationTest,
1947 GetMediaStatsForUnsignaledStreamWithNewStatsApi) {
1948 ASSERT_TRUE(CreatePeerConnectionWrappers());
1949 ConnectFakeSignaling();
1950 caller()->AddAudioVideoMediaStream();
1951 // Remove SSRCs and MSIDs from the received offer SDP.
1952 callee()->SetReceivedSdpMunger(RemoveSsrcsAndMsids);
1953 caller()->CreateAndSetAndSignalOffer();
1954 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
1955 // Wait for one audio frame to be received by the callee.
1956 ExpectNewFramesReceivedWithWait(0, 0, 1, 1, kMaxWaitForFramesMs);
1957
1958 rtc::scoped_refptr<const webrtc::RTCStatsReport> report =
1959 callee()->NewGetStats();
1960 ASSERT_NE(nullptr, report);
1961
1962 auto media_stats = report->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>();
1963 auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats);
1964 ASSERT_GE(audio_index, 0);
1965 EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined());
1932 } 1966 }
1933 1967
1934 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0. 1968 // Test that DTLS 1.0 is used if both sides only support DTLS 1.0.
1935 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) { 1969 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithDtls10) {
1936 PeerConnectionFactory::Options dtls_10_options; 1970 PeerConnectionFactory::Options dtls_10_options;
1937 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; 1971 dtls_10_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10;
1938 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options, 1972 ASSERT_TRUE(CreatePeerConnectionWrappersWithOptions(dtls_10_options,
1939 dtls_10_options)); 1973 dtls_10_options));
1940 ConnectFakeSignaling(); 1974 ConnectFakeSignaling();
1941 // Do normal offer/answer and wait for some frames to be received in each 1975 // Do normal offer/answer and wait for some frames to be received in each
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 caller()->CreateAndSetAndSignalOffer(); 2936 caller()->CreateAndSetAndSignalOffer();
2903 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); 2937 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
2904 // Wait for additional audio frames to be received by the callee. 2938 // Wait for additional audio frames to be received by the callee.
2905 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, 2939 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0,
2906 kMaxWaitForFramesMs); 2940 kMaxWaitForFramesMs);
2907 } 2941 }
2908 2942
2909 } // namespace 2943 } // namespace
2910 2944
2911 #endif // if !defined(THREAD_SANITIZER) 2945 #endif // if !defined(THREAD_SANITIZER)
OLDNEW
« no previous file with comments | « no previous file | webrtc/pc/trackmediainfomap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698