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