Loading...
Searching...
No Matches
ChunkReader.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_CHUNK_READER_H
#define OPENSHOT_CHUNK_READER_H
#include <string>
#include <memory>
#include "ReaderBase.h"
#include "Json.h"
namespace openshot
{
class CacheBase;
class Frame;
struct ChunkLocation
{
int64_t number;
int64_t frame;
};
enum ChunkVersion
{
THUMBNAIL,
PREVIEW,
FINAL
};
class ChunkReader : public ReaderBase
{
private:
std::string path;
bool is_open;
int64_t chunk_size;
openshot::ReaderBase *local_reader;
ChunkLocation previous_location;
ChunkVersion version;
std::shared_ptr<openshot::Frame> last_frame;
bool does_folder_exist(std::string path);
ChunkLocation find_chunk_frame(int64_t requested_frame);
std::string get_chunk_path(int64_t chunk_number, std::string folder, std::string extension);
void load_json();
public:
ChunkReader(std::string path, ChunkVersion chunk_version);
void Close() override;
int64_t GetChunkSize() { return chunk_size; };
void SetChunkSize(int64_t new_size) { chunk_size = new_size; };
openshot::CacheBase* GetCache() override { return nullptr; };
std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame) override;
bool IsOpen() override { return is_open; };
std::string Name() override { return "ChunkReader"; };
// Get and Set JSON methods
std::string Json() const override;
void SetJson(const std::string value) override;
Json::Value JsonValue() const override;
void SetJsonValue(const Json::Value root) override;
void Open() override;
};
}
#endif
Json.h
Header file for JSON class.
ReaderBase.h
Header file for ReaderBase class.
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition CacheBase.h:35
openshot::ChunkReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition ChunkReader.cpp:244
openshot::ChunkReader::Close
void Close() override
Close the reader.
Definition ChunkReader.cpp:149
openshot::ChunkReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition ChunkReader.h:129
openshot::ChunkReader::Open
void Open() override
Open the reader. This is required before you can access frames or data from the reader.
Definition ChunkReader.cpp:135
openshot::ChunkReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition ChunkReader.cpp:251
openshot::ChunkReader::ChunkReader
ChunkReader(std::string path, ChunkVersion chunk_version)
Constructor for ChunkReader. This automatically opens the chunk file or folder and loads frame 1,...
Definition ChunkReader.cpp:23
openshot::ChunkReader::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
Get an openshot::Frame object for a specific frame number of this reader.
Definition ChunkReader.cpp:183
openshot::ChunkReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition ChunkReader.cpp:283
openshot::ChunkReader::GetChunkSize
int64_t GetChunkSize()
Get the chunk size (number of frames to write in each chunk).
Definition ChunkReader.h:114
openshot::ChunkReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition ChunkReader.cpp:267
openshot::ChunkReader::Name
std::string Name() override
Return the type name of the class.
Definition ChunkReader.h:132
openshot::ChunkReader::SetChunkSize
void SetChunkSize(int64_t new_size)
Set the chunk size (number of frames to write in each chunk).
Definition ChunkReader.h:118
openshot::ChunkReader::GetCache
openshot::CacheBase * GetCache() override
Get the cache object used by this reader (always return NULL for this reader).
Definition ChunkReader.h:121
openshot::Frame
This class represents a single frame of video (i.e. image & audio data).
Definition Frame.h:89
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition ReaderBase.h:76
openshot::ReaderBase::ReaderBase
ReaderBase()
Constructor for the base reader, where many things are initialized.
Definition ReaderBase.cpp:26
openshot
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29
openshot::ChunkVersion
ChunkVersion
This enumeration allows the user to choose which version of the chunk they would like (low,...
Definition ChunkReader.h:50
openshot::THUMBNAIL
@ THUMBNAIL
The lowest quality stream contained in this chunk file.
Definition ChunkReader.h:51
openshot::FINAL
@ FINAL
The highest quality stream contained in this chunk file.
Definition ChunkReader.h:53
openshot::PREVIEW
@ PREVIEW
The medium quality stream contained in this chunk file.
Definition ChunkReader.h:52
openshot::ChunkLocation
This struct holds the location of a frame within a chunk.
Definition ChunkReader.h:34
openshot::ChunkLocation::number
int64_t number
The chunk number.
Definition ChunkReader.h:35
openshot::ChunkLocation::frame
int64_t frame
The frame number.
Definition ChunkReader.h:36