Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 2289543003: IPC->mojo of audio_renderer_host (Closed)
Patch Set: New interface. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..79a59922021874b80ba6d2abc633654d9065523c 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,23 +101,22 @@ 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);
+ int32_t next_stream_id_;
class AudioEntry;
typedef std::map<int, AudioEntry*> AudioEntryMap;
@@ -136,61 +142,65 @@ 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
// opened for the stream. For clients that do not use unified IO,
// |session_id| will be ignored and the given |device_id| and
// |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(
+ int64_t render_frame_id,
+ int64_t session_id,
+ const mojo::String& device_id,
+ const url::Origin& origin,
+ const RequestDeviceAuthorizationCallback& callback) override;
+
+ void SendAuthorizationMessage(RequestDeviceAuthorizationCallback callback,
+ int32_t 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.
- void OnCreateStream(int stream_id,
+ void OnCreateStream(int32_t stream_id,
int render_frame_id,
const media::AudioParameters& params);
// Play the audio stream referenced by |stream_id|.
- void OnPlayStream(int stream_id);
+ void OnPlayStream(int32_t stream_id);
// Pause the audio stream referenced by |stream_id|.
- void OnPauseStream(int stream_id);
+ void OnPauseStream(int32_t stream_id);
// Close the audio stream referenced by |stream_id|.
- void OnCloseStream(int stream_id);
+ void OnCloseStream(int32_t stream_id);
// Set the volume of the audio stream referenced by |stream_id|.
- void OnSetVolume(int stream_id, double volume);
-
- // Helper methods.
+ void OnSetVolume(int32_t stream_id, double volume);
// Proceed with device authorization after checking permissions.
- void OnDeviceAuthorized(int stream_id,
+ void OnDeviceAuthorized(int32_t stream_id,
+ RequestDeviceAuthorizationCallback callback,
const std::string& device_id,
const url::Origin& security_origin,
base::TimeTicks auth_start_time,
bool have_access);
// Proceed with device authorization after translating device ID.
- void OnDeviceIDTranslated(int stream_id,
+ void OnDeviceIDTranslated(int32_t stream_id,
base::TimeTicks auth_start_time,
+ RequestDeviceAuthorizationCallback callback,
bool device_found,
const AudioOutputDeviceInfo& device_info);
// Start the actual creation of an audio stream, after the device
// authorization process is complete.
- void DoCreateStream(int stream_id,
+ void DoCreateStream(int32_t stream_id,
int render_frame_id,
const media::AudioParameters& params,
const std::string& device_unique_id,
@@ -199,26 +209,26 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// 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, int32_t stream_id);
// Send playing/paused status to the renderer.
- void DoNotifyStreamStateChanged(int stream_id, bool is_playing);
+ // void DoNotifyStreamStateChanged(int32_t stream_id, bool is_playing);
RenderProcessHost::AudioOutputControllerList DoGetOutputControllers() const;
// Send an error message to the renderer.
- void SendErrorMessage(int stream_id);
+ void SendErrorMessage(int32_t 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);
// Send an error message to the renderer, then close the stream.
- void ReportErrorAndClose(int stream_id);
+ void ReportErrorAndClose(int32_t stream_id);
// A helper method to look up a AudioEntry identified by |stream_id|.
// Returns NULL if not found.
- AudioEntry* LookupById(int stream_id);
+ AudioEntry* LookupById(int32_t stream_id);
// A helper method to update the number of playing streams and alert the
// ResourceScheduler when the renderer starts or stops playing an audiostream.
@@ -233,7 +243,7 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// Invoke |callback| after permission to use a device has been checked.
void AccessChecked(std::unique_ptr<MediaStreamUIProxy> ui_proxy,
const OutputDeviceAccessCB& callback,
- bool have_access);
+ ool have_access);
// Translate the hashed |device_id| to a unique device ID.
void TranslateDeviceID(const std::string& device_id,
@@ -243,7 +253,7 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
// Helper method to check if the authorization procedure for stream
// |stream_id| has started.
- bool IsAuthorizationStarted(int stream_id);
+ bool IsAuthorizationStarted(int32_t stream_id);
#if DCHECK_IS_ON()
// Called from AudioRendererHostTest to override the function that checks for
@@ -291,6 +301,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);
};
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_renderer_host.cc » ('j') | media/mojo/interfaces/audio_output.mojom » ('J')

Powered by Google App Engine
This is Rietveld 408576698