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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 class MEDIA_EXPORT DataSource { | 17 class MEDIA_EXPORT DataSource { |
18 public: | 18 public: |
19 typedef base::Callback<void(int64_t, int64_t)> StatusCallback; | 19 typedef base::Callback<void(int64_t, int64_t)> StatusCallback; |
20 typedef base::Callback<void(int)> ReadCB; | 20 typedef base::Callback<void(int)> ReadCB; |
21 | 21 |
22 enum { kReadError = -1 }; | 22 enum { kReadError = -1, kAborted = -2 }; |
23 | 23 |
24 DataSource(); | 24 DataSource(); |
25 virtual ~DataSource(); | 25 virtual ~DataSource(); |
26 | 26 |
27 // Reads |size| bytes from |position| into |data|. And when the read is done | 27 // Reads |size| bytes from |position| into |data|. And when the read is done |
28 // or failed, |read_cb| is called with the number of bytes read or | 28 // or failed, |read_cb| is called with the number of bytes read or |
29 // kReadError in case of error. | 29 // kReadError in case of error. |
30 virtual void Read(int64_t position, | 30 virtual void Read(int64_t position, |
31 int size, | 31 int size, |
32 uint8_t* data, | 32 uint8_t* data, |
33 const DataSource::ReadCB& read_cb) = 0; | 33 const DataSource::ReadCB& read_cb) = 0; |
34 | 34 |
35 // Stops the DataSource. Once this is called all future Read() calls will | 35 // Stops the DataSource. Once this is called all future Read() calls will |
36 // return an error. | 36 // return an error. |
37 virtual void Stop() = 0; | 37 virtual void Stop() = 0; |
38 | 38 |
| 39 // Similar to Stop(), but only aborts current reads and not future reads. |
| 40 virtual void Abort() = 0; |
| 41 |
39 // Returns true and the file size, false if the file size could not be | 42 // Returns true and the file size, false if the file size could not be |
40 // retrieved. | 43 // retrieved. |
41 virtual bool GetSize(int64_t* size_out) = 0; | 44 virtual bool GetSize(int64_t* size_out) = 0; |
42 | 45 |
43 // Returns true if we are performing streaming. In this case seeking is | 46 // Returns true if we are performing streaming. In this case seeking is |
44 // not possible. | 47 // not possible. |
45 virtual bool IsStreaming() = 0; | 48 virtual bool IsStreaming() = 0; |
46 | 49 |
47 // Notify the DataSource of the bitrate of the media. | 50 // Notify the DataSource of the bitrate of the media. |
48 // Values of |bitrate| <= 0 are invalid and should be ignored. | 51 // Values of |bitrate| <= 0 are invalid and should be ignored. |
49 virtual void SetBitrate(int bitrate) = 0; | 52 virtual void SetBitrate(int bitrate) = 0; |
50 | 53 |
51 private: | 54 private: |
52 DISALLOW_COPY_AND_ASSIGN(DataSource); | 55 DISALLOW_COPY_AND_ASSIGN(DataSource); |
53 }; | 56 }; |
54 | 57 |
55 } // namespace media | 58 } // namespace media |
56 | 59 |
57 #endif // MEDIA_BASE_DATA_SOURCE_H_ | 60 #endif // MEDIA_BASE_DATA_SOURCE_H_ |
OLD | NEW |