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

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

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tommi's comments on PS6. Created 4 years, 8 months 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/external_media_stream_audio_source.h
diff --git a/content/renderer/media/external_media_stream_audio_source.h b/content/renderer/media/external_media_stream_audio_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..f520ae0985abb145ce8bcb3e2a353e91ee360f93
--- /dev/null
+++ b/content/renderer/media/external_media_stream_audio_source.h
@@ -0,0 +1,59 @@
+// Copyright 2016 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_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
+#define CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
+
+#include "content/renderer/media/media_stream_audio_source.h"
+
+#include "media/base/audio_capturer_source.h"
+
+namespace content {
+
+// Represents an externally-provided local or remote source of audio data. This
+// allows users of the public content::MediaStreamApi to provide a
+// media::AudioCapturerSource to be used as the source of audio data in the
+// MediaStream framework. Audio data is transported directly to the tracks
+// (i.e., there is no audio processing).
+class CONTENT_EXPORT ExternalMediaStreamAudioSource final
+ : NON_EXPORTED_BASE(public MediaStreamAudioSource),
+ NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) {
+ public:
+ ExternalMediaStreamAudioSource(
+ scoped_refptr<media::AudioCapturerSource> source,
+ int sample_rate,
+ media::ChannelLayout channel_layout,
+ int frames_per_buffer,
+ bool is_remote);
+
+ ~ExternalMediaStreamAudioSource() final;
+
+ private:
+ // MediaStreamAudioSource implementation.
+ bool EnsureSourceIsStarted() final;
+ void EnsureSourceIsStopped() final;
+
+ // media::AudioCapturerSource::CaptureCallback implementation.
+ void Capture(const media::AudioBus* audio_bus,
+ int audio_delay_milliseconds,
+ double volume,
+ bool key_pressed) final;
+ void OnCaptureError(const std::string& message) final;
+
+ // The external source provided to the constructor.
+ scoped_refptr<media::AudioCapturerSource> source_;
+
+ // In debug builds, check that all methods that could cause object graph
+ // or data flow changes are being called on the main thread.
+ base::ThreadChecker thread_checker_;
+
+ // True once the source has been started successfully.
+ bool was_started_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExternalMediaStreamAudioSource);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_

Powered by Google App Engine
This is Rietveld 408576698