#ifndef MEDIA_FILTERS_FILE_DATA_SOURCE_H_
#define MEDIA_FILTERS_FILE_DATA_SOURCE_H_
#include <string>
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/memory_mapped_file.h"
#include "media/base/data_source.h"
namespace media {
class MEDIA_EXPORT FileDataSource : public DataSource {
public:
FileDataSource();
explicit FileDataSource(base::File file);
virtual ~FileDataSource();
bool Initialize(const base::FilePath& file_path);
virtual void Stop(const base::Closure& callback) OVERRIDE;
virtual void Read(int64 position, int size, uint8* data,
const DataSource::ReadCB& read_cb) OVERRIDE;
virtual bool GetSize(int64* size_out) OVERRIDE;
virtual bool IsStreaming() OVERRIDE;
virtual void SetBitrate(int bitrate) OVERRIDE;
void force_read_errors_for_testing() { force_read_errors_ = true; }
void force_streaming_for_testing() { force_streaming_ = true; }
private:
base::MemoryMappedFile file_;
bool force_read_errors_;
bool force_streaming_;
DISALLOW_COPY_AND_ASSIGN(FileDataSource);
};
}
#endif