| 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..3af560b2edfbb1225dc2a550b625ed248708f26d
|
| --- /dev/null
|
| +++ b/content/renderer/media/audio_output_client.h
|
| @@ -0,0 +1,92 @@
|
| +// Copyright 2015 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 "content/common/media/audio_output.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +#include "mojo/public/cpp/bindings/interface_request.h"
|
| +
|
| +namespace base {
|
| +class SingleThreadTaskRunner;
|
| +}
|
| +
|
| +namespace media {
|
| +class AudioParameters;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +class ServiceRegistry;
|
| +
|
| +// All functions must only be accessed from the creation thread.
|
| +class CONTENT_EXPORT AudioOutputClient {
|
| + public:
|
| + explicit AudioOutputClient(ServiceRegistry* service_registry);
|
| +
|
| + // Getter for the one AudioOutputClient object.
|
| + static AudioOutputClient* Get();
|
| +
|
| + ~AudioOutputClient();
|
| +
|
| + void CreateStream(int stream_id_,
|
| + int render_frame_id_,
|
| + const media::AudioParameters& params);
|
| + void CreateStreamCallback(mojom::AudioOutputStreamPtr stream,
|
| + int stream_id,
|
| + mojo::ScopedSharedBufferHandle shared_buffer,
|
| + mojo::ScopedHandle socket_descriptor);
|
| + void CreateStreamOnIOThread(
|
| + mojom::AudioOutputStreamPtr* stream,
|
| + int stream_id,
|
| + base::SharedMemoryHandle handle,
|
| + base::SyncSocket::TransitDescriptor socket_descriptor,
|
| + uint32_t length);
|
| + void CreateStreamOnMainThread(int stream_id,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params);
|
| +
|
| + void PlayStreamCallback(bool success);
|
| + void PlayStream(mojom::AudioOutputStreamPtr* stream);
|
| + void PlayStreamOnMainThread(mojom::AudioOutputStreamPtr* stream);
|
| +
|
| + void CloseStream(int id);
|
| + void CloseStreamOnMainThread(int id);
|
| +
|
| + void ReportErrorOnIOThread(int stream_id);
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<AudioOutputClient>;
|
| +
|
| + // Mojo connection error handler.
|
| + void OnConnectionError();
|
| +
|
| + // The Mojo service for registering observers to listen for enable/disable
|
| + // events.
|
| + mojom::AudioOutputPtr service_;
|
| + std::map<int, mojom::AudioOutputStreamPtr*> streams_;
|
| +
|
| + // The singleton instance for this.
|
| + static AudioOutputClient* g_filter;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputClient);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
|
|
|