Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/renderer/media/audio_message_filter.h

Issue 11166002: Plumb render view ID from audio-related code in renderer through IPCs to AudioRendererHost in brows… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VLOG --> DVLOG in audio*renderer_host.cc Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 messages and delegates them to audio 5 // MessageFilter that handles audio messages and delegates them to audio
6 // renderers. Created on render thread, AudioMessageFilter is operated on 6 // renderers. 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_MESSAGE_FILTER_H_ 10 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_
11 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ 11 #define CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/id_map.h" 14 #include "base/id_map.h"
15 #include "base/shared_memory.h" 15 #include "base/shared_memory.h"
16 #include "base/sync_socket.h" 16 #include "base/sync_socket.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "ipc/ipc_channel_proxy.h" 18 #include "ipc/ipc_channel_proxy.h"
19 #include "media/audio/audio_buffers_state.h" 19 #include "media/audio/audio_buffers_state.h"
20 #include "media/audio/audio_output_ipc.h" 20 #include "media/audio/audio_output_ipc.h"
21 21
22 class CONTENT_EXPORT AudioMessageFilter 22 class CONTENT_EXPORT AudioMessageFilter
23 : public IPC::ChannelProxy::MessageFilter, 23 : public IPC::ChannelProxy::MessageFilter {
24 public NON_EXPORTED_BASE(media::AudioOutputIPC) {
25 public: 24 public:
26 AudioMessageFilter(); 25 AudioMessageFilter();
27 26
28 // Getter for the one AudioMessageFilter object. 27 // Creates an AudioOutputIPC which is used to send messages to/from the host
29 static AudioMessageFilter* Get(); 28 // on behalf of a render view (i.e., the view which contains the object
30 29 // rendering the audio). Caller owns the returned object.
31 // media::AudioOutputIPCDelegate implementation. 30 media::AudioOutputIPC* CreateAudioOutputIPC(int render_view_id);
scherkus (not reviewing) 2012/10/18 01:56:28 ditto for scoped_ptr<>
miu 2012/10/18 03:27:26 Done.
32 virtual int AddDelegate(media::AudioOutputIPCDelegate* delegate) OVERRIDE;
33 virtual void RemoveDelegate(int id) OVERRIDE;
34 virtual void CreateStream(int stream_id,
35 const media::AudioParameters& params, int input_channels) OVERRIDE;
36 virtual void PlayStream(int stream_id) OVERRIDE;
37 virtual void PauseStream(int stream_id) OVERRIDE;
38 virtual void FlushStream(int stream_id) OVERRIDE;
39 virtual void CloseStream(int stream_id) OVERRIDE;
40 virtual void SetVolume(int stream_id, double volume) OVERRIDE;
41 31
42 // IPC::ChannelProxy::MessageFilter override. Called on IO thread. 32 // IPC::ChannelProxy::MessageFilter override. Called on IO thread.
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
44 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; 34 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
45 virtual void OnFilterRemoved() OVERRIDE; 35 virtual void OnFilterRemoved() OVERRIDE;
46 virtual void OnChannelClosing() OVERRIDE; 36 virtual void OnChannelClosing() OVERRIDE;
47 37
48 protected: 38 protected:
49 virtual ~AudioMessageFilter(); 39 virtual ~AudioMessageFilter();
50 40
51 private: 41 private:
52 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic); 42 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic);
53 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates); 43 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates);
54 44
45 class AudioOutputIPCImpl;
46
55 // Sends an IPC message using |channel_|. 47 // Sends an IPC message using |channel_|.
56 bool Send(IPC::Message* message); 48 bool Send(IPC::Message* message);
57 49
58 // Received when browser process has created an audio output stream. 50 // Received when browser process has created an audio output stream.
59 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle, 51 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle,
60 #if defined(OS_WIN) 52 #if defined(OS_WIN)
61 base::SyncSocket::Handle socket_handle, 53 base::SyncSocket::Handle socket_handle,
62 #else 54 #else
63 base::FileDescriptor socket_descriptor, 55 base::FileDescriptor socket_descriptor,
64 #endif 56 #endif
65 uint32 length); 57 uint32 length);
66 58
67 // Received when internal state of browser process' audio output device has 59 // Received when internal state of browser process' audio output device has
68 // changed. 60 // changed.
69 void OnStreamStateChanged(int stream_id, 61 void OnStreamStateChanged(int stream_id,
70 media::AudioOutputIPCDelegate::State state); 62 media::AudioOutputIPCDelegate::State state);
71 63
72 // The singleton instance for this filter.
73 static AudioMessageFilter* filter_;
74
75 // A map of stream ids to delegates. 64 // A map of stream ids to delegates.
76 IDMap<media::AudioOutputIPCDelegate> delegates_; 65 IDMap<media::AudioOutputIPCDelegate> delegates_;
77 66
78 IPC::Channel* channel_; 67 IPC::Channel* channel_;
79 68
80 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter); 69 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter);
81 }; 70 };
82 71
83 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_ 72 #endif // CONTENT_RENDERER_MEDIA_AUDIO_MESSAGE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698