| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_BASE_DATA_SOURCE_H_ | 5 #ifndef MEDIA_BASE_DATA_SOURCE_H_ |
| 6 #define MEDIA_BASE_DATA_SOURCE_H_ | 6 #define MEDIA_BASE_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // be played. | 23 // be played. |
| 24 virtual void SetBufferedBytes(int64 buffered_bytes) = 0; | 24 virtual void SetBufferedBytes(int64 buffered_bytes) = 0; |
| 25 | 25 |
| 26 // Sets the flag to indicate current network activity. | 26 // Sets the flag to indicate current network activity. |
| 27 virtual void SetNetworkActivity(bool is_downloading_data) = 0; | 27 virtual void SetNetworkActivity(bool is_downloading_data) = 0; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class MEDIA_EXPORT DataSource : public base::RefCountedThreadSafe<DataSource> { | 30 class MEDIA_EXPORT DataSource : public base::RefCountedThreadSafe<DataSource> { |
| 31 public: | 31 public: |
| 32 typedef base::Callback<void(int64, int64)> StatusCallback; | 32 typedef base::Callback<void(int64, int64)> StatusCallback; |
| 33 typedef base::Callback<void(size_t)> ReadCB; | 33 typedef base::Callback<void(int)> ReadCB; |
| 34 static const size_t kReadError; | 34 static const int kReadError; |
| 35 | 35 |
| 36 DataSource(); | 36 DataSource(); |
| 37 | 37 |
| 38 virtual void set_host(DataSourceHost* host); | 38 virtual void set_host(DataSourceHost* host); |
| 39 | 39 |
| 40 // Reads |size| bytes from |position| into |data|. And when the read is done | 40 // Reads |size| bytes from |position| into |data|. And when the read is done |
| 41 // or failed, |read_cb| is called with the number of bytes read or | 41 // or failed, |read_cb| is called with the number of bytes read or |
| 42 // kReadError in case of error. | 42 // kReadError in case of error. |
| 43 // TODO(hclam): should change |size| to int! It makes the code so messy | 43 virtual void Read(int64 position, int size, uint8* data, |
| 44 // with size_t and int all over the place.. | |
| 45 virtual void Read(int64 position, size_t size, | |
| 46 uint8* data, | |
| 47 const DataSource::ReadCB& read_cb) = 0; | 44 const DataSource::ReadCB& read_cb) = 0; |
| 48 | 45 |
| 49 // Notifies the DataSource of a change in the current playback rate. | 46 // Notifies the DataSource of a change in the current playback rate. |
| 50 virtual void SetPlaybackRate(float playback_rate); | 47 virtual void SetPlaybackRate(float playback_rate); |
| 51 | 48 |
| 52 // Stops the DataSource. Once this is called all future Read() calls will | 49 // Stops the DataSource. Once this is called all future Read() calls will |
| 53 // return an error. | 50 // return an error. |
| 54 virtual void Stop(const base::Closure& callback) = 0; | 51 virtual void Stop(const base::Closure& callback) = 0; |
| 55 | 52 |
| 56 // Returns true and the file size, false if the file size could not be | 53 // Returns true and the file size, false if the file size could not be |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 | 74 |
| 78 private: | 75 private: |
| 79 DataSourceHost* host_; | 76 DataSourceHost* host_; |
| 80 | 77 |
| 81 DISALLOW_COPY_AND_ASSIGN(DataSource); | 78 DISALLOW_COPY_AND_ASSIGN(DataSource); |
| 82 }; | 79 }; |
| 83 | 80 |
| 84 } // namespace media | 81 } // namespace media |
| 85 | 82 |
| 86 #endif // MEDIA_BASE_DATA_SOURCE_H_ | 83 #endif // MEDIA_BASE_DATA_SOURCE_H_ |
| OLD | NEW |