in_memory_url_protocol.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_
  5. #define MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_
  6. #include <stdint.h>
  7. #include "base/compiler_specific.h"
  8. #include "media/filters/ffmpeg_glue.h"
  9. namespace media {
  10. // Simple FFmpegURLProtocol that reads from a buffer.
  11. // NOTE: This object does not copy the buffer so the
  12. // buffer pointer passed into the constructor
  13. // needs to remain valid for the entire lifetime of
  14. // this object.
  15. class MEDIA_EXPORT InMemoryUrlProtocol : public FFmpegURLProtocol {
  16. public:
  17. InMemoryUrlProtocol() = delete;
  18. InMemoryUrlProtocol(const uint8_t* buf, int64_t size, bool streaming);
  19. InMemoryUrlProtocol(const InMemoryUrlProtocol&) = delete;
  20. InMemoryUrlProtocol& operator=(const InMemoryUrlProtocol&) = delete;
  21. virtual ~InMemoryUrlProtocol();
  22. // FFmpegURLProtocol methods.
  23. int Read(int size, uint8_t* data) override;
  24. bool GetPosition(int64_t* position_out) override;
  25. bool SetPosition(int64_t position) override;
  26. bool GetSize(int64_t* size_out) override;
  27. bool IsStreaming() override;
  28. private:
  29. const uint8_t* data_;
  30. int64_t size_;
  31. int64_t position_;
  32. bool streaming_;
  33. };
  34. } // namespace media
  35. #endif // MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_