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

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

Issue 2883943003: Add media related stats (audio level etc.) to unsignaled streams. (Closed)
Patch Set: 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
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 12 matching lines...) Expand all
60 RTC_DCHECK(local_audio_track_by_ssrc->find(ssrc) == 62 RTC_DCHECK(local_audio_track_by_ssrc->find(ssrc) ==
61 local_audio_track_by_ssrc->end()); 63 local_audio_track_by_ssrc->end());
62 (*local_audio_track_by_ssrc)[ssrc] = 64 (*local_audio_track_by_ssrc)[ssrc] =
63 static_cast<AudioTrackInterface*>(track); 65 static_cast<AudioTrackInterface*>(track);
64 } else { 66 } else {
65 RTC_DCHECK(local_video_track_by_ssrc->find(ssrc) == 67 RTC_DCHECK(local_video_track_by_ssrc->find(ssrc) ==
66 local_video_track_by_ssrc->end()); 68 local_video_track_by_ssrc->end());
67 (*local_video_track_by_ssrc)[ssrc] = 69 (*local_video_track_by_ssrc)[ssrc] =
68 static_cast<VideoTrackInterface*>(track); 70 static_cast<VideoTrackInterface*>(track);
69 } 71 }
72 } else {
73 if (media_type == cricket::MEDIA_TYPE_VIDEO) {
74 *unsignaled_video_track = static_cast<VideoTrackInterface*>(track);
75 }
70 } 76 }
71 } 77 }
72 for (const rtc::scoped_refptr<RtpReceiverInterface>& rtp_receiver : 78 for (const rtc::scoped_refptr<RtpReceiverInterface>& rtp_receiver :
73 rtp_receivers) { 79 rtp_receivers) {
74 cricket::MediaType media_type = rtp_receiver->media_type(); 80 cricket::MediaType media_type = rtp_receiver->media_type();
75 MediaStreamTrackInterface* track = rtp_receiver->track(); 81 MediaStreamTrackInterface* track = rtp_receiver->track();
76 RTC_DCHECK(track); 82 RTC_DCHECK(track);
77 RTC_DCHECK_EQ(track->kind(), media_type == cricket::MEDIA_TYPE_AUDIO 83 RTC_DCHECK_EQ(track->kind(), media_type == cricket::MEDIA_TYPE_AUDIO
78 ? MediaStreamTrackInterface::kAudioKind 84 ? MediaStreamTrackInterface::kAudioKind
79 : MediaStreamTrackInterface::kVideoKind); 85 : MediaStreamTrackInterface::kVideoKind);
80 RtpParameters params = rtp_receiver->GetParameters(); 86 RtpParameters params = rtp_receiver->GetParameters();
81 for (const RtpEncodingParameters& encoding : params.encodings) { 87 for (const RtpEncodingParameters& encoding : params.encodings) {
82 if (!encoding.ssrc) { 88 if (!encoding.ssrc) {
89 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
90 *unsignaled_audio_track = static_cast<AudioTrackInterface*>(track);
91 }
83 continue; 92 continue;
84 } 93 }
85 if (media_type == cricket::MEDIA_TYPE_AUDIO) { 94 if (media_type == cricket::MEDIA_TYPE_AUDIO) {
86 RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) == 95 RTC_DCHECK(remote_audio_track_by_ssrc->find(*encoding.ssrc) ==
87 remote_audio_track_by_ssrc->end()); 96 remote_audio_track_by_ssrc->end());
88 (*remote_audio_track_by_ssrc)[*encoding.ssrc] = 97 (*remote_audio_track_by_ssrc)[*encoding.ssrc] =
89 static_cast<AudioTrackInterface*>(track); 98 static_cast<AudioTrackInterface*>(track);
90 } else { 99 } else {
91 RTC_DCHECK(remote_video_track_by_ssrc->find(*encoding.ssrc) == 100 RTC_DCHECK(remote_video_track_by_ssrc->find(*encoding.ssrc) ==
92 remote_video_track_by_ssrc->end()); 101 remote_video_track_by_ssrc->end());
(...skipping 10 matching lines...) Expand all
103 std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info, 112 std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info,
104 std::unique_ptr<cricket::VideoMediaInfo> video_media_info, 113 std::unique_ptr<cricket::VideoMediaInfo> video_media_info,
105 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders, 114 const std::vector<rtc::scoped_refptr<RtpSenderInterface>>& rtp_senders,
106 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers) 115 const std::vector<rtc::scoped_refptr<RtpReceiverInterface>>& rtp_receivers)
107 : voice_media_info_(std::move(voice_media_info)), 116 : voice_media_info_(std::move(voice_media_info)),
108 video_media_info_(std::move(video_media_info)) { 117 video_media_info_(std::move(video_media_info)) {
109 std::map<uint32_t, AudioTrackInterface*> local_audio_track_by_ssrc; 118 std::map<uint32_t, AudioTrackInterface*> local_audio_track_by_ssrc;
110 std::map<uint32_t, VideoTrackInterface*> local_video_track_by_ssrc; 119 std::map<uint32_t, VideoTrackInterface*> local_video_track_by_ssrc;
111 std::map<uint32_t, AudioTrackInterface*> remote_audio_track_by_ssrc; 120 std::map<uint32_t, AudioTrackInterface*> remote_audio_track_by_ssrc;
112 std::map<uint32_t, VideoTrackInterface*> remote_video_track_by_ssrc; 121 std::map<uint32_t, VideoTrackInterface*> remote_video_track_by_ssrc;
113 GetAudioAndVideoTrackBySsrc(rtp_senders, 122 AudioTrackInterface* unsignaled_audio_track = nullptr;
114 rtp_receivers, 123 VideoTrackInterface* unsignaled_video_track = nullptr;
115 &local_audio_track_by_ssrc, 124 GetAudioAndVideoTrackBySsrc(
116 &local_video_track_by_ssrc, 125 rtp_senders, rtp_receivers, &local_audio_track_by_ssrc,
117 &remote_audio_track_by_ssrc, 126 &local_video_track_by_ssrc, &remote_audio_track_by_ssrc,
118 &remote_video_track_by_ssrc); 127 &remote_video_track_by_ssrc, &unsignaled_audio_track,
128 &unsignaled_video_track);
119 if (voice_media_info_) { 129 if (voice_media_info_) {
120 for (auto& sender_info : voice_media_info_->senders) { 130 for (auto& sender_info : voice_media_info_->senders) {
121 AudioTrackInterface* associated_track = 131 AudioTrackInterface* associated_track =
122 FindValueOrNull(local_audio_track_by_ssrc, sender_info.ssrc()); 132 FindValueOrNull(local_audio_track_by_ssrc, sender_info.ssrc());
123 if (associated_track) { 133 if (associated_track) {
124 // One sender is associated with at most one track. 134 // One sender is associated with at most one track.
125 // One track may be associated with multiple senders. 135 // One track may be associated with multiple senders.
126 audio_track_by_sender_info_[&sender_info] = associated_track; 136 audio_track_by_sender_info_[&sender_info] = associated_track;
127 voice_infos_by_local_track_[associated_track].push_back(&sender_info); 137 voice_infos_by_local_track_[associated_track].push_back(&sender_info);
128 } 138 }
129 } 139 }
130 for (auto& receiver_info : voice_media_info_->receivers) { 140 for (auto& receiver_info : voice_media_info_->receivers) {
131 AudioTrackInterface* associated_track = 141 AudioTrackInterface* associated_track =
132 FindValueOrNull(remote_audio_track_by_ssrc, receiver_info.ssrc()); 142 FindValueOrNull(remote_audio_track_by_ssrc, receiver_info.ssrc());
133 if (associated_track) { 143 if (associated_track) {
134 // One receiver is associated with at most one track, which is uniquely 144 // One receiver is associated with at most one track, which is uniquely
135 // associated with that receiver. 145 // associated with that receiver.
136 audio_track_by_receiver_info_[&receiver_info] = associated_track; 146 audio_track_by_receiver_info_[&receiver_info] = associated_track;
137 RTC_DCHECK(voice_info_by_remote_track_.find(associated_track) == 147 RTC_DCHECK(voice_info_by_remote_track_.find(associated_track) ==
138 voice_info_by_remote_track_.end()); 148 voice_info_by_remote_track_.end());
139 voice_info_by_remote_track_[associated_track] = &receiver_info; 149 voice_info_by_remote_track_[associated_track] = &receiver_info;
150 } else if (unsignaled_audio_track) {
151 audio_track_by_receiver_info_[&receiver_info] = unsignaled_audio_track;
152 voice_info_by_remote_track_[unsignaled_audio_track] = &receiver_info;
140 } 153 }
141 } 154 }
142 } 155 }
143 if (video_media_info_) { 156 if (video_media_info_) {
144 for (auto& sender_info : video_media_info_->senders) { 157 for (auto& sender_info : video_media_info_->senders) {
145 VideoTrackInterface* associated_track = 158 VideoTrackInterface* associated_track =
146 FindValueOrNull(local_video_track_by_ssrc, sender_info.ssrc()); 159 FindValueOrNull(local_video_track_by_ssrc, sender_info.ssrc());
147 if (associated_track) { 160 if (associated_track) {
148 // One sender is associated with at most one track. 161 // One sender is associated with at most one track.
149 // One track may be associated with multiple senders. 162 // One track may be associated with multiple senders.
150 video_track_by_sender_info_[&sender_info] = associated_track; 163 video_track_by_sender_info_[&sender_info] = associated_track;
151 video_infos_by_local_track_[associated_track].push_back(&sender_info); 164 video_infos_by_local_track_[associated_track].push_back(&sender_info);
152 } 165 }
153 } 166 }
154 for (auto& receiver_info : video_media_info_->receivers) { 167 for (auto& receiver_info : video_media_info_->receivers) {
155 VideoTrackInterface* associated_track = 168 VideoTrackInterface* associated_track =
156 FindValueOrNull(remote_video_track_by_ssrc, receiver_info.ssrc()); 169 FindValueOrNull(remote_video_track_by_ssrc, receiver_info.ssrc());
157 if (associated_track) { 170 if (associated_track) {
158 // One receiver is associated with at most one track, which is uniquely 171 // One receiver is associated with at most one track, which is uniquely
159 // associated with that receiver. 172 // associated with that receiver.
160 video_track_by_receiver_info_[&receiver_info] = associated_track; 173 video_track_by_receiver_info_[&receiver_info] = associated_track;
161 RTC_DCHECK(video_info_by_remote_track_.find(associated_track) == 174 RTC_DCHECK(video_info_by_remote_track_.find(associated_track) ==
162 video_info_by_remote_track_.end()); 175 video_info_by_remote_track_.end());
163 video_info_by_remote_track_[associated_track] = &receiver_info; 176 video_info_by_remote_track_[associated_track] = &receiver_info;
177 } else if (unsignaled_video_track) {
178 video_track_by_receiver_info_[&receiver_info] = unsignaled_video_track;
179 video_info_by_remote_track_[unsignaled_video_track] = &receiver_info;
164 } 180 }
165 } 181 }
166 } 182 }
167 } 183 }
168 184
169 const std::vector<cricket::VoiceSenderInfo*>* 185 const std::vector<cricket::VoiceSenderInfo*>*
170 TrackMediaInfoMap::GetVoiceSenderInfos( 186 TrackMediaInfoMap::GetVoiceSenderInfos(
171 const AudioTrackInterface& local_audio_track) const { 187 const AudioTrackInterface& local_audio_track) const {
172 return FindAddressOrNull(voice_infos_by_local_track_, &local_audio_track); 188 return FindAddressOrNull(voice_infos_by_local_track_, &local_audio_track);
173 } 189 }
(...skipping 28 matching lines...) Expand all
202 const cricket::VideoSenderInfo& video_sender_info) const { 218 const cricket::VideoSenderInfo& video_sender_info) const {
203 return FindValueOrNull(video_track_by_sender_info_, &video_sender_info); 219 return FindValueOrNull(video_track_by_sender_info_, &video_sender_info);
204 } 220 }
205 221
206 rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack( 222 rtc::scoped_refptr<VideoTrackInterface> TrackMediaInfoMap::GetVideoTrack(
207 const cricket::VideoReceiverInfo& video_receiver_info) const { 223 const cricket::VideoReceiverInfo& video_receiver_info) const {
208 return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info); 224 return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info);
209 } 225 }
210 226
211 } // namespace webrtc 227 } // namespace webrtc
OLDNEW
« webrtc/pc/peerconnection_integrationtest.cc ('K') | « webrtc/pc/peerconnection_integrationtest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698