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

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

Issue 7003053: Moves audio files from content\renderer\ to content\renderer\media. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 6 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
(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 CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_
11 #define CONTENT_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 "content/common/audio_stream_state.h"
19 #include "ipc/ipc_channel_proxy.h"
20 #include "media/audio/audio_buffers_state.h"
21
22 class MessageLoop;
23
24 namespace base {
25 class Time;
26 }
27
28 class AudioMessageFilter : public IPC::ChannelProxy::MessageFilter {
29 public:
30 class Delegate {
31 public:
32 // Called when an audio packet is requested from the browser process.
33 virtual void OnRequestPacket(AudioBuffersState buffers_state) = 0;
34
35 // Called when state of an audio stream has changed in the browser process.
36 virtual void OnStateChanged(AudioStreamState 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 virtual ~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, AudioStreamState state);
104
105 // Notification of volume property of an audio output stream.
106 void OnStreamVolume(int stream_id, double volume);
107
108 // A map of stream ids to delegates.
109 IDMap<Delegate> delegates_;
110
111 IPC::Channel* channel_;
112
113 int32 route_id_;
114
115 MessageLoop* message_loop_;
116
117 DISALLOW_COPY_AND_ASSIGN(AudioMessageFilter);
118 };
119
120 #endif // CONTENT_RENDERER_AUDIO_MESSAGE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698