Loading...
Searching...
No Matches
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:

## Public Member Functions

| ChunkReader (std::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.
void | Close () override
| Close the reader.
openshot::CacheBase * | GetCache () override
| Get the cache object used by this reader (always return NULL for this reader)
int64_t | GetChunkSize ()
| Get the chunk size (number of frames to write in each chunk)
std::shared_ptr< openshot::Frame > | GetFrame (int64_t requested_frame) override
| Get an openshot::Frame object for a specific frame number of this reader.
bool | IsOpen () override
| Determine if reader is open or closed.
std::string | Json () const override
| Generate JSON string of this object.
Json::Value | JsonValue () const override
| Generate Json::Value for this object.
std::string | Name () override
| Return the type name of the class.
void | Open () override
| Open the reader. This is required before you can access frames or data from the reader.
void | SetChunkSize (int64_t new_size)
| Set the chunk size (number of frames to write in each chunk)
void | SetJson (const std::string value) override
| Load JSON string into this object.
void | SetJsonValue (const Json::Value root) override
| Load Json::Value into this object.
Public Member Functions inherited from openshot::ReaderBase
void | DisplayInfo (std::ostream *out=&std::cout)
| Display file information in the standard output stream (stdout)
openshot::ClipBase * | ParentClip ()
| Parent clip object of this reader (which can be unparented and NULL)
void | ParentClip (openshot::ClipBase *new_clip)
| Set parent clip object of this reader.
| ReaderBase ()
| Constructor for the base reader, where many things are initialized.
virtual | ~ReaderBase ()=default

## Additional Inherited Members

Public Attributes inherited from openshot::ReaderBase
openshot::ReaderInfo | info
| Information about the current media file.
Protected Attributes inherited from openshot::ReaderBase
openshot::ClipBase * | clip
| Pointer to the parent clip instance (if any)
std::recursive_mutex | getFrameMutex
| Mutex for multiple threads.

## 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();
openshot::ChunkReader
This class reads a special chunk-formatted file, which can be easily shared in a distributed environm...
Definition ChunkReader.h:79
openshot::FINAL
@ FINAL
The highest quality stream contained in this chunk file.
Definition ChunkReader.h:53

Definition at line 78 of file ChunkReader.h.

## Constructor & Destructor Documentation

## ChunkReader()

ChunkReader::ChunkReader | ( | std::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

  path | The folder path / location of a chunk (chunks are stored as folders)
  chunk_version | Choose the video version / quality (THUMBNAIL, PREVIEW, or FINAL)

Definition at line 23 of file ChunkReader.cpp.

## Member Function Documentation

## Close()

void ChunkReader::Close | ( |  | ) |

override virtual

Close the reader.

Implements openshot::ReaderBase.

Definition at line 149 of file ChunkReader.cpp.

Referenced by ChunkReader(), and SetJsonValue().

## GetCache()

openshot::CacheBase * openshot::ChunkReader::GetCache | ( |  | ) |

inline override virtual

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

Implements openshot::ReaderBase.

Definition at line 121 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 114 of file ChunkReader.h.

## GetFrame()

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

override 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_frame | The frame number you want to retrieve

Implements openshot::ReaderBase.

Definition at line 183 of file ChunkReader.cpp.

## IsOpen()

bool openshot::ChunkReader::IsOpen | ( |  | ) |

inline override virtual

Determine if reader is open or closed.

Implements openshot::ReaderBase.

Definition at line 129 of file ChunkReader.h.

## Json()

std::string ChunkReader::Json | ( |  | ) | const

override virtual

Generate JSON string of this object.

Implements openshot::ReaderBase.

Definition at line 244 of file ChunkReader.cpp.

## JsonValue()

Json::Value ChunkReader::JsonValue | ( |  | ) | const

override virtual

Generate Json::Value for this object.

Implements openshot::ReaderBase.

Definition at line 251 of file ChunkReader.cpp.

Referenced by Json().

## Name()

std::string openshot::ChunkReader::Name | ( |  | ) |

inline override virtual

Return the type name of the class.

Implements openshot::ReaderBase.

Definition at line 132 of file ChunkReader.h.

## Open()

void ChunkReader::Open | ( |  | ) |

override virtual

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

Implements openshot::ReaderBase.

Definition at line 135 of file ChunkReader.cpp.

Referenced by ChunkReader(), and SetJsonValue().

## SetChunkSize()

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

inline

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

Parameters

  new_size | The number of frames per chunk

Definition at line 118 of file ChunkReader.h.

## SetJson()

void ChunkReader::SetJson | ( | const std::string | value | ) |

override virtual

Load JSON string into this object.

Implements openshot::ReaderBase.

Definition at line 267 of file ChunkReader.cpp.

## SetJsonValue()

void ChunkReader::SetJsonValue | ( | const Json::Value | root | ) |

override virtual

Load Json::Value into this object.

Implements openshot::ReaderBase.

Definition at line 283 of file ChunkReader.cpp.

Referenced by SetJson().

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

- ChunkReader.h
- ChunkReader.cpp