Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1721)

Unified Diff: content/renderer/media/media_stream_audio_sink_owner.h

Issue 90743004: Add generic interfaces for the sinks of the media stream audio track (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_audio_sink_owner.h
diff --git a/content/renderer/media/media_stream_audio_sink_owner.h b/content/renderer/media/media_stream_audio_sink_owner.h
new file mode 100644
index 0000000000000000000000000000000000000000..25f15c3cb4803cc8be86c4af782c9a7591940d6a
--- /dev/null
+++ b/content/renderer/media/media_stream_audio_sink_owner.h
@@ -0,0 +1,76 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SINK_OWNER_H_
+#define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SINK_OWNER_H_
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "content/public/renderer/media_stream_audio_sink.h"
+#include "content/renderer/media/webrtc_audio_device_impl.h"
+#include "media/audio/audio_parameters.h"
+
+namespace content {
+
+// 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
+class MediaStreamAudioSinkOwner
+ : public base::RefCountedThreadSafe<MediaStreamAudioSinkOwner> {
+ public:
+ explicit MediaStreamAudioSinkOwner(MediaStreamAudioSink* sink);
+ explicit MediaStreamAudioSinkOwner(PeerConnectionAudioSink* sink);
+
+ // MediaStreamAudioSink implementation.
+ int OnData(const int16* audio_data,
+ int sample_rate,
+ int number_of_channels,
+ int number_of_frames,
+ const std::vector<int>& channels,
+ int audio_delay_milliseconds,
+ int current_volume,
+ bool need_audio_processing,
+ bool key_pressed);
+
+ void OnSetFormat(const media::AudioParameters& params);
+
+ bool IsEqual(const MediaStreamAudioSink* other) const;
+ bool IsEqual(const PeerConnectionAudioSink* other) const;
+ void Reset();
+
+ // 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
+ // sinks to/from the list.
+ struct WrapsSink {
+ WrapsSink(MediaStreamAudioSink* sink) : sink_(sink) {}
+ bool operator()(
+ const scoped_refptr<MediaStreamAudioSinkOwner>& owner) {
+ return owner->IsEqual(sink_);
+ }
+ MediaStreamAudioSink* sink_;
+ };
+
+ struct WrapsPeerConnectionSink {
+ WrapsPeerConnectionSink(PeerConnectionAudioSink* sink) : sink_(sink) {}
+ bool operator()(
+ const scoped_refptr<MediaStreamAudioSinkOwner>& owner) {
+ return owner->IsEqual(sink_);
+ }
+ PeerConnectionAudioSink* sink_;
+ };
+
+ protected:
+ virtual ~MediaStreamAudioSinkOwner() {}
+
+ private:
+ friend class base::RefCountedThreadSafe<MediaStreamAudioSinkOwner>;
+ 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.
+ 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
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSinkOwner);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SINK_OWNER_H_

Powered by Google App Engine
This is Rietveld 408576698