chrome.bluetoothSocket: clean-up Listen functions
[chromium-blink-merge.git] / content / renderer / media / media_stream_audio_track_sink.h
blob6e511bd65347071fa66e8360f53c64f247602b5a
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 "media/audio/audio_parameters.h"
13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
15 namespace content {
17 class MediaStreamAudioSink;
18 class PeerConnectionAudioSink;
20 // Interface for reference counted holder of audio stream audio track sink.
21 class MediaStreamAudioTrackSink
22 : public base::RefCountedThreadSafe<MediaStreamAudioTrackSink> {
23 public:
24 virtual int OnData(const int16* audio_data,
25 int sample_rate,
26 int number_of_channels,
27 int number_of_frames,
28 const std::vector<int>& channels,
29 int audio_delay_milliseconds,
30 int current_volume,
31 bool need_audio_processing,
32 bool key_pressed) = 0;
34 virtual void OnSetFormat(const media::AudioParameters& params) = 0;
36 virtual void OnReadyStateChanged(
37 blink::WebMediaStreamSource::ReadyState state) = 0;
39 virtual void Reset() = 0;
41 virtual bool IsEqual(const MediaStreamAudioSink* other) const = 0;
42 virtual bool IsEqual(const PeerConnectionAudioSink* other) const = 0;
44 // Wrapper which allows to use std::find_if() when adding and removing
45 // sinks to/from the list.
46 struct WrapsMediaStreamSink {
47 WrapsMediaStreamSink(MediaStreamAudioSink* sink) : sink_(sink) {}
48 bool operator()(
49 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const {
50 return owner->IsEqual(sink_);
52 MediaStreamAudioSink* sink_;
54 struct WrapsPeerConnectionSink {
55 WrapsPeerConnectionSink(PeerConnectionAudioSink* sink) : sink_(sink) {}
56 bool operator()(
57 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const {
58 return owner->IsEqual(sink_);
60 PeerConnectionAudioSink* sink_;
63 protected:
64 virtual ~MediaStreamAudioTrackSink() {}
66 private:
67 friend class base::RefCountedThreadSafe<MediaStreamAudioTrackSink>;
70 } // namespace content
72 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_