| Index: webrtc/base/stream.h
|
| diff --git a/webrtc/base/stream.h b/webrtc/base/stream.h
|
| index b3317663b5e3327cf4fc45ce06383aca9339ba8b..f67c704aa5155f8ed64cbc2cd2a32e4c6b376efd 100644
|
| --- a/webrtc/base/stream.h
|
| +++ b/webrtc/base/stream.h
|
| @@ -418,6 +418,39 @@ class FileStream : public StreamInterface {
|
| DISALLOW_COPY_AND_ASSIGN(FileStream);
|
| };
|
|
|
| +// A stream that caps the output at a certain size, dropping content from the
|
| +// middle of the logical stream and maintaining equal parts of the start/end of
|
| +// the logical stream.
|
| +class CircularFileStream : public FileStream {
|
| + public:
|
| + explicit CircularFileStream(size_t max_size);
|
| +
|
| + bool Open(const std::string& filename, const char* mode, int* error) override;
|
| + StreamResult Read(void* buffer,
|
| + size_t buffer_len,
|
| + size_t* read,
|
| + int* error) override;
|
| + StreamResult Write(const void* data,
|
| + size_t data_len,
|
| + size_t* written,
|
| + int* error) override;
|
| +
|
| + private:
|
| + enum ReadSegment {
|
| + READ_MARKED, // Read 0 .. marked_position_
|
| + READ_MIDDLE, // Read position_ .. file_size
|
| + READ_LATEST, // Read marked_position_ .. position_ if the buffer was
|
| + // overwritten or 0 .. position_ otherwise.
|
| + };
|
| +
|
| + size_t max_write_size_;
|
| + size_t position_;
|
| + size_t marked_position_;
|
| + size_t last_write_position_;
|
| + ReadSegment read_segment_;
|
| + size_t read_segment_available_;
|
| +};
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // MemoryStream is a simple implementation of a StreamInterface over in-memory
|
| // data. Data is read and written at the current seek position. Reads return
|
|
|