DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
memory_file.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_MEDIA_FILE_H_
8 #define MEDIA_FILE_MEDIA_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 #include <vector>
14 
15 #include "packager/media/file/file.h"
16 
17 namespace shaka {
18 namespace media {
19 
22 class MemoryFile : public File {
23  public:
24  MemoryFile(const std::string& file_name, const std::string& mode);
25 
28  bool Close() override;
29  int64_t Read(void* buffer, uint64_t length) override;
30  int64_t Write(const void* buffer, uint64_t length) override;
31  int64_t Size() override;
32  bool Flush() override;
33  bool Seek(uint64_t position) override;
34  bool Tell(uint64_t* position) override;
36 
40  static void DeleteAll();
43  static void Delete(const std::string& file_name);
44 
45  protected:
46  ~MemoryFile() override;
47  bool Open() override;
48 
49  private:
50  std::string mode_;
51  std::vector<uint8_t>* file_;
52  uint64_t position_;
53 
54  DISALLOW_COPY_AND_ASSIGN(MemoryFile);
55 };
56 
57 } // namespace media
58 } // namespace shaka
59 
60 #endif // MEDIA_FILE_MEDIA_FILE_H_
61 
int64_t Size() override
Definition: memory_file.cc:91
int64_t Read(void *buffer, uint64_t length) override
Definition: memory_file.cc:68
int64_t Write(const void *buffer, uint64_t length) override
Definition: memory_file.cc:80
Define an abstract file interface.
Definition: file.h:24
bool Tell(uint64_t *position) override
Definition: memory_file.cc:108
static void Delete(const std::string &file_name)
Definition: memory_file.cc:135
bool Open() override
Internal open. Should not be used directly.
Definition: memory_file.cc:113
bool Seek(uint64_t position) override
Definition: memory_file.cc:100
const std::string & file_name() const
Definition: file.h:91
bool Flush() override
Definition: memory_file.cc:96
bool Close() override
Definition: memory_file.cc:63