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

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

Issue 2821203005: Add a mojo implementation of AudioOutputIPC. (Closed)
Patch Set: Fix test issues Created 3 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/mojo_audio_output_ipc.h
diff --git a/content/renderer/media/mojo_audio_output_ipc.h b/content/renderer/media/mojo_audio_output_ipc.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f84e39282e971e804e390453deb15032aa49809
--- /dev/null
+++ b/content/renderer/media/mojo_audio_output_ipc.h
@@ -0,0 +1,74 @@
+// Copyright 2017 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_MOJO_AUDIO_OUTPUT_IPC_H_
+#define CONTENT_RENDERER_MEDIA_MOJO_AUDIO_OUTPUT_IPC_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/media/renderer_audio_output_stream_factory.mojom.h"
+#include "media/audio/audio_output_ipc.h"
+
+namespace content {
+
+// MojoAudioOutputIPC is a renderer-side class for handling creation,
+// initialization and control of an output stream. May only be used on a single
+// thread.
+class MojoAudioOutputIPC : public media::AudioOutputIPC {
+ public:
+ using FactoryAccessor =
+ base::Callback<mojom::RendererAudioOutputStreamFactory*()>;
+
+ // |factory_accessor| is required to provide a
Max Morin 2017/05/05 14:06:14 Ignore stale comment, will change it to a better o
Max Morin 2017/05/11 15:31:18 Done.
+ // RendererAudioOutputStreamFactoryWrapper if IPC is possible.
+ explicit MojoAudioOutputIPC(FactoryAccessor factory_accessor);
+
+ ~MojoAudioOutputIPC() override;
+
+ // AudioOutputIPC implementation.
+ void RequestDeviceAuthorization(media::AudioOutputIPCDelegate* delegate,
+ int session_id,
+ const std::string& device_id,
+ const url::Origin& security_origin) override;
+ void CreateStream(media::AudioOutputIPCDelegate* delegate,
+ const media::AudioParameters& params) override;
+ void PlayStream() override;
+ void PauseStream() override;
+ void CloseStream() override;
+ void SetVolume(double volume) override;
+
+ private:
+ bool AuthorizationRequested();
+ bool StreamCreationRequested();
+ media::mojom::AudioOutputStreamProviderRequest MakeProviderRequest(
+ media::AudioOutputIPCDelegate* delegate);
+
+ void RecievedDeviceAuthorization(media::AudioOutputIPCDelegate* delegate,
+ media::OutputDeviceStatus status,
+ const media::AudioParameters& params,
+ const std::string& device_id) const;
+
+ void StreamCreated(media::AudioOutputIPCDelegate* delegate,
+ mojo::ScopedSharedBufferHandle shared_memory,
+ mojo::ScopedHandle socket);
+
+ const FactoryAccessor factory_accessor_;
+
+ base::ThreadChecker thread_checker_;
+ media::mojom::AudioOutputStreamProviderPtr stream_provider_;
+ media::mojom::AudioOutputStreamPtr stream_;
+
+ // To make sure we don't send an "authorization completed" callback for a
+ // stream after it's closed, we use this weak factory.
+ base::WeakPtrFactory<MojoAudioOutputIPC> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputIPC);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_MOJO_AUDIO_OUTPUT_IPC_H_

Powered by Google App Engine
This is Rietveld 408576698