| 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 // MessageFilter that handles audio input messages and delegates them to | 5 // MessageFilter that handles audio input messages and delegates them to |
| 6 // audio capturers. Created on render thread, AudioMessageFilter is operated on | 6 // audio capturers. Created on render thread, AudioMessageFilter is operated on |
| 7 // IO thread (secondary thread of render process), it intercepts audio messages | 7 // IO thread (secondary thread of render process), it intercepts audio messages |
| 8 // and process them on IO thread since these messages are time critical. | 8 // and process them on IO thread since these messages are time critical. |
| 9 | 9 |
| 10 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ | 10 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ |
| 11 #define CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ | 11 #define CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ |
| 12 | 12 |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
| 15 #include "base/sync_socket.h" | 15 #include "base/sync_socket.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "ipc/ipc_channel_proxy.h" | 17 #include "ipc/ipc_channel_proxy.h" |
| 18 #include "media/audio/audio_buffers_state.h" | 18 #include "media/audio/audio_buffers_state.h" |
| 19 #include "media/audio/audio_input_ipc.h" | 19 #include "media/audio/audio_input_ipc.h" |
| 20 | 20 |
| 21 class CONTENT_EXPORT AudioInputMessageFilter | 21 class CONTENT_EXPORT AudioInputMessageFilter |
| 22 : public IPC::ChannelProxy::MessageFilter, | 22 : public IPC::ChannelProxy::MessageFilter { |
| 23 public NON_EXPORTED_BASE(media::AudioInputIPC) { | |
| 24 public: | 23 public: |
| 25 AudioInputMessageFilter(); | 24 AudioInputMessageFilter(); |
| 26 | 25 |
| 27 // Getter for the one AudioInputMessageFilter object. | 26 // Creates an AudioInputIPC which is used to send messages to/from the host |
| 28 static AudioInputMessageFilter* Get(); | 27 // on behalf of a render view (i.e., the view which contains the object |
| 29 | 28 // consuming the audio input). Caller owns the returned object. |
| 30 // Implementation of AudioInputIPC. | 29 media::AudioInputIPC* CreateAudioInputIPC(int render_view_id); |
| 31 virtual int AddDelegate( | |
| 32 media::AudioInputIPCDelegate* delegate) OVERRIDE; | |
| 33 virtual void RemoveDelegate(int id) OVERRIDE; | |
| 34 virtual void CreateStream(int stream_id, const media::AudioParameters& params, | |
| 35 const std::string& device_id, bool automatic_gain_control) OVERRIDE; | |
| 36 virtual void StartDevice(int stream_id, int session_id) OVERRIDE; | |
| 37 virtual void RecordStream(int stream_id) OVERRIDE; | |
| 38 virtual void CloseStream(int stream_id) OVERRIDE; | |
| 39 virtual void SetVolume(int stream_id, double volume) OVERRIDE; | |
| 40 | 30 |
| 41 private: | 31 private: |
| 32 class AudioInputIPCImpl; |
| 33 |
| 42 virtual ~AudioInputMessageFilter(); | 34 virtual ~AudioInputMessageFilter(); |
| 43 | 35 |
| 44 // Sends an IPC message using |channel_|. | 36 // Sends an IPC message using |channel_|. |
| 45 bool Send(IPC::Message* message); | 37 bool Send(IPC::Message* message); |
| 46 | 38 |
| 47 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. | 39 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. |
| 48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 49 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 41 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| 50 virtual void OnFilterRemoved() OVERRIDE; | 42 virtual void OnFilterRemoved() OVERRIDE; |
| 51 virtual void OnChannelClosing() OVERRIDE; | 43 virtual void OnChannelClosing() OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 media::AudioInputIPCDelegate::State state); | 60 media::AudioInputIPCDelegate::State state); |
| 69 | 61 |
| 70 // Notification of the opened device of an audio session. | 62 // Notification of the opened device of an audio session. |
| 71 void OnDeviceStarted(int stream_id, const std::string& device_id); | 63 void OnDeviceStarted(int stream_id, const std::string& device_id); |
| 72 | 64 |
| 73 // A map of stream ids to delegates. | 65 // A map of stream ids to delegates. |
| 74 IDMap<media::AudioInputIPCDelegate> delegates_; | 66 IDMap<media::AudioInputIPCDelegate> delegates_; |
| 75 | 67 |
| 76 IPC::Channel* channel_; | 68 IPC::Channel* channel_; |
| 77 | 69 |
| 78 // The singleton instance for this filter. | |
| 79 static AudioInputMessageFilter* filter_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(AudioInputMessageFilter); | 70 DISALLOW_COPY_AND_ASSIGN(AudioInputMessageFilter); |
| 82 }; | 71 }; |
| 83 | 72 |
| 84 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ | 73 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_MESSAGE_FILTER_H_ |
| OLD | NEW |