Chromium Code Reviews| Index: content/renderer/media/audio_output_client.h |
| diff --git a/content/renderer/media/audio_output_client.h b/content/renderer/media/audio_output_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9b9c73d8f12bcfc3ff4cfef76f61018a26b616f6 |
| --- /dev/null |
| +++ b/content/renderer/media/audio_output_client.h |
| @@ -0,0 +1,120 @@ |
| +// 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_AUDIO_OUTPUT_CLIENT_H_ |
| +#define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/files/file.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/shared_memory_handle.h" |
| +#include "base/sync_socket.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "content/common/content_export.h" |
| +#include "media/mojo/interfaces/audio_output.mojom.h" |
| +#include "mojo/edk/embedder/embedder.h" |
| +#include "mojo/public/c/system/buffer.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| +#include "mojo/public/cpp/bindings/interface_request.h" |
| +#include "mojo/public/cpp/system/handle.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace media { |
| +class AudioParameters; |
| +} |
| + |
| +namespace content { |
| + |
| +class AudioMessageFilter; |
| +class ServiceRegistry; |
| + |
| +class CONTENT_EXPORT AudioOutputClient { |
|
mcasas
2016/04/29 18:29:01
Please add class comments, including the
threading
|
| + public: |
| + typedef std::map<int, |
| + std::unique_ptr<media::interfaces::AudioOutputStreamPtr>> |
| + ScopedAudioOutputStreamPtrMap; |
|
mcasas
2016/04/29 18:29:01
using ScopedAudioOutputStreamPtrMap = ...
?
rchtara
2016/05/23 16:38:18
Done.
|
| + |
| + // Create a Mojo Audio Output Client. It's going to be created by |
|
mcasas
2016/04/29 18:29:01
Method documentation are descriptive:
s/Create/Cre
|
| + // RenderThreadImpl::init and be bound to RenderThread. This means that all |
|
mcasas
2016/04/29 18:29:01
init()
rchtara
2016/05/23 16:38:18
Done.
|
| + // future Mojo service calls and all Mojo callbacks are going to be |
| + // performed on the RenderThread. |
| + explicit AudioOutputClient( |
| + ServiceRegistry* service_registry, |
| + scoped_refptr<AudioMessageFilter> audio_message_filter); |
| + |
| + ~AudioOutputClient(); |
| + |
| + // Create stream by calling the AudioOutput.CreateStream Mojo interface |
| + // function using the Mojo service. This function could be called on any |
| + // thread and is going to call CreateStreamOnMainThread in the RenderThread. |
| + void CreateStream(int stream_id, |
| + int render_frame_id, |
| + const media::AudioParameters& params); |
| + |
| + // Create stream by calling the AudioOutput.CreateStream Mojo interface |
| + // function using the Mojo service. This function could be called on just |
| + // the RenderThread. |
| + void CreateStreamOnMainThread(int stream_id, |
| + int render_frame_id, |
| + const media::AudioParameters& params); |
| + |
| + // Callback for AudioOutput.CreateStream which contains information about |
| + // the new created stream. Called on RenderThread. This function is going to |
| + // notify the |audio_message_filter_| of the stream creation by calling |
| + // StreamCreated. StreamCreated could only be ran on |io_task_runner_| and |
| + // this is why CreateStreamOnIOThread is going to be used to do that. |
| + void CreateStreamCallback(int stream_id, |
| + media::interfaces::AudioOutputStreamPtr stream, |
| + mojo::ScopedSharedBufferHandle shared_buffer, |
| + mojo::ScopedHandle socket_descriptor); |
| + |
| + // Notify the |audio_message_filter_| of the stream creation. Can only be |
| + // called on |io_task_runner_|. |
| + void CreateStreamOnIOThread( |
| + media::interfaces::AudioOutputStreamPtr* const stream, |
| + base::SharedMemoryHandle handle, |
| + base::SyncSocket::TransitDescriptor socket_descriptor, |
| + uint32_t length); |
| + |
| + // Close stream by calling the AudioOutputStream.Close Mojo interface |
| + // function using the Mojo service. This function could be called on any |
| + // thread and is going to call CloseStreamOnMainThread in the RenderThread. |
| + void CloseStream(int stream_id); |
| + |
| + // Close stream by calling the AudioOutputStream.Close Mojo interface |
| + // function using the Mojo service. This function could be called on just the |
| + // RenderThread. |
| + void CloseStreamOnMainThread(int stream_id); |
| + |
| + // Called when there is an error with AudioOutputStream Mojo interface in |
| + // the renderer. This function is going to call ReportErrorOnIOThread in the |
| + // RenderThread. |
| + void OnStreamError(int stream_id); |
|
mcasas
2016/04/29 18:29:01
Can be private I believe. Check the
other methods
rchtara
2016/05/23 16:38:18
Done.
|
| + |
| + // Notify the |audio_message_filter_| of a stream error. Can only be called |
| + // on |io_task_runner_|. |
| + void ReportErrorOnIOThread(int stream_id); |
| + |
| + private: |
| + // Mojo connection error handler. |
| + void OnConnectionError(); |
| + |
| + scoped_refptr<AudioMessageFilter> audio_message_filter_; |
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
|
mcasas
2016/04/29 18:29:01
const.
Leave a blank line before the next comment
rchtara
2016/05/23 16:38:19
Done.
|
| + // The Mojo service. |
| + media::interfaces::AudioOutputPtr service_; |
| + ScopedAudioOutputStreamPtrMap streams_; |
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputClient); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_ |