StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
Classes | Protected Member Functions | Friends | List of all members
StormByte::Multimedia::Pipeline::Transcoder Class Reference

Facade that maps tracks and runs one file-to-file job. More...

#include <StormByte/multimedia/pipeline/transcoder.hxx>

Classes

class  Track
 Fluent handle for one origin stream in this job. More...
 

Public Member Functions

Lifecycle
 Transcoder (std::shared_ptr< StormByte::Logger::Log > logger, File &&file) noexcept
 Constructs an empty job.
 
 Transcoder (const Transcoder &other)=delete
 Copy constructor.
 
 Transcoder (Transcoder &&other) noexcept=delete
 Move constructor.
 
virtual ~Transcoder () noexcept
 Destructor.
 
Transcoderoperator= (const Transcoder &other)=delete
 Copy assignment.
 
Transcoderoperator= (Transcoder &&other) noexcept=delete
 Move assignment.
 
Source
const FileSource () const noexcept
 Opened source file.
 
const std::shared_ptr< StormByte::Logger::Log > & Logger () const noexcept
 Logger used by this job after InstallLog.
 
const std::shared_ptr< class Plan > & Plan () const noexcept
 Intention built for this job, if any.
 
Map
Track Video (int in) noexcept
 Maps a video origin stream.
 
Track Audio (int in) noexcept
 Maps an audio origin stream.
 
Track Subtitle (int in) noexcept
 Maps a subtitle origin stream.
 
TranscoderAttachments () noexcept
 Keeps every attachment from the source File.
 
TranscoderAttachments (std::string_view mime) noexcept
 Keeps source attachments whose MIME equals mime.
 
TranscoderIgnore (int in) noexcept
 Drops an origin stream (omit from the Plan).
 
template<typename FilterType , typename... Args>
TranscoderFilter (Args &&... args) noexcept
 Appends a global analytics filter.
 
TranscoderDestination (const Container &container, std::filesystem::path path) noexcept
 Sets the destination container and path.
 
Run
void Run () noexcept
 Builds the Plan, starts the coordinator and returns.
 
void Cancel () noexcept
 Requests abort.
 
void Pause () noexcept
 Pauses the coordinator.
 
void Resume () noexcept
 Resumes after Pause.
 
enum Status Status () const noexcept
 Current lifecycle value.
 
bool Failed () const noexcept
 Whether the job failed.
 
std::optional< std::string > Error () const noexcept
 Failure text.
 
std::optional< unsigned > Progress () const noexcept
 Last published percent.
 
std::vector< std::pair< std::string, Filter::Report > > Reports () const noexcept
 Analytics snapshots after the job is Idle.
 
 operator bool () const noexcept
 true if not failed.
 

Static Public Member Functions

Open
static ExpectedTranscoder Open (std::shared_ptr< StormByte::Logger::Log > logger, const std::filesystem::path &source, const std::filesystem::path &destination, std::optional< std::chrono::nanoseconds > duration=std::nullopt) noexcept
 Opens source and binds destination.
 

Protected Member Functions

virtual void InstallLog () noexcept
 Scopes this job's own logger.
 
const std::shared_ptr< StormByte::Logger::Log > & ApplicationLog () const noexcept
 Application logger passed to Open.
 
virtual std::unique_ptr< class PlanEmptyPlan (File &&source, const Container &container, std::filesystem::path destination) const noexcept
 Allocates the Plan type for this job.
 
virtual std::unique_ptr< TrackSettledEmptySettled () const noexcept
 Allocates the settled-row type.
 
virtual void OnConfigure () noexcept
 Last chance to raise ceilings before the job starts.
 
virtual enum Status OnStart () noexcept
 Gate after the Plan is filled and Destination is set.
 
virtual void OnPlan (const class Plan &plan) noexcept
 Intention, just before plan >> demuxer.
 
virtual void OnSettled (const TrackSettled &track) noexcept
 One encode lane finished Encoder open.
 
