Home | History | Annotate | Download | only in renderer
      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.
      4 
      5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_
      6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/basictypes.h"
     11 #include "content/common/content_export.h"
     12 #include "content/public/renderer/media_stream_sink.h"
     13 
     14 namespace blink {
     15 class WebMediaStreamTrack;
     16 }
     17 
     18 namespace media {
     19 class AudioParameters;
     20 }
     21 
     22 namespace content {
     23 
     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);
     31 
     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);
     37 
     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;
     48 
     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;
     52 
     53  protected:
     54   virtual ~MediaStreamAudioSink() {}
     55 };
     56 
     57 }  // namespace content
     58 
     59 #endif  // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_SINK_H_
     60