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

Unified Diff: webkit/glue/media/buffered_data_source.h

Issue 160076: BufferedDataSource to support server without range request support... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/api/src/WebMediaPlayerClientImpl.cpp ('k') | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/media/buffered_data_source.h
===================================================================
--- webkit/glue/media/buffered_data_source.h (revision 21893)
+++ webkit/glue/media/buffered_data_source.h (working copy)
@@ -44,7 +44,18 @@
// Start the resource loading with the specified URL and range.
// This method operates in asynchronous mode. Once there's a response from the
- // server, success or fail |start_callback| is called with the result.
+ // server, success or fail |callback| is called with the result.
+ // |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
+ // An invalid response is received from the server.
+ // - (Anything else)
+ // An error code that indicates the request has failed.
virtual void Start(net::CompletionCallback* callback);
// Stop this loader, cancels and request and release internal buffer.
@@ -53,13 +64,24 @@
// Reads the specified |read_size| from |position| into |buffer| and when
// the operation is done invoke |callback| with number of bytes read or an
// error code.
+ // |callback| is called with the following values:
+ // - (Anything greater than or equal 0)
+ // Read was successful with the indicated number of bytes read.
+ // - net::ERR_FAILED
+ // The read has failed because of an error with the network.
+ // - net::ERR_CACHE_MISS
+ // The read was made too far away from the current buffered position.
virtual void Read(int64 position, int read_size,
uint8* buffer, net::CompletionCallback* callback);
// Gets the content length in bytes of the instance after this loader has been
- // started.
+ // started. If this value is -1, then content length is unknown.
virtual int64 content_length() { return content_length_; }
+ // Gets the original size of the file requested. If this value is -1, then
+ // the size is unknown.
+ virtual int64 instance_size() { return instance_size_; }
+
/////////////////////////////////////////////////////////////////////////////
// webkit_glue::ResourceLoaderBridge::Peer implementations.
virtual void OnUploadProgress(uint64 position, uint64 size) {}
@@ -91,13 +113,13 @@
// Returns true if the current read request will be fulfilled in the future.
bool WillFulfillRead();
- // Checks parameters and make sure they are valid.
- bool VerifyRead();
-
// Method that does the actual read and calls the |read_callbac_|, assuming
// the request range is in |buffer_|.
void ReadInternal();
+ // If we have made a range request, verify the response from the server.
+ bool VerifyPartialResponse(const ResourceLoaderBridge::ResponseInfo& info);
+
// Done with read. Invokes the read callback and reset parameters for the
// read request.
void DoneRead(int error);
@@ -124,6 +146,7 @@
scoped_ptr<webkit_glue::ResourceLoaderBridge> bridge_;
int64 offset_;
int64 content_length_;
+ int64 instance_size_;
// Members used during a read operation. They should be reset after each
// read has completed or failed.
@@ -165,7 +188,7 @@
uint8* data,
media::DataSource::ReadCallback* read_callback);
virtual bool GetSize(int64* size_out);
- virtual bool IsSeekable();
+ virtual bool IsStreaming();
const media::MediaFormat& media_format() {
return media_format_;
@@ -215,10 +238,14 @@
// Calls |initialize_callback_| and reset it.
void DoneInitialization();
- // Callback method to perform BufferedResourceLoader::Start() during
- // initialization.
- void InitializeStartCallback(int error);
+ // Callback method for |loader_|. This method is called when response for
+ // 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
@@ -241,18 +268,34 @@
// need to protect it.
int64 total_bytes_;
+ // This value will be true if this data source can only support streaming.
+ // i.e. range request is not supported.
+ bool streaming_;
+
// A factory object to produce ResourceLoaderBridge.
scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_;
- // A downloader object for loading the media resource.
+ // A resource loader for the media resource.
scoped_ptr<BufferedResourceLoader> loader_;
+ // A resource loader that probes the server's ability to serve range requests.
+ scoped_ptr<BufferedResourceLoader> probe_loader_;
+
+ // Callback method from the pipeline for initialization.
+ scoped_ptr<media::FilterCallback> initialize_callback_;
+
// Read parameters received from the Read() method call.
scoped_ptr<media::DataSource::ReadCallback> read_callback_;
int64 read_position_;
int read_size_;
uint8* read_buffer_;
+ // 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
@@ -269,9 +312,6 @@
// The message loop of the render thread.
MessageLoop* render_loop_;
- // Filter callbacks.
- scoped_ptr<media::FilterCallback> initialize_callback_;
-
// Protects |stopped_|.
Lock lock_;
« no previous file with comments | « webkit/api/src/WebMediaPlayerClientImpl.cpp ('k') | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698