| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 5 #ifndef MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
| 6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 6 #define MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // http://www.w3.org/TR/html5/video.html#attr-media-preload | 46 // http://www.w3.org/TR/html5/video.html#attr-media-preload |
| 47 // | 47 // |
| 48 // Enum values must match the values in blink::WebMediaPlayer::Preload and | 48 // Enum values must match the values in blink::WebMediaPlayer::Preload and |
| 49 // there will be assertions at compile time if they do not match. | 49 // there will be assertions at compile time if they do not match. |
| 50 enum Preload { | 50 enum Preload { |
| 51 NONE, | 51 NONE, |
| 52 METADATA, | 52 METADATA, |
| 53 AUTO, | 53 AUTO, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Enum values must match the values in | |
| 57 // blink::WebMediaPlayer::BufferingStrategy and there will be assertions at | |
| 58 // compile time if they do not match. | |
| 59 enum BufferingStrategy { | |
| 60 BUFFERING_STRATEGY_NORMAL, | |
| 61 BUFFERING_STRATEGY_AGGRESSIVE, | |
| 62 }; | |
| 63 | |
| 64 // |url| and |cors_mode| are passed to the object. Buffered byte range changes | 56 // |url| and |cors_mode| are passed to the object. Buffered byte range changes |
| 65 // will be reported to |host|. |downloading_cb| will be called whenever the | 57 // will be reported to |host|. |downloading_cb| will be called whenever the |
| 66 // downloading/paused state of the source changes. | 58 // downloading/paused state of the source changes. |
| 67 MultibufferDataSource( | 59 MultibufferDataSource( |
| 68 const GURL& url, | 60 const GURL& url, |
| 69 UrlData::CORSMode cors_mode, | 61 UrlData::CORSMode cors_mode, |
| 70 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 62 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 71 linked_ptr<UrlIndex> url_index, | 63 linked_ptr<UrlIndex> url_index, |
| 72 blink::WebFrame* frame, | 64 blink::WebFrame* frame, |
| 73 MediaLog* media_log, | 65 MediaLog* media_log, |
| 74 BufferedDataSourceHost* host, | 66 BufferedDataSourceHost* host, |
| 75 const DownloadingCB& downloading_cb); | 67 const DownloadingCB& downloading_cb); |
| 76 ~MultibufferDataSource() override; | 68 ~MultibufferDataSource() override; |
| 77 | 69 |
| 78 // Executes |init_cb| with the result of initialization when it has completed. | 70 // Executes |init_cb| with the result of initialization when it has completed. |
| 79 // | 71 // |
| 80 // Method called on the render thread. | 72 // Method called on the render thread. |
| 81 typedef base::Callback<void(bool)> InitializeCB; | 73 typedef base::Callback<void(bool)> InitializeCB; |
| 82 void Initialize(const InitializeCB& init_cb); | 74 void Initialize(const InitializeCB& init_cb); |
| 83 | 75 |
| 84 // Adjusts the buffering algorithm based on the given preload value. | 76 // Adjusts the buffering algorithm based on the given preload value. |
| 85 void SetPreload(Preload preload); | 77 void SetPreload(Preload preload); |
| 86 | 78 |
| 87 // Adjusts the buffering algorithm based on the given buffering strategy | |
| 88 // value. | |
| 89 void SetBufferingStrategy(BufferingStrategy buffering_strategy); | |
| 90 | |
| 91 // Returns true if the media resource has a single origin, false otherwise. | 79 // Returns true if the media resource has a single origin, false otherwise. |
| 92 // Only valid to call after Initialize() has completed. | 80 // Only valid to call after Initialize() has completed. |
| 93 // | 81 // |
| 94 // Method called on the render thread. | 82 // Method called on the render thread. |
| 95 bool HasSingleOrigin(); | 83 bool HasSingleOrigin(); |
| 96 | 84 |
| 97 // Returns true if the media resource passed a CORS access control check. | 85 // Returns true if the media resource passed a CORS access control check. |
| 98 bool DidPassCORSAccessCheck() const; | 86 bool DidPassCORSAccessCheck() const; |
| 99 | 87 |
| 100 // Notifies changes in playback state for controlling media buffering | 88 // Notifies changes in playback state for controlling media buffering |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // Protects |stop_signal_received_|, |read_op_| and |total_bytes_|. | 207 // Protects |stop_signal_received_|, |read_op_| and |total_bytes_|. |
| 220 base::Lock lock_; | 208 base::Lock lock_; |
| 221 | 209 |
| 222 // Whether we've been told to stop via Abort() or Stop(). | 210 // Whether we've been told to stop via Abort() or Stop(). |
| 223 bool stop_signal_received_; | 211 bool stop_signal_received_; |
| 224 | 212 |
| 225 // This variable is true when the user has requested the video to play at | 213 // This variable is true when the user has requested the video to play at |
| 226 // least once. | 214 // least once. |
| 227 bool media_has_played_; | 215 bool media_has_played_; |
| 228 | 216 |
| 229 // Buffering strategy set by SetBufferingStrategy. | |
| 230 BufferingStrategy buffering_strategy_; | |
| 231 | |
| 232 // As we follow redirects, we set this variable to false if redirects | 217 // As we follow redirects, we set this variable to false if redirects |
| 233 // go between different origins. | 218 // go between different origins. |
| 234 bool single_origin_; | 219 bool single_origin_; |
| 235 | 220 |
| 236 // Close the connection when we have enough data. | 221 // Close the connection when we have enough data. |
| 237 bool cancel_on_defer_; | 222 bool cancel_on_defer_; |
| 238 | 223 |
| 239 // This variable holds the value of the preload attribute for the video | 224 // This variable holds the value of the preload attribute for the video |
| 240 // element. | 225 // element. |
| 241 Preload preload_; | 226 Preload preload_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 266 // reaching into this class from multiple threads to attain a WeakPtr. | 251 // reaching into this class from multiple threads to attain a WeakPtr. |
| 267 base::WeakPtr<MultibufferDataSource> weak_ptr_; | 252 base::WeakPtr<MultibufferDataSource> weak_ptr_; |
| 268 base::WeakPtrFactory<MultibufferDataSource> weak_factory_; | 253 base::WeakPtrFactory<MultibufferDataSource> weak_factory_; |
| 269 | 254 |
| 270 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); | 255 DISALLOW_COPY_AND_ASSIGN(MultibufferDataSource); |
| 271 }; | 256 }; |
| 272 | 257 |
| 273 } // namespace media | 258 } // namespace media |
| 274 | 259 |
| 275 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ | 260 #endif // MEDIA_BLINK_MULTIBUFFER_DATA_SOURCE_H_ |
| OLD | NEW |