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

Side by Side Diff: webrtc/pc/trackmediainfomap.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 | « webrtc/pc/peerconnection_integrationtest.cc ('k') | no next file » | 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 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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
27 auto it = map.find(key); 27 auto it = map.find(key);
28 return (it != map.end()) ? &it->second : nullptr; 28 return (it != map.end()) ? &it->second : nullptr;
29 } 29 }
30 30
31 void GetAudioAndVideoTrackBySsrc( 31 void GetAudioAndVideoTrackBySsrc(
32 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders, 32 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders,
33 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers, 33 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers,
34 std::map<uint32_t, AudioTrackInterface*>* local_audio_track_by_ssrc, 34 std::map<uint32_t, AudioTrackInterface*>* local_audio_track_by_ssrc,
35 std::map<uint32_t, VideoTrackInterface*>* local_video_track_by_ssrc, 35 std::map<uint32_t, VideoTrackInterface*>* local_video_track_by_ssrc,
36 std::map<uint32_t, AudioTrackInterface*>* remote_audio_track_by_ssrc, 36 std::map<uint32_t, AudioTrackInterface*>* remote_audio_track_by_ssrc,
37 std::map<uint32_t, VideoTrackInterface*>* remote_video_track_by_ssrc) { 37 std::map<uint32_t, VideoTrackInterface*>* remote_video_track_by_ssrc,
38 AudioTrackInterface** unsignaled_audio_track,
39 VideoTrackInterface** unsignaled_video_track) {
38 RTC_DCHECK(local_audio_track_by_ssrc->empty()); 40 RTC_DCHECK(local_audio_track_by_ssrc->empty());
39 RTC_DCHECK(local_video_track_by_ssrc->empty()); 41 RTC_DCHECK(local_video_track_by_ssrc->empty());
40 RTC_DCHECK(remote_audio_track_by_ssrc->empty()); 42 RTC_DCHECK(remote_audio_track_by_ssrc->empty());
41 RTC_DCHECK(remote_video_track_by_ssrc->empty()); 43 RTC_DCHECK(remote_video_track_by_ssrc->empty());
42 // TODO(hbos): RTP senders/receivers uses a proxy to the signaling thread, and 44 // TODO(hbos): RTP senders/receivers uses a proxy to the signaling thread, and
43 // our sender/receiver implementations invokes on the worker thread. (This 45 // our sender/receiver implementations invokes on the worker thread. (This
44 // means one thread jump if on signaling thread and two thread jumps if on any 46 // means one thread jump if on signaling thread and two thread jumps if on any
45 // other threads). Is there a way to avoid thread jump(s) on a per 47 // other threads). Is there a way to avoid thread jump(s) on a per
46 // sender/receiver, per method basis? 48 // sender/receiver, per method basis?
47 for (const rtc::scoped_refptr<RtpSenderInterface>& rtp_sender : rtp_senders) { 49 for (const rtc::scoped_refptr<RtpSenderInterface>& rtp_sender : rtp_senders) {
(...skipping 25 matching lines...) Expand all
73 rtp_receivers) { 75 rtp_receivers) {
74 cricket::MediaType media_type = rtp_receiver->media_type(); 76 cricket::MediaType media_type = rtp_receiver->media_type();
75 MediaStreamTrackInterface* track = rtp_receiver->track(); 77 MediaStreamTrackInterface* track = rtp_receiver->track();
76 RTC_DCHECK(track); 78 RTC_DCHECK(track);
77 RTC_DCHECK_EQ(track->kind(), media_type == cricket::MEDIA_TYPE_AUDIO 79 RTC_DCHECK_EQ(track->kind(), media_type == cricket::MEDIA_TYPE_AUDIO
78 ? MediaStreamTrackInterface::kAudioKind 80 ? MediaStreamTrackInterface::kAudioKind
79 : MediaStreamTrackInterface::kVideoKind); 81 : MediaStreamTrackInterface::kVideoKind);
80 RtpParameters params = rtp_receiver->GetParameters(); 82 RtpParameters params = rtp_receiver->GetParameters();
81 for (const RtpEncodingParameters& encoding : params.encodings) { 83 for (const RtpEncodingParameters& encoding : params.encodings) {
82 if (!encoding.ssrc) { 84 if (!encoding.ssrc) {
85 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
86 *unsignaled_audio_track = static_cast<AudioTrackInterface*>(track);
87 } else {
88 RTC_DCHECK(media_type == cricket::MEDIA_TYPE_VIDEO);
89 *unsignaled_video_track = static_cast<VideoTrackInterface*>(track);
90 }
83 continue; 91 continue;
84 } 92 }
85 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 93 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
86 RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) == 94 RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) ==
87 remote_audio_track_by_ssrc->end()); 95 remote_audio_track_by_ssrc->end());
88 (*remote_audio_track_by_ssrc)[*encoding.ssrc] = 96 (*remote_audio_track_by_ssrc)[*encoding.ssrc] =
89 static_cast<AudioTrackInterface*>(track); 97 static_cast<AudioTrackInterface*>(track);
90 } else { 98 } else {
91 RTC_DCHECK(remote_video_track_by_ssrc->find(*encoding.ssrc) == 99 RTC_DCHECK(remote_video_track_by_ssrc->find(*encoding.ssrc) ==
92 remote_video_track_by_ssrc->end()); 100 remote_video_track_by_ssrc->end());
(...skipping 10 matching lines...) Expand all
103 std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info, 111 std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info,
104 std::unique_ptr<cricket::VideoMediaInfo> video_media_info, 112 std::unique_ptr<cricket::VideoMediaInfo> video_media_info,
105 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders, 113 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders,
106 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers) 114 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers)
107 : voice_media_info_(std::move(voice_media_info)), 115 : voice_media_info_(std::move(voice_media_info)),
108 video_media_info_(std::move(video_media_info)) { 116 video_media_info_(std::move(video_media_info)) {
109 std::map<uint32_t, AudioTrackInterface*> local_audio_track_by_ssrc; 117 std::map<uint32_t, AudioTrackInterface*> local_audio_track_by_ssrc;
110 std::map<uint32_t, VideoTrackInterface*> local_video_track_by_ssrc; 118 std::map<uint32_t, VideoTrackInterface*> local_video_track_by_ssrc;
111 std::map<uint32_t, AudioTrackInterface*> remote_audio_track_by_ssrc; 119 std::map<uint32_t, AudioTrackInterface*> remote_audio_track_by_ssrc;
112 std::map<uint32_t, VideoTrackInterface*> remote_video_track_by_ssrc; 120 std::map<uint32_t, VideoTrackInterface*> remote_video_track_by_ssrc;
113 GetAudioAndVideoTrackBySsrc(rtp_senders, 121 AudioTrackInterface* unsignaled_audio_track = nullptr;
114 rtp_receivers, 122 VideoTrackInterface* unsignaled_video_track = nullptr;
115 &local_audio_track_by_ssrc, 123 GetAudioAndVideoTrackBySsrc(
116 &local_video_track_by_ssrc, 124 rtp_senders, rtp_receivers, &local_audio_track_by_ssrc,
117 &remote_audio_track_by_ssrc, 125 &local_video_track_by_ssrc, &remote_audio_track_by_ssrc,
118 &remote_video_track_by_ssrc); 126 &remote_video_track_by_ssrc, &unsignaled_audio_track,
127 &unsignaled_video_track);
119 if (voice_media_info_) { 128 if (voice_media_info_) {
120 for (auto& sender_info : voice_media_info_->senders) { 129 for (auto& sender_info : voice_media_info_->senders) {
121 AudioTrackInterface* associated_track = 130 AudioTrackInterface* associated_track =
122 FindValueOrNull(local_audio_track_by_ssrc, sender_info.ssrc()); 131 FindValueOrNull(local_audio_track_by_ssrc, sender_info.ssrc());
123 if (associated_track) { 132 if (associated_track) {
124 // One sender is associated with at most one track. 133 // One sender is associated with at most one track.
125 // One track may be associated with multiple senders. 134 // One track may be associated with multiple senders.
126 audio_track_by_sender_info_[&sender_info] = associated_track; 135 audio_track_by_sender_info_[&sender_info] = associated_track;
127 voice_infos_by_local_track_[associated_track].push_back(&sender_info); 136 voice_infos_by_local_track_[associated_track].push_back(&sender_info);
128 } 137 }
129 } 138 }
130 for (auto& receiver_info : voice_media_info_->receivers) { 139 for (auto& receiver_info : voice_media_info_->receivers) {
131 AudioTrackInterface* associated_track = 140 AudioTrackInterface* associated_track =
132 FindValueOrNull(remote_audio_track_by_ssrc, receiver_info.ssrc()); 141 FindValueOrNull(remote_audio_track_by_ssrc, receiver_info.ssrc());
133 if (associated_track) { 142 if (associated_track) {
134 // One receiver is associated with at most one track, which is uniquely 143 // One receiver is associated with at most one track, which is uniquely
135 // associated with that receiver. 144 // associated with that receiver.
136 audio_track_by_receiver_info_[&receiver_info] = associated_track; 145 audio_track_by_receiver_info_[&receiver_info] = associated_track;
137 RTC_DCHECK(voice_info_by_remote_track_.find(associated_track) == 146 RTC_DCHECK(voice_info_by_remote_track_.find(associated_track) ==
138 voice_info_by_remote_track_.end()); 147 voice_info_by_remote_track_.end());
139 voice_info_by_remote_track_[associated_track] = &receiver_info; 148 voice_info_by_remote_track_[associated_track] = &receiver_info;
149 } else if (unsignaled_audio_track) {
150 audio_track_by_receiver_info_[&receiver_info] = unsignaled_audio_track;
151 voice_info_by_remote_track_[unsignaled_audio_track] = &receiver_info;
140 } 152 }
141 } 153 }
142 } 154 }
143 if (video_media_info_) { 155 if (video_media_info_) {
144 for (auto& sender_info : video_media_info_->senders) { 156 for (auto& sender_info : video_media_info_->senders) {
145 VideoTrackInterface* associated_track = 157 VideoTrackInterface* associated_track =
146 FindValueOrNull(local_video_track_by_ssrc, sender_info.ssrc()); 158 FindValueOrNull(local_video_track_by_ssrc, sender_info.ssrc());
147 if (associated_track) { 159 if (associated_track) {
148 // One sender is associated with at most one track. 160 // One sender is associated with at most one track.
149 // One track may be associated with multiple senders. 161 // One track may be associated with multiple senders.
150 video_track_by_sender_info_[&sender_info] = associated_track; 162 video_track_by_sender_info_[&sender_info] = associated_track;
151 video_infos_by_local_track_[associated_track].push_back(&sender_info); 163 video_infos_by_local_track_[associated_track].push_back(&sender_info);
152 } 164 }
153 } 165 }
154 for (auto& receiver_info : video_media_info_->receivers) { 166 for (auto& receiver_info : video_media_info_->receivers) {
155 VideoTrackInterface* associated_track = 167 VideoTrackInterface* associated_track =
156 FindValueOrNull(remote_video_track_by_ssrc, receiver_info.ssrc()); 168 FindValueOrNull(remote_video_track_by_ssrc, receiver_info.ssrc());
157 if (associated_track) { 169 if (associated_track) {
158 // One receiver is associated with at most one track, which is uniquely 170 // One receiver is associated with at most one track, which is uniquely
159 // associated with that receiver. 171 // associated with that receiver.
160 video_track_by_receiver_info_[&receiver_info] = associated_track; 172 video_track_by_receiver_info_[&receiver_info] = associated_track;
161 RTC_DCHECK(video_info_by_remote_track_.find(associated_track) == 173 RTC_DCHECK(video_info_by_remote_track_.find(associated_track) ==
162 video_info_by_remote_track_.end()); 174 video_info_by_remote_track_.end());
163 video_info_by_remote_track_[associated_track] = &receiver_info; 175 video_info_by_remote_track_[associated_track] = &receiver_info;
176 } else if (unsignaled_video_track) {
177 video_track_by_receiver_info_[&receiver_info] = unsignaled_video_track;
178 video_info_by_remote_track_[unsignaled_video_track] = &receiver_info;
164 } 179 }
165 } 180 }
166 } 181 }
167 } 182 }
168 183
169 const std::vector<cricket::VoiceSenderInfo*>* 184 const std::vector<cricket::VoiceSenderInfo*>*
170 TrackMediaInfoMap::GetVoiceSenderInfos( 185 TrackMediaInfoMap::GetVoiceSenderInfos(
171 const AudioTrackInterface& local_audio_track) const { 186 const AudioTrackInterface& local_audio_track) const {
172 return FindAddressOrNull(voice_infos_by_local_track_, &local_audio_track); 187 return FindAddressOrNull(voice_infos_by_local_track_, &local_audio_track);
173 } 188 }
(...skipping 28 matching lines...) Expand all
202 const cricket::VideoSenderInfo& video_sender_info) const { 217 const cricket::VideoSenderInfo& video_sender_info) const {
203 return FindValueOrNull(video_track_by_sender_info_, &video_sender_info); 218 return FindValueOrNull(video_track_by_sender_info_, &video_sender_info);
204 } 219 }
205 220
206 rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack( 221 rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack(
207 const cricket::VideoReceiverInfo& video_receiver_info) const { 222 const cricket::VideoReceiverInfo& video_receiver_info) const {
208 return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info); 223 return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info);
209 } 224 }
210 225
211 } // namespace webrtc 226 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnection_integrationtest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698