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

Side by Side Diff: talk/app/webrtc/peerconnection.h

Issue 1469833006: Fixing issue with default stream upon setting 2nd remote description. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moving default stream logic into UpdateRemoteStreamsList. Created 5 years 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 | talk/app/webrtc/peerconnection.cc » ('j') | talk/app/webrtc/peerconnection.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 protected: 151 protected:
152 ~PeerConnection() override; 152 ~PeerConnection() override;
153 153
154 private: 154 private:
155 struct TrackInfo { 155 struct TrackInfo {
156 TrackInfo() : ssrc(0) {} 156 TrackInfo() : ssrc(0) {}
157 TrackInfo(const std::string& stream_label, 157 TrackInfo(const std::string& stream_label,
158 const std::string track_id, 158 const std::string track_id,
159 uint32_t ssrc) 159 uint32_t ssrc)
160 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} 160 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
161 bool operator==(const TrackInfo& other) {
162 return this->stream_label == other.stream_label &&
163 this->track_id == other.track_id && this->ssrc == other.ssrc;
164 }
161 std::string stream_label; 165 std::string stream_label;
162 std::string track_id; 166 std::string track_id;
163 uint32_t ssrc; 167 uint32_t ssrc;
164 }; 168 };
165 typedef std::vector<TrackInfo> TrackInfos; 169 typedef std::vector<TrackInfo> TrackInfos;
166 170
167 struct RemotePeerInfo {
168 RemotePeerInfo()
169 : msid_supported(false),
170 default_audio_track_needed(false),
171 default_video_track_needed(false) {}
172 // True if it has been discovered that the remote peer support MSID.
173 bool msid_supported;
174 // The remote peer indicates in the session description that audio will be
175 // sent but no MSID is given.
176 bool default_audio_track_needed;
177 // The remote peer indicates in the session description that video will be
178 // sent but no MSID is given.
179 bool default_video_track_needed;
180
181 bool IsDefaultMediaStreamNeeded() {
182 return !msid_supported &&
183 (default_audio_track_needed || default_video_track_needed);
184 }
185 };
186
187 // Implements MessageHandler. 171 // Implements MessageHandler.
188 void OnMessage(rtc::Message* msg) override; 172 void OnMessage(rtc::Message* msg) override;
189 173
190 void CreateAudioReceiver(MediaStreamInterface* stream, 174 void CreateAudioReceiver(MediaStreamInterface* stream,
191 AudioTrackInterface* audio_track, 175 AudioTrackInterface* audio_track,
192 uint32_t ssrc); 176 uint32_t ssrc);
193 void CreateVideoReceiver(MediaStreamInterface* stream, 177 void CreateVideoReceiver(MediaStreamInterface* stream,
194 VideoTrackInterface* video_track, 178 VideoTrackInterface* video_track,
195 uint32_t ssrc); 179 uint32_t ssrc);
196 void DestroyAudioReceiver(MediaStreamInterface* stream, 180 void DestroyAudioReceiver(MediaStreamInterface* stream,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Returns a MediaSessionOptions struct with options decided by 227 // Returns a MediaSessionOptions struct with options decided by
244 // |constraints|, the local MediaStreams and DataChannels. 228 // |constraints|, the local MediaStreams and DataChannels.
245 virtual bool GetOptionsForAnswer( 229 virtual bool GetOptionsForAnswer(
246 const MediaConstraintsInterface* constraints, 230 const MediaConstraintsInterface* constraints,
247 cricket::MediaSessionOptions* session_options); 231 cricket::MediaSessionOptions* session_options);
248 232
249 // Remove all local and remote tracks of type |media_type|. 233 // Remove all local and remote tracks of type |media_type|.
250 // Called when a media type is rejected (m-line set to port 0). 234 // Called when a media type is rejected (m-line set to port 0).
251 void RemoveTracks(cricket::MediaType media_type); 235 void RemoveTracks(cricket::MediaType media_type);
252 236
253 // Makes sure a MediaStream Track is created for each StreamParam in 237 // Makes sure a MediaStreamTrack is created for each StreamParam in
254 // |streams|. |media_type| is the type of the |streams| and can be either 238 // |streams|. If |default_track_needed| is true create a default
255 // audio or video. 239 // MediaStreamTrack. |media_type| is the type of the |streams| and can be
pthatcher1 2015/12/03 20:07:40 Then perhaps a better name would be create_default
Taylor Brandstetter 2015/12/04 22:04:54 But an existing default track will be destroyed if
240 // either audio or video.
256 // If a new MediaStream is created it is added to |new_streams|. 241 // If a new MediaStream is created it is added to |new_streams|.
257 void UpdateRemoteStreamsList( 242 void UpdateRemoteStreamsList(
258 const std::vector<cricket::StreamParams>& streams, 243 const std::vector<cricket::StreamParams>& streams,
244 bool default_track_needed,
259 cricket::MediaType media_type, 245 cricket::MediaType media_type,
260 StreamCollection* new_streams); 246 StreamCollection* new_streams);
261 247
262 // Triggered when a remote track has been seen for the first time in a remote 248 // Triggered when a remote track has been seen for the first time in a remote
263 // session description. It creates a remote MediaStreamTrackInterface 249 // session description. It creates a remote MediaStreamTrackInterface
264 // implementation and triggers CreateAudioReceiver or CreateVideoReceiver. 250 // implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
265 void OnRemoteTrackSeen(const std::string& stream_label, 251 void OnRemoteTrackSeen(const std::string& stream_label,
266 const std::string& track_id, 252 const std::string& track_id,
267 uint32_t ssrc, 253 uint32_t ssrc,
268 cricket::MediaType media_type); 254 cricket::MediaType media_type);
269 255
270 // Triggered when a remote track has been removed from a remote session 256 // Triggered when a remote track has been removed from a remote session
271 // description. It removes the remote track with id |track_id| from a remote 257 // description. It removes the remote track with id |track_id| from a remote
272 // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver. 258 // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
273 void OnRemoteTrackRemoved(const std::string& stream_label, 259 void OnRemoteTrackRemoved(const std::string& stream_label,
274 const std::string& track_id, 260 const std::string& track_id,
275 cricket::MediaType media_type); 261 cricket::MediaType media_type);
276 262
277 // Finds remote MediaStreams without any tracks and removes them from 263 // Finds remote MediaStreams without any tracks and removes them from
278 // |remote_streams_| and notifies the observer that the MediaStreams no longer 264 // |remote_streams_| and notifies the observer that the MediaStreams no longer
279 // exist. 265 // exist.
280 void UpdateEndedRemoteMediaStreams(); 266 void UpdateEndedRemoteMediaStreams();
281 267
282 void MaybeCreateDefaultStream();
283
284 // Set the MediaStreamTrackInterface::TrackState to |kEnded| on all remote 268 // Set the MediaStreamTrackInterface::TrackState to |kEnded| on all remote
285 // tracks of type |media_type|. 269 // tracks of type |media_type|.
286 void EndRemoteTracks(cricket::MediaType media_type); 270 void EndRemoteTracks(cricket::MediaType media_type);
287 271
288 // Loops through the vector of |streams| and finds added and removed 272 // Loops through the vector of |streams| and finds added and removed
289 // StreamParams since last time this method was called. 273 // StreamParams since last time this method was called.
290 // For each new or removed StreamParam, OnLocalTrackSeen or 274 // For each new or removed StreamParam, OnLocalTrackSeen or
291 // OnLocalTrackRemoved is invoked. 275 // OnLocalTrackRemoved is invoked.
292 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams, 276 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams,
293 cricket::MediaType media_type); 277 cricket::MediaType media_type);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 TrackInfos remote_audio_tracks_; 368 TrackInfos remote_audio_tracks_;
385 TrackInfos remote_video_tracks_; 369 TrackInfos remote_video_tracks_;
386 TrackInfos local_audio_tracks_; 370 TrackInfos local_audio_tracks_;
387 TrackInfos local_video_tracks_; 371 TrackInfos local_video_tracks_;
388 372
389 SctpSidAllocator sid_allocator_; 373 SctpSidAllocator sid_allocator_;
390 // label -> DataChannel 374 // label -> DataChannel
391 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_; 375 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
392 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_; 376 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
393 377
394 RemotePeerInfo remote_info_; 378 // True if it has been discovered that the remote peer supports MSID.
379 bool remote_peer_msid_supported_ = false;
pthatcher1 2015/12/03 20:07:40 Perhaps a better name would be remote_peer_support
Taylor Brandstetter 2015/12/04 22:04:54 Done.
395 rtc::scoped_ptr<RemoteMediaStreamFactory> remote_stream_factory_; 380 rtc::scoped_ptr<RemoteMediaStreamFactory> remote_stream_factory_;
396 381
397 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_; 382 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_;
398 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_; 383 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_;
399 384
400 // The session_ scoped_ptr is declared at the bottom of PeerConnection 385 // The session_ scoped_ptr is declared at the bottom of PeerConnection
401 // because its destruction fires signals (such as VoiceChannelDestroyed) 386 // because its destruction fires signals (such as VoiceChannelDestroyed)
402 // which will trigger some final actions in PeerConnection... 387 // which will trigger some final actions in PeerConnection...
403 rtc::scoped_ptr<WebRtcSession> session_; 388 rtc::scoped_ptr<WebRtcSession> session_;
404 // ... But stats_ depends on session_ so it should be destroyed even earlier. 389 // ... But stats_ depends on session_ so it should be destroyed even earlier.
405 rtc::scoped_ptr<StatsCollector> stats_; 390 rtc::scoped_ptr<StatsCollector> stats_;
406 }; 391 };
407 392
408 } // namespace webrtc 393 } // namespace webrtc
409 394
410 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ 395 #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/peerconnection.cc » ('j') | talk/app/webrtc/peerconnection.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698