Chromium Code Reviews| 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..8530ffa17c2e670298429619080c4404f7a45122 100644 |
| --- a/content/browser/renderer_host/media/audio_renderer_host.h |
| +++ b/content/browser/renderer_host/media/audio_renderer_host.h |
| @@ -40,33 +40,22 @@ |
| #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| -#include <stddef.h> |
| - |
| #include <map> |
| #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/process/process.h" |
| -#include "base/sequenced_task_runner_helpers.h" |
| #include "content/browser/renderer_host/media/audio_output_authorization_handler.h" |
| -#include "content/browser/renderer_host/media/media_devices_manager.h" |
| +#include "content/browser/renderer_host/media/audio_output_delegate.h" |
| #include "content/common/content_export.h" |
| #include "content/public/browser/browser_message_filter.h" |
| -#include "content/public/browser/browser_thread.h" |
| #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" |
| -#include "url/origin.h" |
| + |
| +namespace base { |
| +class SharedMemory; |
| +class CancelableSyncSocket; |
| +} |
| namespace media { |
| class AudioManager; |
| @@ -76,16 +65,16 @@ class AudioParameters; |
| namespace content { |
| class AudioMirroringManager; |
| -class MediaInternals; |
| class MediaStreamManager; |
| -class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
| +class CONTENT_EXPORT AudioRendererHost |
| + : public BrowserMessageFilter, |
| + public 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); |
| @@ -99,6 +88,13 @@ class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
| void OnDestruct() const override; |
| bool OnMessageReceived(const IPC::Message& message) 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; |
| + |
| // Returns true if any streams managed by this host are actively playing. Can |
| // be called from any thread. |
| bool HasActiveAudio(); |
| @@ -114,13 +110,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>; |
|
DaleCurtis
2016/12/02 18:20:13
DelegateVector for clarity?
|
| + |
| // 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. |
| @@ -178,13 +173,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 +186,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 +208,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. |