Chromium Code Reviews| 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..ab8e160825069c2574455ad3270d52f10865b605 |
| --- /dev/null |
| +++ b/content/renderer/media/mojo_audio_output_ipc.h |
| @@ -0,0 +1,83 @@ |
| +// 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/content_export.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 CONTENT_EXPORT MojoAudioOutputIPC : public media::AudioOutputIPC { |
| + public: |
| + using FactoryAccessor = |
| + base::RepeatingCallback<mojom::RendererAudioOutputStreamFactory*()>; |
| + |
| + // |factory_accessor| is required to provide a |
| + // RendererAudioOutputStreamFactory* if IPC is possible. |
| + explicit MojoAudioOutputIPC(FactoryAccessor factory_accessor); |
|
DaleCurtis
2017/05/24 01:36:54
Typically we end callbacks types with CB for clari
Max Morin
2017/05/30 14:17:11
Done.
|
| + |
| + ~MojoAudioOutputIPC() override; |
| + |
| + // AudioOutputIPC implementation. |
| + void RequestDeviceAuthorization(media::AudioOutputIPCDelegate* delegate, |
|
DaleCurtis
2017/05/24 01:36:54
Technically I/O parameters should be last. I reali
Max Morin
2017/05/30 14:17:11
Yes, maybe we can revisit the AudioOutputIPC inter
|
| + 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: |
| + using AuthorizationCallback = mojom::RendererAudioOutputStreamFactory:: |
|
DaleCurtis
2017/05/24 01:36:55
AuthorizationCB is sufficient if you want.
Max Morin
2017/05/30 14:17:11
Done.
|
| + RequestDeviceAuthorizationCallback; |
| + |
| + bool AuthorizationRequested(); |
| + bool StreamCreationRequested(); |
| + media::mojom::AudioOutputStreamProviderRequest MakeProviderRequest(); |
| + |
| + // Tries to acquire a RendererAudioOutputStreamFactory, returns true on |
| + // success. On failure, |this| has been deleted, so returning immediately |
| + // is required. |
| + bool DoRequestDeviceAuthorization(int session_id, |
| + const std::string& device_id, |
| + AuthorizationCallback callback); |
| + |
| + void RecievedDeviceAuthorization(media::OutputDeviceStatus status, |
| + const media::AudioParameters& params, |
| + const std::string& device_id) const; |
| + |
| + void StreamCreated(mojo::ScopedSharedBufferHandle shared_memory, |
| + mojo::ScopedHandle socket); |
| + |
| + const FactoryAccessor factory_accessor_; |
| + |
| + THREAD_CHECKER(thread_checker_); |
| + media::mojom::AudioOutputStreamProviderPtr stream_provider_; |
| + media::mojom::AudioOutputStreamPtr stream_; |
| + media::AudioOutputIPCDelegate* delegate_ = nullptr; |
| + |
| + // 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_ |