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

Side by Side Diff: webkit/media/buffered_data_source.h

Issue 9836102: Fold WebDataSource into BufferedDataSource. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: dcheck-o-rama Created 8 years, 9 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
« no previous file with comments | « no previous file | webkit/media/buffered_data_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
25 class BufferedDataSource : public WebDataSource { 28 //
29 // BufferedDataSource must be created and initialized on the render thread
30 // before being passed to other threads. It may be deleted on any thread.
31 class BufferedDataSource : public media::DataSource {
26 public: 32 public:
27 BufferedDataSource(MessageLoop* render_loop, 33 BufferedDataSource(MessageLoop* render_loop,
28 WebKit::WebFrame* frame, 34 WebKit::WebFrame* frame,
29 media::MediaLog* media_log); 35 media::MediaLog* media_log);
30 36
31 virtual ~BufferedDataSource(); 37 virtual ~BufferedDataSource();
32 38
39 // Initialize this object using |url|. This object calls |status_cb| when
40 // initialization has completed.
41 //
42 // Method called on the render thread.
43 void Initialize(const GURL& url,
44 const media::PipelineStatusCB& status_cb);
45
46 // Returns true if the media resource has a single origin, false otherwise.
47 // Only valid to call after Initialize() has completed.
48 //
49 // Method called on the render thread.
50 bool HasSingleOrigin();
51
52 // Cancels initialization, any pending loaders, and any pending read calls
53 // from the demuxer. The caller is expected to release its reference to this
54 // object and never call it again.
55 //
56 // Method called on the render thread.
57 void Abort();
58
33 // media::DataSource implementation. 59 // media::DataSource implementation.
34 // Called from demuxer thread. 60 // Called from demuxer thread.
35 virtual void set_host(media::DataSourceHost* host) OVERRIDE; 61 virtual void set_host(media::DataSourceHost* host) OVERRIDE;
36 virtual void Stop(const base::Closure& closure) OVERRIDE; 62 virtual void Stop(const base::Closure& closure) OVERRIDE;
37 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; 63 virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
38 64
39 virtual void Read(int64 position, int size, uint8* data, 65 virtual void Read(int64 position, int size, uint8* data,
40 const media::DataSource::ReadCB& read_cb) OVERRIDE; 66 const media::DataSource::ReadCB& read_cb) OVERRIDE;
41 virtual bool GetSize(int64* size_out) OVERRIDE; 67 virtual bool GetSize(int64* size_out) OVERRIDE;
42 virtual bool IsStreaming() OVERRIDE; 68 virtual bool IsStreaming() OVERRIDE;
43 virtual void SetPreload(media::Preload preload) OVERRIDE; 69 virtual void SetPreload(media::Preload preload) OVERRIDE;
44 virtual void SetBitrate(int bitrate) OVERRIDE; 70 virtual void SetBitrate(int bitrate) OVERRIDE;
45 71
46 // webkit_glue::WebDataSource implementation.
47 virtual void Initialize(
48 const GURL& url, const media::PipelineStatusCB& initialize_cb) OVERRIDE;
49 virtual bool HasSingleOrigin() OVERRIDE;
50 virtual void Abort() OVERRIDE;
51
52 protected: 72 protected:
53 // A factory method to create a BufferedResourceLoader based on the read 73 // A factory method to create a BufferedResourceLoader based on the read
54 // parameters. We can override this file to object a mock 74 // parameters. We can override this file to object a mock
55 // BufferedResourceLoader for testing. 75 // BufferedResourceLoader for testing.
56 virtual BufferedResourceLoader* CreateResourceLoader( 76 virtual BufferedResourceLoader* CreateResourceLoader(
57 int64 first_byte_position, int64 last_byte_position); 77 int64 first_byte_position, int64 last_byte_position);
58 78
59 private: 79 private:
60 friend class BufferedDataSourceTest; 80 friend class BufferedDataSourceTest;
61 81
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 float playback_rate_; 223 float playback_rate_;
204 224
205 scoped_refptr<media::MediaLog> media_log_; 225 scoped_refptr<media::MediaLog> media_log_;
206 226
207 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 227 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
208 }; 228 };
209 229
210 } // namespace webkit_media 230 } // namespace webkit_media
211 231
212 #endif // WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_ 232 #endif // WEBKIT_MEDIA_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698