Chromium Code Reviews| 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_SINK_OWNER_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SINK_OWNER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/synchronization/lock.h" | |
| 12 #include "content/public/renderer/media_stream_audio_sink.h" | |
| 13 #include "content/renderer/media/webrtc_audio_device_impl.h" | |
| 14 #include "media/audio/audio_parameters.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 // Reference counted container of MediaStreamAudioSink delegates. | |
|
Jói
2013/11/27 17:35:02
It might be worth mentioning that this is a tempor
no longer working on chromium
2013/11/28 17:27:18
Added a TODO to remind removing the PeerConnection
| |
| 19 class MediaStreamAudioSinkOwner | |
| 20 : public base::RefCountedThreadSafe<MediaStreamAudioSinkOwner> { | |
| 21 public: | |
| 22 explicit MediaStreamAudioSinkOwner(MediaStreamAudioSink* sink); | |
| 23 explicit MediaStreamAudioSinkOwner(PeerConnectionAudioSink* sink); | |
| 24 | |
| 25 // MediaStreamAudioSink implementation. | |
| 26 int OnData(const int16* audio_data, | |
| 27 int sample_rate, | |
| 28 int number_of_channels, | |
| 29 int number_of_frames, | |
| 30 const std::vector<int>& channels, | |
| 31 int audio_delay_milliseconds, | |
| 32 int current_volume, | |
| 33 bool need_audio_processing, | |
| 34 bool key_pressed); | |
| 35 | |
| 36 void OnSetFormat(const media::AudioParameters& params); | |
| 37 | |
| 38 bool IsEqual(const MediaStreamAudioSink* other) const; | |
| 39 bool IsEqual(const PeerConnectionAudioSink* other) const; | |
| 40 void Reset(); | |
| 41 | |
| 42 // Wrapper which allows to use std::find_if() when adding and removing | |
|
Jói
2013/11/27 17:35:02
Would these wrappers be needed if we simply had tw
no longer working on chromium
2013/11/28 17:27:18
It is a very interesting idea.
I guess you mean ad
| |
| 43 // sinks to/from the list. | |
| 44 struct WrapsSink { | |
| 45 WrapsSink(MediaStreamAudioSink* sink) : sink_(sink) {} | |
| 46 bool operator()( | |
| 47 const scoped_refptr<MediaStreamAudioSinkOwner>& owner) { | |
| 48 return owner->IsEqual(sink_); | |
| 49 } | |
| 50 MediaStreamAudioSink* sink_; | |
| 51 }; | |
| 52 | |
| 53 struct WrapsPeerConnectionSink { | |
| 54 WrapsPeerConnectionSink(PeerConnectionAudioSink* sink) : sink_(sink) {} | |
| 55 bool operator()( | |
| 56 const scoped_refptr<MediaStreamAudioSinkOwner>& owner) { | |
| 57 return owner->IsEqual(sink_); | |
| 58 } | |
| 59 PeerConnectionAudioSink* sink_; | |
| 60 }; | |
| 61 | |
| 62 protected: | |
| 63 virtual ~MediaStreamAudioSinkOwner() {} | |
| 64 | |
| 65 private: | |
| 66 friend class base::RefCountedThreadSafe<MediaStreamAudioSinkOwner>; | |
| 67 MediaStreamAudioSink* media_stream_delegate_; | |
|
tommi (sloooow) - chröme
2013/11/28 09:12:11
document ownership and how it's guaranteed that th
no longer working on chromium
2013/11/28 17:27:18
Done.
| |
| 68 PeerConnectionAudioSink* peer_connection_delegate_; | |
|
tommi (sloooow) - chröme
2013/11/28 09:12:11
why do we have these two mutually exclusive pointe
no longer working on chromium
2013/11/28 17:27:18
Done with separate the media stream sink owner and
| |
| 69 mutable base::Lock lock_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSinkOwner); | |
| 72 }; | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SINK_OWNER_H_ | |
| OLD | NEW |