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 // A Chrome specific data source for video stack pipeline. The actual resource | 5 // A Chrome specific data source for video stack pipeline. The actual resource |
6 // loading would happen in the browser process. This class is given a file | 6 // loading would happen in the browser process. This class is given a file |
7 // handle and will ask for progress of downloading from RenderView which | 7 // handle and will ask for progress of downloading from RenderView which |
8 // delegates requests to browser process through IPC. Asynchronous IO will be | 8 // delegates requests to browser process through IPC. Asynchronous IO will be |
9 // performed on the file handle. | 9 // performed on the file handle. |
10 // | 10 // |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // media::MediaFilter implementation. | 129 // media::MediaFilter implementation. |
130 virtual void Stop(); | 130 virtual void Stop(); |
131 | 131 |
132 // Methods called from demuxer thread --------------------------------------- | 132 // Methods called from demuxer thread --------------------------------------- |
133 // media::DataSource implementation. | 133 // media::DataSource implementation. |
134 virtual size_t Read(uint8* data, size_t size); | 134 virtual size_t Read(uint8* data, size_t size); |
135 virtual bool GetPosition(int64* position_out); | 135 virtual bool GetPosition(int64* position_out); |
136 virtual bool SetPosition(int64 position); | 136 virtual bool SetPosition(int64 position); |
137 virtual bool GetSize(int64* size_out); | 137 virtual bool GetSize(int64* size_out); |
138 | 138 |
139 const media::MediaFormat* GetMediaFormat(); | 139 const media::MediaFormat& media_format(); |
140 | 140 |
141 private: | 141 private: |
142 friend class media::FilterFactoryImpl1<DataSourceImpl, | 142 friend class media::FilterFactoryImpl1<DataSourceImpl, |
143 WebMediaPlayerDelegateImpl*>; | 143 WebMediaPlayerDelegateImpl*>; |
144 | 144 |
145 // Methods called from render thread ---------------------------------------- | 145 // Methods called from render thread ---------------------------------------- |
146 explicit DataSourceImpl(WebMediaPlayerDelegateImpl* delegate); | 146 explicit DataSourceImpl(WebMediaPlayerDelegateImpl* delegate); |
147 virtual ~DataSourceImpl(); | 147 virtual ~DataSourceImpl(); |
148 | 148 |
149 // Tasks to be posted on render thread. | 149 // Tasks to be posted on render thread. |
150 void OnInitialize(std::string uri); | 150 void OnInitialize(std::string uri); |
151 void OnCancel(); | 151 void OnCancel(); |
152 | 152 |
153 // Methods called from IO thread -------------------------------------------- | 153 // Methods called from IO thread -------------------------------------------- |
154 // Handlers for file reading. | 154 // Handlers for file reading. |
155 void OnCreateFileStream(base::PlatformFile file); | 155 void OnCreateFileStream(base::PlatformFile file); |
156 void OnReadFileStream(uint8* data, size_t size); | 156 void OnReadFileStream(uint8* data, size_t size); |
157 void OnCloseFileStream(); | 157 void OnCloseFileStream(); |
158 void OnSeekFileStream(net::Whence whence, int64 position); | 158 void OnSeekFileStream(net::Whence whence, int64 position); |
159 void OnDidFileStreamRead(int size); | 159 void OnDidFileStreamRead(int size); |
160 | 160 |
161 media::MediaFormat media_format_; | 161 media::MediaFormat media_format_; |
162 | 162 |
163 // Pointer to the delegate which provides access to RenderView, this is set | 163 // Pointer to the delegate which provides access to RenderView, this is set |
164 // in construction and can be accessed in all threads safely. | 164 // in construction and can be accessed in all threads safely. |
165 WebMediaPlayerDelegateImpl* delegate_; | 165 WebMediaPlayerDelegateImpl* delegate_; |
166 | 166 |
167 // Message loop of render thread.» | 167 // Message loop of render thread. |
168 MessageLoop* render_loop_; | 168 MessageLoop* render_loop_; |
169 | 169 |
170 // A common lock for protecting members accessed by multiple threads. | 170 // A common lock for protecting members accessed by multiple threads. |
171 Lock lock_; | 171 Lock lock_; |
172 | 172 |
173 // A flag that indicates whether this object has been called to stop. | 173 // A flag that indicates whether this object has been called to stop. |
174 bool stopped_; | 174 bool stopped_; |
175 | 175 |
176 // URI to the resource being downloaded.» | 176 // URI to the resource being downloaded. |
177 std::string uri_; | 177 std::string uri_; |
178 | 178 |
179 // Members for keeping track of downloading progress. | 179 // Members for keeping track of downloading progress. |
180 base::WaitableEvent download_event_; | 180 base::WaitableEvent download_event_; |
181 int64 downloaded_bytes_; | 181 int64 downloaded_bytes_; |
182 int64 total_bytes_; | 182 int64 total_bytes_; |
183 bool total_bytes_known_; | 183 bool total_bytes_known_; |
184 | 184 |
185 // Members related to resource loading with RenderView. | 185 // Members related to resource loading with RenderView. |
186 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_; | 186 webkit_glue::ResourceLoaderBridge* resource_loader_bridge_; |
187 base::WaitableEvent resource_release_event_; | 187 base::WaitableEvent resource_release_event_; |
188 | 188 |
189 // Members used for reading. | 189 // Members used for reading. |
190 base::WaitableEvent read_event_; | 190 base::WaitableEvent read_event_; |
191 net::CompletionCallbackImpl<DataSourceImpl> read_callback_; | 191 net::CompletionCallbackImpl<DataSourceImpl> read_callback_; |
192 scoped_ptr<net::FileStream> stream_; | 192 scoped_ptr<net::FileStream> stream_; |
193 size_t last_read_size_; | 193 size_t last_read_size_; |
194 int64 position_; | 194 int64 position_; |
195 MessageLoop* io_loop_; | 195 MessageLoop* io_loop_; |
196 | 196 |
197 // Events for other operations on stream_. | 197 // Events for other operations on stream_. |
198 base::WaitableEvent close_event_; | 198 base::WaitableEvent close_event_; |
199 base::WaitableEvent seek_event_; | 199 base::WaitableEvent seek_event_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(DataSourceImpl); | 201 DISALLOW_COPY_AND_ASSIGN(DataSourceImpl); |
202 }; | 202 }; |
203 | 203 |
204 #endif // CHROME_RENDERER_MEDIA_DATA_SOURCE_IMPL_H_ | 204 #endif // CHROME_RENDERER_MEDIA_DATA_SOURCE_IMPL_H_ |
OLD | NEW |