OpenShot Library | libopenshot 0.3.3
Loading...
Searching...
No Matches
ChunkReader.h
Go to the documentation of this file.
1
9// Copyright (c) 2008-2019 OpenShot Studios, LLC
10//
11// SPDX-License-Identifier: LGPL-3.0-or-later
12
13#ifndef OPENSHOT_CHUNK_READER_H
14#define OPENSHOT_CHUNK_READER_H
15
16#include <string>
17#include <memory>
18
19#include "ReaderBase.h"
20#include "Json.h"
21
22namespace openshot
23{
24 class CacheBase;
25 class Frame;
34 {
35 int64_t number;
36 int64_t frame;
37 };
38
55
78 class ChunkReader : public ReaderBase
79 {
80 private:
81 std::string path;
82 bool is_open;
83 int64_t chunk_size;
84 openshot::ReaderBase *local_reader;
85 ChunkLocation previous_location;
86 ChunkVersion version;
87 std::shared_ptr<openshot::Frame> last_frame;
88
90 bool does_folder_exist(std::string path);
91
93 ChunkLocation find_chunk_frame(int64_t requested_frame);
94
96 std::string get_chunk_path(int64_t chunk_number, std::string folder, std::string extension);
97
99 void load_json();
100
101 public:
102
107 ChunkReader(std::string path, ChunkVersion chunk_version);
108
110 void Close() override;
111
114 int64_t GetChunkSize() { return chunk_size; };
115
118 void SetChunkSize(int64_t new_size) { chunk_size = new_size; };
119
121 openshot::CacheBase* GetCache() override { return nullptr; };
122
126 std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame) override;
127
129 bool IsOpen() override { return is_open; };
130
132 std::string Name() override { return "ChunkReader"; };
133
134 // Get and Set JSON methods
135 std::string Json() const override;
136 void SetJson(const std::string value) override;
137 Json::Value JsonValue() const override;
138 void SetJsonValue(const Json::Value root) override;
139
141 void Open() override;
142 };
143
144}
145
146#endif
Header file for JSON class.
Header file for ReaderBase class.
All cache managers in libopenshot are based on this CacheBase class.
Definition CacheBase.h:35
This class reads a special chunk-formatted file, which can be easily shared in a distributed environm...
Definition ChunkReader.h:79
std::string Json() const override
Generate JSON string of this object.
void Close() override
Close the reader.
bool IsOpen() override
Determine if reader is open or closed.
void Open() override
Open the reader. This is required before you can access frames or data from the reader.
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
Get an openshot::Frame object for a specific frame number of this reader.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
int64_t GetChunkSize()
Get the chunk size (number of frames to write in each chunk)
void SetJson(const std::string value) override
Load JSON string into this object.
std::string Name() override
Return the type name of the class.
void SetChunkSize(int64_t new_size)
Set the chunk size (number of frames to write in each chunk)
openshot::CacheBase * GetCache() override
Get the cache object used by this reader (always return NULL for this reader)
This abstract class is the base class, used by all readers in libopenshot.
Definition ReaderBase.h:76
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29
ChunkVersion
This enumeration allows the user to choose which version of the chunk they would like (low,...
Definition ChunkReader.h:50
@ THUMBNAIL
The lowest quality stream contained in this chunk file.
Definition ChunkReader.h:51
@ FINAL
The highest quality stream contained in this chunk file.
Definition ChunkReader.h:53
@ PREVIEW
The medium quality stream contained in this chunk file.
Definition ChunkReader.h:52
This struct holds the location of a frame within a chunk.
Definition ChunkReader.h:34
int64_t number
The chunk number.
Definition ChunkReader.h:35
int64_t frame
The frame number.
Definition ChunkReader.h:36