StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Multimedia::Pipeline::Muxer Class Referencefinal

Writes interleaved packets to the Plan writer. More...

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

Inheritance diagram for StormByte::Multimedia::Pipeline::Muxer:
Collaboration diagram for StormByte::Multimedia::Pipeline::Muxer:

Public Member Functions

 operator bool () const noexcept
 true if the muxer has not failed and is Ready.
bool Closed () const noexcept
 true after Finish flushed the trailer, or after Fail.
StormByte::Safe::Optional< Property::Duration > Position () const
 Presentation time of the last packet written.
const Container & Destination () const noexcept
 Destination container.
bool Armed () const noexcept
 Whether every muxable Plan track has an output connection.
bool Ready () const noexcept override
 Open finished without Fail or Stop, and Armed.
StormByte::Size InputCeiling () const noexcept override
 Maximum number of queued input packets.
Lifecycle
 Muxer (StormByte::Safe::Shared< StormByte::Logger::Log > log)
 Muxer.
 Muxer (const Muxer &other)=delete
 Copy constructor (deleted).
 Muxer (Muxer &&other) noexcept=delete
 Move constructor (deleted).
 ~Muxer () noexcept override
 Destructor.
Muxer & operator= (const Muxer &other)=delete
 Copy assignment (deleted).
Muxer & operator= (Muxer &&other) noexcept=delete
 Move assignment (deleted).
Stream tags
StormByte::Safe::Optional< StormByte::Safe::String > Language (int output_index) const
 Language tag for mux output output_index.
void Language (int output_index, StormByte::Safe::String language)
 Sets the language tag for mux output output_index.
void RemoveLanguage (int output_index)
 Writes mux output output_index without a language tag.
StormByte::Safe::Optional< StormByte::Safe::String > Title (int output_index) const
 Title tag for mux output output_index.
void Title (int output_index, StormByte::Safe::String title)
 Sets the title tag for mux output output_index.
void RemoveTitle (int output_index)
 Writes mux output output_index without a title.
StormByte::Safe::Optional< StormByte::Multimedia::Metadata::Disposition > Disposition (int output_index) const
 Disposition for mux output output_index.
void Disposition (int output_index, StormByte::Multimedia::Metadata::Disposition disposition)
 Sets the disposition for mux output output_index.
File tags

Tags without an edit are copied from the source.

StormByte::Safe::Optional< StormByte::Safe::String > Tag (StormByte::Multimedia::Metadata::FileTag tag) const
 Edit of file tag tag.
void Tag (StormByte::Multimedia::Metadata::FileTag tag, StormByte::Safe::String value)
 Replaces file tag tag.
void RemoveTag (StormByte::Multimedia::Metadata::FileTag tag)
 Writes the output without file tag tag.
Public Member Functions inherited from StormByte::Multimedia::Pipeline::Step
 Step (const Step &other)=delete
 Copy construction is disabled.
 Step (Step &&other) noexcept=delete
 Move construction is disabled.
virtual ~Step () noexcept
 Destructor.
Step & operator= (const Step &other)=delete
 Copy assignment is disabled.
Step & operator= (Step &&other) noexcept=delete
 Move assignment is disabled.
void Wake () noexcept
 Notifies all waiters of this step.
StormByte::Safe::Shared< class Plan > Plan () const noexcept
 Bound job intention, if any.
const Kinds & Receives () const noexcept
 Kinds this step consumes.
const Kinds & Produces () const noexcept
 Kinds this step emits.
State Status () const noexcept
 Current lifecycle value.
StormByte::Safe::Shared< const StageTelemetry > Telemetry () const
 Shared stage counters, retained independently of this Step.
StormByte::Buffer::QueueSnapshot QueueSnapshot (int track) const noexcept
 Reads effective queue limits and logical-byte accounting.
void Stop () noexcept
 Requests shutdown and notifies connected stages.
bool Failed () const noexcept
 Whether this step has failed.
StormByte::Safe::Optional< StormByte::Safe::String > Error () const
 Failure text.
