| 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 2fa7d353ae2b9445b1c137f46c4e0eef2a7f136d..c19b3be77b268b8ef126c3d6216d155720d7472a 100644
|
| --- a/content/browser/renderer_host/media/audio_renderer_host.h
|
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h
|
| @@ -46,15 +46,19 @@
|
| #include <memory>
|
| #include <string>
|
| #include <utility>
|
| +#include <vector>
|
|
|
| #include "base/atomic_ref_count.h"
|
| #include "base/gtest_prod_util.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/memory/shared_memory.h"
|
| #include "base/process/process.h"
|
| #include "base/sequenced_task_runner_helpers.h"
|
| +#include "base/sync_socket.h"
|
| #include "content/browser/renderer_host/media/audio_output_authorization_handler.h"
|
| +#include "content/browser/renderer_host/media/audio_output_delegate.h"
|
| #include "content/browser/renderer_host/media/media_devices_manager.h"
|
| #include "content/common/content_export.h"
|
| #include "content/public/browser/browser_message_filter.h"
|
| @@ -62,7 +66,6 @@
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/resource_context.h"
|
| #include "media/audio/audio_io.h"
|
| -#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"
|
| @@ -76,16 +79,16 @@ class AudioParameters;
|
| namespace content {
|
|
|
| class AudioMirroringManager;
|
| -class MediaInternals;
|
| class MediaStreamManager;
|
|
|
| -class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
| +class CONTENT_EXPORT AudioRendererHost
|
| + : public BrowserMessageFilter,
|
| + private AudioOutputDelegate::EventHandler {
|
| public:
|
| // Called from UI thread from the owner of this object.
|
| AudioRendererHost(int render_process_id,
|
| media::AudioManager* audio_manager,
|
| AudioMirroringManager* mirroring_manager,
|
| - MediaInternals* media_internals,
|
| MediaStreamManager* media_stream_manager,
|
| const std::string& salt);
|
|
|
| @@ -114,13 +117,12 @@ 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.
|
| // |have_access| is true only if there is permission to access the device.
|
| typedef base::Callback<void(bool have_access)> OutputDeviceAccessCB;
|
|
|
| + using AudioOutputDelegateList = std::vector<AudioOutputDelegate::UniquePtr>;
|
| +
|
| // The type of a function that is run on the UI thread to check whether the
|
| // routing IDs reference a valid RenderFrameHost. The function then runs
|
| // |callback| on the IO thread with true/false if valid/invalid.
|
| @@ -131,6 +133,13 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
|
|
| ~AudioRendererHost() override;
|
|
|
| + // AudioOutputDelegate::EventHandler implementation
|
| + void OnStreamCreated(int stream_id,
|
| + base::SharedMemory* shared_memory,
|
| + base::CancelableSyncSocket* foreign_socket) override;
|
| + void OnStreamError(int stream_id) override;
|
| + void OnStreamStateChanged(bool is_playing) override;
|
| +
|
| // Methods called on IO thread ----------------------------------------------
|
|
|
| // Audio related IPC message handlers.
|
| @@ -178,13 +187,8 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
|
|
| // Helper methods.
|
|
|
| - // 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);
|
| -
|
| // Called after the |render_frame_id| provided to OnCreateStream() was
|
| - // validated. When |is_valid| is false, this calls ReportErrorAndClose().
|
| + // validated. When |is_valid| is false, this calls OnStreamError().
|
| void DidValidateRenderFrame(int stream_id, bool is_valid);
|
|
|
| // Updates status of stream for AudioStreamMonitor and updates
|
| @@ -196,20 +200,11 @@ 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
|
| - // 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);
|
| -
|
| - // A helper method to look up a AudioEntry identified by |stream_id|.
|
| - // Returns NULL if not found.
|
| - AudioEntry* LookupById(int 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.
|
| - void UpdateNumPlayingStreams(AudioEntry* entry, bool is_playing);
|
| + // Helper methods to look up a AudioOutputDelegate identified by |stream_id|.
|
| + // Returns delegates_.end() if not found.
|
| + AudioOutputDelegateList::iterator LookupIteratorById(int stream_id);
|
| + // Returns nullptr if not found.
|
| + AudioOutputDelegate* LookupById(int stream_id);
|
|
|
| // Helper method to check if the authorization procedure for stream
|
| // |stream_id| has started.
|
| @@ -227,10 +222,12 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter {
|
|
|
| media::AudioManager* const audio_manager_;
|
| AudioMirroringManager* const mirroring_manager_;
|
| - std::unique_ptr<media::AudioLog> audio_log_;
|
|
|
| - // A map of stream IDs to audio sources.
|
| - AudioEntryMap audio_entries_;
|
| + // Used to access to AudioInputDeviceManager.
|
| + MediaStreamManager* media_stream_manager_;
|
| +
|
| + // A list of the current open streams.
|
| + AudioOutputDelegateList delegates_;
|
|
|
| // The number of streams in the playing state. Atomic read safe from any
|
| // thread, but should only be updated from the IO thread.
|
|
|