MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Private Member Functions | Private Attributes
DTSC::File Class Reference

A simple wrapper class that will open a file and allow easy reading/writing of DTSC data from/to it. More...

#include <dtsc.h>

Public Member Functions

 File ()
 
 File ()
 
 File (const File &rhs)
 
 File (const File &rhs)
 
 File (std::string filename, bool create=false)
 Open a filename for DTSC reading/writing. More...
 
 File (std::string filename, bool create=false)
 
 ~File ()
 Close the file if open. More...
 
 ~File ()
 
long long int addHeader (std::string &header)
 
long long int addHeader (std::string &header)
 Adds the given string as a new header to the end of the file. More...
 
bool atKeyframe ()
 
bool atKeyframe ()
 
long int getBytePos ()
 
long int getBytePos ()
 
long int getBytePosEOF ()
 
long int getBytePosEOF ()
 
long long int getLastReadPos ()
 Returns the byte positon of the start of the last packet that was read. More...
 
long long int getLastReadPos ()
 
MetagetMeta ()
 Returns the header metadata for this file as JSON::Value. More...
 
MetagetMeta ()
 
DTSC::PacketgetPacket ()
 Returns the internal buffer of the last read packet in raw binary format. More...
 
DTSC::PacketgetPacket ()
 
 operator bool () const
 
 operator bool () const
 
Fileoperator= (const File &rhs)
 
Fileoperator= (const File &rhs)
 
void parseNext ()
 
void parseNext ()
 
bool reachedEOF ()
 
bool reachedEOF ()
 
void rewritePacket (std::string &newPacket, int bytePos)
 
void rewritePacket (std::string &newPacket, int bytePos)
 
bool seek_bpos (int bpos)
 
bool seek_bpos (int bpos)
 
bool seek_time (unsigned int ms)
 Attempts to seek to the given time in ms within the file. More...
 
bool seek_time (unsigned int ms)
 
bool seek_time (unsigned int ms, unsigned int trackNo, bool forceSeek=false)
 
bool seek_time (unsigned int ms, unsigned int trackNo, bool forceSeek=false)
 
void seekNext ()
 
void seekNext ()
 Reads the packet available at the current file position. More...
 
void selectTracks (std::set< unsigned long > &tracks)
 
void selectTracks (std::set< unsigned long > &tracks)
 
bool writeHeader (std::string &header, bool force=false)
 (Re)writes the given string to the header area if the size is the same as the existing header. More...
 
bool writeHeader (std::string &header, bool force=false)
 
void writePacket (std::string &newPacket)
 
void writePacket (std::string &newPacket)
 
void writePacket (JSON::Value &newPacket)
 
void writePacket (JSON::Value &newPacket)
 

Private Member Functions

void readHeader (int pos)
 Reads the header at the given file position. More...
 
void readHeader (int pos)
 

Private Attributes

void * buffer
 
bool created
 
std::set< seekPoscurrentPositions
 
int currframe
 
long long int currtime
 
long int endPos
 
FILE * F
 
unsigned long headerSize
 
long long int lastreadpos
 
Meta metadata
 
JSON::Value metaStorage
 
DTSC::Packet myPack
 
std::set< unsigned long > selectedTracks
 
std::map< unsigned int, std::string > trackMapping
 

Detailed Description

A simple wrapper class that will open a file and allow easy reading/writing of DTSC data from/to it.

Constructor & Destructor Documentation

DTSC::File::File ( )
DTSC::File::File ( const File rhs)
DTSC::File::File ( std::string  filename,
bool  create = false 
)

Open a filename for DTSC reading/writing.

If create is true and file does not exist, attempt to create.

DTSC::File::~File ( )

Close the file if open.

DTSC::File::File ( )
DTSC::File::File ( const File rhs)
DTSC::File::File ( std::string  filename,
bool  create = false 
)
DTSC::File::~File ( )

Member Function Documentation

long long int DTSC::File::addHeader ( std::string &  header)

