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 "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "content/public/renderer/media_stream_sink.h"
16 class WebMediaStreamTrack
;
21 class AudioParameters
;
26 class CONTENT_EXPORT MediaStreamAudioSink
: public MediaStreamSink
{
28 // Adds a MediaStreamAudioSink to the audio track to receive audio data from
30 // Called on the main render thread.
31 static void AddToAudioTrack(MediaStreamAudioSink
* sink
,
32 const blink::WebMediaStreamTrack
& track
);
34 // Removes a MediaStreamAudioSink from the audio track to stop receiving
35 // audio data from the track.
36 // Called on the main render thread.
37 static void RemoveFromAudioTrack(MediaStreamAudioSink
* sink
,
38 const blink::WebMediaStreamTrack
& track
);
40 // Callback called to deliver audio data. The data in |audio_bus| respects the
41 // AudioParameters passed in the last call to OnSetFormat(). Called on
42 // real-time audio thread.
44 // |estimated_capture_time| is the local time at which the first sample frame
45 // in |audio_bus| either: 1) was generated, if it was done so locally; or 2)
46 // should be targeted for play-out, if it was generated from a remote
47 // source. Either way, an implementation should not play-out the audio before
48 // this point-in-time. This value is NOT a high-resolution timestamp, and so
49 // it should not be used as a presentation time; but, instead, it should be
50 // used for buffering playback and for A/V synchronization purposes.
51 virtual void OnData(const media::AudioBus
& audio_bus
,
52 base::TimeTicks estimated_capture_time
) = 0;
54 // Callback called when the format of the audio stream has changed. This is
55 // always called at least once before OnData(), and on the same thread.
56 virtual void OnSetFormat(const media::AudioParameters
& params
) = 0;
59 ~MediaStreamAudioSink() override
{}
62 } // namespace content
64 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_