virtual void OnProgress (unsigned percent) noexcept
 Progress tick.
 
virtual void OnDone () noexcept
 Successful flush.
 
virtual void OnError (const std::string &message) noexcept
 Hard error.
 
virtual void OnAborted () noexcept
 Cancel completed.
 

Friends

class Backend::Pipeline::Transcoder
 
class Track
 

Detailed Description

Facade that maps tracks and runs one file-to-file job.

Connects operator>> and Filters for you. The stock class is a complete job: open a File, choose origin streams, remux or encode each one, write another file. You do not have to derive anything to transcode.

It is also the extension point. Nothing in the extra surface is required. Mix what you need:

EmptyPlan / EmptySettled only pick the dynamic type. This class still fills tracks from the fluent map and settled fields from the opened Encoder. One instance is one source and one destination; another job is another instance.

Mux order is the order of Video / Audio / Subtitle / Attachments calls. There is no output-index argument.

Analytics attach with Filter. After the job reaches Status::Done, Reports returns the same snapshots a hand tube reads with Filter::Analytics::Report on the leaf pointer. The Notice line from a leaf is log, not the API.

Open applies InstallLog after the most-derived constructor. Stock InstallLog scopes this job at StormByte/Multimedia/Transcoder and applies the Multimedia format ([L] T c) and throttle (Window on LowLevel, Drop on Debug and Notice). There is no STMM component. A derived Open that constructs a subclass must call InstallLog itself after that constructor.

Constructor & Destructor Documentation

◆ Transcoder() [1/3]

StormByte::Multimedia::Pipeline::Transcoder::Transcoder ( std::shared_ptr< StormByte::Logger::Log >  logger,
File &&  file 
)
noexcept

Constructs an empty job.

Only Open / derived classes.

Parameters
loggerRequired application logger.
fileOpened source (moved).

Stores logger as-is. InstallLog runs after the most-derived constructor.

◆ Transcoder() [2/3]

Copy constructor.

Parameters
otherSource job.

◆ Transcoder() [3/3]

Move constructor.

Parameters
otherJob to take.

◆ ~Transcoder()

virtual StormByte::Multimedia::Pipeline::Transcoder::~Transcoder ( )
virtualnoexcept

Destructor.

Stops the coordinator and joins.

Member Function Documentation

◆ ApplicationLog()

const std::shared_ptr< StormByte::Logger::Log > & StormByte::Multimedia::Pipeline::Transcoder::ApplicationLog ( ) const
inlineprotectednoexcept

Application logger passed to Open.

Returns
Logger given to the constructor, not the job facade.

Hand this to a Step or filter. Those apply the Multimedia stage path themselves.

◆ Attachments() [1/2]

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::Attachments ( )
noexcept

Keeps every attachment from the source File.

Returns
*this.

Each source slot becomes a Plan track with Config::Attachment and the concrete MIME. Default is drop (do not call this).

◆ Attachments() [2/2]

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::Attachments ( std::string_view  mime)
noexcept

Keeps source attachments whose MIME equals mime.

Parameters
mimeConcrete MIME (image/jpeg). Not a wildcard.
Returns
*this.

◆ Audio()

Track StormByte::Multimedia::Pipeline::Transcoder::Audio ( int  in)
noexcept

Maps an audio origin stream.

Mux order is Add order.

Parameters
inOrigin stream index.
Returns
Fluent handle.

◆ Cancel()

void StormByte::Multimedia::Pipeline::Transcoder::Cancel ( )
noexcept

Requests abort.

Coordinator ends in Status::Aborted.

◆ Destination()

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::Destination ( const Container container,
std::filesystem::path  path 
)
noexcept

Sets the destination container and path.

Parameters
containerRegistry destination container.
pathOutput path.
Returns
*this.

Required before Run. Closes the job identity together with the File from Open.

◆ EmptyPlan()

virtual std::unique_ptr< class Plan > StormByte::Multimedia::Pipeline::Transcoder::EmptyPlan ( File &&  source,
const Container container,
std::filesystem::path  destination 
) const
protectedvirtualnoexcept

