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

Unified Diff: content/browser/media/audio_output_impl.h

Issue 1930393002: Switch stream creation and closing in Chrome audio rendering from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unique_ptr for Binding 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/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/media/audio_output_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/audio_output_impl.h
diff --git a/content/browser/media/audio_output_impl.h b/content/browser/media/audio_output_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..12a85bb004f63322406aeaecdb9293c5864b8176
--- /dev/null
+++ b/content/browser/media/audio_output_impl.h
@@ -0,0 +1,89 @@
+// 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_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
+#define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
+
+#include "base/callback.h"
+#include "base/sync_socket.h"
+#include "content/browser/renderer_host/media/audio_renderer_host.h"
+#include "media/mojo/interfaces/audio_output.mojom.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace base {
+class SharedMemory;
+}
+
+namespace content {
+class AudioOutputStreamImpl;
+class RenderFrameHostImpl;
+
+// This class implements AudioOutput Mojo interface. It is connected to
+// the AudioOutputClient to perform operations on audio output streams.
+// AudioOutputClient is going to perform operations remotely and Mojo is
+// transfer them to AudioOutputImpl.
+// This class must always be accessed from the creation thread.
+class CONTENT_EXPORT AudioOutputImpl
+ : NON_EXPORTED_BASE(public media::mojom::AudioOutput) {
+ public:
+ explicit AudioOutputImpl(RenderFrameHostImpl* frame,
+ media::mojom::AudioOutputRequest request);
+
+ ~AudioOutputImpl() override;
+
+ // Creates a Mojo service.
+ static void CreateService(RenderFrameHostImpl* frame,
+ media::mojom::AudioOutputRequest request);
+
+ // Initializes Mojo service on the IO thread. The service is bound to the
+ // IO thread so future Mojo calls performed by the AudioOutputClient to the
+ // AudioOutput interface will be run on that thread.
+ // There are a lot of dependencies used in audio output that require to be
+ // called on the IO thread, this is why we initialize Mojo service on this
+ // thread.
+ static void CreateServiceOnIOThread(RenderFrameHostImpl* frame,
+ media::mojom::AudioOutputRequest request);
+ void Reset();
+
+ // Called by AudioRendererHost::DoCompleteCreation to create the streams.
+ virtual void CreateStreamFactory(
+ int stream_id,
+ base::SharedMemory* shared_memory,
+ base::SyncSocket::TransitDescriptor socket_descriptor);
+
+ virtual bool CloseStream(int stream_id);
+
+ // Sends an error message to the renderer, then close the stream.
+ virtual void ReportErrorAndCloseStream(int stream_id);
+
+ private:
+ friend class AudioOutputImplTest;
+ friend class MockAudioOutputImpl;
+ FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream);
+ FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory);
+ FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream);
+
+ // AudioOutput interface implementation.
+ void CreateStream(int stream_id,
+ const media::AudioParameters& params,
+ const CreateStreamCallback& callback) override;
+
+ void InitAudioRendererHost();
+
+ RenderFrameHostImpl* frame_;
+ std::unique_ptr<mojo::Binding<AudioOutput>> binding_;
+ scoped_refptr<AudioRendererHost> audio_renderer_host_;
+ // Maps from |stream_id| to AudioOutputStreamImpl.
+ std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
+ // Maps from |stream_id| to CreateStreamCallback.
+ std::map<int, media::mojom::AudioOutput::CreateStreamCallback>
+ create_stream_callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/media/audio_output_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698