Adds the given string as a new header to the end of the file.

Returns
The positon the header was written at, or 0 on failure.
long long int DTSC::File::addHeader ( std::string &  header)
bool DTSC::File::atKeyframe ( )
bool DTSC::File::atKeyframe ( )
long int DTSC::File::getBytePos ( )
long int DTSC::File::getBytePos ( )
long int DTSC::File::getBytePosEOF ( )
long int DTSC::File::getBytePosEOF ( )
long long int DTSC::File::getLastReadPos ( )
long long int DTSC::File::getLastReadPos ( )

Returns the byte positon of the start of the last packet that was read.

DTSC::Meta & DTSC::File::getMeta ( )

Returns the header metadata for this file as JSON::Value.

Meta& DTSC::File::getMeta ( )
DTSC::Packet& DTSC::File::getPacket ( )
DTSC::Packet & DTSC::File::getPacket ( )

Returns the internal buffer of the last read packet in raw binary format.

DTSC::File::operator bool ( ) const
DTSC::File::operator bool ( ) const
DTSC::File & DTSC::File::operator= ( const File rhs)
File& DTSC::File::operator= ( const File rhs)
void DTSC::File::parseNext ( )
void DTSC::File::parseNext ( )
bool DTSC::File::reachedEOF ( )
bool DTSC::File::reachedEOF ( )
void DTSC::File::readHeader ( int  pos)
private

Reads the header at the given file position.

If the packet could not be read for any reason, the reason is printed. Reading the header means the file position is moved to after the header.

void DTSC::File::readHeader ( int  pos)
private
void DTSC::File::rewritePacket ( std::string &  newPacket,
int  bytePos 
)
void DTSC::File::rewritePacket ( std::string &  newPacket,
int  bytePos 
)
bool DTSC::File::seek_bpos ( int  bpos)
bool DTSC::File::seek_bpos ( int  bpos)
bool DTSC::File::seek_time ( unsigned int  ms)
bool DTSC::File::seek_time ( unsigned int  ms)

Attempts to seek to the given time in ms within the file.

Returns true if successful, false otherwise.

bool DTSC::File::seek_time ( unsigned int  ms,
unsigned int  trackNo,
bool  forceSeek = false 
)
bool DTSC::File::seek_time ( unsigned int  ms,
unsigned int  trackNo,
bool  forceSeek = false 
)
void DTSC::File::seekNext ( )
void DTSC::File::seekNext ( )

Reads the packet available at the current file position.

If the packet could not be read for any reason, the reason is printed. Reading the packet means the file position is increased to the next packet.

void DTSC::File::selectTracks ( std::set< unsigned long > &  tracks)
void DTSC::File::selectTracks ( std::set< unsigned long > &  tracks)
bool DTSC::File::writeHeader ( std::string &  header,
bool  force = false 
)

(Re)writes the given string to the header area if the size is the same as the existing header.

Forces a write if force is set to true.

bool DTSC::File::writeHeader ( std::string &  header,
bool  force = false 
)
void DTSC::File::writePacket ( std::string &  newPacket)
void DTSC::File::writePacket ( std::string &  newPacket)
void DTSC::File::writePacket ( JSON::Value newPacket)
void DTSC::File::writePacket ( JSON::Value newPacket)

Field Documentation

void * DTSC::File::buffer
private
bool DTSC::File::created
private
std::set< seekPos > DTSC::File::currentPositions
private
int DTSC::File::currframe
private
long long int DTSC::File::currtime
private
long int DTSC::File::endPos
private
FILE * DTSC::File::F
private
unsigned long DTSC::File::headerSize
private
long long int DTSC::File::lastreadpos
private
Meta DTSC::File::metadata
private
JSON::Value DTSC::File::metaStorage
private
DTSC::Packet DTSC::File::myPack
private
std::set< unsigned long > DTSC::File::selectedTracks
private
std::map< unsigned int, std::string > DTSC::File::trackMapping
private

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