tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BufferStream.h (1399B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef BUFFER_STREAM_H_
      6 #define BUFFER_STREAM_H_
      7 
      8 #include "ByteStream.h"
      9 #include "MediaResource.h"
     10 #include "nsTArray.h"
     11 
     12 namespace mozilla {
     13 class MediaByteBuffer;
     14 
     15 DDLoggedTypeDeclNameAndBase(BufferStream, ByteStream);
     16 
     17 class BufferStream : public ByteStream,
     18                     public mozilla::DecoderDoctorLifeLogger<BufferStream> {
     19 public:
     20  /* BufferStream does not take ownership of aData nor does it make a copy.
     21   * Therefore BufferStream shouldn't get used after aData is destroyed.
     22   */
     23  BufferStream();
     24  explicit BufferStream(mozilla::MediaByteBuffer* aBuffer);
     25 
     26  virtual nsresult ReadAt(int64_t aOffset, void* aData, size_t aLength,
     27                          size_t* aBytesRead) override;
     28  virtual nsresult CachedReadAt(int64_t aOffset, void* aData, size_t aLength,
     29                                size_t* aBytesRead) override;
     30  virtual bool Length(int64_t* aLength) override;
     31 
     32  virtual void DiscardBefore(int64_t aOffset) override;
     33 
     34  bool AppendBytes(const uint8_t* aData, size_t aLength);
     35 
     36  mozilla::MediaByteRange GetByteRange();
     37 
     38 private:
     39  ~BufferStream();
     40  int64_t mStartOffset;
     41  RefPtr<mozilla::MediaByteBuffer> mData;
     42 };
     43 }  // namespace mozilla
     44 
     45 #endif