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

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

Issue 495353003: Move WebMediaPlayerImpl and its dependencies to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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
« no previous file with comments | « media/blink/active_loader.cc ('k') | media/blink/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 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 CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_ 5 #ifndef MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_ 6 #define MEDIA_BLINK_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 "content/common/content_export.h"
14 #include "content/renderer/media/buffered_resource_loader.h"
15 #include "media/base/data_source.h" 13 #include "media/base/data_source.h"
14 #include "media/base/media_export.h"
16 #include "media/base/ranges.h" 15 #include "media/base/ranges.h"
16 #include "media/blink/buffered_resource_loader.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace base { 19 namespace base {
20 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
21 } 21 }
22 22
23 namespace media { 23 namespace media {
24 class MediaLog; 24 class MediaLog;
25 }
26 25
27 namespace content { 26 class MEDIA_EXPORT BufferedDataSourceHost {
28
29 class CONTENT_EXPORT BufferedDataSourceHost {
30 public: 27 public:
31 // Notify the host of the total size of the media file. 28 // Notify the host of the total size of the media file.
32 virtual void SetTotalBytes(int64 total_bytes) = 0; 29 virtual void SetTotalBytes(int64 total_bytes) = 0;
33 30
34 // Notify the host that byte range [start,end] has been buffered. 31 // Notify the host that byte range [start,end] has been buffered.
35 // TODO(fischman): remove this method when demuxing is push-based instead of 32 // TODO(fischman): remove this method when demuxing is push-based instead of
36 // pull-based. http://crbug.com/131444 33 // pull-based. http://crbug.com/131444
37 virtual void AddBufferedByteRange(int64 start, int64 end) = 0; 34 virtual void AddBufferedByteRange(int64 start, int64 end) = 0;
38 35
39 protected: 36 protected:
40 virtual ~BufferedDataSourceHost() {}; 37 virtual ~BufferedDataSourceHost() {};
41 }; 38 };
42 39
43 // A data source capable of loading URLs and buffering the data using an 40 // A data source capable of loading URLs and buffering the data using an
44 // in-memory sliding window. 41 // in-memory sliding window.
45 // 42 //
46 // BufferedDataSource must be created and initialized on the render thread 43 // BufferedDataSource must be created and initialized on the render thread
47 // before being passed to other threads. It may be deleted on any thread. 44 // before being passed to other threads. It may be deleted on any thread.
48 class CONTENT_EXPORT BufferedDataSource : public media::DataSource { 45 class MEDIA_EXPORT BufferedDataSource : public DataSource {
49 public: 46 public:
50 // Used to specify video preload states. They are "hints" to the browser about 47 // Used to specify video preload states. They are "hints" to the browser about
51 // how aggressively the browser should load and buffer data. 48 // how aggressively the browser should load and buffer data.
52 // Please see the HTML5 spec for the descriptions of these values: 49 // Please see the HTML5 spec for the descriptions of these values:
53 // http://www.w3.org/TR/html5/video.html#attr-media-preload 50 // http://www.w3.org/TR/html5/video.html#attr-media-preload
54 // 51 //
55 // Enum values must match the values in blink::WebMediaPlayer::Preload and 52 // Enum values must match the values in blink::WebMediaPlayer::Preload and
56 // there will be assertions at compile time if they do not match. 53 // there will be assertions at compile time if they do not match.
57 enum Preload { 54 enum Preload {
58 NONE, 55 NONE,
59 METADATA, 56 METADATA,
60 AUTO, 57 AUTO,
61 }; 58 };
62 typedef base::Callback<void(bool)> DownloadingCB; 59 typedef base::Callback<void(bool)> DownloadingCB;
63 60
64 // |url| and |cors_mode| are passed to the object. Buffered byte range changes 61 // |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 62 // will be reported to |host|. |downloading_cb| will be called whenever the
66 // downloading/paused state of the source changes. 63 // downloading/paused state of the source changes.
67 BufferedDataSource( 64 BufferedDataSource(
68 const GURL& url, 65 const GURL& url,
69 BufferedResourceLoader::CORSMode cors_mode, 66 BufferedResourceLoader::CORSMode cors_mode,
70 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
71 blink::WebFrame* frame, 68 blink::WebFrame* frame,
72 media::MediaLog* media_log, 69 MediaLog* media_log,
73 BufferedDataSourceHost* host, 70 BufferedDataSourceHost* host,
74 const DownloadingCB& downloading_cb); 71 const DownloadingCB& downloading_cb);
75 virtual ~BufferedDataSource(); 72 virtual ~BufferedDataSource();
76 73
77 // Executes |init_cb| with the result of initialization when it has completed. 74 // Executes |init_cb| with the result of initialization when it has completed.
78 // 75 //
79 // Method called on the render thread. 76 // Method called on the render thread.
80 typedef base::Callback<void(bool)> InitializeCB; 77 typedef base::Callback<void(bool)> InitializeCB;
81 void Initialize(const InitializeCB& init_cb); 78 void Initialize(const InitializeCB& init_cb);
82 79
(...skipping 18 matching lines...) Expand all
101 98
102 // Notifies changes in playback state for controlling media buffering 99 // Notifies changes in playback state for controlling media buffering
103 // behavior. 100 // behavior.
104 void MediaPlaybackRateChanged(float playback_rate); 101 void MediaPlaybackRateChanged(float playback_rate);
105 void MediaIsPlaying(); 102 void MediaIsPlaying();
106 void MediaIsPaused(); 103 void MediaIsPaused();
107 104
108 // Returns true if the resource is local. 105 // Returns true if the resource is local.
109 bool assume_fully_buffered() { return !url_.SchemeIsHTTPOrHTTPS(); } 106 bool assume_fully_buffered() { return !url_.SchemeIsHTTPOrHTTPS(); }
110 107
111 // media::DataSource implementation. 108 // DataSource implementation.
112 // Called from demuxer thread. 109 // Called from demuxer thread.
113 virtual void Stop() OVERRIDE; 110 virtual void Stop() OVERRIDE;
114 111
115 virtual void Read(int64 position, int size, uint8* data, 112 virtual void Read(int64 position, int size, uint8* data,
116 const media::DataSource::ReadCB& read_cb) OVERRIDE; 113 const DataSource::ReadCB& read_cb) OVERRIDE;
117 virtual bool GetSize(int64* size_out) OVERRIDE; 114 virtual bool GetSize(int64* size_out) OVERRIDE;
118 virtual bool IsStreaming() OVERRIDE; 115 virtual bool IsStreaming() OVERRIDE;
119 virtual void SetBitrate(int bitrate) OVERRIDE; 116 virtual void SetBitrate(int bitrate) OVERRIDE;
120 117
121 protected: 118 protected:
122 // A factory method to create a BufferedResourceLoader based on the read 119 // A factory method to create a BufferedResourceLoader based on the read
123 // parameters. We can override this file to object a mock 120 // parameters. We can override this file to object a mock
124 // BufferedResourceLoader for testing. 121 // BufferedResourceLoader for testing.
125 virtual BufferedResourceLoader* CreateResourceLoader( 122 virtual BufferedResourceLoader* CreateResourceLoader(
126 int64 first_byte_position, int64 last_byte_position); 123 int64 first_byte_position, int64 last_byte_position);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // This variable holds the value of the preload attribute for the video 215 // This variable holds the value of the preload attribute for the video
219 // element. 216 // element.
220 Preload preload_; 217 Preload preload_;
221 218
222 // Bitrate of the content, 0 if unknown. 219 // Bitrate of the content, 0 if unknown.
223 int bitrate_; 220 int bitrate_;
224 221
225 // Current playback rate. 222 // Current playback rate.
226 float playback_rate_; 223 float playback_rate_;
227 224
228 scoped_refptr<media::MediaLog> media_log_; 225 scoped_refptr<MediaLog> media_log_;
229 226
230 // Host object to report buffered byte range changes to. 227 // Host object to report buffered byte range changes to.
231 BufferedDataSourceHost* host_; 228 BufferedDataSourceHost* host_;
232 229
233 DownloadingCB downloading_cb_; 230 DownloadingCB downloading_cb_;
234 231
235 // NOTE: Weak pointers must be invalidated before all other member variables. 232 // NOTE: Weak pointers must be invalidated before all other member variables.
236 base::WeakPtrFactory<BufferedDataSource> weak_factory_; 233 base::WeakPtrFactory<BufferedDataSource> weak_factory_;
237 234
238 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 235 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
239 }; 236 };
240 237
241 } // namespace content 238 } // namespace media
242 239
243 #endif // CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_H_ 240 #endif // MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « media/blink/active_loader.cc ('k') | media/blink/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698