| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // AudioRendererHost serves audio related requests from AudioRenderer which | 5 // AudioRendererHost serves audio related requests from AudioRenderer which |
| 6 // lives inside the render process and provide access to audio hardware. | 6 // lives inside the render process and provide access to audio hardware. |
| 7 // | 7 // |
| 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI |
| 9 // thread, but all other operations and method calls happen on IO thread, so we | 9 // thread, but all other operations and method calls happen on IO thread, so we |
| 10 // need to be extra careful about the lifetime of this object. AudioManager is a | 10 // need to be extra careful about the lifetime of this object. AudioManager is a |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace media { | 55 namespace media { |
| 56 class AudioManager; | 56 class AudioManager; |
| 57 class AudioParameters; | 57 class AudioParameters; |
| 58 } | 58 } |
| 59 | 59 |
| 60 namespace content { | 60 namespace content { |
| 61 | 61 |
| 62 class AudioMirroringManager; | 62 class AudioMirroringManager; |
| 63 class MediaInternals; | 63 class MediaInternals; |
| 64 class MediaStreamManager; |
| 64 class ResourceContext; | 65 class ResourceContext; |
| 65 | 66 |
| 66 class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { | 67 class CONTENT_EXPORT AudioRendererHost : public BrowserMessageFilter { |
| 67 public: | 68 public: |
| 68 // Called from UI thread from the owner of this object. | 69 // Called from UI thread from the owner of this object. |
| 69 AudioRendererHost(int render_process_id, | 70 AudioRendererHost(int render_process_id, |
| 70 media::AudioManager* audio_manager, | 71 media::AudioManager* audio_manager, |
| 71 AudioMirroringManager* mirroring_manager, | 72 AudioMirroringManager* mirroring_manager, |
| 72 MediaInternals* media_internals); | 73 MediaInternals* media_internals, |
| 74 MediaStreamManager* media_stream_manager); |
| 73 | 75 |
| 74 // BrowserMessageFilter implementation. | 76 // BrowserMessageFilter implementation. |
| 75 virtual void OnChannelClosing() OVERRIDE; | 77 virtual void OnChannelClosing() OVERRIDE; |
| 76 virtual void OnDestruct() const OVERRIDE; | 78 virtual void OnDestruct() const OVERRIDE; |
| 77 virtual bool OnMessageReceived(const IPC::Message& message, | 79 virtual bool OnMessageReceived(const IPC::Message& message, |
| 78 bool* message_was_ok) OVERRIDE; | 80 bool* message_was_ok) OVERRIDE; |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 friend class AudioRendererHostTest; | 83 friend class AudioRendererHostTest; |
| 82 friend class BrowserThread; | 84 friend class BrowserThread; |
| 83 friend class base::DeleteHelper<AudioRendererHost>; | 85 friend class base::DeleteHelper<AudioRendererHost>; |
| 84 friend class MockAudioRendererHost; | 86 friend class MockAudioRendererHost; |
| 85 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); | 87 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); |
| 86 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); | 88 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
| 87 | 89 |
| 88 class AudioEntry; | 90 class AudioEntry; |
| 89 typedef std::map<int, AudioEntry*> AudioEntryMap; | 91 typedef std::map<int, AudioEntry*> AudioEntryMap; |
| 90 | 92 |
| 91 virtual ~AudioRendererHost(); | 93 virtual ~AudioRendererHost(); |
| 92 | 94 |
| 93 // Methods called on IO thread ---------------------------------------------- | 95 // Methods called on IO thread ---------------------------------------------- |
| 94 | 96 |
| 95 // Audio related IPC message handlers. | 97 // Audio related IPC message handlers. |
| 96 | 98 |
| 97 // Creates an audio output stream with the specified format whose data is | 99 // Creates an audio output stream with the specified format whose data is |
| 98 // produced by an entity in the render view referenced by |render_view_id|. | 100 // produced by an entity in the render view referenced by |render_view_id|. |
| 101 // |session_id| is used for unified IO to find out which input device to be |
| 102 // opened for the stream. For clients that do not use unified IO, |
| 103 // |session_id| will be ignored. |
| 99 // Upon success/failure, the peer is notified via the NotifyStreamCreated | 104 // Upon success/failure, the peer is notified via the NotifyStreamCreated |
| 100 // message. | 105 // message. |
| 101 void OnCreateStream(int stream_id, | 106 void OnCreateStream(int stream_id, |
| 102 int render_view_id, | 107 int render_view_id, |
| 108 int session_id, |
| 103 const media::AudioParameters& params); | 109 const media::AudioParameters& params); |
| 104 | 110 |
| 105 // Play the audio stream referenced by |stream_id|. | 111 // Play the audio stream referenced by |stream_id|. |
| 106 void OnPlayStream(int stream_id); | 112 void OnPlayStream(int stream_id); |
| 107 | 113 |
| 108 // Pause the audio stream referenced by |stream_id|. | 114 // Pause the audio stream referenced by |stream_id|. |
| 109 void OnPauseStream(int stream_id); | 115 void OnPauseStream(int stream_id); |
| 110 | 116 |
| 111 // Close the audio stream referenced by |stream_id|. | 117 // Close the audio stream referenced by |stream_id|. |
| 112 void OnCloseStream(int stream_id); | 118 void OnCloseStream(int stream_id); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 136 // Returns NULL if not found. | 142 // Returns NULL if not found. |
| 137 AudioEntry* LookupById(int stream_id); | 143 AudioEntry* LookupById(int stream_id); |
| 138 | 144 |
| 139 // ID of the RenderProcessHost that owns this instance. | 145 // ID of the RenderProcessHost that owns this instance. |
| 140 const int render_process_id_; | 146 const int render_process_id_; |
| 141 | 147 |
| 142 media::AudioManager* const audio_manager_; | 148 media::AudioManager* const audio_manager_; |
| 143 AudioMirroringManager* const mirroring_manager_; | 149 AudioMirroringManager* const mirroring_manager_; |
| 144 MediaInternals* const media_internals_; | 150 MediaInternals* const media_internals_; |
| 145 | 151 |
| 152 // Used to access to AudioInputDeviceManager. |
| 153 MediaStreamManager* media_stream_manager_; |
| 154 |
| 146 // A map of stream IDs to audio sources. | 155 // A map of stream IDs to audio sources. |
| 147 AudioEntryMap audio_entries_; | 156 AudioEntryMap audio_entries_; |
| 148 | 157 |
| 149 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 158 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
| 150 }; | 159 }; |
| 151 | 160 |
| 152 } // namespace content | 161 } // namespace content |
| 153 | 162 |
| 154 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 163 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
| OLD | NEW |