Databases

CTheater

Store JPEG-compressed movie frames and metadata, then export encoded video.

C++23 mc/CTheater.h
#include <mc/CTheater.h>

Frames use tightly packed four-channel image data. Keep the source frame valid for the duration of addFrame().

Video export requires ffmpeg available to the process. simultaneousEncoders limits concurrent encoders.

Jump to a declaration · 13

CTheater

class CTheater

Types, constants & data

using Id = uint32_t;

Methods

CTheater

CTheater(const cstr& path, bool create, size_t simultaneousEncoders = 3);
CTheater(const CTheater&) = delete;

Creates a new movie collection directory when create is true, or reopens an existing collection otherwise. simultaneousEncoders must be positive and limits concurrent exports.

createMovie

Id createMovie(size_t width, size_t height, size_t quality = 50, const cvar& metadata = cnull);

Creates a movie and returns its ID. Quality controls JPEG frame storage; metadata is stored with the movie.

getMovies

cvec getMovies();

Returns stored movie metadata records, including their assigned IDs, sizes, and JPEG quality. The result owns its values.

movieInfo

cvar movieInfo(Id movieId);

Returns a movie’s metadata with #id, #size, and #quality fields. An unknown movie ID raises CError.

addFrame

void addFrame(Id movieId, unsigned char* frame, const cvar& metadata = cnone);

Appends a JPEG-compressed frame and optional metadata, assigning the next zero-based frame index. The source must contain the movie’s full tightly packed four-channel bitmap and remain valid until the call returns.

encode

void encode(Id movieId, const cstr& path, size_t fps, size_t bitrate = 100000);

Exports H.264 video through ffmpeg and waits for completion. FPS and bitrate must be positive; bitrate is in kilobits per second, dimensions must be even, and an existing output file is not replaced.

deleteMovie

void deleteMovie(Id movieId);

Removes the movie and all of its stored frames. An unknown movie ID is a no-op.

getFrame

unsigned char* getFrame(Id movieId, size_t frame, cvar& metadata);
bool getFrame(Id movieId, size_t frame, unsigned char* buf, cvar& metadata);

The pointer overload returns caller-owned decoded pixels released with free(), or nullptr for a missing frame. The buffer overload requires width × height × 4 bytes and returns false when absent. Missing frames leave metadata and caller-buffer outputs unchanged.

compact

void compact();

Rewrites the movie and frame tables to reclaim unused storage. This is an explicit maintenance operation rather than part of frame playback.