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

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

Issue 6625059: Implementing preload=metadata for video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 9 years, 8 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 | « media/filters/file_data_source.cc ('k') | webkit/glue/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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
6 #define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 6 #define WEBKIT_GLUE_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 "media/base/filter_factories.h" 13 #include "media/base/filter_factories.h"
14 #include "media/base/filters.h"
14 #include "webkit/glue/media/buffered_resource_loader.h" 15 #include "webkit/glue/media/buffered_resource_loader.h"
15 16
16 namespace webkit_glue { 17 namespace webkit_glue {
17 18
18 class BufferedDataSource : public WebDataSource { 19 class BufferedDataSource : public WebDataSource {
19 public: 20 public:
20 // Creates a DataSourceFactory for building BufferedDataSource objects. 21 // Creates a DataSourceFactory for building BufferedDataSource objects.
21 static media::DataSourceFactory* CreateFactory( 22 static media::DataSourceFactory* CreateFactory(
22 MessageLoop* render_loop, 23 MessageLoop* render_loop,
23 WebKit::WebFrame* frame, 24 WebKit::WebFrame* frame,
24 WebDataSourceBuildObserverHack* build_observer); 25 WebDataSourceBuildObserverHack* build_observer);
25 26
26 BufferedDataSource(MessageLoop* render_loop, 27 BufferedDataSource(MessageLoop* render_loop,
27 WebKit::WebFrame* frame); 28 WebKit::WebFrame* frame);
28 29
29 virtual ~BufferedDataSource(); 30 virtual ~BufferedDataSource();
30 31
31 // media::Filter implementation. 32 // media::Filter implementation.
32 virtual void set_host(media::FilterHost* host); 33 virtual void set_host(media::FilterHost* host);
33 virtual void Stop(media::FilterCallback* callback); 34 virtual void Stop(media::FilterCallback* callback);
34 virtual void SetPlaybackRate(float playback_rate); 35 virtual void SetPlaybackRate(float playback_rate);
35 36
36 // media::DataSource implementation. 37 // media::DataSource implementation.
37 // Called from demuxer thread. 38 // Called from demuxer thread.
38 virtual void Read(int64 position, size_t size, 39 virtual void Read(int64 position, size_t size,
39 uint8* data, 40 uint8* data,
40 media::DataSource::ReadCallback* read_callback); 41 media::DataSource::ReadCallback* read_callback);
41 virtual bool GetSize(int64* size_out); 42 virtual bool GetSize(int64* size_out);
42 virtual bool IsStreaming(); 43 virtual bool IsStreaming();
44 virtual void SetPreload(media::Preload preload);
43 45
44 const media::MediaFormat& media_format() { 46 const media::MediaFormat& media_format() {
45 return media_format_; 47 return media_format_;
46 } 48 }
47 49
48 // webkit_glue::WebDataSource implementation. 50 // webkit_glue::WebDataSource implementation.
49 virtual void Initialize(const std::string& url, 51 virtual void Initialize(const std::string& url,
50 media::PipelineStatusCallback* callback); 52 media::PipelineStatusCallback* callback);
51 virtual void CancelInitialize(); 53 virtual void CancelInitialize();
52 virtual bool HasSingleOrigin(); 54 virtual bool HasSingleOrigin();
(...skipping 30 matching lines...) Expand all
83 // This task monitors the current active read request. If the current read 85 // This task monitors the current active read request. If the current read
84 // request has timed out, this task will destroy the current loader and 86 // request has timed out, this task will destroy the current loader and
85 // creates a new one to accommodate the read request. 87 // creates a new one to accommodate the read request.
86 void WatchDogTask(); 88 void WatchDogTask();
87 89
88 // This task uses the current playback rate with the previous playback rate 90 // This task uses the current playback rate with the previous playback rate
89 // to determine whether we are going from pause to play and play to pause, 91 // to determine whether we are going from pause to play and play to pause,
90 // and signals the buffered resource loader accordingly. 92 // and signals the buffered resource loader accordingly.
91 void SetPlaybackRateTask(float playback_rate); 93 void SetPlaybackRateTask(float playback_rate);
92 94
95 // This task saves the preload value for the media.
96 void SetPreloadTask(media::Preload preload);
97
98 // Decides which DeferStrategy to used based on the current state of the
99 // BufferedDataSource.
100 BufferedResourceLoader::DeferStrategy ChooseDeferStrategy();
101
93 // The method that performs actual read. This method can only be executed on 102 // The method that performs actual read. This method can only be executed on
94 // the render thread. 103 // the render thread.
95 void ReadInternal(); 104 void ReadInternal();
96 105
97 // Calls |read_callback_| and reset all read parameters. 106 // Calls |read_callback_| and reset all read parameters.
98 void DoneRead_Locked(int error); 107 void DoneRead_Locked(int error);
99 108
100 // Calls |initialize_callback_| and reset it. 109 // Calls |initialize_callback_| and reset it.
101 void DoneInitialization_Locked(media::PipelineStatus status); 110 void DoneInitialization_Locked(media::PipelineStatus status);
102 111
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool stop_signal_received_; 198 bool stop_signal_received_;
190 199
191 // This variable is set by CleanupTask() that indicates this object is stopped 200 // This variable is set by CleanupTask() that indicates this object is stopped
192 // on the render thread and work should no longer progress. 201 // on the render thread and work should no longer progress.
193 bool stopped_on_render_loop_; 202 bool stopped_on_render_loop_;
194 203
195 // This variable is true when we are in a paused state and false when we 204 // This variable is true when we are in a paused state and false when we
196 // are in a playing state. 205 // are in a playing state.
197 bool media_is_paused_; 206 bool media_is_paused_;
198 207
208 // This variable is true when the user has requested the video to play at
209 // least once.
210 bool media_has_played_;
211
212 // This variable holds the value of the preload attribute for the video
213 // element.
214 media::Preload preload_;
215
199 // This timer is to run the WatchDogTask repeatedly. We use a timer instead 216 // This timer is to run the WatchDogTask repeatedly. We use a timer instead
200 // of doing PostDelayedTask() reduce the extra reference held by the message 217 // of doing PostDelayedTask() reduce the extra reference held by the message
201 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it 218 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it
202 // the message loop doesn't hold a reference for the watch dog task. 219 // the message loop doesn't hold a reference for the watch dog task.
203 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_; 220 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_;
204 221
205 // Keeps track of whether we used a Range header in the initialization 222 // Keeps track of whether we used a Range header in the initialization
206 // request. 223 // request.
207 bool using_range_request_; 224 bool using_range_request_;
208 225
209 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 226 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
210 }; 227 };
211 228
212 } // namespace webkit_glue 229 } // namespace webkit_glue
213 230
214 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 231 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « media/filters/file_data_source.cc ('k') | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698