OLD | NEW |
(Empty) | |
| 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_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "media/audio/audio_parameters.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class MediaStreamAudioSink; |
| 17 class PeerConnectionAudioSink; |
| 18 |
| 19 // Interface for reference counted holder of audio stream audio track sink. |
| 20 class MediaStreamAudioTrackSink |
| 21 : public base::RefCountedThreadSafe<MediaStreamAudioTrackSink> { |
| 22 public: |
| 23 virtual int OnData(const int16* audio_data, |
| 24 int sample_rate, |
| 25 int number_of_channels, |
| 26 int number_of_frames, |
| 27 const std::vector<int>& channels, |
| 28 int audio_delay_milliseconds, |
| 29 int current_volume, |
| 30 bool need_audio_processing, |
| 31 bool key_pressed) = 0; |
| 32 |
| 33 virtual void OnSetFormat(const media::AudioParameters& params) = 0; |
| 34 |
| 35 virtual void Reset() = 0; |
| 36 |
| 37 virtual bool IsEqual(const MediaStreamAudioSink* other) const = 0; |
| 38 virtual bool IsEqual(const PeerConnectionAudioSink* other) const = 0; |
| 39 |
| 40 // Wrapper which allows to use std::find_if() when adding and removing |
| 41 // sinks to/from the list. |
| 42 struct WrapsMediaStreamSink { |
| 43 WrapsMediaStreamSink(MediaStreamAudioSink* sink) : sink_(sink) {} |
| 44 bool operator()(const scoped_refptr<MediaStreamAudioTrackSink>& owner) { |
| 45 return owner->IsEqual(sink_); |
| 46 } |
| 47 MediaStreamAudioSink* sink_; |
| 48 }; |
| 49 struct WrapsPeerConnectionSink { |
| 50 WrapsPeerConnectionSink(PeerConnectionAudioSink* sink) : sink_(sink) {} |
| 51 bool operator()(const scoped_refptr<MediaStreamAudioTrackSink>& owner) { |
| 52 return owner->IsEqual(sink_); |
| 53 } |
| 54 PeerConnectionAudioSink* sink_; |
| 55 }; |
| 56 |
| 57 protected: |
| 58 virtual ~MediaStreamAudioTrackSink() {} |
| 59 |
| 60 private: |
| 61 friend class base::RefCountedThreadSafe<MediaStreamAudioTrackSink>; |
| 62 }; |
| 63 |
| 64 } // namespace content |
| 65 |
| 66 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
OLD | NEW |