OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_FILTERS_MEMORY_DATA_SOURCE_H_ | 5 #ifndef MEDIA_FILTERS_MEMORY_DATA_SOURCE_H_ |
6 #define MEDIA_FILTERS_MEMORY_DATA_SOURCE_H_ | 6 #define MEDIA_FILTERS_MEMORY_DATA_SOURCE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "media/base/data_source.h" | 11 #include "media/base/data_source.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // Basic data source that treats the URL as a file path, and uses the file | 15 // Basic data source that treats the URL as a file path, and uses the file |
16 // system to read data for a media pipeline. | 16 // system to read data for a media pipeline. |
17 class MEDIA_EXPORT MemoryDataSource : public DataSource { | 17 class MEDIA_EXPORT MemoryDataSource : public DataSource { |
18 public: | 18 public: |
19 // Construct MemoryDataSource with |data| and |size|. The data is guaranteed | 19 // Construct MemoryDataSource with |data| and |size|. The data is guaranteed |
20 // to be valid during the lifetime of MemoryDataSource. | 20 // to be valid during the lifetime of MemoryDataSource. |
21 MemoryDataSource(const uint8_t* data, size_t size); | 21 MemoryDataSource(const uint8_t* data, size_t size); |
22 ~MemoryDataSource() final; | 22 ~MemoryDataSource() final; |
23 | 23 |
24 // Implementation of DataSource. | 24 // Implementation of DataSource. |
25 void Read(int64_t position, | 25 void Read(int64_t position, |
26 int size, | 26 int size, |
27 uint8_t* data, | 27 uint8_t* data, |
28 const DataSource::ReadCB& read_cb) final; | 28 const DataSource::ReadCB& read_cb) final; |
29 void Stop() final; | 29 void Stop() final; |
| 30 void Abort() final; |
30 bool GetSize(int64_t* size_out) final; | 31 bool GetSize(int64_t* size_out) final; |
31 bool IsStreaming() final; | 32 bool IsStreaming() final; |
32 void SetBitrate(int bitrate) final; | 33 void SetBitrate(int bitrate) final; |
33 | 34 |
34 private: | 35 private: |
35 const uint8_t* data_ = nullptr; | 36 const uint8_t* data_ = nullptr; |
36 size_t size_ = 0; | 37 size_t size_ = 0; |
37 | 38 |
38 bool is_stopped_ = false; | 39 bool is_stopped_ = false; |
39 | 40 |
40 DISALLOW_COPY_AND_ASSIGN(MemoryDataSource); | 41 DISALLOW_COPY_AND_ASSIGN(MemoryDataSource); |
41 }; | 42 }; |
42 | 43 |
43 } // namespace media | 44 } // namespace media |
44 | 45 |
45 #endif // MEDIA_FILTERS_MEMORY_DATA_SOURCE_H_ | 46 #endif // MEDIA_FILTERS_MEMORY_DATA_SOURCE_H_ |
OLD | NEW |