| Index: content/browser/renderer_host/media/audio_output_impl.h
|
| diff --git a/content/browser/renderer_host/media/audio_output_impl.h b/content/browser/renderer_host/media/audio_output_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e8e2f9dc04ab8b55a6361abf8912abedbee1ebed
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/media/audio_output_impl.h
|
| @@ -0,0 +1,72 @@
|
| +// 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_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
|
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +
|
| +// This class handles IPC for single stream by delegating method calls to its
|
| +// AudioOutputDelegate.
|
| +
|
| +#include "base/threading/thread_checker.h"
|
| +#include "content/browser/renderer_host/media/audio_output_delegate.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/common/media/audio_output.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +
|
| +namespace content {
|
| +
|
| +class CONTENT_EXPORT AudioOutputImpl
|
| + : public mojom::AudioOutput,
|
| + public AudioOutputDelegate::EventHandler {
|
| + public:
|
| + using CreateDelegateCallback =
|
| + base::OnceCallback<std::unique_ptr<AudioOutputDelegate>(
|
| + AudioOutputDelegate::EventHandler*,
|
| + const media::AudioParameters&)>;
|
| + using FinishedCallback = base::OnceCallback<void(mojom::AudioOutput*)>;
|
| +
|
| + // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the
|
| + // stream when it's started and |finished_callback| is called when this class
|
| + // should be removed (stream ended/error).
|
| + AudioOutputImpl(mojom::AudioOutputRequest request,
|
| + CreateDelegateCallback create_delegate_callback,
|
| + FinishedCallback finished_callback);
|
| +
|
| + ~AudioOutputImpl() override;
|
| +
|
| + private:
|
| + // mojom::AudioOutput implementation.
|
| + void Start(const media::AudioParameters& params,
|
| + const StartCallback& callback) override;
|
| + void Play() override;
|
| + void Pause() override;
|
| + void SetVolume(double volume) override;
|
| +
|
| + // AudioOutputDelegate::EventHandler implementation.
|
| + void OnStreamCreated(int stream_id,
|
| + base::SharedMemory* shared_memory,
|
| + base::CancelableSyncSocket* foreign_socket) override;
|
| + void OnStreamError(int stream_id) override;
|
| +
|
| + // Closes connection to client and notifies owner.
|
| + void OnError();
|
| +
|
| + // The callback for the Start() must be stored until the response is ready.
|
| + StartCallback start_callback_;
|
| +
|
| + mojo::Binding<AudioOutput> binding_;
|
| + CreateDelegateCallback create_delegate_callback_;
|
| + FinishedCallback finished_callback_;
|
| + std::unique_ptr<AudioOutputDelegate> delegate_;
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
|
|
|