| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "media/audio/audio_parameters.h" | 12 #include "media/audio/audio_parameters.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class MediaStreamAudioSink; | 17 class MediaStreamAudioSink; |
| 18 class PeerConnectionAudioSink; | |
| 19 | 18 |
| 20 // Interface for reference counted holder of audio stream audio track sink. | 19 // Interface for reference counted holder of audio stream audio track sink. |
| 21 class MediaStreamAudioTrackSink | 20 class MediaStreamAudioTrackSink |
| 22 : public base::RefCountedThreadSafe<MediaStreamAudioTrackSink> { | 21 : public base::RefCountedThreadSafe<MediaStreamAudioTrackSink> { |
| 23 public: | 22 public: |
| 24 virtual int OnData(const int16* audio_data, | 23 virtual void OnData(const int16* audio_data, |
| 25 int sample_rate, | 24 int sample_rate, |
| 26 int number_of_channels, | 25 int number_of_channels, |
| 27 int number_of_frames, | 26 int number_of_frames) = 0; |
| 28 const std::vector<int>& channels, | |
| 29 int audio_delay_milliseconds, | |
| 30 int current_volume, | |
| 31 bool need_audio_processing, | |
| 32 bool key_pressed) = 0; | |
| 33 | 27 |
| 34 virtual void OnSetFormat(const media::AudioParameters& params) = 0; | 28 virtual void OnSetFormat(const media::AudioParameters& params) = 0; |
| 35 | 29 |
| 36 virtual void OnReadyStateChanged( | 30 virtual void OnReadyStateChanged( |
| 37 blink::WebMediaStreamSource::ReadyState state) = 0; | 31 blink::WebMediaStreamSource::ReadyState state) = 0; |
| 38 | 32 |
| 39 virtual void Reset() = 0; | 33 virtual void Reset() = 0; |
| 40 | 34 |
| 41 virtual bool IsEqual(const MediaStreamAudioSink* other) const = 0; | 35 virtual bool IsEqual(const MediaStreamAudioSink* other) const = 0; |
| 42 virtual bool IsEqual(const PeerConnectionAudioSink* other) const = 0; | |
| 43 | 36 |
| 44 // Wrapper which allows to use std::find_if() when adding and removing | 37 // Wrapper which allows to use std::find_if() when adding and removing |
| 45 // sinks to/from the list. | 38 // sinks to/from the list. |
| 46 struct WrapsMediaStreamSink { | 39 struct WrapsMediaStreamSink { |
| 47 WrapsMediaStreamSink(MediaStreamAudioSink* sink) : sink_(sink) {} | 40 WrapsMediaStreamSink(MediaStreamAudioSink* sink) : sink_(sink) {} |
| 48 bool operator()( | 41 bool operator()( |
| 49 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const { | 42 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const { |
| 50 return owner->IsEqual(sink_); | 43 return owner->IsEqual(sink_); |
| 51 } | 44 } |
| 52 MediaStreamAudioSink* sink_; | 45 MediaStreamAudioSink* sink_; |
| 53 }; | 46 }; |
| 54 struct WrapsPeerConnectionSink { | |
| 55 WrapsPeerConnectionSink(PeerConnectionAudioSink* sink) : sink_(sink) {} | |
| 56 bool operator()( | |
| 57 const scoped_refptr<MediaStreamAudioTrackSink>& owner) const { | |
| 58 return owner->IsEqual(sink_); | |
| 59 } | |
| 60 PeerConnectionAudioSink* sink_; | |
| 61 }; | |
| 62 | 47 |
| 63 protected: | 48 protected: |
| 64 virtual ~MediaStreamAudioTrackSink() {} | 49 virtual ~MediaStreamAudioTrackSink() {} |
| 65 | 50 |
| 66 private: | 51 private: |
| 67 friend class base::RefCountedThreadSafe<MediaStreamAudioTrackSink>; | 52 friend class base::RefCountedThreadSafe<MediaStreamAudioTrackSink>; |
| 68 }; | 53 }; |
| 69 | 54 |
| 70 } // namespace content | 55 } // namespace content |
| 71 | 56 |
| 72 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ | 57 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_SINK_H_ |
| OLD | NEW |