OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ | 5 #ifndef WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ |
6 #define WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ | 6 #define WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "media/base/data_source.h" | 14 #include "media/base/data_source.h" |
15 #include "media/base/pipeline_status.h" | |
15 #include "webkit/media/buffered_resource_loader.h" | 16 #include "webkit/media/buffered_resource_loader.h" |
16 | 17 |
18 class MessageLoop; | |
19 | |
17 namespace media { | 20 namespace media { |
18 class MediaLog; | 21 class MediaLog; |
19 } | 22 } |
20 | 23 |
21 namespace webkit_media { | 24 namespace webkit_media { |
22 | 25 |
23 // This class may be created on any thread, and is callable from the render | 26 // A data source capable of loading URLs and buffering the data using an |
24 // thread as well as media-specific threads. | 27 // in-memory sliding window. |
Ami GONE FROM CHROMIUM
2012/03/27 05:16:19
doco ctor/dtor thread restrictions? (I think this
scherkus (not reviewing)
2012/03/27 14:10:06
Done.
| |
25 class BufferedDataSource : public WebDataSource { | 28 class BufferedDataSource : public media::DataSource { |
Ami GONE FROM CHROMIUM
2012/03/27 05:16:19
How long till DataSource can become a pure interfa
scherkus (not reviewing)
2012/03/27 14:10:06
set_host() is the only non-pure-virtual method and
| |
26 public: | 29 public: |
27 BufferedDataSource(MessageLoop* render_loop, | 30 BufferedDataSource(MessageLoop* render_loop, |
28 WebKit::WebFrame* frame, | 31 WebKit::WebFrame* frame, |
29 media::MediaLog* media_log); | 32 media::MediaLog* media_log); |
30 | 33 |
31 virtual ~BufferedDataSource(); | 34 virtual ~BufferedDataSource(); |
32 | 35 |
36 // Initialize this object using |url|. This object calls |status_cb| when | |
37 // initialization has completed. | |
38 // | |
39 // Method called on the render thread. | |
40 void Initialize(const GURL& url, | |
41 const media::PipelineStatusCB& status_cb); | |
42 | |
43 // Returns true if the media resource has a single origin, false otherwise. | |
44 // | |
45 // Method called on the render thread. | |
46 bool HasSingleOrigin(); | |
47 | |
48 // Cancels initialization, any pending loaders, and any pending read calls | |
49 // from the demuxer. The caller is expected to release its reference to this | |
50 // object and never call it again. | |
51 // | |
52 // Method called on the render thread. | |
53 void Abort(); | |
54 | |
33 // media::DataSource implementation. | 55 // media::DataSource implementation. |
34 // Called from demuxer thread. | 56 // Called from demuxer thread. |
35 virtual void set_host(media::DataSourceHost* host) OVERRIDE; | 57 virtual void set_host(media::DataSourceHost* host) OVERRIDE; |
36 virtual void Stop(const base::Closure& closure) OVERRIDE; | 58 virtual void Stop(const base::Closure& closure) OVERRIDE; |
37 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 59 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
38 | 60 |
39 virtual void Read( | 61 virtual void Read( |
40 int64 position, | 62 int64 position, |
41 size_t size, | 63 size_t size, |
42 uint8* data, | 64 uint8* data, |
43 const media::DataSource::ReadCB& read_cb) OVERRIDE; | 65 const media::DataSource::ReadCB& read_cb) OVERRIDE; |
44 virtual bool GetSize(int64* size_out) OVERRIDE; | 66 virtual bool GetSize(int64* size_out) OVERRIDE; |
45 virtual bool IsStreaming() OVERRIDE; | 67 virtual bool IsStreaming() OVERRIDE; |
46 virtual void SetPreload(media::Preload preload) OVERRIDE; | 68 virtual void SetPreload(media::Preload preload) OVERRIDE; |
47 virtual void SetBitrate(int bitrate) OVERRIDE; | 69 virtual void SetBitrate(int bitrate) OVERRIDE; |
48 | 70 |
49 // webkit_glue::WebDataSource implementation. | |
50 virtual void Initialize( | |
51 const GURL& url, const media::PipelineStatusCB& initialize_cb) OVERRIDE; | |
52 virtual bool HasSingleOrigin() OVERRIDE; | |
53 virtual void Abort() OVERRIDE; | |
54 | |
55 protected: | 71 protected: |
56 // A factory method to create a BufferedResourceLoader based on the read | 72 // A factory method to create a BufferedResourceLoader based on the read |
57 // parameters. We can override this file to object a mock | 73 // parameters. We can override this file to object a mock |
58 // BufferedResourceLoader for testing. | 74 // BufferedResourceLoader for testing. |
59 virtual BufferedResourceLoader* CreateResourceLoader( | 75 virtual BufferedResourceLoader* CreateResourceLoader( |
60 int64 first_byte_position, int64 last_byte_position); | 76 int64 first_byte_position, int64 last_byte_position); |
61 | 77 |
62 private: | 78 private: |
63 friend class BufferedDataSourceTest; | 79 friend class BufferedDataSourceTest; |
64 | 80 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 float playback_rate_; | 222 float playback_rate_; |
207 | 223 |
208 scoped_refptr<media::MediaLog> media_log_; | 224 scoped_refptr<media::MediaLog> media_log_; |
209 | 225 |
210 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); | 226 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); |
211 }; | 227 }; |
212 | 228 |
213 } // namespace webkit_media | 229 } // namespace webkit_media |
214 | 230 |
215 #endif // WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ | 231 #endif // WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ |
OLD | NEW |