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 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
6 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
12 #include "base/sync_socket.h" | 12 #include "base/sync_socket.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "ipc/ipc_channel_proxy.h" | 15 #include "ipc/message_filter.h" |
16 #include "media/audio/audio_output_ipc.h" | 16 #include "media/audio/audio_output_ipc.h" |
17 #include "media/base/audio_hardware_config.h" | 17 #include "media/base/audio_hardware_config.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class MessageLoopProxy; | 20 class MessageLoopProxy; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 // MessageFilter that handles audio messages and delegates them to audio | 25 // MessageFilter that handles audio messages and delegates them to audio |
26 // renderers. Created on render thread, AudioMessageFilter is operated on | 26 // renderers. Created on render thread, AudioMessageFilter is operated on |
27 // IO thread (secondary thread of render process) it intercepts audio messages | 27 // IO thread (secondary thread of render process) it intercepts audio messages |
28 // and process them on IO thread since these messages are time critical. | 28 // and process them on IO thread since these messages are time critical. |
29 class CONTENT_EXPORT AudioMessageFilter | 29 class CONTENT_EXPORT AudioMessageFilter : public IPC::MessageFilter { |
30 : public IPC::ChannelProxy::MessageFilter { | |
31 public: | 30 public: |
32 explicit AudioMessageFilter( | 31 explicit AudioMessageFilter( |
33 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); | 32 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
34 | 33 |
35 // Getter for the one AudioMessageFilter object. | 34 // Getter for the one AudioMessageFilter object. |
36 static AudioMessageFilter* Get(); | 35 static AudioMessageFilter* Get(); |
37 | 36 |
38 // Create an AudioOutputIPC to be owned by one delegate. |render_view_id| and | 37 // Create an AudioOutputIPC to be owned by one delegate. |render_view_id| and |
39 // |render_frame_id| are the render view and render frame containing the | 38 // |render_frame_id| are the render view and render frame containing the |
40 // entity producing the audio. | 39 // entity producing the audio. |
(...skipping 21 matching lines...) Expand all Loading... |
62 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic); | 61 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic); |
63 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates); | 62 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates); |
64 | 63 |
65 // Implementation of media::AudioOutputIPC which augments IPC calls with | 64 // Implementation of media::AudioOutputIPC which augments IPC calls with |
66 // stream_id and the source render_view_id. | 65 // stream_id and the source render_view_id. |
67 class AudioOutputIPCImpl; | 66 class AudioOutputIPCImpl; |
68 | 67 |
69 // Sends an IPC message using |channel_|. | 68 // Sends an IPC message using |channel_|. |
70 void Send(IPC::Message* message); | 69 void Send(IPC::Message* message); |
71 | 70 |
72 // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|. | 71 // IPC::MessageFilter override. Called on |io_message_loop|. |
73 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
74 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 73 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
75 virtual void OnFilterRemoved() OVERRIDE; | 74 virtual void OnFilterRemoved() OVERRIDE; |
76 virtual void OnChannelClosing() OVERRIDE; | 75 virtual void OnChannelClosing() OVERRIDE; |
77 | 76 |
78 // Received when browser process has created an audio output stream. | 77 // Received when browser process has created an audio output stream. |
79 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, | 78 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, |
80 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
81 base::SyncSocket::Handle socket_handle, | 80 base::SyncSocket::Handle socket_handle, |
82 #else | 81 #else |
(...skipping 27 matching lines...) Expand all Loading... |
110 | 109 |
111 // The singleton instance for this filter. | 110 // The singleton instance for this filter. |
112 static AudioMessageFilter* g_filter; | 111 static AudioMessageFilter* g_filter; |
113 | 112 |
114 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); | 113 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); |
115 }; | 114 }; |
116 | 115 |
117 } // namespace content | 116 } // namespace content |
118 | 117 |
119 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ | 118 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ |
OLD | NEW |