| 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 e549df20cc94f0778b29efcfc7bc0f93e3b23677..34225d37e3dc6d319897c356bd09d86fb1e28738 100644
|
| --- a/content/browser/renderer_host/media/audio_renderer_host.h
|
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h
|
| @@ -49,12 +49,14 @@
|
| #include "base/atomic_ref_count.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/shared_memory.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/process/process.h"
|
| #include "base/sequenced_task_runner_helpers.h"
|
| #include "content/browser/renderer_host/media/audio_output_device_enumerator.h"
|
| #include "content/common/content_export.h"
|
| +#include "content/common/media/audio_output.mojom.h"
|
| #include "content/public/browser/browser_message_filter.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/render_process_host.h"
|
| @@ -73,11 +75,78 @@ class AudioParameters;
|
| namespace content {
|
|
|
| class AudioMirroringManager;
|
| +class AudioRendererHost;
|
| class MediaInternals;
|
| class MediaStreamManager;
|
| class MediaStreamUIProxy;
|
| class ResourceContext;
|
|
|
| +class CONTENT_EXPORT AudioEntry
|
| + : public media::AudioOutputController::EventHandler {
|
| + public:
|
| + AudioEntry(AudioRendererHost* host,
|
| + int stream_id,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params,
|
| + const std::string& output_device_id,
|
| + scoped_ptr<base::SharedMemory> shared_memory,
|
| + scoped_ptr<media::AudioOutputController::SyncReader> reader);
|
| +
|
| + AudioEntry(AudioRendererHost* host,
|
| + int stream_id,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params,
|
| + const std::string& output_device_id,
|
| + scoped_ptr<base::SharedMemory> shared_memory,
|
| + scoped_ptr<media::AudioOutputController::SyncReader> reader,
|
| + mojom::AudioOutputStreamPtr stream,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback);
|
| +
|
| + ~AudioEntry() override;
|
| +
|
| + int stream_id() const { return stream_id_; }
|
| +
|
| + int render_frame_id() const { return render_frame_id_; }
|
| +
|
| + media::AudioOutputController* controller() const { return controller_.get(); }
|
| +
|
| + base::SharedMemory* shared_memory() { return shared_memory_.get(); }
|
| +
|
| + media::AudioOutputController::SyncReader* reader() const {
|
| + return reader_.get();
|
| + }
|
| +
|
| + bool playing() const { return playing_; }
|
| + void set_playing(bool playing) { playing_ = playing; }
|
| +
|
| + private:
|
| + // media::AudioOutputController::EventHandler implementation.
|
| + void OnCreated(
|
| + mojom::AudioOutputStreamPtr stream,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback) override;
|
| + void OnCreated() override;
|
| + void OnPlaying() override;
|
| + void OnPaused() override;
|
| + void OnError() override;
|
| +
|
| + AudioRendererHost* const host_;
|
| + const int stream_id_;
|
| +
|
| + // The routing ID of the source RenderFrame.
|
| + const int render_frame_id_;
|
| +
|
| + // Shared memory for transmission of the audio data. Used by |reader_|.
|
| + const scoped_ptr<base::SharedMemory> shared_memory_;
|
| +
|
| + // The synchronous reader to be used by |controller_|.
|
| + const scoped_ptr<media::AudioOutputController::SyncReader> reader_;
|
| +
|
| + // The AudioOutputController that manages the audio stream.
|
| + const scoped_refptr<media::AudioOutputController> controller_;
|
| +
|
| + bool playing_;
|
| +};
|
| +
|
| class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| public:
|
| // Called from UI thread from the owner of this object.
|
| @@ -106,7 +175,31 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // |render_frame_id| are actively playing. Can be called from any thread.
|
| bool RenderFrameHasActiveAudio(int render_frame_id) const;
|
|
|
| + // 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,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params);
|
| +
|
| + // Creates an audio output stream with the specified format.
|
| + // Upon success/failure, the peer is notified via the NotifyStreamCreated
|
| + // message.
|
| + void OnCreateStreamMojo(
|
| + int stream_id,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params,
|
| + mojom::AudioOutputStreamPtr stream,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback);
|
| +
|
| + // Close the audio stream referenced by |stream_id|.
|
| + void OnCloseStream(int stream_id);
|
| +
|
| + // Play the audio stream referenced by |stream_id|.
|
| + void OnPlayEntry(AudioEntry* entry);
|
| +
|
| private:
|
| + friend class AudioEntry;
|
| friend class AudioRendererHostTest;
|
| friend class BrowserThread;
|
| friend class base::DeleteHelper<AudioRendererHost>;
|
| @@ -115,7 +208,6 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream);
|
| FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation);
|
|
|
| - class AudioEntry;
|
| typedef std::map<int, AudioEntry*> AudioEntryMap;
|
|
|
| // Internal callback type for access requests to output devices.
|
| @@ -149,22 +241,12 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| const std::string& device_id,
|
| const url::Origin& gurl_security_origin);
|
|
|
| - // 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,
|
| - int render_frame_id,
|
| - const media::AudioParameters& params);
|
| -
|
| // Play the audio stream referenced by |stream_id|.
|
| void OnPlayStream(int stream_id);
|
|
|
| // Pause the audio stream referenced by |stream_id|.
|
| void OnPauseStream(int stream_id);
|
|
|
| - // Close the audio stream referenced by |stream_id|.
|
| - void OnCloseStream(int stream_id);
|
| -
|
| // Set the volume of the audio stream referenced by |stream_id|.
|
| void OnSetVolume(int stream_id, double volume);
|
|
|
| @@ -186,6 +268,15 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| void DoCreateStream(int stream_id,
|
| int render_frame_id,
|
| const media::AudioParameters& params,
|
| + const std::string& device_unique_id,
|
| + mojom::AudioOutputStreamPtr stream,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback);
|
| +
|
| + // Start the actual creation of an audio stream, after the device
|
| + // authorization process is complete.
|
| + void DoCreateStream(int stream_id,
|
| + int render_frame_id,
|
| + const media::AudioParameters& params,
|
| const std::string& device_unique_id);
|
|
|
| // Complete the process of creating an audio stream. This will set up the
|
| @@ -193,6 +284,12 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // NotifyStreamCreated message to the peer.
|
| void DoCompleteCreation(int stream_id);
|
|
|
| + // 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 DoCompleteCreationMojo(
|
| + int stream_id,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback);
|
| // Send playing/paused status to the renderer.
|
| void DoNotifyStreamStateChanged(int stream_id, bool is_playing);
|
|
|
| @@ -208,6 +305,11 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // Send an error message to the renderer, then close the stream.
|
| void ReportErrorAndClose(int stream_id);
|
|
|
| + // Send an error message to the renderer, then close the stream.
|
| + void ReportErrorAndCloseMojo(
|
| + int stream_id,
|
| + const mojom::AudioOutput::CreateStreamCallback& callback);
|
| +
|
| // A helper method to look up a AudioEntry identified by |stream_id|.
|
| // Returns NULL if not found.
|
| AudioEntry* LookupById(int stream_id);
|
| @@ -267,6 +369,8 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| // host. Reported as UMA stat at shutdown.
|
| size_t max_simultaneous_streams_;
|
|
|
| + mojom::AudioOutputStreamPtr stream_ptr_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
|
| };
|
|
|
|
|