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

Unified Diff: webrtc/api/rtpsender.cc

Issue 1894283002: Fixing a segfault that can occur when changing the track of an RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/api/rtpsenderreceiver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/rtpsender.cc
diff --git a/webrtc/api/rtpsender.cc b/webrtc/api/rtpsender.cc
index 58cb18c6cd2734e5bc37df470c5a3ba121abd401..360b6868fd377b99e1f64fdeb21bead5d7b490df 100644
--- a/webrtc/api/rtpsender.cc
+++ b/webrtc/api/rtpsender.cc
@@ -122,6 +122,9 @@ bool AudioRtpSender::SetTrack(MediaStreamTrackInterface* track) {
// Attach to new track.
bool prev_can_send_track = can_send_track();
+ // Keep a reference to the old track to keep it alive until we call
+ // SetAudioSend.
+ rtc::scoped_refptr<AudioTrackInterface> old_track = track_;
track_ = audio_track;
if (track_) {
cached_track_enabled_ = track_->enabled();
@@ -276,6 +279,9 @@ bool VideoRtpSender::SetTrack(MediaStreamTrackInterface* track) {
// Attach to new track.
bool prev_can_send_track = can_send_track();
+ // Keep a reference to the old track to keep it alive until we call
+ // SetSource.
+ rtc::scoped_refptr<VideoTrackInterface> old_track = track_;
track_ = video_track;
if (track_) {
cached_track_enabled_ = track_->enabled();
« no previous file with comments | « no previous file | webrtc/api/rtpsenderreceiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698