Index: media/base/data_source.h |
diff --git a/media/base/data_source.h b/media/base/data_source.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8e9022de9efb31eb5a48c609c0ac7acde723cef6 |
--- /dev/null |
+++ b/media/base/data_source.h |
@@ -0,0 +1,98 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_BASE_DATA_SOURCE_H_ |
+#define MEDIA_BASE_DATA_SOURCE_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "media/base/media_export.h" |
+ |
+namespace media { |
+ |
+class DataSourceHost { |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
No MEDIA_EXPORT on this and the enum below?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Didn't appear to be needed for my shared build, bu
|
+ public: |
+ // Set the total size of the media file. |
+ virtual void SetTotalBytes(int64 total_bytes) = 0; |
+ |
+ // Sets the total number of bytes that are buffered on the client and ready to |
+ // be played. |
+ virtual void SetBufferedBytes(int64 buffered_bytes) = 0; |
+ |
+ // Sets the flag to indicate current network activity. |
+ virtual void SetNetworkActivity(bool is_downloading_data) = 0; |
+ |
+ protected: |
+ virtual ~DataSourceHost() {} |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
Comment about why?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
I don't have a good reason why so I'm just going t
|
+}; |
+ |
+// Used to specify video preload states. They are "hints" to the browser about |
+// how aggressively the browser should load and buffer data. |
+// Please see the HTML5 spec for the descriptions of these values: |
+// http://www.w3.org/TR/html5/video.html#attr-media-preload |
+// |
+// Enum values must match the values in WebCore::MediaPlayer::Preload and |
+// there will be assertions at compile time if they do not match. |
+enum Preload { |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
I wonder whether this wants to live inside DataSou
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Actually after further thought, I don't think Data
Ami GONE FROM CHROMIUM
2011/12/15 22:39:18
Either of the latter 2 would cause a circular depe
|
+ NONE, |
+ METADATA, |
+ AUTO, |
+}; |
+ |
+class MEDIA_EXPORT DataSource : public base::RefCountedThreadSafe<DataSource> { |
+ public: |
+ typedef base::Callback<void(int64, int64)> StatusCallback; |
+ typedef base::Callback<void(size_t)> ReadCallback; |
+ static const size_t kReadError; |
+ |
+ virtual void set_host(DataSourceHost* host); |
+ |
+ // Reads |size| bytes from |position| into |data|. And when the read is done |
+ // or failed, |read_callback| is called with the number of bytes read or |
+ // kReadError in case of error. |
+ // TODO(hclam): should change |size| to int! It makes the code so messy |
+ // with size_t and int all over the place.. |
+ virtual void Read(int64 position, size_t size, |
+ uint8* data, |
+ const DataSource::ReadCallback& read_callback) = 0; |
+ |
+ // Notifies the DataSource of a change in the current playback rate. |
+ virtual void SetPlaybackRate(float playback_rate); |
+ |
+ // Stops the DataSource. Once this is called all future Read() calls will |
+ // return an error. |
+ virtual void Stop(const base::Closure& callback) = 0; |
+ |
+ // Returns true and the file size, false if the file size could not be |
+ // retrieved. |
+ virtual bool GetSize(int64* size_out) = 0; |
+ |
+ // Returns true if we are performing streaming. In this case seeking is |
+ // not possible. |
+ virtual bool IsStreaming() = 0; |
+ |
+ // Alert the DataSource that the video preload value has been changed. |
+ virtual void SetPreload(Preload preload) = 0; |
+ |
+ // Notify the DataSource of the bitrate of the media. |
+ // Values of |bitrate| <= 0 are invalid and should be ignored. |
+ virtual void SetBitrate(int bitrate) = 0; |
+ |
+ protected: |
+ friend class base::RefCountedThreadSafe<DataSource>; |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
This is necessary?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Yes. This follows the pattern, in other parts of t
|
+ |
+ DataSource(); |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
doco why these are protected?
(generally, "protec
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Made this public since a DataSource can't be creat
|
+ virtual ~DataSource(); |
+ |
+ DataSourceHost* host(); |
+ |
+ private: |
+ DataSourceHost* host_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DataSource); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_DATA_SOURCE_H_ |