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

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

Issue 1599533003: MediaCaptureFromElement: add support for audio captureStream(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using refptr iso WeakPtr Created 4 years, 7 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
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/media/html_audio_element_capturer_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/html_audio_element_capturer_source.h
diff --git a/content/renderer/media/html_audio_element_capturer_source.h b/content/renderer/media/html_audio_element_capturer_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..2bbfb3c22db253f20cc05679eafab4b66005d7b9
--- /dev/null
+++ b/content/renderer/media/html_audio_element_capturer_source.h
@@ -0,0 +1,63 @@
+// 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_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_
+#define CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/content_export.h"
+#include "content/renderer/media/media_stream_audio_source.h"
+
+namespace blink {
+class WebMediaPlayer;
+} // namespace blink
+
+namespace media {
+class AudioBus;
+class WebAudioSourceProviderImpl;
+} // namespace media
+
+namespace content {
+
+// This class is a MediaStreamAudioSource that registers to the constructor-
+// passed weak WebAudioSourceProviderImpl to receive a copy of the audio data
+// intended for rendering. This copied data is received on OnAudioBus() and sent
+// to all the registered Tracks.
+class CONTENT_EXPORT HtmlAudioElementCapturerSource final
+ : NON_EXPORTED_BASE(public MediaStreamAudioSource) {
+ public:
+ static HtmlAudioElementCapturerSource*
+ CreateFromWebMediaPlayerImpl(blink::WebMediaPlayer* player);
+
+ explicit HtmlAudioElementCapturerSource(
+ media::WebAudioSourceProviderImpl* audio_source);
+ ~HtmlAudioElementCapturerSource() override;
+
+ private:
+ // MediaStreamAudioSource implementation.
+ bool EnsureSourceIsStarted() final;
+ void EnsureSourceIsStopped() final;
+
+ // To act as an WebAudioSourceProviderImpl::CopyAudioCB.
+ void OnAudioBus(std::unique_ptr<media::AudioBus> audio_bus,
+ uint32_t delay_milliseconds,
+ int sample_rate);
+
+ scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_;
+
+ bool is_started_;
+ int last_sample_rate_;
+ int last_num_channels_;
+ int last_bus_frames_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(HtmlAudioElementCapturerSource);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/media/html_audio_element_capturer_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698