Ocean
Ocean::Media::Utilities Class Reference

This class implements utilities functions for the media library. More...

Public Types

typedef std::vector< uint8_t > Buffer
 Definition of a vector holding 8 bit elements. More...
 

Static Public Member Functions

static Frame loadImage (const std::string &url)
 Loads an image defined by the url and returns the frame. More...
 
static Frame loadImage (const void *imageBuffer, const size_t imageBufferSize, const std::string &imageBufferTypeIn=std::string(""), std::string *imageBufferTypeOut=nullptr)
 Loads an image defined by a memory buffer, the size of the buffer and the type of the stored image information. More...
 
static bool saveImage (const Frame &frame, const std::string &url, const bool addTimeSuffix=true)
 Saves a frame as image file. More...
 
static bool saveImage (const Frame &frame, const std::string &imageType, Buffer &buffer)
 Saves a frame into a memory buffer. More...
 
static void encodeFrame (const Frame &frame, const std::string &imageType, Buffer &buffer)
 Encodes a frame to a buffer and adds further control parameters to the buffer. More...
 
static Buffer encodeFrame (const Frame &frame, const std::string &imageType, const size_t reservedHeaderSize=0)
 Encodes a frame to a buffer and adds further control parameters to the buffer. More...
 
static bool decodeFrame (const uint8_t *&data, size_t &size, Frame &frame)
 Decodes a frame from a maintenance data buffer. More...
 
static bool decodeFrame (const Buffer &buffer, Frame &frame)
 Decodes a frame from a data buffer holding the compressed image content as well as further control parameters. More...
 

Detailed Description

This class implements utilities functions for the media library.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8_t> Ocean::Media::Utilities::Buffer

Definition of a vector holding 8 bit elements.

Member Function Documentation

◆ decodeFrame() [1/2]

bool Ocean::Media::Utilities::decodeFrame ( const Buffer buffer,
Frame frame 
)
inlinestatic

Decodes a frame from a data buffer holding the compressed image content as well as further control parameters.

Parameters
bufferThe buffer from which the frame will be decoded
frameThe resulting frame
Returns
True, if succeeded

◆ decodeFrame() [2/2]

static bool Ocean::Media::Utilities::decodeFrame ( const uint8_t *&  data,
size_t &  size,
Frame frame 
)
static

Decodes a frame from a maintenance data buffer.

Parameters
dataThe buffer providing the frame, will be shifted by the number of consumed bytes afterwards
sizeThe size of the entire buffer, will be reduced by the number of consumed bytes afterwards
frameThe resulting frame
Returns
True, if succeeded

◆ encodeFrame() [1/2]

static void Ocean::Media::Utilities::encodeFrame ( const Frame frame,
const std::string &  imageType,
Buffer buffer 
)
static

Encodes a frame to a buffer and adds further control parameters to the buffer.

Parameters
frameThe frame to encode
imageTypeOptional type of the image, e.g. bmp, jpg, png
bufferThe resulting buffer

◆ encodeFrame() [2/2]

Utilities::Buffer Ocean::Media::Utilities::encodeFrame ( const Frame frame,
const std::string &  imageType,
const size_t  reservedHeaderSize = 0 
)
inlinestatic

Encodes a frame to a buffer and adds further control parameters to the buffer.

Parameters
frameThe frame to encode
imageTypeOptional type of the image, e.g. bmp, jpg, png
reservedHeaderSizeThe number of bytes which will be reserved for an optional header, so that the resulting buffer has a header followed by the payload data
Returns
The resulting buffer

◆ loadImage() [1/2]

static Frame Ocean::Media::Utilities::loadImage ( const std::string &  url)
static

Loads an image defined by the url and returns the frame.

Beware: A media library supporting the image format must be loaded before.

Parameters
urlUrl of the image to be loaded
Returns
Resutling frame, the frame is Null if loading fails
See also
saveImage(), Manager, Library.

◆ loadImage() [2/2]

static Frame Ocean::Media::Utilities::loadImage ( const void *  imageBuffer,
const size_t  imageBufferSize,
const std::string &  imageBufferTypeIn = std::string(""),
std::string *  imageBufferTypeOut = nullptr 
)
static

Loads an image defined by a memory buffer, the size of the buffer and the type of the stored image information.

Beware: A media library supporting the image format must be loaded before.

Parameters
imageBufferBuffer of the image to be loaded
imageBufferSizeSize of the image buffer in bytes
imageBufferTypeInType of the given image that is stored in the buffer, should be specified if known (e.g. the file extension of a corresponding image file)
imageBufferTypeOutOptional type of the given image that is stored in the buffer, as determined by the decoder (if possible)
Returns
Resutling frame, the frame is Null if loading fails
See also
saveImage(), Manager, Library.

◆ saveImage() [1/2]

static bool Ocean::Media::Utilities::saveImage ( const Frame frame,
const std::string &  imageType,
Buffer buffer 
)
static

Saves a frame into a memory buffer.

Beware: A media library supporting the image format must be loaded before.

Parameters
frameThe frame to be saved as image
imageTypeType of the image to be created in the memory buffer e.g. the file extension of a corresponding image file (bmp, jpg, png, ...)
bufferResulting memory buffer holding the (compressed) image which will be extended so that already existing data stays untouched
Returns
True, if succeeded
See also
loadImage(), Manager, Library.

◆ saveImage() [2/2]

static bool Ocean::Media::Utilities::saveImage ( const Frame frame,
const std::string &  url,
const bool  addTimeSuffix = true 
)
static

Saves a frame as image file.

Beware: A media library supporting the image format must be loaded before.

Parameters
frameThe frame to be saved as image, must be valid
urlUrl of the image to be saved
addTimeSuffixIf True the time and date is added to the url as suffix
Returns
True, if succeeded
See also
loadImage(), Manager, Library.

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