| OLD | NEW |
| 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 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 stream->AddTrack( | 1479 stream->AddTrack( |
| 1480 static_cast<VideoTrackInterface*>(receiver->internal()->track().get())); | 1480 static_cast<VideoTrackInterface*>(receiver->internal()->track().get())); |
| 1481 receivers_.push_back(receiver); | 1481 receivers_.push_back(receiver); |
| 1482 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; | 1482 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; |
| 1483 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); | 1483 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); |
| 1484 observer_->OnAddTrack(receiver, streams); | 1484 observer_->OnAddTrack(receiver, streams); |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote | 1487 // TODO(deadbeef): Keep RtpReceivers around even if track goes away in remote |
| 1488 // description. | 1488 // description. |
| 1489 void PeerConnection::DestroyReceiver(const std::string& track_id) { | 1489 void PeerConnection::DestroyReceiver(MediaStreamInterface* stream, |
| 1490 const std::string& track_id) { |
| 1490 auto it = FindReceiverForTrack(track_id); | 1491 auto it = FindReceiverForTrack(track_id); |
| 1491 if (it == receivers_.end()) { | 1492 if (it == receivers_.end()) { |
| 1492 LOG(LS_WARNING) << "RtpReceiver for track with id " << track_id | 1493 LOG(LS_WARNING) << "RtpReceiver for track with id " << track_id |
| 1493 << " doesn't exist."; | 1494 << " doesn't exist."; |
| 1494 } else { | 1495 } else { |
| 1496 rtc::scoped_refptr<RtpReceiverInterface> receiver(*it); |
| 1497 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams; |
| 1498 streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream)); |
| 1499 |
| 1495 (*it)->internal()->Stop(); | 1500 (*it)->internal()->Stop(); |
| 1496 receivers_.erase(it); | 1501 receivers_.erase(it); |
| 1502 |
| 1503 observer_->OnRemoveTrack(receiver, streams); |
| 1497 } | 1504 } |
| 1498 } | 1505 } |
| 1499 | 1506 |
| 1500 void PeerConnection::AddAudioTrack(AudioTrackInterface* track, | 1507 void PeerConnection::AddAudioTrack(AudioTrackInterface* track, |
| 1501 MediaStreamInterface* stream) { | 1508 MediaStreamInterface* stream) { |
| 1502 RTC_DCHECK(!IsClosed()); | 1509 RTC_DCHECK(!IsClosed()); |
| 1503 auto sender = FindSenderForTrack(track); | 1510 auto sender = FindSenderForTrack(track); |
| 1504 if (sender != senders_.end()) { | 1511 if (sender != senders_.end()) { |
| 1505 // We already have a sender for this track, so just change the stream_id | 1512 // We already have a sender for this track, so just change the stream_id |
| 1506 // so that it's correct in the next call to CreateOffer. | 1513 // so that it's correct in the next call to CreateOffer. |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 } | 1917 } |
| 1911 | 1918 |
| 1912 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, | 1919 void PeerConnection::OnRemoteTrackRemoved(const std::string& stream_label, |
| 1913 const std::string& track_id, | 1920 const std::string& track_id, |
| 1914 cricket::MediaType media_type) { | 1921 cricket::MediaType media_type) { |
| 1915 MediaStreamInterface* stream = remote_streams_->find(stream_label); | 1922 MediaStreamInterface* stream = remote_streams_->find(stream_label); |
| 1916 | 1923 |
| 1917 if (media_type == cricket::MEDIA_TYPE_AUDIO) { | 1924 if (media_type == cricket::MEDIA_TYPE_AUDIO) { |
| 1918 // When the MediaEngine audio channel is destroyed, the RemoteAudioSource | 1925 // When the MediaEngine audio channel is destroyed, the RemoteAudioSource |
| 1919 // will be notified which will end the AudioRtpReceiver::track(). | 1926 // will be notified which will end the AudioRtpReceiver::track(). |
| 1920 DestroyReceiver(track_id); | 1927 DestroyReceiver(stream, track_id); |
| 1921 rtc::scoped_refptr<AudioTrackInterface> audio_track = | 1928 rtc::scoped_refptr<AudioTrackInterface> audio_track = |
| 1922 stream->FindAudioTrack(track_id); | 1929 stream->FindAudioTrack(track_id); |
| 1923 if (audio_track) { | 1930 if (audio_track) { |
| 1924 stream->RemoveTrack(audio_track); | 1931 stream->RemoveTrack(audio_track); |
| 1925 } | 1932 } |
| 1926 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 1933 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
| 1927 // Stopping or destroying a VideoRtpReceiver will end the | 1934 // Stopping or destroying a VideoRtpReceiver will end the |
| 1928 // VideoRtpReceiver::track(). | 1935 // VideoRtpReceiver::track(). |
| 1929 DestroyReceiver(track_id); | 1936 DestroyReceiver(stream, track_id); |
| 1930 rtc::scoped_refptr<VideoTrackInterface> video_track = | 1937 rtc::scoped_refptr<VideoTrackInterface> video_track = |
| 1931 stream->FindVideoTrack(track_id); | 1938 stream->FindVideoTrack(track_id); |
| 1932 if (video_track) { | 1939 if (video_track) { |
| 1933 // There's no guarantee the track is still available, e.g. the track may | 1940 // There's no guarantee the track is still available, e.g. the track may |
| 1934 // have been removed from the stream by an application. | 1941 // have been removed from the stream by an application. |
| 1935 stream->RemoveTrack(video_track); | 1942 stream->RemoveTrack(video_track); |
| 1936 } | 1943 } |
| 1937 } else { | 1944 } else { |
| 1938 RTC_NOTREACHED() << "Invalid media type"; | 1945 RTC_NOTREACHED() << "Invalid media type"; |
| 1939 } | 1946 } |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 return event_log_->StartLogging(file, max_size_bytes); | 2438 return event_log_->StartLogging(file, max_size_bytes); |
| 2432 } | 2439 } |
| 2433 | 2440 |
| 2434 void PeerConnection::StopRtcEventLog_w() { | 2441 void PeerConnection::StopRtcEventLog_w() { |
| 2435 if (event_log_) { | 2442 if (event_log_) { |
| 2436 event_log_->StopLogging(); | 2443 event_log_->StopLogging(); |
| 2437 } | 2444 } |
| 2438 } | 2445 } |
| 2439 | 2446 |
| 2440 } // namespace webrtc | 2447 } // namespace webrtc |
| OLD | NEW |