diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 02:46:29 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 02:46:29 +0000 |
commit | 84b0cbf0fc3b8eafa444be319fd10bb33b5f0f79 (patch) | |
tree | f75771ca6eb4a2f09d1ba1d89cee20671edc0faa /webkit/glue/media/buffered_data_source.h | |
parent | c0222007b5c580f0d5b8332e491c12918c9bad04 (diff) | |
download | chromium_src-84b0cbf0fc3b8eafa444be319fd10bb33b5f0f79.zip chromium_src-84b0cbf0fc3b8eafa444be319fd10bb33b5f0f79.tar.gz chromium_src-84b0cbf0fc3b8eafa444be319fd10bb33b5f0f79.tar.bz2 |
Change how <video> fetch a resource to make it friendly to sparse caching
BUG=16013
TEST=test_shell_tests --gtest_filter=Buffered*
Also video on a server that doesn't support range request will still work.
How <video> used to fetch a resource:
1. Fetch the whole file to get the header
2. Fetch a small range (1, 1) to determine if server supports range request
3. If [2] was successful, then fetch the file with range request if necessary
If [2] failed, prevent range request by telling ffmpeg this is streaming
New way of fetching a resource for <video>:
1. Fetch (0, 1023) to get the header (This needs more experiment).
2. If [1] was successful, then request later on will be made partial
If [1] failed, prevent range request by telling ffmpeg this is streaming
By doing this change we can eliminate one request before we can start the
file. And with the help of sparse cache, we would be able to reuse the first
1KB fetched even we need to fetch the index at the end of file.
Review URL: http://codereview.chromium.org/248012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media/buffered_data_source.h')
-rw-r--r-- | webkit/glue/media/buffered_data_source.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index f3282cc..e160c60 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -51,8 +51,6 @@ class BufferedResourceLoader : // |callback| is called with the following values: // - net::OK // The request has started successfully. - // - net::ERR_REQUEST_RANGE_NOT_SATISFIABLE - // A range request was made to the server but the server doesn't support it. // - net::ERR_FAILED // The request has failed because of an error with the network. // - net::ERR_INVALID_RESPONSE @@ -85,6 +83,10 @@ class BufferedResourceLoader : // the size is unknown. virtual int64 instance_size() { return instance_size_; } + // Returns true if the response for this loader is a partial response. + // It means a 206 response in HTTP/HTTPS protocol. + virtual bool partial_response() { return partial_response_; } + ///////////////////////////////////////////////////////////////////////////// // webkit_glue::ResourceLoaderBridge::Peer implementations. virtual void OnUploadProgress(uint64 position, uint64 size) {} @@ -137,10 +139,18 @@ class BufferedResourceLoader : // A sliding window of buffer. scoped_ptr<media::SeekableBuffer> buffer_; + // True if resource loading was deferred. bool deferred_; + + // True if resource loading has completed. bool completed_; + + // True if a range request was made. bool range_requested_; + // True if response data received is a partial range. + bool partial_response_; + webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory_; GURL url_; int64 first_byte_position_; @@ -257,10 +267,6 @@ class BufferedDataSource : public media::DataSource { // initial request is received. void InitialStartCallback(int error); - // Callback method for |probe_loader_|. This method is called when the - // response for probe request is received. - void ProbeStartCallback(int error); - // Callback method to be passed to BufferedResourceLoader during range // request. Once a resource request has started, this method will be called // with the error code. This method will be executed on the thread @@ -293,9 +299,6 @@ class BufferedDataSource : public media::DataSource { // A resource loader for the media resource. scoped_refptr<BufferedResourceLoader> loader_; - // A resource loader that probes the server's ability to serve range requests. - scoped_refptr<BufferedResourceLoader> probe_loader_; - // Callback method from the pipeline for initialization. scoped_ptr<media::FilterCallback> initialize_callback_; @@ -307,12 +310,6 @@ class BufferedDataSource : public media::DataSource { base::Time read_submitted_time_; int read_attempts_; - // This flag is set to true if the initial request has started. - bool initial_response_received_; - - // This flag is set to true if the probe request has started. - bool probe_response_received_; - // This buffer is intermediate, we use it for BufferedResourceLoader to write // to. And when read in BufferedResourceLoader is done, we copy data from // this buffer to |read_buffer_|. The reason for an additional copy is that |