Index: webrtc/api/mediastreaminterface.h |
diff --git a/webrtc/api/mediastreaminterface.h b/webrtc/api/mediastreaminterface.h |
index a52f0c76455e0daeeff445b3c4a1822bdf7c8833..59ca66c865bfd3ec3bb67da451dc6a8a171ee343 100644 |
--- a/webrtc/api/mediastreaminterface.h |
+++ b/webrtc/api/mediastreaminterface.h |
@@ -53,8 +53,8 @@ class NotifierInterface { |
virtual ~NotifierInterface() {} |
}; |
-// Base class for sources. A MediaStreamTrack have an underlying source that |
-// provide media. A source can be shared with multiple tracks. |
+// Base class for sources. A MediaStreamTrack has an underlying source that |
+// provides media. A source can be shared by multiple tracks. |
class MediaSourceInterface : public rtc::RefCountInterface, |
public NotifierInterface { |
public: |
@@ -73,7 +73,8 @@ class MediaSourceInterface : public rtc::RefCountInterface, |
virtual ~MediaSourceInterface() {} |
}; |
-// Information about a track. |
+// C++ version of MediaStreamTrack. |
+// See: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack |
class MediaStreamTrackInterface : public rtc::RefCountInterface, |
public NotifierInterface { |
public: |
@@ -90,17 +91,24 @@ class MediaStreamTrackInterface : public rtc::RefCountInterface, |
// object is a subclass of VideoTrackInterface. It is typically used |
// to protect a static_cast<> to the corresponding subclass. |
virtual std::string kind() const = 0; |
+ |
+ // Track identifier. |
virtual std::string id() const = 0; |
+ |
+ // A disabled track will produce silence (if audio) or black frames (if |
+ // video). Can be disabled and re-enabled. |
virtual bool enabled() const = 0; |
- virtual TrackState state() const = 0; |
virtual bool set_enabled(bool enable) = 0; |
+ // Live or ended. A track will never be live again after becoming ended. |
+ virtual TrackState state() const = 0; |
+ |
protected: |
virtual ~MediaStreamTrackInterface() {} |
}; |
-// VideoTrackSourceInterface is a reference counted source used for VideoTracks. |
-// The same source can be used in multiple VideoTracks. |
+// VideoTrackSourceInterface is a reference counted source used for |
+// VideoTracks. The same source can be used by multiple VideoTracks. |
class VideoTrackSourceInterface |
: public MediaSourceInterface, |
public rtc::VideoSourceInterface<VideoFrame> { |
@@ -114,7 +122,7 @@ class VideoTrackSourceInterface |
// Indicates that parameters suitable for screencasts should be automatically |
// applied to RtpSenders. |
// TODO(perkj): Remove these once all known applications have moved to |
- // explicitly setting suitable parameters for screencasts and dont' need this |
+ // explicitly setting suitable parameters for screencasts and don't need this |
// implicit behavior. |
virtual bool is_screencast() const = 0; |
@@ -125,9 +133,10 @@ class VideoTrackSourceInterface |
// the encoder. |
virtual rtc::Optional<bool> needs_denoising() const = 0; |
- // Returns false if no stats are available, e.g, for a remote |
- // source, or a source which has not seen its first frame yet. |
- // Should avoid blocking. |
+ // Returns false if no stats are available, e.g, for a remote source, or a |
+ // source which has not seen its first frame yet. |
+ // |
+ // Implementation should avoid blocking. |
virtual bool GetStats(Stats* stats) = 0; |
protected: |
@@ -143,7 +152,8 @@ class VideoTrackInterface |
// See https://crbug.com/653531 and https://github.com/WICG/mst-content-hint. |
enum class ContentHint { kNone, kFluid, kDetailed }; |
- // Register a video sink for this track. |
+ // Register a video sink for this track. Used to connect the track to the |
+ // underlying video engine. |
void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
const rtc::VideoSinkWants& wants) override {} |
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {} |
@@ -171,7 +181,7 @@ class AudioTrackSinkInterface { |
}; |
// AudioSourceInterface is a reference counted source used for AudioTracks. |
-// The same source can be used in multiple AudioTracks. |
+// The same source can be used by multiple AudioTracks. |
class AudioSourceInterface : public MediaSourceInterface { |
public: |
class AudioObserver { |
@@ -182,14 +192,15 @@ class AudioSourceInterface : public MediaSourceInterface { |
virtual ~AudioObserver() {} |
}; |
- // TODO(xians): Makes all the interface pure virtual after Chrome has their |
- // implementations. |
- // Sets the volume to the source. |volume| is in the range of [0, 10]. |
+ // TODO(deadbeef): Makes all the interfaces pure virtual after they're |
+ // implemented in chromium. |
+ |
+ // Sets the volume of the source. |volume| is in the range of [0, 10]. |
// TODO(tommi): This method should be on the track and ideally volume should |
// be applied in the track in a way that does not affect clones of the track. |
virtual void SetVolume(double volume) {} |
- // Registers/unregisters observer to the audio source. |
+ // Registers/unregisters observers to the audio source. |
virtual void RegisterAudioObserver(AudioObserver* observer) {} |
virtual void UnregisterAudioObserver(AudioObserver* observer) {} |
@@ -235,7 +246,8 @@ class AudioProcessorInterface : public rtc::RefCountInterface { |
class AudioTrackInterface : public MediaStreamTrackInterface { |
public: |
- // TODO(xians): Figure out if the following interface should be const or not. |
+ // TODO(deadbeef): Figure out if the following interface should be const or |
+ // not. |
virtual AudioSourceInterface* GetSource() const = 0; |
// Add/Remove a sink that will receive the audio data from the track. |
@@ -244,15 +256,16 @@ class AudioTrackInterface : public MediaStreamTrackInterface { |
// Get the signal level from the audio track. |
// Return true on success, otherwise false. |
- // TODO(xians): Change the interface to int GetSignalLevel() and pure virtual |
- // after Chrome has the correct implementation of the interface. |
+ // TODO(deadbeef): Change the interface to int GetSignalLevel() and pure |
+ // virtual after it's implemented in chromium. |
virtual bool GetSignalLevel(int* level) { return false; } |
// Get the audio processor used by the audio track. Return NULL if the track |
// does not have any processor. |
- // TODO(xians): Make the interface pure virtual. |
- virtual rtc::scoped_refptr<AudioProcessorInterface> |
- GetAudioProcessor() { return NULL; } |
+ // TODO(deadbeef): Make the interface pure virtual. |
+ virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor() { |
+ return nullptr; |
+ } |
protected: |
virtual ~AudioTrackInterface() {} |
@@ -263,6 +276,14 @@ typedef std::vector<rtc::scoped_refptr<AudioTrackInterface> > |
typedef std::vector<rtc::scoped_refptr<VideoTrackInterface> > |
VideoTrackVector; |
+// C++ version of https://www.w3.org/TR/mediacapture-streams/#mediastream. |
+// |
+// A major difference is that remote audio/video tracks (received by a |
+// PeerConnection/RtpReceiver) are not synchronized simply by adding them to |
+// the same stream; a session description with the correct "a=msid" attributes |
+// must be pushed down. |
+// |
+// Thus, this interface acts as simply a container for tracks. |
class MediaStreamInterface : public rtc::RefCountInterface, |
public NotifierInterface { |
public: |