Allocates the Plan type for this job.

Parameters
sourceOrigin File (moved).
containerDestination container.
destinationOutput path.
Returns
Plan of the desired dynamic type, with no tracks yet.

Override to return a type derived from Plan. Tracks are filled from the fluent map after this returns.

◆ EmptySettled()

virtual std::unique_ptr< TrackSettled > StormByte::Multimedia::Pipeline::Transcoder::EmptySettled ( ) const
protectedvirtualnoexcept

Allocates the settled-row type.

Returns
Empty row of the desired dynamic type.

Override to return a type derived from TrackSettled. MarkSettled fills it and calls OnSettled.

◆ Error()

std::optional< std::string > StormByte::Multimedia::Pipeline::Transcoder::Error ( ) const
noexcept

Failure text.

Returns
Message, or empty.

◆ Failed()

bool StormByte::Multimedia::Pipeline::Transcoder::Failed ( ) const
noexcept

Whether the job failed.

Returns
true after Status::Error.

◆ Filter()

template<typename FilterType , typename... Args>
Transcoder & StormByte::Multimedia::Pipeline::Transcoder::Filter ( Args &&...  args)
inlinenoexcept

Appends a global analytics filter.

One node, every matching stretch.

Template Parameters
FilterTypeChild of Filter::Analytics.
Parameters
argsConstructor arguments, forwarded.
Returns
*this.

Track-scoped analytics attach on Track::Filter. Both are allowed; there is no dedup.

◆ Ignore()

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::Ignore ( int  in)
noexcept

Drops an origin stream (omit from the Plan).

Parameters
inOrigin stream index.
Returns
*this.

◆ InstallLog()

virtual void StormByte::Multimedia::Pipeline::Transcoder::InstallLog ( )
protectedvirtualnoexcept

Scopes this job's own logger.

Stock path is StormByte/Multimedia/Transcoder with the Multimedia format and throttle. Override to use another path and other rules. Tube stages still use StormByte/Multimedia/<stage>. Do not call from a constructor. Open calls this after the most-derived constructor.

◆ Logger()

const std::shared_ptr< StormByte::Logger::Log > & StormByte::Multimedia::Pipeline::Transcoder::Logger ( ) const
noexcept

Logger used by this job after InstallLog.

Returns
Job facade, or empty.

Stock path is StormByte/Multimedia/Transcoder. Do not pass this pointer to a Step or filter; those use the application logger and the Multimedia stage path.

◆ OnAborted()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnAborted ( )
protectedvirtualnoexcept

Cancel completed.

◆ OnConfigure()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnConfigure ( )
protectedvirtualnoexcept

Last chance to raise ceilings before the job starts.

◆ OnDone()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnDone ( )
protectedvirtualnoexcept

Successful flush.

◆ OnError()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnError ( const std::string &  message)
protectedvirtualnoexcept

Hard error.

Parameters
messageError text.

◆ OnPlan()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnPlan ( const class Plan plan)
protectedvirtualnoexcept

Intention, just before plan >> demuxer.

Parameters
planFilled Plan (still owned by this job).

◆ OnProgress()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnProgress ( unsigned  percent)
protectedvirtualnoexcept

Progress tick.

Parameters
percent0..100.

◆ OnSettled()

virtual void StormByte::Multimedia::Pipeline::Transcoder::OnSettled ( const TrackSettled track)
protectedvirtualnoexcept

One encode lane finished Encoder open.

Parameters
trackSettled row from EmptySettled.

◆ OnStart()

virtual enum Status StormByte::Multimedia::Pipeline::Transcoder::OnStart ( )
protectedvirtualnoexcept

Gate after the Plan is filled and Destination is set.

Returns
Running to proceed, Error / Aborted / Stopped to bail.

◆ Open()

