Make sure webrtc::VideoSourceInterface is released on the main render thread.
[chromium-blink-merge.git] / content / public / renderer / media_stream_audio_sink.h
blob312d61dc42fb2d7ab62f9443d595a9a0c5851d1c
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_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "content/public/renderer/media_stream_sink.h"
14 namespace blink {
15 class WebMediaStreamTrack;
18 namespace media {
19 class AudioParameters;
22 namespace content {
24 class CONTENT_EXPORT MediaStreamAudioSink : public MediaStreamSink {
25 public:
26 // Adds a MediaStreamAudioSink to the audio track to receive audio data from
27 // the track.
28 // Called on the main render thread.
29 static void AddToAudioTrack(MediaStreamAudioSink* sink,
30 const blink::WebMediaStreamTrack& track);
32 // Removes a MediaStreamAudioSink from the audio track to stop receiving
33 // audio data from the track.
34 // Called on the main render thread.
35 static void RemoveFromAudioTrack(MediaStreamAudioSink* sink,
36 const blink::WebMediaStreamTrack& track);
38 // Callback on delivering the interleaved audio data.
39 // |audio_data| is the pointer to the audio data.
40 // |sample_rate| is the sample frequency of |audio_data|.
41 // |number_of_channels| is the number of audio channels of |audio_data|.
42 // |number_of_frames| is the number of audio frames in the |audio_data|.
43 // Called on real-time audio thread.
44 virtual void OnData(const int16* audio_data,
45 int sample_rate,
46 int number_of_channels,
47 int number_of_frames) = 0;
49 // Callback called when the format of the audio stream has changed.
50 // This is called on the same thread as OnData().
51 virtual void OnSetFormat(const media::AudioParameters& params) = 0;
53 protected:
54 virtual ~MediaStreamAudioSink() {}
57 } // namespace content
59 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_