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

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: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. 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
Index: content/renderer/media/external_media_stream_audio_source.h
diff --git a/content/renderer/media/image_capture_frame_grabber.h b/content/renderer/media/external_media_stream_audio_source.h
similarity index 13%
copy from content/renderer/media/image_capture_frame_grabber.h
copy to content/renderer/media/external_media_stream_audio_source.h
index 78543e4a940124eef84c7ebeca319d0dfd37ccc6..f520ae0985abb145ce8bcb3e2a353e91ee360f93 100644
--- a/content/renderer/media/image_capture_frame_grabber.h
+++ b/content/renderer/media/external_media_stream_audio_source.h
@@ -2,57 +2,58 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_
-#define CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "content/child/scoped_web_callbacks.h"
-#include "content/common/content_export.h"
-#include "content/public/renderer/media_stream_video_sink.h"
-#include "third_party/WebKit/public/platform/WebImageCaptureFrameGrabber.h"
-
-namespace blink {
-class WebMediaStreamTrack;
-}
-
-namespace media {
-class VideoFrame;
-}
+#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 {
-// This class grabs Video Frames from a given Media Stream Video Track, binding
-// a function every time grabFrame() is called. This function receives an
-// incoming VideoFrame on a background thread and converts it into the
-// appropriate SkBitmap which is sent back to OnSkBitmap(). This class is single
-// threaded throughout.
-class CONTENT_EXPORT ImageCaptureFrameGrabber final
- : NON_EXPORTED_BASE(public blink::WebImageCaptureFrameGrabber),
- NON_EXPORTED_BASE(public MediaStreamVideoSink) {
+// 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:
- using SkImageDeliverCB = base::Callback<void(sk_sp<SkImage>)>;
-
- ImageCaptureFrameGrabber();
- ~ImageCaptureFrameGrabber() override;
+ ExternalMediaStreamAudioSource(
+ scoped_refptr<media::AudioCapturerSource> source,
+ int sample_rate,
+ media::ChannelLayout channel_layout,
+ int frames_per_buffer,
+ bool is_remote);
- // blink::WebImageCaptureFrameGrabber implementation.
- void grabFrame(blink::WebMediaStreamTrack* track,
- blink::WebImageCaptureGrabFrameCallbacks* callbacks) override;
+ ~ExternalMediaStreamAudioSource() final;
private:
- void OnSkImage(
- ScopedWebCallbacks<blink::WebImageCaptureGrabFrameCallbacks> callbacks,
- sk_sp<SkImage> image);
-
+ // 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_;
- base::WeakPtrFactory<ImageCaptureFrameGrabber> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(ImageCaptureFrameGrabber);
+ // True once the source has been started successfully.
+ bool was_started_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExternalMediaStreamAudioSource);
};
} // namespace content
-#endif // CONTENT_RENDERER_MEDIA_IMAGE_CAPTURE_FRAME_GRABBER_H_
+#endif // CONTENT_RENDERER_MEDIA_EXTERNAL_MEDIA_STREAM_AUDIO_SOURCE_H_
« no previous file with comments | « content/renderer/media/audio_track_recorder_unittest.cc ('k') | content/renderer/media/external_media_stream_audio_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698