Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / content / renderer / media / media_stream_audio_track_sink.h
blob3c67ba387b9b8038d8e4a94afd984f57a9c9c23b
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_
8 #include <vector>
10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "media/audio/audio_parameters.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
16 namespace media {
17 class AudioBus;
20 namespace content {
22 class MediaStreamAudioSink;
24 // Interface for reference counted holder of audio stream audio track sink.
25 class MediaStreamAudioTrackSink
26 : public base::RefCountedThreadSafe<MediaStreamAudioTrackSink> {
27 public:
28 // Note: OnData() and OnSetFormat() have the same meaning and semantics as in
29 // content::MediaStreamAudioSink. See comments there for usage info.
30 virtual void OnData(const media::AudioBus& audio_bus,
31 base::TimeTicks estimated_capture_time) = 0;
32 virtual void OnSetFormat(const media::AudioParameters& params) = 0;
34 virtual void OnReadyStateChanged(
35 blink::WebMediaStreamSource::ReadyState state) = 0;
37 virtual void Reset() = 0;
39 virtual bool IsEqual(const MediaStreamAudioSink* other) const = 0;
41 // Wrapper which allows to use std::find_if() when adding and removing
42 // sinks to/from the list.
43 struct WrapsMediaStreamSink {
44 WrapsMediaStreamSink(MediaStreamAudioSink* sink) : sink_(sink) {}
45 bool operator()(
46 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const {
47 return owner->IsEqual(sink_);
49 MediaStreamAudioSink* sink_;
52 protected:
53 virtual ~MediaStreamAudioTrackSink() {}
55 private:
56 friend class base::RefCountedThreadSafe<MediaStreamAudioTrackSink>;
59 } // namespace content
61 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_