PSA: c++ API for MediaStream.AddTrack / RemoveTrack has changed

59 views
Skip to first unread message

Harald Alvestrand

unread,
Apr 21, 2022, 8:36:50 AMApr 21
to discuss...@googlegroups.com
If you don't use the WebRTC C++ API, you can stop reading now.
If you don't use the MediaStream API, you can stop reading now.

The webrtc::MediaStream API is changing the type of two methods (in two versions each):
OLD:

  virtual bool AddTrack(AudioTrackInterface* track) = 0;
  virtual bool AddTrack(VideoTrackInterface* track) = 0;
  virtual bool RemoveTrack(AudioTrackInterface* track) = 0;
  virtual bool RemoveTrack(VideoTrackInterface* track) = 0;

NEW:

  virtual bool AddTrack(rtc::scoped_refptr<AudioTrackInterface> track) 
  virtual bool AddTrack(rtc::scoped_refptr<VideoTrackInterface> track) 
  virtual bool RemoveTrack(rtc::scoped_refptr<AudioTrackInterface> track) 
  virtual bool RemoveTrack(rtc::scoped_refptr<VideoTrackInterface> track) 

This better reflects the fact that AddTrack() takes shared ownership of the track; the change
to RemoveTrack() is done mainly for symmetry.

The old API will be in place for at least a couple of weeks, to give callers time to adapt.


Harald
Reply all
Reply to author
Forward
0 new messages