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_
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"
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
> {
24 virtual int OnData(const int16
* audio_data
,
26 int number_of_channels
,
28 const std::vector
<int>& channels
,
29 int audio_delay_milliseconds
,
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
) {}
49 const scoped_refptr
<MediaStreamAudioTrackSink
>& owner
) const {
50 return owner
->IsEqual(sink_
);
52 MediaStreamAudioSink
* sink_
;
54 struct WrapsPeerConnectionSink
{
55 WrapsPeerConnectionSink(PeerConnectionAudioSink
* sink
) : sink_(sink
) {}
57 const scoped_refptr
<MediaStreamAudioTrackSink
>& owner
) const {
58 return owner
->IsEqual(sink_
);
60 PeerConnectionAudioSink
* sink_
;
64 virtual ~MediaStreamAudioTrackSink() {}
67 friend class base::RefCountedThreadSafe
<MediaStreamAudioTrackSink
>;
70 } // namespace content
72 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_