| Index: content/browser/renderer_host/media/audio_renderer_host.h
|
| diff --git a/content/browser/renderer_host/media/audio_renderer_host.h b/content/browser/renderer_host/media/audio_renderer_host.h
|
| index d72a5e67c09b97a4ba8aefa601749f56c98c5589..66d681f99dadf3615bd2654ae0ff844d12d1302b 100644
|
| --- a/content/browser/renderer_host/media/audio_renderer_host.h
|
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h
|
| @@ -64,6 +64,10 @@
|
| #include "media/audio/audio_logging.h"
|
| #include "media/audio/audio_output_controller.h"
|
| #include "media/audio/simple_sources.h"
|
| +#include "media/base/output_device_info.h"
|
| +#include "media/mojo/interfaces/audio_output.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +#include "mojo/public/cpp/bindings/interface_request.h"
|
| #include "url/origin.h"
|
|
|
| namespace media {
|
| @@ -79,7 +83,10 @@ class MediaStreamManager;
|
| class MediaStreamUIProxy;
|
| class ResourceContext;
|
|
|
| -class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| +class CONTENT_EXPORT AudioRendererHost
|
| + : public base::RefCountedThreadSafe<AudioRendererHost,
|
| + BrowserThread::DeleteOnIOThread>,
|
| + NON_EXPORTED_BASE(private media::mojom::AudioOutput) {
|
| public:
|
| // Called from UI thread from the owner of this object.
|
| AudioRendererHost(int render_process_id,
|
| @@ -94,21 +101,19 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| const RenderProcessHost::GetAudioOutputControllersCallback&
|
| callback) const;
|
|
|
| - // BrowserMessageFilter implementation.
|
| - void OnChannelClosing() override;
|
| - void OnDestruct() const override;
|
| - bool OnMessageReceived(const IPC::Message& message) override;
|
| -
|
| - // Returns true if any streams managed by this host are actively playing. Can
|
| + // Returns true if any streams managed by this host are actively playing. Can
|
| // be called from any thread.
|
| bool HasActiveAudio();
|
|
|
| + void BindRequest(media::mojom::AudioOutputRequest request);
|
| +
|
| private:
|
| friend class AudioRendererHostTest;
|
| friend class BrowserThread;
|
| friend class base::DeleteHelper<AudioRendererHost>;
|
| friend class MockAudioRendererHost;
|
| friend class TestAudioRendererHost;
|
| + friend class base::RefCounted<AudioRendererHost>;
|
| FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream);
|
| FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation);
|
|
|
| @@ -136,10 +141,6 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
|
|
| ~AudioRendererHost() override;
|
|
|
| - // Methods called on IO thread ----------------------------------------------
|
| -
|
| - // Audio related IPC message handlers.
|
| -
|
| // Request permission to use an output device for use by a stream produced
|
| // in the RenderFrame referenced by |render_frame_id|.
|
| // |session_id| is used for unified IO to find out which input device to be
|
| @@ -148,12 +149,29 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // |security_origin| will be used to select the output device.
|
| // Upon completion of the process, the peer is notified with the device output
|
| // parameters via the NotifyDeviceAuthorized message.
|
| - void OnRequestDeviceAuthorization(int stream_id,
|
| - int render_frame_id,
|
| - int session_id,
|
| - const std::string& device_id,
|
| - const url::Origin& security_origin);
|
| + void RequestDeviceAuthorization(
|
| + int stream_id,
|
| + int render_frame_id,
|
| + int session_id,
|
| + const mojo::String& device_id,
|
| + const url::Origin& origin,
|
| + const RequestDeviceAuthorizationCallback& callback) override;
|
| + void CreateStream(int stream_id,
|
| + int render_frame_id,
|
| + media::mojom::AudioOutputStreamClientPtr client,
|
| + const media::AudioParameters& params,
|
| + const CreateStreamCallback& callback) override;
|
| + void CloseStream(int stream_id) override;
|
| +
|
| + void SendAuthorizationMessage(RequestDeviceAuthorizationCallback callback,
|
| + int stream_id,
|
| + media::OutputDeviceStatus status,
|
| + const media::AudioParameters& params,
|
| + const std::string& matched_device_id);
|
|
|
| + // Methods called on IO thread ----------------------------------------------
|
| +
|
| + // Audio related IPC message handlers.
|
| // Creates an audio output stream with the specified format.
|
| // Upon success/failure, the peer is notified via the NotifyStreamCreated
|
| // message.
|
| @@ -173,10 +191,9 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // Set the volume of the audio stream referenced by |stream_id|.
|
| void OnSetVolume(int stream_id, double volume);
|
|
|
| - // Helper methods.
|
| -
|
| // Proceed with device authorization after checking permissions.
|
| void OnDeviceAuthorized(int stream_id,
|
| + RequestDeviceAuthorizationCallback callback,
|
| const std::string& device_id,
|
| const url::Origin& security_origin,
|
| base::TimeTicks auth_start_time,
|
| @@ -185,6 +202,7 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // Proceed with device authorization after translating device ID.
|
| void OnDeviceIDTranslated(int stream_id,
|
| base::TimeTicks auth_start_time,
|
| + RequestDeviceAuthorizationCallback callback,
|
| bool device_found,
|
| const AudioOutputDeviceInfo& device_info);
|
|
|
| @@ -194,12 +212,16 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| int render_frame_id,
|
| const media::AudioParameters& params,
|
| const std::string& device_unique_id,
|
| + media::mojom::AudioOutputStreamClientPtr client,
|
| + CreateStreamCallback callback,
|
| bool render_frame_id_is_valid);
|
|
|
| // Complete the process of creating an audio stream. This will set up the
|
| // shared memory or shared socket in low latency mode and send the
|
| // NotifyStreamCreated message to the peer.
|
| - void DoCompleteCreation(int stream_id);
|
| + void DoCompleteCreation(AudioEntry* entry,
|
| + int stream_id,
|
| + CreateStreamCallback callback);
|
|
|
| // Send playing/paused status to the renderer.
|
| void DoNotifyStreamStateChanged(int stream_id, bool is_playing);
|
| @@ -209,7 +231,7 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // Send an error message to the renderer.
|
| void SendErrorMessage(int stream_id);
|
|
|
| - // Delete an audio entry, notifying observers first. This is called by
|
| + // Delete an audio entry, notifying observers first. This is called by
|
| // AudioOutputController after it has closed.
|
| void DeleteEntry(std::unique_ptr<AudioEntry> entry);
|
|
|
| @@ -291,6 +313,9 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // host. Reported as UMA stat at shutdown.
|
| size_t max_simultaneous_streams_;
|
|
|
| + // Binds AudioRendererHost to a media::mojom::AudioOutputRequest.
|
| + std::unique_ptr<mojo::Binding<media::mojom::AudioOutput>> binding_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
|
| };
|
|
|
|
|