void Fail (StormByte::Safe::String reason) noexcept
 Marks the stage as failed and notifies connected stages.
void Fail () noexcept
 Marks failure without storing a message or allocating.
STORMBYTE_FORCE_INLINE void Fail (const char *reason) noexcept
 Copies a null-terminated failure literal into Safe storage.
void Fail (std::string_view reason) noexcept
 Copies borrowed failure text before calling the DLL-safe overload.

Friends

class Backend::Pipeline::Detail::Muxer::FFmpeg::Container
 Allows the FFmpeg container backend to access mux state.
class Backend::Pipeline::Muxer
 Allows the mux backend to access its owning stage.
class Backend::Pipeline::Detail::Worker::Mux
 Allows the mux worker to drive output and progress.
Encoder & operator>> (Encoder &encoder, Muxer &muxer)
 Allows encoder connections to reserve output tracks.
Muxer & operator>> (Demuxer &demuxer, Muxer &muxer)
 Allows demuxer connections to bind the remux origin.
Remuxer & operator>> (Remuxer &remuxer, Muxer &muxer)
 Allows remuxer connections to reserve output tracks.

Additional Inherited Members

Protected Member Functions inherited from StormByte::Multimedia::Pipeline::Step
bool Connect (Step &downstream) noexcept
 Registers a borrowed downstream stage and shares any bound plan.
bool WaitPlan () noexcept
 Waits interruptibly for the shared plan to enter Running.
Backend::Pipeline::Pipe & pipe () noexcept
const Backend::Pipeline::Pipe & pipe () const noexcept
 Step (StormByte::Safe::Shared< StormByte::Logger::Log > log, enum Producer name, Kinds receives, Kinds produces)
 Constructs a stage in State::Created.
void Emit (Item::PointerType item) noexcept
 Sends item to connected consumers.
Item::PointerType CloneItem (const Item &item) const
 Creates a distinct item through Item::Clone.
virtual void Wait () noexcept
 Waits until input is available, the stage fails or stops, or WakeNow.
virtual bool WakeNow () const noexcept
 Extra reason to leave Wait.
virtual void AfterWait () noexcept
 Work on the waiting worker after Wait unblocks.
void Launch () noexcept
 Starts stage initialization and processing.
void Halt () noexcept
 Stops the stage and waits for execution to finish.
bool Stopping () const noexcept
 Worker must return (Stop, Halt or Fail).
void RecordWork (std::int64_t microseconds) noexcept
 Adds one Process duration to the step summary.
std::int64_t LastWork () const noexcept
 Duration of the last timed Process, or 0.
void DumpWork () noexcept
 Writes min/max Process time at Debug.
Backend::Pipeline::Host & Face () noexcept
void Mount (StormByte::Safe::Unique< Backend::Pipeline::Pumper > pumper, StormByte::Safe::Unique< Backend::Pipeline::Worker > worker)
virtual StormByte::Safe::String Label () const
 Display name of this step.
Protected Attributes inherited from StormByte::Multimedia::Pipeline::Step
StormByte::Safe::Shared< StormByte::Logger::Log > m_log
 Scoped logger retained through Base-heap shared ownership.
enum Producer m_name
 UseLog leaf / default Label.
Kinds m_receives
 Receives.
Kinds m_produces
 Produces.

Detailed Description

Writes interleaved packets to the Plan writer.

Destination is the seekable writer owned by StormByte::Multimedia::Pipeline::Plan. The writer's path extension determines the destination container.

Does not write the container header until Armed is true. Armed is reserved muxable tracks versus the Plan, not a bound path. Ready is Status Ready and Armed.

Shares the Demuxer's Progress. Written packets advance output progress; completion includes the container trailer and flushing the destination writer.

Constructor & Destructor Documentation

◆ Muxer() [1/3]

Muxer.

Destination is the Plan writer.

Parameters
logShared logger. Empty pointer means no log.
Note
Starts execution immediately. Setup waits until encoder/remuxer connections reserve all muxable tracks required by the Plan, or the stage is stopped or fails.

◆ Muxer() [2/3]

Copy constructor (deleted).

Parameters
otherSource muxer.

◆ Muxer() [3/3]

Move constructor (deleted).

Parameters
otherSource muxer.

◆ ~Muxer()

StormByte::Multimedia::Pipeline::Muxer::~Muxer ( )
overridenoexcept

Destructor.

Step::Join Halts before backends die.

Member Function Documentation

◆ Armed()

bool StormByte::Multimedia::Pipeline::Muxer::Armed ( ) const
noexcept

Whether every muxable Plan track has an output connection.

Counts Video, Audio and Subtitle entries in Plan::Tracks. Attachments are written with the header, not as packet streams. true when connected tracks equal that count. false with no Plan, or while operator>> is still running.

Does not Fail. The owner of the graph (Filters::Close or Transcoder) checks this after wiring and Fails the Muxer if it is still false.

Returns
Arming state of the output graph.

◆ Closed()

bool StormByte::Multimedia::Pipeline::Muxer::Closed ( ) const
noexcept

true after Finish flushed the trailer, or after Fail.

Returns
Muxer will not accept more packets.

◆ Destination()

const Container & StormByte::Multimedia::Pipeline::Muxer::Destination ( ) const
noexcept

Destination container.

Returns
Registry container from the bound Plan.

◆ Disposition() [1/2]

StormByte::Safe::Optional< StormByte::Multimedia::Metadata::Disposition > StormByte::Multimedia::Pipeline::Muxer::Disposition ( int output_index) const

Disposition for mux output output_index.

Parameters
output_indexMux destination order key.
Returns
Flags, or empty to let the container policy choose.

◆ Disposition() [2/2]

void StormByte::Multimedia::Pipeline::Muxer::Disposition ( int output_index,
StormByte::Multimedia::Metadata::Disposition disposition )

Sets the disposition for mux output output_index.

Parameters
output_indexMux destination order key.
dispositionFlags written verbatim (default, forced, ...).

◆ InputCeiling()

StormByte::Size StormByte::Multimedia::Pipeline::Muxer::InputCeiling ( ) const
overridevirtualnoexcept

Maximum number of queued input packets.

The first muxable Plan track determines the limit. Returns zero before a Plan supplies a muxable track.

Returns
Max queued packets. Never 0 after a live Plan.

Reimplemented from StormByte::Multimedia::Pipeline::Step.

◆ Language() [1/2]

StormByte::Safe::Optional< StormByte::Safe::String > StormByte::Multimedia::Pipeline::Muxer::Language ( int output_index) const

Language tag for mux output output_index.

Parameters
output_indexMux destination order key.
Returns
Tag; engaged and empty when removed; disengaged when unset.

◆ Language() [2/2]

void StormByte::Multimedia::Pipeline::Muxer::Language ( int output_index,
StormByte::Safe::String language )

Sets the language tag for mux output output_index.

Parameters
output_indexMux destination order key.
languageBCP-47 / ISO tag. Empty clears.

◆ operator bool()

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

true if the muxer has not failed and is Ready.

Returns
Open and writable.

◆ operator=() [1/2]

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

Copy assignment (deleted).

Parameters
otherSource muxer.
Returns
*this.

◆ operator=() [2/2]

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

Move assignment (deleted).

Parameters
otherSource muxer.
Returns
*this.

◆ Position()

StormByte::Safe::Optional< Property::Duration > StormByte::Multimedia::Pipeline::Muxer::Position ( ) const

Presentation time of the last packet written.

Returns
Pts of the last video packet, or of audio if no video has been written yet.

◆ Ready()

bool StormByte::Multimedia::Pipeline::Muxer::Ready ( ) const
overridevirtualnoexcept

Open finished without Fail or Stop, and Armed.

Returns
Step Status is Ready and every muxable Plan track is reserved.

Reimplemented from StormByte::Multimedia::Pipeline::Step.

◆ RemoveLanguage()

void StormByte::Multimedia::Pipeline::Muxer::RemoveLanguage ( int output_index)

Writes mux output output_index without a language tag.

Parameters
output_indexMux destination order key.

◆ RemoveTag()

void StormByte::Multimedia::Pipeline::Muxer::RemoveTag ( StormByte::Multimedia::Metadata::FileTag tag)

Writes the output without file tag tag.

Parameters
tagFile tag.

◆ RemoveTitle()

void StormByte::Multimedia::Pipeline::Muxer::RemoveTitle ( int output_index)

Writes mux output output_index without a title.

Parameters
output_indexMux destination order key.

◆ Tag() [1/2]

StormByte::Safe::Optional< StormByte::Safe::String > StormByte::Multimedia::Pipeline::Muxer::Tag ( StormByte::Multimedia::Metadata::FileTag tag) const

Edit of file tag tag.

Parameters
tagFile tag.
Returns
Value; engaged and empty when removed; disengaged keeps the source.

◆ Tag() [2/2]

void StormByte::Multimedia::Pipeline::Muxer::Tag ( StormByte::Multimedia::Metadata::FileTag tag,
StormByte::Safe::String value )

Replaces file tag tag.

Track and Disc are written verbatim, so "3" and "3/12" both work.

Parameters
tagFile tag.
valueNew value. Empty keeps the source value.

◆ Title() [1/2]

StormByte::Safe::Optional< StormByte::Safe::String > StormByte::Multimedia::Pipeline::Muxer::Title ( int output_index) const

Title tag for mux output output_index.

Parameters
output_indexMux destination order key.
Returns
Title; engaged and empty when removed; disengaged when unset.

◆ Title() [2/2]

void StormByte::Multimedia::Pipeline::Muxer::Title ( int output_index,
StormByte::Safe::String title )

Sets the title tag for mux output output_index.

Parameters
output_indexMux destination order key.
titleStream title. Empty clears.

◆ Backend::Pipeline::Detail::Muxer::FFmpeg::Container

friend class Backend::Pipeline::Detail::Muxer::FFmpeg::Container
friend

Allows the FFmpeg container backend to access mux state.

◆ Backend::Pipeline::Detail::Worker::Mux

friend class Backend::Pipeline::Detail::Worker::Mux
friend

Allows the mux worker to drive output and progress.

◆ Backend::Pipeline::Muxer

friend class Backend::Pipeline::Muxer
friend

Allows the mux backend to access its owning stage.

◆ operator>> [1/3]

Muxer & operator>> ( Demuxer & demuxer,
Muxer & muxer )
friend

Allows demuxer connections to bind the remux origin.

Parameters
demuxerOrigin demuxer.
muxerDestination.
Returns
Destination muxer.

Required when any remux track is reserved. Without it the muxer cannot clone origin codec parameters. Also shares the tube Progress clock. Does not open the writer during connection. There is no file >> muxer and no muxer >> path.

Parameters
demuxerOrigin demuxer. Must outlive header write.
muxerDestination.
Returns
muxer.

◆ operator>> [2/3]

Encoder & operator>> ( Encoder & encoder,
Muxer & muxer )
friend

Allows encoder connections to reserve output tracks.

Parameters
encoderLive encoder.
muxerDestination.
Returns
Connected encoder.
Parameters
encoderLive encoder.
muxerDestination.
Returns
encoder.
Registers a borrowed graph edge and binds the typed packet lane,
even without a Plan. Backend reservation and writer opening are
deferred until Setup observes a running Plan.

◆ operator>> [3/3]

Remuxer & operator>> ( Remuxer & remuxer,
Muxer & muxer )
friend

Allows remuxer connections to reserve output tracks.

Parameters
remuxerLive remuxer.
muxerDestination.
Returns
Connected remuxer.
Parameters
remuxerLive remuxer.
muxerDestination.
Returns
remuxer.
Registers a borrowed graph edge and binds the typed packet lane,
even without a Plan. Backend reservation and writer opening are
deferred until Setup observes a running Plan.

The documentation for this class was generated from the following file:
  • lib/public/StormByte/multimedia/pipeline/muxer.hxx