static ExpectedTranscoder StormByte::Multimedia::Pipeline::Transcoder::Open ( std::shared_ptr< StormByte::Logger::Log >  logger,
const std::filesystem::path &  source,
const std::filesystem::path &  destination,
std::optional< std::chrono::nanoseconds >  duration = std::nullopt 
)
staticnoexcept

Opens source and binds destination.

Parameters
loggerRequired logger.
sourceInput path.
destinationOutput path.
durationAuthoritative container duration, if known. Empty runs the normal probe. A value skips the packet scan.
Returns
Job, or unexpected.

Shorthand for File::Open plus the public constructor. The destination container is still set with Destination before Run. Stock Open constructs Transcoder and calls InstallLog. A derived Open that constructs a subclass must call InstallLog after that constructor.

◆ operator bool()

StormByte::Multimedia::Pipeline::Transcoder::operator bool ( ) const
explicitnoexcept

true if not failed.

Returns
Not Failed.

◆ operator=() [1/2]

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::operator= ( const Transcoder other)
delete

Copy assignment.

Parameters
otherSource job.
Returns
*this.

◆ operator=() [2/2]

Transcoder & StormByte::Multimedia::Pipeline::Transcoder::operator= ( Transcoder &&  other)
deletenoexcept

Move assignment.

Parameters
otherJob to take.
Returns
*this.

◆ Pause()

void StormByte::Multimedia::Pipeline::Transcoder::Pause ( )
noexcept

Pauses the coordinator.

◆ Plan()

const std::shared_ptr< class Plan > & StormByte::Multimedia::Pipeline::Transcoder::Plan ( ) const
inlinenoexcept

Intention built for this job, if any.

Returns
Plan, or empty before Destination / Run.

◆ Progress()

std::optional< unsigned > StormByte::Multimedia::Pipeline::Transcoder::Progress ( ) const
noexcept

Last published percent.

Returns
0..100, or empty before the first tick.

◆ Reports()

std::vector< std::pair< std::string, Filter::Report > > StormByte::Multimedia::Pipeline::Transcoder::Reports ( ) const
noexcept

Analytics snapshots after the job is Idle.

Returns
Pair of flattened key (vmaf[0], vmaf[general], vmaf[0]#2 on an exact-key repeat) and Filter::Report.

Track-scoped leaves use the origin index. Global Add uses general. Same contract as Filters::Reports. Snapshots only; the leaves stay owned by the job. Meaningful after Status::Done. A low score is still Ok. Notice lines from a leaf are log, not this API.

◆ Resume()

void StormByte::Multimedia::Pipeline::Transcoder::Resume ( )
noexcept

Resumes after Pause.

◆ Run()

void StormByte::Multimedia::Pipeline::Transcoder::Run ( )
noexcept

Builds the Plan, starts the coordinator and returns.

Calls OnConfigure, EmptyPlan, fills tracks from the fluent map, OnPlan, OnStart, then plan >> demuxer. Does not block until Done.

◆ Source()

const File & StormByte::Multimedia::Pipeline::Transcoder::Source ( ) const
noexcept

Opened source file.

Returns
File snapshot.

After Run hands the File to the Plan, this is Plan::Source().

◆ Status()

enum Status StormByte::Multimedia::Pipeline::Transcoder::Status ( ) const
noexcept

Current lifecycle value.

Returns
Status.

◆ Subtitle()

Track StormByte::Multimedia::Pipeline::Transcoder::Subtitle ( int  in)
noexcept

Maps a subtitle origin stream.

Mux order is Add order.

Parameters
inOrigin stream index.
Returns
Fluent handle.

◆ Video()

Track StormByte::Multimedia::Pipeline::Transcoder::Video ( int  in)
noexcept

Maps a video origin stream.

Mux order is Add order.

Parameters
inOrigin stream index.
Returns
Fluent handle.

Friends And Related Symbol Documentation

◆ Backend::Pipeline::Transcoder

friend class Backend::Pipeline::Transcoder
friend

◆ Track

friend class Track
friend

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