OpenShot Library | libopenshot  0.1.9
Public Member Functions | List of all members
openshot::ChunkReader Class Reference

This class reads a special chunk-formatted file, which can be easily shared in a distributed environment. More...

#include <ChunkReader.h>

Inheritance diagram for openshot::ChunkReader:
openshot::ReaderBase

Public Member Functions

 ChunkReader (string path, ChunkVersion chunk_version)
 Constructor for ChunkReader. This automatically opens the chunk file or folder and loads frame 1, or it throws one of the following exceptions. More...
 
void Close ()
 Close the reader. More...
 
CacheMemoryGetCache ()
 Get the cache object used by this reader (always return NULL for this reader) More...
 
int64_t GetChunkSize ()
 Get the chunk size (number of frames to write in each chunk) More...
 
std::shared_ptr< FrameGetFrame (int64_t requested_frame)
 Get an openshot::Frame object for a specific frame number of this reader. More...
 
bool IsOpen ()
 Determine if reader is open or closed. More...
 
string Json ()
 Get and Set JSON methods. More...
 
Json::Value JsonValue ()
 Generate Json::JsonValue for this object. More...
 
string Name ()
 Return the type name of the class. More...
 
void Open ()
 Open the reader. This is required before you can access frames or data from the reader. More...
 
void SetChunkSize (int64_t new_size)
 Set the chunk size (number of frames to write in each chunk) More...
 
void SetJson (string value)
 Load JSON string into this object. More...
 
void SetJsonValue (Json::Value root)
 Load Json::JsonValue into this object. More...
 
- Public Member Functions inherited from openshot::ReaderBase
void DisplayInfo ()
 Display file information in the standard output stream (stdout) More...
 
 ReaderBase ()
 Constructor for the base reader, where many things are initialized. More...
 
void SetMaxSize (int width, int height)
 Set Max Image Size (used for performance optimization) More...
 

Additional Inherited Members

- Public Attributes inherited from openshot::ReaderBase
ReaderInfo info
 Information about the current media file. More...
 
- Protected Attributes inherited from openshot::ReaderBase
CriticalSection getFrameCriticalSection
 Section lock for multiple threads. More...
 
int max_height
 The maximium image height needed by this clip (used for optimizations) More...
 
int max_width
 The maximum image width needed by this clip (used for optimizations) More...
 
CriticalSection processingCriticalSection
 

Detailed Description

This class reads a special chunk-formatted file, which can be easily shared in a distributed environment.

It stores the video in small "chunks", which are really just short video clips, a few seconds each. A ChunkReader only needs the part of the chunk that contains the frames it is looking for. For example, if you only need the end of a video, only the last few chunks might be needed to successfully access those openshot::Frame objects.

// This example demonstrates how to read a chunk folder and access frame objects inside it.
ChunkReader r("/home/jonathan/apps/chunks/chunk1/", FINAL); // Load highest quality version of this chunk file
r.DisplayInfo(); // Display all known details about this chunk file
r.Open(); // Open the reader
// Access frame 1
r.GetFrame(1)->Display();
// Close the reader
r.Close();

Definition at line 104 of file ChunkReader.h.

Constructor & Destructor Documentation

◆ ChunkReader()

ChunkReader::ChunkReader ( string  path,
ChunkVersion  chunk_version 
)

Constructor for ChunkReader. This automatically opens the chunk file or folder and loads frame 1, or it throws one of the following exceptions.

Parameters
pathThe folder path / location of a chunk (chunks are stored as folders)
chunk_versionChoose the video version / quality (THUMBNAIL, PREVIEW, or FINAL)

Definition at line 32 of file ChunkReader.cpp.

Member Function Documentation

◆ Close()

void ChunkReader::Close ( )
virtual

Close the reader.

Implements openshot::ReaderBase.

Definition at line 156 of file ChunkReader.cpp.

◆ GetCache()

CacheMemory* openshot::ChunkReader::GetCache ( )
inlinevirtual

Get the cache object used by this reader (always return NULL for this reader)

Implements openshot::ReaderBase.

Definition at line 147 of file ChunkReader.h.

◆ GetChunkSize()

int64_t openshot::ChunkReader::GetChunkSize ( )
inline

Get the chunk size (number of frames to write in each chunk)

Returns
The number of frames in this chunk

Definition at line 140 of file ChunkReader.h.

◆ GetFrame()

std::shared_ptr< Frame > ChunkReader::GetFrame ( int64_t  requested_frame)
virtual

Get an openshot::Frame object for a specific frame number of this reader.

Returns
The requested frame (containing the image and audio)
Parameters
requested_frameThe frame number you want to retrieve

Implements openshot::ReaderBase.

Definition at line 190 of file ChunkReader.cpp.

◆ IsOpen()

bool openshot::ChunkReader::IsOpen ( )
inlinevirtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 155 of file ChunkReader.h.

◆ Json()

string ChunkReader::Json ( )
virtual

Get and Set JSON methods.

Generate JSON string of this object

Implements openshot::ReaderBase.

Definition at line 254 of file ChunkReader.cpp.

◆ JsonValue()

Json::Value ChunkReader::JsonValue ( )
virtual

Generate Json::JsonValue for this object.

Implements openshot::ReaderBase.

Definition at line 261 of file ChunkReader.cpp.

◆ Name()

string openshot::ChunkReader::Name ( )
inlinevirtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 158 of file ChunkReader.h.

◆ Open()

void ChunkReader::Open ( )
virtual

Open the reader. This is required before you can access frames or data from the reader.

Implements openshot::ReaderBase.

Definition at line 142 of file ChunkReader.cpp.

◆ SetChunkSize()

void openshot::ChunkReader::SetChunkSize ( int64_t  new_size)
inline

Set the chunk size (number of frames to write in each chunk)

Parameters
new_sizeThe number of frames per chunk

Definition at line 144 of file ChunkReader.h.

◆ SetJson()

void ChunkReader::SetJson ( string  value)
virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 277 of file ChunkReader.cpp.

◆ SetJsonValue()

void ChunkReader::SetJsonValue ( Json::Value  root)
virtual

Load Json::JsonValue into this object.

Implements openshot::ReaderBase.

Definition at line 300 of file ChunkReader.cpp.


The documentation for this class was generated from the following files: