OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 // | 4 // |
5 // Audio rendering unit utilizing audio output stream provided by browser | 5 // Audio rendering unit utilizing audio output stream provided by browser |
6 // process through IPC. | 6 // process through IPC. |
7 // | 7 // |
8 // Relationship of classes. | 8 // Relationship of classes. |
9 // | 9 // |
10 // AudioRendererHost AudioRendererImpl | 10 // AudioRendererHost AudioRendererImpl |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 class AudioRendererImpl : public media::AudioRendererBase { | 102 class AudioRendererImpl : public media::AudioRendererBase { |
103 public: | 103 public: |
104 // Methods called on render thread ------------------------------------------ | 104 // Methods called on render thread ------------------------------------------ |
105 // Methods called during construction. | 105 // Methods called during construction. |
106 static media::FilterFactory* CreateFactory( | 106 static media::FilterFactory* CreateFactory( |
107 WebMediaPlayerDelegateImpl* delegate) { | 107 WebMediaPlayerDelegateImpl* delegate) { |
108 return new media::FilterFactoryImpl1<AudioRendererImpl, | 108 return new media::FilterFactoryImpl1<AudioRendererImpl, |
109 WebMediaPlayerDelegateImpl*>(delegate); | 109 WebMediaPlayerDelegateImpl*>(delegate); |
110 } | 110 } |
111 static bool IsMediaFormatSupported(const media::MediaFormat* format); | 111 static bool IsMediaFormatSupported(const media::MediaFormat& format); |
112 | 112 |
113 // Methods call from RenderView when audio related IPC messages are received | 113 // Methods call from RenderView when audio related IPC messages are received |
114 // from browser process. | 114 // from browser process. |
115 void OnRequestPacket(); | 115 void OnRequestPacket(); |
116 void OnStateChanged(AudioOutputStream::State state, int info); | 116 void OnStateChanged(AudioOutputStream::State state, int info); |
117 void OnCreated(base::SharedMemoryHandle handle, size_t length); | 117 void OnCreated(base::SharedMemoryHandle handle, size_t length); |
118 void OnVolume(double left, double right); | 118 void OnVolume(double left, double right); |
119 | 119 |
120 // Release resources that lives in renderer thread, i.e. audio output streams. | 120 // Release resources that lives in renderer thread, i.e. audio output streams. |
121 void ReleaseRendererResources(); | 121 void ReleaseRendererResources(); |
122 | 122 |
123 // Methods called on pipeline thread ---------------------------------------- | 123 // Methods called on pipeline thread ---------------------------------------- |
124 // media::MediaFilter implementation. | 124 // media::MediaFilter implementation. |
125 virtual void SetPlaybackRate(float rate); | 125 virtual void SetPlaybackRate(float rate); |
126 const media::MediaFormat* GetMediaFormat(); | |
127 | 126 |
128 // media::AudioRenderer implementation. | 127 // media::AudioRenderer implementation. |
129 virtual void SetVolume(float volume); | 128 virtual void SetVolume(float volume); |
130 | 129 |
131 // AssignableBuffer<AudioRendererBase, BufferInterface> implementation. | 130 // AssignableBuffer<AudioRendererBase, BufferInterface> implementation. |
132 virtual void OnAssignment(media::Buffer* buffer_in); | 131 virtual void OnAssignment(media::Buffer* buffer_in); |
133 | 132 |
134 protected: | 133 protected: |
135 // Methods called on audio renderer thread ---------------------------------- | 134 // Methods called on audio renderer thread ---------------------------------- |
136 // These methods are called from AudioRendererBase. | 135 // These methods are called from AudioRendererBase. |
137 virtual bool OnInitialize(const media::MediaFormat* media_format); | 136 virtual bool OnInitialize(const media::MediaFormat& media_format); |
138 virtual void OnStop(); | 137 virtual void OnStop(); |
139 | 138 |
140 private: | 139 private: |
141 friend class media::FilterFactoryImpl1<AudioRendererImpl, | 140 friend class media::FilterFactoryImpl1<AudioRendererImpl, |
142 WebMediaPlayerDelegateImpl*>; | 141 WebMediaPlayerDelegateImpl*>; |
143 | 142 |
144 explicit AudioRendererImpl(WebMediaPlayerDelegateImpl* delegate); | 143 explicit AudioRendererImpl(WebMediaPlayerDelegateImpl* delegate); |
145 virtual ~AudioRendererImpl(); | 144 virtual ~AudioRendererImpl(); |
146 | 145 |
147 // Methods call on render thread -------------------------------------------- | 146 // Methods call on render thread -------------------------------------------- |
148 // The following methods are tasks posted on the render thread that needs to | 147 // The following methods are tasks posted on the render thread that needs to |
149 // be executed on that thread. They interact with WebMediaPlayerDelegateImpl | 148 // be executed on that thread. They interact with WebMediaPlayerDelegateImpl |
150 // and the containing RenderView, because method calls to RenderView must be | 149 // and the containing RenderView, because method calls to RenderView must be |
151 // executed on render thread. | 150 // executed on render thread. |
152 void OnCreateAudioStream(AudioManager::Format format, int channels, | 151 void OnCreateAudioStream(AudioManager::Format format, int channels, |
153 int sample_rate, int bits_per_sample, | 152 int sample_rate, int bits_per_sample, |
154 size_t packet_size); | 153 size_t packet_size); |
155 void OnStartAudioStream(); | 154 void OnStartAudioStream(); |
156 void OnCloseAudioStream(); | 155 void OnCloseAudioStream(); |
157 void OnSetAudioVolume(double left, double right); | 156 void OnSetAudioVolume(double left, double right); |
158 void OnNotifyAudioPacketReady(); | 157 void OnNotifyAudioPacketReady(); |
159 | 158 |
160 WebMediaPlayerDelegateImpl* delegate_; | 159 WebMediaPlayerDelegateImpl* delegate_; |
161 | 160 |
162 // A map of media format information. | |
163 media::MediaFormat media_format_; | |
164 | |
165 // ID of the stream created in the browser process. | 161 // ID of the stream created in the browser process. |
166 int32 stream_id_; | 162 int32 stream_id_; |
167 | 163 |
168 // Memory shared by the browser process for audio buffer. | 164 // Memory shared by the browser process for audio buffer. |
169 scoped_ptr<base::SharedMemory> shared_memory_; | 165 scoped_ptr<base::SharedMemory> shared_memory_; |
170 size_t shared_memory_size_; | 166 size_t shared_memory_size_; |
171 | 167 |
172 // Flag that tells whether we have any unfulfilled packet request. | 168 // Flag that tells whether we have any unfulfilled packet request. |
173 bool packet_requested_; | 169 bool packet_requested_; |
174 | 170 |
175 // Message loop for the render thread, it's the message loop where this class | 171 // Message loop for the render thread, it's the message loop where this class |
176 // is constructed. | 172 // is constructed. |
177 MessageLoop* render_loop_; | 173 MessageLoop* render_loop_; |
178 | 174 |
179 // Event for releasing resources that live in render thread. | 175 // Event for releasing resources that live in render thread. |
180 base::WaitableEvent resource_release_event_; | 176 base::WaitableEvent resource_release_event_; |
181 | 177 |
182 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 178 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
183 }; | 179 }; |
184 | 180 |
185 #endif // CHROME_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ | 181 #endif // CHROME_RENDERER_MEDIA_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |