Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 // Triggered when the remote SessionDescription removes a stream. | 60 // Triggered when the remote SessionDescription removes a stream. |
| 61 virtual void OnRemoveRemoteStream(MediaStreamInterface* stream) = 0; | 61 virtual void OnRemoveRemoteStream(MediaStreamInterface* stream) = 0; |
| 62 | 62 |
| 63 // Triggered when the remote SessionDescription has a new data channel. | 63 // Triggered when the remote SessionDescription has a new data channel. |
| 64 virtual void OnAddDataChannel(DataChannelInterface* data_channel) = 0; | 64 virtual void OnAddDataChannel(DataChannelInterface* data_channel) = 0; |
| 65 | 65 |
| 66 // Triggered when the remote SessionDescription has a new audio track. | 66 // Triggered when the remote SessionDescription has a new audio track. |
| 67 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, | 67 virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, |
| 68 AudioTrackInterface* audio_track, | 68 AudioTrackInterface* audio_track, |
| 69 uint32 ssrc) = 0; | 69 uint32 ssrc, |
| 70 const std::string& mid) = 0; | |
|
pthatcher1
2015/09/17 04:25:46
I don't see how MID is even useful here. I think
Taylor Brandstetter
2015/09/23 00:10:45
It's not useful right now. It's just something I k
| |
| 70 | 71 |
| 71 // Triggered when the remote SessionDescription has a new video track. | 72 // Triggered when the remote SessionDescription has a new video track. |
| 72 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, | 73 virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, |
| 73 VideoTrackInterface* video_track, | 74 VideoTrackInterface* video_track, |
| 74 uint32 ssrc) = 0; | 75 uint32 ssrc, |
| 76 const std::string& mid) = 0; | |
| 75 | 77 |
| 76 // Triggered when the remote SessionDescription has removed an audio track. | 78 // Triggered when the remote SessionDescription has removed an audio track. |
| 77 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, | 79 virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, |
| 78 AudioTrackInterface* audio_track) = 0; | 80 AudioTrackInterface* audio_track) = 0; |
| 79 | 81 |
| 80 // Triggered when the remote SessionDescription has removed a video track. | 82 // Triggered when the remote SessionDescription has removed a video track. |
| 81 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, | 83 virtual void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, |
| 82 VideoTrackInterface* video_track) = 0; | 84 VideoTrackInterface* video_track) = 0; |
| 83 | 85 |
| 84 // Triggered when the local SessionDescription has a new audio track. | 86 // Triggered when the local SessionDescription has a new audio track. |
| 85 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, | 87 virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, |
| 86 AudioTrackInterface* audio_track, | 88 AudioTrackInterface* audio_track, |
| 87 uint32 ssrc) = 0; | 89 uint32 ssrc, |
| 90 const std::string& mid) = 0; | |
| 88 | 91 |
| 89 // Triggered when the local SessionDescription has a new video track. | 92 // Triggered when the local SessionDescription has a new video track. |
| 90 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, | 93 virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, |
| 91 VideoTrackInterface* video_track, | 94 VideoTrackInterface* video_track, |
| 92 uint32 ssrc) = 0; | 95 uint32 ssrc, |
| 96 const std::string& mid) = 0; | |
| 93 | 97 |
| 94 // Triggered when the local SessionDescription has removed an audio track. | 98 // Triggered when the local SessionDescription has removed an audio track. |
| 95 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, | 99 virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, |
| 96 AudioTrackInterface* audio_track, | 100 AudioTrackInterface* audio_track, |
| 97 uint32 ssrc) = 0; | 101 uint32 ssrc) = 0; |
| 98 | 102 |
| 99 // Triggered when the local SessionDescription has removed a video track. | 103 // Triggered when the local SessionDescription has removed a video track. |
| 100 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, | 104 virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, |
| 101 VideoTrackInterface* video_track) = 0; | 105 VideoTrackInterface* video_track) = 0; |
| 102 | 106 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 } | 273 } |
| 270 // True if it has been discovered that the remote peer support MSID. | 274 // True if it has been discovered that the remote peer support MSID. |
| 271 bool msid_supported; | 275 bool msid_supported; |
| 272 // The remote peer indicates in the session description that audio will be | 276 // The remote peer indicates in the session description that audio will be |
| 273 // sent but no MSID is given. | 277 // sent but no MSID is given. |
| 274 bool default_audio_track_needed; | 278 bool default_audio_track_needed; |
| 275 // The remote peer indicates in the session description that video will be | 279 // The remote peer indicates in the session description that video will be |
| 276 // sent but no MSID is given. | 280 // sent but no MSID is given. |
| 277 bool default_video_track_needed; | 281 bool default_video_track_needed; |
| 278 | 282 |
| 283 // mid strings associated with the empty audio/video content descriptions. | |
| 284 std::string default_audio_mid; | |
| 285 std::string default_video_mid; | |
| 286 | |
| 279 bool IsDefaultMediaStreamNeeded() { | 287 bool IsDefaultMediaStreamNeeded() { |
| 280 return !msid_supported && (default_audio_track_needed || | 288 return !msid_supported && (default_audio_track_needed || |
| 281 default_video_track_needed); | 289 default_video_track_needed); |
| 282 } | 290 } |
| 283 }; | 291 }; |
| 284 | 292 |
| 285 struct TrackInfo { | 293 struct TrackInfo { |
| 286 TrackInfo() : ssrc(0) {} | 294 TrackInfo() : ssrc(0) {} |
| 287 TrackInfo(const std::string& stream_label, | 295 TrackInfo(const std::string& stream_label, |
| 288 const std::string track_id, | 296 const std::string track_id, |
| 289 uint32 ssrc) | 297 uint32 ssrc, |
| 298 const std::string& mid) | |
| 290 : stream_label(stream_label), | 299 : stream_label(stream_label), |
| 291 track_id(track_id), | 300 track_id(track_id), |
| 292 ssrc(ssrc) { | 301 ssrc(ssrc), |
| 293 } | 302 mid(mid) {} |
| 294 std::string stream_label; | 303 std::string stream_label; |
| 295 std::string track_id; | 304 std::string track_id; |
| 296 uint32 ssrc; | 305 uint32 ssrc; |
| 306 std::string mid; | |
| 297 }; | 307 }; |
| 298 typedef std::vector<TrackInfo> TrackInfos; | 308 typedef std::vector<TrackInfo> TrackInfos; |
| 299 | 309 |
| 300 // Makes sure a MediaStream Track is created for each StreamParam in | 310 // Makes sure a MediaStream Track is created for each StreamParam in |
| 301 // |streams|. |media_type| is the type of the |streams| and can be either | 311 // |streams|. |media_type| is the type of the |streams| and can be either |
| 302 // audio or video. | 312 // audio or video. |
| 303 // If a new MediaStream is created it is added to |new_streams|. | 313 // If a new MediaStream is created it is added to |new_streams|. |
| 304 void UpdateRemoteStreamsList( | 314 void UpdateRemoteStreamsList( |
| 305 const std::vector<cricket::StreamParams>& streams, | 315 const std::vector<cricket::StreamParams>& streams, |
| 306 cricket::MediaType media_type, | 316 cricket::MediaType media_type, |
| 317 const std::string& mid, | |
| 307 StreamCollection* new_streams); | 318 StreamCollection* new_streams); |
| 308 | 319 |
| 309 // Triggered when a remote track has been seen for the first time in a remote | 320 // Triggered when a remote track has been seen for the first time in a remote |
| 310 // session description. It creates a remote MediaStreamTrackInterface | 321 // session description. It creates a remote MediaStreamTrackInterface |
| 311 // implementation and triggers MediaStreamSignaling::OnAddRemoteAudioTrack or | 322 // implementation and triggers MediaStreamSignaling::OnAddRemoteAudioTrack or |
| 312 // MediaStreamSignaling::OnAddRemoteVideoTrack. | 323 // MediaStreamSignaling::OnAddRemoteVideoTrack. |
| 313 void OnRemoteTrackSeen(const std::string& stream_label, | 324 void OnRemoteTrackSeen(const std::string& stream_label, |
| 314 const std::string& track_id, | 325 const std::string& track_id, |
| 315 uint32 ssrc, | 326 uint32 ssrc, |
| 316 cricket::MediaType media_type); | 327 cricket::MediaType media_type, |
| 328 const std::string& mid); | |
| 317 | 329 |
| 318 // Triggered when a remote track has been removed from a remote session | 330 // Triggered when a remote track has been removed from a remote session |
| 319 // description. It removes the remote track with id |track_id| from a remote | 331 // description. It removes the remote track with id |track_id| from a remote |
| 320 // MediaStream and triggers MediaStreamSignaling::OnRemoveRemoteAudioTrack or | 332 // MediaStream and triggers MediaStreamSignaling::OnRemoveRemoteAudioTrack or |
| 321 // MediaStreamSignaling::OnRemoveRemoteVideoTrack. | 333 // MediaStreamSignaling::OnRemoveRemoteVideoTrack. |
| 322 void OnRemoteTrackRemoved(const std::string& stream_label, | 334 void OnRemoteTrackRemoved(const std::string& stream_label, |
| 323 const std::string& track_id, | 335 const std::string& track_id, |
| 324 cricket::MediaType media_type); | 336 cricket::MediaType media_type); |
| 325 | 337 |
| 326 // Set the MediaStreamTrackInterface::TrackState to |kEnded| on all remote | 338 // Set the MediaStreamTrackInterface::TrackState to |kEnded| on all remote |
| 327 // tracks of type |media_type|. | 339 // tracks of type |media_type|. |
| 328 void RejectRemoteTracks(cricket::MediaType media_type); | 340 void RejectRemoteTracks(cricket::MediaType media_type); |
| 329 | 341 |
| 330 // Finds remote MediaStreams without any tracks and removes them from | 342 // Finds remote MediaStreams without any tracks and removes them from |
| 331 // |remote_streams_| and notifies the observer that the MediaStream no longer | 343 // |remote_streams_| and notifies the observer that the MediaStream no longer |
| 332 // exist. | 344 // exist. |
| 333 void UpdateEndedRemoteMediaStreams(); | 345 void UpdateEndedRemoteMediaStreams(); |
| 334 void MaybeCreateDefaultStream(); | 346 void MaybeCreateDefaultStream(); |
| 335 TrackInfos* GetRemoteTracks(cricket::MediaType type); | 347 TrackInfos* GetRemoteTracks(cricket::MediaType type); |
| 336 | 348 |
| 337 // Returns a map of currently negotiated LocalTrackInfo of type |type|. | 349 // Returns a map of currently negotiated LocalTrackInfo of type |type|. |
| 338 TrackInfos* GetLocalTracks(cricket::MediaType type); | 350 TrackInfos* GetLocalTracks(cricket::MediaType type); |
| 339 bool FindLocalTrack(const std::string& track_id, cricket::MediaType type); | 351 bool FindLocalTrack(const std::string& track_id, cricket::MediaType type); |
| 340 | 352 |
| 341 // Loops through the vector of |streams| and finds added and removed | 353 // Loops through the vector of |streams| and finds added and removed |
| 342 // StreamParams since last time this method was called. | 354 // StreamParams since last time this method was called. |
| 343 // For each new or removed StreamParam NotifyLocalTrackAdded or | 355 // For each new or removed StreamParam NotifyLocalTrackAdded or |
| 344 // NotifyLocalTrackRemoved in invoked. | 356 // NotifyLocalTrackRemoved in invoked. |
| 345 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams, | 357 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams, |
| 346 cricket::MediaType media_type); | 358 cricket::MediaType media_type, |
| 359 const std::string& mid); | |
| 347 | 360 |
| 348 // Triggered when a local track has been seen for the first time in a local | 361 // Triggered when a local track has been seen for the first time in a local |
| 349 // session description. | 362 // session description. |
| 350 // This method triggers MediaStreamSignaling::OnAddLocalAudioTrack or | 363 // This method triggers MediaStreamSignaling::OnAddLocalAudioTrack or |
| 351 // MediaStreamSignaling::OnAddLocalVideoTrack if the rtp streams in the local | 364 // MediaStreamSignaling::OnAddLocalVideoTrack if the rtp streams in the local |
| 352 // SessionDescription can be mapped to a MediaStreamTrack in a MediaStream in | 365 // SessionDescription can be mapped to a MediaStreamTrack in a MediaStream in |
| 353 // |local_streams_| | 366 // |local_streams_| |
| 354 void OnLocalTrackSeen(const std::string& stream_label, | 367 void OnLocalTrackSeen(const std::string& stream_label, |
| 355 const std::string& track_id, | 368 const std::string& track_id, |
| 356 uint32 ssrc, | 369 uint32 ssrc, |
| 357 cricket::MediaType media_type); | 370 cricket::MediaType media_type, |
| 371 const std::string& mid); | |
| 358 | 372 |
| 359 // Triggered when a local track has been removed from a local session | 373 // Triggered when a local track has been removed from a local session |
| 360 // description. | 374 // description. |
| 361 // This method triggers MediaStreamSignaling::OnRemoveLocalAudioTrack or | 375 // This method triggers MediaStreamSignaling::OnRemoveLocalAudioTrack or |
| 362 // MediaStreamSignaling::OnRemoveLocalVideoTrack if a stream has been removed | 376 // MediaStreamSignaling::OnRemoveLocalVideoTrack if a stream has been removed |
| 363 // from the local SessionDescription and the stream can be mapped to a | 377 // from the local SessionDescription and the stream can be mapped to a |
| 364 // MediaStreamTrack in a MediaStream in |local_streams_|. | 378 // MediaStreamTrack in a MediaStream in |local_streams_|. |
| 365 void OnLocalTrackRemoved(const std::string& stream_label, | 379 void OnLocalTrackRemoved(const std::string& stream_label, |
| 366 const std::string& track_id, | 380 const std::string& track_id, |
| 367 uint32 ssrc, | 381 uint32 ssrc, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 397 int last_allocated_sctp_even_sid_; | 411 int last_allocated_sctp_even_sid_; |
| 398 int last_allocated_sctp_odd_sid_; | 412 int last_allocated_sctp_odd_sid_; |
| 399 | 413 |
| 400 RtpDataChannels rtp_data_channels_; | 414 RtpDataChannels rtp_data_channels_; |
| 401 SctpDataChannels sctp_data_channels_; | 415 SctpDataChannels sctp_data_channels_; |
| 402 }; | 416 }; |
| 403 | 417 |
| 404 } // namespace webrtc | 418 } // namespace webrtc |
| 405 | 419 |
| 406 #endif // TALK_APP_WEBRTC_MEDIASTREAMSIGNALING_H_ | 420 #endif // TALK_APP_WEBRTC_MEDIASTREAMSIGNALING_H_ |
| OLD | NEW |