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_
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "content/public/renderer/media_stream_sink.h"
15 class WebMediaStreamTrack
;
19 class AudioParameters
;
24 class CONTENT_EXPORT MediaStreamAudioSink
: public MediaStreamSink
{
26 // Adds a MediaStreamAudioSink to the audio track to receive audio data from
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
,
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;
54 virtual ~MediaStreamAudioSink() {}
57 } // namespace content
59 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_