Chromium Code Reviews| Index: content/renderer/media/media_stream_audio_track.h |
| diff --git a/content/renderer/media/media_stream_audio_track.h b/content/renderer/media/media_stream_audio_track.h |
| index 2175b4e186f47fefc982e097a1691dac1fdd7383..3fbbeb4e02759225e3e40b905593821dba28905b 100644 |
| --- a/content/renderer/media/media_stream_audio_track.h |
| +++ b/content/renderer/media/media_stream_audio_track.h |
| @@ -5,6 +5,9 @@ |
| #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_ |
| #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_ |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| #include "content/renderer/media/media_stream_track.h" |
| @@ -16,13 +19,23 @@ namespace content { |
| class MediaStreamAudioSink; |
| +// TODO(miu): In a soon-upcoming set of refactoring changes, this class will |
| +// take on the functionality of managing sink connections and the audio data |
| +// flow between source and sinks. The WebRTC-specific elements will then be |
| +// moved into a subclass. http://crbug.com/577874 |
| class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack { |
| public: |
| explicit MediaStreamAudioTrack(bool is_local_track); |
| ~MediaStreamAudioTrack() override; |
| - static MediaStreamAudioTrack* GetTrack( |
| - const blink::WebMediaStreamTrack& track); |
| + // Returns the MediaStreamAudioTrack instance owned by the given blink |track| |
| + // or null. |
| + static MediaStreamAudioTrack* From(const blink::WebMediaStreamTrack& track); |
| + |
| + // The first time Stop() is called on this track, each |stop_callback| will be |
| + // run. This is generally used by sources to be notified that the audio data |
| + // flow to the track should halt. |
| + void AddStopObserver(const base::Closure& stop_callback); |
| // Add a sink to the track. This function will trigger a OnSetFormat() |
| // call on the |sink|. |
| @@ -34,6 +47,7 @@ class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack { |
| virtual void RemoveSink(MediaStreamAudioSink* sink) = 0; |
| // TODO(tommi, xians): Remove this method. |
| + // TODO(miu): See class-level TODO comment. ;-) |
| virtual webrtc::AudioTrackInterface* GetAudioAdapter(); |
| // Returns the output format of the capture source. May return an invalid |
| @@ -44,7 +58,15 @@ class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack { |
| // to the complexity of all types of audio tracks+source implementations. |
| virtual media::AudioParameters GetOutputFormat() const = 0; |
| + // The final implementation of the Stop() method. Subclasses that wish to |
| + // extend this functionality should use AddStopObserver() instead. |
| + void Stop() final; |
| + |
| private: |
| + // These are run after this track has been stopped. Even if Stop() is called |
| + // multiple times, the |stop_callbacks_| are only run the first time. |
| + std::vector<base::Closure> stop_callbacks_; |
|
mcasas
2016/02/26 01:28:19
Use base::ObserverList ? Meh could be worse
since
miu
2016/02/27 03:46:36
Took a look. Yeah, I just have a dirt-simple case
|
| + |
| DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioTrack); |
| }; |