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

Side by Side Diff: chrome/renderer/audio_message_filter.h

Issue 6703003: Move a bunch of html5 renderer code to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 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
« no previous file with comments | « chrome/renderer/audio_device.cc ('k') | chrome/renderer/audio_message_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // MessageFilter that handles audio messages and delegates them to audio
6 // renderers. Created on render thread, AudioMessageFilter is operated on
7 // IO thread (main thread of render process), it intercepts audio messages
8 // and process them on IO thread since these messages are time critical.
9
10 #ifndef CHROME_RENDERER_AUDIO_MESSAGE_FILTER_H_
11 #define CHROME_RENDERER_AUDIO_MESSAGE_FILTER_H_
12 #pragma once
13
14 #include "base/gtest_prod_util.h"
15 #include "base/id_map.h"
16 #include "base/shared_memory.h"
17 #include "base/sync_socket.h"
18 #include "ipc/ipc_channel_proxy.h"
19 #include "media/audio/audio_buffers_state.h"
20
21 struct ViewMsg_AudioStreamState_Params;
22
23 namespace base {
24 class Time;
25 }
26
27 class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
28 public:
29 class Delegate {
30 public:
31 // Called when an audio packet is requested from the browser process.
32 virtual void OnRequestPacket(AudioBuffersState buffers_state) = 0;
33
34 // Called when state of an audio stream has changed in the browser process.
35 virtual void OnStateChanged(
36 const ViewMsg_AudioStreamState_Params& state) = 0;
37
38 // Called when an audio stream has been created in the browser process.
39 virtual void OnCreated(base::SharedMemoryHandle handle, uint32 length) = 0;
40
41 // Called when a low-latency audio stream has been created in the browser
42 // process.
43 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle,
44 base::SyncSocket::Handle socket_handle,
45 uint32 length) = 0;
46
47 // Called when notification of stream volume is received from the browser
48 // process.
49 virtual void OnVolume(double volume) = 0;
50
51 protected:
52 virtual ~Delegate() {}
53 };
54
55 explicit AudioMessageFilter(int32 route_id);
56 ~AudioMessageFilter();
57
58 // Add a delegate to the map and return id of the entry.
59 int32 AddDelegate(Delegate* delegate);
60
61 // Remove a delegate referenced by |id| from the map.
62 void RemoveDelegate(int32 id);
63
64 // Sends an IPC message using |channel_|.
65 bool Send(IPC::Message* message);
66
67 MessageLoop* message_loop() { return message_loop_; }
68
69 private:
70 // For access to |message_loop_|.
71 friend class AudioRendererImplTest;
72
73 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Basic);
74 FRIEND_TEST_ALL_PREFIXES(AudioMessageFilterTest, Delegates);
75
76 // IPC::ChannelProxy::MessageFilter override. Called on IO thread.
77 virtual bool OnMessageReceived(const IPC::Message& message);
78 virtual void OnFilterAdded(IPC::Channel* channel);
79 virtual void OnFilterRemoved();
80 virtual void OnChannelClosing();
81
82 // Received when browser process wants more audio packet.
83 void OnRequestPacket(const IPC::Message& msg, int stream_id,
84 AudioBuffersState buffers_state);
85
86 // Received when browser process has created an audio output stream.
87 void OnStreamCreated(int stream_id, base::SharedMemoryHandle handle,
88 uint32 length);
89
90 // Received when browser process has created an audio output stream of low
91 // latency.
92 void OnLowLatencyStreamCreated(int stream_id, base::SharedMemoryHandle handle,
93 #if defined(OS_WIN)
94 base::SyncSocket::Handle socket_handle,
95 #else
96 base::FileDescriptor socket_descriptor,
97 #endif
98 uint32 length);
99
100
101 // Received when internal state of browser process' audio output device has
102 // changed.
103 void OnStreamStateChanged(int stream_id,
104 const ViewMsg_AudioStreamState_Params& state);
105
106 // Notification of volume property of an audio output stream.
107 void OnStreamVolume(int stream_id, double volume);
108
109 // A map of stream ids to delegates.
110 IDMap<Delegate> delegates_;
111
112 IPC::Channel* channel_;
113
114 int32 route_id_;
115
116 MessageLoop* message_loop_;
117
118 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter);
119 };
120
121 #endif // CHROME_RENDERER_AUDIO_MESSAGE_FILTER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/audio_device.cc ('k') | chrome/renderer/audio_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698